Browse Source

use stringbuilder to append string (#2108)

pull/3/MERGE
tswstarplanet 5 years ago committed by gaojun2048
parent
commit
12841bb4af
  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){ if (splits.length != Constants.HEARTBEAT_FOR_ZOOKEEPER_INFO_LENGTH){
return; return;
} }
String str = splits[0] + Constants.COMMA StringBuilder sb = new StringBuilder();
+ splits[1] + Constants.COMMA sb.append(splits[0]).append(Constants.COMMA)
+ OSUtils.cpuUsage() + Constants.COMMA .append(splits[1]).append(Constants.COMMA)
+ OSUtils.memoryUsage() + Constants.COMMA .append(OSUtils.cpuUsage()).append(Constants.COMMA)
+ OSUtils.loadAverage() + Constants.COMMA .append(OSUtils.memoryUsage()).append(Constants.COMMA)
+ splits[5] + Constants.COMMA .append(OSUtils.loadAverage()).append(Constants.COMMA)
+ DateUtils.dateToString(new Date()); .append(splits[5]).append(Constants.COMMA)
zkClient.setData().forPath(znode,str.getBytes()); .append(DateUtils.dateToString(new Date()));
zkClient.setData().forPath(znode, sb.toString().getBytes());
} catch (Exception e) { } catch (Exception e) {
logger.error("heartbeat for zk failed", e); logger.error("heartbeat for zk failed", e);

Loading…
Cancel
Save