allow to specify timeout as a string time value (i.e. "2s") when getting from a future

This commit is contained in:
kimchy 2010-04-11 10:26:39 +03:00
parent 9846847a61
commit 93e14e06c9
2 changed files with 11 additions and 0 deletions

View File

@ -39,6 +39,13 @@ public interface ActionFuture<T> extends Future<T> {
*/
T actionGet() throws ElasticSearchException;
/**
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just wrapping the {@link InterruptedException} with
* {@link org.elasticsearch.ElasticSearchInterruptedException}, and throwing the actual
* cause of the {@link java.util.concurrent.ExecutionException}.
*/
T actionGet(String timeout) throws ElasticSearchException;
/**
* Similar to {@link #get(long, java.util.concurrent.TimeUnit)}, just wrapping the {@link InterruptedException} with
* {@link org.elasticsearch.ElasticSearchInterruptedException}, and throwing the actual

View File

@ -111,6 +111,10 @@ public class PlainActionFuture<T> implements ActionFuture<T>, ActionListener<T>
}
}
@Override public T actionGet(String timeout) throws ElasticSearchException {
return actionGet(TimeValue.parseTimeValue(timeout, null));
}
@Override public T actionGet(long timeoutMillis) throws ElasticSearchException {
return actionGet(timeoutMillis, TimeUnit.MILLISECONDS);
}