Search in sources :

Example 6 with MessageGroup

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

the class MessageGroupTest method receive.

@Override
public void receive(MessageGroup message, MessageGroupConnection connection) {
    Log.fine("received: ", message);
    switch(mode) {
        case client:
            semaphore.release();
            messagesReceived.incrementAndGet();
            break;
        case server:
            try {
                InetSocketAddress other;
                MessageGroup msg;
                other = new InetSocketAddress(connection.getRemoteSocketAddress().getHostName(), testClientPort);
                msg = createMessage(NumConversion.intToBytes(testClientPort));
                paServer.send(other, msg, false, Long.MAX_VALUE);
            // connection.sendAsynchronous(bufferedData, Long.MAX_VALUE);
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
            break;
        default:
            throw new RuntimeException("panic");
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) IOException(java.io.IOException)

Example 7 with MessageGroup

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

the class OpSender method createMessages.

/**
 * Given a group of same-typed operations, create and send messages.
 * @param asyncOpImpls
 * @param startIndex
 * @param endIndex
 */
private void createMessages(AsyncOperationImpl[] asyncOpImpls, int startIndex, int endIndex) {
    ProtoMessageGroup protoMG;
    List<MessageGroup> messageGroups;
    MessageEstimate estimate;
    estimate = estimateMessage(asyncOpImpls, startIndex, endIndex);
    protoMG = asyncOpImpls[startIndex].createProtoMG(estimate);
    if (debug) {
        System.out.printf("asyncOpImpls.length %d startIndex %d endIndex %d\n", asyncOpImpls.length, startIndex, endIndex);
    }
    messageGroups = new ArrayList<>();
    // then create a new protoMG and add the old to the messageGroups list.
    for (int i = startIndex; i <= endIndex; i++) {
        if (debug) {
            System.out.printf("Calling create with %s\tfor%s\n", protoMG.getUUID(), asyncOpImpls[i].objectToString());
        }
        protoMG = asyncOpImpls[i].createMessagesForIncomplete(protoMG, messageGroups, estimate);
    }
    // Add the final protoMG to the list if it is non-empty
    protoMG.addToMessageGroupList(messageGroups);
    // FUTURE - consider sending sooner, in creation loop
    for (MessageGroup messageGroup : messageGroups) {
        if (debug) {
            System.out.println("OpSender sending:");
            System.out.println(messageGroup);
            messageGroup.displayForDebug();
        }
        send(messageGroup);
    }
}
Also used : ProtoMessageGroup(com.ms.silverking.cloud.dht.net.ProtoMessageGroup) MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) ProtoMessageGroup(com.ms.silverking.cloud.dht.net.ProtoMessageGroup)

Example 8 with MessageGroup

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

the class DHTRingMaster method requestChecksumTree.

public void requestChecksumTree(Triple<Long, Long, Long> nsAndRegion, ConvergencePoint curCP, ConvergencePoint targetCP, IPAndPort owner) {
    MessageGroup mg;
    UUIDBase uuid;
    uuid = UUIDBase.random();
    mg = new ProtoChecksumTreeRequestMessageGroup(uuid, nsAndRegion.getV1(), targetCP, curCP, mgBase.getMyID(), new RingRegion(nsAndRegion.getV2(), nsAndRegion.getV3()), mgBase._getIPAndPort(), false).toMessageGroup();
    mgBase.send(mg, owner);
}
Also used : RingRegion(com.ms.silverking.cloud.ring.RingRegion) ProtoChecksumTreeRequestMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup) MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) ProtoChecksumTreeMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeMessageGroup) UUIDBase(com.ms.silverking.id.UUIDBase) ProtoChecksumTreeRequestMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup)

Example 9 with MessageGroup

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

the class CentralConvergenceController method sendSetState.

private UUIDBase sendSetState(UUIDBase uuid, IPAndPort replica, RingState ringState) {
    MessageGroup mg;
    mg = new ProtoSetConvergenceStateMessageGroup(uuid, mgBase.getMyID(), setStateDeadlineRelativeMillis, curCP, targetCP, ringState).toMessageGroup();
    mgBase.send(mg, replica);
    return uuid;
}
Also used : ProtoSetConvergenceStateMessageGroup(com.ms.silverking.cloud.dht.net.ProtoSetConvergenceStateMessageGroup) MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) ProtoSetConvergenceStateMessageGroup(com.ms.silverking.cloud.dht.net.ProtoSetConvergenceStateMessageGroup)

Example 10 with MessageGroup

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

the class ConvergenceController2 method sendChecksumTreeRequest.

private void sendChecksumTreeRequest(ChecksumTreeRequest ctr) {
    MessageGroup mg;
    UUIDBase uuid;
    uuid = UUIDBase.random();
    outstandingChecksumTreeRequests.put(uuid, ctr);
    convergenceControllers.put(uuid, this);
    mg = new ProtoChecksumTreeRequestMessageGroup(uuid, ns, ctr.getTargetCP(), ctr.getCurCP(), mgBase.getMyID(), ctr.getRegion(), false).toMessageGroup();
    if (verbose || debug) {
        Log.warningAsyncf("%x requestChecksumTree: %s\t%s\t%s\t%s", ns, ctr.getReplica(), ctr.getRegion(), ctr.getTargetCP(), ctr.getCurCP());
    }
    mgBase.send(mg, ctr.getReplica());
    ctr.setSent();
}
Also used : ProtoChecksumTreeRequestMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup) MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) ProtoRetrievalMessageGroup(com.ms.silverking.cloud.dht.net.ProtoRetrievalMessageGroup) UUIDBase(com.ms.silverking.id.UUIDBase) ProtoChecksumTreeRequestMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup)

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