StormClusterState clusterState = workerData.getZkCluster();
String topologyId = workerData.getTopologyId();
String hostName =JStormServerUtils.getHostName(workerData.getConf());
String workerId = hostName + ":" + workerData.getPort();
UserDefMetric userDefMetric = Metrics.getUserDefMetric();
UserDefMetricData userDefMetricData = new UserDefMetricData();
userDefMetricData.updateFromGauge(userDefMetric.getGauge());
userDefMetricData.updateFromCounter(userDefMetric.getCounter());
userDefMetricData.updateFromMeterData(userDefMetric.getMeter());
// If metrics performance is disable, Timer & Histogram metrics will not be monitored,
// and the corresponding metrics data will not be sent to ZK either.
if (metricPerf == false) {
userDefMetricData.updateFromHistogramData(userDefMetric.getHistogram());
userDefMetricData.updateFromTimerData(userDefMetric.getTimer());
}
try {
clusterState.update_userDef_metric(topologyId, workerId, userDefMetricData);
} catch(Exception e) {
logger.error(marker, "Failed to update user define metrics data in ZK for topo-{} idStr-{}.",
topologyId, workerId, e);
}
//Do callbacks defined by user
doCallback(userDefMetric.getGauge());
doCallback(userDefMetric.getCounter());
doCallback(userDefMetric.getMeter());
if (metricPerf == false) {
doCallback(userDefMetric.getHistogram());
doCallback(userDefMetric.getTimer());
}
}