use of com.ms.silverking.cloud.dht.net.ProtoOpResponseMessageGroup in project SilverKing by Morgan-Stanley.
the class StorageModule method handleReap.
public void handleReap(MessageGroup message, MessageGroupConnection connection) {
OpResult result;
ProtoOpResponseMessageGroup response;
asyncInvocation("reap");
result = OpResult.SUCCEEDED;
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.net.ProtoOpResponseMessageGroup in project SilverKing by Morgan-Stanley.
the class MessageModule method handleSyncRequest.
// sync requests are only for testing
private void handleSyncRequest(MessageGroup message, MessageGroupConnection connection) {
long version;
ProtoOpResponseMessageGroup response;
if (Log.levelMet(Level.FINE)) {
message.displayForDebug();
}
Log.warning("handleSyncRequest");
version = ProtoVersionedBasicOpMessageGroup.getVersion(message);
requestChecksumTree(version);
response = new ProtoOpResponseMessageGroup(message.getUUID(), message.getContext(), OpResult.SUCCEEDED, mgBase.getMyID(), message.getDeadlineRelativeMillis());
try {
connection.sendAsynchronous(response.toMessageGroup(), message.getDeadlineAbsMillis(absMillisTimeSource));
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
use of com.ms.silverking.cloud.dht.net.ProtoOpResponseMessageGroup 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.net.ProtoOpResponseMessageGroup 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.net.ProtoOpResponseMessageGroup 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