use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class StreamingSlopPusherTest method replaceOneNode.
private void replaceOneNode(int nodeId) throws IOException {
Cluster oldCluster = cluster;
cluster = ServerTestUtils.getLocalClusterWithOneNodeReplaced(cluster, nodeId);
metadataStore = ServerTestUtils.createMetadataStore(cluster, new StoreDefinitionsMapper().readStoreList(new File(storesXmlfile)));
String newClusterXml = new ClusterMapper().writeCluster(cluster);
AdminClient adminClient = ServerTestUtils.getAdminClient(oldCluster);
for (Integer remoteNodeId : oldCluster.getNodeIds()) {
try {
adminClient.metadataMgmtOps.updateRemoteMetadata(remoteNodeId, MetadataStore.CLUSTER_KEY, newClusterXml);
} catch (UnreachableStoreException e) {
}
}
}
use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class ExceededQuotaSlopTest method setGetPutQuotasForEachServer.
public void setGetPutQuotasForEachServer() throws Exception {
Properties adminProperties = new Properties();
adminProperties.setProperty("max_connections", "2");
adminClient = new AdminClient(cluster, new AdminClientConfig().setMaxConnectionsPerNode(2));
Map<Pair<Integer, QuotaType>, Integer> throughPutMap = new HashMap<Pair<Integer, QuotaType>, Integer>();
// Set Node0 Quota
throughPutMap.put(new Pair<Integer, QuotaType>(0, QuotaType.PUT_THROUGHPUT), 5);
throughPutMap.put(new Pair<Integer, QuotaType>(0, QuotaType.GET_THROUGHPUT), 20);
// Set Node1 Quota
throughPutMap.put(new Pair<Integer, QuotaType>(1, QuotaType.PUT_THROUGHPUT), 2);
throughPutMap.put(new Pair<Integer, QuotaType>(1, QuotaType.GET_THROUGHPUT), 20);
for (Entry<Pair<Integer, QuotaType>, Integer> throughPut : throughPutMap.entrySet()) {
int nodeId = throughPut.getKey().getFirst();
QuotaType type = throughPut.getKey().getSecond();
int value = throughPut.getValue();
VectorClock clock = VectorClockUtils.makeClockWithCurrentTime(cluster.getNodeIds());
NodeValue<ByteArray, byte[]> operationValue = new NodeValue<ByteArray, byte[]>(nodeId, new ByteArray(getKeyBytes(type)), new Versioned<byte[]>(ByteUtils.getBytes(Integer.toString(value), encodingType), clock));
try {
adminClient.storeOps.putNodeKeyValue(quotaStoreName, operationValue);
} catch (Exception e) {
throw new Exception("Exception when setting put quota for node " + nodeId + " Operation " + type + "." + e.getMessage());
}
}
}
use of voldemort.client.protocol.admin.AdminClient in project whirr by apache.
the class VoldemortServiceTest method testInstances.
@Test(timeout = TestConstants.ITEST_TIMEOUT)
public void testInstances() throws Exception {
Set<Instance> instances = cluster.getInstances();
String url = "tcp://" + instances.iterator().next().getPublicAddress().getHostAddress() + ":" + ADMIN_PORT;
AdminClient client = new AdminClient(url, new AdminClientConfig());
voldemort.cluster.Cluster c = client.getAdminClientCluster();
List<String> voldemortBasedHosts = new ArrayList<String>();
for (Node node : c.getNodes()) voldemortBasedHosts.add(node.getHost());
List<String> whirrBasedHosts = new ArrayList<String>();
for (Instance instance : instances) whirrBasedHosts.add(instance.getPrivateAddress().getHostAddress());
Collections.sort(voldemortBasedHosts);
Collections.sort(whirrBasedHosts);
Assert.assertEquals(whirrBasedHosts, voldemortBasedHosts);
}
use of voldemort.client.protocol.admin.AdminClient in project whirr by apache.
the class VoldemortServiceTest method waitForBootstrap.
private void waitForBootstrap() {
for (Instance instance : cluster.getInstances()) {
while (true) {
try {
String url = "tcp://" + instance.getPublicAddress().getHostAddress() + ":" + ADMIN_PORT;
AdminClient client = new AdminClient(url, new AdminClientConfig());
client.getAdminClientCluster();
break;
} catch (Exception e) {
System.out.print(".");
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
break;
}
}
}
}
}
use of voldemort.client.protocol.admin.AdminClient in project voldemort by voldemort.
the class ConsistencyCheck method execute.
/**
* Run consistency check on connected key-value iterators
*
* @return Results in form of ConsistencyCheckStats
*/
public Reporter execute() throws IOException {
Map<ClusterNode, Iterator<Pair<ByteArray, Versioned<byte[]>>>> nodeFetchIteratorMap;
nodeFetchIteratorMap = new HashMap<ClusterNode, Iterator<Pair<ByteArray, Versioned<byte[]>>>>();
/* start fetch from each node */
for (ClusterNode clusterNode : clusterNodeList) {
AdminClient adminClient = adminClients.get(clusterNode.getPrefixId());
List<Integer> singlePartition = new ArrayList<Integer>();
singlePartition.add(partitionId);
if (logger.isDebugEnabled()) {
logger.debug("Start fetch request to Node[" + clusterNode.toString() + "] for partition[" + partitionId + "] of store[" + storeName + "]");
}
Iterator<Pair<ByteArray, Versioned<byte[]>>> fetchIterator;
fetchIterator = adminClient.bulkFetchOps.fetchEntries(clusterNode.getNode().getId(), storeName, singlePartition, null, false);
nodeFetchIteratorMap.put(clusterNode, fetchIterator);
}
keyFetchTracker = new KeyFetchTracker(clusterNodeList.size());
/* start to fetch */
boolean fetchFinished;
do {
fetchFinished = true;
for (Map.Entry<ClusterNode, Iterator<Pair<ByteArray, Versioned<byte[]>>>> nodeFetchIteratorMapEntry : nodeFetchIteratorMap.entrySet()) {
ClusterNode clusterNode = nodeFetchIteratorMapEntry.getKey();
Iterator<Pair<ByteArray, Versioned<byte[]>>> fetchIterator = nodeFetchIteratorMapEntry.getValue();
if (fetchIterator.hasNext()) {
fetchFinished = false;
reporter.recordScans(1);
Pair<ByteArray, Versioned<byte[]>> fetchedEntry = fetchIterator.next();
ByteArray key = fetchedEntry.getFirst();
Versioned<byte[]> versioned = fetchedEntry.getSecond();
// record fetch
recordFetch(clusterNode, key, versioned);
// try sweep last key fetched by this iterator
keyFetchTracker.recordFetch(clusterNode, key);
if (logger.isTraceEnabled()) {
logger.trace("fetched " + new String(key.get()));
logger.trace("map has keys: " + keyValueNodeSetMap.size());
}
trySweepAll();
if (logger.isTraceEnabled()) {
logger.trace("sweeped; keys left: " + keyValueNodeSetMap.size());
}
}
}
// stats reporting
if (logger.isInfoEnabled()) {
String report = reporter.tryProgressReport();
if (report != null) {
for (String line : report.split("\n")) {
logger.info(line);
}
}
}
} while (!fetchFinished);
/* adminClient shutdown */
for (AdminClient adminClient : adminClients) {
if (adminClient != null) {
adminClient.close();
}
}
// clean keys not sufficient for write
cleanIneligibleKeys(keyValueNodeSetMap, requiredWrites);
keyFetchTracker.finishAll();
trySweepAll();
reporter.processInconsistentKeys(storeName, partitionId, keyValueNodeSetMap);
return reporter;
}
Aggregations