Package voldemort.routing

Examples of voldemort.routing.BaseStoreRoutingPlan


        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


         * with errors in that case.
         */
        if(storeDef.getType().compareTo(ReadOnlyStorageConfiguration.TYPE_NAME) == 0) {
            throw new UnsupportedOperationException("put() not supported on read-only store");
        }
        BaseStoreRoutingPlan currentRoutingPlan = new BaseStoreRoutingPlan(currentCluster, storeDef);
        Integer redirectNode = getProxyNode(currentRoutingPlan, storeDef, key.get());
        /**
         * If I am rebalancing for this key, try to do remote get() if this node
         * does not have the key , put it locally first to get the correct
         * version ignoring any {@link ObsoleteVersionException}
         */
        if(redirectNode != null) {
            /*
             * first check if the key exists locally. If so, it means, it has
             * been moved over (either by a proxy fetch or background fetch) and
             * we are good simply issuing the put on top of that.
             */
            List<Versioned<byte[]>> vals = getInnerStore().get(key, transforms);
            if(vals.isEmpty()) {
                // if not, then go proxy fetch it
                if(logger.isTraceEnabled()) {
                    logger.trace("Proxying GET (before PUT) on stealer:" + metadata.getNodeId()
                                 + " for  key " + ByteUtils.toHexString(key.get()) + " to node:"
                                 + redirectNode);
                }
                proxyGetAndLocalPut(key, redirectNode, transforms);
            }
        }

        // Here we are sure that the current node has caught up with the proxy
        // for this key. Moving on to the put logic.
        // put the data locally, if this step fails, there will be no proxy puts
        getInnerStore().put(key, value, transforms);

        // submit an async task to issue proxy puts to the redirectNode
        // NOTE : if the redirect node is also a current replica for the key (we
        // could have a situation where the online replicated write could lose
        // out to the proxy put and hence fail the client operation with an
        // OVE). So do not send proxy puts in those cases.
        if(redirectNode != null
           && !currentRoutingPlan.getReplicationNodeList(key.get()).contains(redirectNode)) {
            AsyncProxyPutTask asyncProxyPutTask = new AsyncProxyPutTask(this,
                                                                        key,
                                                                        value,
                                                                        transforms,
                                                                        redirectNode);
View Full Code Here

        Integer nodeId = metadata.getNodeId();
        Integer zoneId = currentRoutingPlan.getCluster().getNodeById(nodeId).getZoneId();

        // Use the old store definition to get the routing object
        BaseStoreRoutingPlan oldRoutingPlan = new BaseStoreRoutingPlan(sourceCluster,
                                                                       sourceStoreDef);
        // Check the current node's relationship to the key.
        int zoneNAry = currentRoutingPlan.getZoneNAry(zoneId, nodeId, key);
        // Determine which node held the key with the same relationship in the
        // old cluster. That is your man!
        Integer redirectNodeId;
        try {
            redirectNodeId = oldRoutingPlan.getNodeIdForZoneNary(zoneId, zoneNAry, key);
        } catch(VoldemortException ve) {
            /*
             * If the zone does not exist, as in the case of Zone Expansion,
             * there will be no proxy bridges built. The only other time an
             * exception can be thrown here is when the replicaType is invalid.
View Full Code Here

    private Integer getProxyNode(byte[] key) {
        Cluster currentCluster = metadata.getCluster();
        StoreDefinition storeDef = metadata.getStoreDef(getName());
        // TODO Ideally, this object construction should be done only when
        // metadata changes using a listener mechanism
        BaseStoreRoutingPlan currentRoutingPlan = new BaseStoreRoutingPlan(currentCluster, storeDef);
        return getProxyNode(currentRoutingPlan, storeDef, key);
    }
View Full Code Here

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

            logger.info("Key-Version file " + kvFileName
                        + " exists, so will not sample keys from file " + keysFileName + ".");
            return true;
        }

        BaseStoreRoutingPlan storeRoutingPlan = new BaseStoreRoutingPlan(cluster, storeDefinition);
        BufferedReader keyReader = null;
        BufferedWriter kvWriter = null;
        try {
            keyReader = new BufferedReader(new FileReader(keysFileName));
            kvWriter = new BufferedWriter(new FileWriter(kvFileName));
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.