Skip to content

Commit

Permalink
moved registering JMX inside ClientRequestExecutorPool
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongjiewu committed Jun 19, 2012
1 parent 9c520a9 commit 320203f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
14 changes: 1 addition & 13 deletions src/java/voldemort/client/SocketStoreClientFactory.java
Expand Up @@ -37,10 +37,7 @@
import voldemort.store.socket.SocketDestination;
import voldemort.store.socket.SocketStoreFactory;
import voldemort.store.socket.clientrequest.ClientRequestExecutorPool;
import voldemort.store.stats.ClientSocketStats;
import voldemort.store.stats.ClientSocketStatsJmx;
import voldemort.utils.ByteArray;
import voldemort.utils.JmxUtils;
import voldemort.versioning.InconsistencyResolver;
import voldemort.versioning.Versioned;

Expand All @@ -59,27 +56,18 @@ public class SocketStoreClientFactory extends AbstractStoreClientFactory {
private final SocketStoreFactory storeFactory;
private FailureDetectorListener failureDetectorListener;
private final RequestRoutingType requestRoutingType;
private final ClientSocketStats stats;

public SocketStoreClientFactory(ClientConfig config) {
super(config);
this.requestRoutingType = RequestRoutingType.getRequestRoutingType(RoutingTier.SERVER.equals(config.getRoutingTier()),
false);
if(config.isJmxEnabled()) {
stats = new ClientSocketStats();
} else {
stats = null;
}
this.storeFactory = new ClientRequestExecutorPool(config.getSelectors(),
config.getMaxConnectionsPerNode(),
config.getConnectionTimeout(TimeUnit.MILLISECONDS),
config.getSocketTimeout(TimeUnit.MILLISECONDS),
config.getSocketBufferSize(),
config.getSocketKeepAlive(),
stats);
JmxUtils.registerMbean(new ClientSocketStatsJmx(stats),
JmxUtils.createObjectName(JmxUtils.getPackageName(storeFactory.getClass()),
"aggregated"));
config.isJmxEnabled());
}

@Override
Expand Down
Expand Up @@ -27,6 +27,7 @@
import voldemort.store.socket.SocketStore;
import voldemort.store.socket.SocketStoreFactory;
import voldemort.store.stats.ClientSocketStats;
import voldemort.store.stats.ClientSocketStatsJmx;
import voldemort.utils.JmxUtils;
import voldemort.utils.Time;
import voldemort.utils.Utils;
Expand Down Expand Up @@ -56,14 +57,20 @@ public ClientRequestExecutorPool(int selectors,
int soTimeoutMs,
int socketBufferSize,
boolean socketKeepAlive,
ClientSocketStats stats) {
boolean enableJmx) {
ResourcePoolConfig config = new ResourcePoolConfig().setIsFair(true)
.setMaxPoolSize(maxConnectionsPerNode)
.setMaxInvalidAttempts(maxConnectionsPerNode)
.setTimeout(connectionTimeoutMs,
TimeUnit.MILLISECONDS);

this.stats = stats;
if(enableJmx) {
stats = new ClientSocketStats();
JmxUtils.registerMbean(new ClientSocketStatsJmx(stats),
JmxUtils.createObjectName(JmxUtils.getPackageName(this.getClass()),
"aggregated"));
} else {
stats = null;
}
this.factory = new ClientRequestExecutorFactory(selectors,
connectionTimeoutMs,
soTimeoutMs,
Expand All @@ -76,20 +83,20 @@ public ClientRequestExecutorPool(int selectors,
}
}

// JMX bean is disabled by default
public ClientRequestExecutorPool(int selectors,
int maxConnectionsPerNode,
int connectionTimeoutMs,
int soTimeoutMs,
int socketBufferSize,
boolean socketKeepAlive) {
// JMX bean is disabled by default
this(selectors,
maxConnectionsPerNode,
connectionTimeoutMs,
soTimeoutMs,
socketBufferSize,
socketKeepAlive,
null);
false);
}

public ClientRequestExecutorPool(int maxConnectionsPerNode,
Expand Down
Expand Up @@ -69,15 +69,14 @@ public static Collection<Object[]> configs() {
@Override
@Before
public void setUp() {
this.stats = new ClientSocketStats();
this.port = ServerTestUtils.findFreePort();
this.pool = new ClientRequestExecutorPool(2,
maxConnectionsPerNode,
1000,
1000,
32 * 1024,
false,
stats);
true);
this.dest1 = new SocketDestination("localhost", port, RequestFormatType.VOLDEMORT_V1);
RequestHandlerFactory handlerFactory = ServerTestUtils.getSocketRequestHandlerFactory(new StoreRepository());
this.server = ServerTestUtils.getSocketService(useNio,
Expand Down

0 comments on commit 320203f

Please sign in to comment.