当前位置: 首页>>代码示例>>Java>>正文


Java MetricsSink类代码示例

本文整理汇总了Java中org.apache.hadoop.metrics2.MetricsSink的典型用法代码示例。如果您正苦于以下问题:Java MetricsSink类的具体用法?Java MetricsSink怎么用?Java MetricsSink使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MetricsSink类属于org.apache.hadoop.metrics2包,在下文中一共展示了MetricsSink类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: register

import org.apache.hadoop.metrics2.MetricsSink; //导入依赖的package包/类
@Override public synchronized <T extends MetricsSink>
T register(final String name, final String description, final T sink) {
  LOG.debug(name +", "+ description);
  if (allSinks.containsKey(name)) {
    LOG.warn("Sink "+ name +" already exists!");
    return sink;
  }
  allSinks.put(name, sink);
  if (config != null) {
    registerSink(name, description, sink);
  }
  // We want to re-register the sink to pick up new config
  // when the metrics system restarts.
  register(name, new AbstractCallback() {
    @Override public void postStart() {
      register(name, description, sink);
    }
  });
  return sink;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:21,代码来源:MetricsSystemImpl.java

示例2: testHangOnSinkRead

import org.apache.hadoop.metrics2.MetricsSink; //导入依赖的package包/类
/**
 * HADOOP-11932
 */
@Test(timeout = 5000)
public void testHangOnSinkRead() throws Exception {
  new ConfigBuilder().add("*.period", 8)
      .add("test.sink.test.class", TestSink.class.getName())
      .save(TestMetricsConfig.getTestFilename("hadoop-metrics2-test"));
  MetricsSystemImpl ms = new MetricsSystemImpl("Test");
  ms.start();
  try {
    CountDownLatch collectingLatch = new CountDownLatch(1);
    MetricsSink sink = new TestClosableSink(collectingLatch);
    ms.registerSink("closeableSink",
        "The sink will be used to test closeability", sink);
    // trigger metric collection first time
    ms.onTimerEvent();
    // Make sure that sink is collecting metrics
    assertTrue(collectingLatch.await(1, TimeUnit.SECONDS));
  } finally {
    ms.stop();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:24,代码来源:TestMetricsSystemImpl.java

示例3: register

import org.apache.hadoop.metrics2.MetricsSink; //导入依赖的package包/类
@Override public synchronized <T extends MetricsSink>
T register(final String name, final String description, final T sink) {
  LOG.debug(name +", "+ description);
  if (allSinks.containsKey(name)) {
    LOG.warn("Sink "+ name +" already exists!");
    return sink;
  }
  allSinks.put(name, sink);
  if (config != null) {
    registerSink(name, description, sink);
  }
  // We want to re-register the sink to pick up new config
  // when the metrics system restarts.
  register(new AbstractCallback() {
    @Override public void postStart() {
      register(name, description, sink);
    }
  });
  return sink;
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:21,代码来源:MetricsSystemImpl.java

示例4: register

import org.apache.hadoop.metrics2.MetricsSink; //导入依赖的package包/类
@Override
public synchronized <T extends MetricsSink>
T register(final String name, final String description, final T sink) {
  if (config != null) {
    registerSink(name, description, sink);
  }
  // We want to re-register the sink to pick up new config
  // when the metrics system restarts.
  register(new AbstractCallback() {

    @Override public void postStart() {
      registerSink(name, description, sink);
    }

  });
  return sink;
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:18,代码来源:MetricsSystemImpl.java

示例5: registerSink

import org.apache.hadoop.metrics2.MetricsSink; //导入依赖的package包/类
synchronized void registerSink(String name, String desc, MetricsSink sink) {
  checkNotNull(config, "config");
  MetricsConfig conf = sinkConfigs.get(name);
  MetricsSinkAdapter sa = conf != null
      ? newSink(name, desc, sink, conf)
      : newSink(name, desc, sink, config.subset(SINK_KEY));
  sinks.put(name, sa);
  sa.start();
  LOG.info("Registered sink "+ name);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:11,代码来源:MetricsSystemImpl.java

示例6: newSink

import org.apache.hadoop.metrics2.MetricsSink; //导入依赖的package包/类
static MetricsSinkAdapter newSink(String name, String desc, MetricsSink sink,
                                  MetricsConfig conf) {
  return new MetricsSinkAdapter(name, desc, sink, conf.getString(CONTEXT_KEY),
      conf.getFilter(SOURCE_FILTER_KEY),
      conf.getFilter(RECORD_FILTER_KEY),
      conf.getFilter(METRIC_FILTER_KEY),
      conf.getInt(PERIOD_KEY, PERIOD_DEFAULT),
      conf.getInt(QUEUE_CAPACITY_KEY, QUEUE_CAPACITY_DEFAULT),
      conf.getInt(RETRY_DELAY_KEY, RETRY_DELAY_DEFAULT),
      conf.getFloat(RETRY_BACKOFF_KEY, RETRY_BACKOFF_DEFAULT),
      conf.getInt(RETRY_COUNT_KEY, RETRY_COUNT_DEFAULT));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:13,代码来源:MetricsSystemImpl.java

示例7: MetricsSinkAdapter

import org.apache.hadoop.metrics2.MetricsSink; //导入依赖的package包/类
MetricsSinkAdapter(String name, String description, MetricsSink sink,
                   String context, MetricsFilter sourceFilter,
                   MetricsFilter recordFilter, MetricsFilter metricFilter,
                   int period, int queueCapacity, int retryDelay,
                   float retryBackoff, int retryCount) {
  this.name = checkNotNull(name, "name");
  this.description = description;
  this.sink = checkNotNull(sink, "sink object");
  this.context = context;
  this.sourceFilter = sourceFilter;
  this.recordFilter = recordFilter;
  this.metricFilter = metricFilter;
  this.period = checkArg(period, period > 0, "period");
  firstRetryDelay = checkArg(retryDelay, retryDelay > 0, "retry delay");
  this.retryBackoff = checkArg(retryBackoff, retryBackoff>1, "retry backoff");
  oobPutTimeout = (long)
      (firstRetryDelay * Math.pow(retryBackoff, retryCount) * 1000);
  this.retryCount = retryCount;
  this.queue = new SinkQueue<MetricsBuffer>(checkArg(queueCapacity,
      queueCapacity > 0, "queue capacity"));
  latency = registry.newRate("Sink_"+ name, "Sink end to end latency", false);
  dropped = registry.newCounter("Sink_"+ name +"Dropped",
                                "Dropped updates per sink", 0);
  qsize = registry.newGauge("Sink_"+ name + "Qsize", "Queue size", 0);

  sinkThread = new Thread() {
    @Override public void run() {
      publishMetricsFromQueue();
    }
  };
  sinkThread.setName(name);
  sinkThread.setDaemon(true);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:34,代码来源:MetricsSinkAdapter.java

示例8: testInitFirstVerifyCallBacks

import org.apache.hadoop.metrics2.MetricsSink; //导入依赖的package包/类
@Test public void testInitFirstVerifyCallBacks() throws Exception {
  DefaultMetricsSystem.shutdown(); 
  new ConfigBuilder().add("*.period", 8)
      //.add("test.sink.plugin.urls", getPluginUrlsAsString())
      .add("test.sink.test.class", TestSink.class.getName())
      .add("test.*.source.filter.exclude", "s0")
      .add("test.source.s1.metric.filter.exclude", "X*")
      .add("test.sink.sink1.metric.filter.exclude", "Y*")
      .add("test.sink.sink2.metric.filter.exclude", "Y*")
      .save(TestMetricsConfig.getTestFilename("hadoop-metrics2-test"));
  MetricsSystemImpl ms = new MetricsSystemImpl("Test");
  ms.start();
  ms.register("s0", "s0 desc", new TestSource("s0rec"));
  TestSource s1 = ms.register("s1", "s1 desc", new TestSource("s1rec"));
  s1.c1.incr();
  s1.xxx.incr();
  s1.g1.set(2);
  s1.yyy.incr(2);
  s1.s1.add(0);
  MetricsSink sink1 = mock(MetricsSink.class);
  MetricsSink sink2 = mock(MetricsSink.class);
  ms.registerSink("sink1", "sink1 desc", sink1);
  ms.registerSink("sink2", "sink2 desc", sink2);
  ms.publishMetricsNow(); // publish the metrics

  try {
    verify(sink1, timeout(200).times(2)).putMetrics(r1.capture());
    verify(sink2, timeout(200).times(2)).putMetrics(r2.capture());
  } finally {
    ms.stop();
    ms.shutdown();
  }
  //When we call stop, at most two sources will be consumed by each sink thread.
  List<MetricsRecord> mr1 = r1.getAllValues();
  List<MetricsRecord> mr2 = r2.getAllValues();
  checkMetricsRecords(mr1);
  assertEquals("output", mr1, mr2);

}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:40,代码来源:TestMetricsSystemImpl.java

示例9: testInitFirstVerifyStopInvokedImmediately

import org.apache.hadoop.metrics2.MetricsSink; //导入依赖的package包/类
@Test public void testInitFirstVerifyStopInvokedImmediately() throws Exception {
  new ConfigBuilder().add("*.period", 8)
      //.add("test.sink.plugin.urls", getPluginUrlsAsString())
      .add("test.sink.test.class", TestSink.class.getName())
      .add("test.*.source.filter.exclude", "s0")
      .add("test.source.s1.metric.filter.exclude", "X*")
      .add("test.sink.sink1.metric.filter.exclude", "Y*")
      .add("test.sink.sink2.metric.filter.exclude", "Y*")
      .save(TestMetricsConfig.getTestFilename("hadoop-metrics2-test"));
  MetricsSystemImpl ms = new MetricsSystemImpl("Test");
  ms.start();
  ms.register("s0", "s0 desc", new TestSource("s0rec"));
  TestSource s1 = ms.register("s1", "s1 desc", new TestSource("s1rec"));
  s1.c1.incr();
  s1.xxx.incr();
  s1.g1.set(2);
  s1.yyy.incr(2);
  s1.s1.add(0);
  MetricsSink sink1 = mock(MetricsSink.class);
  MetricsSink sink2 = mock(MetricsSink.class);
  ms.registerSink("sink1", "sink1 desc", sink1);
  ms.registerSink("sink2", "sink2 desc", sink2);
  ms.publishMetricsNow(); // publish the metrics
  ms.stop();
  ms.shutdown();

  //When we call stop, at most two sources will be consumed by each sink thread.
  verify(sink1, atMost(2)).putMetrics(r1.capture());
  List<MetricsRecord> mr1 = r1.getAllValues();
  verify(sink2, atMost(2)).putMetrics(r2.capture());
  List<MetricsRecord> mr2 = r2.getAllValues();
  if (mr1.size() != 0 && mr2.size() != 0) {
    checkMetricsRecords(mr1);
    assertEquals("output", mr1, mr2);
  } else if (mr1.size() != 0) {
    checkMetricsRecords(mr1);
  } else if (mr2.size() != 0) {
    checkMetricsRecords(mr2);
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:41,代码来源:TestMetricsSystemImpl.java


注:本文中的org.apache.hadoop.metrics2.MetricsSink类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。