Search in sources :

Example 41 with AdminClient

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) {
        }
    }
}
Also used : StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) Cluster(voldemort.cluster.Cluster) ClusterMapper(voldemort.xml.ClusterMapper) UnreachableStoreException(voldemort.store.UnreachableStoreException) File(java.io.File) AdminClient(voldemort.client.protocol.admin.AdminClient)

Example 42 with AdminClient

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());
        }
    }
}
Also used : NodeValue(voldemort.store.routed.NodeValue) AdminClientConfig(voldemort.client.protocol.admin.AdminClientConfig) HashMap(java.util.HashMap) QuotaType(voldemort.store.quota.QuotaType) VectorClock(voldemort.versioning.VectorClock) Properties(java.util.Properties) VoldemortException(voldemort.VoldemortException) IOException(java.io.IOException) ByteArray(voldemort.utils.ByteArray) AdminClient(voldemort.client.protocol.admin.AdminClient) Pair(voldemort.utils.Pair)

Example 43 with AdminClient

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);
}
Also used : AdminClientConfig(voldemort.client.protocol.admin.AdminClientConfig) Instance(org.apache.whirr.Cluster.Instance) Node(voldemort.cluster.Node) ArrayList(java.util.ArrayList) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Example 44 with AdminClient

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;
                }
            }
        }
    }
}
Also used : AdminClientConfig(voldemort.client.protocol.admin.AdminClientConfig) Instance(org.apache.whirr.Cluster.Instance) IOException(java.io.IOException) AdminClient(voldemort.client.protocol.admin.AdminClient)

Example 45 with AdminClient

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;
}
Also used : Versioned(voldemort.versioning.Versioned) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map) AdminClient(voldemort.client.protocol.admin.AdminClient)

Aggregations

AdminClient (voldemort.client.protocol.admin.AdminClient)80 Test (org.junit.Test)35 Cluster (voldemort.cluster.Cluster)26 Node (voldemort.cluster.Node)26 Properties (java.util.Properties)19 StoreDefinition (voldemort.store.StoreDefinition)19 ArrayList (java.util.ArrayList)18 AdminClientConfig (voldemort.client.protocol.admin.AdminClientConfig)18 VoldemortException (voldemort.VoldemortException)17 IOException (java.io.IOException)14 Before (org.junit.Before)14 ByteArray (voldemort.utils.ByteArray)14 HashMap (java.util.HashMap)13 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)13 File (java.io.File)11 VoldemortServer (voldemort.server.VoldemortServer)11 ClientConfig (voldemort.client.ClientConfig)10 VectorClock (voldemort.versioning.VectorClock)10 Versioned (voldemort.versioning.Versioned)9 ClusterMapper (voldemort.xml.ClusterMapper)9