@Test public void testRegisterApplicationNodeInCollectServer() throws MalformedURLException { MonitoringFilter.registerApplicationNodeInCollectServer(null, new URL("http: MonitoringFilter.registerApplicationNodeInCollectServer("test", new URL("http: try { MonitoringFilter.registerApplicationNodeInCollectServer(null, null, new URL("http: } catch (final IllegalArgumentException e) { assertNotNull("e", e); } try { MonitoringFilter.registerApplicationNodeInCollectServer(null, new URL("http: } catch (final IllegalArgumentException e) { assertNotNull("e", e); } }
public static void registerApplicationNodeInCollectServer(String applicationName, URL collectServerUrl, URL applicationNodeUrl) { if (collectServerUrl == null || applicationNodeUrl == null) { throw new IllegalArgumentException( "collectServerUrl and applicationNodeUrl must not be null"); } final String appName; if (applicationName == null) { appName = Parameters.getCurrentApplication(); } else { appName = applicationName; } final URL registerUrl; try { registerUrl = new URL(collectServerUrl.toExternalForm() + "?appName=" + URLEncoder.encode(appName, "UTF-8") + "&appUrls=" + URLEncoder.encode(applicationNodeUrl.toExternalForm(), "UTF-8") + "&action=registerNode"); unregisterApplicationNodeInCollectServerUrl = new URL( registerUrl.toExternalForm().replace("registerNode", "unregisterNode")); } catch (final IOException e) { throw new IllegalArgumentException(e); } final Thread thread = new Thread("javamelody registerApplicationNodeInCollectServer") { @Override public void run() { try { Thread.sleep(10000); } catch (final InterruptedException e) { throw new IllegalStateException(e); } try { new LabradorRetriever(registerUrl).post(null); LOG.info("application node added to the collect server"); } catch (final IOException e) { LOG.warn("Unable to register application's node in the collect server ( " + e + ')', e); } } }; thread.setDaemon(true); thread.start(); }
MonitoringFilter implements Filter { public static void registerApplicationNodeInCollectServer(String applicationName, URL collectServerUrl, URL applicationNodeUrl) { if (collectServerUrl == null || applicationNodeUrl == null) { throw new IllegalArgumentException( "collectServerUrl and applicationNodeUrl must not be null"); } final String appName; if (applicationName == null) { appName = Parameters.getCurrentApplication(); } else { appName = applicationName; } final URL registerUrl; try { registerUrl = new URL(collectServerUrl.toExternalForm() + "?appName=" + URLEncoder.encode(appName, "UTF-8") + "&appUrls=" + URLEncoder.encode(applicationNodeUrl.toExternalForm(), "UTF-8") + "&action=registerNode"); unregisterApplicationNodeInCollectServerUrl = new URL( registerUrl.toExternalForm().replace("registerNode", "unregisterNode")); } catch (final IOException e) { throw new IllegalArgumentException(e); } final Thread thread = new Thread("javamelody registerApplicationNodeInCollectServer") { @Override public void run() { try { Thread.sleep(10000); } catch (final InterruptedException e) { throw new IllegalStateException(e); } try { new LabradorRetriever(registerUrl).post(null); LOG.info("application node added to the collect server"); } catch (final IOException e) { LOG.warn("Unable to register application's node in the collect server ( " + e + ')', e); } } }; thread.setDaemon(true); thread.start(); } }
MonitoringFilter implements Filter { public static void registerApplicationNodeInCollectServer(String applicationName, URL collectServerUrl, URL applicationNodeUrl) { if (collectServerUrl == null || applicationNodeUrl == null) { throw new IllegalArgumentException( "collectServerUrl and applicationNodeUrl must not be null"); } final String appName; if (applicationName == null) { appName = Parameters.getCurrentApplication(); } else { appName = applicationName; } final URL registerUrl; try { registerUrl = new URL(collectServerUrl.toExternalForm() + "?appName=" + URLEncoder.encode(appName, "UTF-8") + "&appUrls=" + URLEncoder.encode(applicationNodeUrl.toExternalForm(), "UTF-8") + "&action=registerNode"); unregisterApplicationNodeInCollectServerUrl = new URL( registerUrl.toExternalForm().replace("registerNode", "unregisterNode")); } catch (final IOException e) { throw new IllegalArgumentException(e); } final Thread thread = new Thread("javamelody registerApplicationNodeInCollectServer") { @Override public void run() { try { Thread.sleep(10000); } catch (final InterruptedException e) { throw new IllegalStateException(e); } try { new LabradorRetriever(registerUrl).post(null); LOG.info("application node added to the collect server"); } catch (final IOException e) { LOG.warn("Unable to register application's node in the collect server ( " + e + ')', e); } } }; thread.setDaemon(true); thread.start(); } MonitoringFilter(); }
MonitoringFilter implements Filter { public static void registerApplicationNodeInCollectServer(String applicationName, URL collectServerUrl, URL applicationNodeUrl) { if (collectServerUrl == null || applicationNodeUrl == null) { throw new IllegalArgumentException( "collectServerUrl and applicationNodeUrl must not be null"); } final String appName; if (applicationName == null) { appName = Parameters.getCurrentApplication(); } else { appName = applicationName; } final URL registerUrl; try { registerUrl = new URL(collectServerUrl.toExternalForm() + "?appName=" + URLEncoder.encode(appName, "UTF-8") + "&appUrls=" + URLEncoder.encode(applicationNodeUrl.toExternalForm(), "UTF-8") + "&action=registerNode"); unregisterApplicationNodeInCollectServerUrl = new URL( registerUrl.toExternalForm().replace("registerNode", "unregisterNode")); } catch (final IOException e) { throw new IllegalArgumentException(e); } final Thread thread = new Thread("javamelody registerApplicationNodeInCollectServer") { @Override public void run() { try { Thread.sleep(10000); } catch (final InterruptedException e) { throw new IllegalStateException(e); } try { new LabradorRetriever(registerUrl).post(null); LOG.info("application node added to the collect server"); } catch (final IOException e) { LOG.warn("Unable to register application's node in the collect server ( " + e + ')', e); } } }; thread.setDaemon(true); thread.start(); } MonitoringFilter(); String getApplicationType(); void setApplicationType(final String applicationType); @Override void init(FilterConfig config); @Override void destroy(); @Override void doFilter(ServletRequest request, ServletResponse response, FilterChain chain); static void registerApplicationNodeInCollectServer(String applicationName,
			URL collectServerUrl, URL applicationNodeUrl); static void unregisterApplicationNodeInCollectServer(); }
MonitoringFilter implements Filter { public static void registerApplicationNodeInCollectServer(String applicationName, URL collectServerUrl, URL applicationNodeUrl) { if (collectServerUrl == null || applicationNodeUrl == null) { throw new IllegalArgumentException( "collectServerUrl and applicationNodeUrl must not be null"); } final String appName; if (applicationName == null) { appName = Parameters.getCurrentApplication(); } else { appName = applicationName; } final URL registerUrl; try { registerUrl = new URL(collectServerUrl.toExternalForm() + "?appName=" + URLEncoder.encode(appName, "UTF-8") + "&appUrls=" + URLEncoder.encode(applicationNodeUrl.toExternalForm(), "UTF-8") + "&action=registerNode"); unregisterApplicationNodeInCollectServerUrl = new URL( registerUrl.toExternalForm().replace("registerNode", "unregisterNode")); } catch (final IOException e) { throw new IllegalArgumentException(e); } final Thread thread = new Thread("javamelody registerApplicationNodeInCollectServer") { @Override public void run() { try { Thread.sleep(10000); } catch (final InterruptedException e) { throw new IllegalStateException(e); } try { new LabradorRetriever(registerUrl).post(null); LOG.info("application node added to the collect server"); } catch (final IOException e) { LOG.warn("Unable to register application's node in the collect server ( " + e + ')', e); } } }; thread.setDaemon(true); thread.start(); } MonitoringFilter(); String getApplicationType(); void setApplicationType(final String applicationType); @Override void init(FilterConfig config); @Override void destroy(); @Override void doFilter(ServletRequest request, ServletResponse response, FilterChain chain); static void registerApplicationNodeInCollectServer(String applicationName,
			URL collectServerUrl, URL applicationNodeUrl); static void unregisterApplicationNodeInCollectServer();  }