public Timer newTimer(String name) { return registry.newTimer(groupName, (prefix + name).toLowerCase()); } }
public Timer newTimer(String name) { return registry.newTimer(groupName, (prefix + name).toLowerCase()); } }
public Timer newTimer(String name) { return registry.newTimer(groupName, (prefix + name).toLowerCase()); } }
public Timer newTimer(String name) { return registry.newTimer(groupName, (prefix + name).toLowerCase()); } }
public Timer newTimer(String name) { return registry.newTimer(groupName, (prefix + name).toLowerCase()); } }
/** * Create a new timer by delegating to the underlying metrics registry * @param name name of the timer * @return newly created timer */ public Timer newTimer(String name) { return metricsRegistry.newTimer(groupName, getMetricFullName(name)); }
/** * Create a new timer by delegating to the underlying metrics registry * @param name name of the timer * @return newly created timer */ public Timer newTimer(String name) { return metricsRegistry.newTimer(groupName, getMetricFullName(name)); }
/** * Create a new timer by delegating to the underlying metrics registry * @param name name of the timer * @return newly created timer */ public Timer newTimer(String name) { return metricsRegistry.newTimer(groupName, getMetricFullName(name)); }
/** * Create a new timer by delegating to the underlying metrics registry * @param name name of the timer * @return newly created timer */ public Timer newTimer(String name) { return metricsRegistry.newTimer(groupName, getMetricFullName(name)); }
/** * Create a new timer by delegating to the underlying metrics registry * @param name name of the timer * @return newly created timer */ public Timer newTimer(String name) { return metricsRegistry.newTimer(groupName, getMetricFullName(name)); }
public static Context getMockContext() { Context context = new MockContext(); MetricsRegistry metricsRegistry = mock(MetricsRegistry.class); doAnswer(args -> new Timer((String) args.getArguments()[0])).when(metricsRegistry).newTimer(anyString(), anyString()); doAnswer(args -> new Counter((String) args.getArguments()[0])).when(metricsRegistry).newCounter(anyString(), anyString()); doAnswer(args -> new Gauge((String) args.getArguments()[0], 0)).when(metricsRegistry).newGauge(anyString(), any()); doReturn(metricsRegistry).when(context.getContainerContext()).getContainerMetricsRegistry(); return context; }
private void initTables(boolean isTimerMetricsDisabled, ReadWriteTable ... tables) { Map<String, String> config = new HashMap<>(); if (isTimerMetricsDisabled) { config.put(MetricsConfig.METRICS_TIMER_ENABLED(), "false"); } Context context = new MockContext(); doReturn(new MapConfig(config)).when(context.getJobContext()).getConfig(); metricsRegistry = mock(MetricsRegistry.class); doReturn(mock(Timer.class)).when(metricsRegistry).newTimer(anyString(), anyString()); doReturn(mock(Counter.class)).when(metricsRegistry).newCounter(anyString(), anyString()); doReturn(mock(Gauge.class)).when(metricsRegistry).newGauge(anyString(), any()); doReturn(metricsRegistry).when(context.getContainerContext()).getContainerMetricsRegistry(); Arrays.asList(tables).forEach(t -> t.init(context)); }
MetricsRegistry metricsRegistry = taskContext.getTaskMetricsRegistry(); 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 = taskContext.getTaskModel().getTaskName();
MetricsRegistry metricsRegistry = taskContext.getTaskMetricsRegistry(); 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 = taskContext.getTaskModel().getTaskName();
MetricsRegistry metricsRegistry = taskContext.getTaskMetricsRegistry(); 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 = taskContext.getTaskModel().getTaskName();
MetricsRegistry metricsRegistry = taskContext.getTaskMetricsRegistry(); 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 = taskContext.getTaskModel().getTaskName();
final MetricsRegistry metricsRegistry = containerContext.getContainerMetricsRegistry(); 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");
@Before public void setUp() { keys = Arrays.asList("k1", "k2", "k3"); values = new HashMap<>(); values.put("k1", "v1"); values.put("k2", "v2"); values.put("k3", null); kvStore = mock(KeyValueStore.class); when(kvStore.get("k1")).thenReturn("v1"); when(kvStore.get("k2")).thenReturn("v2"); when(kvStore.getAll(keys)).thenReturn(values); getNs = new Timer(""); getAllNs = new Timer(""); numGets = new Counter(""); numGetAlls = new Counter(""); getCallbackNs = new Timer(""); numMissedLookups = new Counter(""); metricsRegistry = mock(MetricsRegistry.class); String groupName = LocalTable.class.getSimpleName(); when(metricsRegistry.newCounter(groupName, TABLE_ID + "-num-gets")).thenReturn(numGets); when(metricsRegistry.newCounter(groupName, TABLE_ID + "-num-getAlls")).thenReturn(numGetAlls); when(metricsRegistry.newCounter(groupName, TABLE_ID + "-num-missed-lookups")).thenReturn(numMissedLookups); when(metricsRegistry.newTimer(groupName, TABLE_ID + "-get-ns")).thenReturn(getNs); when(metricsRegistry.newTimer(groupName, TABLE_ID + "-getAll-ns")).thenReturn(getAllNs); when(metricsRegistry.newTimer(groupName, TABLE_ID + "-get-callback-ns")).thenReturn(getCallbackNs); }
@Before public void setUp() { putNs = new Timer(""); putAllNs = new Timer(""); deleteNs = new Timer(""); deleteAllNs = new Timer(""); flushNs = new Timer(""); numPuts = new Counter(""); numPutAlls = new Counter(""); numDeletes = new Counter(""); numDeleteAlls = new Counter(""); numFlushes = new Counter(""); putCallbackNs = new Timer(""); deleteCallbackNs = new Timer(""); metricsRegistry = mock(MetricsRegistry.class); String groupName = LocalTable.class.getSimpleName(); when(metricsRegistry.newTimer(groupName, TABLE_ID + "-put-ns")).thenReturn(putNs); when(metricsRegistry.newTimer(groupName, TABLE_ID + "-putAll-ns")).thenReturn(putAllNs); when(metricsRegistry.newTimer(groupName, TABLE_ID + "-delete-ns")).thenReturn(deleteNs); when(metricsRegistry.newTimer(groupName, TABLE_ID + "-deleteAll-ns")).thenReturn(deleteAllNs); when(metricsRegistry.newCounter(groupName, TABLE_ID + "-num-puts")).thenReturn(numPuts); when(metricsRegistry.newCounter(groupName, TABLE_ID + "-num-putAlls")).thenReturn(numPutAlls); when(metricsRegistry.newCounter(groupName, TABLE_ID + "-num-deletes")).thenReturn(numDeletes); when(metricsRegistry.newCounter(groupName, TABLE_ID + "-num-deleteAlls")).thenReturn(numDeleteAlls); when(metricsRegistry.newCounter(groupName, TABLE_ID + "-num-flushes")).thenReturn(numFlushes); when(metricsRegistry.newTimer(groupName, TABLE_ID + "-put-callback-ns")).thenReturn(putCallbackNs); when(metricsRegistry.newTimer(groupName, TABLE_ID + "-delete-callback-ns")).thenReturn(deleteCallbackNs); when(metricsRegistry.newTimer(groupName, TABLE_ID + "-flush-ns")).thenReturn(flushNs); kvStore = mock(KeyValueStore.class); }
private Context createMockContext(TableDescriptor tableDescriptor) { Context context = mock(Context.class); ContainerContext containerContext = mock(ContainerContext.class); when(context.getContainerContext()).thenReturn(containerContext); MetricsRegistry metricsRegistry = mock(MetricsRegistry.class); when(metricsRegistry.newTimer(anyString(), anyString())).thenReturn(mock(Timer.class)); when(metricsRegistry.newCounter(anyString(), anyString())).thenReturn(mock(Counter.class)); when(containerContext.getContainerMetricsRegistry()).thenReturn(metricsRegistry); TaskContextImpl taskContext = mock(TaskContextImpl.class); when(context.getTaskContext()).thenReturn(taskContext); TaskName taskName = new TaskName("MyTask"); TaskModel taskModel = mock(TaskModel.class); when(taskModel.getTaskName()).thenReturn(taskName); when(context.getTaskContext().getTaskModel()).thenReturn(taskModel); ContainerModel containerModel = mock(ContainerModel.class); when(containerModel.getTasks()).thenReturn(ImmutableMap.of(taskName, taskModel)); when(containerContext.getContainerModel()).thenReturn(containerModel); String containerId = "container-1"; JobModel jobModel = mock(JobModel.class); when(taskContext.getJobModel()).thenReturn(jobModel); when(jobModel.getContainers()).thenReturn(ImmutableMap.of(containerId, containerModel)); JobContext jobContext = mock(JobContext.class); when(jobContext.getConfig()).thenReturn(new MapConfig(tableDescriptor.toConfig(new MapConfig()))); when(context.getJobContext()).thenReturn(jobContext); return context; }