Search in sources :

Example 21 with VoldemortServer

use of voldemort.server.VoldemortServer 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 22 with VoldemortServer

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

the class OfflineStateTest method testStartingOfflineServers.

/**
     *This test simulates the situation when Voldemort server is close under offline mode,
     *the new server instance should read server state from the local file and start under respective modes.
     */
@Test
public void testStartingOfflineServers() throws Exception {
    VoldemortServer server = getVoldemortServer(0);
    server.goOffline();
    server.stop();
    verifyNewServer(server);
}
Also used : VoldemortServer(voldemort.server.VoldemortServer) Test(org.junit.Test)

Example 23 with VoldemortServer

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

the class QuotaTest method tearDown.

@After
public void tearDown() throws Exception {
    adminClient.close();
    for (VoldemortServer server : servers) {
        ServerTestUtils.stopVoldemortServer(server);
    }
    ssf.close();
}
Also used : VoldemortServer(voldemort.server.VoldemortServer) After(org.junit.After)

Example 24 with VoldemortServer

use of voldemort.server.VoldemortServer 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 25 with VoldemortServer

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

the class StoreServlet method init.

@Override
public void init() throws ServletException {
    super.init();
    // servlet context
    if (this.requestHandler == null) {
        ServletContext context = this.getServletContext();
        VoldemortServer server = (VoldemortServer) Utils.notNull(context.getAttribute(VoldemortServletContextListener.SERVER_KEY));
        HttpService httpService = (HttpService) server.getService(ServiceType.HTTP);
        this.requestHandler = httpService.getRequestHandler();
    }
}
Also used : ServletContext(javax.servlet.ServletContext) VoldemortServer(voldemort.server.VoldemortServer)

Aggregations

VoldemortServer (voldemort.server.VoldemortServer)86 Properties (java.util.Properties)36 VoldemortConfig (voldemort.server.VoldemortConfig)24 Test (org.junit.Test)23 Node (voldemort.cluster.Node)23 Before (org.junit.Before)21 SocketStoreFactory (voldemort.store.socket.SocketStoreFactory)20 ClientRequestExecutorPool (voldemort.store.socket.clientrequest.ClientRequestExecutorPool)18 ClientConfig (voldemort.client.ClientConfig)17 ByteArray (voldemort.utils.ByteArray)17 ArrayList (java.util.ArrayList)16 After (org.junit.After)15 StoreDefinition (voldemort.store.StoreDefinition)15 SocketStoreClientFactory (voldemort.client.SocketStoreClientFactory)14 Cluster (voldemort.cluster.Cluster)14 IOException (java.io.IOException)11 HashMap (java.util.HashMap)11 AdminClient (voldemort.client.protocol.admin.AdminClient)11 VectorClock (voldemort.versioning.VectorClock)10 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)9