Search in sources :

Example 1 with PutCommunicator

use of com.ms.silverking.cloud.dht.daemon.storage.protocol.PutCommunicator in project SilverKing by Morgan-Stanley.

the class ActiveProxyPut method startOperation.

void startOperation() {
    PutCommunicator pComm;
    if (debug) {
        System.out.println(this + " " + forwardingMode + " " + storageOperation);
    }
    pComm = new PutCommunicator(this);
    if (forwardingMode.forwards()) {
        messageModule.addActivePut(uuid, this);
    }
    super.startOperation(pComm, message.getPutValueKeyIterator(ProtoPutMessageGroup.getChecksumType(message)), new PutForwardCreator());
    // super.startOperation() will forward initial puts. Now we need to forward any
    // state updates created due to local processing.
    forwardGroupedEntries(pComm.takeReplicaUpdateMessageLists(), optionsByteBuffer, new PutUpdateForwardCreator(storageOperation.nextStorageState(storageOperation.initialStorageState())), pComm);
    // free payload for GC
    message = null;
}
Also used : PutCommunicator(com.ms.silverking.cloud.dht.daemon.storage.protocol.PutCommunicator)

Example 2 with PutCommunicator

use of com.ms.silverking.cloud.dht.daemon.storage.protocol.PutCommunicator in project SilverKing by Morgan-Stanley.

the class ActiveProxyPut method localOp.

protected void localOp(List<? extends DHTKey> _entries, OpCommunicator<MessageGroupKeyEntry, PutResult> comm) {
    boolean useUpdate;
    PutCommunicator pComm;
    pComm = (PutCommunicator) comm;
    useUpdate = _entries.size() > 0 && (_entries.get(0) instanceof MessageGroupKeyOrdinalEntry);
    if (!useUpdate) {
        List<StorageValueAndParameters> values;
        long creationTime;
        creationTime = SystemTimeUtil.systemTimeSource.absTimeNanos();
        values = new ArrayList<>(_entries.size());
        for (DHTKey _entry : _entries) {
            values.add(new StorageValueAndParameters((MessageGroupPutEntry) _entry, (PutOperationContainer) this, creationTime));
            if (debug) {
                System.out.printf("localOp: %s\n", _entry);
            }
        // Log.fine(entry);
        }
        getStorage().put(getContext(), values, getUserData(), pComm);
        if (forwardingMode.forwards()) {
            for (DHTKey _entry : _entries) {
                storageOperation.localUpdate(_entry, StorageProtocolUtil.initialStorageStateOrdinal, OpResult.SUCCEEDED, pComm);
            }
        }
    } else {
        localOp_putupdate(_entries, pComm);
    }
}
Also used : MessageGroupKeyOrdinalEntry(com.ms.silverking.cloud.dht.net.MessageGroupKeyOrdinalEntry) PutCommunicator(com.ms.silverking.cloud.dht.daemon.storage.protocol.PutCommunicator) DHTKey(com.ms.silverking.cloud.dht.common.DHTKey) PutOperationContainer(com.ms.silverking.cloud.dht.daemon.storage.protocol.PutOperationContainer) StorageValueAndParameters(com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters) MessageGroupPutEntry(com.ms.silverking.cloud.dht.net.MessageGroupPutEntry)

Example 3 with PutCommunicator

use of com.ms.silverking.cloud.dht.daemon.storage.protocol.PutCommunicator 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

PutCommunicator (com.ms.silverking.cloud.dht.daemon.storage.protocol.PutCommunicator)3 MessageGroupKeyOrdinalEntry (com.ms.silverking.cloud.dht.net.MessageGroupKeyOrdinalEntry)2 DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)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 IPAndPort (com.ms.silverking.net.IPAndPort)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1