Search in sources :

Example 6 with MessageGroupRetrievalResponseEntry

use of com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry in project SilverKing by Morgan-Stanley.

the class SegmentedRetrievalValue method getResult.

private OpResult getResult(DHTKey key) {
    MessageGroupRetrievalResponseEntry response;
    response = results.get(key);
    // System.out.printf("getResult(%s):\t%s\t%s\n", key, response, response == null ? OpResult.INCOMPLETE : response.getOpResult());
    return response == null ? OpResult.INCOMPLETE : response.getOpResult();
}
Also used : MessageGroupRetrievalResponseEntry(com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry)

Example 7 with MessageGroupRetrievalResponseEntry

use of com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry in project SilverKing by Morgan-Stanley.

the class SegmentedValue method resultReceived.

@Override
public void resultReceived(DHTKey key, R result) {
    R prevResult;
    if (debug) {
        if (result instanceof MessageGroupRetrievalResponseEntry) {
            MessageGroupRetrievalResponseEntry _result;
            _result = (MessageGroupRetrievalResponseEntry) result;
            System.out.printf("SegmentedValue.resultReceived key: %s\tresult: %s\tvalue %s\n", key, result, ((MessageGroupRetrievalResponseEntry) result).getValue());
        } else {
            System.out.printf("SegmentedValue.resultReceived key: %s\tresult: %s\tresultsReceived %d\n", key, result, resultsReceived.get());
        }
    }
    prevResult = results.put(key, result);
    if (prevResult != null) {
    // FIXME
    } else {
        resultsReceived.incrementAndGet();
    }
    if (resultsReceived.get() >= keys.length + trackRelayKeyCompletion) {
        // all keys + relay key
        checkForCompletion();
    }
}
Also used : MessageGroupRetrievalResponseEntry(com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry)

Example 8 with MessageGroupRetrievalResponseEntry

use of com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry in project SilverKing by Morgan-Stanley.

the class ConvergenceController2 method incomingSyncRetrievalResponse.

// ////////////////////////////////////////////////////////////////////
// Handle incoming convergence data
public void incomingSyncRetrievalResponse(MessageGroup message) {
    List<StorageValueAndParameters> svpList;
    SyncRetrievalRequest srr;
    srr = outstandingSyncRetrievalRequests.get(message.getUUID());
    outstandingMessages.decrementAndGet();
    if (outstandingMessages.get() < 0) {
        outstandingMessages.set(0);
    }
    if (debug) {
        Log.warningAsyncf("incomingSyncRetrievalResponse");
    }
    svpList = new ArrayList<>();
    for (MessageGroupRetrievalResponseEntry entry : message.getRetrievalResponseValueKeyIterator()) {
        StorageValueAndParameters svp;
        if (srr != null) {
            srr.outstandingKeys.remove(entry);
        }
        svp = StorageValueAndParameters.createSVP(entry);
        if (svp != null) {
            svpList.add(svp);
        }
    }
    if (!svpList.isEmpty()) {
        // FUTURE - support migration of user data
        nsStore.put(svpList, emptyUserData, this);
    }
    if (srr != null && srr.outstandingKeys.isEmpty()) {
        outstandingSyncRetrievalRequests.remove(message.getUUID());
    }
    checkQueuedChecksumTreeRequests();
    checkMGQueue();
    checkForCompletion();
}
Also used : StorageValueAndParameters(com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters) MessageGroupRetrievalResponseEntry(com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry)

Example 9 with MessageGroupRetrievalResponseEntry

use of com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry in project SilverKing by Morgan-Stanley.

the class ActiveRegionSync method incomingSyncRetrievalResponse.

// //////////////////////////////////////////////////////////////////
public void incomingSyncRetrievalResponse(MessageGroup message) {
    List<StorageValueAndParameters> svpList;
    SyncRetrievalRequest srr;
    lastUpdateMillis = SystemTimeSource.instance.absTimeMillis();
    srr = outstandingSyncRetrievalRequests.get(message.getUUID());
    if (debug) {
        Log.warning("incomingSyncRetrievalResponse");
    }
    svpList = new ArrayList<>();
    for (MessageGroupRetrievalResponseEntry entry : message.getRetrievalResponseValueKeyIterator()) {
        StorageValueAndParameters svp;
        if (debug) {
            Log.warningf("%s", entry.toString());
        }
        if (srr != null) {
            srr.outstandingKeys.remove(entry);
        }
        svp = StorageValueAndParameters.createSVP(entry);
        if (svp != null) {
            svpList.add(svp);
        }
    }
    if (!svpList.isEmpty()) {
        if (nsStore != null) {
            // FUTURE - support migration of user data
            nsStore.put(svpList, emptyUserData, this);
        }
    }
    if (srr != null && srr.outstandingKeys.isEmpty()) {
        Log.warningAsyncf("ars %s complete-srr %s", uuid, srr.getUUID());
        outstandingSyncRetrievalRequests.remove(srr.getUUID());
        inprocessSyncRetrievalRequests.remove(srr.getUUID());
    }
    // checkMGQueue();
    checkForCompletion();
}
Also used : StorageValueAndParameters(com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters) MessageGroupRetrievalResponseEntry(com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry)

Example 10 with MessageGroupRetrievalResponseEntry

use of com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry in project SilverKing by Morgan-Stanley.

the class ActiveProxyRetrieval method handleRetrievalResponse.

// ///////////////////
// Handle responses
public OpResult handleRetrievalResponse(MessageGroup message, MessageGroupConnectionProxy connection) {
    RetrievalCommunicator rComm;
    Map<IPAndPort, List<DHTKey>> destEntryMap;
    OpResult opResult;
    rComm = new RetrievalCommunicator();
    if (debug) {
        System.out.println("handleRetrievalResponse");
    }
    for (MessageGroupRetrievalResponseEntry entry : message.getRetrievalResponseValueKeyIterator()) {
        IPAndPort replica;
        replica = new IPAndPort(message.getOriginator(), DHTNode.getServerPort());
        if (debug) {
            System.out.println("replica: " + replica);
        }
        retrievalOperation.update(entry, replica, new RetrievalResult(entry, entry.getOpResult(), entry.getValue()), rComm);
    }
    sendResults(rComm);
    destEntryMap = rComm.takeReplicaMessageLists();
    if (destEntryMap != null) {
        forwardGroupedEntries(destEntryMap, optionsByteBuffer, new RetrievalForwardCreator(), rComm);
    }
    if (retrievalOptions.getRetrievalOptions().getUpdateSecondariesOnMiss()) {
        if (debug) {
            Log.warning("ActiveProxyRetrieval calling sendSecondaryReplicasUpdates");
        }
        sendSecondaryReplicasUpdates(rComm);
    } else {
        if (debug) {
            Log.warning("ActiveProxyRetrieval *no* sendSecondaryReplicasUpdates");
        }
    }
    return retrievalOperation.getOpResult();
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) OpResult(com.ms.silverking.cloud.dht.common.OpResult) RetrievalCommunicator(com.ms.silverking.cloud.dht.daemon.storage.protocol.RetrievalCommunicator) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) MessageGroupRetrievalResponseEntry(com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry) RetrievalResult(com.ms.silverking.cloud.dht.daemon.storage.protocol.RetrievalResult)

Aggregations

MessageGroupRetrievalResponseEntry (com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry)10 DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)4 List (java.util.List)3 OpResult (com.ms.silverking.cloud.dht.common.OpResult)2 StorageValueAndParameters (com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters)2 ProtoRetrievalMessageGroup (com.ms.silverking.cloud.dht.net.ProtoRetrievalMessageGroup)2 WeakReference (java.lang.ref.WeakReference)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 ImmutableList (com.google.common.collect.ImmutableList)1 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)1 InternalRetrievalOptions (com.ms.silverking.cloud.dht.common.InternalRetrievalOptions)1 RetrievalCommunicator (com.ms.silverking.cloud.dht.daemon.storage.protocol.RetrievalCommunicator)1 RetrievalResult (com.ms.silverking.cloud.dht.daemon.storage.protocol.RetrievalResult)1 MessageGroup (com.ms.silverking.cloud.dht.net.MessageGroup)1 ProtoMessageGroup (com.ms.silverking.cloud.dht.net.ProtoMessageGroup)1 IPAndPort (com.ms.silverking.net.IPAndPort)1