Search in sources :

Example 1 with MessageGroup

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

the class AsyncRetrievalOperationImpl method retrieveSegments.

private void retrieveSegments(DHTKey relayKey, DHTKey[] segmentKeys, MetaData metaData) {
    List<MessageGroup> messageGroups;
    SegmentedRetrievalValue<K, V> segmentedRetrievalValue;
    if (segmentedRetrievalValues == null) {
        segmentedRetrievalValues = new ArrayList<>(segmentKeys.length);
    }
    segmentedRetrievalValue = new SegmentedRetrievalValue<>(segmentKeys, relayKey, this, nspoImpl.getValueDeserializer(), metaData);
    messageGroups = new ArrayList<>();
    for (DHTKey segmentKey : segmentKeys) {
        ProtoRetrievalMessageGroup protoRetrievalMG;
        boolean listenerInserted;
        List<WeakReference<ActiveKeyedOperationResultListener<MessageGroupRetrievalResponseEntry>>> listeners;
        protoRetrievalMG = createProtoRetrievalMG(new KeyedMessageEstimate(1), false);
        listenerInserted = activeRetrievalListeners.addListener(protoRetrievalMG.getUUID(), segmentKey, segmentedRetrievalValue);
        if (!listenerInserted) {
            throw new RuntimeException("Duplicate listener insertion");
        }
        protoRetrievalMG.addKey(segmentKey);
        protoRetrievalMG.addToMessageGroupList(messageGroups);
        // hold a reference to the uuid to prevent GC
        opUUIDs.add((OperationUUID) protoRetrievalMG.getUUID());
        segmentedRetrievalValues.add(segmentedRetrievalValue);
    }
    for (MessageGroup messageGroup : messageGroups) {
        retrievalSender.send(messageGroup);
    }
}
Also used : MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) ProtoRetrievalMessageGroup(com.ms.silverking.cloud.dht.net.ProtoRetrievalMessageGroup) ProtoMessageGroup(com.ms.silverking.cloud.dht.net.ProtoMessageGroup) DHTKey(com.ms.silverking.cloud.dht.common.DHTKey) ProtoRetrievalMessageGroup(com.ms.silverking.cloud.dht.net.ProtoRetrievalMessageGroup) MessageGroupRetrievalResponseEntry(com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry) WeakReference(java.lang.ref.WeakReference)

Example 2 with MessageGroup

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

the class ActiveRegionSync method sendSyncRetrievalRequest.

private void sendSyncRetrievalRequest(SyncRetrievalRequest srr) {
    MessageGroup mg;
    RetrievalOptions retrievalOptions;
    Log.warningAsyncf("ars %s send srr %s", uuid, srr.getUUID());
    inprocessSyncRetrievalRequests.add(srr.getUUID());
    retrievalOptions = OptionsHelper.newRetrievalOptions(RetrievalType.VALUE_AND_META_DATA, WaitMode.GET, checksumVersionConstraint(srr.dataVersion));
    mg = new ProtoRetrievalMessageGroup(srr.uuid, namespace, new InternalRetrievalOptions(retrievalOptions), mgBase.getMyID(), srr.outstandingKeys, convergenceRelativeDeadlineMillis).toMessageGroup();
    // outgoingMessages.add(new OutgoingMessage(mg, new IPAndPort(srr.connection.getRemoteSocketAddress())));
    mgBase.send(mg, srr.connection.getRemoteIPAndPort());
}
Also used : RetrievalOptions(com.ms.silverking.cloud.dht.RetrievalOptions) InternalRetrievalOptions(com.ms.silverking.cloud.dht.common.InternalRetrievalOptions) 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 3 with MessageGroup

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

the class ActiveRegionSync method sendChecksumTreeRequest.

// //////////////////////////////////////////////////////////////////
private void sendChecksumTreeRequest(ChecksumTreeRequest ctr) {
    MessageGroup mg;
    mg = new ProtoChecksumTreeRequestMessageGroup(uuid, namespace, ctr.getTargetCP(), ctr.getCurCP(), mgBase.getMyID(), ctr.getRegion(), false).toMessageGroup();
    if (verbose || debug) {
        Log.warningAsyncf("%x requestChecksumTree: %s\t%s\t%s\t%s", namespace, 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) ProtoChecksumTreeRequestMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup)

Example 4 with MessageGroup

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

the class SyncController method sendReplicaSyncRequest.

private void sendReplicaSyncRequest(ReplicaSyncRequest r) {
    MessageGroup mg;
    ensureFrozen();
    mg = new ProtoChecksumTreeRequestMessageGroup(r.getUUID(), r.getNS(), targetCP, curCP, mgBase.getMyID(), r.getRegion(), r.getOldOwner(), true).toMessageGroup();
    if (verbose || debug) {
        Log.warningAsyncf("%x requestChecksumTree: %s", r.getNS(), r);
    }
    if (!hasErrors) {
        mgBase.send(mg, r.getNewOwner());
        r.setSendTime(absMillisTimeSource.absTimeMillis());
    }
}
Also used : ProtoChecksumTreeRequestMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup) MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) ProtoChecksumTreeRequestMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup)

Example 5 with MessageGroup

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

the class ChecksumTreeServer method getChecksumTree.

// ////////////////////////////////////////////////////////////////////
// Handle incoming request for a convergence tree
public void getChecksumTree(UUIDBase uuid, ConvergencePoint targetCP, ConvergencePoint sourceCP, MessageGroupConnection connection, byte[] originator, RingRegion region) {
    ChecksumNode root;
    ProtoChecksumTreeMessageGroup pmg;
    int bufferSize;
    ConvergencePoint mixedCP;
    if (verbose || debug) {
        System.out.printf("getChecksumTree %x\t%s\t%s\t%s\t%s\n", ns, targetCP, sourceCP, region, uuid);
    }
    // FUTURE - support both min and max version
    // We create a mixedCP because we need to retrieve target data from the source regions, but
    // we need to use the target data version
    mixedCP = sourceCP.dataVersion(targetCP.getDataVersion());
    root = getRegionChecksumTree_Local(mixedCP, region, new LongInterval(Long.MIN_VALUE, mixedCP.getDataVersion()));
    if (root == null) {
        if (verbose || debug) {
            System.out.printf("null root for %x\t%s\t%s\n", ns, mixedCP, region);
        }
    }
    if (debug) {
        System.out.println("computed:");
        System.out.println(root);
    }
    bufferSize = estimateBufferSize(root);
    pmg = null;
    do {
        try {
            pmg = new ProtoChecksumTreeMessageGroup(uuid, ns, targetCP, originator, root, bufferSize);
        // pmg = new ProtoChecksumTreeMessageGroup(uuid, ns, mixedCP, originator, root, bufferSize);
        } catch (BufferOverflowException bfe) {
            pmg = null;
            if (bufferSize == Integer.MAX_VALUE) {
                throw new RuntimeException("Buffer limit reached");
            } else {
                if (debug) {
                    System.out.printf("raising checksum tree buffer limit %s\n", uuid);
                }
                bufferSize = bufferSize << 1;
                if (bufferSize < 0) {
                    bufferSize = Integer.MAX_VALUE;
                }
            }
        }
    } while (pmg == null);
    try {
        MessageGroup mg;
        mg = pmg.toMessageGroup();
        if (verbose || debug) {
            System.out.printf("Sending checksum tree %s to %s\n", uuid, connection.getRemoteIPAndPort());
        }
        if (debug) {
            System.out.printf("Sending checksum tree at %d %d\n", absMillisTimeSource.absTimeMillis(), mg.getDeadlineAbsMillis(absMillisTimeSource));
        }
        connection.sendAsynchronous(mg, mg.getDeadlineAbsMillis(absMillisTimeSource));
    } catch (IOException ioe) {
        Log.logErrorWarning(ioe);
    }
}
Also used : ProtoChecksumTreeMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeMessageGroup) ProtoChecksumTreeMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeMessageGroup) MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) LongInterval(com.ms.silverking.numeric.LongInterval) BufferOverflowException(java.nio.BufferOverflowException) IOException(java.io.IOException)

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