use of com.ms.silverking.cloud.dht.net.PutResult in project SilverKing by Morgan-Stanley.
the class MessageModule method handlePutUpdate.
/**
* Process a put update.
* @param message
* @param connection
*/
private void handlePutUpdate(MessageGroup message, MessageGroupConnectionProxy connection) {
List<PutResult> results;
long version;
byte storageState;
version = ProtoPutUpdateMessageGroup.getPutVersion(message);
storageState = ProtoPutUpdateMessageGroup.getStorageState(message);
if (debug) {
System.out.println("handlePutUpdate storageState: " + storageState);
}
results = new ArrayList<>();
for (MessageGroupKeyEntry entry : message.getKeyIterator()) {
OpResult opResult;
opResult = storage.putUpdate(message.getContext(), entry, version, storageState);
results.add(new PutResult(entry, opResult));
}
sendPutResults(message, version, connection, results, storageState, message.getDeadlineRelativeMillis());
}
use of com.ms.silverking.cloud.dht.net.PutResult 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);
}
}
}
Aggregations