Search in sources :

Example 1 with MetaType

use of com.alibaba.jstorm.metric.MetaType in project jstorm by alibaba.

the class RefreshEvent method syncMetaFromRemote.

private void syncMetaFromRemote(String topologyId, TopologyMetricContext tmContext) {
    try {
        int memSize = tmContext.getMemMeta().size();
        //Integer zkSize = (Integer) context.getStormClusterState().get_topology_metric(topologyId);
        Set<String> added = new HashSet<>();
        List<Pair<MetricMeta, Long>> pairsToCheck = new ArrayList<>();
        ConcurrentMap<String, Long> memMeta = tmContext.getMemMeta();
        for (MetaType metaType : MetaType.values()) {
            List<MetricMeta> metaList = context.getMetricQueryClient().getMetricMeta(context.getClusterName(), topologyId, metaType);
            if (metaList != null) {
                LOG.debug("get remote metric meta, topology:{}, metaType:{}, local mem:{}, remote:{}", topologyId, metaType, memSize, metaList.size());
                for (MetricMeta meta : metaList) {
                    String fqn = meta.getFQN();
                    if (added.contains(fqn)) {
                        Long existingId = memMeta.get(fqn);
                        if (existingId != null && existingId != meta.getId()) {
                            LOG.warn("duplicate remote metric meta:{}, will double-check...", fqn);
                            pairsToCheck.add(new Pair<>(meta, existingId));
                        }
                    } else {
                        // force remote to overwrite local meta
                        LOG.debug("overwrite local from remote:{}", fqn);
                        added.add(fqn);
                        memMeta.put(fqn, meta.getId());
                    }
                }
            }
        }
        context.getMetricCache().putMeta(topologyId, memMeta);
        if (pairsToCheck.size() > 0) {
            CheckMetricEvent.pushEvent(topologyId, tmContext, pairsToCheck);
        }
    } catch (Exception ex) {
        LOG.error("failed to sync remote meta", ex);
    }
}
Also used : ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Pair(com.alibaba.jstorm.utils.Pair) MetaType(com.alibaba.jstorm.metric.MetaType) MetricMeta(com.alibaba.jstorm.common.metric.MetricMeta)

Example 2 with MetaType

use of com.alibaba.jstorm.metric.MetaType in project jstorm by alibaba.

the class MetricMeta method getFQN.

public String getFQN() {
    MetaType meta = MetaType.parse(metaType);
    MetricType metric = MetricType.parse(metricType);
    String types = meta.getV() + metric.getV();
    if (isWorkerMetric()) {
        return MetricUtils.concat2(types, topologyId, host, port, metricGroup, metricName);
    }
    return MetricUtils.concat2(types, topologyId, component, taskId, streamId, metricGroup, metricName);
}
Also used : MetricType(com.alibaba.jstorm.metric.MetricType) MetaType(com.alibaba.jstorm.metric.MetaType)

Aggregations

MetaType (com.alibaba.jstorm.metric.MetaType)2 MetricMeta (com.alibaba.jstorm.common.metric.MetricMeta)1 MetricType (com.alibaba.jstorm.metric.MetricType)1 Pair (com.alibaba.jstorm.utils.Pair)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1