Package voldemort.routing

Examples of voldemort.routing.BaseStoreRoutingPlan


    @Test
    public void testReadRepairWithFailures() throws Exception {
        cluster = getNineNodeCluster();

        RoutedStore routedStore = getStore(cluster, 2, 2, 1, 0);
        BaseStoreRoutingPlan routingPlan = new BaseStoreRoutingPlan(cluster, this.storeDef);
        List<Integer> replicatingNodes = routingPlan.getReplicationNodeList(aKey.get());
        // This is node 1
        Node primaryNode = Iterables.get(cluster.getNodes(), replicatingNodes.get(0));
        // This is node 6
        Node secondaryNode = Iterables.get(cluster.getNodes(), replicatingNodes.get(1));
View Full Code Here


                                           zoneReplicationFactor);

        Store<ByteArray, byte[], byte[]> store = new InconsistencyResolvingStore<ByteArray, byte[], byte[]>(routedStore,
                                                                                                            new VectorClockInconsistencyResolver<byte[]>());

        BaseStoreRoutingPlan routingPlan = new BaseStoreRoutingPlan(cluster, this.storeDef);
        List<Integer> replicatingNodes = routingPlan.getReplicationNodeList(aKey.get());

        try {
            // Do the initial put with all nodes up
            store.put(aKey, new Versioned<byte[]>(aValue), null);
View Full Code Here

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

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

        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 + "("
View Full Code Here

                }
            }

            StoreDefinitionsMapper mapper = new StoreDefinitionsMapper();
            List<StoreDefinition> storeDefs = mapper.readStoreList(new StringReader(VoldemortTestConstants.getSingleStoreDefinitionsXml()));
            BaseStoreRoutingPlan rPlan = new BaseStoreRoutingPlan(adminClient.getAdminClientCluster(),
                                                                  StoreDefinitionUtils.getStoreDefinitionWithName(storeDefs,
                                                                                                                  "test"));

            // Confirm the valid ones made it
            for(Versioned<Slop> slop: validStoreSlops) {
                ByteArray key = slop.getValue().getKey();

                if(rPlan.getReplicationNodeList(key.get()).contains(1)) {
                    List<Versioned<byte[]>> slopEntry = adminClient.storeOps.getNodeKey("test",
                                                                                        1,
                                                                                        key);
                    if(slop.getValue().getOperation() == Operation.DELETE) {
                        assertTrue("Delete Slop should have not reached destination",
View Full Code Here

        // 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
View Full Code Here

        // Assumes master node is 0 and generates keys that goes to master node
        HashMap<String, String> keyValuePairs = new HashMap<String, String>();
        StoreDefinitionsMapper storedDefMapper = new StoreDefinitionsMapper();
        List<StoreDefinition> storeDefs = storedDefMapper.readStoreList(new File(storesxml));
        StoreDefinition testStoreDef = storeDefs.get(0);
        BaseStoreRoutingPlan baseStoreRoutingPlan = new BaseStoreRoutingPlan(cluster, testStoreDef);

        /*
         * Generating simple key values pairs of the form 3:3 where key and
         * value are same but route to the Master node's partition
         */

        int key = 0;
        int partiionId = -1;
        for(int count = 0; count < numKeys;) {
            byte[] keyBytes = Integer.toString(key).getBytes();
            partiionId = baseStoreRoutingPlan.getMasterPartitionId(keyBytes);
            if(partitionToNodeMap.get(partiionId) == 0) {
                keyValuePairs.put(String.valueOf(key), String.valueOf(key));
                count++;
            }
            key++;
View Full Code Here

                                                        "test/common/voldemort/config/single-store-322.xml",
                                                        new Properties());
        StringReader reader = new StringReader(VoldemortTestConstants.getSingleStore322Xml());
        StoreDefinition storeDef = new StoreDefinitionsMapper().readStoreList(reader).get(0);

        currentRoutingPlan = new BaseStoreRoutingPlan(cluster, storeDef);

        String bootStrapUrl = "";
        for(VoldemortServer server: servers) {
            Node node = server.getIdentityNode();
            socketStoreMap.put(node.getId(),
                               ServerTestUtils.getSocketStore(socketStoreFactory,
                                                              "test",
                                                              node.getHost(),
                                                              node.getSocketPort(),
                                                              RequestFormatType.PROTOCOL_BUFFERS,
                                                              false,
                                                              true));
            bootStrapUrl = "tcp://" + node.getHost() + ":" + node.getSocketPort();
        }
        testEntries = ServerTestUtils.createRandomKeyValueString(100);

        int oldPartitionMap[][] = { { 3, 6 }, { 1, 4 }, { 7, 2 }, { 5, 0 } };
        oldRoutingPlan = new BaseStoreRoutingPlan(ServerTestUtils.getLocalCluster(numServers,
                                                                                  oldPartitionMap),
                                                  storeDef);

        SocketStoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootStrapUrl));
        storeClient = factory.getStoreClient("test");
View Full Code Here

            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: keyStrings) {
                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
View Full Code Here

        Map<Integer, Store<ByteArray, byte[], byte[]>> storeMap = new HashMap<Integer, Store<ByteArray, byte[], byte[]>>();
        for(Node node: cluster.getNodes()) {
            storeMap.put(node.getId(),
                         getSocketStore(storeDef.getName(), node.getHost(), node.getSocketPort()));
        }
        BaseStoreRoutingPlan storeInstance = new BaseStoreRoutingPlan(cluster, storeDef);
        for(Entry<String, String> entry: testEntries.entrySet()) {
            ByteArray keyBytes = new ByteArray(ByteUtils.getBytes(entry.getKey(), "UTF-8"));
            List<Integer> preferenceNodes = storeInstance.getReplicationNodeList(keyBytes.get());
            // Go over every node
            for(int nodeId: preferenceNodes) {
                try {
                    storeMap.get(nodeId)
                            .put(keyBytes,
View Full Code Here

TOP

Related Classes of voldemort.routing.BaseStoreRoutingPlan

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.