Skip to content

Commit

Permalink
avoid jmx id from being incremented when factory is created for syste…
Browse files Browse the repository at this point in the history
…m stores
  • Loading branch information
Lei Gao committed Jul 10, 2012
1 parent 35a887e commit fe46419
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/java/voldemort/client/AbstractStoreClientFactory.java
Expand Up @@ -111,7 +111,7 @@ public AbstractStoreClientFactory(ClientConfig config) {
this.bootstrapUrls = validateUrls(config.getBootstrapUrls());
this.isJmxEnabled = config.isJmxEnabled();
this.requestFormatType = config.getRequestFormatType();
this.jmxId = jmxIdCounter.getAndIncrement();
this.jmxId = getNextJmxId();
this.maxBootstrapRetries = config.getMaxBootstrapRetries();
this.stats = new StoreStats();
this.clientZoneId = config.getClientZoneId();
Expand All @@ -137,6 +137,14 @@ public AbstractStoreClientFactory(ClientConfig config) {
}
}

public int getNextJmxId() {
return jmxIdCounter.getAndIncrement();
}

public int getCurrentJmxId() {
return jmxIdCounter.get();
}

public <K, V> StoreClient<K, V> getStoreClient(String storeName) {
return getStoreClient(storeName, null);
}
Expand Down
2 changes: 1 addition & 1 deletion src/java/voldemort/client/SystemStore.java
Expand Up @@ -39,7 +39,7 @@ public SystemStore(String storeName, String[] bootstrapUrls, int clientZoneID, S
.setEnableJmx(false)
.setEnablePipelineRoutedStore(true)
.setClientZoneId(clientZoneID);
this.systemStoreFactory = new SocketStoreClientFactory(config);
this.systemStoreFactory = new SystemStoreClientFactory(config);
this.storeName = storeName;
this.sysStore = this.systemStoreFactory.getSystemStore(this.storeName, clusterXml);
}
Expand Down
14 changes: 14 additions & 0 deletions src/java/voldemort/client/SystemStoreClientFactory.java
@@ -0,0 +1,14 @@
package voldemort.client;

public class SystemStoreClientFactory extends SocketStoreClientFactory {

public SystemStoreClientFactory(ClientConfig config) {
super(config);
}

@Override
public int getNextJmxId() {
// for system store, we don't increment jmx id
return getCurrentJmxId();
}
}
2 changes: 1 addition & 1 deletion test/unit/voldemort/client/ClientJmxTest.java
Expand Up @@ -36,7 +36,7 @@ public ClientJmxTest() {
private static String getAndIncrementJmxId() {
int current = factoryJmxId;
factoryJmxId++;
return (0 == current ? "" : "." + current);
return (0 == current ? "" : "" + current);
}

@Override
Expand Down

0 comments on commit fe46419

Please sign in to comment.