Search in sources :

Example 1 with PutResult

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

the class MessageModule method handlePutUpdate.

/**
 * Process a put update.
 * @param message
 * @param connection
 */
private void handlePutUpdate(MessageGroup message, MessageGroupConnectionProxy connection) {
    List<PutResult> results;
    long version;
    byte storageState;
    version = ProtoPutUpdateMessageGroup.getPutVersion(message);
    storageState = ProtoPutUpdateMessageGroup.getStorageState(message);
    if (debug) {
        System.out.println("handlePutUpdate storageState: " + storageState);
    }
    results = new ArrayList<>();
    for (MessageGroupKeyEntry entry : message.getKeyIterator()) {
        OpResult opResult;
        opResult = storage.putUpdate(message.getContext(), entry, version, storageState);
        results.add(new PutResult(entry, opResult));
    }
    sendPutResults(message, version, connection, results, storageState, message.getDeadlineRelativeMillis());
}
Also used : MessageGroupKeyEntry(com.ms.silverking.cloud.dht.net.MessageGroupKeyEntry) OpResult(com.ms.silverking.cloud.dht.common.OpResult) PutResult(com.ms.silverking.cloud.dht.net.PutResult)

Example 2 with PutResult

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

the class MessageModule method sendPutResults.

// //////////////////////////
// FUTURE make ActiveProxyPut use this after we have it working for PutUpdate
// and after the below FUTUREs have been resolved
protected void sendPutResults(MessageGroup message, long version, MessageGroupConnectionProxy connection, List<PutResult> results, byte storageState, int deadlineRelativeMillis) {
    ProtoPutResponseMessageGroup response;
    if (results.size() > 0) {
        response = new ProtoPutResponseMessageGroup(message.getUUID(), message.getContext(), // FUTURE - does ProtoPutResponseMessageGroup really need version when we're using the uuid now?
        version, results.size(), mgBase.getMyID(), storageState, // FUTURE - allow constructor without this?
        deadlineRelativeMillis);
        if (debug) {
            System.out.println("results.size " + results.size());
        }
        for (PutResult result : results) {
            if (debug) {
                System.out.println(result);
            }
            response.addResult(result.getKey(), result.getResult());
        }
        try {
            MessageGroup mg;
            mg = response.toMessageGroup();
            if (Log.levelMet(Level.FINE)) {
                Log.warning("sendResults: " + connection.getConnectionID());
                mg.displayForDebug(true);
            }
            connection.sendAsynchronous(mg, mg.getDeadlineAbsMillis(getAbsMillisTimeSource()));
        } catch (IOException ioe) {
            Log.logErrorWarning(ioe);
        }
    }
}
Also used : ProtoPutResponseMessageGroup(com.ms.silverking.cloud.dht.net.ProtoPutResponseMessageGroup) ProtoPingMessageGroup(com.ms.silverking.cloud.dht.net.ProtoPingMessageGroup) ProtoChecksumTreeRequestMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup) MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) ProtoSnapshotMessageGroup(com.ms.silverking.cloud.dht.net.ProtoSnapshotMessageGroup) ProtoNopMessageGroup(com.ms.silverking.cloud.dht.net.ProtoNopMessageGroup) ProtoRetrievalMessageGroup(com.ms.silverking.cloud.dht.net.ProtoRetrievalMessageGroup) ProtoPutResponseMessageGroup(com.ms.silverking.cloud.dht.net.ProtoPutResponseMessageGroup) ProtoPutUpdateMessageGroup(com.ms.silverking.cloud.dht.net.ProtoPutUpdateMessageGroup) ProtoPingAckMessageGroup(com.ms.silverking.cloud.dht.net.ProtoPingAckMessageGroup) ProtoVersionedBasicOpMessageGroup(com.ms.silverking.cloud.dht.net.ProtoVersionedBasicOpMessageGroup) ProtoOpResponseMessageGroup(com.ms.silverking.cloud.dht.net.ProtoOpResponseMessageGroup) IOException(java.io.IOException) PutResult(com.ms.silverking.cloud.dht.net.PutResult)

Aggregations

PutResult (com.ms.silverking.cloud.dht.net.PutResult)2 OpResult (com.ms.silverking.cloud.dht.common.OpResult)1 MessageGroup (com.ms.silverking.cloud.dht.net.MessageGroup)1 MessageGroupKeyEntry (com.ms.silverking.cloud.dht.net.MessageGroupKeyEntry)1 ProtoChecksumTreeRequestMessageGroup (com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup)1 ProtoNopMessageGroup (com.ms.silverking.cloud.dht.net.ProtoNopMessageGroup)1 ProtoOpResponseMessageGroup (com.ms.silverking.cloud.dht.net.ProtoOpResponseMessageGroup)1 ProtoPingAckMessageGroup (com.ms.silverking.cloud.dht.net.ProtoPingAckMessageGroup)1 ProtoPingMessageGroup (com.ms.silverking.cloud.dht.net.ProtoPingMessageGroup)1 ProtoPutResponseMessageGroup (com.ms.silverking.cloud.dht.net.ProtoPutResponseMessageGroup)1 ProtoPutUpdateMessageGroup (com.ms.silverking.cloud.dht.net.ProtoPutUpdateMessageGroup)1 ProtoRetrievalMessageGroup (com.ms.silverking.cloud.dht.net.ProtoRetrievalMessageGroup)1 ProtoSnapshotMessageGroup (com.ms.silverking.cloud.dht.net.ProtoSnapshotMessageGroup)1 ProtoVersionedBasicOpMessageGroup (com.ms.silverking.cloud.dht.net.ProtoVersionedBasicOpMessageGroup)1 IOException (java.io.IOException)1