Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Unregister from JMX at shutdown

  • Loading branch information...
commit 853a552245dd0f5bad052fb29eb968dfccbffe8f 1 parent 79594a8
@rhavyn rhavyn authored
View
4 cluster/src/main/scala/com/linkedin/norbert/cluster/ClusterClient.scala
@@ -44,7 +44,7 @@ trait ClusterClient extends Logging {
private val shutdownSwitch = new AtomicBoolean
private val startedSwitch = new AtomicBoolean
- JMX.register(new MBean(classOf[ClusterClientMBean], "serviceName=%s".format(serviceName)) with ClusterClientMBean {
+ private val jmxHandle = JMX.register(new MBean(classOf[ClusterClientMBean], "serviceName=%s".format(serviceName)) with ClusterClientMBean {
def getNodes = nodes.map(_.toString).toArray
def isConnected = ClusterClient.this.isConnected
})
@@ -226,6 +226,8 @@ trait ClusterClient extends Logging {
*/
def shutdown: Unit = {
if (shutdownSwitch.compareAndSet(false, true)) {
+ jmxHandle.foreach { JMX.unregister(_) }
+
log.ifDebug("Shutting down ZooKeeperManager...")
clusterManager ! ClusterManagerMessages.Shutdown
View
4 network/src/main/scala/com/linkedin/norbert/network/netty/ChannelPool.scala
@@ -44,7 +44,7 @@ class ChannelPool(address: InetSocketAddress, maxConnections: Int, writeTimeoutM
private val closed = new AtomicBoolean
private val requestsSent = new AtomicInteger(0)
- val jmxObjectInstance = JMX.register(new MBean(classOf[ChannelPoolMBean], "address=%s,port=%d".format(address.getHostName, address.getPort)) with ChannelPoolMBean {
+ private val jmxHandle = JMX.register(new MBean(classOf[ChannelPoolMBean], "address=%s,port=%d".format(address.getHostName, address.getPort)) with ChannelPoolMBean {
def getWriteQueueSize = waitingWrites.size
def getOpenChannels = poolSize.get
@@ -70,7 +70,7 @@ class ChannelPool(address: InetSocketAddress, maxConnections: Int, writeTimeoutM
def close {
if (closed.compareAndSet(false, true)) {
- jmxObjectInstance.foreach { oi => JMX.unregister(oi) }
+ jmxHandle.foreach { JMX.unregister(_) }
channelGroup.close.awaitUninterruptibly
}
}
View
3  network/src/main/scala/com/linkedin/norbert/network/netty/ClientChannelHandler.scala
@@ -51,7 +51,7 @@ class ClientChannelHandler(serviceName: String, messageRegistry: MessageRegistry
private val statsActor = new NetworkStatisticsActor(100)
statsActor.start
- JMX.register(new MBean(classOf[NetworkClientStatisticsMBean], "service=%s".format(serviceName)) with NetworkClientStatisticsMBean {
+ private val jmxHandle = JMX.register(new MBean(classOf[NetworkClientStatisticsMBean], "service=%s".format(serviceName)) with NetworkClientStatisticsMBean {
import statsActor.Stats._
def getRequestsPerSecond = statsActor !? GetRequestsPerSecond match {
@@ -113,6 +113,7 @@ class ClientChannelHandler(serviceName: String, messageRegistry: MessageRegistry
def shutdown {
statsActor ! 'quit
+ jmxHandle.foreach { JMX.unregister(_) }
}
}
View
5 network/src/main/scala/com/linkedin/norbert/network/netty/NettyNetworkClient.scala
@@ -39,8 +39,9 @@ abstract class BaseNettyNetworkClient(clientConfig: NetworkClientConfig) extends
private val executor = Executors.newCachedThreadPool(new NamedPoolThreadFactory("norbert-client-pool-%s".format(clusterClient.serviceName)))
private val bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(executor, executor))
private val connectTimeoutMillis = clientConfig.connectTimeoutMillis
- val handler = new ClientChannelHandler(clusterClient.serviceName, messageRegistry, clientConfig.maxConnectionsPerNode,
- clientConfig.staleRequestCleanupFrequenceMins)
+ private val handler = new ClientChannelHandler(clusterClient.serviceName, messageRegistry, clientConfig.maxConnectionsPerNode,
+ clientConfig.staleRequestCleanupFrequenceMins)
+
// TODO why isn't clientConfig visible here?
bootstrap.setOption("connectTimeoutMillis", connectTimeoutMillis)
bootstrap.setOption("tcpNoDelay", true)
View
1  network/src/main/scala/com/linkedin/norbert/network/netty/NettyNetworkServer.scala
@@ -52,7 +52,6 @@ class NettyNetworkServer(serverConfig: NetworkServerConfig) extends NetworkServe
val executor = Executors.newCachedThreadPool(new NamedPoolThreadFactory("norbert-server-pool-%s".format(clusterClient.serviceName)))
val bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(executor, executor))
val channelGroup = new DefaultChannelGroup("norbert-server-group-%s".format(clusterClient.serviceName))
-
val requestContextEncoder = new RequestContextEncoder(clusterClient.serviceName)
bootstrap.setOption("reuseAddress", true)
View
3  network/src/main/scala/com/linkedin/norbert/network/netty/ServerChannelHandler.scala
@@ -56,7 +56,7 @@ class RequestContextEncoder(serviceName: String) extends OneToOneEncoder with Lo
private val requestProcessingTime = new AverageTimeTracker(100)
- JMX.register(new MBean(classOf[NetworkServerStatisticsMBean], "service=%s".format(serviceName)) with NetworkServerStatisticsMBean {
+ private val jmxHandle = JMX.register(new MBean(classOf[NetworkServerStatisticsMBean], "service=%s".format(serviceName)) with NetworkServerStatisticsMBean {
import statsActor.Stats._
def getRequestsPerSecond = statsActor !? GetRequestsPerSecond match {
@@ -78,6 +78,7 @@ class RequestContextEncoder(serviceName: String) extends OneToOneEncoder with Lo
def shutdown {
statsActor ! 'quit
+ jmxHandle.foreach { JMX.unregister(_) }
}
}
View
3  network/src/main/scala/com/linkedin/norbert/network/server/MessageExecutorComponent.scala
@@ -79,7 +79,7 @@ class ThreadPoolMessageExecutor(messageHandlerRegistry: MessageHandlerRegistry,
}
}
- JMX.register(new MBean(classOf[RequestProcessorMBean]) with RequestProcessorMBean {
+ private val jmxHandle = JMX.register(new MBean(classOf[RequestProcessorMBean]) with RequestProcessorMBean {
import Stats._
def getQueueSize = threadPool.getQueue.size
@@ -102,6 +102,7 @@ class ThreadPoolMessageExecutor(messageHandlerRegistry: MessageHandlerRegistry,
}
def shutdown {
+ jmxHandle.foreach { JMX.unregister(_) }
threadPool.shutdown
statsActor ! 'quit
log.ifDebug("MessageExecutor shut down")
Please sign in to comment.
Something went wrong with that request. Please try again.