use of com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry 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.MessageGroupRetrievalResponseEntry in project SilverKing by Morgan-Stanley.
the class AsyncRetrievalOperationImpl method createProtoRetrievalMG.
private ProtoRetrievalMessageGroup createProtoRetrievalMG(MessageEstimate estimate, boolean verifyIntegrity) {
OperationUUID opUUID;
ConcurrentMap<DHTKey, List<ActiveKeyedOperationResultListener<MessageGroupRetrievalResponseEntry>>> newMap;
KeyedMessageEstimate keyedMessageEstimate;
int relDeadline;
keyedMessageEstimate = (KeyedMessageEstimate) estimate;
opUUID = activeRetrievalListeners.newOpUUID();
relDeadline = operation.getTimeoutController().getMaxRelativeTimeoutMillis(this);
if (debugShortTimeout) {
if (relDeadline < shortTimeoutLimit) {
Log.warning("short relDeadline: " + relDeadline);
// Log.warning(timeoutParameters.computeTimeout(keyedMessageEstimate.getNumKeys()));
Log.warning(timeoutState.getCurRelTimeoutMillis());
// throw new RuntimeException();
}
}
return new ProtoRetrievalMessageGroup(opUUID, context.contextAsLong(), new InternalRetrievalOptions(retrievalOperation.retrievalOptions(), verifyIntegrity), originator, keyedMessageEstimate.getNumKeys(), relDeadline, retrievalOperation.retrievalOptions().getForwardingMode());
}
use of com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry in project SilverKing by Morgan-Stanley.
the class SegmentedRetrievalValue method checkForCompletion.
@Override
protected void checkForCompletion() {
MessageGroupRetrievalResponseEntry response;
OpResult result;
result = OpResult.SUCCEEDED;
for (DHTKey key : keys) {
if (getResult(key) != OpResult.SUCCEEDED) {
result = getResult(key);
// System.out.println("Incomplete: "+ key);
}
}
if (result == OpResult.SUCCEEDED) {
// System.out.println("SegmentedRetrievalValue complete");
parent.reassembledResultReceived(relayKey, new SegmentedRetrievalResult<>(metaData, deserializer, getBuffers(), result));
} else {
// System.out.println("SegmentedRetrievalValue incomplete");
// parent.resultReceived(relayKey, MessageGroupRetrievalResponseEntry);
}
}
use of com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry in project SilverKing by Morgan-Stanley.
the class NamespaceStore method handleSecondarySync.
public void handleSecondarySync(MessageGroup message) {
List<StorageValueAndParameters> svpList;
if (debug) {
Log.warningAsyncf("incomingSyncRetrievalResponse");
}
svpList = new ArrayList<>();
for (MessageGroupRetrievalResponseEntry entry : message.getRetrievalResponseValueKeyIterator()) {
StorageValueAndParameters svp;
svp = StorageValueAndParameters.createSVP(entry);
if (svp != null) {
svpList.add(svp);
}
}
if (!svpList.isEmpty()) {
put(svpList, emptyUserData, NullKeyedOpResultListener.instance);
}
}
use of com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry in project SilverKing by Morgan-Stanley.
the class ActiveRetrievalListeners method receivedRetrievalResponse.
void receivedRetrievalResponse(MessageGroup message) {
if (enableMultipleOpsPerMessage) {
// long version;
ConcurrentMap<DHTKey, List<WeakReference<ActiveKeyedOperationResultListener<MessageGroupRetrievalResponseEntry>>>> listenerMap;
// version = message.getBuffers()[0].getLong(0);
// System.out.println("receivedRetrievalResponse version "+ version);
listenerMap = activeRetrievalListeners.get(message.getUUID());
if (listenerMap != null) {
// System.out.println("listenerMap "+ listenerMap);
for (MessageGroupRetrievalResponseEntry entry : message.getRetrievalResponseValueKeyIterator()) {
List<WeakReference<ActiveKeyedOperationResultListener<MessageGroupRetrievalResponseEntry>>> listenerList;
// System.out.println("entry:\t"+ entry);
listenerList = listenerMap.get(entry);
if (listenerList != null) {
for (WeakReference<ActiveKeyedOperationResultListener<MessageGroupRetrievalResponseEntry>> listenerRef : listenerList) {
ActiveKeyedOperationResultListener<MessageGroupRetrievalResponseEntry> listener;
listener = listenerRef.get();
if (listener != null) {
listener.resultReceived(entry, entry);
} else {
Log.info("receivedRetrievalResponse. null listenerRef.get() for entry: ", entry);
}
}
} else {
Log.warning("receivedRetrievalResponse. No listener for entry: ", entry);
}
}
} else {
// If we're receiving the error, then it's possible that we lost the
// reference that was stored in the weak map.
// FUTURE - was WARNING, think about level
Log.info("receivedRetrievalResponse. No listenerMap for: ", message.getUUID());
}
} else {
ActiveKeyedOperationResultListener<MessageGroupRetrievalResponseEntry> listener;
listener = activeOpListeners.get(message.getUUID());
if (listener == null) {
Log.info("receivedRetrievalResponse. No listener for uuid: ", message.getUUID());
} else {
for (MessageGroupRetrievalResponseEntry entry : message.getRetrievalResponseValueKeyIterator()) {
listener.resultReceived(entry, entry);
}
}
}
}
Aggregations