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);
}
}
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()));
}
}
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());
}
}
Aggregations