private MonitoringServices() { registerMBean(); perfTimerListeners = 0; structuralTimerListeners = 0; killTimerOnExit(); startPerformanceUpdates(); }
@Override public synchronized void setStructuralUpdates(boolean value) { if (value == structuralTimerStarted) return; if (!structuralTimerStarted) startStructuralUpdates(); else stopStructuralUpdates(); }
@Override public synchronized void setPerformanceUpdates(boolean value) { if (value == perfTimerStarted) return; if (!perfTimerStarted) startPerformanceUpdates(); else stopPerformanceUpdates(); }
public void unregisterMBean() { try { if (registered) { ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(name)); MonitoringServices.getInstance().removePerfNotificationListener(this); } this.registered = false; } catch (InstanceNotFoundException | MBeanRegistrationException | MalformedObjectNameException ex) { ex.printStackTrace(); } }
private void registerMBean() { try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName mxbeanName = new ObjectName(name); mbs.registerMBean(this, mxbeanName); MonitoringServices.getInstance().addPerfNotificationListener(this, name); this.registered = true; } catch (InstanceAlreadyExistsException ex) { throw new RuntimeException(ex); } catch (MBeanRegistrationException ex) { ex.printStackTrace(); } catch (NotCompliantMBeanException | MalformedObjectNameException ex) { throw new AssertionError(ex); } }
public synchronized void addPerfNotificationListener(NotificationListener listener, Object handback) { timer.addNotificationListener(listener, new NotificationFilter() { @Override public boolean isNotificationEnabled(Notification notification) { return "perfTimer".equals(notification.getType()); } }, handback); perfTimerListeners++; manageTimer(); }
private MonitoringServices() { registerMBean(); perfTimerListeners = 0; structuralTimerListeners = 0; startPerformanceUpdates(); }
public void unregisterMBean() { try { if (registered) { ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(name)); MonitoringServices.getInstance().removePerfNotificationListener(this); } this.registered = false; } catch (InstanceNotFoundException | MBeanRegistrationException | MalformedObjectNameException ex) { ex.printStackTrace(); } }
@SuppressWarnings({"CallToPrintStackTrace", "CallToThreadDumpStack"}) protected void registerMBean() { try { final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); final ObjectName mxbeanName = new ObjectName(mbeanName); mbs.registerMBean(this, mxbeanName); this.registered = true; } catch (InstanceAlreadyExistsException ex) { throw new RuntimeException(ex); } catch (MBeanRegistrationException ex) { ex.printStackTrace(); } catch (NotCompliantMBeanException ex) { throw new AssertionError(ex); } catch (MalformedObjectNameException ex) { throw new AssertionError(ex); } MonitoringServices.getInstance().addPerfNotificationListener(this, mbeanName); }
@Override public synchronized void startPerformanceUpdates() { if (!perfTimerStarted) { timer.addNotification("perfTimer", null, null, new Date(System.currentTimeMillis()), perfTimerPeriod); this.perfTimerStarted = true; } manageTimer(); }
@SuppressWarnings({"CallToPrintStackTrace", "CallToThreadDumpStack"}) private void unregister() { try { if (registered) { MonitoringServices.getInstance().removePerfNotificationListener(this); ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(mbeanName)); } this.registered = false; } catch (InstanceNotFoundException ex) { ex.printStackTrace(); } catch (MBeanRegistrationException ex) { ex.printStackTrace(); } catch (MalformedObjectNameException ex) { throw new AssertionError(ex); } }
@SuppressWarnings({"CallToPrintStackTrace", "CallToThreadDumpStack"}) private void registerMBean() { try { final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); final ObjectName mxbeanName = new ObjectName(mbeanName); mbs.registerMBean(this, mxbeanName); this.registered = true; } catch (InstanceAlreadyExistsException ex) { throw new RuntimeException(ex); } catch (MBeanRegistrationException ex) { ex.printStackTrace(); } catch (NotCompliantMBeanException ex) { throw new AssertionError(ex); } catch (MalformedObjectNameException ex) { throw new AssertionError(ex); } MonitoringServices.getInstance().addPerfNotificationListener(this, mbeanName); }
@Override public synchronized void setStructuraltimerPeriod(int structuralTimerPeriod) { if (structuralTimerPeriod != this.structuralTimerPeriod) { this.structuralTimerPeriod = structuralTimerPeriod; if (structuralTimerStarted) { stopStructuralUpdates(); startStructuralUpdates(); } } }
@Override public synchronized void startStructuralUpdates() { if (!structuralTimerStarted) { timer.addNotification("structTimer", null, null, new Date(System.currentTimeMillis()), structuralTimerPeriod); this.structuralTimerStarted = true; } manageTimer(); }
@Override public synchronized void setPerformanceTimerPeriod(int perfTimerPeriod) { if (perfTimerPeriod != this.perfTimerPeriod) { this.perfTimerPeriod = perfTimerPeriod; if (perfTimerStarted) { stopPerformanceUpdates(); startPerformanceUpdates(); } } }
@SuppressWarnings({"CallToPrintStackTrace", "CallToThreadDumpStack"}) @Override public void unregister() { try { if (registered) { MonitoringServices.getInstance().removePerfNotificationListener(this); ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(mbeanName)); } this.registered = false; } catch (InstanceNotFoundException ex) { ex.printStackTrace(); } catch (MBeanRegistrationException ex) { ex.printStackTrace(); } catch (MalformedObjectNameException ex) { throw new AssertionError(ex); } }
private void registerMBean() { try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName mxbeanName = new ObjectName(name); if (mbs.isRegistered(mxbeanName)) { try { LOG.info("MBean named {} is already registered. Unregistering it.", name); mbs.unregisterMBean(mxbeanName); } catch (InstanceNotFoundException e) { } } mbs.registerMBean(this, mxbeanName); MonitoringServices.getInstance().addPerfNotificationListener(this, name); this.registered = true; } catch (InstanceAlreadyExistsException ex) { throw new RuntimeException(ex); } catch (MBeanRegistrationException ex) { ex.printStackTrace(); } catch (NotCompliantMBeanException | MalformedObjectNameException ex) { throw new AssertionError(ex); } }
@Override public synchronized void setStructuraltimerPeriod(int structuralTimerPeriod) { if (structuralTimerPeriod != this.structuralTimerPeriod) { this.structuralTimerPeriod = structuralTimerPeriod; if (structuralTimerStarted) { stopStructuralUpdates(); startStructuralUpdates(); } } }
@Override public synchronized void stopStructuralUpdates() { if (structuralTimerStarted) { try { timer.removeNotifications("structTimer"); this.structuralTimerStarted = false; } catch (InstanceNotFoundException ex) { } } manageTimer(); }
@Override public synchronized void setPerformanceTimerPeriod(int perfTimerPeriod) { if (perfTimerPeriod != this.perfTimerPeriod) { this.perfTimerPeriod = perfTimerPeriod; if (perfTimerStarted) { stopPerformanceUpdates(); startPerformanceUpdates(); } } }