Skip to content

Commit

Permalink
Fix RO JMX register/Unregister
Browse files Browse the repository at this point in the history
1) Stores JMX are registered by JmxService class.
2) Previously ReadOnlyStorageConfiguration registered the same metrics
by prepending the NodeId. As Part of the commit

2aec46a#diff-005b79e324515c9e1045a61d0aee6d07

I fixed it and removed the NodeId. But I did not realize that this
caused the name collission and overwriting.

[18:50:45,445 voldemort.server.jmx.JmxService] WARN Overwriting mbean
voldemort.store.readonly:type=test2 [main]
[18:50:45,447 voldemort.server.jmx.JmxService] WARN Overwriting mbean
voldemort.store.readonly:type=test1 [main]

Now ReadOnlyStorageConfiguration does not register any JMX Metric at
all. Used the JConsole to verify that it is the same object registered
under two different names. Now the duplicate one is gone and the
warnings on the shutdown of Read Only server will be gone as well.
  • Loading branch information
arunthirupathi committed Dec 23, 2015
1 parent bc38518 commit cd3b9e0
Showing 1 changed file with 1 addition and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
package voldemort.store.readonly;

import java.io.File;
import java.lang.management.ManagementFactory;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import javax.management.MBeanServer;
import javax.management.ObjectName;

import voldemort.VoldemortException;
import voldemort.routing.RoutingStrategy;
Expand All @@ -32,7 +25,6 @@
import voldemort.store.StorageEngine;
import voldemort.store.StoreDefinition;
import voldemort.utils.ByteArray;
import voldemort.utils.JmxUtils;
import voldemort.utils.ReflectUtils;

public class ReadOnlyStorageConfiguration implements StorageConfiguration {
Expand All @@ -41,7 +33,6 @@ public class ReadOnlyStorageConfiguration implements StorageConfiguration {

private final int numBackups;
private final File storageDir;
private final Set<ObjectName> registeredBeans;
private final SearchStrategy searcher;
private final int nodeId;
private RoutingStrategy routingStrategy = null;
Expand All @@ -52,7 +43,6 @@ public class ReadOnlyStorageConfiguration implements StorageConfiguration {
public ReadOnlyStorageConfiguration(VoldemortConfig config) {
this.storageDir = new File(config.getReadOnlyDataStorageDirectory());
this.numBackups = config.getNumReadOnlyVersions();
this.registeredBeans = Collections.synchronizedSet(new HashSet<ObjectName>());
this.searcher = (SearchStrategy) ReflectUtils.callConstructor(ReflectUtils.loadClass(config.getReadOnlySearchStrategy()
.trim()));
this.nodeId = config.getNodeId();
Expand All @@ -62,9 +52,7 @@ public ReadOnlyStorageConfiguration(VoldemortConfig config) {
}

public void close() {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
for(ObjectName name: registeredBeans)
JmxUtils.unregisterMbean(server, name);

}

public void setRoutingStrategy(RoutingStrategy routingStrategy) {
Expand All @@ -83,13 +71,6 @@ public StorageEngine<ByteArray, byte[], byte[]> getStore(StoreDefinition storeDe
numBackups,
deleteBackupMs,
maxValueBufferAllocationSize);
ObjectName objName = JmxUtils.createObjectName(JmxUtils.getPackageName(store.getClass()),
storeDef.getName() );
JmxUtils.registerMbean(ManagementFactory.getPlatformMBeanServer(),
JmxUtils.createModelMBean(store),
objName);
registeredBeans.add(objName);

return store;
}

Expand All @@ -107,12 +88,5 @@ public void update(StoreDefinition storeDef) {
*/
@Override
public void removeStorageEngine(StorageEngine<ByteArray, byte[], byte[]> engine) {
ReadOnlyStorageEngine store = (ReadOnlyStorageEngine) engine;

if(this.voldConfig.isJmxEnabled()) {
ObjectName objName = JmxUtils.createObjectName(JmxUtils.getPackageName(store.getClass()),
store.getName() + nodeId);
JmxUtils.unregisterMbean(ManagementFactory.getPlatformMBeanServer(), objName);
}
}
}

0 comments on commit cd3b9e0

Please sign in to comment.