use of com.ms.silverking.cloud.dht.net.MessageGroup in project SilverKing by Morgan-Stanley.
the class ConvergenceController2 method sendSyncRetrievalRequest.
private void sendSyncRetrievalRequest(SyncRetrievalRequest srr) {
MessageGroup mg;
RetrievalOptions retrievalOptions;
retrievalOptions = OptionsHelper.newRetrievalOptions(RetrievalType.VALUE_AND_META_DATA, WaitMode.GET, checksumVersionConstraint(srr.dataVersion));
mg = new ProtoRetrievalMessageGroup(srr.uuid, ns, new InternalRetrievalOptions(retrievalOptions), mgBase.getMyID(), srr.outstandingKeys, convergenceRelativeDeadlineMillis).toMessageGroup();
outgoingMessages.add(new OutgoingMessage(mg, new IPAndPort(srr.connection.getRemoteSocketAddress())));
}
use of com.ms.silverking.cloud.dht.net.MessageGroup 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.MessageGroup in project SilverKing by Morgan-Stanley.
the class MessageGroupConnectionProxyLocal method sendAsynchronous.
@Override
public void sendAsynchronous(Object data, long deadline) throws IOException {
MessageAndConnection messageAndConnection;
// Log.warning("MessageGroupConnectionProxyLocal sending");
messageAndConnection = new MessageAndConnection((MessageGroup) data, this);
worker.addWork(messageAndConnection);
}
use of com.ms.silverking.cloud.dht.net.MessageGroup in project SilverKing by Morgan-Stanley.
the class MessageModule method sendPutResults.
// //////////////////////////
// FUTURE make ActiveProxyPut use this after we have it working for PutUpdate
// and after the below FUTUREs have been resolved
protected void sendPutResults(MessageGroup message, long version, MessageGroupConnectionProxy connection, List<PutResult> results, byte storageState, int deadlineRelativeMillis) {
ProtoPutResponseMessageGroup response;
if (results.size() > 0) {
response = new ProtoPutResponseMessageGroup(message.getUUID(), message.getContext(), // FUTURE - does ProtoPutResponseMessageGroup really need version when we're using the uuid now?
version, results.size(), mgBase.getMyID(), storageState, // FUTURE - allow constructor without this?
deadlineRelativeMillis);
if (debug) {
System.out.println("results.size " + results.size());
}
for (PutResult result : results) {
if (debug) {
System.out.println(result);
}
response.addResult(result.getKey(), result.getResult());
}
try {
MessageGroup mg;
mg = response.toMessageGroup();
if (Log.levelMet(Level.FINE)) {
Log.warning("sendResults: " + connection.getConnectionID());
mg.displayForDebug(true);
}
connection.sendAsynchronous(mg, mg.getDeadlineAbsMillis(getAbsMillisTimeSource()));
} catch (IOException ioe) {
Log.logErrorWarning(ioe);
}
}
}
use of com.ms.silverking.cloud.dht.net.MessageGroup in project SilverKing by Morgan-Stanley.
the class ActiveProxyOperation method forwardGroup.
/**
* Forward to a single replica
* @param replica
* @param destEntries
* @param optionsByteBuffer
*/
private <L extends DHTKey> void forwardGroup(IPAndPort replica, List<L> destEntries, ByteBuffer optionsByteBuffer, ForwardCreator<L> forwardCreator, OpCommunicator<K, R> comm) {
if (forwardingMode.forwards()) {
MessageGroup mg;
assert replica != null;
mg = forwardCreator.createForward(destEntries, optionsByteBuffer);
if (debug) {
System.out.println("Forwarding: " + new SimpleValueCreator(originator) + ":" + replica + " : " + mg + ":" + mg.getForwardingMode());
mg.displayForDebug();
}
messageModule.getMessageGroupBase().send(mg, replica);
} else {
localOp(destEntries, comm);
}
}
Aggregations