use of com.ms.silverking.cloud.dht.common.OpResult in project SilverKing by Morgan-Stanley.
the class MessageModule method handleRetrieveResponse.
/**
* Process a retrieval response. For client-initiated retrievals, handle in the
* retrieval protocol. For locally-initiated synchronization, handle in the synchronization code.
* @param message
* @param connection
*/
void handleRetrieveResponse(MessageGroup message, MessageGroupConnectionProxy connection) {
Log.fine("handleRetrieveResponse");
if (debug) {
Log.warning("rr: " + message + " " + connection);
}
// if (Arrays.equals(message.getOriginator(), mgBase.getIPAndPort())) {
// storage.incomingSyncRetrievalResponse(message);
// } else {
ActiveProxyRetrieval activeRetrieval;
activeRetrieval = activeRetrievals.get(message.getUUID());
if (activeRetrieval != null) {
OpResult opResult;
opResult = activeRetrieval.handleRetrievalResponse(message, connection);
if (opResult.isComplete()) {
// FIXME - think about failures
activeRetrievals.remove(message.getUUID());
if (debugCompletion) {
// _complete.incrementAndGet();
}
} else {
if (debugCompletion) {
// _incomplete.incrementAndGet();
}
}
} else {
// storage.incomingSyncRetrievalResponse(message);
storage.asyncInvocation("incomingSyncRetrievalResponse", message);
/*
Log.warning("Couldn't find activeRetrieval for ", message);
if (debugCompletion) {
//_notFound.incrementAndGet();
}
*/
}
// }
}
use of com.ms.silverking.cloud.dht.common.OpResult in project SilverKing by Morgan-Stanley.
the class MessageModule method handleSnapshot.
// /////////////////////////////////
private void handleSnapshot(MessageGroup message, MessageGroupConnectionProxy connection) {
long version;
ProtoOpResponseMessageGroup response;
OpResult result;
if (Log.levelMet(Level.FINE)) {
message.displayForDebug();
}
version = ProtoSnapshotMessageGroup.getVersion(message);
result = storage.snapshot(message.getContext(), version);
response = new ProtoOpResponseMessageGroup(message.getUUID(), message.getContext(), result, mgBase.getMyID(), message.getDeadlineRelativeMillis());
try {
connection.sendAsynchronous(response.toMessageGroup(), message.getDeadlineAbsMillis(absMillisTimeSource));
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
use of com.ms.silverking.cloud.dht.common.OpResult 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.common.OpResult in project SilverKing by Morgan-Stanley.
the class ActiveProxyPut method localOp_putupdate.
protected void localOp_putupdate(List<? extends DHTKey> _entries, PutCommunicator pComm) {
List<OpResult> results;
int _entriesSize;
results = getStorage().putUpdate(getContext(), _entries, getVersion());
_entriesSize = _entries.size();
if (results.size() != _entriesSize) {
throw new RuntimeException("panic");
}
for (int i = 0; i < _entriesSize; i++) {
DHTKey _entry;
MessageGroupKeyOrdinalEntry mgkoEntry;
OpResult result;
_entry = _entries.get(i);
if (debug) {
System.out.printf("localOp_putupdate: %s\n", _entry);
}
mgkoEntry = (MessageGroupKeyOrdinalEntry) _entry;
result = results.get(i);
storageOperation.localUpdate(_entry, mgkoEntry.getOrdinal(), result, pComm);
}
}
use of com.ms.silverking.cloud.dht.common.OpResult in project SilverKing by Morgan-Stanley.
the class AsyncPutOperationImpl method resultUpdated.
@Override
public void resultUpdated(DHTKey key, OpResult opResult) {
OpResult previous;
// System.out.println(key +"\t"+ opResult +"\t"+ resolvedVersion +"\t"+ this);
Log.fine("resultUpdated ", key);
previous = opResults.putIfAbsent(key, opResult);
if (previous != null && previous != opResult) {
if (debug) {
Log.warning(String.format("resultUpdated %s new %s prev %s", key, opResult, previous));
}
switch(previous.toOperationState()) {
// no action necessary
case INCOMPLETE:
break;
case FAILED:
opResults.put(key, previous);
if (opResult.toOperationState() == OperationState.FAILED) {
Log.info("Multiple failures: ", key);
} else if (opResult.toOperationState() == OperationState.SUCCEEDED) {
Log.warning("ActivePutOperationImpl received failure then success for: " + key);
Log.warning(previous);
}
break;
case SUCCEEDED:
if (opResult.toOperationState() == OperationState.FAILED) {
Log.warning("ActivePutOperationImpl received success then failure for: " + key);
Log.warning(opResult);
}
break;
default:
throw new RuntimeException("panic");
}
} else {
if (opResult.hasFailed()) {
setFailureCause(key, opResult.toFailureCause(getNonExistenceResponse()));
}
}
if (resultsReceived.incrementAndGet() >= putOperation.size()) {
// System.out.println(resultMessagesReceived +" > "+ putOperation.size());
checkForCompletion();
}
}
Aggregations