Search in sources :

Example 26 with ClientRequestExecutorPool

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);
}
Also used : ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) Test(org.junit.Test)

Example 27 with ClientRequestExecutorPool

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));
}
Also used : ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) ClientRequestExecutor(voldemort.store.socket.clientrequest.ClientRequestExecutor) Test(org.junit.Test)

Example 28 with ClientRequestExecutorPool

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);
}
Also used : ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) ArrayList(java.util.ArrayList) ClientRequestExecutor(voldemort.store.socket.clientrequest.ClientRequestExecutor) Test(org.junit.Test)

Example 29 with ClientRequestExecutorPool

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();
}
Also used : InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) SocketDestination(voldemort.store.socket.SocketDestination) ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) ByteArray(voldemort.utils.ByteArray) StoreRepository(voldemort.server.StoreRepository) Before(org.junit.Before)

Example 30 with ClientRequestExecutorPool

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());
    }
}
Also used : ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) Node(voldemort.cluster.Node) Cluster(voldemort.cluster.Cluster) SocketStoreFactory(voldemort.store.socket.SocketStoreFactory) ClientConfig(voldemort.client.ClientConfig) Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) Before(org.junit.Before)

Aggregations

ClientRequestExecutorPool (voldemort.store.socket.clientrequest.ClientRequestExecutorPool)30 Properties (java.util.Properties)18 VoldemortServer (voldemort.server.VoldemortServer)18 SocketStoreFactory (voldemort.store.socket.SocketStoreFactory)18 Before (org.junit.Before)17 Node (voldemort.cluster.Node)15 VoldemortConfig (voldemort.server.VoldemortConfig)11 StoreDefinition (voldemort.store.StoreDefinition)9 ClientConfig (voldemort.client.ClientConfig)8 Test (org.junit.Test)7 ByteArray (voldemort.utils.ByteArray)7 SocketStoreClientFactory (voldemort.client.SocketStoreClientFactory)6 AdminClient (voldemort.client.protocol.admin.AdminClient)6 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)6 File (java.io.File)5 ArrayList (java.util.ArrayList)5 Cluster (voldemort.cluster.Cluster)4 StoreRepository (voldemort.server.StoreRepository)4 IOException (java.io.IOException)3 RoutingStrategyFactory (voldemort.routing.RoutingStrategyFactory)3