Browse Source

use stringbuilder to append string (#2108)

pull/2/head
tswstarplanet 5 years ago committed by GitHub
parent
commit
b2268b1af9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/zk/AbstractZKClient.java

18
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/zk/AbstractZKClient.java

@ -65,14 +65,16 @@ public abstract class AbstractZKClient extends ZookeeperCachedOperator {
if (splits.length != Constants.HEARTBEAT_FOR_ZOOKEEPER_INFO_LENGTH){
return;
}
String str = splits[0] + Constants.COMMA
+ splits[1] + Constants.COMMA
+ OSUtils.cpuUsage() + Constants.COMMA
+ OSUtils.memoryUsage() + Constants.COMMA
+ OSUtils.loadAverage() + Constants.COMMA
+ splits[5] + Constants.COMMA
+ DateUtils.dateToString(new Date());
zkClient.setData().forPath(znode,str.getBytes());
StringBuilder sb = new StringBuilder();
sb.append(splits[0]).append(Constants.COMMA)
.append(splits[1]).append(Constants.COMMA)
.append(OSUtils.cpuUsage()).append(Constants.COMMA)
.append(OSUtils.memoryUsage()).append(Constants.COMMA)
.append(OSUtils.loadAverage()).append(Constants.COMMA)
.append(splits[5]).append(Constants.COMMA)
.append(DateUtils.dateToString(new Date()));
zkClient.setData().forPath(znode, sb.toString().getBytes());
} catch (Exception e) {
logger.error("heartbeat for zk failed", e);

Loading…
Cancel
Save