@Test public void onExit() { FakeMetricExtension extension = new FakeMetricExtension(); MetricExtensionProvider.addMetricExtension(extension); MetricExitCallback exitCallback = new MetricExitCallback(); StringResourceWrapper resourceWrapper = new StringResourceWrapper("resource", EntryType.OUT); int count = 2; Object[] args = {"args1", "args2"}; extension.rt = 20; extension.success = 6; extension.thread = 10; Context context = mock(Context.class); Entry entry = mock(Entry.class); when(entry.getError()).thenReturn(null); when(entry.getCreateTime()).thenReturn(TimeUtil.currentTimeMillis() - 100); when(context.getCurEntry()).thenReturn(entry); exitCallback.onExit(context, resourceWrapper, count, args); Assert.assertEquals(120, extension.rt, 10); Assert.assertEquals(extension.success, 6 + count); Assert.assertEquals(extension.thread, 10 - 1); }
@Override public void onExit(Context context, ResourceWrapper resourceWrapper, int count, Object... args) { for (MetricExtension m : MetricExtensionProvider.getMetricExtensions()) { if (context.getCurEntry().getError() == null) { long realRt = TimeUtil.currentTimeMillis() - context.getCurEntry().getCreateTime(); m.addRt(resourceWrapper.getName(), realRt, args); m.addSuccess(resourceWrapper.getName(), count, args); m.decreaseThreadNum(resourceWrapper.getName(), args); } } }
MetricExitCallback implements ProcessorSlotExitCallback { @Override public void onExit(Context context, ResourceWrapper resourceWrapper, int count, Object... args) { for (MetricExtension m : MetricExtensionProvider.getMetricExtensions()) { if (context.getCurEntry().getError() == null) { long realRt = TimeUtil.currentTimeMillis() - context.getCurEntry().getCreateTime(); m.addRt(resourceWrapper.getName(), realRt, args); m.addSuccess(resourceWrapper.getName(), count, args); m.decreaseThreadNum(resourceWrapper.getName(), args); } } } }
MetricExitCallback implements ProcessorSlotExitCallback { @Override public void onExit(Context context, ResourceWrapper resourceWrapper, int count, Object... args) { for (MetricExtension m : MetricExtensionProvider.getMetricExtensions()) { if (context.getCurEntry().getError() == null) { long realRt = TimeUtil.currentTimeMillis() - context.getCurEntry().getCreateTime(); m.addRt(resourceWrapper.getName(), realRt, args); m.addSuccess(resourceWrapper.getName(), count, args); m.decreaseThreadNum(resourceWrapper.getName(), args); } } }  }
MetricExitCallback implements ProcessorSlotExitCallback { @Override public void onExit(Context context, ResourceWrapper resourceWrapper, int count, Object... args) { for (MetricExtension m : MetricExtensionProvider.getMetricExtensions()) { if (context.getCurEntry().getError() == null) { long realRt = TimeUtil.currentTimeMillis() - context.getCurEntry().getCreateTime(); m.addRt(resourceWrapper.getName(), realRt, args); m.addSuccess(resourceWrapper.getName(), count, args); m.decreaseThreadNum(resourceWrapper.getName(), args); } } }  @Override void onExit(Context context, ResourceWrapper resourceWrapper, int count, Object... args); }
MetricExitCallback implements ProcessorSlotExitCallback { @Override public void onExit(Context context, ResourceWrapper resourceWrapper, int count, Object... args) { for (MetricExtension m : MetricExtensionProvider.getMetricExtensions()) { if (context.getCurEntry().getError() == null) { long realRt = TimeUtil.currentTimeMillis() - context.getCurEntry().getCreateTime(); m.addRt(resourceWrapper.getName(), realRt, args); m.addSuccess(resourceWrapper.getName(), count, args); m.decreaseThreadNum(resourceWrapper.getName(), args); } } }  @Override void onExit(Context context, ResourceWrapper resourceWrapper, int count, Object... args);  }