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


Java ReadableMetricsRegistry类代码示例

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


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

示例1: testOnMessageUpdatesMetrics

import org.apache.samza.metrics.ReadableMetricsRegistry; //导入依赖的package包/类
@Test
public void testOnMessageUpdatesMetrics() {
  TaskContextImpl mockTaskContext = mock(TaskContextImpl.class);
  ReadableMetricsRegistry mockMetricsRegistry = mock(ReadableMetricsRegistry.class);
  when(mockTaskContext.getMetricsRegistry()).thenReturn(mockMetricsRegistry);
  Counter mockCounter = mock(Counter.class);
  Timer mockTimer = mock(Timer.class);
  when(mockMetricsRegistry.newCounter(anyString(), anyString())).thenReturn(mockCounter);
  when(mockMetricsRegistry.newTimer(anyString(), anyString())).thenReturn(mockTimer);

  Object mockTestOpImplOutput = mock(Object.class);
  OperatorImpl<Object, Object> opImpl = new TestOpImpl(mockTestOpImplOutput);
  opImpl.init(mock(Config.class), mockTaskContext);

  // send a message to this operator
  MessageCollector mockCollector = mock(MessageCollector.class);
  TaskCoordinator mockCoordinator = mock(TaskCoordinator.class);
  opImpl.onMessage(mock(Object.class), mockCollector, mockCoordinator);

  // verify that it updates message count and timer metrics
  verify(mockCounter, times(1)).inc();
  verify(mockTimer, times(1)).update(anyLong());
}
 
开发者ID:apache,项目名称:samza,代码行数:24,代码来源:TestOperatorImpl.java

示例2: testOnTimerUpdatesMetrics

import org.apache.samza.metrics.ReadableMetricsRegistry; //导入依赖的package包/类
@Test
public void testOnTimerUpdatesMetrics() {
  TaskContextImpl mockTaskContext = mock(TaskContextImpl.class);
  ReadableMetricsRegistry mockMetricsRegistry = mock(ReadableMetricsRegistry.class);
  when(mockTaskContext.getMetricsRegistry()).thenReturn(mockMetricsRegistry);
  Counter mockMessageCounter = mock(Counter.class);
  Timer mockTimer = mock(Timer.class);
  when(mockMetricsRegistry.newCounter(anyString(), anyString())).thenReturn(mockMessageCounter);
  when(mockMetricsRegistry.newTimer(anyString(), anyString())).thenReturn(mockTimer);

  Object mockTestOpImplOutput = mock(Object.class);
  OperatorImpl<Object, Object> opImpl = new TestOpImpl(mockTestOpImplOutput);
  opImpl.init(mock(Config.class), mockTaskContext);

  // send a message to this operator
  MessageCollector mockCollector = mock(MessageCollector.class);
  TaskCoordinator mockCoordinator = mock(TaskCoordinator.class);
  opImpl.onTimer(mockCollector, mockCoordinator);

  // verify that it updates metrics
  verify(mockMessageCounter, times(0)).inc();
  verify(mockTimer, times(1)).update(anyLong());
}
 
开发者ID:apache,项目名称:samza,代码行数:24,代码来源:TestOperatorImpl.java

示例3: SamzaRestService

import org.apache.samza.metrics.ReadableMetricsRegistry; //导入依赖的package包/类
public SamzaRestService(Server server,
                        ReadableMetricsRegistry metricsRegistry,
                        Map<String, MetricsReporter> metricsReporters,
                        ServletContextHandler context) {
  this.server = server;
  this.metricsRegistry = metricsRegistry;
  this.metricsReporters = metricsReporters;
  this.context = context;
  this.context.setContextPath("/");
  server.setHandler(context);
}
 
开发者ID:apache,项目名称:samza,代码行数:12,代码来源:SamzaRestService.java

示例4: main

import org.apache.samza.metrics.ReadableMetricsRegistry; //导入依赖的package包/类
/**
 * Command line interface to run the server.
 *
 * @param args arguments supported by {@link org.apache.samza.util.CommandLine}.
 *             In particular, --config-path and --config-factory are used to read the Samza REST config file.
 * @throws Exception if the server could not be successfully started.
 */
public static void main(String[] args)
    throws Exception {
  ScheduledExecutorSchedulingProvider schedulingProvider = null;
  try {
    SamzaRestConfig config = parseConfig(args);
    ReadableMetricsRegistry metricsRegistry = new MetricsRegistryMap();
    log.info("Creating new SamzaRestService with config: {}", config);
    MetricsConfig metricsConfig = new MetricsConfig(config);
    Map<String, MetricsReporter> metricsReporters = MetricsReporterLoader.getMetricsReporters(metricsConfig, Util.getLocalHost().getHostName());
    SamzaRestService restService = new SamzaRestService(new Server(config.getPort()), metricsRegistry, metricsReporters,
                                                        new ServletContextHandler(ServletContextHandler.SESSIONS));

    // Add applications
    SamzaRestApplication samzaRestApplication = new SamzaRestApplication(config);
    ServletContainer container = new ServletContainer(samzaRestApplication);
    restService.addServlet(container, "/*");

    // Schedule monitors to run
    ThreadFactory threadFactory = new ThreadFactoryBuilder().setDaemon(true)
                                                            .setNameFormat("MonitorThread-%d")
                                                            .build();
    ScheduledExecutorService schedulingService = Executors.newScheduledThreadPool(1, threadFactory);
    schedulingProvider = new ScheduledExecutorSchedulingProvider(schedulingService);
    SamzaMonitorService monitorService = new SamzaMonitorService(config,
                                                                 metricsRegistry,
                                                                 schedulingProvider);
    monitorService.start();

    restService.runBlocking();
    monitorService.stop();
  } catch (Throwable t) {
    log.error("Exception in main.", t);
  } finally {
    if (schedulingProvider != null){
      schedulingProvider.stop();
    }
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:46,代码来源:SamzaRestService.java

示例5: setup

import org.apache.samza.metrics.ReadableMetricsRegistry; //导入依赖的package包/类
@Before
public void setup()
    throws Exception {
  container = mock(YarnContainer.class);
  ReadableMetricsRegistry registry = new MetricsRegistryMap("test-registry");

  yarnAppState =
      new YarnAppState(-1, ConverterUtils.toContainerId("container_1350670447861_0003_01_000001"), "testHost", 1, 1);
  webApp = new HttpServer("/", 0, "", new ServletHolder(new DefaultServlet()));
  webApp.addServlet("/", new YarnContainerHeartbeatServlet(yarnAppState, registry));
  webApp.start();
  mapper = new ObjectMapper();
}
 
开发者ID:apache,项目名称:samza,代码行数:14,代码来源:TestYarnContainerHeartbeatServlet.java

示例6: startMetrics

import org.apache.samza.metrics.ReadableMetricsRegistry; //导入依赖的package包/类
private void startMetrics() {
  for (MetricsReporter reporter: reporters.values()) {
    reporter.register("job-coordinator-" + processorId, (ReadableMetricsRegistry) metrics.getMetricsRegistry());
    reporter.start();
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:7,代码来源:ZkJobCoordinator.java

示例7: getMetricsRegistry

import org.apache.samza.metrics.ReadableMetricsRegistry; //导入依赖的package包/类
@Override
public ReadableMetricsRegistry getMetricsRegistry() {
  return metrics.registry();
}
 
开发者ID:apache,项目名称:samza,代码行数:5,代码来源:TaskContextImpl.java

示例8: YarnContainerHeartbeatServlet

import org.apache.samza.metrics.ReadableMetricsRegistry; //导入依赖的package包/类
public YarnContainerHeartbeatServlet(YarnAppState yarnAppState, ReadableMetricsRegistry registry) {
  this.yarnAppState = yarnAppState;
  this.mapper = new ObjectMapper();
  this.heartbeatsExpiredCount = registry.newCounter(GROUP, "heartbeats-expired");
}
 
开发者ID:apache,项目名称:samza,代码行数:6,代码来源:YarnContainerHeartbeatServlet.java


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