use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class EndToEndRebootstrapTest method testEndToEndRebootstrap.
/*
* Test to validate that the client bootstraps on metadata change.
* 1. Do some operations to validate that the client is correctly initialized.
* 2. Update the cluster.xml using the Admin Tool (which should update the
* metadata version as well).
* 3. Verify that the client bootstraps after this update.
* 4. Whether the client has automatically bootstrapped is verified by checking
* the new bootstrap time in the client registry.
*/
@Test
public void testEndToEndRebootstrap() {
try {
sanityTestClientOps();
// Get bootstraptime at start
String bootstrapTime = getPropertyFromClientInfo("bootstrapTime");
// Update cluster.xml metadata
ClientConfig clientConfig = new ClientConfig().setBootstrapUrls(bootStrapUrls).setClientZoneId(CLIENT_ZONE_ID);
AdminClient adminClient = new AdminClient(clientConfig);
for (Node node : cluster.getNodes()) {
VoldemortAdminTool.executeSetMetadata(node.getId(), adminClient, CLUSTER_KEY, new ClusterMapper().writeCluster(cluster));
}
// Wait for about 15 seconds to be sure
try {
Thread.sleep(15000);
} catch (Exception e) {
fail("Interrupted .");
}
// Get bootstraptime again
String newBootstrapTime = getPropertyFromClientInfo("bootstrapTime");
assertFalse(bootstrapTime.equals(newBootstrapTime));
long origTime = Long.parseLong(bootstrapTime);
long newTime = Long.parseLong(newBootstrapTime);
assertTrue(newTime > origTime);
} catch (Exception e) {
fail("Error in validating end to end client rebootstrap : " + e);
}
}
use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class EndToEndRebootstrapTest method testEndToEndRebootstrapWithSetMetadataPair.
/*
* Test to validate that the client bootstraps on metadata change.
* 1. Do some operations to validate that the client is correctly initialized.
* 2. Update the <cluster.xml, stores.xml> pair using the Admin Tool.
* 3. Verify that the client bootstraps after this update.
* 4. Whether the client has automatically bootstrapped is verified by checking
* the new bootstrap time in the client registry.
*/
@Test
public void testEndToEndRebootstrapWithSetMetadataPair() {
try {
sanityTestClientOps();
// Get bootstraptime at start
String bootstrapTime = getPropertyFromClientInfo("bootstrapTime");
// Update cluster.xml metadata
ClientConfig clientConfig = new ClientConfig().setBootstrapUrls(bootStrapUrls).setClientZoneId(CLIENT_ZONE_ID);
AdminClient adminClient = new AdminClient(clientConfig);
StoreDefinitionsMapper storeDefsMapper = new StoreDefinitionsMapper();
List<StoreDefinition> storeDefs = storeDefsMapper.readStoreList(new File(storesXmlfile));
for (Node node : cluster.getNodes()) {
VoldemortAdminTool.executeSetMetadataPair(node.getId(), adminClient, CLUSTER_KEY, new ClusterMapper().writeCluster(cluster), STORES_KEY, storeDefsMapper.writeStoreList(storeDefs));
}
// Wait for about 15 seconds to be sure
try {
Thread.sleep(15000);
} catch (Exception e) {
fail("Interrupted .");
}
// Get bootstraptime again
String newBootstrapTime = getPropertyFromClientInfo("bootstrapTime");
assertFalse(bootstrapTime.equals(newBootstrapTime));
long origTime = Long.parseLong(bootstrapTime);
long newTime = Long.parseLong(newBootstrapTime);
assertTrue(newTime > origTime);
} catch (Exception e) {
fail("Error in validating end to end client rebootstrap : " + e);
}
}
use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class OfflineStateTest method testStateTransitions.
@Test
public void testStateTransitions() throws Exception {
AdminClient client = getAdminClient();
assertTrue(testOnlineTraffic());
assertTrue(testSlopStreaming());
toOfflineState(client);
assertFalse(testOnlineTraffic());
assertFalse(testSlopStreaming());
toNormalState(client);
assertTrue(testOnlineTraffic());
assertTrue(testSlopStreaming());
toOfflineState(client);
assertFalse(testOnlineTraffic());
assertFalse(testSlopStreaming());
toNormalState(client);
assertTrue(testOnlineTraffic());
assertTrue(testSlopStreaming());
toOfflineState(client);
assertFalse(testOnlineTraffic());
assertFalse(testSlopStreaming());
toNormalState(client);
assertTrue(testOnlineTraffic());
assertTrue(testSlopStreaming());
}
use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class QuotaResetterTest method setUp.
@Before
public void setUp() throws IOException {
int numServers = 2;
servers = new VoldemortServer[numServers];
int[][] partitionMap = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 } };
Properties serverProperties = new Properties();
serverProperties.setProperty("client.max.connections.per.node", "20");
serverProperties.setProperty("enforce.retention.policy.on.read", Boolean.toString(false));
cluster = ServerTestUtils.startVoldemortCluster(numServers, servers, partitionMap, socketStoreFactory, true, null, storesXmlfile, serverProperties);
List<StoreDefinition> storeDefs = new StoreDefinitionsMapper().readStoreList(new File(storesXmlfile));
this.storeNames = Sets.newHashSet();
for (StoreDefinition storeDef : storeDefs) {
storeNames.add(storeDef.getName());
}
Properties adminProperties = new Properties();
adminProperties.setProperty("max_connections", "20");
adminClient = new AdminClient(cluster, new AdminClientConfig(adminProperties));
}
use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class AdminServiceBasicTest method testUpdateClusterMetadata.
@Test
public void testUpdateClusterMetadata() {
Cluster updatedCluster = ServerTestUtils.getLocalCluster(4);
AdminClient client = getAdminClient();
for (int i = 0; i < NUM_RUNS; i++) {
VectorClock existingClock = ((VectorClock) client.metadataMgmtOps.getRemoteCluster(0).getVersion());
VectorClock clock = existingClock.incremented(0, System.currentTimeMillis());
client.metadataMgmtOps.updateRemoteCluster(0, updatedCluster, clock);
assertEquals("Cluster should match", updatedCluster, getVoldemortServer(0).getMetadataStore().getCluster());
assertEquals("AdminClient.getMetdata() should match", client.metadataMgmtOps.getRemoteCluster(0).getValue(), updatedCluster);
// version should match
assertEquals("versions should match as well.", clock, client.metadataMgmtOps.getRemoteCluster(0).getVersion());
}
}
Aggregations