/** {@inheritDoc} */ @Override public boolean isCancelled() { return fut.isCancelled(); }
/** {@inheritDoc} */ @Override public boolean isCancelled() { return embedded.isCancelled(); }
/** {@inheritDoc} */ @Override public T get() throws ExecutionException { try { T res = fut.get(); if (fut.isCancelled()) throw new CancellationException("Task was cancelled: " + fut); return res; } catch (GridException e) { // Task cancellation may cause throwing exception. if (fut.isCancelled()) { RuntimeException ex = new CancellationException("Task was cancelled: " + fut); ex.initCause(e); throw ex; } throw new ExecutionException("Failed to get task result: " + fut, e); } }
/** {@inheritDoc} */ @SuppressWarnings({"MethodWithTooExceptionsDeclared"}) @Override public T get(long timeout, TimeUnit unit) throws ExecutionException, TimeoutException { A.ensure(timeout >= 0, "timeout >= 0"); A.notNull(unit, "unit != null"); try { T res = fut.get(unit.toMillis(timeout)); if (fut.isCancelled()) throw new CancellationException("Task was cancelled: " + fut); return res; } catch (GridFutureTimeoutException e) { TimeoutException e2 = new TimeoutException(); e2.initCause(e); throw e2; } catch (GridComputeTaskTimeoutException e) { throw new ExecutionException("Task execution timed out during waiting for task result: " + fut, e); } catch (GridException e) { // Task cancellation may cause throwing exception. if (fut.isCancelled()) { RuntimeException ex = new CancellationException("Task was cancelled: " + fut); ex.initCause(e); throw ex; } throw new ExecutionException("Failed to get task result.", e); } } }