本文整理汇总了Java中com.alibaba.dubbo.monitor.support.MonitorFilter类的典型用法代码示例。如果您正苦于以下问题:Java MonitorFilter类的具体用法?Java MonitorFilter怎么用?Java MonitorFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MonitorFilter类属于com.alibaba.dubbo.monitor.support包,在下文中一共展示了MonitorFilter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFilter
import com.alibaba.dubbo.monitor.support.MonitorFilter; //导入依赖的package包/类
@Test
public void testFilter() throws Exception {
MonitorFilter monitorFilter = new MonitorFilter();
monitorFilter.setMonitorFactory(monitorFactory);
Invocation invocation = new RpcInvocation("aaa", new Class<?>[0], new Object[0]);
RpcContext.getContext().setRemoteAddress(NetUtils.getLocalHost(), 20880).setLocalAddress(NetUtils.getLocalHost(), 2345);
monitorFilter.invoke(serviceInvoker, invocation);
while (lastStatistics == null) {
Thread.sleep(10);
}
Assert.assertEquals("abc", lastStatistics.getParameter(MonitorService.APPLICATION));
Assert.assertEquals(MonitorService.class.getName(), lastStatistics.getParameter(MonitorService.INTERFACE));
Assert.assertEquals("aaa", lastStatistics.getParameter(MonitorService.METHOD));
Assert.assertEquals(NetUtils.getLocalHost() + ":20880", lastStatistics.getParameter(MonitorService.PROVIDER));
Assert.assertEquals(NetUtils.getLocalHost(), lastStatistics.getAddress());
Assert.assertEquals(null, lastStatistics.getParameter(MonitorService.CONSUMER));
Assert.assertEquals(1, lastStatistics.getParameter(MonitorService.SUCCESS, 0));
Assert.assertEquals(0, lastStatistics.getParameter(MonitorService.FAILURE, 0));
Assert.assertEquals(1, lastStatistics.getParameter(MonitorService.CONCURRENT, 0));
Assert.assertEquals(invocation, lastInvocation);
}
示例2: testGenericFilter
import com.alibaba.dubbo.monitor.support.MonitorFilter; //导入依赖的package包/类
@Test
public void testGenericFilter() throws Exception {
MonitorFilter monitorFilter = new MonitorFilter();
monitorFilter.setMonitorFactory(monitorFactory);
Invocation invocation = new RpcInvocation("$invoke", new Class<?>[] { String.class, String[].class, Object[].class }, new Object[] { "xxx", new String[] {}, new Object[] {} } );
RpcContext.getContext().setRemoteAddress(NetUtils.getLocalHost(), 20880).setLocalAddress(NetUtils.getLocalHost(), 2345);
monitorFilter.invoke(serviceInvoker, invocation);
while (lastStatistics == null) {
Thread.sleep(10);
}
Assert.assertEquals("abc", lastStatistics.getParameter(MonitorService.APPLICATION));
Assert.assertEquals(MonitorService.class.getName(), lastStatistics.getParameter(MonitorService.INTERFACE));
Assert.assertEquals("xxx", lastStatistics.getParameter(MonitorService.METHOD));
Assert.assertEquals(NetUtils.getLocalHost() + ":20880", lastStatistics.getParameter(MonitorService.PROVIDER));
Assert.assertEquals(NetUtils.getLocalHost(), lastStatistics.getAddress());
Assert.assertEquals(null, lastStatistics.getParameter(MonitorService.CONSUMER));
Assert.assertEquals(1, lastStatistics.getParameter(MonitorService.SUCCESS, 0));
Assert.assertEquals(0, lastStatistics.getParameter(MonitorService.FAILURE, 0));
Assert.assertEquals(1, lastStatistics.getParameter(MonitorService.CONCURRENT, 0));
Assert.assertEquals(invocation, lastInvocation);
}