use of com.alibaba.jstorm.metric.TimeTicker in project jstorm by alibaba.
the class ClusterMetricsContext method registerMetrics.
public Map<String, Long> registerMetrics(String topologyId, Set<String> metricNames) {
TimeTicker ticker = new TimeTicker(TimeUnit.MILLISECONDS, true);
TopologyMetricContext topologyMetricContext = topologyMetricContexts.get(topologyId);
if (topologyMetricContext == null) {
LOG.warn("topology metrics context does not exist for topology:{}!!!", topologyId);
return new HashMap<>();
}
// if (!topologyMetricContext.finishSyncRemote()) {
// LOG.warn("waiting for topology {} to finish sync with remote.", topologyId);
// return new HashMap<>();
// }
ConcurrentMap<String, Long> memMeta = topologyMetricContexts.get(topologyId).getMemMeta();
Map<String, Long> ret = new HashMap<>();
for (String metricName : metricNames) {
Long id = memMeta.get(metricName);
if (id != null && MetricUtils.isValidId(id)) {
ret.put(metricName, id);
} else {
id = metricIDGenerator.genMetricId(metricName);
Long old = memMeta.putIfAbsent(metricName, id);
if (old == null) {
ret.put(metricName, id);
} else {
ret.put(metricName, old);
}
}
}
long cost = ticker.stop();
LOG.info("register metrics, topology:{}, size:{}, cost:{}", topologyId, metricNames.size(), cost);
return ret;
}
use of com.alibaba.jstorm.metric.TimeTicker in project jstorm by alibaba.
the class RefreshEvent method refreshTopologies.
/**
* refresh metric settings of topologies & metric meta
*/
public void refreshTopologies() {
TimeTicker ticker = new TimeTicker(TimeUnit.MILLISECONDS, true);
try {
doRefreshTopologies();
LOG.debug("Refresh topologies, cost:{}", ticker.stopAndRestart());
if (!context.getNimbusData().isLeader()) {
syncTopologyMeta();
LOG.debug("Sync topology meta, cost:{}", ticker.stop());
} else if (context.getNimbusData().uptime() < SYNC_REMOTE_META_TIME_SEC) {
syncSysMetaFromRemote();
}
} catch (Exception ex) {
LOG.error("handleRefreshEvent error:", ex);
}
}
Aggregations