com.alibaba.dubbo.monitor.MonitorService Java Examples
The following examples show how to use
com.alibaba.dubbo.monitor.MonitorService.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DubboMonitor.java From dubbox with Apache License 2.0 | 6 votes |
public DubboMonitor(Invoker<MonitorService> monitorInvoker, MonitorService monitorService) { this.monitorInvoker = monitorInvoker; this.monitorService = monitorService; this.monitorInterval = monitorInvoker.getUrl().getPositiveParameter("interval", 60000); // 启动统计信息收集定时器 sendFuture = scheduledExecutorService.scheduleWithFixedDelay(new Runnable() { public void run() { // 收集统计信息 try { send(); } catch (Throwable t) { // 防御性容错 logger.error("Unexpected error occur at send statistic, cause: " + t.getMessage(), t); } } }, monitorInterval, monitorInterval, TimeUnit.MILLISECONDS); }
Example #2
Source File: MonitorFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@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); }
Example #3
Source File: DubboMonitorFactory.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@Override protected Monitor createMonitor(URL url) { url = url.setProtocol(url.getParameter(Constants.PROTOCOL_KEY, "dubbo")); if (url.getPath() == null || url.getPath().length() == 0) { url = url.setPath(MonitorService.class.getName()); } String filter = url.getParameter(Constants.REFERENCE_FILTER_KEY); if (filter == null || filter.length() == 0) { filter = ""; } else { filter = filter + ","; } url = url.addParameters(Constants.CLUSTER_KEY, "failsafe", Constants.CHECK_KEY, String.valueOf(false), Constants.REFERENCE_FILTER_KEY, filter + "-monitor"); Invoker<MonitorService> monitorInvoker = protocol.refer(MonitorService.class, url); MonitorService monitorService = proxyFactory.getProxy(monitorInvoker); return new DubboMonitor(monitorInvoker, monitorService); }
Example #4
Source File: DubboMonitor.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
public DubboMonitor(Invoker<MonitorService> monitorInvoker, MonitorService monitorService) { this.monitorInvoker = monitorInvoker; this.monitorService = monitorService; this.monitorInterval = monitorInvoker.getUrl().getPositiveParameter("interval", 60000); // collect timer for collecting statistics data sendFuture = scheduledExecutorService.scheduleWithFixedDelay(new Runnable() { @Override public void run() { // collect data try { send(); } catch (Throwable t) { logger.error("Unexpected error occur at send statistic, cause: " + t.getMessage(), t); } } }, monitorInterval, monitorInterval, TimeUnit.MILLISECONDS); }
Example #5
Source File: MonitorFilterTest.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@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); }
Example #6
Source File: AbstractMonitorFactory.java From dubbo3 with Apache License 2.0 | 6 votes |
public Monitor getMonitor(URL url) { url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName()); String key = url.toServiceString(); LOCK.lock(); try { Monitor monitor = MONITORS.get(key); if (monitor != null) { return monitor; } monitor = createMonitor(url); if (monitor == null) { throw new IllegalStateException("Can not create monitor " + url); } MONITORS.put(key, monitor); return monitor; } finally { // 释放锁 LOCK.unlock(); } }
Example #7
Source File: MonitorFilterTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@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); }
Example #8
Source File: MonitorFilterTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@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); }
Example #9
Source File: MonitorFilterTest.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@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); }
Example #10
Source File: DubboMonitorFactroy.java From dubbox with Apache License 2.0 | 6 votes |
@Override protected Monitor createMonitor(URL url) { url = url.setProtocol(url.getParameter(Constants.PROTOCOL_KEY, "dubbo")); if (url.getPath() == null || url.getPath().length() == 0) { url = url.setPath(MonitorService.class.getName()); } String filter = url.getParameter(Constants.REFERENCE_FILTER_KEY); if (filter == null || filter.length() == 0) { filter = ""; } else { filter = filter + ","; } url = url.addParameters(Constants.CLUSTER_KEY, "failsafe", Constants.CHECK_KEY, String.valueOf(false), Constants.REFERENCE_FILTER_KEY, filter + "-monitor"); Invoker<MonitorService> monitorInvoker = protocol.refer(MonitorService.class, url); MonitorService monitorService = proxyFactory.getProxy(monitorInvoker); return new DubboMonitor(monitorInvoker, monitorService); }
Example #11
Source File: DubboMonitorFactroy.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
@Override protected Monitor createMonitor(URL url) { url = url.setProtocol(url.getParameter(Constants.PROTOCOL_KEY, "dubbo")); if (url.getPath() == null || url.getPath().length() == 0) { url = url.setPath(MonitorService.class.getName()); } String filter = url.getParameter(Constants.REFERENCE_FILTER_KEY); if (filter == null || filter.length() == 0) { filter = ""; } else { filter = filter + ","; } url = url.addParameters(Constants.CLUSTER_KEY, "failsafe", Constants.CHECK_KEY, String.valueOf(false), Constants.REFERENCE_FILTER_KEY, filter + "-monitor"); Invoker<MonitorService> monitorInvoker = protocol.refer(MonitorService.class, url); MonitorService monitorService = proxyFactory.getProxy(monitorInvoker); return new DubboMonitor(monitorInvoker, monitorService); }
Example #12
Source File: MonitorFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@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); }
Example #13
Source File: DubboMonitorFactroy.java From dubbox with Apache License 2.0 | 6 votes |
@Override protected Monitor createMonitor(URL url) { url = url.setProtocol(url.getParameter(Constants.PROTOCOL_KEY, "dubbo")); if (url.getPath() == null || url.getPath().length() == 0) { url = url.setPath(MonitorService.class.getName()); } String filter = url.getParameter(Constants.REFERENCE_FILTER_KEY); if (filter == null || filter.length() == 0) { filter = ""; } else { filter = filter + ","; } url = url.addParameters(Constants.CLUSTER_KEY, "failsafe", Constants.CHECK_KEY, String.valueOf(false), Constants.REFERENCE_FILTER_KEY, filter + "-monitor"); Invoker<MonitorService> monitorInvoker = protocol.refer(MonitorService.class, url); MonitorService monitorService = proxyFactory.getProxy(monitorInvoker); return new DubboMonitor(monitorInvoker, monitorService); }
Example #14
Source File: AbstractMonitorFactory.java From dubbox with Apache License 2.0 | 6 votes |
public Monitor getMonitor(URL url) { url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName()); String key = url.toServiceString(); LOCK.lock(); try { Monitor monitor = MONITORS.get(key); if (monitor != null) { return monitor; } monitor = createMonitor(url); if (monitor == null) { throw new IllegalStateException("Can not create monitor " + url); } MONITORS.put(key, monitor); return monitor; } finally { // 释放锁 LOCK.unlock(); } }
Example #15
Source File: MonitorFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@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); }
Example #16
Source File: MonitorFilterTest.java From dubbox with Apache License 2.0 | 6 votes |
@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); }
Example #17
Source File: AbstractMonitorFactory.java From dubbox with Apache License 2.0 | 6 votes |
public Monitor getMonitor(URL url) { url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName()); String key = url.toServiceString(); LOCK.lock(); try { Monitor monitor = MONITORS.get(key); if (monitor != null) { return monitor; } monitor = createMonitor(url); if (monitor == null) { throw new IllegalStateException("Can not create monitor " + url); } MONITORS.put(key, monitor); return monitor; } finally { // 释放锁 LOCK.unlock(); } }
Example #18
Source File: AbstractMonitorFactory.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
public Monitor getMonitor(URL url) { url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName()); String key = url.toServiceString(); LOCK.lock(); try { Monitor monitor = MONITORS.get(key); if (monitor != null) { return monitor; } monitor = createMonitor(url); if (monitor == null) { throw new IllegalStateException("Can not create monitor " + url); } MONITORS.put(key, monitor); return monitor; } finally { // 释放锁 LOCK.unlock(); } }
Example #19
Source File: DubboMonitorFactroy.java From dubbo3 with Apache License 2.0 | 6 votes |
@Override protected Monitor createMonitor(URL url) { url = url.setProtocol(url.getParameter(Constants.PROTOCOL_KEY, "dubbo")); if (url.getPath() == null || url.getPath().length() == 0) { url = url.setPath(MonitorService.class.getName()); } String filter = url.getParameter(Constants.REFERENCE_FILTER_KEY); if (filter == null || filter.length() == 0) { filter = ""; } else { filter = filter + ","; } url = url.addParameters(Constants.CLUSTER_KEY, "failsafe", Constants.CHECK_KEY, String.valueOf(false), Constants.REFERENCE_FILTER_KEY, filter + "-monitor"); Invoker<MonitorService> monitorInvoker = protocol.refer(MonitorService.class, url); MonitorService monitorService = proxyFactory.getProxy(monitorInvoker); return new DubboMonitor(monitorInvoker, monitorService); }
Example #20
Source File: MonitorFilterTest.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
@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); }
Example #21
Source File: AbstractMonitorFactory.java From dubbox with Apache License 2.0 | 6 votes |
public Monitor getMonitor(URL url) { url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName()); String key = url.toServiceString(); LOCK.lock(); try { Monitor monitor = MONITORS.get(key); if (monitor != null) { return monitor; } monitor = createMonitor(url); if (monitor == null) { throw new IllegalStateException("Can not create monitor " + url); } MONITORS.put(key, monitor); return monitor; } finally { // 释放锁 LOCK.unlock(); } }
Example #22
Source File: DubboMonitorTest.java From dubbo3 with Apache License 2.0 | 5 votes |
@Test public void testMonitorFactory() throws Exception { MockMonitorService monitorService = new MockMonitorService(); URL statistics = new URL("dubbo", "10.20.153.10", 0) .addParameter(MonitorService.APPLICATION, "morgan") .addParameter(MonitorService.INTERFACE, "MemberService") .addParameter(MonitorService.METHOD, "findPerson") .addParameter(MonitorService.CONSUMER, "10.20.153.11") .addParameter(MonitorService.SUCCESS, 1) .addParameter(MonitorService.FAILURE, 0) .addParameter(MonitorService.ELAPSED, 3) .addParameter(MonitorService.MAX_ELAPSED, 3) .addParameter(MonitorService.CONCURRENT, 1) .addParameter(MonitorService.MAX_CONCURRENT, 1); Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension(); ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension(); MonitorFactory monitorFactory = ExtensionLoader.getExtensionLoader(MonitorFactory.class).getAdaptiveExtension(); Exporter<MonitorService> exporter = protocol.export(proxyFactory.getInvoker(monitorService, MonitorService.class, URL.valueOf("dubbo://127.0.0.1:17979/" + MonitorService.class.getName()))); try { Monitor monitor = monitorFactory.getMonitor(URL.valueOf("dubbo://127.0.0.1:17979?interval=10")); try { monitor.collect(statistics); int i = 0; while(monitorService.getStatistics() == null && i < 200) { i ++; Thread.sleep(10); } URL result = monitorService.getStatistics(); Assert.assertEquals(1, result.getParameter(MonitorService.SUCCESS, 0)); Assert.assertEquals(3, result.getParameter(MonitorService.ELAPSED, 0)); } finally { monitor.destroy(); } } finally { exporter.unexport(); } }
Example #23
Source File: DubboMonitorTest.java From dubbox with Apache License 2.0 | 5 votes |
@Test public void testCount() throws Exception { DubboMonitor monitor = new DubboMonitor(monitorInvoker, monitorService); URL statistics = new URL("dubbo", "10.20.153.10", 0) .addParameter(MonitorService.APPLICATION, "morgan") .addParameter(MonitorService.INTERFACE, "MemberService") .addParameter(MonitorService.METHOD, "findPerson") .addParameter(MonitorService.CONSUMER, "10.20.153.11") .addParameter(MonitorService.SUCCESS, 1) .addParameter(MonitorService.FAILURE, 0) .addParameter(MonitorService.ELAPSED, 3) .addParameter(MonitorService.MAX_ELAPSED, 3) .addParameter(MonitorService.CONCURRENT, 1) .addParameter(MonitorService.MAX_CONCURRENT, 1); monitor.collect(statistics); while (lastStatistics == null) { Thread.sleep(10); } Assert.assertEquals(lastStatistics.getParameter(MonitorService.APPLICATION), "morgan"); Assert.assertEquals(lastStatistics.getProtocol(), "dubbo"); Assert.assertEquals(lastStatistics.getHost(), "10.20.153.10"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.APPLICATION), "morgan"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.INTERFACE), "MemberService"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.METHOD), "findPerson"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.CONSUMER), "10.20.153.11"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.SUCCESS), "1"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.FAILURE), "0"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.ELAPSED), "3"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.MAX_ELAPSED), "3"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.CONCURRENT), "1"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.MAX_CONCURRENT), "1"); monitor.destroy(); }
Example #24
Source File: DubboMonitorTest.java From dubbox with Apache License 2.0 | 5 votes |
@Test public void testMonitorFactory() throws Exception { MockMonitorService monitorService = new MockMonitorService(); URL statistics = new URL("dubbo", "10.20.153.10", 0) .addParameter(MonitorService.APPLICATION, "morgan") .addParameter(MonitorService.INTERFACE, "MemberService") .addParameter(MonitorService.METHOD, "findPerson") .addParameter(MonitorService.CONSUMER, "10.20.153.11") .addParameter(MonitorService.SUCCESS, 1) .addParameter(MonitorService.FAILURE, 0) .addParameter(MonitorService.ELAPSED, 3) .addParameter(MonitorService.MAX_ELAPSED, 3) .addParameter(MonitorService.CONCURRENT, 1) .addParameter(MonitorService.MAX_CONCURRENT, 1); Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension(); ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension(); MonitorFactory monitorFactory = ExtensionLoader.getExtensionLoader(MonitorFactory.class).getAdaptiveExtension(); Exporter<MonitorService> exporter = protocol.export(proxyFactory.getInvoker(monitorService, MonitorService.class, URL.valueOf("dubbo://127.0.0.1:17979/" + MonitorService.class.getName()))); try { Monitor monitor = monitorFactory.getMonitor(URL.valueOf("dubbo://127.0.0.1:17979?interval=10")); try { monitor.collect(statistics); int i = 0; while(monitorService.getStatistics() == null && i < 200) { i ++; Thread.sleep(10); } URL result = monitorService.getStatistics(); Assert.assertEquals(1, result.getParameter(MonitorService.SUCCESS, 0)); Assert.assertEquals(3, result.getParameter(MonitorService.ELAPSED, 0)); } finally { monitor.destroy(); } } finally { exporter.unexport(); } }
Example #25
Source File: StatisticsPageHandler.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
private void appendStatistics(File providerDir, long[] statistics) { statistics[0] += CountUtils.sum(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.SUCCESS)); statistics[1] += CountUtils.sum(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.SUCCESS)); statistics[2] += CountUtils.sum(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.FAILURE)); statistics[3] += CountUtils.sum(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.FAILURE)); statistics[4] += CountUtils.sum(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.ELAPSED)); statistics[5] += CountUtils.sum(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.ELAPSED)); statistics[6] = Math.max(statistics[6], CountUtils.max(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.MAX_ELAPSED))); statistics[7] = Math.max(statistics[7], CountUtils.max(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.MAX_ELAPSED))); statistics[8] = Math.max(statistics[8], CountUtils.max(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.MAX_CONCURRENT))); statistics[9] = Math.max(statistics[9], CountUtils.max(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.MAX_CONCURRENT))); }
Example #26
Source File: DubboMonitorTest.java From dubbox with Apache License 2.0 | 5 votes |
@Test public void testCount() throws Exception { DubboMonitor monitor = new DubboMonitor(monitorInvoker, monitorService); URL statistics = new URL("dubbo", "10.20.153.10", 0) .addParameter(MonitorService.APPLICATION, "morgan") .addParameter(MonitorService.INTERFACE, "MemberService") .addParameter(MonitorService.METHOD, "findPerson") .addParameter(MonitorService.CONSUMER, "10.20.153.11") .addParameter(MonitorService.SUCCESS, 1) .addParameter(MonitorService.FAILURE, 0) .addParameter(MonitorService.ELAPSED, 3) .addParameter(MonitorService.MAX_ELAPSED, 3) .addParameter(MonitorService.CONCURRENT, 1) .addParameter(MonitorService.MAX_CONCURRENT, 1); monitor.collect(statistics); while (lastStatistics == null) { Thread.sleep(10); } Assert.assertEquals(lastStatistics.getParameter(MonitorService.APPLICATION), "morgan"); Assert.assertEquals(lastStatistics.getProtocol(), "dubbo"); Assert.assertEquals(lastStatistics.getHost(), "10.20.153.10"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.APPLICATION), "morgan"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.INTERFACE), "MemberService"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.METHOD), "findPerson"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.CONSUMER), "10.20.153.11"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.SUCCESS), "1"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.FAILURE), "0"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.ELAPSED), "3"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.MAX_ELAPSED), "3"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.CONCURRENT), "1"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.MAX_CONCURRENT), "1"); monitor.destroy(); }
Example #27
Source File: DubboMonitorTest.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
@Test public void testMonitorFactory() throws Exception { MockMonitorService monitorService = new MockMonitorService(); URL statistics = new URL("dubbo", "10.20.153.10", 0) .addParameter(MonitorService.APPLICATION, "morgan") .addParameter(MonitorService.INTERFACE, "MemberService") .addParameter(MonitorService.METHOD, "findPerson") .addParameter(MonitorService.CONSUMER, "10.20.153.11") .addParameter(MonitorService.SUCCESS, 1) .addParameter(MonitorService.FAILURE, 0) .addParameter(MonitorService.ELAPSED, 3) .addParameter(MonitorService.MAX_ELAPSED, 3) .addParameter(MonitorService.CONCURRENT, 1) .addParameter(MonitorService.MAX_CONCURRENT, 1); Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension(); ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension(); MonitorFactory monitorFactory = ExtensionLoader.getExtensionLoader(MonitorFactory.class).getAdaptiveExtension(); Exporter<MonitorService> exporter = protocol.export(proxyFactory.getInvoker(monitorService, MonitorService.class, URL.valueOf("dubbo://127.0.0.1:17979/" + MonitorService.class.getName()))); try { Monitor monitor = monitorFactory.getMonitor(URL.valueOf("dubbo://127.0.0.1:17979?interval=10")); try { monitor.collect(statistics); int i = 0; while(monitorService.getStatistics() == null && i < 200) { i ++; Thread.sleep(10); } URL result = monitorService.getStatistics(); Assert.assertEquals(1, result.getParameter(MonitorService.SUCCESS, 0)); Assert.assertEquals(3, result.getParameter(MonitorService.ELAPSED, 0)); } finally { monitor.destroy(); } } finally { exporter.unexport(); } }
Example #28
Source File: StatisticsPageHandler.java From dubbo3 with Apache License 2.0 | 5 votes |
private void appendStatistics(File providerDir, long[] statistics) { statistics[0] += CountUtils.sum(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.SUCCESS)); statistics[1] += CountUtils.sum(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.SUCCESS)); statistics[2] += CountUtils.sum(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.FAILURE)); statistics[3] += CountUtils.sum(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.FAILURE)); statistics[4] += CountUtils.sum(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.ELAPSED)); statistics[5] += CountUtils.sum(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.ELAPSED)); statistics[6] = Math.max(statistics[6], CountUtils.max(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.MAX_ELAPSED))); statistics[7] = Math.max(statistics[7], CountUtils.max(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.MAX_ELAPSED))); statistics[8] = Math.max(statistics[8], CountUtils.max(new File(providerDir, MonitorService.CONSUMER + "." + MonitorService.MAX_CONCURRENT))); statistics[9] = Math.max(statistics[9], CountUtils.max(new File(providerDir, MonitorService.PROVIDER + "." + MonitorService.MAX_CONCURRENT))); }
Example #29
Source File: DubboMonitorTest.java From dubbo3 with Apache License 2.0 | 5 votes |
@Test public void testCount() throws Exception { DubboMonitor monitor = new DubboMonitor(monitorInvoker, monitorService); URL statistics = new URL("dubbo", "10.20.153.10", 0) .addParameter(MonitorService.APPLICATION, "morgan") .addParameter(MonitorService.INTERFACE, "MemberService") .addParameter(MonitorService.METHOD, "findPerson") .addParameter(MonitorService.CONSUMER, "10.20.153.11") .addParameter(MonitorService.SUCCESS, 1) .addParameter(MonitorService.FAILURE, 0) .addParameter(MonitorService.ELAPSED, 3) .addParameter(MonitorService.MAX_ELAPSED, 3) .addParameter(MonitorService.CONCURRENT, 1) .addParameter(MonitorService.MAX_CONCURRENT, 1); monitor.collect(statistics); while (lastStatistics == null) { Thread.sleep(10); } Assert.assertEquals(lastStatistics.getParameter(MonitorService.APPLICATION), "morgan"); Assert.assertEquals(lastStatistics.getProtocol(), "dubbo"); Assert.assertEquals(lastStatistics.getHost(), "10.20.153.10"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.APPLICATION), "morgan"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.INTERFACE), "MemberService"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.METHOD), "findPerson"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.CONSUMER), "10.20.153.11"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.SUCCESS), "1"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.FAILURE), "0"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.ELAPSED), "3"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.MAX_ELAPSED), "3"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.CONCURRENT), "1"); Assert.assertEquals(lastStatistics.getParameter(MonitorService.MAX_CONCURRENT), "1"); monitor.destroy(); }
Example #30
Source File: Statistics.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public Statistics(URL url) { this.url = url; this.application = url.getParameter(MonitorService.APPLICATION); this.service = url.getParameter(MonitorService.INTERFACE); this.method = url.getParameter(MonitorService.METHOD); this.group = url.getParameter(MonitorService.GROUP); this.version = url.getParameter(MonitorService.VERSION); this.client = url.getParameter(MonitorService.CONSUMER, url.getAddress()); this.server = url.getParameter(MonitorService.PROVIDER, url.getAddress()); }