Search in sources :

Example 26 with OpResult

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();
        }
    }
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) OpResult(com.ms.silverking.cloud.dht.common.OpResult)

Example 27 with OpResult

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);
    }
}
Also used : ProtoOpResponseMessageGroup(com.ms.silverking.cloud.dht.net.ProtoOpResponseMessageGroup) ConvergencePoint(com.ms.silverking.cloud.dht.daemon.storage.convergence.ConvergencePoint) OpResult(com.ms.silverking.cloud.dht.common.OpResult) IOException(java.io.IOException) RingState(com.ms.silverking.cloud.dht.daemon.storage.convergence.RingState) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException)

Example 28 with OpResult

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;
}
Also used : OpResult(com.ms.silverking.cloud.dht.common.OpResult) Waiter(com.ms.silverking.cloud.dht.daemon.Waiter)

Example 29 with OpResult

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;
}
Also used : MessageGroupKeyOrdinalEntry(com.ms.silverking.cloud.dht.net.MessageGroupKeyOrdinalEntry) OpResult(com.ms.silverking.cloud.dht.common.OpResult) DHTKey(com.ms.silverking.cloud.dht.common.DHTKey) Waiter(com.ms.silverking.cloud.dht.daemon.Waiter)

Example 30 with OpResult

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);
    }
}
Also used : ProtoOpResponseMessageGroup(com.ms.silverking.cloud.dht.net.ProtoOpResponseMessageGroup) OpResult(com.ms.silverking.cloud.dht.common.OpResult) IOException(java.io.IOException)

Aggregations

OpResult (com.ms.silverking.cloud.dht.common.OpResult)32 DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)7 IOException (java.io.IOException)5 ProtoOpResponseMessageGroup (com.ms.silverking.cloud.dht.net.ProtoOpResponseMessageGroup)4 Waiter (com.ms.silverking.cloud.dht.daemon.Waiter)3 ConvergencePoint (com.ms.silverking.cloud.dht.daemon.storage.convergence.ConvergencePoint)3 MessageGroupKeyOrdinalEntry (com.ms.silverking.cloud.dht.net.MessageGroupKeyOrdinalEntry)3 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)2 MessageGroupRetrievalResponseEntry (com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry)2 IPAndPort (com.ms.silverking.net.IPAndPort)2 WeakReference (java.lang.ref.WeakReference)2 ImmutableList (com.google.common.collect.ImmutableList)1 NamespaceVersionMode (com.ms.silverking.cloud.dht.NamespaceVersionMode)1 NonExistenceResponse (com.ms.silverking.cloud.dht.NonExistenceResponse)1 RetrievalOptions (com.ms.silverking.cloud.dht.RetrievalOptions)1 WaitOptions (com.ms.silverking.cloud.dht.WaitOptions)1 CorruptValueException (com.ms.silverking.cloud.dht.common.CorruptValueException)1 InternalRetrievalOptions (com.ms.silverking.cloud.dht.common.InternalRetrievalOptions)1 RawRetrievalResult (com.ms.silverking.cloud.dht.common.RawRetrievalResult)1 SimpleKey (com.ms.silverking.cloud.dht.common.SimpleKey)1