Implements https://issues.apache.org/jira/browse/AMQ-5458 - Lets make sure we register the Test mbean when in slave mode.

This commit is contained in:
Hiram Chirino 2014-11-26 10:57:13 -05:00
parent f4149c0a46
commit 4e3499e41b
2 changed files with 13 additions and 3 deletions

View File

@ -293,7 +293,7 @@ class LevelDBStore extends LockableServiceSupport with BrokerServiceAware with P
try { try {
AnnotatedMBean.registerMBean(brokerService.getManagementContext, new LevelDBStoreView(this), objectName) AnnotatedMBean.registerMBean(brokerService.getManagementContext, new LevelDBStoreView(this), objectName)
if( java.lang.Boolean.getBoolean("org.apache.activemq.leveldb.test") ) { if( java.lang.Boolean.getBoolean("org.apache.activemq.leveldb.test") ) {
val name = new ObjectName(objectName.toString + ",test=test") val name = new ObjectName(objectName.toString + ",view=Test")
AnnotatedMBean.registerMBean(brokerService.getManagementContext, new LevelDBStoreTest(this), name) AnnotatedMBean.registerMBean(brokerService.getManagementContext, new LevelDBStoreTest(this), name)
} }
} catch { } catch {
@ -353,7 +353,7 @@ class LevelDBStore extends LockableServiceSupport with BrokerServiceAware with P
if(brokerService!=null && brokerService.isUseJmx){ if(brokerService!=null && brokerService.isUseJmx){
brokerService.getManagementContext().unregisterMBean(objectName); brokerService.getManagementContext().unregisterMBean(objectName);
if( java.lang.Boolean.getBoolean("org.apache.activemq.leveldb.test") ) if( java.lang.Boolean.getBoolean("org.apache.activemq.leveldb.test") )
brokerService.getManagementContext().unregisterMBean(new ObjectName(objectName.toString+",test=test")); brokerService.getManagementContext().unregisterMBean(new ObjectName(objectName.toString+",view=Test"));
} }
info("Stopped "+this) info("Stopped "+this)
} }

View File

@ -16,7 +16,7 @@
*/ */
package org.apache.activemq.leveldb.replicated package org.apache.activemq.leveldb.replicated
import org.apache.activemq.leveldb.{LevelDBClient, LevelDBStore} import org.apache.activemq.leveldb.{LevelDBStoreTest, LevelDBClient, LevelDBStore}
import org.apache.activemq.util.ServiceStopper import org.apache.activemq.util.ServiceStopper
import java.util import java.util
import org.fusesource.hawtdispatch._ import org.fusesource.hawtdispatch._
@ -30,6 +30,8 @@ import FileSupport._
import java.io.{IOException, RandomAccessFile, File} import java.io.{IOException, RandomAccessFile, File}
import scala.beans.BeanProperty import scala.beans.BeanProperty
import java.util.concurrent.{CountDownLatch, TimeUnit} import java.util.concurrent.{CountDownLatch, TimeUnit}
import javax.management.ObjectName
import org.apache.activemq.broker.jmx.AnnotatedMBean
object SlaveLevelDBStore extends Log object SlaveLevelDBStore extends Log
@ -79,10 +81,18 @@ class SlaveLevelDBStore extends LevelDBStore with ReplicatedLevelDBStoreTrait {
db.client.dirtyIndexFile.recursiveDelete db.client.dirtyIndexFile.recursiveDelete
db.client.plistIndexFile.recursiveDelete db.client.plistIndexFile.recursiveDelete
start_slave_connections start_slave_connections
if( java.lang.Boolean.getBoolean("org.apache.activemq.leveldb.test") ) {
val name = new ObjectName(objectName.toString + ",view=Test")
AnnotatedMBean.registerMBean(brokerService.getManagementContext, new LevelDBStoreTest(this), name)
}
} }
var stopped = false var stopped = false
override def doStop(stopper: ServiceStopper) = { override def doStop(stopper: ServiceStopper) = {
if( java.lang.Boolean.getBoolean("org.apache.activemq.leveldb.test") )
brokerService.getManagementContext().unregisterMBean(new ObjectName(objectName.toString+",view=Test"));
val latch = new CountDownLatch(1) val latch = new CountDownLatch(1)
stop_connections(^{ stop_connections(^{
latch.countDown latch.countDown