Package voldemort.routing

Examples of voldemort.routing.StoreRoutingPlan


        // Confirm that we would not route to any of the dropped nodes for any
        // store.
        Set<Integer> dropNodes = interimCluster.getNodeIdsInZone(dropZoneId);
        for(StoreDefinition storeDef: clippedStoreDefs) {
            StoreRoutingPlan routingPlan = new StoreRoutingPlan(finalCluster, storeDef);
            Node[] partitionToNode = finalCluster.getPartitionIdToNodeArray();
            for(int p = 0; p < partitionToNode.length; p++) {
                List<Integer> replicaNodes = routingPlan.getReplicationNodeList(p);
                assertFalse("Should not be routing to any dropped nodes",
                            replicaNodes.removeAll(dropNodes));
            }
        }
    }
View Full Code Here


     * @return ns to complete count constructions
     */
    public long perfStoreRoutingPlan(int count) {
        long startNs = System.nanoTime();
        for(int i = 0; i < count; ++i) {
            new StoreRoutingPlan(cluster, storeDefinition);
        }

        return System.nanoTime() - startNs;
    }
View Full Code Here

    }

    @Test
    public void testPrimaryResolvingForkLift() throws Exception {

        StoreRoutingPlan srcStoreInstance = new StoreRoutingPlan(srcCluster,
                                                                 primaryResolvingStoreDef);

        // populate data on the source cluster..
        for(Map.Entry<String, String> entry: kvPairs.entrySet()) {
            srcPrimaryResolvingStoreClient.put(entry.getKey(), entry.getValue());
        }

        // generate a conflict on the master partition
        int masterNode = srcStoreInstance.getNodeIdForPartitionId(srcStoreInstance.getMasterPartitionId(conflictKey.getBytes("UTF-8")));
        VectorClock losingClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 0, 5)),
                                                  System.currentTimeMillis());
        VectorClock winningClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 1, 5)),
                                                   losingClock.getTimestamp() + 1);
        srcAdminClient.storeOps.putNodeKeyValue(PRIMARY_RESOLVING_STORE_NAME,
View Full Code Here

    }

    @Test
    public void testGloballyResolvingForkLift() throws Exception {

        StoreRoutingPlan srcStoreInstance = new StoreRoutingPlan(srcCluster,
                                                                 globallyResolvingStoreDef);

        // populate data on the source cluster..
        for(Map.Entry<String, String> entry: kvPairs.entrySet()) {
            srcGloballyResolvingStoreClient.put(entry.getKey(), entry.getValue());
        }

        // generate a conflict on the primary and a secondary
        List<Integer> nodeList = srcStoreInstance.getReplicationNodeList(srcStoreInstance.getMasterPartitionId(conflictKey.getBytes("UTF-8")));
        VectorClock losingClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 0, 5)),
                                                  System.currentTimeMillis());
        VectorClock winningClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 1, 5)),
                                                   losingClock.getTimestamp() + 1);
        srcAdminClient.storeOps.putNodeKeyValue(GLOBALLY_RESOLVING_STORE_NAME,
View Full Code Here

    }

    @Test
    public void testForkLiftOverWrite() throws Exception {

        StoreRoutingPlan srcStoreInstance = new StoreRoutingPlan(srcCluster,
                                                                 globallyResolvingStoreDef);

        // populate data on the source cluster..
        for(Map.Entry<String, String> entry: kvPairs.entrySet()) {
            srcGloballyResolvingStoreClient.put(entry.getKey(), entry.getValue());
        }

        // generate a conflict on the primary and a secondary
        List<Integer> nodeList = srcStoreInstance.getReplicationNodeList(srcStoreInstance.getMasterPartitionId(conflictKey.getBytes("UTF-8")));
        VectorClock losingClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 0, 5)),
                                                  System.currentTimeMillis());
        VectorClock winningClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 1, 5)),
                                                   losingClock.getTimestamp() + 1);
        srcAdminClient.storeOps.putNodeKeyValue(GLOBALLY_RESOLVING_STORE_NAME,
View Full Code Here

    @Test
    public void testNoresolutionForkLift() throws Exception {

        int versions = 0;

        StoreRoutingPlan srcStoreInstance = new StoreRoutingPlan(srcCluster, nonResolvingStoreDef);

        // generate a conflict on the master partition
        int masterNode = srcStoreInstance.getNodeIdForPartitionId(srcStoreInstance.getMasterPartitionId(conflictKey.getBytes("UTF-8")));
        VectorClock losingClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 0, 5)),
                                                  System.currentTimeMillis());
        VectorClock winningClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 1, 5)),
                                                   losingClock.getTimestamp() + 1);
        srcAdminClient.storeOps.putNodeKeyValue(MULTIPLE_VERSIONS_STORE_NAME,
View Full Code Here

        Cluster cluster = adminClient.getAdminClientCluster();
        List<StoreDefinition> storeDefs = adminClient.metadataMgmtOps.getRemoteStoreDefList()
                                                                     .getValue();
        StoreDefinition storeDef = StoreDefinitionUtils.getStoreDefinitionWithName(storeDefs,
                                                                                   storeName);
        StoreRoutingPlan routingPlan = new StoreRoutingPlan(cluster, storeDef);
        BaseStoreRoutingPlan bRoutingPlan = new BaseStoreRoutingPlan(cluster, storeDef);

        final int COLUMN_WIDTH = 30;

        for(String keyStr: keyList) {
            byte[] key = ByteUtils.fromHexString(keyStr);
            System.out.println("Key :" + keyStr);
            System.out.println("Replicating Partitions :"
                               + routingPlan.getReplicatingPartitionList(key));
            System.out.println("Replicating Nodes :");
            List<Integer> nodeList = routingPlan.getReplicationNodeList(routingPlan.getMasterPartitionId(key));
            for(int i = 0; i < nodeList.size(); i++) {
                System.out.println(nodeList.get(i) + "\t"
                                   + cluster.getNodeById(nodeList.get(i)).getHost());
            }

            System.out.println("Zone Nary information :");
            HashMap<Integer, Integer> zoneRepMap = storeDef.getZoneReplicationFactor();

            for(Zone zone: cluster.getZones()) {
                System.out.println("\tZone #" + zone.getId());
                int numReplicas = -1;
                if(zoneRepMap == null) {
                    // non zoned cluster
                    numReplicas = storeDef.getReplicationFactor();
                } else {
                    // zoned cluster
                    if(!zoneRepMap.containsKey(zone.getId())) {
                        Utils.croak("Repfactor for Zone " + zone.getId() + " not found in storedef");
                    }
                    numReplicas = zoneRepMap.get(zone.getId());
                }

                String FormatString = "%s %s %s\n";
                System.out.format(FormatString,
                                  Utils.paddedString("REPLICA#", COLUMN_WIDTH),
                                  Utils.paddedString("PARTITION", COLUMN_WIDTH),
                                  Utils.paddedString("NODE", COLUMN_WIDTH));
                for(int i = 0; i < numReplicas; i++) {
                    Integer nodeId = bRoutingPlan.getNodeIdForZoneNary(zone.getId(), i, key);
                    Integer partitionId = routingPlan.getNodesPartitionIdForKey(nodeId, key);
                    System.out.format(FormatString,
                                      Utils.paddedString(i + "", COLUMN_WIDTH),
                                      Utils.paddedString(partitionId.toString(), COLUMN_WIDTH),
                                      Utils.paddedString(nodeId + "("
                                                         + cluster.getNodeById(nodeId).getHost()
View Full Code Here

            sb.append("Store exemplar: " + currentStoreDef.getName())
              .append(Utils.NEWLINE)
              .append("\tThere are " + uniqueStores.get(currentStoreDef) + " other similar stores.")
              .append(Utils.NEWLINE);

            StoreRoutingPlan currentSRP = new StoreRoutingPlan(currentCluster, currentStoreDef);
            StoreDefinition finalStoreDef = StoreUtils.getStoreDef(finalStoreDefs,
                                                                   currentStoreDef.getName());
            StoreRoutingPlan finalSRP = new StoreRoutingPlan(finalCluster, finalStoreDef);

            // Only care about existing zones
            for(int zoneId: currentCluster.getZoneIds()) {
                int zonePrimariesCount = 0;
                int invalidMetadata = 0;

                // Examine nodes in current cluster in existing zone.
                for(int nodeId: currentCluster.getNodeIdsInZone(zoneId)) {
                    // For every zone-primary in current cluster
                    for(int zonePrimaryPartitionId: currentSRP.getZonePrimaryPartitionIds(nodeId)) {
                        zonePrimariesCount++;
                        // Determine if original zone-primary node is still some
                        // form of n-ary in final cluster. If not,
                        // InvalidMetadataException will fire.
                        if(!finalSRP.getZoneNAryPartitionIds(nodeId)
                                    .contains(zonePrimaryPartitionId)) {
                            invalidMetadata++;
                        }
                    }
                }
View Full Code Here

    @Before
    public void setup() throws Exception {
        cluster = VoldemortTestConstants.getNineNodeCluster();
        StringReader reader = new StringReader(VoldemortTestConstants.getSingleStore322Xml());
        storeDef = new StoreDefinitionsMapper().readStoreList(reader).get(0);
        routingPlan = new StoreRoutingPlan(cluster, storeDef);
        key = "key1".getBytes();
        keyReplicas = Lists.newArrayList(0, 2, 1);
    }
View Full Code Here

        if(request.hasInitialCluster()) {
            this.initialCluster = new ClusterMapper().readCluster(new StringReader(request.getInitialCluster()));
        } else {
            this.initialCluster = metadataStore.getCluster();
        }
        this.storeInstance = new StoreRoutingPlan(this.initialCluster, this.storeDef);

        this.throttler = new EventThrottler(voldemortConfig.getStreamMaxReadBytesPerSec());
        if(request.hasFilter()) {
            this.filter = AdminServiceRequestHandler.getFilterFromRequest(request.getFilter(),
                                                                          voldemortConfig,
View Full Code Here

TOP

Related Classes of voldemort.routing.StoreRoutingPlan

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.