Search in sources :

Example 11 with VoldemortConfig

use of voldemort.server.VoldemortConfig in project voldemort by voldemort.

the class ZoneShrinkageEndToEndTest method setup.

@Before
public void setup() throws IOException {
    // setup and start servers
    for (Node node : cluster.getNodes()) {
        String tempFolderPath = TestUtils.createTempDir().getAbsolutePath();
        // setup servers
        SocketStoreFactory ssf = new TestSocketStoreFactory();
        VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, node.getId(), tempFolderPath, cluster, storeDefs, new Properties());
        Assert.assertTrue(config.isSlopEnabled());
        Assert.assertTrue(config.isSlopPusherJobEnabled());
        Assert.assertTrue(config.getAutoPurgeDeadSlops());
        config.setSlopFrequencyMs(10000L);
        VoldemortServer vs = ServerTestUtils.startVoldemortServer(ssf, config, cluster);
        vservers.put(node.getId(), vs);
        socketStoreFactories.put(node.getId(), ssf);
        voldemortConfigs.put(node.getId(), config);
    }
    for (Node node : cluster.getNodes()) {
        if (node.getZoneId() != droppingZoneId) {
            survivingNodes.add(node);
        }
    }
    bootstrapURL = survivingNodes.get(0).getSocketUrl().toString();
}
Also used : TestSocketStoreFactory(voldemort.store.socket.TestSocketStoreFactory) Node(voldemort.cluster.Node) SocketStoreFactory(voldemort.store.socket.SocketStoreFactory) TestSocketStoreFactory(voldemort.store.socket.TestSocketStoreFactory) Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) VoldemortConfig(voldemort.server.VoldemortConfig) Before(org.junit.Before)

Example 12 with VoldemortConfig

use of voldemort.server.VoldemortConfig in project voldemort by voldemort.

the class OfflineStateTest method verifyNewServer.

private void verifyNewServer(VoldemortServer originalServer) throws Exception {
    String baseDirPath = originalServer.getVoldemortConfig().getVoldemortHome();
    String parentDirPath = Paths.get(baseDirPath).getParent().toString();
    List<StoreDefinition> storeDefs = originalServer.getMetadataStore().getStoreDefList();
    VoldemortServer newServer = null;
    try {
        VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(useNio, 0, parentDirPath, cluster, storeDefs, new Properties());
        newServer = ServerTestUtils.startVoldemortServer(socketStoreFactory, config, cluster, false);
        ServerTestUtils.waitForServerStart(socketStoreFactory, newServer.getIdentityNode());
        fail("should have thrown an connection exception");
    } catch (UnreachableStoreException e) {
        assertEquals(ConnectException.class, e.getCause().getClass());
    }
    newServer.goOnline();
    servers[0] = newServer;
    assertTrue(testOnlineTraffic());
}
Also used : StoreDefinition(voldemort.store.StoreDefinition) UnreachableStoreException(voldemort.store.UnreachableStoreException) VoldemortServer(voldemort.server.VoldemortServer) Properties(java.util.Properties) VoldemortConfig(voldemort.server.VoldemortConfig) ConnectException(java.net.ConnectException)

Example 13 with VoldemortConfig

use of voldemort.server.VoldemortConfig in project voldemort by voldemort.

the class ReplaceNodeTest method testNodeDownReplacement.

@Test
public void testNodeDownReplacement() throws Exception {
    final int REPLACEMENT_NODE = 0;
    // This is to simulate the case where a machine failed but hard disk was intact
    // In this case we will move the hard disk to another machine, edit the cluster.xml
    // to point to this host and start this machine.
    // The case is simulated by remembering the cluster of node A.
    // Replace this node with node B. Now create a new server with cluster of
    // node A ( this is to simulate the cluster.xml edit) and data directory of B
    // ( this is to simulate the hard disk move). Now try replacing the node B with
    // newly created node after shutting down the node B.
    Cluster cluster = originalServers[nodeToBeReplaced].getMetadataStore().getCluster();
    List<StoreDefinition> storeDefs = originalServers[nodeToBeReplaced].getMetadataStore().getStoreDefList();
    Node node = originalServers[nodeToBeReplaced].getIdentityNode();
    //Verify the node down scenario first
    final boolean DO_RESTORE = false;
    final boolean STOP_OLD_NODE = true;
    verifyNodeReplacement(nodeToBeReplaced, otherServers, REPLACEMENT_NODE, STOP_OLD_NODE, DO_RESTORE);
    // Now the replacement node is part of the original cluster.
    // Stop the replacement node, assume you moved the hard disk
    // to a new node ( This is done by starting another node)
    // that points to the data directory of the replacement node.
    String baseDirPath = otherServers[REPLACEMENT_NODE].getVoldemortConfig().getVoldemortHome();
    // Using ServerTestUtils stopVoldemortServer also deletes the data
    // directory so using the stop, to simulate the hard disk move.
    otherServers[REPLACEMENT_NODE].stop();
    VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, node.getId(), baseDirPath, cluster, storeDefs, new Properties());
    Assert.assertTrue(config.isSlopEnabled());
    Assert.assertTrue(config.isSlopPusherJobEnabled());
    Assert.assertTrue(config.getAutoPurgeDeadSlops());
    config.setSlopFrequencyMs(8000L);
    config.setEnableNodeIdDetection(this.autoDetectNodeId);
    if (this.autoDetectNodeId) {
        config.setNodeIdImplementation(new NodeIdHostMatcher(nodeToBeReplaced));
    }
    // Though baseDir is used as part of Config, TestUtils, always appends
    // it with node- (nodeId). So forcefully overwriting it here to point to
    // the old directory.
    config.setVoldemortHome(baseDirPath);
    SocketStoreFactory ssf = new TestSocketStoreFactory();
    VoldemortServer hardDiskMovedServer = ServerTestUtils.startVoldemortServer(ssf, config, cluster);
    ssf.close();
    otherServers[REPLACEMENT_NODE] = hardDiskMovedServer;
    final boolean SKIP_RESTORE = true;
    final boolean DONOT_STOP_OLD_NODE = true;
    verifyNodeReplacement(nodeToBeReplaced, otherServers, REPLACEMENT_NODE, DONOT_STOP_OLD_NODE, SKIP_RESTORE);
}
Also used : Node(voldemort.cluster.Node) Cluster(voldemort.cluster.Cluster) SocketStoreFactory(voldemort.store.socket.SocketStoreFactory) TestSocketStoreFactory(voldemort.store.socket.TestSocketStoreFactory) Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) VoldemortConfig(voldemort.server.VoldemortConfig) NodeIdHostMatcher(voldemort.server.NodeIdHostMatcher) TestSocketStoreFactory(voldemort.store.socket.TestSocketStoreFactory) StoreDefinition(voldemort.store.StoreDefinition) Test(org.junit.Test)

Example 14 with VoldemortConfig

use of voldemort.server.VoldemortConfig in project voldemort by voldemort.

the class RebalanceRebootstrapConsistencyTest method rebalance.

/*
     * simulate rebalance behavior
     */
public void rebalance() {
    assert servers != null && servers.size() > 1;
    VoldemortConfig config = servers.get(0).getVoldemortConfig();
    adminClient = AdminClient.createTempAdminClient(config, cluster, 4);
    List<Integer> partitionIds = ImmutableList.of(0, 1);
    int req = adminClient.storeMntOps.migratePartitions(0, 1, testStoreNameRW, partitionIds, null, null);
    adminClient.rpcOps.waitForCompletion(1, req, 5, TimeUnit.SECONDS);
    Versioned<Cluster> versionedCluster = adminClient.metadataMgmtOps.getRemoteCluster(0);
    Node node0 = versionedCluster.getValue().getNodeById(0);
    Node node1 = versionedCluster.getValue().getNodeById(1);
    Node newNode0 = new Node(node0.getId(), node0.getHost(), node0.getHttpPort(), node0.getSocketPort(), node0.getAdminPort(), ImmutableList.<Integer>of());
    Node newNode1 = new Node(node1.getId(), node1.getHost(), node1.getHttpPort(), node1.getSocketPort(), node1.getAdminPort(), ImmutableList.of(0, 1));
    adminClient.storeMntOps.deletePartitions(0, testStoreNameRW, ImmutableList.of(0, 1), null);
    newCluster = new Cluster(cluster.getName(), ImmutableList.of(newNode0, newNode1), Lists.newArrayList(cluster.getZones()));
    newstoredefs = new ArrayList<StoreDefinition>();
    newstoredefs.add(rwStoreDefWithReplication2);
    for (Node node : cluster.getNodes()) {
        VectorClock clock = (VectorClock) versionedCluster.getVersion();
        clock.incrementVersion(node.getId(), System.currentTimeMillis());
        adminClient.metadataMgmtOps.updateRemoteMetadata(node.getId(), MetadataStore.STORES_KEY, new Versioned<String>(storeMapper.writeStoreList(newstoredefs), clock));
        adminClient.metadataMgmtOps.updateRemoteMetadata(node.getId(), MetadataStore.CLUSTER_KEY, new Versioned<String>(clusterMapper.writeCluster(newCluster), clock));
    }
    adminClient.metadataMgmtOps.updateMetadataversion(adminClient.getAdminClientCluster().getNodeIds(), CLUSTER_VERSION_KEY);
}
Also used : Node(voldemort.cluster.Node) StoreDefinition(voldemort.store.StoreDefinition) VectorClock(voldemort.versioning.VectorClock) Cluster(voldemort.cluster.Cluster) VoldemortConfig(voldemort.server.VoldemortConfig)

Example 15 with VoldemortConfig

use of voldemort.server.VoldemortConfig in project voldemort by voldemort.

the class ServerTestUtils method createServerConfig.

public static VoldemortConfig createServerConfig(boolean useNio, int nodeId, String baseDir, String clusterFile, String storeFile, Properties properties) throws IOException {
    Props props = new Props();
    props.put("node.id", nodeId);
    props.put("voldemort.home", baseDir + "/node-" + nodeId);
    props.put("bdb.cache.size", 1 * 1024 * 1024);
    props.put("jmx.enable", "false");
    props.put("enable.mysql.engine", "true");
    props.loadProperties(properties);
    VoldemortConfig config = new VoldemortConfig(props);
    config.setMysqlDatabaseName("voldemort");
    config.setMysqlUsername("voldemort");
    config.setMysqlPassword("voldemort");
    config.setStreamMaxReadBytesPerSec(10 * 1000 * 1000);
    config.setStreamMaxWriteBytesPerSec(10 * 1000 * 1000);
    config.setUseNioConnector(useNio);
    // clean and reinit metadata dir.
    File tempDir = new File(config.getMetadataDirectory());
    tempDir.mkdirs();
    tempDir.deleteOnExit();
    File tempDir2 = new File(config.getDataDirectory());
    tempDir2.mkdirs();
    tempDir2.deleteOnExit();
    // copy cluster.xml / stores.xml to temp metadata dir.
    if (null != clusterFile)
        FileUtils.copyFile(new File(clusterFile), new File(tempDir.getAbsolutePath() + File.separatorChar + "cluster.xml"));
    if (null != storeFile)
        FileUtils.copyFile(new File(storeFile), new File(tempDir.getAbsolutePath() + File.separatorChar + "stores.xml"));
    return config;
}
Also used : Props(voldemort.utils.Props) File(java.io.File) VoldemortConfig(voldemort.server.VoldemortConfig)

Aggregations

VoldemortConfig (voldemort.server.VoldemortConfig)53 Properties (java.util.Properties)29 VoldemortServer (voldemort.server.VoldemortServer)24 Before (org.junit.Before)18 Node (voldemort.cluster.Node)16 StoreDefinition (voldemort.store.StoreDefinition)16 File (java.io.File)15 Props (voldemort.utils.Props)14 SocketStoreFactory (voldemort.store.socket.SocketStoreFactory)13 ByteArray (voldemort.utils.ByteArray)12 ClientRequestExecutorPool (voldemort.store.socket.clientrequest.ClientRequestExecutorPool)11 Cluster (voldemort.cluster.Cluster)7 Test (org.junit.Test)6 ClientConfig (voldemort.client.ClientConfig)6 SocketStoreClientFactory (voldemort.client.SocketStoreClientFactory)6 BdbStorageConfiguration (voldemort.store.bdb.BdbStorageConfiguration)6 AdminClient (voldemort.client.protocol.admin.AdminClient)5 OptionParser (joptsimple.OptionParser)4 OptionSet (joptsimple.OptionSet)4 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)4