use of com.ms.silverking.cloud.dht.net.ProtoValueMessageGroup in project SilverKing by Morgan-Stanley.
the class ActiveProxyRetrieval method sendResults.
/**
* Send responses for all locally completed operations
* @param retrievalOperation
*/
protected void sendResults(List<RetrievalResult> results) {
if (debug) {
System.out.printf("ActiveProxyRetrieval.sendresults() %d\n", results.size());
}
/*
debugString.append("***\n");
for (RetrievalResult result : results) {
debugString.append(result.getValue() +"\n");
}
debugString.append("+++\n");
*/
try {
if (results.size() > 0) {
ProtoValueMessageGroup pmg;
byte[] _originator;
List<List<RetrievalResult>> resultGroups;
_originator = ConvergenceController2.isChecksumVersionConstraint(retrievalOptions.getVersionConstraint()) ? originator : messageModule.getMessageGroupBase().getMyID();
resultGroups = createResultGroups(results);
for (List<RetrievalResult> resultGroup : resultGroups) {
MessageGroup messageGroup;
int groupLength;
groupLength = RetrievalResult.totalResultLength(resultGroup);
pmg = new ProtoValueMessageGroup(uuid, namespace, results.size(), groupLength, _originator, messageModule.getAbsMillisTimeSource().relMillisRemaining(absDeadlineMillis));
for (RetrievalResult result : resultGroup) {
DHTKey key;
ByteBuffer value;
if (debug) {
System.out.println(result);
}
key = result.getKey();
if (retrievalOptions.getWaitMode() != WaitMode.WAIT_FOR || result.getValue() == null) {
value = result.getValue();
} else {
value = result.getValue().duplicate();
}
if (value == null) {
pmg.addErrorCode(key, result.getResult());
} else {
pmg.addValue(key, value, result.getResultLength(), true);
}
}
messageGroup = pmg.toMessageGroup();
connection.sendAsynchronous(messageGroup, messageGroup.getDeadlineAbsMillis(messageModule.getAbsMillisTimeSource()));
}
}
/*
} catch (RuntimeException re) {
// for debugging only
re.printStackTrace();
System.out.println("results.size() "+ results.size());
for (RetrievalResult result : results) {
System.out.println(result);
}
//rComm.displayDebug();
System.exit(-1);
*/
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
use of com.ms.silverking.cloud.dht.net.ProtoValueMessageGroup 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;
}
Aggregations