Skip to content

Commit

Permalink
Merge pull request alibaba#73 from hxy1991/master
Browse files Browse the repository at this point in the history
Eliminate warnings: Redundant array creation for calling varargs method
  • Loading branch information
hxy1991 authored Sep 30, 2018
2 parents 2729376 + 04045be commit cfb96d8
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public String doGetConfig(HttpServletRequest request, HttpServletResponse respon
Channels.newChannel(response.getOutputStream()));
}

LogUtil.pullCheckLog.warn("{}|{}|{}|{}", new Object[]{groupKey,requestIp,md5, TimeUtils.getCurrentTimeStr()});
LogUtil.pullCheckLog.warn("{}|{}|{}|{}", groupKey,requestIp,md5, TimeUtils.getCurrentTimeStr());


final long delayed = System.currentTimeMillis() - lastModified;
Expand All @@ -275,7 +275,7 @@ public String doGetConfig(HttpServletRequest request, HttpServletResponse respon

} else {

pullLog.info("[client-get] clientIp={}, {}, get data during dump", new Object[]{clientIp, groupKey});
pullLog.info("[client-get] clientIp={}, {}, get data during dump", clientIp, groupKey);

response.setStatus(HttpServletResponse.SC_CONFLICT);
response.getWriter().println("requested file is being modified, please try later.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ public void run() {
int groupCount = ConfigService.groupCount();
int subClientCount = ClientTrackService.subscribeClientCount();
long subCount = ClientTrackService.subscriberCount();
memoryLog.info("groupCount={}, subscriberClientCount={}, subscriberCount={}",
new Object[] { groupCount, subClientCount, subCount });
memoryLog.info("groupCount={}, subscriberClientCount={}, subscriberCount={}", groupCount, subClientCount, subCount);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ static public boolean dump(String dataId, String group, String tenant, String co
final String md5 = MD5.getInstance().getMD5String(content);
if (md5.equals(ConfigService.getContentMd5(groupKey))) {
dumpLog.warn(
"[dump-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, lastModifiedNew={}",
new Object[] { groupKey, md5, ConfigService.getLastModifiedTs(groupKey), lastModifiedTs });
"[dump-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, "
+ "lastModifiedNew={}",
groupKey, md5, ConfigService.getLastModifiedTs(groupKey), lastModifiedTs);
} else if (!PropertyUtil.isStandaloneMode()) {
DiskUtil.saveToDisk(dataId, group, tenant, content);
}
Expand Down Expand Up @@ -121,7 +122,10 @@ static public boolean dumpBeta(String dataId, String group, String tenant, Strin
try {
final String md5 = MD5.getInstance().getMD5String(content);
if(md5.equals(ConfigService.getContentBetaMd5(groupKey))) {
dumpLog.warn("[dump-beta-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, lastModifiedNew={}", new Object[]{groupKey, md5, ConfigService.getLastModifiedTs(groupKey), lastModifiedTs});
dumpLog.warn(
"[dump-beta-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, "
+ "lastModifiedNew={}",
groupKey, md5, ConfigService.getLastModifiedTs(groupKey), lastModifiedTs);
} else if (!PropertyUtil.isStandaloneMode()) {
DiskUtil.saveBetaToDisk(dataId, group, tenant, content);
}
Expand Down Expand Up @@ -156,7 +160,10 @@ static public boolean dumpTag(String dataId, String group, String tenant, String
try {
final String md5 = MD5.getInstance().getMD5String(content);
if(md5.equals(ConfigService.getContentTagMd5(groupKey,tag))) {
dumpLog.warn("[dump-tag-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, lastModifiedNew={}", new Object[]{groupKey, md5, ConfigService.getLastModifiedTs(groupKey), lastModifiedTs});
dumpLog.warn(
"[dump-tag-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, "
+ "lastModifiedNew={}",
groupKey, md5, ConfigService.getLastModifiedTs(groupKey), lastModifiedTs);
} else if (!PropertyUtil.isStandaloneMode()) {
DiskUtil.saveTagToDisk(dataId, group, tenant, tag, content);
}
Expand Down Expand Up @@ -192,7 +199,10 @@ static public boolean dumpChange(String dataId, String group, String tenant, Str
if (!PropertyUtil.isStandaloneMode()) {
String loacalMd5 = DiskUtil.getLocalConfigMd5(dataId, group, tenant);
if(md5.equals(loacalMd5)) {
dumpLog.warn("[dump-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, lastModifiedNew={}", new Object[]{groupKey, md5, ConfigService.getLastModifiedTs(groupKey), lastModifiedTs});
dumpLog.warn(
"[dump-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, "
+ "lastModifiedNew={}",
groupKey, md5, ConfigService.getLastModifiedTs(groupKey), lastModifiedTs);
} else {
DiskUtil.saveToDisk(dataId, group, tenant, content);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ public void addLongPullingClient(HttpServletRequest req, HttpServletResponse rsp
if (changedGroups.size() > 0) {
generateResponse(req, rsp, changedGroups);
LogUtil.clientLog.info("{}|{}|{}|{}|{}|{}|{}",
new Object[]{System.currentTimeMillis() - start, "instant", RequestUtil.getRemoteIp(req), "polling",
clientMd5Map.size(), probeRequestSize, changedGroups.size()});
System.currentTimeMillis() - start, "instant", RequestUtil.getRemoteIp(req), "polling",
clientMd5Map.size(), probeRequestSize, changedGroups.size());
return;
} else if(noHangUpFlag!=null && noHangUpFlag.equalsIgnoreCase(TRUE_STR)) {
LogUtil.clientLog.info("{}|{}|{}|{}|{}|{}|{}",
new Object[]{System.currentTimeMillis() - start, "nohangup", RequestUtil.getRemoteIp(req), "polling",
clientMd5Map.size(), probeRequestSize, changedGroups.size()});
LogUtil.clientLog.info("{}|{}|{}|{}|{}|{}|{}", System.currentTimeMillis() - start, "nohangup",
RequestUtil.getRemoteIp(req), "polling", clientMd5Map.size(), probeRequestSize,
changedGroups.size());
return;
}
}
Expand Down Expand Up @@ -335,9 +335,10 @@ public void run() {
getRetainIps().put(clientSub.ip, System.currentTimeMillis());
iter.remove(); // 删除订阅关系
LogUtil.clientLog.info("{}|{}|{}|{}|{}|{}|{}",
new Object[]{(System.currentTimeMillis() - changeTime),
"in-advance", RequestUtil.getRemoteIp((HttpServletRequest) clientSub.asyncContext.getRequest()), "polling",
clientSub.clientMd5Map.size(), clientSub.probeRequestSize, groupKey});
(System.currentTimeMillis() - changeTime),
"in-advance", RequestUtil.getRemoteIp((HttpServletRequest) clientSub.asyncContext.getRequest()),
"polling",
clientSub.clientMd5Map.size(), clientSub.probeRequestSize, groupKey);
clientSub.sendResponse(Arrays.asList(groupKey));
}
}
Expand Down Expand Up @@ -394,9 +395,10 @@ public void run() {

if(isFixedPolling()) {
LogUtil.clientLog.info("{}|{}|{}|{}|{}|{}",
new Object[]{(System.currentTimeMillis() - createTime),
"fix", RequestUtil.getRemoteIp((HttpServletRequest) asyncContext.getRequest()), "polling",
clientMd5Map.size(), probeRequestSize});
(System.currentTimeMillis() - createTime),
"fix", RequestUtil.getRemoteIp((HttpServletRequest) asyncContext.getRequest()),
"polling",
clientMd5Map.size(), probeRequestSize);
List<String> changedGroups = MD5Util.compareMd5((HttpServletRequest) asyncContext.getRequest(), (HttpServletResponse) asyncContext.getResponse(), clientMd5Map);
if (changedGroups.size() > 0) {
sendResponse(changedGroups);
Expand All @@ -405,9 +407,10 @@ public void run() {
}
} else {
LogUtil.clientLog.info("{}|{}|{}|{}|{}|{}",
new Object[]{(System.currentTimeMillis() - createTime),
"timeout", RequestUtil.getRemoteIp((HttpServletRequest) asyncContext.getRequest()), "polling",
clientMd5Map.size(), probeRequestSize});
(System.currentTimeMillis() - createTime),
"timeout", RequestUtil.getRemoteIp((HttpServletRequest) asyncContext.getRequest()),
"polling",
clientMd5Map.size(), probeRequestSize);
sendResponse(null);
}
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static boolean getSwitchBoolean(String key, boolean defaultValue) {
rtn = value != null ? Boolean.valueOf(value).booleanValue() : defaultValue;
} catch (Exception e) {
rtn = defaultValue;
LogUtil.fatalLog.error("corrupt switch value {}={}", new Object[]{key, switches.get(key)});
LogUtil.fatalLog.error("corrupt switch value {}={}", key, switches.get(key));
}
return rtn;
}
Expand All @@ -64,7 +64,7 @@ public static int getSwitchInteger(String key, int defaultValue) {
rtn = status != null ? Integer.parseInt(status) : defaultValue;
} catch (Exception e) {
rtn = defaultValue;
LogUtil.fatalLog.error("corrupt switch value {}={}", new Object[]{key, switches.get(key)});
LogUtil.fatalLog.error("corrupt switch value {}={}", key, switches.get(key));
}
return rtn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ public void run() {
this.isSuccess = PROCESSOR.process(GroupKey2.getKey(getDataId(), getGroup()), this);
} catch (Exception e) { // never goes here, but in case (运行中never中断此通知线程)
this.isSuccess = false;
LogUtil.notifyLog.error("[notify-exception] target:{} dataid:{} group:{} ts:{}", new Object[]{target, getDataId(), getGroup(), getLastModified()});
LogUtil.notifyLog.error("[notify-exception] target:{} dataid:{} group:{} ts:{}", target, getDataId(),
getGroup(), getLastModified());
LogUtil.notifyLog.debug("[notify-exception] target:{} dataid:{} group:{} ts:{}",
new Object[] { target, getDataId(), getGroup(), getLastModified() }, e);
}

if (!this.isSuccess) {
LogUtil.notifyLog.error("[notify-retry] target:{} dataid:{} group:{} ts:{}", new Object[]{target, getDataId(), getGroup(), getLastModified()});
LogUtil.notifyLog.error("[notify-retry] target:{} dataid:{} group:{} ts:{}", target, getDataId(),
getGroup(), getLastModified());
try {
((ScheduledThreadPoolExecutor) executor).schedule(this, 500L, TimeUnit.MILLISECONDS);
} catch (Exception e) { // 通知虽然失败,但是同时此前节点也下线了
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public static void logPersistenceEvent(String dataId, String group, String tenan
}
//localIp | dataid | group | tenant | requestIpAppName | ts | handleIp | event | type | [delayed = -1] | ext(md5)
String md5 = content == null ? null : MD5.getInstance().getMD5String(content);
LogUtil.traceLog.info("{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}", new Object[]{SystemConfig.LOCAL_IP, dataId, group, tenant, requestIpAppName, ts, handleIp, "persist", type, -1, md5});
LogUtil.traceLog.info("{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}", SystemConfig.LOCAL_IP, dataId, group, tenant,
requestIpAppName, ts, handleIp, "persist", type, -1, md5);
}

public static void logNotifyEvent(String dataId, String group, String tenant, String requestIpAppName, long ts, String handleIp, String type,long delayed, String targetIp) {
Expand All @@ -68,7 +69,8 @@ public static void logNotifyEvent(String dataId, String group, String tenant, St
tenant = null;
}
//localIp | dataid | group | tenant | requestIpAppName | ts | handleIp | event | type | [delayed] | ext(targetIp)
LogUtil.traceLog.info("{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}", new Object[]{SystemConfig.LOCAL_IP, dataId, group, tenant, requestIpAppName, ts, handleIp, "notify", type, delayed, targetIp});
LogUtil.traceLog.info("{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}", SystemConfig.LOCAL_IP, dataId, group, tenant,
requestIpAppName, ts, handleIp, "notify", type, delayed, targetIp);
}

public static void logDumpEvent(String dataId, String group, String tenant, String requestIpAppName, long ts, String handleIp, String type, long delayed, long length) {
Expand All @@ -80,7 +82,8 @@ public static void logDumpEvent(String dataId, String group, String tenant, Stri
tenant = null;
}
//localIp | dataid | group | tenant | requestIpAppName | ts | handleIp | event | type | [delayed] | length
LogUtil.traceLog.info("{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}", new Object[]{SystemConfig.LOCAL_IP, dataId, group, tenant, requestIpAppName, ts, handleIp, "dump", type, delayed, length});
LogUtil.traceLog.info("{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}", SystemConfig.LOCAL_IP, dataId, group, tenant,
requestIpAppName, ts, handleIp, "dump", type, delayed, length);
}

public static void logDumpAllEvent(String dataId, String group, String tenant, String requestIpAppName, long ts, String handleIp, String type) {
Expand All @@ -92,7 +95,8 @@ public static void logDumpAllEvent(String dataId, String group, String tenant, S
tenant = null;
}
//localIp | dataid | group | tenant | requestIpAppName | ts | handleIp | event | type | [delayed = -1]
LogUtil.traceLog.info("{}|{}|{}|{}|{}|{}|{}|{}|{}|{}", new Object[]{SystemConfig.LOCAL_IP, dataId, group, tenant, requestIpAppName, ts, handleIp, "dump-all", type, -1});
LogUtil.traceLog.info("{}|{}|{}|{}|{}|{}|{}|{}|{}|{}", SystemConfig.LOCAL_IP, dataId, group, tenant,
requestIpAppName, ts, handleIp, "dump-all", type, -1);
}

public static void logPullEvent(String dataId, String group, String tenant, String requestIpAppName, long ts, String type, long delayed, String clientIp) {
Expand All @@ -104,6 +108,7 @@ public static void logPullEvent(String dataId, String group, String tenant, Stri
tenant = null;
}
//localIp | dataid | group | tenant| requestIpAppName| ts | event | type | [delayed] | ext(clientIp)
LogUtil.traceLog.info("{}|{}|{}|{}|{}|{}|{}|{}|{}|{}", new Object[]{SystemConfig.LOCAL_IP, dataId, group, tenant, requestIpAppName, ts, "pull", type, delayed, clientIp});
LogUtil.traceLog.info("{}|{}|{}|{}|{}|{}|{}|{}|{}|{}", SystemConfig.LOCAL_IP, dataId, group, tenant,
requestIpAppName, ts, "pull", type, delayed, clientIp);
}
}
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,6 @@
<artifactId>jackson-core-asl</artifactId>
<version>1.9.10</version>
</dependency>
<dependency>
<groupId>com.taobao.middleware</groupId>
<artifactId>logger.api</artifactId>
<version>0.2.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>apache-log4j</groupId>
<artifactId>log4j</artifactId>
Expand Down

0 comments on commit cfb96d8

Please sign in to comment.