public Recoverer() { String serverId = TransactionManagerServices.getConfiguration().getServerId(); if (serverId == null) serverId = ""; this.jmxName = "bitronix.tm:type=Recoverer,ServerId=" + ManagementRegistrar.makeValidName(serverId); ManagementRegistrar.register(jmxName, this); }
@Override public void shutdown() { ManagementRegistrar.unregister(jmxName); }
private static void runOrEnqueueCommand(ManagementCommand command) { if (commandQueue == null) command.run(); else { // Try to enqueue the command unless the queue is full. // Recover from a full queue by running already queued commands first to protect the async. implementation // from being vulnerable to DOS attacks. while (!commandQueue.offer(command)) normalizeAndRunQueuedCommands(); } }
@Test(expected = InstanceNotFoundException.class) public void testCanUnregister() throws Exception { TestBean testBean = new TestBean("1"); ManagementRegistrar.register(objectName, testBean); ManagementRegistrar.unregister(objectName); ManagementRegistrar.normalizeAndRunQueuedCommands(); mBeanServer.getAttribute(new ObjectName(objectName), "Name"); } }
@After public void tearDown() throws Exception { ManagementRegistrar.unregister(objectName); ManagementRegistrar.normalizeAndRunQueuedCommands(); }
public void setStatus(int status, Set<String> uniqueNames) throws BitronixSystemException { try { boolean force = (resourceManager.size() > 1) && (status == Status.STATUS_COMMITTING); if (log.isDebugEnabled()) log.debug("changing transaction status to " + Decoder.decodeStatus(status) + (force ? " (forced)" : "")); int oldStatus = this.status; this.status = status; journal.log(status, resourceManager.getGtrid(), uniqueNames); if (force) { journal.force(); } if (status == Status.STATUS_ACTIVE) ManagementRegistrar.register("bitronix.tm:type=Transaction,Gtrid=" + resourceManager.getGtrid(), this); fireTransactionStatusChangedEvent(oldStatus, status); } catch (IOException ex) { // if we cannot log, the TM must stop managing TX until the problem is fixed throw new BitronixSystemException("error logging status", ex); } }
/** * Unregister the management object with the specified name. * * @param name the name of the object. */ public static void unregister(String name) { if (mbeanServer == null) return; runOrEnqueueCommand(new ManagementUnregisterCommand(name)); }
/** * Unregister the management object with the specified name. * @param name the name of the object. */ public static void unregister(String name) { MBeanServer mbeanServer = getMBeanServer(); if (mbeanServer == null) return; try { mbeanServer.unregisterMBean(new ObjectName(name)); } catch (Exception ex) { log.warn("cannot unregister object with name " + name, ex); } }
@Test(expected = InstanceNotFoundException.class) public void testCanUnregister() throws Exception { TestBean testBean = new TestBean("1"); ManagementRegistrar.register(objectName, testBean); ManagementRegistrar.unregister(objectName); ManagementRegistrar.normalizeAndRunQueuedCommands(); mBeanServer.getAttribute(new ObjectName(objectName), "Name"); } }
@After public void tearDown() throws Exception { ManagementRegistrar.unregister(objectName); ManagementRegistrar.normalizeAndRunQueuedCommands(); }
public void setStatus(int status, Set<String> uniqueNames) throws BitronixSystemException { try { boolean force = (resourceManager.size() > 1) && (status == Status.STATUS_COMMITTING); if (log.isDebugEnabled()) log.debug("changing transaction status to " + Decoder.decodeStatus(status) + (force ? " (forced)" : "")); int oldStatus = this.status; this.status = status; journal.log(status, resourceManager.getGtrid(), uniqueNames); if (force) { journal.force(); } if (status == Status.STATUS_ACTIVE) ManagementRegistrar.register("bitronix.tm:type=Transaction,Gtrid=" + resourceManager.getGtrid(), this); fireTransactionStatusChangedEvent(oldStatus, status); } catch (IOException ex) { // if we cannot log, the TM must stop managing TX until the problem is fixed throw new BitronixSystemException("error logging status", ex); } }
/** * Register the specified management object. * * @param name the name of the object. * @param obj the management object. */ public static void register(String name, Object obj) { if (mbeanServer == null) return; runOrEnqueueCommand(new ManagementRegisterCommand(name, obj)); }
/** * Unregister the management object with the specified name. * @param name the name of the object. */ public static void unregister(String name) { MBeanServer mbeanServer = getMBeanServer(); if (mbeanServer == null) return; try { mbeanServer.unregisterMBean(new ObjectName(name)); } catch (Exception ex) { log.warn("cannot unregister object with name " + name, ex); } }
public Recoverer() { String serverId = TransactionManagerServices.getConfiguration().getServerId(); if (serverId == null) serverId = ""; this.jmxName = "bitronix.tm:type=Recoverer,ServerId=" + ManagementRegistrar.makeValidName(serverId); ManagementRegistrar.register(jmxName, this); }
@Test public void testCanRegister() throws Exception { final int iterations = 100000; final List<TestBean> beans = new ArrayList<TestBean>(iterations); for (int i = 0; i < iterations; i++) { if (i > 0) ManagementRegistrar.unregister(objectName); TestBean testBean = new TestBean("#" + i); beans.add(testBean); // holding a hard reference to ensure the instances are not GCed. ManagementRegistrar.register(objectName, testBean); } ManagementRegistrar.normalizeAndRunQueuedCommands(); assertEquals(beans.get(beans.size() - 1).getName(), mBeanServer.getAttribute(new ObjectName(objectName), "Name")); }
public void shutdown() { ManagementRegistrar.unregister(jmxName); }
public void setStatus(int status, Set<String> uniqueNames) throws BitronixSystemException { try { boolean force = (resourceManager.size() > 1) && (status == Status.STATUS_COMMITTING); if (log.isDebugEnabled()) { log.debug("changing transaction status to " + Decoder.decodeStatus(status) + (force ? " (forced)" : "")); } int oldStatus = this.status; this.status = status; Journal journal = TransactionManagerServices.getJournal(); journal.log(status, resourceManager.getGtrid(), uniqueNames); if (force) { journal.force(); } if (status == Status.STATUS_ACTIVE) ManagementRegistrar.register("bitronix.tm:type=Transaction,Gtrid=" + resourceManager.getGtrid(), this); fireTransactionStatusChangedEvent(oldStatus, status); } catch (IOException ex) { // if we cannot log, the TM must stop managing TX until the problem is fixed throw new BitronixSystemException("error logging status", ex); } }
private static void runOrEnqueueCommand(ManagementCommand command) { if (commandQueue == null) command.run(); else { // Try to enqueue the command unless the queue is full. // Recover from a full queue by running already queued commands first to protect the async. implementation // from being vulnerable to DOS attacks. while (!commandQueue.offer(command)) normalizeAndRunQueuedCommands(); } }
/** * Unregister the management object with the specified name. * * @param name the name of the object. */ public static void unregister(String name) { if (mbeanServer == null) return; runOrEnqueueCommand(new ManagementUnregisterCommand(name)); }
/** * Register the specified management object. * @param name the name of the object. * @param obj the management object. */ public static void register(String name, Object obj) { MBeanServer mbeanServer = getMBeanServer(); if (mbeanServer == null) return; try { mbeanServer.registerMBean(obj, new ObjectName(name)); } catch (Exception ex) { log.warn("cannot register object with name " + name, ex); } }