/** * Unregister all StreamScopeMXBean for the oplet. * no-op if none registered. * <BR> * N.B. This does not unregister StreamScopes from the underlying StreamScopeRegistry. * @param jobId * @param opletId */ void unregister(String jobId, String opletId) { for (String controlId : controlIds(jobId, opletId)) { cs.unregister(controlId); } }
controlService.unregister(controlId); logger.trace("Control {} unregistered", controlId);
controlService.unregister(controlId); logger.trace("Control {} unregistered", controlId);
@Test(expected=RuntimeException.class) public void testDoubleunregister() throws Exception { ControlService cs = new JMXControlService(DOMAIN, new Hashtable<>()); String type = "timer"; String id = "a"; String alias = "ControlA"; String controlId = cs.registerControl(type, id, alias, TimerMBean.class, new Timer()); cs.unregister(controlId); cs.unregister(controlId); } }
private void registerControl(ControlService cs) { if (cs == null) throw new IllegalArgumentException("ControlService must not be null"); logger.trace("Registering control for job id {}, job name {}", job.getId(), job.getName()); this.controlService = cs; JobMXBean oldControl = cs.getControl(JobMXBean.TYPE, job.getName(), JobMXBean.class); if (oldControl != null) { String oldControlId = cs.getControlId(JobMXBean.TYPE, job.getName(), JobMXBean.class); if (oldControlId != null) { if (isJobClosed(oldControl)) { cs.unregister(oldControlId); logger.debug("Old control id {} for CLOSED job name {} was unregistered", oldControlId, job.getName()); } else { throw new IllegalStateException( "Cannot register job control for alias " + job.getName() + " because a job control with id " + oldControlId + " for the same alias already exists and is not CLOSED"); } } } this.controlId = cs.registerControl(JobMXBean.TYPE, job.getId(), job.getName(), JobMXBean.class, this); logger.debug("Control for job id {}, job name {} was registered with id {}", job.getId(), job.getName(), controlId); }
private void registerControl(ControlService cs) { if (cs == null) throw new IllegalArgumentException("ControlService must not be null"); logger.trace("Registering control for job id {}, job name {}", job.getId(), job.getName()); this.controlService = cs; JobMXBean oldControl = cs.getControl(JobMXBean.TYPE, job.getName(), JobMXBean.class); if (oldControl != null) { String oldControlId = cs.getControlId(JobMXBean.TYPE, job.getName(), JobMXBean.class); if (oldControlId != null) { if (isJobClosed(oldControl)) { cs.unregister(oldControlId); logger.debug("Old control id {} for CLOSED job name {} was unregistered", oldControlId, job.getName()); } else { throw new IllegalStateException( "Cannot register job control for alias " + job.getName() + " because a job control with id " + oldControlId + " for the same alias already exists and is not CLOSED"); } } } this.controlId = cs.registerControl(JobMXBean.TYPE, job.getId(), job.getName(), JobMXBean.class, this); logger.debug("Control for job id {}, job name {} was registered with id {}", job.getId(), job.getName(), controlId); }
@Test public void testControlObject() throws Exception { ControlService cs = new JMXControlService(DOMAIN, new Hashtable<>()); String type = "timer"; String id = "a"; String alias = "ControlA"; String controlId = cs.registerControl(type, id, alias, TimerMBean.class, new Timer()); assertNotNull(controlId); ObjectName on = ObjectName.getInstance(controlId); assertEquals(DOMAIN, on.getDomain()); assertEquals(type, ObjectName.unquote(on.getKeyProperty("type"))); assertEquals(id, ObjectName.unquote(on.getKeyProperty("id"))); assertEquals(alias, ObjectName.unquote(on.getKeyProperty("alias"))); assertEquals(TimerMBean.class.getName(), ObjectName.unquote(on.getKeyProperty("interface"))); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); assertTrue(mbs.isRegistered(on)); cs.unregister(controlId); assertFalse(mbs.isRegistered(on)); }
@Test(expected=RuntimeException.class) public void testDoubleRegister() throws Exception { ControlService cs = new JMXControlService(DOMAIN, new Hashtable<>()); String type = "timer"; String id = "a"; String alias = "ControlA"; String controlId = cs.registerControl(type, id, alias, TimerMBean.class, new Timer()); try { cs.registerControl(type, id, alias, TimerMBean.class, new Timer()); } finally { cs.unregister(controlId); } } @Test(expected=RuntimeException.class)
cs.unregister(controlId); assertFalse(mbs.isRegistered(on));