public boolean isStarted() { return monitor.isStarted(); }
public boolean isStarted() { return monitor.isStarted(); }
public void run() { if (etmMonitor.isStarted()) { etmMonitor.stop(); } } }
/** * Create a JETM monitor. * * @return An {@link EtmMonitor} object. */ public static EtmMonitor getEtmMonitor() { final EtmMonitor monitor = EtmManager.getEtmMonitor(); if (monitor.isStarted()) return monitor; return NO_OP_MONITOR; }
public void run() { if (etmMonitor.isStarted()) { etmMonitor.stop(); } } }
public Object getAttribute(String string) throws AttributeNotFoundException, MBeanException, ReflectionException { if ("started".equals(string)) { return (etmMonitor.isStarted()) ? Boolean.TRUE : Boolean.FALSE; } else if ("collecting".equals(string)) { return (etmMonitor.isCollecting()) ? Boolean.TRUE : Boolean.FALSE; } else if ("startDate".equals(string)) { return (etmMonitor.getMetaData().getStartTime()); } else if ("lastResetDate".equals(string)) { return etmMonitor.getMetaData().getLastResetTime(); } else { throw new AttributeNotFoundException(string); } }
public Object getAttribute(String string) throws AttributeNotFoundException, MBeanException, ReflectionException { if ("started".equals(string)) { return (etmMonitor.isStarted()) ? Boolean.TRUE : Boolean.FALSE; } else if ("collecting".equals(string)) { return (etmMonitor.isCollecting()) ? Boolean.TRUE : Boolean.FALSE; } else if ("startDate".equals(string)) { return (etmMonitor.getMetaData().getStartTime()); } else if ("lastResetDate".equals(string)) { return etmMonitor.getMetaData().getLastResetTime(); } else { throw new AttributeNotFoundException(string); } }
/** * Create a point used for measurement. * * @param pointOwner * The {@link Class} of the class that owns the requested point instance. * @param methodSignature * The signature of the method in which the point is being used. * @return An {@link EtmPoint}. */ public static EtmPoint getPoint(final Class<?> pointOwner, final String methodSignature) { final EtmMonitor monitor = EtmManager.getEtmMonitor(); final String measurementName = pointOwner.getCanonicalName() + ": " + methodSignature; return monitor.isStarted() ? monitor.createPoint(measurementName) : new NoOpEtmPoint(measurementName); } }
/** * Enables performance monitoring using {@link etm.core.configuration.BasicEtmConfigurator}. * */ public void enableBasicConfig() { if (!EtmManager.getEtmMonitor().isStarted()) { BasicEtmConfigurator.configure(true); EtmManager.getEtmMonitor().start(); } else { LOG.warn("Etm subsystem already initialized. Ignoring init."); } }
protected void enable(URL url) { if (!EtmManager.getEtmMonitor().isStarted()) { XmlEtmConfigurator.configure(url); EtmManager.getEtmMonitor().start(); } else { LOG.warn("Etm subsystem already initialized. Ignoring init."); } }
public void testFilePath() throws Exception { File file = new File(System.getProperty("java.io.tmpdir"), "jetm-config.xml"); try { FileOutputStream out = new FileOutputStream(file); out.write(("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<!DOCTYPE jetm-config PUBLIC \"-// void.fm //DTD JETM Config 1.0//EN\" \"http://jetm.void.fm/dtd/jetm_config_1_0.dtd\">\n" + "<jetm-config>\n" + "\n" + "</jetm-config>").getBytes()); EtmManager.reset(); EtmMonitorContextListener listener = new EtmMonitorContextListener(); HashMap attributes = new HashMap(); attributes.put("jetm.config.filepath", file.getParentFile().getAbsolutePath()); ServletContext ctx = getServletContext(attributes); assertTrue(Proxy.isProxyClass(EtmManager.getEtmMonitor().getClass())); listener.contextInitialized(new ServletContextEvent(ctx)); assertFalse(Proxy.isProxyClass(EtmManager.getEtmMonitor().getClass())); assertTrue(EtmManager.getEtmMonitor().isStarted()); listener.contextDestroyed(new ServletContextEvent(ctx)); assertFalse(EtmManager.getEtmMonitor().isStarted()); } finally { if (file.exists()){ file.delete(); } } }
public void testSystemPropertyPath() throws Exception { File file = new File(System.getProperty("java.io.tmpdir"), "jetm-config.xml"); try { FileOutputStream out = new FileOutputStream(file); out.write(("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<!DOCTYPE jetm-config PUBLIC \"-// void.fm //DTD JETM Config 1.0//EN\" \"http://jetm.void.fm/dtd/jetm_config_1_0.dtd\">\n" + "<jetm-config>\n" + "\n" + "</jetm-config>").getBytes()); EtmManager.reset(); EtmMonitorContextListener listener = new EtmMonitorContextListener(); HashMap attributes = new HashMap(); attributes.put("jetm.config.filepath", "${myapp.jetm.config}"); System.setProperty("myapp.jetm.config", file.getParentFile().getAbsolutePath()); ServletContext ctx = getServletContext(attributes); assertTrue(Proxy.isProxyClass(EtmManager.getEtmMonitor().getClass())); listener.contextInitialized(new ServletContextEvent(ctx)); assertFalse(Proxy.isProxyClass(EtmManager.getEtmMonitor().getClass())); assertTrue(EtmManager.getEtmMonitor().isStarted()); listener.contextDestroyed(new ServletContextEvent(ctx)); assertFalse(EtmManager.getEtmMonitor().isStarted()); } finally { if (file.exists()){ file.delete(); } } }
public void testClassPath() throws Exception { EtmManager.reset(); EtmMonitorContextListener listener = new EtmMonitorContextListener(); HashMap attributes = new HashMap(); attributes.put("jetm.config.filename", "etm/contrib/integration/web/classpath-config.xml"); ServletContext ctx = getServletContext(attributes); assertTrue(Proxy.isProxyClass(EtmManager.getEtmMonitor().getClass())); listener.contextInitialized(new ServletContextEvent(ctx)); assertFalse(Proxy.isProxyClass(EtmManager.getEtmMonitor().getClass())); assertTrue(EtmManager.getEtmMonitor().isStarted()); listener.contextDestroyed(new ServletContextEvent(ctx)); assertFalse(EtmManager.getEtmMonitor().isStarted()); }
public void testAutostartConfig() throws Exception { URL url = locateResource("autostart-on-config.xml"); EtmManager.reset(); XmlEtmConfigurator.configure(url); EtmMonitor etmMonitor = EtmManager.getEtmMonitor(); assertTrue(etmMonitor.isStarted()); assertTrue(etmMonitor.isCollecting()); etmMonitor.stop(); url = locateResource("autostart-off-config.xml"); EtmManager.reset(); XmlEtmConfigurator.configure(url); etmMonitor = EtmManager.getEtmMonitor(); assertFalse(etmMonitor.isStarted()); assertTrue(etmMonitor.isCollecting()); }
public void testAutostartConfig() throws Exception { URL url = locateResource("autostart-on-config.xml"); EtmManager.reset(); XmlEtmConfigurator.configure(url); EtmMonitor etmMonitor = EtmManager.getEtmMonitor(); assertTrue(etmMonitor.isStarted()); assertTrue(etmMonitor.isCollecting()); etmMonitor.stop(); url = locateResource("autostart-off-config.xml"); EtmManager.reset(); XmlEtmConfigurator.configure(url); etmMonitor = EtmManager.getEtmMonitor(); assertFalse(etmMonitor.isStarted()); assertTrue(etmMonitor.isCollecting()); }
" <td class=\"noborder\">Monitoring status:</td>\n"); if (request.getEtmMonitor().isStarted()) { response.write(" <td class=\"noborder\"><span class=\"enabled\">enabled</span></td>\n"); } else {