use of com.ms.silverking.id.UUIDBase in project SilverKing by Morgan-Stanley.
the class OpCompletionTracker method waitForCompletion.
public Pair<Set<UUIDBase>, Set<UUIDBase>> waitForCompletion(Set<UUIDBase> uuids, int time, TimeUnit unit) {
Timer waitTimer;
Set<UUIDBase> incompleteOps;
Set<UUIDBase> failedOps;
incompleteOps = new HashSet<>();
failedOps = new HashSet<>();
waitTimer = new SimpleTimer(unit, time);
for (UUIDBase uuid : uuids) {
completionState.putIfAbsent(uuid, new OpCompletionState());
}
try {
for (UUIDBase uuid : uuids) {
OpCompletionState opCompletionState;
boolean complete;
opCompletionState = completionState.get(uuid);
complete = opCompletionState.waitForCompletion(waitTimer.getRemainingMillis(), TimeUnit.MILLISECONDS);
if (!complete) {
incompleteOps.add(uuid);
}
if (opCompletionState.getResult().hasFailed()) {
failedOps.add(uuid);
}
}
} finally {
for (UUIDBase uuid : uuids) {
completionState.remove(uuid);
}
}
return new Pair<>(incompleteOps, failedOps);
}
use of com.ms.silverking.id.UUIDBase in project SilverKing by Morgan-Stanley.
the class Connection method sendTimedOut.
/**
* Must be called if a send times out. This happens when a send
* deadline is not met.
*/
protected void sendTimedOut(OutgoingData data) {
ActiveSend activeSend;
UUIDBase sendUUID;
Log.warningAsync("sendTimedOut", remoteSocketAddress);
data.displayForDebug();
sendUUID = data.getSendUUID();
if (sendUUID != null && activeBlockingSends != null) {
activeSend = activeBlockingSends.get(sendUUID);
} else {
activeSend = null;
}
if (activeSend != null) {
activeSend.setException(new IOException("send timed out"));
} else {
if (Log.levelMet(Level.FINE)) {
Log.fine("sendTimedOut() not an active send ", data.getSendUUID() + " " + remoteSocketAddress);
}
}
data.timeout();
}
use of com.ms.silverking.id.UUIDBase in project SilverKing by Morgan-Stanley.
the class PersistentAsyncServer method sendSynchronous.
public void sendSynchronous(InetSocketAddress dest, Object data, UUIDBase uuid, AsyncSendListener listener, long deadline) throws IOException {
Connection connection;
RandomBackoff backoff;
if (uuid == null) {
uuid = new UUIDBase();
Log.fine("null send uuid, picking new uuid ", uuid);
listener = null;
}
backoff = null;
while (true) {
connection = getConnectionFast(dest, deadline);
try {
connection.sendSynchronous(data, uuid, listener, deadline);
return;
} catch (IOException ioe) {
connections.remove(dest);
informSuspectAddressListener(dest);
Log.warning(ioe + " " + dest);
Log.logErrorWarning(ioe);
if (backoff == null) {
backoff = new RandomBackoff(maxSendBackoffNum, initialSendBackoffValue);
}
if (!backoff.maxBackoffExceeded()) {
backoff.backoff();
} else {
listener.failed(uuid);
throw ioe;
}
}
}
}
use of com.ms.silverking.id.UUIDBase in project SilverKing by Morgan-Stanley.
the class PersistentAsyncServer method send.
public void send(InetSocketAddress dest, Object data, boolean synchronous, long deadline) throws IOException {
UUIDBase uuid;
uuid = new UUIDBase();
if (synchronous) {
sendSynchronous(dest, data, uuid, null, deadline);
} else {
sendAsynchronous(dest, data, null, null, deadline);
}
}
use of com.ms.silverking.id.UUIDBase in project SilverKing by Morgan-Stanley.
the class DHTRingMaster method requestChecksumTree.
public void requestChecksumTree(Triple<Long, Long, Long> nsAndRegion, ConvergencePoint curCP, ConvergencePoint targetCP, IPAndPort owner) {
MessageGroup mg;
UUIDBase uuid;
uuid = UUIDBase.random();
mg = new ProtoChecksumTreeRequestMessageGroup(uuid, nsAndRegion.getV1(), targetCP, curCP, mgBase.getMyID(), new RingRegion(nsAndRegion.getV2(), nsAndRegion.getV3()), mgBase._getIPAndPort(), false).toMessageGroup();
mgBase.send(mg, owner);
}
Aggregations