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);
}
}
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());
}
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();
}
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());
}
}
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);
}
}
Aggregations