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());
}
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);
}
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();
}
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);
}
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();
}
}
Aggregations