use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class VoldemortServerTest method testClusterWithDifferentStateFails.
@Test
public void testClusterWithDifferentStateFails() throws IOException {
Cluster localCluster = ServerTestUtils.getLocalCluster(1);
VoldemortConfig config = getVoldemortConfig(new Properties());
server = new VoldemortServer(config, localCluster);
server.start();
final int UPDATED_NODE_ID = 3;
Node oldNode = localCluster.getNodes().iterator().next();
// For single local node, host matcher is not used.
config.setNodeIdImplementation(new NodeIdHostMatcher(UPDATED_NODE_ID));
Cluster updatedCluster = ServerTestUtils.getLocalCluster(UPDATED_NODE_ID + 1);
oldAdminClient = new AdminClient(localCluster);
try {
oldAdminClient.metadataMgmtOps.updateRemoteCluster(oldNode.getId(), updatedCluster, VectorClockUtils.makeClockWithCurrentTime(localCluster.getNodeIds()));
Assert.fail("Invalid node id should have failed");
} catch (VoldemortException ex) {
// Expected, ignore
}
}
use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class VoldemortServerTest method testClusterUpdateWithAutoDetection.
@Test
public void testClusterUpdateWithAutoDetection() throws IOException {
Cluster localCluster = ServerTestUtils.getLocalCluster(1);
VoldemortConfig config = getVoldemortConfig(new Properties());
server = new VoldemortServer(config, localCluster);
server.start();
final int UPDATED_NODE_ID = 3;
Node oldNode = localCluster.getNodes().iterator().next();
// For single local node, host matcher is not used.
config.setNodeIdImplementation(new NodeIdHostMatcher(UPDATED_NODE_ID));
Cluster updatedCluster = ServerTestUtils.getLocalCluster(UPDATED_NODE_ID + 1);
oldAdminClient = new AdminClient(localCluster);
List<Node> newNodes = Lists.newArrayList();
for (Node node : updatedCluster.getNodes()) {
if (node.getId() != UPDATED_NODE_ID) {
newNodes.add(node);
}
}
Node nodeToBeReplaced = updatedCluster.getNodeById(UPDATED_NODE_ID);
Node updatedNode = new Node(UPDATED_NODE_ID, oldNode.getHost(), oldNode.getHttpPort(), oldNode.getSocketPort(), oldNode.getAdminPort(), nodeToBeReplaced.getPartitionIds());
newNodes.add(updatedNode);
Cluster updatedClusterWithCorrectNode = new Cluster("updated-cluster", newNodes);
oldAdminClient.metadataMgmtOps.updateRemoteCluster(oldNode.getId(), updatedClusterWithCorrectNode, VectorClockUtils.makeClockWithCurrentTime(localCluster.getNodeIds()));
Assert.assertEquals("Identity node is not auto detected", UPDATED_NODE_ID, server.getIdentityNode().getId());
Assert.assertEquals("Voldemort config is not updated", UPDATED_NODE_ID, server.getVoldemortConfig().getNodeId());
Assert.assertEquals("Metadata store is not updated", UPDATED_NODE_ID, server.getMetadataStore().getNodeId());
}
use of voldemort.client.protocol.admin.AdminClient 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();
}
}
use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class RepairJobTest method testRepairJob.
@Test
public void testRepairJob() {
// start the servers
setUp();
// Create socket store
storeMap = createSocketStore(storeDefs.get(0));
// Generate random data, populate cluster with it.
HashMap<String, String> testEntries = ServerTestUtils.createRandomKeyValueString(128);
populateData(testEntries);
// create admin client and run repair on all nodes
AdminClient admin = new AdminClient(cluster);
for (int i = 0; i < 9; i++) {
admin.storeMntOps.repairJob(i);
}
// wait for the repair to complete
for (int i = 0; i < 9; i++) {
ServerTestUtils.waitForAsyncOperationOnServer(serverMap.get(i), "Repair", 5000);
}
BaseStoreRoutingPlan storeInstance = new BaseStoreRoutingPlan(cluster, storeDefs.get(0));
for (Entry<String, String> entry : testEntries.entrySet()) {
ByteArray keyBytes = new ByteArray(ByteUtils.getBytes(entry.getKey(), "UTF-8"));
List<Integer> preferenceNodes = storeInstance.getReplicationNodeList(keyBytes.get());
List<Integer> allNodes = new ArrayList<Integer>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8));
// Repair job should have deleted the keys on the nodes that
// shouldn't have been
// hosting the key. Go over all these remaining nodes to make sure
// that it's true.
allNodes.removeAll(preferenceNodes);
for (int nodeId : allNodes) {
try {
List<Versioned<byte[]>> retVal = storeMap.get(nodeId).get(keyBytes, null);
assertEquals("Repair did not run properly as it left the key it should have" + " deleted", retVal.isEmpty(), true);
} catch (Exception e) {
// We expect a bunch of invalidmetadata exceptions as we are
// asking for key
// that doesn't belong to the nodes. Hence leaving the catch
// empty.
}
}
// pref list.
for (int nodeId : preferenceNodes) {
try {
List<Versioned<byte[]>> retVal = storeMap.get(nodeId).get(keyBytes, null);
assertEquals("Repair job has deleted keys that it should not have", retVal.isEmpty(), false);
} catch (Exception e) {
e.printStackTrace();
}
}
}
for (Store<ByteArray, byte[], byte[]> store : storeMap.values()) {
store.close();
}
}
use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class SlopPurgeTest method setUp.
@Before
public void setUp() throws Exception {
cluster = ServerTestUtils.getLocalZonedCluster(6, 3, new int[] { 0, 0, 1, 1, 2, 2 }, new int[][] { { 0 }, { 2 }, { 4 }, { 1 }, { 3 }, { 5 } });
servers = new VoldemortServer[cluster.getNodes().size()];
slopSerializer = new SlopSerializer();
Properties serverProperties = new Properties();
// Schedule the slop pusher far far far out in the future, so it won't
// run during the test
serverProperties.setProperty("slop.frequency.ms", "" + (Integer.MAX_VALUE));
// Also no auto purging so we are sure that the only thing deleting the
// slops is the purge job
serverProperties.setProperty("auto.purge.dead.slops", "false");
cluster = ServerTestUtils.startVoldemortCluster(servers, null, null, "test/common/voldemort/config/three-stores-with-zones.xml", serverProperties, cluster);
for (VoldemortServer server : servers) {
if (server.getIdentityNode().getId() == PURGE_SERVER_ID) {
purgedServer = server;
break;
}
}
Properties adminProperties = new Properties();
adminProperties.setProperty("max_connections", "2");
adminClient = new AdminClient(servers[0].getMetadataStore().getCluster(), new AdminClientConfig(adminProperties));
}
Aggregations