Search in sources :

Example 76 with Cluster

use of voldemort.cluster.Cluster in project voldemort by voldemort.

the class GossiperTest method attemptStartAdditionalServer.

private Cluster attemptStartAdditionalServer() throws IOException {
    // Set up a new cluster that is one bigger than the original cluster
    int originalSize = cluster.getNumberOfNodes();
    int numOriginalPorts = originalSize * 3;
    int[] ports = new int[numOriginalPorts + 3];
    for (int i = 0, j = 0; i < originalSize; i++, j += 3) {
        Node node = cluster.getNodeById(i);
        System.arraycopy(new int[] { node.getHttpPort(), node.getSocketPort(), node.getAdminPort() }, 0, ports, j, 3);
    }
    System.arraycopy(ServerTestUtils.findFreePorts(3), 0, ports, numOriginalPorts, 3);
    // Create a new partitioning scheme with room for a new server
    final Cluster newCluster = ServerTestUtils.getLocalCluster(originalSize + 1, ports, new int[][] { { 0, 4, 8 }, { 1, 5, 9 }, { 2, 6, 10 }, { 3, 7, 11 } });
    // Create a new server
    VoldemortServer newServer = ServerTestUtils.startVoldemortServer(socketStoreFactory, ServerTestUtils.createServerConfig(useNio, 3, TestUtils.createTempDir().getAbsolutePath(), null, storesXmlfile, props), newCluster);
    // This step is only reached if startVoldemortServer does *not* throw a
    // BindException due to TOCTOU problem with getLocalCluster
    servers.add(newServer);
    return newCluster;
}
Also used : Node(voldemort.cluster.Node) Cluster(voldemort.cluster.Cluster) VoldemortServer(voldemort.server.VoldemortServer)

Example 77 with Cluster

use of voldemort.cluster.Cluster in project voldemort by voldemort.

the class GossiperTest method testGossiper.

// Protect against this test running forever until the root cause of running
// forever is found.
@Test(timeout = 1800)
public void testGossiper() throws Exception {
    Cluster newCluster = null;
    boolean startedAdditionalServer = false;
    while (!startedAdditionalServer) {
        try {
            newCluster = attemptStartAdditionalServer();
            startedAdditionalServer = true;
        } catch (IOException ioe) {
            logger.warn("Caught an IOException when attempting to start additional server. Will print stacktrace and then attempt to start additional server again.");
            ioe.printStackTrace();
        }
    }
    // Get the new cluster.xml
    AdminClient localAdminClient = getAdminClient(newCluster);
    Versioned<String> versionedClusterXML = localAdminClient.metadataMgmtOps.getRemoteMetadata(3, MetadataStore.CLUSTER_KEY);
    // Increment the version, let what would be the "donor node" know about
    // it to seed the Gossip.
    Version version = versionedClusterXML.getVersion();
    ((VectorClock) version).incrementVersion(3, ((VectorClock) version).getTimestamp() + 1);
    ((VectorClock) version).incrementVersion(0, ((VectorClock) version).getTimestamp() + 1);
    localAdminClient.metadataMgmtOps.updateRemoteMetadata(0, MetadataStore.CLUSTER_KEY, versionedClusterXML);
    localAdminClient.metadataMgmtOps.updateRemoteMetadata(3, MetadataStore.CLUSTER_KEY, versionedClusterXML);
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
    // Wait up to five seconds for Gossip to spread
    final Cluster newFinalCluster = newCluster;
    try {
        TestUtils.assertWithBackoff(5000, new Attempt() {

            public void checkCondition() {
                int serversSeen = 0;
                // Now verify that we have gossiped correctly
                for (VoldemortServer server : servers) {
                    Cluster clusterAtServer = server.getMetadataStore().getCluster();
                    int nodeId = server.getMetadataStore().getNodeId();
                    assertEquals("server " + nodeId + " has heard " + " the gossip about number of nodes", clusterAtServer.getNumberOfNodes(), newFinalCluster.getNumberOfNodes());
                    assertEquals("server " + nodeId + " has heard " + " the gossip about partitions", clusterAtServer.getNodeById(nodeId).getPartitionIds(), newFinalCluster.getNodeById(nodeId).getPartitionIds());
                    serversSeen++;
                }
                assertEquals("saw all servers", serversSeen, servers.size());
            }
        });
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
}
Also used : Attempt(voldemort.Attempt) Version(voldemort.versioning.Version) VectorClock(voldemort.versioning.VectorClock) Cluster(voldemort.cluster.Cluster) IOException(java.io.IOException) VoldemortServer(voldemort.server.VoldemortServer) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Example 78 with Cluster

use of voldemort.cluster.Cluster in project voldemort by voldemort.

the class StoreRoutingPlanTest method setupNonContiguous.

@Before
public void setupNonContiguous() {
    Cluster z1z3Current = ClusterTestUtils.getZ1Z3ClusterWithNonContiguousNodeIds();
    HashMap<Integer, Integer> zoneRep211 = new HashMap<Integer, Integer>();
    zoneRep211.put(1, 2);
    zoneRep211.put(3, 2);
    StoreDefinition z1z3211StoreDef = new StoreDefinitionBuilder().setName("z1z3211").setType(BdbStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.ZONE_STRATEGY).setReplicationFactor(4).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).setZoneCountReads(0).setZoneCountWrites(0).setZoneReplicationFactor(zoneRep211).setHintedHandoffStrategy(HintedHandoffStrategyType.PROXIMITY_STRATEGY).build();
    z1z3BaseRoutingPlan = new BaseStoreRoutingPlan(z1z3Current, z1z3211StoreDef);
    z1z3StoreRoutingPlan = new StoreRoutingPlan(z1z3Current, z1z3211StoreDef);
    // 3 zones
    Cluster z1z3z5Current = ClusterTestUtils.getZ1Z3Z5ClusterWithNonContiguousNodeIds();
    HashMap<Integer, Integer> zoneRep3zones211 = new HashMap<Integer, Integer>();
    zoneRep3zones211.put(1, 2);
    zoneRep3zones211.put(3, 2);
    zoneRep3zones211.put(5, 2);
    StoreDefinition z1z3z5211StoreDef = new StoreDefinitionBuilder().setName("z1z3z5211").setType(BdbStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.ZONE_STRATEGY).setReplicationFactor(6).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).setZoneCountReads(0).setZoneCountWrites(0).setZoneReplicationFactor(zoneRep3zones211).setHintedHandoffStrategy(HintedHandoffStrategyType.PROXIMITY_STRATEGY).build();
    z1z3z5BaseRoutingPlan = new BaseStoreRoutingPlan(z1z3z5Current, z1z3z5211StoreDef);
    z1z3z5StoreRoutingPlan = new StoreRoutingPlan(z1z3z5Current, z1z3z5211StoreDef);
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) HashMap(java.util.HashMap) StoreDefinition(voldemort.store.StoreDefinition) Cluster(voldemort.cluster.Cluster) SerializerDefinition(voldemort.serialization.SerializerDefinition) Before(org.junit.Before)

Example 79 with Cluster

use of voldemort.cluster.Cluster in project voldemort by voldemort.

the class BlockingSlopPusherTest method setUp.

@Override
protected void setUp() throws Exception {
    Cluster cluster = makeCluster(3);
    repo = new StoreRepository();
    repo.setSlopStore(new SlopStorageEngine(new InMemoryStorageEngine<ByteArray, byte[], byte[]>("slop"), cluster));
    repo.addNodeStore(0, new InMemoryStorageEngine<ByteArray, byte[], byte[]>(STORE_NAME));
    repo.addNodeStore(1, new InMemoryStorageEngine<ByteArray, byte[], byte[]>(STORE_NAME));
    repo.addNodeStore(2, new FailingStore<ByteArray, byte[], byte[]>(STORE_NAME));
    MetadataStore metadataStore = ServerTestUtils.createMetadataStore(cluster, ServerTestUtils.getStoreDefs(1));
    Props props = new Props();
    props.put("node.id", 0);
    props.put("voldemort.home", "/");
    pusher = new BlockingSlopPusherJob(repo, metadataStore, new NoopFailureDetector(), new VoldemortConfig(props), new ScanPermitWrapper(1));
}
Also used : BlockingSlopPusherJob(voldemort.server.scheduler.slop.BlockingSlopPusherJob) NoopFailureDetector(voldemort.cluster.failuredetector.NoopFailureDetector) ScanPermitWrapper(voldemort.server.storage.ScanPermitWrapper) Cluster(voldemort.cluster.Cluster) StoreRepository(voldemort.server.StoreRepository) Props(voldemort.utils.Props) VoldemortConfig(voldemort.server.VoldemortConfig) MetadataStore(voldemort.store.metadata.MetadataStore) InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) ByteArray(voldemort.utils.ByteArray) SlopStorageEngine(voldemort.store.slop.SlopStorageEngine)

Example 80 with Cluster

use of voldemort.cluster.Cluster in project voldemort by voldemort.

the class StreamingSlopPusherTest method replaceOneNode.

private void replaceOneNode(int nodeId) throws IOException {
    Cluster oldCluster = cluster;
    cluster = ServerTestUtils.getLocalClusterWithOneNodeReplaced(cluster, nodeId);
    metadataStore = ServerTestUtils.createMetadataStore(cluster, new StoreDefinitionsMapper().readStoreList(new File(storesXmlfile)));
    String newClusterXml = new ClusterMapper().writeCluster(cluster);
    AdminClient adminClient = ServerTestUtils.getAdminClient(oldCluster);
    for (Integer remoteNodeId : oldCluster.getNodeIds()) {
        try {
            adminClient.metadataMgmtOps.updateRemoteMetadata(remoteNodeId, MetadataStore.CLUSTER_KEY, newClusterXml);
        } catch (UnreachableStoreException e) {
        }
    }
}
Also used : StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) Cluster(voldemort.cluster.Cluster) ClusterMapper(voldemort.xml.ClusterMapper) UnreachableStoreException(voldemort.store.UnreachableStoreException) File(java.io.File) AdminClient(voldemort.client.protocol.admin.AdminClient)

Aggregations

Cluster (voldemort.cluster.Cluster)197 Test (org.junit.Test)74 StoreDefinition (voldemort.store.StoreDefinition)74 Node (voldemort.cluster.Node)72 ArrayList (java.util.ArrayList)51 HashMap (java.util.HashMap)47 ByteArray (voldemort.utils.ByteArray)33 AdminClient (voldemort.client.protocol.admin.AdminClient)26 ClusterTestUtils (voldemort.ClusterTestUtils)25 VoldemortException (voldemort.VoldemortException)24 List (java.util.List)23 ClusterMapper (voldemort.xml.ClusterMapper)23 File (java.io.File)20 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)18 Zone (voldemort.cluster.Zone)17 Versioned (voldemort.versioning.Versioned)17 Properties (java.util.Properties)16 IOException (java.io.IOException)15 VoldemortServer (voldemort.server.VoldemortServer)15 RoutingStrategyFactory (voldemort.routing.RoutingStrategyFactory)14