Search in sources :

Example 66 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class QuotaOperationsTest method setup.

@Before
public void setup() throws IOException {
    // setup cluster
    cluster = ServerTestUtils.getLocalCluster(2);
    stores = ServerTestUtils.getStoreDefs(2);
    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, stores, new Properties());
        VoldemortServer vs = ServerTestUtils.startVoldemortServer(ssf, config, cluster);
        vservers.put(node.getId(), vs);
        socketStoreFactories.put(node.getId(), ssf);
    }
    adminClient = new AdminClient(cluster);
    storeName = stores.iterator().next().getName();
}
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)

Example 67 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class ClusterForkLiftToolTest method setUpClusters.

@Before
public void setUpClusters() {
    // setup four nodes with one store and one partition
    final SocketStoreFactory socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 32 * 1024);
    try {
        int[][] srcPartitionMap = { { 0 }, { 1 }, { 2 }, { 3 } };
        srcServers = new VoldemortServer[4];
        srcCluster = ServerTestUtils.startVoldemortCluster(4, srcServers, srcPartitionMap, socketStoreFactory, true, null, SRC_STORES_XML, new Properties());
        Node node = srcCluster.getNodeById(0);
        srcBootStrapUrl = "tcp://" + node.getHost() + ":" + node.getSocketPort();
        int[][] dstPartitionMap = { { 0 }, { 1 }, { 2 } };
        dstServers = new VoldemortServer[3];
        dstCluster = ServerTestUtils.startVoldemortCluster(3, dstServers, dstPartitionMap, socketStoreFactory, true, null, DST_STORES_XML, new Properties());
        node = dstCluster.getNodeById(0);
        dstBootStrapUrl = "tcp://" + node.getHost() + ":" + node.getSocketPort();
        kvPairs = ServerTestUtils.createRandomKeyValueString(100);
        int keyCount = 0;
        for (String key : kvPairs.keySet()) {
            if (keyCount == 0)
                firstKey = key;
            if (keyCount == kvPairs.size() - 1)
                lastKey = key;
            if (keyCount == kvPairs.size() / 2)
                conflictKey = key;
            keyCount++;
        }
        srcAdminClient = new AdminClient(srcCluster);
        List<StoreDefinition> storeDefs = new StoreDefinitionsMapper().readStoreList(new File(SRC_STORES_XML));
        primaryResolvingStoreDef = StoreUtils.getStoreDef(storeDefs, PRIMARY_RESOLVING_STORE_NAME);
        globallyResolvingStoreDef = StoreUtils.getStoreDef(storeDefs, GLOBALLY_RESOLVING_STORE_NAME);
        nonResolvingStoreDef = StoreUtils.getStoreDef(storeDefs, MULTIPLE_VERSIONS_STORE_NAME);
        srcfactory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(srcBootStrapUrl).setSelectors(1).setRoutingTimeout(1000, java.util.concurrent.TimeUnit.MILLISECONDS).setSocketTimeout(1000, java.util.concurrent.TimeUnit.MILLISECONDS).setConnectionTimeout(1000, java.util.concurrent.TimeUnit.MILLISECONDS).setMaxConnectionsPerNode(1));
        srcPrimaryResolvingStoreClient = srcfactory.getStoreClient(PRIMARY_RESOLVING_STORE_NAME);
        srcGloballyResolvingStoreClient = srcfactory.getStoreClient(GLOBALLY_RESOLVING_STORE_NAME);
        dstfactory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(dstBootStrapUrl).setSelectors(1).setRoutingTimeout(1000, java.util.concurrent.TimeUnit.MILLISECONDS).setSocketTimeout(1000, java.util.concurrent.TimeUnit.MILLISECONDS).setConnectionTimeout(1000, java.util.concurrent.TimeUnit.MILLISECONDS).setMaxConnectionsPerNode(1));
        dstPrimaryResolvingStoreClient = dstfactory.getStoreClient(PRIMARY_RESOLVING_STORE_NAME);
        dstGloballyResolvingStoreClient = dstfactory.getStoreClient(GLOBALLY_RESOLVING_STORE_NAME);
    } catch (IOException e) {
        e.printStackTrace();
        fail("Unexpected exception");
    }
}
Also used : Node(voldemort.cluster.Node) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) SocketStoreFactory(voldemort.store.socket.SocketStoreFactory) IOException(java.io.IOException) Properties(java.util.Properties) ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) StoreDefinition(voldemort.store.StoreDefinition) ClientConfig(voldemort.client.ClientConfig) File(java.io.File) AdminClient(voldemort.client.protocol.admin.AdminClient) Before(org.junit.Before)

Example 68 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class ClusterForkLiftToolTest method testNoresolutionForkLift.

@Test
public void testNoresolutionForkLift() throws Exception {
    int versions = 0;
    StoreRoutingPlan srcStoreInstance = new StoreRoutingPlan(srcCluster, nonResolvingStoreDef);
    // generate a conflict on the master partition
    int masterNode = srcStoreInstance.getNodeIdForPartitionId(srcStoreInstance.getMasterPartitionId(conflictKey.getBytes("UTF-8")));
    VectorClock losingClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 0, 5)), System.currentTimeMillis());
    VectorClock winningClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 1, 5)), losingClock.getTimestamp() + 1);
    srcAdminClient.storeOps.putNodeKeyValue(MULTIPLE_VERSIONS_STORE_NAME, new NodeValue<ByteArray, byte[]>(masterNode, new ByteArray(conflictKey.getBytes("UTF-8")), new Versioned<byte[]>("losing value".getBytes("UTF-8"), losingClock)));
    srcAdminClient.storeOps.putNodeKeyValue(MULTIPLE_VERSIONS_STORE_NAME, new NodeValue<ByteArray, byte[]>(masterNode, new ByteArray(conflictKey.getBytes("UTF-8")), new Versioned<byte[]>("winning value".getBytes("UTF-8"), winningClock)));
    // perform the forklifting..
    ClusterForkLiftTool forkLiftTool = new ClusterForkLiftTool(srcBootStrapUrl, dstBootStrapUrl, false, // ignoreSchemaMismatch
    false, 10000, 1, 1000, Lists.newArrayList(MULTIPLE_VERSIONS_STORE_NAME), null, ClusterForkLiftTool.ForkLiftTaskMode.no_resolution);
    forkLiftTool.run();
    AdminClient dstAdminClient = new AdminClient(dstBootStrapUrl);
    for (Node node : dstAdminClient.getAdminClientCluster().getNodes()) {
        Iterator<Pair<ByteArray, Versioned<byte[]>>> entryItr = dstAdminClient.bulkFetchOps.fetchEntries(node.getId(), MULTIPLE_VERSIONS_STORE_NAME, node.getPartitionIds(), null, true);
        while (entryItr.hasNext()) {
            Pair<ByteArray, Versioned<byte[]>> record = entryItr.next();
            ByteArray key = record.getFirst();
            Versioned<byte[]> versioned = record.getSecond();
            versions++;
        }
    }
    assertEquals("Both conflicting versions present", versions, 2);
}
Also used : StoreRoutingPlan(voldemort.routing.StoreRoutingPlan) Versioned(voldemort.versioning.Versioned) VectorClock(voldemort.versioning.VectorClock) Node(voldemort.cluster.Node) ClockEntry(voldemort.versioning.ClockEntry) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Example 69 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class ZoneShrinkageCLITest method testZoneShrinkageCLI.

@Test
public void testZoneShrinkageCLI() throws Exception {
    cluster = ClusterTestUtils.getZZZCluster();
    oldStores = ClusterTestUtils.getZZZStoreDefsInMemory();
    setup();
    String[] argv = ("--url " + bsURL + " --drop-zoneid 0 --real-run").split(" ");
    ZoneShrinkageCLI.main(argv);
    AdminClient adminClient = new AdminClient(bsURL);
    assertEquals(2, adminClient.getAdminClientCluster().getZoneIds().size());
    String bootstrapUrl = adminClient.getAdminClientCluster().getNodes().iterator().next().getSocketUrl().toString();
    StoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl));
    StoreClient<String, String> client = factory.getStoreClient(oldStores.get(0).getName());
    client.put("k1", "v1");
    assertEquals("v1", client.get("k1").getValue());
}
Also used : SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) ClientConfig(voldemort.client.ClientConfig) AdminClient(voldemort.client.protocol.admin.AdminClient) SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) StoreClientFactory(voldemort.client.StoreClientFactory) Test(org.junit.Test)

Example 70 with AdminClient

use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.

the class MetaOperationsTest method setup.

@Before
public void setup() throws IOException {
    // setup cluster
    cluster = ServerTestUtils.getLocalCluster(2);
    stores = ServerTestUtils.getStoreDefs(2);
    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, stores, 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

AdminClient (voldemort.client.protocol.admin.AdminClient)80 Test (org.junit.Test)35 Cluster (voldemort.cluster.Cluster)26 Node (voldemort.cluster.Node)26 Properties (java.util.Properties)19 StoreDefinition (voldemort.store.StoreDefinition)19 ArrayList (java.util.ArrayList)18 AdminClientConfig (voldemort.client.protocol.admin.AdminClientConfig)18 VoldemortException (voldemort.VoldemortException)17 IOException (java.io.IOException)14 Before (org.junit.Before)14 ByteArray (voldemort.utils.ByteArray)14 HashMap (java.util.HashMap)13 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)13 File (java.io.File)11 VoldemortServer (voldemort.server.VoldemortServer)11 ClientConfig (voldemort.client.ClientConfig)10 VectorClock (voldemort.versioning.VectorClock)10 Versioned (voldemort.versioning.Versioned)9 ClusterMapper (voldemort.xml.ClusterMapper)9