Search in sources :

Example 11 with UUIDBase

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);
}
Also used : SimpleTimer(com.ms.silverking.time.SimpleTimer) Timer(com.ms.silverking.time.Timer) SimpleTimer(com.ms.silverking.time.SimpleTimer) UUIDBase(com.ms.silverking.id.UUIDBase) Pair(com.ms.silverking.collection.Pair)

Example 12 with UUIDBase

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();
}
Also used : UUIDBase(com.ms.silverking.id.UUIDBase) IOException(java.io.IOException)

Example 13 with UUIDBase

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;
            }
        }
    }
}
Also used : UUIDBase(com.ms.silverking.id.UUIDBase) RandomBackoff(com.ms.silverking.net.async.time.RandomBackoff) IOException(java.io.IOException)

Example 14 with UUIDBase

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);
    }
}
Also used : UUIDBase(com.ms.silverking.id.UUIDBase)

Example 15 with UUIDBase

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);
}
Also used : RingRegion(com.ms.silverking.cloud.ring.RingRegion) ProtoChecksumTreeRequestMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup) MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) ProtoChecksumTreeMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeMessageGroup) UUIDBase(com.ms.silverking.id.UUIDBase) ProtoChecksumTreeRequestMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup)

Aggregations

UUIDBase (com.ms.silverking.id.UUIDBase)26 IOException (java.io.IOException)7 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)3 ByteBuffer (java.nio.ByteBuffer)3 KeeperException (org.apache.zookeeper.KeeperException)3 RetrievalOptions (com.ms.silverking.cloud.dht.RetrievalOptions)2 DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)2 InternalRetrievalOptions (com.ms.silverking.cloud.dht.common.InternalRetrievalOptions)2 KeyAndVersionChecksum (com.ms.silverking.cloud.dht.daemon.storage.KeyAndVersionChecksum)2 ConvergencePoint (com.ms.silverking.cloud.dht.daemon.storage.convergence.ConvergencePoint)2 MessageGroup (com.ms.silverking.cloud.dht.net.MessageGroup)2 ProtoChecksumTreeRequestMessageGroup (com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup)2 ProtoNamespaceRequestMessageGroup (com.ms.silverking.cloud.dht.net.ProtoNamespaceRequestMessageGroup)2 IPAndPort (com.ms.silverking.net.IPAndPort)2 LongInterval (com.ms.silverking.numeric.LongInterval)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 NamespaceCreationOptions (com.ms.silverking.cloud.dht.NamespaceCreationOptions)1 ValueCreator (com.ms.silverking.cloud.dht.ValueCreator)1 OpResult (com.ms.silverking.cloud.dht.common.OpResult)1 ProtoChecksumTreeMessageGroup (com.ms.silverking.cloud.dht.net.ProtoChecksumTreeMessageGroup)1