Search in sources :

Example 11 with OpResult

use of com.ms.silverking.cloud.dht.common.OpResult in project SilverKing by Morgan-Stanley.

the class MessageModule method handleRetrieveResponse.

/**
 * Process a retrieval response. For client-initiated retrievals, handle in the
 * retrieval protocol. For locally-initiated synchronization, handle in the synchronization code.
 * @param message
 * @param connection
 */
void handleRetrieveResponse(MessageGroup message, MessageGroupConnectionProxy connection) {
    Log.fine("handleRetrieveResponse");
    if (debug) {
        Log.warning("rr: " + message + " " + connection);
    }
    // if (Arrays.equals(message.getOriginator(), mgBase.getIPAndPort())) {
    // storage.incomingSyncRetrievalResponse(message);
    // } else {
    ActiveProxyRetrieval activeRetrieval;
    activeRetrieval = activeRetrievals.get(message.getUUID());
    if (activeRetrieval != null) {
        OpResult opResult;
        opResult = activeRetrieval.handleRetrievalResponse(message, connection);
        if (opResult.isComplete()) {
            // FIXME - think about failures
            activeRetrievals.remove(message.getUUID());
            if (debugCompletion) {
            // _complete.incrementAndGet();
            }
        } else {
            if (debugCompletion) {
            // _incomplete.incrementAndGet();
            }
        }
    } else {
        // storage.incomingSyncRetrievalResponse(message);
        storage.asyncInvocation("incomingSyncRetrievalResponse", message);
    /*
                Log.warning("Couldn't find activeRetrieval for ", message);
                if (debugCompletion) {
                    //_notFound.incrementAndGet();
                }
                */
    }
// }
}
Also used : OpResult(com.ms.silverking.cloud.dht.common.OpResult)

Example 12 with OpResult

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

Example 13 with OpResult

use of com.ms.silverking.cloud.dht.common.OpResult in project SilverKing by Morgan-Stanley.

the class MessageModule method handlePutUpdate.

/**
 * Process a put update.
 * @param message
 * @param connection
 */
private void handlePutUpdate(MessageGroup message, MessageGroupConnectionProxy connection) {
    List<PutResult> results;
    long version;
    byte storageState;
    version = ProtoPutUpdateMessageGroup.getPutVersion(message);
    storageState = ProtoPutUpdateMessageGroup.getStorageState(message);
    if (debug) {
        System.out.println("handlePutUpdate storageState: " + storageState);
    }
    results = new ArrayList<>();
    for (MessageGroupKeyEntry entry : message.getKeyIterator()) {
        OpResult opResult;
        opResult = storage.putUpdate(message.getContext(), entry, version, storageState);
        results.add(new PutResult(entry, opResult));
    }
    sendPutResults(message, version, connection, results, storageState, message.getDeadlineRelativeMillis());
}
Also used : MessageGroupKeyEntry(com.ms.silverking.cloud.dht.net.MessageGroupKeyEntry) OpResult(com.ms.silverking.cloud.dht.common.OpResult) PutResult(com.ms.silverking.cloud.dht.net.PutResult)

Example 14 with OpResult

use of com.ms.silverking.cloud.dht.common.OpResult in project SilverKing by Morgan-Stanley.

the class ActiveProxyPut method localOp_putupdate.

protected void localOp_putupdate(List<? extends DHTKey> _entries, PutCommunicator pComm) {
    List<OpResult> results;
    int _entriesSize;
    results = getStorage().putUpdate(getContext(), _entries, getVersion());
    _entriesSize = _entries.size();
    if (results.size() != _entriesSize) {
        throw new RuntimeException("panic");
    }
    for (int i = 0; i < _entriesSize; i++) {
        DHTKey _entry;
        MessageGroupKeyOrdinalEntry mgkoEntry;
        OpResult result;
        _entry = _entries.get(i);
        if (debug) {
            System.out.printf("localOp_putupdate: %s\n", _entry);
        }
        mgkoEntry = (MessageGroupKeyOrdinalEntry) _entry;
        result = results.get(i);
        storageOperation.localUpdate(_entry, mgkoEntry.getOrdinal(), result, pComm);
    }
}
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)

Example 15 with OpResult

use of com.ms.silverking.cloud.dht.common.OpResult in project SilverKing by Morgan-Stanley.

the class AsyncPutOperationImpl method resultUpdated.

@Override
public void resultUpdated(DHTKey key, OpResult opResult) {
    OpResult previous;
    // System.out.println(key +"\t"+ opResult +"\t"+ resolvedVersion +"\t"+ this);
    Log.fine("resultUpdated ", key);
    previous = opResults.putIfAbsent(key, opResult);
    if (previous != null && previous != opResult) {
        if (debug) {
            Log.warning(String.format("resultUpdated %s new %s prev %s", key, opResult, previous));
        }
        switch(previous.toOperationState()) {
            // no action necessary
            case INCOMPLETE:
                break;
            case FAILED:
                opResults.put(key, previous);
                if (opResult.toOperationState() == OperationState.FAILED) {
                    Log.info("Multiple failures: ", key);
                } else if (opResult.toOperationState() == OperationState.SUCCEEDED) {
                    Log.warning("ActivePutOperationImpl received failure then success for: " + key);
                    Log.warning(previous);
                }
                break;
            case SUCCEEDED:
                if (opResult.toOperationState() == OperationState.FAILED) {
                    Log.warning("ActivePutOperationImpl received success then failure for: " + key);
                    Log.warning(opResult);
                }
                break;
            default:
                throw new RuntimeException("panic");
        }
    } else {
        if (opResult.hasFailed()) {
            setFailureCause(key, opResult.toFailureCause(getNonExistenceResponse()));
        }
    }
    if (resultsReceived.incrementAndGet() >= putOperation.size()) {
        // System.out.println(resultMessagesReceived +" > "+ putOperation.size());
        checkForCompletion();
    }
}
Also used : OpResult(com.ms.silverking.cloud.dht.common.OpResult)

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