use of voldemort.store.socket.clientrequest.ClientRequestExecutorPool in project voldemort by voldemort.
the class ClientRequestExecutorPoolTest method testConnectionTimeoutThrows.
@Test
public void testConnectionTimeoutThrows() throws Exception {
ClientRequestExecutorPool timeoutPool = new ClientRequestExecutorPool(2, maxConnectionsPerNode, //Connection timeout
50, // Socket timeout, 0 milliseconds :)
0, IDLE_CONNECTION_TIMEOUT_MS, 32 * 1024, false, true, new String());
testConnectionFailure(timeoutPool, dest1, ConnectException.class);
}
use of voldemort.store.socket.clientrequest.ClientRequestExecutorPool in project voldemort by voldemort.
the class ClientRequestExecutorPoolTest method testIsValidConnectionIdleTimeout.
@Test
public void testIsValidConnectionIdleTimeout() throws Exception {
long idleConnectionTimeoutMs = 200;
ClientRequestExecutorPool execPool = new ClientRequestExecutorPool(2, maxConnectionsPerNode, CONNECTION_TIMEOUT_MS, SOCKET_TIMEOUT_MS, idleConnectionTimeoutMs, 32 * 1024, false, true, new String());
ClientRequestExecutor clientRequest = execPool.checkout(dest1);
assertTrue("Connection checked out is valid", execPool.getFactory().validate(dest1, clientRequest));
Thread.sleep(idleConnectionTimeoutMs);
assertFalse("Idle connection will expire", execPool.getFactory().validate(dest1, clientRequest));
}
use of voldemort.store.socket.clientrequest.ClientRequestExecutorPool in project voldemort by voldemort.
the class ClientRequestExecutorPoolTest method testIdleConnectionTimeout.
@Test
public void testIdleConnectionTimeout() throws Exception {
long idleConnectionTimeoutMs = 1000;
ClientRequestExecutorPool execPool = new ClientRequestExecutorPool(2, maxConnectionsPerNode, CONNECTION_TIMEOUT_MS, SOCKET_TIMEOUT_MS, idleConnectionTimeoutMs, 32 * 1024, false, true, new String());
List<ClientRequestExecutor> executors = new ArrayList<ClientRequestExecutor>();
for (int i = 0; i < maxConnectionsPerNode; i++) {
executors.add(execPool.checkout(dest1));
}
for (ClientRequestExecutor executor : executors) {
execPool.checkin(dest1, executor);
}
validateResourceCount(execPool, " checkout should have created " + maxConnectionsPerNode, maxConnectionsPerNode);
// Selector only wakes up every few seconds
Thread.sleep(idleConnectionTimeoutMs + 1000);
// All existing connections are marked as invalid by selector
// This call will create new connection.
ClientRequestExecutor exec1 = execPool.checkout(dest1);
for (ClientRequestExecutor executor : executors) {
assertNotSame("Connections should have been destroyed and new one expected", exec1, executor);
}
execPool.checkin(dest1, exec1);
validateResourceCount(execPool, " all idle connections should have been destroyed ", 1);
}
use of voldemort.store.socket.clientrequest.ClientRequestExecutorPool in project voldemort by voldemort.
the class NioSelectorManagerTest method setUp.
@Before
public void setUp() throws IOException {
this.port = ServerTestUtils.findFreePort();
StoreRepository repository = new StoreRepository();
sleepyStore = new SleepyStore<ByteArray, byte[], byte[]>(Long.MAX_VALUE, new InMemoryStorageEngine<ByteArray, byte[], byte[]>(STORE_NAME));
repository.addLocalStore(sleepyStore);
repository.addRoutedStore(sleepyStore);
this.pool = new ClientRequestExecutorPool(50, 300, 250, 32 * 1024);
this.dest1 = new SocketDestination("localhost", port, RequestFormatType.VOLDEMORT_V1);
final Store<ByteArray, byte[], byte[]> socketStore = pool.create(STORE_NAME, "localhost", port, RequestFormatType.VOLDEMORT_V1, RequestRoutingType.NORMAL);
factory = ServerTestUtils.getSocketRequestHandlerFactory(repository);
socketService = ServerTestUtils.getSocketService(true, factory, port, numSelectors, 10, 1000, MAX_HEART_BEAT_MS);
socketService.start();
}
use of voldemort.store.socket.clientrequest.ClientRequestExecutorPool in project voldemort by voldemort.
the class NioStatsJmxTest method setUp.
@Before
public void setUp() throws Exception {
String storesXmlfile = "test/common/voldemort/config/single-store.xml";
ClientConfig clientConfig = new ClientConfig().setMaxConnectionsPerNode(1).setMaxThreads(1);
SocketStoreFactory socketStoreFactory = new ClientRequestExecutorPool(clientConfig.getSelectors(), clientConfig.getMaxConnectionsPerNode(), clientConfig.getConnectionTimeout(TimeUnit.MILLISECONDS), clientConfig.getSocketTimeout(TimeUnit.MILLISECONDS), clientConfig.getSocketBufferSize(), clientConfig.getSocketKeepAlive());
Properties props = new Properties();
props.put("jmx.enable", "true");
int numServers = 1;
VoldemortServer[] servers = new VoldemortServer[numServers];
Cluster cluster = ServerTestUtils.startVoldemortCluster(numServers, servers, null, socketStoreFactory, true, null, storesXmlfile, props);
server = servers[0];
for (Node node : cluster.getNodes()) {
socketStore = ServerTestUtils.getSocketStore(socketStoreFactory, "test", node.getSocketPort(), clientConfig.getRequestFormatType());
}
}
Aggregations