Search in sources :

Example 11 with MessageGroup

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

the class ConvergenceController2 method sendSyncRetrievalRequest.

private void sendSyncRetrievalRequest(SyncRetrievalRequest srr) {
    MessageGroup mg;
    RetrievalOptions retrievalOptions;
    retrievalOptions = OptionsHelper.newRetrievalOptions(RetrievalType.VALUE_AND_META_DATA, WaitMode.GET, checksumVersionConstraint(srr.dataVersion));
    mg = new ProtoRetrievalMessageGroup(srr.uuid, ns, new InternalRetrievalOptions(retrievalOptions), mgBase.getMyID(), srr.outstandingKeys, convergenceRelativeDeadlineMillis).toMessageGroup();
    outgoingMessages.add(new OutgoingMessage(mg, new IPAndPort(srr.connection.getRemoteSocketAddress())));
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) InternalRetrievalOptions(com.ms.silverking.cloud.dht.common.InternalRetrievalOptions) RetrievalOptions(com.ms.silverking.cloud.dht.RetrievalOptions) ProtoChecksumTreeRequestMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup) MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) ProtoRetrievalMessageGroup(com.ms.silverking.cloud.dht.net.ProtoRetrievalMessageGroup) ProtoRetrievalMessageGroup(com.ms.silverking.cloud.dht.net.ProtoRetrievalMessageGroup) InternalRetrievalOptions(com.ms.silverking.cloud.dht.common.InternalRetrievalOptions)

Example 12 with MessageGroup

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

the class ActiveProxyRetrieval method sendResults.

/**
 * Send responses for all locally completed operations
 * @param retrievalOperation
 */
protected void sendResults(List<RetrievalResult> results) {
    if (debug) {
        System.out.printf("ActiveProxyRetrieval.sendresults() %d\n", results.size());
    }
    /*
        debugString.append("***\n");
        for (RetrievalResult result : results) {
            debugString.append(result.getValue() +"\n");
        }
        debugString.append("+++\n");
        */
    try {
        if (results.size() > 0) {
            ProtoValueMessageGroup pmg;
            byte[] _originator;
            List<List<RetrievalResult>> resultGroups;
            _originator = ConvergenceController2.isChecksumVersionConstraint(retrievalOptions.getVersionConstraint()) ? originator : messageModule.getMessageGroupBase().getMyID();
            resultGroups = createResultGroups(results);
            for (List<RetrievalResult> resultGroup : resultGroups) {
                MessageGroup messageGroup;
                int groupLength;
                groupLength = RetrievalResult.totalResultLength(resultGroup);
                pmg = new ProtoValueMessageGroup(uuid, namespace, results.size(), groupLength, _originator, messageModule.getAbsMillisTimeSource().relMillisRemaining(absDeadlineMillis));
                for (RetrievalResult result : resultGroup) {
                    DHTKey key;
                    ByteBuffer value;
                    if (debug) {
                        System.out.println(result);
                    }
                    key = result.getKey();
                    if (retrievalOptions.getWaitMode() != WaitMode.WAIT_FOR || result.getValue() == null) {
                        value = result.getValue();
                    } else {
                        value = result.getValue().duplicate();
                    }
                    if (value == null) {
                        pmg.addErrorCode(key, result.getResult());
                    } else {
                        pmg.addValue(key, value, result.getResultLength(), true);
                    }
                }
                messageGroup = pmg.toMessageGroup();
                connection.sendAsynchronous(messageGroup, messageGroup.getDeadlineAbsMillis(messageModule.getAbsMillisTimeSource()));
            }
        }
    /*
        } catch (RuntimeException re) {
            // for debugging only
            re.printStackTrace();
            System.out.println("results.size() "+ results.size());
            for (RetrievalResult result : results) {
                System.out.println(result);
            }
            //rComm.displayDebug();
            System.exit(-1);
            */
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}
Also used : ProtoKeyedMessageGroup(com.ms.silverking.cloud.dht.net.ProtoKeyedMessageGroup) MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) ProtoValueMessageGroup(com.ms.silverking.cloud.dht.net.ProtoValueMessageGroup) ProtoRetrievalMessageGroup(com.ms.silverking.cloud.dht.net.ProtoRetrievalMessageGroup) ProtoMessageGroup(com.ms.silverking.cloud.dht.net.ProtoMessageGroup) DHTKey(com.ms.silverking.cloud.dht.common.DHTKey) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) RetrievalResult(com.ms.silverking.cloud.dht.daemon.storage.protocol.RetrievalResult) IOException(java.io.IOException) ByteBuffer(java.nio.ByteBuffer) ProtoValueMessageGroup(com.ms.silverking.cloud.dht.net.ProtoValueMessageGroup)

Example 13 with MessageGroup

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

the class MessageGroupConnectionProxyLocal method sendAsynchronous.

@Override
public void sendAsynchronous(Object data, long deadline) throws IOException {
    MessageAndConnection messageAndConnection;
    // Log.warning("MessageGroupConnectionProxyLocal sending");
    messageAndConnection = new MessageAndConnection((MessageGroup) data, this);
    worker.addWork(messageAndConnection);
}
Also used : MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) MessageAndConnection(com.ms.silverking.cloud.dht.daemon.MessageModule.MessageAndConnection)

Example 14 with MessageGroup

use of com.ms.silverking.cloud.dht.net.MessageGroup 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)

Example 15 with MessageGroup

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

the class ActiveProxyOperation method forwardGroup.

/**
 * Forward to a single replica
 * @param replica
 * @param destEntries
 * @param optionsByteBuffer
 */
private <L extends DHTKey> void forwardGroup(IPAndPort replica, List<L> destEntries, ByteBuffer optionsByteBuffer, ForwardCreator<L> forwardCreator, OpCommunicator<K, R> comm) {
    if (forwardingMode.forwards()) {
        MessageGroup mg;
        assert replica != null;
        mg = forwardCreator.createForward(destEntries, optionsByteBuffer);
        if (debug) {
            System.out.println("Forwarding: " + new SimpleValueCreator(originator) + ":" + replica + " : " + mg + ":" + mg.getForwardingMode());
            mg.displayForDebug();
        }
        messageModule.getMessageGroupBase().send(mg, replica);
    } else {
        localOp(destEntries, comm);
    }
}
Also used : SimpleValueCreator(com.ms.silverking.cloud.dht.common.SimpleValueCreator) MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) ProtoPutMessageGroup(com.ms.silverking.cloud.dht.net.ProtoPutMessageGroup)

Aggregations

MessageGroup (com.ms.silverking.cloud.dht.net.MessageGroup)16 ProtoChecksumTreeRequestMessageGroup (com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup)7 ProtoRetrievalMessageGroup (com.ms.silverking.cloud.dht.net.ProtoRetrievalMessageGroup)7 IOException (java.io.IOException)4 ProtoMessageGroup (com.ms.silverking.cloud.dht.net.ProtoMessageGroup)3 RetrievalOptions (com.ms.silverking.cloud.dht.RetrievalOptions)2 DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)2 InternalRetrievalOptions (com.ms.silverking.cloud.dht.common.InternalRetrievalOptions)2 ProtoChecksumTreeMessageGroup (com.ms.silverking.cloud.dht.net.ProtoChecksumTreeMessageGroup)2 UUIDBase (com.ms.silverking.id.UUIDBase)2 ImmutableList (com.google.common.collect.ImmutableList)1 SimpleValueCreator (com.ms.silverking.cloud.dht.common.SimpleValueCreator)1 MessageAndConnection (com.ms.silverking.cloud.dht.daemon.MessageModule.MessageAndConnection)1 RetrievalResult (com.ms.silverking.cloud.dht.daemon.storage.protocol.RetrievalResult)1 MessageGroupRetrievalResponseEntry (com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry)1 ProtoKeyedMessageGroup (com.ms.silverking.cloud.dht.net.ProtoKeyedMessageGroup)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