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


Java MetricsRegistry.newCounter方法代码示例

本文整理汇总了Java中org.apache.samza.metrics.MetricsRegistry.newCounter方法的典型用法代码示例。如果您正苦于以下问题:Java MetricsRegistry.newCounter方法的具体用法?Java MetricsRegistry.newCounter怎么用?Java MetricsRegistry.newCounter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.samza.metrics.MetricsRegistry的用法示例。


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

示例1: BlockingEnvelopeMapMetrics

import org.apache.samza.metrics.MetricsRegistry; //导入方法依赖的package包/类
public BlockingEnvelopeMapMetrics(String group, MetricsRegistry metricsRegistry) {
  this.group = group;
  this.metricsRegistry = metricsRegistry;
  this.noMoreMessageGaugeMap = new ConcurrentHashMap<SystemStreamPartition, Gauge<Boolean>>();
  this.blockingPollCountMap = new ConcurrentHashMap<SystemStreamPartition, Counter>();
  this.blockingPollTimeoutCountMap = new ConcurrentHashMap<SystemStreamPartition, Counter>();
  this.pollCount = metricsRegistry.newCounter(group, "poll-count");
}
 
开发者ID:apache,项目名称:samza,代码行数:9,代码来源:BlockingEnvelopeMap.java

示例2: EventHubSystemConsumer

import org.apache.samza.metrics.MetricsRegistry; //导入方法依赖的package包/类
public EventHubSystemConsumer(EventHubConfig config, String systemName,
                              EventHubClientManagerFactory eventHubClientManagerFactory,
                              Map<String, Interceptor> interceptors, MetricsRegistry registry) {
  super(registry, System::currentTimeMillis);

  this.config = config;
  this.systemName = systemName;
  this.interceptors = interceptors;
  List<String> streamIds = config.getStreams(systemName);
  // Create and initiate connections to Event Hubs
  for (String streamId : streamIds) {
    EventHubClientManager eventHubClientManager = eventHubClientManagerFactory
            .getEventHubClientManager(systemName, streamId, config);
    streamEventHubManagers.put(streamId, eventHubClientManager);
    eventHubClientManager.init();
  }

  // Initiate metrics
  eventReadRates = streamIds.stream()
          .collect(Collectors.toMap(Function.identity(), x -> registry.newCounter(x, EVENT_READ_RATE)));
  eventByteReadRates = streamIds.stream()
          .collect(Collectors.toMap(Function.identity(), x -> registry.newCounter(x, EVENT_BYTE_READ_RATE)));
  readLatencies = streamIds.stream()
          .collect(Collectors.toMap(Function.identity(), x -> new SamzaHistogram(registry, x, READ_LATENCY)));
  readErrors = streamIds.stream()
          .collect(Collectors.toMap(Function.identity(), x -> registry.newCounter(x, READ_ERRORS)));

  // Locking to ensure that these aggregated metrics will be created only once across multiple system consumers.
  synchronized (AGGREGATE_METRICS_LOCK) {
    if (aggEventReadRate == null) {
      aggEventReadRate = registry.newCounter(AGGREGATE, EVENT_READ_RATE);
      aggEventByteReadRate = registry.newCounter(AGGREGATE, EVENT_BYTE_READ_RATE);
      aggReadLatency = new SamzaHistogram(registry, AGGREGATE, READ_LATENCY);
      aggReadErrors = registry.newCounter(AGGREGATE, READ_ERRORS);
    }
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:38,代码来源:EventHubSystemConsumer.java

示例3: init

import org.apache.samza.metrics.MetricsRegistry; //导入方法依赖的package包/类
/**
 * Initialize this {@link OperatorImpl} and its user-defined functions.
 *
 * @param config  the {@link Config} for the task
 * @param context  the {@link TaskContext} for the task
 */
public final void init(Config config, TaskContext context) {
  String opId = getOpImplId();

  if (initialized) {
    throw new IllegalStateException(String.format("Attempted to initialize Operator %s more than once.", opId));
  }

  if (closed) {
    throw new IllegalStateException(String.format("Attempted to initialize Operator %s after it was closed.", opId));
  }

  this.highResClock = createHighResClock(config);
  registeredOperators = new HashSet<>();
  prevOperators = new HashSet<>();
  inputStreams = new HashSet<>();
  MetricsRegistry metricsRegistry = context.getMetricsRegistry();
  this.numMessage = metricsRegistry.newCounter(METRICS_GROUP, opId + "-messages");
  this.handleMessageNs = metricsRegistry.newTimer(METRICS_GROUP, opId + "-handle-message-ns");
  this.handleTimerNs = metricsRegistry.newTimer(METRICS_GROUP, opId + "-handle-timer-ns");
  this.taskName = context.getTaskName();

  TaskContextImpl taskContext = (TaskContextImpl) context;
  this.eosStates = (EndOfStreamStates) taskContext.fetchObject(EndOfStreamStates.class.getName());
  this.watermarkStates = (WatermarkStates) taskContext.fetchObject(WatermarkStates.class.getName());

  if (taskContext.getJobModel() != null) {
    ContainerModel containerModel = taskContext.getJobModel().getContainers()
        .get(context.getSamzaContainerContext().id);
    this.taskModel = containerModel.getTasks().get(taskName);
  } else {
    this.taskModel = null;
    this.usedInCurrentTask = true;
  }

  handleInit(config, context);

  initialized = true;
}
 
开发者ID:apache,项目名称:samza,代码行数:45,代码来源:OperatorImpl.java

示例4: testMetricRegistry

import org.apache.samza.metrics.MetricsRegistry; //导入方法依赖的package包/类
@Test
public void testMetricRegistry() {
    MetricsRegistry registry = taskContext.getMetricsRegistry();
    Counter testCounter = registry.newCounter("test", "test");
    testCounter.inc();
    assertEquals(1, testCounter.getCount());
}
 
开发者ID:theduderog,项目名称:hello-samza-confluent,代码行数:8,代码来源:InMemoryTaskContextTest.java

示例5: HdfsSystemConsumerMetrics

import org.apache.samza.metrics.MetricsRegistry; //导入方法依赖的package包/类
public HdfsSystemConsumerMetrics(MetricsRegistry metricsRegistry) {
  this.metricsRegistry = metricsRegistry;
  this.numEventsCounterMap = new ConcurrentHashMap<>();
  this.numTotalEventsCounter = metricsRegistry.newCounter(METRICS_GROUP_NAME, "num-total-events");
}
 
开发者ID:apache,项目名称:samza,代码行数:6,代码来源:HdfsSystemConsumer.java


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