Search in sources :

Example 6 with SocketDestination

use of voldemort.store.socket.SocketDestination in project voldemort by voldemort.

the class ClientRequestExecutorPoolTest method testMachinUpProcessDownThrows.

@Test
public void testMachinUpProcessDownThrows() throws Exception {
    int processDownPort = ServerTestUtils.findFreePort();
    SocketDestination processDownDest = new SocketDestination("localhost", processDownPort, RequestFormatType.VOLDEMORT_V1);
    testConnectionFailure(pool, processDownDest, ConnectException.class);
}
Also used : SocketDestination(voldemort.store.socket.SocketDestination) Test(org.junit.Test)

Example 7 with SocketDestination

use of voldemort.store.socket.SocketDestination in project voldemort by voldemort.

the class SimpleSocketPoolTest method testSocketPoolLimitSomeTimeout.

@Test
public void testSocketPoolLimitSomeTimeout() throws Exception {
    // start a dummy server
    AbstractSocketService server = ServerTestUtils.getSocketService(useNio, new ClientRequestHandlerFactory(null), 7666, 50, 50, 1000);
    server.start();
    final ResourcePoolConfig config = new ResourcePoolConfig().setTimeout(50, TimeUnit.MILLISECONDS).setMaxPoolSize(20);
    ResourceFactory<SocketDestination, SocketAndStreams> factory = ResourcePoolTestUtils.getSocketPoolFactory();
    final AbstractSocketPoolTest<SocketDestination, SocketAndStreams> test = new AbstractSocketPoolTest<SocketDestination, SocketAndStreams>() {

        @Override
        protected void doSomethingWithResource(SocketDestination key, SocketAndStreams resource) throws Exception {
            Thread.sleep(100);
            int random = (int) (Math.random() * 10);
            if (random >= 5)
                resource.getSocket().close();
        }

        @Override
        protected SocketDestination getRequestKey() throws Exception {
            return new SocketDestination("localhost", 7666, RequestFormatType.VOLDEMORT_V1);
        }
    };
    // borrow timeout >> doSomething() no timeout expected
    TestStats testStats = test.startTest(factory, config, 50, 200);
    assertEquals("We should see some timeoutRequests", true, testStats.timeoutRequests > 0);
    server.stop();
}
Also used : SocketAndStreams(voldemort.client.protocol.admin.SocketAndStreams) SocketDestination(voldemort.store.socket.SocketDestination) ClientRequestHandlerFactory(voldemort.server.protocol.ClientRequestHandlerFactory) AbstractSocketService(voldemort.server.AbstractSocketService) TestStats(voldemort.socketpool.AbstractSocketPoolTest.TestStats) ResourcePoolConfig(voldemort.utils.pool.ResourcePoolConfig) Test(org.junit.Test)

Example 8 with SocketDestination

use of voldemort.store.socket.SocketDestination in project voldemort by voldemort.

the class BaseStreamingClient method cleanupSessions.

/**
     * Helper method to Close all open socket connections and checkin back to
     * the pool
     * 
     * @param storeNamesToCleanUp List of stores to be cleanedup from the current
     *        streaming session
     */
@SuppressWarnings({ "rawtypes", "unchecked" })
private void cleanupSessions(List<String> storeNamesToCleanUp) {
    logger.info("Performing cleanup");
    for (String store : storeNamesToCleanUp) {
        for (Node node : nodesToStream) {
            try {
                SocketAndStreams sands = nodeIdStoreToSocketAndStreams.get(new Pair(store, node.getId()));
                close(sands.getSocket());
                SocketDestination destination = nodeIdStoreToSocketRequest.get(new Pair(store, node.getId()));
                streamingSocketPool.checkin(destination, sands);
            } catch (Exception ioE) {
                logger.error(ioE);
            }
        }
    }
    cleanedUp = true;
}
Also used : SocketDestination(voldemort.store.socket.SocketDestination) Node(voldemort.cluster.Node) InsufficientOperationalNodesException(voldemort.store.InsufficientOperationalNodesException) VoldemortException(voldemort.VoldemortException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) Pair(voldemort.utils.Pair)

Example 9 with SocketDestination

use of voldemort.store.socket.SocketDestination in project voldemort by voldemort.

the class ClientSocketStatsTest method setUp.

@Before
public void setUp() throws Exception {
    this.port = ServerTestUtils.findFreePort();
    this.dest1 = new SocketDestination("localhost", port, RequestFormatType.VOLDEMORT_V1);
    this.dest2 = new SocketDestination("localhost", port + 1, RequestFormatType.VOLDEMORT_V1);
    this.masterStats = new ClientSocketStats("");
    pool = null;
}
Also used : SocketDestination(voldemort.store.socket.SocketDestination) Before(org.junit.Before)

Example 10 with SocketDestination

use of voldemort.store.socket.SocketDestination in project voldemort by voldemort.

the class SocketPoolTest method testVariousProtocols.

@Test
public void testVariousProtocols() throws Exception {
    for (RequestFormatType type : RequestFormatType.values()) {
        SocketDestination dest = new SocketDestination("localhost", port, type);
        SocketAndStreams sas = pool.checkout(dest);
        assertEquals(type, sas.getRequestFormatType());
    }
}
Also used : SocketAndStreams(voldemort.client.protocol.admin.SocketAndStreams) SocketDestination(voldemort.store.socket.SocketDestination) RequestFormatType(voldemort.client.protocol.RequestFormatType) Test(org.junit.Test)

Aggregations

SocketDestination (voldemort.store.socket.SocketDestination)14 Test (org.junit.Test)5 Before (org.junit.Before)4 Node (voldemort.cluster.Node)4 IOException (java.io.IOException)3 ExecutionException (java.util.concurrent.ExecutionException)3 VoldemortException (voldemort.VoldemortException)3 InsufficientOperationalNodesException (voldemort.store.InsufficientOperationalNodesException)3 ClientRequestExecutorPool (voldemort.store.socket.clientrequest.ClientRequestExecutorPool)3 Pair (voldemort.utils.Pair)3 SocketAndStreams (voldemort.client.protocol.admin.SocketAndStreams)2 AbstractSocketService (voldemort.server.AbstractSocketService)2 StoreRepository (voldemort.server.StoreRepository)2 ClientRequestHandlerFactory (voldemort.server.protocol.ClientRequestHandlerFactory)2 TestStats (voldemort.socketpool.AbstractSocketPoolTest.TestStats)2 ByteArray (voldemort.utils.ByteArray)2 ResourcePoolConfig (voldemort.utils.pool.ResourcePoolConfig)2 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 ArrayList (java.util.ArrayList)1