org.apache.storm.task.TopologyContext.registerMetric()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(69)

本文整理了Java中org.apache.storm.task.TopologyContext.registerMetric()方法的一些代码示例,展示了TopologyContext.registerMetric()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TopologyContext.registerMetric()方法的具体详情如下:
包路径:org.apache.storm.task.TopologyContext
类名称:TopologyContext
方法名:registerMetric

TopologyContext.registerMetric介绍

暂无

代码示例

代码示例来源:origin: apache/storm

public <T extends IMetric> T registerMetric(String name, T metric, int timeBucketSizeInSecs) {
  return _topoContext.registerMetric(name, metric, timeBucketSizeInSecs);
}

代码示例来源:origin: apache/storm

public static void registerMetric(String name, IMetric metric, Map<String, Object> topoConf, TopologyContext context) {
    int bucketSize = ((Number) topoConf.get(Config.TOPOLOGY_BUILTIN_METRICS_BUCKET_SIZE_SECS)).intValue();
    context.registerMetric(name, metric, bucketSize);
  }
}

代码示例来源:origin: apache/storm

@Override
  public void registerMetrics(TopologyContext topoContext, Map<String, Object> topoConf) {
    int bucketSize = ((Number) topoConf.get(Config.TOPOLOGY_BUILTIN_METRICS_BUCKET_SIZE_SECS)).intValue();
    topoContext.registerMetric("TGT-TimeToExpiryMsecs", () -> getMsecsUntilExpiration(), bucketSize);
  }
}

代码示例来源:origin: apache/storm

public OutputStreamEngineWithHisto(OutputStream stats, TopologyContext context) {
    super(stats);
    histogram = new HistogramMetric(3600000000000L, 3);
    //TODO perhaps we can adjust the frequency later...
    context.registerMetric("comp-lat-histo-" + stats.id, histogram, 10);
  }
}

代码示例来源:origin: apache/storm

private void registerMetrics(TopologyContext context, Map<String, String> metrics, int bucketSize, Map<String, Object> conf) {
  if (metrics == null) {
    return;
  }
  for (Map.Entry<String, String> metric : metrics.entrySet()) {
    try {
      context.registerMetric(metric.getKey(), (IMetric) ReflectionUtils.newInstance(metric.getValue(), conf), bucketSize);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}

代码示例来源:origin: apache/storm

@Deprecated
public CombinedMetric registerMetric(String name, ICombiner combiner, int timeBucketSizeInSecs) {
  return registerMetric(name, new CombinedMetric(combiner), timeBucketSizeInSecs);
}

代码示例来源:origin: apache/storm

@Deprecated
public ReducedMetric registerMetric(String name, IReducer reducer, int timeBucketSizeInSecs) {
  return registerMetric(name, new ReducedMetric(reducer), timeBucketSizeInSecs);
}

代码示例来源:origin: apache/storm

public CombinedMetric registerMetric(String name, ICombiner combiner, int timeBucketSizeInSecs) {
    return _topoContext.registerMetric(name, new CombinedMetric(combiner), timeBucketSizeInSecs);
  }
}

代码示例来源:origin: apache/storm

public ReducedMetric registerMetric(String name, IReducer reducer, int timeBucketSizeInSecs) {
  return _topoContext.registerMetric(name, new ReducedMetric(reducer), timeBucketSizeInSecs);
}

代码示例来源:origin: apache/storm

private void registerMetric() {
  LOG.info("Registering Spout Metrics");
  kafkaOffsetMetric = new KafkaOffsetMetric<>(() -> Collections.unmodifiableMap(offsetManagers), () -> consumer);
  context.registerMetric("kafkaOffset", kafkaOffsetMetric, kafkaSpoutConfig.getMetricsTimeBucketSizeInSecs());
}

代码示例来源:origin: apache/storm

context.registerMetric("uptimeSecs", () -> jvmRT.getUptime() / 1000.0, bucketSize);
context.registerMetric("startTimeSecs", () -> jvmRT.getStartTime() / 1000.0, bucketSize);
context.registerMetric("threadCount", threadBean::getThreadCount, bucketSize);
context.registerMetric("newWorkerEvent", new IMetric() {
  boolean doEvent = true;
context.registerMetric("memory/heap", new MemoryUsageMetric(jvmMemRT::getHeapMemoryUsage), bucketSize);
context.registerMetric("memory/nonHeap", new MemoryUsageMetric(jvmMemRT::getNonHeapMemoryUsage), bucketSize);
  context.registerMetric("GC/" + b.getName().replaceAll("\\W", ""), new GarbageCollectorMetric(b), bucketSize);

代码示例来源:origin: apache/storm

@Override
public void open(Map<String, Object> conf, TopologyContext context, SpoutOutputCollector collector) {
  super.open(conf, context, collector);
  CountShellMetric cMetric = new CountShellMetric();
  context.registerMetric("my-custom-shellspout-metric", cMetric, 5);
}

代码示例来源:origin: apache/storm

public void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) {
  super.prepare(topoConf, context, collector);
  CountShellMetric cMetric = new CountShellMetric();
  context.registerMetric("my-custom-shell-metric", cMetric, 5);
}

代码示例来源:origin: apache/storm

context.registerMetric("EventHubReceiver", new IMetric() {
  @Override
  public Object getValueAndReset() {

代码示例来源:origin: com.yahoo.bullet/bullet-storm

private <T extends IMetric> T registerMetric(T metric, String name, TopologyContext context) {
    Number interval = metricsIntervalMapping.getOrDefault(name, metricsIntervalMapping.get(DEFAULT_BUILT_IN_METRICS_INTERVAL_KEY));
    log.info("Registered metric: {} with interval {}", name, interval);
    return context.registerMetric(name, metric, interval.intValue());
  }
}

代码示例来源:origin: org.apache.storm/storm-core

@Deprecated
public ReducedMetric registerMetric(String name, IReducer reducer, int timeBucketSizeInSecs) {
  return registerMetric(name, new ReducedMetric(reducer), timeBucketSizeInSecs);
}
/*

代码示例来源:origin: org.apache.storm/storm-core

private void registerMetrics(TopologyContext context, Map<String, String> metrics, int bucketSize) {
  if (metrics == null) return;
  for (Map.Entry<String, String> metric: metrics.entrySet()) {
    try {
      context.registerMetric(metric.getKey(), (IMetric)Utils.newInstance(metric.getValue()), bucketSize);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}

代码示例来源:origin: org.apache.storm/storm-core

public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
  super.prepare(stormConf, context, collector);
  
  CountShellMetric cMetric = new CountShellMetric();
  context.registerMetric("my-custom-shell-metric", cMetric, 5);
}

代码示例来源:origin: DigitalPebble/storm-crawler

public static TopologyContext getMockedTopologyContext() {
  TopologyContext context = mock(TopologyContext.class);
  when(context.registerMetric(anyString(), any(IMetric.class), anyInt()))
      .thenAnswer(new Answer<IMetric>() {
        @Override
        public IMetric answer(InvocationOnMock invocation)
            throws Throwable {
          return invocation.getArgumentAt(1, IMetric.class);
        }
      });
  return context;
}

代码示例来源:origin: DigitalPebble/storm-crawler

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void prepare(Map conf, TopologyContext context,
    OutputCollector collector) {
  super.prepare(conf, context, collector);
  _collector = collector;
  this.eventCounter = context.registerMetric("SQLIndexer",
      new MultiCountMetric(), 10);
  this.tableName = ConfUtils.getString(conf, SQL_INDEX_TABLE_PARAM_NAME);
  this.conf = conf;
}

相关文章

微信公众号

最新文章

更多