private void insertOrAppend() { Date now = DateUtil.now(); DubboMethodDayIP day = new DubboMethodDayIP( "LZY5", "com.lvmama.test.soa.monitor.DubboMethodDayIPServiceTest", "testInsertOrAppend", "111.333.555.777", "222.444.666.888", DateUtil.trimToDay(now)); day.setSuccessTimes(10L); day.setFailTimes(1L); day.setElapsedAvg(BigDecimal.valueOf(2L)); day.setElapsedMax(5L); day.setSuccessTimesDetail( DateUtil.HHmm(now) + " " + day.getSuccessTimes() + StringUtil.getLineSeparator()); day.setFailTimesDetail( DateUtil.HHmm(now) + " " + day.getFailTimes() + StringUtil.getLineSeparator()); day.setElapsedTotalDetail( DateUtil.HHmm(now) + " " + day.getElapsedAvg().multiply(BigDecimal.valueOf(day.getSuccessTimes())) + StringUtil.getLineSeparator()); day.setElapsedMaxDetail( DateUtil.HHmm(now) + " " + day.getElapsedMax() + StringUtil.getLineSeparator()); for (int i = 1; i <= 10; i++) { dubboMethodDayIPService.insertOrAppend(day); dubboMethodDayIPDao.insert(day); } }
@Override public String getTargetTableName(String baseTableName, Object params, String mapperId) { if (params == null) { return baseTableName; } if (baseTableName == null || !BASE_TABLE_NAMES_FOR_SHARD.contains(baseTableName.toUpperCase())) { return baseTableName; } String targetTableName = baseTableName; if (params instanceof DubboMethodDayIP) { DubboMethodDayIP day = (DubboMethodDayIP) params; String appName = day.getAppName(); if (!StringUtil.isEmpty(appName)) { targetTableName = baseTableName + "_" + appName.toString().toUpperCase(); } } else if (params instanceof Map) { Map map = (Map) params; Object appName = map.get("appName"); if (appName != null && !StringUtil.isEmpty(appName.toString())) { targetTableName = baseTableName + "_" + appName.toString().toUpperCase(); } } if (!existsTableNames.contains(targetTableName)) { if (!isTableExists(targetTableName)) { createTable(targetTableName); } existsTableNames.add(targetTableName); } return targetTableName; }