Search in sources :

Example 6 with MessageGroupKeyOrdinalEntry

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

the class ActiveProxyPut method handlePutResponse.

// ///////////////////
// handle responses
/**
 * Process a put response according to the protocol in use by this StorageOperation.
 *
 * @param message
 * @param _connection
 * @return
 */
OpResult handlePutResponse(MessageGroup message, MessageGroupConnectionProxy _connection) {
    PutCommunicator pComm;
    byte storageState;
    pComm = new PutCommunicator(this);
    if (debug) {
        System.out.println("handlePutResponse");
    }
    storageState = ProtoPutResponseMessageGroup.getStorageState(message);
    for (MessageGroupKeyOrdinalEntry entry : message.getKeyOrdinalIterator()) {
        IPAndPort replica;
        replica = new IPAndPort(message.getOriginator(), DHTNode.getServerPort());
        if (debug) {
            System.out.println("replica: " + replica);
        }
        storageOperation.update(entry.getKey(), replica, storageState, EnumValues.opResult[entry.getOrdinal()], pComm);
    }
    // forward state updates
    Map<IPAndPort, List<MessageGroupKeyOrdinalEntry>> rumLists;
    rumLists = pComm.takeReplicaUpdateMessageLists();
    if (rumLists.size() > 0) {
        forwardGroupedEntries(rumLists, optionsByteBuffer, new PutUpdateForwardCreator(storageOperation.nextStorageState(storageState)), pComm);
    }
    // send responses for completions
    messageModule.sendPutResults(message, version, connection, pComm.takeResults(), storageState, message.getDeadlineRelativeMillis());
    return storageOperation.getOpResult();
}
Also used : MessageGroupKeyOrdinalEntry(com.ms.silverking.cloud.dht.net.MessageGroupKeyOrdinalEntry) IPAndPort(com.ms.silverking.net.IPAndPort) PutCommunicator(com.ms.silverking.cloud.dht.daemon.storage.protocol.PutCommunicator) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

MessageGroupKeyOrdinalEntry (com.ms.silverking.cloud.dht.net.MessageGroupKeyOrdinalEntry)6 DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)4 OpResult (com.ms.silverking.cloud.dht.common.OpResult)3 PutCommunicator (com.ms.silverking.cloud.dht.daemon.storage.protocol.PutCommunicator)2 IPAndPort (com.ms.silverking.net.IPAndPort)2 SimpleKey (com.ms.silverking.cloud.dht.common.SimpleKey)1 Waiter (com.ms.silverking.cloud.dht.daemon.Waiter)1 StorageValueAndParameters (com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters)1 PutOperationContainer (com.ms.silverking.cloud.dht.daemon.storage.protocol.PutOperationContainer)1 MessageGroupPutEntry (com.ms.silverking.cloud.dht.net.MessageGroupPutEntry)1 WeakReference (java.lang.ref.WeakReference)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1