Search in sources :

Example 6 with ClientRequestExecutorPool

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

the class VersionedPutPruneJobTest method setup.

@Before
public void setup() throws Exception {
    socketStoreMap = new HashMap<Integer, Store<ByteArray, byte[], byte[]>>();
    socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 32 * 1024);
    final int numServers = 4;
    servers = new VoldemortServer[numServers];
    int[][] currentPartitionMap = { { 0, 4 }, { 2, 6 }, { 1, 5 }, { 3, 7 } };
    cluster = ServerTestUtils.startVoldemortCluster(numServers, servers, currentPartitionMap, socketStoreFactory, true, null, "test/common/voldemort/config/single-store-322.xml", new Properties());
    StringReader reader = new StringReader(VoldemortTestConstants.getSingleStore322Xml());
    StoreDefinition storeDef = new StoreDefinitionsMapper().readStoreList(reader).get(0);
    currentRoutingPlan = new BaseStoreRoutingPlan(cluster, storeDef);
    String bootStrapUrl = "";
    for (VoldemortServer server : servers) {
        Node node = server.getIdentityNode();
        socketStoreMap.put(node.getId(), ServerTestUtils.getSocketStore(socketStoreFactory, "test", node.getHost(), node.getSocketPort(), RequestFormatType.PROTOCOL_BUFFERS, false, true));
        bootStrapUrl = "tcp://" + node.getHost() + ":" + node.getSocketPort();
    }
    testEntries = ServerTestUtils.createRandomKeyValueString(100);
    int[][] oldPartitionMap = { { 3, 6 }, { 1, 4 }, { 7, 2 }, { 5, 0 } };
    oldRoutingPlan = new BaseStoreRoutingPlan(ServerTestUtils.getLocalCluster(numServers, oldPartitionMap), storeDef);
    SocketStoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootStrapUrl));
    storeClient = factory.getStoreClient("test");
}
Also used : Node(voldemort.cluster.Node) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) Store(voldemort.store.Store) Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) StoreDefinition(voldemort.store.StoreDefinition) StringReader(java.io.StringReader) BaseStoreRoutingPlan(voldemort.routing.BaseStoreRoutingPlan) ClientConfig(voldemort.client.ClientConfig) Before(org.junit.Before)

Example 7 with ClientRequestExecutorPool

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

the class ClientRequestExecutorPoolTest method testRememberedExceptionsBeyondTime.

@Test
public void testRememberedExceptionsBeyondTime() throws Exception {
    final int CURRENT_CONNECTION_TIMEOUT = 50;
    ClientRequestExecutorPool timeoutPool = new ClientRequestExecutorPool(2, maxConnectionsPerNode, CURRENT_CONNECTION_TIMEOUT, CURRENT_CONNECTION_TIMEOUT, IDLE_CONNECTION_TIMEOUT_MS, 32 * 1024, false, true, new String());
    ConnectException connectEx = new ConnectException("Connect exception");
    UnreachableStoreException unreachableEx = new UnreachableStoreException("test Exception", connectEx);
    final int COUNT = 10;
    for (int i = 0; i < COUNT; i++) {
        timeoutPool.internalGetQueuedPool().reportException(dest1, unreachableEx);
    }
    Thread.sleep(CURRENT_CONNECTION_TIMEOUT);
    // Get all exceptions but 1.
    for (int i = 0; i < COUNT - 1; i++) {
        try {
            timeoutPool.internalGetQueuedPool().checkout(dest1);
            fail("should have thrown an exception");
        } catch (Exception ex) {
        }
    }
    Thread.sleep(CURRENT_CONNECTION_TIMEOUT + 1);
    // should not fail
    timeoutPool.checkout(dest1);
}
Also used : ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) UnreachableStoreException(voldemort.store.UnreachableStoreException) ConnectException(java.net.ConnectException) UnreachableStoreException(voldemort.store.UnreachableStoreException) IOException(java.io.IOException) UnresolvedAddressException(java.nio.channels.UnresolvedAddressException) ConnectException(java.net.ConnectException) Test(org.junit.Test)

Example 8 with ClientRequestExecutorPool

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

the class ClientRequestExecutorPoolTest method testCloseWithOutstandingQueue.

@Test
public void testCloseWithOutstandingQueue() {
    final int MAX_CONNECTIONS = 2;
    ClientRequestExecutorPool execPool = new ClientRequestExecutorPool(2, MAX_CONNECTIONS, CONNECTION_TIMEOUT_MS, SOCKET_TIMEOUT_MS, IDLE_CONNECTION_TIMEOUT_MS, 32 * 1024, false, true, new String());
    // will always wait in the queue.
    for (int i = 0; i < MAX_CONNECTIONS; i++) {
        execPool.checkout(dest1);
    }
    for (int j = 0; j < 2; j++) {
        GetClientRequest clientRequest = new GetClientRequest("sampleStore", new RequestFormatFactory().getRequestFormat(dest1.getRequestFormatType()), RequestRoutingType.ROUTED, new ByteArray(new byte[] { 1, 2, 3 }), null);
        final AtomicInteger cancelledEvents = new AtomicInteger(0);
        NonblockingStoreCallback callback = new NonblockingStoreCallback() {

            @Override
            public void requestComplete(Object result, long requestTime) {
                if (result instanceof UnreachableStoreException)
                    cancelledEvents.incrementAndGet();
                else
                    fail("The request must have failed with UnreachableException" + result);
            }
        };
        int queuedRequestCount = 20;
        for (int i = 0; i < queuedRequestCount; i++) {
            execPool.submitAsync(dest1, clientRequest, callback, 5000, "get");
        }
        int outstandingQueue = execPool.internalGetQueuedPool().getRegisteredResourceRequestCount(dest1);
        assertEquals("Queued request count should match", queuedRequestCount, outstandingQueue);
        // Now reset the queue, the outstanding requests should fail with
        // UnreachableStoreException
        execPool.close(dest1);
        outstandingQueue = execPool.internalGetQueuedPool().getRegisteredResourceRequestCount(dest1);
        assertEquals("Queued request should have been cleared", 0, outstandingQueue);
        // CancelledEvents should be
        assertEquals("All Queuedrequest must have been cancelled.", queuedRequestCount, cancelledEvents.get());
    }
}
Also used : RequestFormatFactory(voldemort.client.protocol.RequestFormatFactory) GetClientRequest(voldemort.store.socket.clientrequest.GetClientRequest) NonblockingStoreCallback(voldemort.store.nonblockingstore.NonblockingStoreCallback) ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ByteArray(voldemort.utils.ByteArray) UnreachableStoreException(voldemort.store.UnreachableStoreException) Test(org.junit.Test)

Example 9 with ClientRequestExecutorPool

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

the class ZoneCountWriteTest method setup.

@Before
public void setup() throws IOException {
    storeDef = storeDefs.get(0);
    Integer zoneCountWrite = 1;
    // override
    storeDef = new StoreDefinition(storeDef.getName(), storeDef.getType(), storeDef.getDescription(), storeDef.getKeySerializer(), storeDef.getValueSerializer(), storeDef.getTransformsSerializer(), storeDef.getRoutingPolicy(), storeDef.getRoutingStrategyType(), storeDef.getReplicationFactor(), storeDef.getPreferredReads(), storeDef.getRequiredReads(), storeDef.getPreferredWrites(), storeDef.getRequiredWrites(), storeDef.getViewTargetStoreName(), storeDef.getValueTransformation(), storeDef.getZoneReplicationFactor(), storeDef.getZoneCountReads(), zoneCountWrite, storeDef.getRetentionDays(), storeDef.getRetentionScanThrottleRate(), storeDef.getRetentionFrequencyDays(), storeDef.getSerializerFactory(), storeDef.getHintedHandoffStrategyType(), storeDef.getHintPrefListSize(), storeDef.getOwners(), storeDef.getMemoryFootprintMB());
    storeDefs.set(0, storeDef);
    SocketStoreClientFactory socketStoreClientFactory = new SocketStoreClientFactory(clientConfig);
    for (Integer nodeId : cluster.getNodeIds()) {
        SocketStoreFactory socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
        VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, nodeId, TestUtils.createTempDir().getAbsolutePath(), cluster, storeDefs, new Properties());
        VoldemortServer vs = ServerTestUtils.startVoldemortServer(socketStoreFactory, config, cluster);
        vservers.put(nodeId, vs);
    }
    client = socketStoreClientFactory.getRawStore(storeDef.getName(), null);
}
Also used : ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) StoreDefinition(voldemort.store.StoreDefinition) SocketStoreFactory(voldemort.store.socket.SocketStoreFactory) Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) VoldemortConfig(voldemort.server.VoldemortConfig) Before(org.junit.Before)

Example 10 with ClientRequestExecutorPool

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

the class AvroAddStoreTest method setup.

/**
     * This test is to partially test the functionality of SetMetadata feature
     * of the VoldemortAdminTool
     */
@Before
public void setup() throws IOException {
    // setup cluster
    cluster = ClusterTestUtils.getZZZCluster();
    oldStores = ClusterTestUtils.getZZZStoreDefsInMemory();
    bsURL = cluster.getNodes().iterator().next().getSocketUrl().toString();
    for (Node node : cluster.getNodes()) {
        SocketStoreFactory ssf = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
        VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, node.getId(), TestUtils.createTempDir().getAbsolutePath(), cluster, oldStores, new Properties());
        VoldemortServer vs = ServerTestUtils.startVoldemortServer(ssf, config, cluster);
        vservers.put(node.getId(), vs);
        socketStoreFactories.put(node.getId(), ssf);
    }
    adminClient = new AdminClient(cluster);
}
Also used : ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) Node(voldemort.cluster.Node) SocketStoreFactory(voldemort.store.socket.SocketStoreFactory) Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) VoldemortConfig(voldemort.server.VoldemortConfig) AdminClient(voldemort.client.protocol.admin.AdminClient) 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