Package voldemort.cluster

Examples of voldemort.cluster.Node


        Map<ByteArray, byte[]> transforms = pipelineData.getTransforms();

        final AtomicBoolean isResponseProcessed = new AtomicBoolean(false);

        for (Map.Entry<Node, List<ByteArray>> entry: pipelineData.getNodeToKeysMap().entrySet()) {
            final Node node = entry.getKey();
            final Collection<ByteArray> keys = entry.getValue();

            NonblockingStoreCallback callback = new NonblockingStoreCallback() {

                public void requestComplete(Object result, long requestTime) {
                    if (logger.isTraceEnabled())
                        logger.trace(pipeline.getOperation().getSimpleName()
                                     + " response received (" + requestTime + " ms.) from node "
                                     + node.getId());

                    Response<Iterable<ByteArray>, Object> response = new Response<Iterable<ByteArray>, Object>(node,
                                                                                                               keys,
                                                                                                               result,
                                                                                                               requestTime);
                    responses.put(node.getId(), response);
                    latch.countDown();
                    // TODO: There is inconsistency between the exceptions are treated here in the
                    // completion callback and in the application thread.
                    // They need a cleanup to make them consistent. Thought about handling
                    // them here, but it is the selector thread that is calling this completion method,
                    // handleResponseError has some synchronization, not sure about the effect, so reserving
                    // it for later.

                    // isResponseProcessed just reduces the time window during
                    // which a exception can go uncounted. When the parallel
                    // requests timeout and it is trying Serial timeout
                    // exceptions are lost and the node is never marked down.
                    // This reduces the window where an exception is lost
                    if (isResponseProcessed.get() && response.getValue() instanceof Exception)
                        if (response.getValue() instanceof InvalidMetadataException) {
                            pipelineData.reportException((InvalidMetadataException) response.getValue());
                            logger.warn("Received invalid metadata problem after a successful "
                                        + pipeline.getOperation().getSimpleName()
                                        + " call on node " + node.getId() + ", store '"
                                        + pipelineData.getStoreName() + "'");
                        } else {
                            handleResponseError(response, pipeline, failureDetector);
                        }
                }

            };

            if (logger.isTraceEnabled())
                logger.trace("Submitting " + pipeline.getOperation().getSimpleName()
                             + " request on node " + node.getId());

            NonblockingStore store = nonblockingStores.get(node.getId());
            store.submitGetAllRequest(keys, transforms, callback, timeoutMs);
        }

        try {
            latch.await(timeoutMs, TimeUnit.MILLISECONDS);
View Full Code Here


        }

        for(int i = 0; i < getPartitionToNode().length; i++) {
            // add this one if we haven't already, and it can satisfy some zone
            // replicationFactor
            Node currentNode = getNodeByPartition(index);
            if(!preferenceNodesList.contains(currentNode)) {
                preferenceNodesList.add(currentNode);
                if(checkZoneRequirement(requiredRepFactor, currentNode.getZoneId()))
                    replicationPartitionsList.add(index);
            }

            // if we have enough, go home
            if(replicationPartitionsList.size() >= getNumReplicas())
View Full Code Here

     */
    // TODO: add unit test.
    public boolean zoneNAryExists(int zoneId, int zoneNAry, int partitionId) {
        int currentZoneNAry = -1;
        for(int replicatingNodeId: getReplicationNodeList(partitionId)) {
            Node replicatingNode = cluster.getNodeById(replicatingNodeId);
            if(replicatingNode.getZoneId() == zoneId) {
                currentZoneNAry++;
                if(currentZoneNAry == zoneNAry) {
                    return true;
                }
            }
View Full Code Here

        }

        List<Integer> replicatingNodeIds = getReplicationNodeList(partitionId);
        int zoneNAry = -1;
        for(int replicatingNodeId: replicatingNodeIds) {
            Node replicatingNode = cluster.getNodeById(replicatingNodeId);
            // bump up the replica number once you encounter a node in the given
            // zone
            if(replicatingNode.getZoneId() == zoneId) {
                zoneNAry++;
            }
            if(replicatingNodeId == nodeId) {
                return zoneNAry;
            }
View Full Code Here

    public int getNodeIdForZoneNary(int zoneId, int zoneNary, int partitionId) {
        List<Integer> replicatingNodeIds = getReplicationNodeList(partitionId);

        int zoneNAry = -1;
        for(int replicatingNodeId: replicatingNodeIds) {
            Node replicatingNode = cluster.getNodeById(replicatingNodeId);
            // bump up the counter if we encounter a replica in the given zone
            if(replicatingNode.getZoneId() == zoneId) {
                zoneNAry++;
            }
            // when the counter matches up with the replicaNumber we need, we
            // are done.
            if(zoneNAry == zoneNary) {
                return replicatingNode.getId();
            }
        }
        if(zoneNAry == 0) {
            throw new VoldemortException("Could not find any replicas for the partition "
                                         + partitionId + " in given zone " + zoneId);
View Full Code Here

    public void testClusterMapperValues() {
        ClusterMapper mapper = new ClusterMapper();
        Cluster cluster = mapper.readCluster(new StringReader(VoldemortTestConstants.getOneNodeClusterXml()));
        assertEquals(cluster.getNumberOfNodes(), 1);
        assertEquals(cluster.getName(), "mycluster");
        Node node = cluster.getNodes().iterator().next();
        assertNotNull(node);
        assertEquals(node.getId(), 0);
        List<Integer> tags = node.getPartitionIds();
        assertTrue("Tag not found.", tags.contains(0));
        assertTrue("Tag not found.", tags.contains(1));

    }
View Full Code Here

        cluster1 = ServerTestUtils.getLocalCluster(4, 10, 2);

        List<Node> newNodes = Lists.newArrayList();
        for(Node node: cluster1.getNodes()) {
            newNodes.add(new Node(node.getId(),
                                  node.getHost(),
                                  node.getHttpPort(),
                                  node.getSocketPort(),
                                  node.getAdminPort(),
                                  0,
View Full Code Here

        // TODO move as many messages to use this helper.
        private void sendAdminRequest(VAdminProto.VoldemortAdminRequest adminRequest,
                                      int destinationNodeId) {
            // TODO probably need a helper to do all this, at some point.. all
            // of this file has repeated code
            Node node = AdminClient.this.getAdminClientCluster().getNodeById(destinationNodeId);
            SocketDestination destination = new SocketDestination(node.getHost(),
                                                                  node.getAdminPort(),
                                                                  RequestFormatType.ADMIN_PROTOCOL_BUFFERS);
            SocketAndStreams sands = socketPool.checkout(destination);

            try {
                DataOutputStream outputStream = sands.getOutputStream();
View Full Code Here

        ByteArray slopKey = slop.makeKey();
        Versioned<byte[]> slopValue = new Versioned<byte[]>(slopSerializer.toBytes(slop),
                                                            value.getVersion());

        Node failedNode = adminClient.getAdminClientCluster().getNodeById(failedNodeId);
        HandoffToAnyStrategy slopRoutingStrategy = new HandoffToAnyStrategy(adminClient.getAdminClientCluster(),
                                                                            true,
                                                                            failedNode.getZoneId());
        // node Id which will recieve the slop
        int slopDestination = slopRoutingStrategy.routeHint(failedNode).get(0).getId();

        VAdminProto.PartitionEntry partitionEntry = VAdminProto.PartitionEntry.newBuilder()
                                                                              .setKey(ProtoUtils.encodeBytes(slopKey))
View Full Code Here

    @Override
    public void execute(Pipeline pipeline) {
        for(Map.Entry<Node, Slop> slopToBeSent: slopsToBeSent.entrySet()) {
            Slop slop = slopToBeSent.getValue();
            Node failedNode = slopToBeSent.getKey();
            if(logger.isTraceEnabled())
                logger.trace("Performing hinted handoff for node " + failedNode + ", store "
                             + pipelineData.getStoreName() + "key " + key + ", version" + version);

            hintedHandoff.sendHintParallel(failedNode, version, slop);
View Full Code Here

TOP

Related Classes of voldemort.cluster.Node

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.