Search in sources :

Example 6 with ClientRequestExecutor

use of voldemort.store.socket.clientrequest.ClientRequestExecutor in project voldemort by voldemort.

the class NioSelectorManagerTest method testSelectorHeartBeat.

@Test
public void testSelectorHeartBeat() throws Exception {
    // Open a request so that Sleepy store hangs.
    pool.submitAsync(dest1, getClientRequest(), getCallBack(), 250, "get");
    // wait for MAX heart beat + some more time so that the selector
    // threads should be marked dead
    Thread.sleep(MAX_HEART_BEAT_MS + 50);
    // request, if not it calls proceesLoop which creates one more.
    try {
        pool.checkout(dest1);
    } catch (Exception ex) {
    }
    // here sleeps for infinite time
    for (int i = 0; i < 20; i++) {
        try {
            ClientRequestExecutor executor = pool.checkout(dest1);
            if (numSelectors == 1) {
                fail("Single selector expected an exception");
            } else {
                assertNotNull("multiple selector should have valid executor", executor);
            }
        } catch (UnreachableStoreException ex) {
            if (numSelectors > 1) {
                fail("more than one selector, no exception should be observed" + ex);
            } else {
                assertTrue("inner exception should be instance of IOException", ex.getCause() instanceof IOException);
            }
        }
    }
    sleepyStore.releaseThreads();
}
Also used : ClientRequestExecutor(voldemort.store.socket.clientrequest.ClientRequestExecutor) UnreachableStoreException(voldemort.store.UnreachableStoreException) IOException(java.io.IOException) UnreachableStoreException(voldemort.store.UnreachableStoreException) IOException(java.io.IOException) Test(org.junit.Test)

Example 7 with ClientRequestExecutor

use of voldemort.store.socket.clientrequest.ClientRequestExecutor in project voldemort by voldemort.

the class ClientRequestExecutorPoolTest method testTwoCheckoutsGetTheSameSocket.

@Test
public void testTwoCheckoutsGetTheSameSocket() throws Exception {
    ClientRequestExecutor sas1 = pool.checkout(dest1);
    pool.checkin(dest1, sas1);
    ClientRequestExecutor sas2 = pool.checkout(dest1);
    assertTrue(sas1 == sas2);
}
Also used : ClientRequestExecutor(voldemort.store.socket.clientrequest.ClientRequestExecutor) Test(org.junit.Test)

Example 8 with ClientRequestExecutor

use of voldemort.store.socket.clientrequest.ClientRequestExecutor in project voldemort by voldemort.

the class ClientRequestExecutorPoolTest method testInFlightServerBounce.

@Test
public void testInFlightServerBounce() throws Exception {
    // Create 2 resources
    ClientRequestExecutor sas1 = pool.checkout(dest1);
    ClientRequestExecutor sas2 = pool.checkout(dest1);
    // Stop the Server
    stopServer();
    // It takes few milliseconds for the selector to wake-up and clear
    // connections
    Thread.sleep(5);
    pool.checkin(dest1, sas1);
    pool.checkin(dest1, sas2);
    validateResourceCount(pool, "Dead connections should have been cleared on checkin", 0);
}
Also used : ClientRequestExecutor(voldemort.store.socket.clientrequest.ClientRequestExecutor) Test(org.junit.Test)

Example 9 with ClientRequestExecutor

use of voldemort.store.socket.clientrequest.ClientRequestExecutor 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 10 with ClientRequestExecutor

use of voldemort.store.socket.clientrequest.ClientRequestExecutor 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)

Aggregations

ClientRequestExecutor (voldemort.store.socket.clientrequest.ClientRequestExecutor)12 Test (org.junit.Test)10 UnreachableStoreException (voldemort.store.UnreachableStoreException)3 ClientRequestExecutorPool (voldemort.store.socket.clientrequest.ClientRequestExecutorPool)3 ArrayList (java.util.ArrayList)2 IOException (java.io.IOException)1 AbstractSocketService (voldemort.server.AbstractSocketService)1 ClientRequestHandlerFactory (voldemort.server.protocol.ClientRequestHandlerFactory)1 TestStats (voldemort.socketpool.AbstractSocketPoolTest.TestStats)1 SocketDestination (voldemort.store.socket.SocketDestination)1 ResourcePoolConfig (voldemort.utils.pool.ResourcePoolConfig)1