Skip to content

Commit

Permalink
[ISSUE apache#6138] Skip log empty remoting code distribution (apache…
Browse files Browse the repository at this point in the history
…#6136)

* skip log empty code distribution

* skip log empty remoting code distirbution

* skip log empty code distribusion
  • Loading branch information
yuz10 authored and mxsm committed Feb 23, 2023
1 parent df1a6d5 commit c63219e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,17 @@ private void prepareSharableHandlers() {

private void printRemotingCodeDistribution() {
if (distributionHandler != null) {
TRAFFIC_LOGGER.info("Port: {}, RequestCode Distribution: {}",
nettyServerConfig.getListenPort(), distributionHandler.getInBoundSnapshotString());
TRAFFIC_LOGGER.info("Port: {}, ResponseCode Distribution: {}",
nettyServerConfig.getListenPort(), distributionHandler.getOutBoundSnapshotString());
String inBoundSnapshotString = distributionHandler.getInBoundSnapshotString();
if (inBoundSnapshotString != null) {
TRAFFIC_LOGGER.info("Port: {}, RequestCode Distribution: {}",
nettyServerConfig.getListenPort(), inBoundSnapshotString);
}

String outBoundSnapshotString = distributionHandler.getOutBoundSnapshotString();
if (outBoundSnapshotString != null) {
TRAFFIC_LOGGER.info("Port: {}, ResponseCode Distribution: {}",
nettyServerConfig.getListenPort(), outBoundSnapshotString);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ private Map<Integer, Long> getDistributionSnapshot(Map<Integer, LongAdder> count
}

private String snapshotToString(Map<Integer, Long> distribution) {
StringBuilder sb = new StringBuilder("{");
if (null != distribution && !distribution.isEmpty()) {
StringBuilder sb = new StringBuilder("{");
boolean first = true;
for (Map.Entry<Integer, Long> entry : distribution.entrySet()) {
if (0L == entry.getValue()) {
Expand All @@ -85,9 +85,13 @@ private String snapshotToString(Map<Integer, Long> distribution) {
sb.append(first ? "" : ", ").append(entry.getKey()).append(":").append(entry.getValue());
first = false;
}
if (first) {
return null;
}
sb.append("}");
return sb.toString();
}
sb.append("}");
return sb.toString();
return null;
}

public String getInBoundSnapshotString() {
Expand Down

0 comments on commit c63219e

Please sign in to comment.