use of com.ms.silverking.id.UUIDBase in project SilverKing by Morgan-Stanley.
the class ConvergenceController2 method incomingChecksumTree.
// FUTURE - ENSURE THAT NO CONVERGENCE CODE USES THE RECEIVE THREADS TO DO WORK
// USE A WORKER
private void incomingChecksumTree(UUIDBase incomingUUID, ConvergencePoint cp, ChecksumNode remoteTree, MessageGroupConnection connection) {
ChecksumNode localTree;
MatchResult matchResult;
Set<DHTKey> keysToFetch;
List<DHTKey> keysToFetchList;
outstandingChecksumTreeRequests.remove(incomingUUID);
checkQueuedChecksumTreeRequests();
if (remoteTree == null) {
checkForCompletion();
return;
}
localTree = checksumTreeServer.getRegionChecksumTree_Local(cp, remoteTree.getRegion(), new LongInterval(Long.MIN_VALUE, cp.getDataVersion()));
if (verbose) {
Log.warningAsyncf("incomingChecksumTree %s", incomingUUID);
}
if (debug) {
Log.warningAsyncf("incomingChecksumTree %x\t%s\t%s\t%s", ns, cp, remoteTree.getRegion(), incomingUUID);
Log.warningAsyncf(remoteTree + "\n\nlocalTree\n" + localTree);
}
if (localTree == null) {
checkForCompletion();
return;
}
try {
matchResult = TreeMatcher.match(localTree, remoteTree);
} catch (RuntimeException re) {
System.err.println(localTree);
System.err.println();
System.err.println(connection);
System.err.println(remoteTree);
throw re;
}
if (debug) {
Log.warningAsyncf("%s", matchResult);
}
keysToFetch = new HashSet<>();
for (KeyAndVersionChecksum kvc : matchResult.getDestNotInSource()) {
if (debug) {
System.out.printf("Adding destNotInSource %s\n", kvc.getKey());
}
keysToFetch.add(kvc.getKey());
}
for (KeyAndVersionChecksum kvc : matchResult.getChecksumMismatch()) {
if (debug) {
System.out.printf("Adding checksumMismatch %s\n", kvc.getKey());
}
keysToFetch.add(kvc.getKey());
}
/*
Queue<DHTKey> keysToFetchQueue;
keysToFetchQueue = keysToFetchMap.get(cp);
if (keysToFetchQueue == null) {
Queue<DHTKey> prev;
keysToFetchQueue = new ConcurrentLinkedQueue<>();
prev = keysToFetchMap.putIfAbsent(cp, keysToFetchQueue);
if (prev != null) {
keysToFetchQueue = prev;
}
}
keysToFetchQueue.addAll(keysToFetch);
*/
keysToFetchList = new LinkedList<>(keysToFetch);
while (keysToFetchList.size() > 0) {
Set<DHTKey> batchKeys;
int batchSize;
RetrievalOptions retrievalOptions;
UUIDBase uuid;
// MessageGroup mg;
SyncRetrievalRequest srr;
// batchKeys = new HashSet<>(retrievalBatchSize);
batchKeys = new ConcurrentSkipListSet<DHTKey>();
batchSize = 0;
while (keysToFetchList.size() > 0 && batchSize < retrievalBatchSize) {
batchKeys.add(keysToFetchList.remove(0));
++batchSize;
}
// FUTURE - could consider sending SourceNotInDest
retrievalOptions = OptionsHelper.newRetrievalOptions(RetrievalType.VALUE_AND_META_DATA, WaitMode.GET, checksumVersionConstraint(cp.getDataVersion()));
// new VersionConstraint(Long.MIN_VALUE + 1, version, Mode.NEWEST));
uuid = UUIDBase.random();
srr = new SyncRetrievalRequest(uuid, batchKeys, cp.getDataVersion(), connection);
outstandingSyncRetrievalRequests.put(uuid, srr);
convergenceControllers.put(uuid, this);
sendSyncRetrievalRequest(srr);
// mg = new ProtoRetrievalMessageGroup(uuid, ns, new InternalRetrievalOptions(retrievalOptions),
// mgBase.getMyID(), batchKeys, convergenceRelativeDeadlineMillis).toMessageGroup();
// outgoingMessages.add(new OutgoingMessage(mg, new IPAndPort(connection.getRemoteSocketAddress())));
/*
try {
connection.sendAsynchronous(mg, mg.getDeadlineAbsMillis(absMillisTimeSource));
} catch (IOException ioe) {
Log.logErrorWarning(ioe);
}
*/
// if (keysToFetchList.size() > 0) {
// ThreadUtil.sleep(5);
// }
}
checkMGQueue();
if (debug) {
Log.warningAsyncf("no more keysToFetch");
}
checkForCompletion();
}
use of com.ms.silverking.id.UUIDBase 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();
}
use of com.ms.silverking.id.UUIDBase in project SilverKing by Morgan-Stanley.
the class ActiveProxyRetrieval method createValueMessageForSecondaryReplicas.
// ///////////////////////
private ProtoValueMessageGroup createValueMessageForSecondaryReplicas(RetrievalResult result) {
ProtoValueMessageGroup pmg;
ByteBuffer buf;
ValueCreator creator;
int valueBytes;
ByteBuffer value;
int valueLength;
buf = result.getValue();
creator = MetaDataUtil.getCreator(buf, 0);
valueBytes = MetaDataUtil.getStoredLength(buf, 0);
valueLength = MetaDataUtil.getCompressedLength(buf, 0);
value = (ByteBuffer) buf.duplicate().flip();
if (debug) {
System.out.printf("buf %s\n", buf);
System.out.printf("value %s\n", value);
System.out.printf("valueBytes %d valueLength %d\n", valueBytes, valueLength);
}
pmg = new ProtoValueMessageGroup(new UUIDBase(), message.getContext(), 1, valueBytes, creator.getBytes(), DHTConstants.defaultSecondaryReplicaUpdateTimeoutMillis);
pmg.addValue(result.getKey(), value, valueLength, true);
return pmg;
}
use of com.ms.silverking.id.UUIDBase in project SilverKing by Morgan-Stanley.
the class ActiveRegionSync method checkForCompletion.
// ////////////////////////////////////////////////////////////////////
// completion check
private void checkForCompletion() {
if (outstandingSyncRetrievalRequests.isEmpty()) {
setComplete();
} else {
int inprocessSize;
inprocessSize = inprocessSyncRetrievalRequests.size();
Log.warningAsyncf("ars progress: %s outstanding %d inprocess %d", uuid, outstandingSyncRetrievalRequests.size(), inprocessSize);
if (inprocessSize < maxInProcess) {
for (Map.Entry<UUIDBase, SyncRetrievalRequest> e : outstandingSyncRetrievalRequests.entrySet()) {
if (!inprocessSyncRetrievalRequests.contains(e.getKey())) {
sendSyncRetrievalRequest(e.getValue());
break;
}
}
}
}
}
use of com.ms.silverking.id.UUIDBase in project SilverKing by Morgan-Stanley.
the class DebugMessageDump method parse.
public MessageGroup parse(List<String> lines) {
List<ByteBuffer> buffers;
buffers = getBuffers(lines);
return new MessageGroup(messageType, // options
0, new UUIDBase(0, 0), // context
0L, buffers.toArray(new ByteBuffer[0]), // originator
new byte[6], // deadlineRelativeMillis
0, // forward
ForwardingMode.DO_NOT_FORWARD);
}
Aggregations