Search in sources :

Example 1 with WaitOptions

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

the class WaitForTimeoutController method getMaxRelativeTimeoutMillis.

@Override
public final int getMaxRelativeTimeoutMillis(AsyncOperation op) {
    AsyncRetrieval asyncRetrieval;
    WaitOptions waitOptions;
    asyncRetrieval = (AsyncRetrieval) op;
    waitOptions = (WaitOptions) asyncRetrieval.getRetrievalOptions();
    if (waitOptions.getTimeoutSeconds() == Integer.MAX_VALUE) {
        return Integer.MAX_VALUE;
    } else {
        return (int) TimeUnit.MILLISECONDS.convert(waitOptions.getTimeoutSeconds(), TimeUnit.SECONDS);
    }
}
Also used : WaitOptions(com.ms.silverking.cloud.dht.WaitOptions)

Example 2 with WaitOptions

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

the class ClientTool method doWaitFor.

private void doWaitFor(ClientOptions options, SynchronousNamespacePerspective<String, byte[]> syncNSP, Stopwatch sw) throws OperationException, IOException {
    SynchronousNamespacePerspective<String, byte[]> ns;
    WaitOptions waitOptions;
    StoredValue<byte[]> storedValue;
    waitOptions = OptionsHelper.newWaitOptions(RetrievalType.VALUE);
    if (options.timeoutSeconds != 0) {
        waitOptions = waitOptions.timeoutSeconds(options.timeoutSeconds).timeoutResponse(options.timeoutResponse);
    }
    Log.warning("Getting value...");
    storedValue = null;
    sw.reset();
    for (int i = 0; i < options.reps; i++) {
        storedValue = syncNSP.waitFor(options.key, waitOptions);
    }
    sw.stop();
    if (storedValue == null) {
        Log.warning(noSuchValue);
    } else {
        Log.warning(new String(storedValue.getValue()));
    }
}
Also used : WaitOptions(com.ms.silverking.cloud.dht.WaitOptions) VersionConstraint(com.ms.silverking.cloud.dht.VersionConstraint)

Example 3 with WaitOptions

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

the class AsyncRetrievalOperationImpl method isFailure.

@Override
protected boolean isFailure(OpResult result) {
    switch(result) {
        case MULTIPLE:
            // multiple will only be called when checking completion of the entire operation
            // others will be called key-by-key also
            // filter no such value errors to allow for users to override
            // all other failures result in a failure
            NonExistenceResponse nonExistenceResponse;
            nonExistenceResponse = getNonExistenceResponse();
            for (OpResult _result : allResults) {
                if (_result.hasFailed(nonExistenceResponse)) {
                    return true;
                }
            }
            return false;
        case TIMEOUT:
            RetrievalOptions retrievalOptions;
            retrievalOptions = retrievalOperation.retrievalOptions();
            if (retrievalOptions.getWaitMode() == WaitMode.WAIT_FOR && ((WaitOptions) retrievalOptions).getTimeoutResponse() == TimeoutResponse.IGNORE) {
                return false;
            } else {
                return result.hasFailed();
            }
        default:
            return result.hasFailed(getNonExistenceResponse());
    }
}
Also used : RetrievalOptions(com.ms.silverking.cloud.dht.RetrievalOptions) InternalRetrievalOptions(com.ms.silverking.cloud.dht.common.InternalRetrievalOptions) OpResult(com.ms.silverking.cloud.dht.common.OpResult) WaitOptions(com.ms.silverking.cloud.dht.WaitOptions) NonExistenceResponse(com.ms.silverking.cloud.dht.NonExistenceResponse)

Aggregations

WaitOptions (com.ms.silverking.cloud.dht.WaitOptions)3 NonExistenceResponse (com.ms.silverking.cloud.dht.NonExistenceResponse)1 RetrievalOptions (com.ms.silverking.cloud.dht.RetrievalOptions)1 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)1 InternalRetrievalOptions (com.ms.silverking.cloud.dht.common.InternalRetrievalOptions)1 OpResult (com.ms.silverking.cloud.dht.common.OpResult)1