use of com.ms.silverking.cloud.dht.common.OpResult in project SilverKing by Morgan-Stanley.
the class MessageModule method handlePutResponse.
/**
* Process a put response.
* @param message
* @param connection
*/
private void handlePutResponse(MessageGroup message, MessageGroupConnectionProxy connection) {
ActiveProxyPut activePut;
activePut = activePuts.get(message.getUUID());
if (activePut != null) {
OpResult opResult;
opResult = activePut.handlePutResponse(message, connection);
if (opResult.isComplete()) {
activePuts.remove(message.getUUID());
if (debugCompletion) {
_complete.incrementAndGet();
}
} else {
if (debugCompletion) {
_incomplete.incrementAndGet();
}
}
} else {
Log.infoAsync("Couldn't find active put ", message.getUUID() + " " + new IPAndPort(message.getOriginator()));
if (debugCompletion) {
_notFound.incrementAndGet();
}
}
}
use of com.ms.silverking.cloud.dht.common.OpResult in project SilverKing by Morgan-Stanley.
the class NodeRingMaster2 method setConvergenceState.
public void setConvergenceState(MessageGroup message, MessageGroupConnection connection) {
RingState state;
ProtoOpResponseMessageGroup response;
OpResult result;
ConvergencePoint curCP;
ConvergencePoint targetCP;
state = ProtoSetConvergenceStateMessageGroup.getRingState(message);
curCP = ProtoSetConvergenceStateMessageGroup.getCurCP(message);
targetCP = ProtoSetConvergenceStateMessageGroup.getTargetCP(message);
Log.warningf("setConvergenceState %s %s %s", state, curCP, targetCP);
if (!curMapState.getConvergencePoint().equals(curCP)) {
Log.warningf("!curMapState.getConvergencePoint().equals(curCP)");
// This is valid if the node was not in the last ring
// in which case, nobody should be trying to read from this replica
// result = OpResult.ERROR;
}
// } else {
if (targetMapState == null || (!targetMapState.getConvergencePoint().equals(targetCP) && state != RingState.ABANDONED)) {
if (state == RingState.INITIAL) {
try {
setTargetMapState(newMapState(targetCP));
result = OpResult.SUCCEEDED;
} catch (Exception e) {
Log.logErrorWarning(e);
result = OpResult.ERROR;
}
} else {
Log.warningf("targetMapState error. state %s", state);
if (targetMapState == null) {
Log.warningf("targetMapState == null");
} else {
Log.warningf("!targetMapState.getConvergencePoint().equals(targetCP) %s", !targetMapState.getConvergencePoint().equals(targetCP));
}
result = OpResult.ERROR;
}
} else {
result = targetMapState.setState(state);
if (state == RingState.CLOSED && result == OpResult.SUCCEEDED) {
setCurMapState(targetMapState);
setTargetMapState(null);
} else if (state == RingState.ABANDONED) {
setTargetMapState(null);
}
}
// }
Log.warningf("setConvergenceState result %s", result);
response = new ProtoOpResponseMessageGroup(message.getUUID(), 0, result, myOriginatorID.getBytes(), message.getDeadlineRelativeMillis());
try {
connection.sendAsynchronous(response.toMessageGroup(), SystemTimeUtil.systemTimeSource.absTimeMillis() + message.getDeadlineRelativeMillis());
} catch (IOException ioe) {
Log.logErrorWarning(ioe);
}
}
use of com.ms.silverking.cloud.dht.common.OpResult in project SilverKing by Morgan-Stanley.
the class NamespaceStore method putUpdate_.
public OpResult putUpdate_(DHTKey key, long version, byte storageState) {
OpResult result;
Set<Waiter> triggeredWaitFors;
if (debug) {
System.out.println("Single key putUpdate()");
}
triggeredWaitFors = null;
writeLock.lock();
try {
result = _putUpdate(key, version, storageState);
// if (result != OpResult.SUCCEEDED) Log.warningf("fail putUpdate %s %s %d", KeyUtil.keyToString(key), result, version); // for debugging
if (result == OpResult.SUCCEEDED && StorageProtocolUtil.storageStateValidForRead(nsOptions.getConsistencyProtocol(), storageState)) {
triggeredWaitFors = checkPendingWaitFors(key);
}
} finally {
writeLock.unlock();
}
if (triggeredWaitFors != null) {
handleTriggeredWaitFors(triggeredWaitFors);
}
return result;
}
use of com.ms.silverking.cloud.dht.common.OpResult in project SilverKing by Morgan-Stanley.
the class NamespaceStore method putUpdate.
public List<OpResult> putUpdate(List<? extends DHTKey> updates, long version) {
List<OpResult> results;
Set<Waiter> triggeredWaitFors;
triggeredWaitFors = null;
results = new ArrayList<>(updates.size());
writeLock.lock();
try {
for (DHTKey update : updates) {
MessageGroupKeyOrdinalEntry entry;
OpResult result;
entry = (MessageGroupKeyOrdinalEntry) update;
result = _putUpdate(entry, version, entry.getOrdinal());
results.add(result);
if (result == OpResult.SUCCEEDED && StorageProtocolUtil.storageStateValidForRead(nsOptions.getConsistencyProtocol(), entry.getOrdinal())) {
Set<Waiter> _triggeredWaitFors;
_triggeredWaitFors = checkPendingWaitFors(update);
if (_triggeredWaitFors != null) {
if (triggeredWaitFors == null) {
triggeredWaitFors = new HashSet<>();
}
triggeredWaitFors.addAll(_triggeredWaitFors);
}
}
}
} finally {
writeLock.unlock();
}
if (triggeredWaitFors != null) {
handleTriggeredWaitFors(triggeredWaitFors);
}
return results;
}
use of com.ms.silverking.cloud.dht.common.OpResult in project SilverKing by Morgan-Stanley.
the class StorageModule method getChecksumTreeForLocal.
// ///////////////////////
// synchronization code
// ns is Long so that invokeAsync works
public void getChecksumTreeForLocal(Long ns, UUIDBase uuid, ConvergencePoint targetCP, ConvergencePoint sourceCP, MessageGroupConnection connection, byte[] originator, RingRegion region, IPAndPort replica, Integer timeoutMillis) {
NamespaceStore nsStore;
boolean success;
OpResult result;
ProtoOpResponseMessageGroup response;
nsStore = getNamespaceStore(ns, NSCreationMode.CreateIfAbsent);
success = nsStore.getChecksumTreeForLocal(uuid, targetCP, sourceCP, connection, originator, region, replica, timeoutMillis);
result = success ? OpResult.SUCCEEDED : OpResult.ERROR;
response = new ProtoOpResponseMessageGroup(uuid, 0, result, SimpleValueCreator.forLocalProcess().getBytes(), timeoutMillis);
try {
connection.sendAsynchronous(response.toMessageGroup(), SystemTimeUtil.systemTimeSource.absTimeMillis() + timeoutMillis);
} catch (IOException ioe) {
Log.logErrorWarning(ioe);
}
}
Aggregations