/** {@inheritDoc} */ @Override public void onTimeout() { synchronized (mux) { if (state != State.WAITING) return; } U.warn(log, "Task has timed out: " + ses); recordTaskEvent(EVT_TASK_TIMEDOUT, "Task has timed out."); Throwable e = new GridComputeTaskTimeoutException("Task timed out (check logs for error messages): " + ses); finishTask(null, e); }
/** * Execute method on grid. * * @param subgrid Subgrid. * @param cls Joint point signature class. * @param arg GridifyArgument with all method signature parameters. * @param nodeFilter Node filter. * @param threshold Parameter that defines the minimal value below which the * execution will NOT be grid-enabled. * @param splitSize Size of elements to send in job argument. * @param timeout Execution timeout. * @return Result. * @throws GridException If execution failed. */ protected Object execute(GridProjection subgrid, Class<?> cls, GridifyRangeArgument arg, GridifyNodeFilter nodeFilter, int threshold, int splitSize, long timeout) throws GridException { long now = U.currentTimeMillis(); long end = timeout == 0 ? Long.MAX_VALUE : timeout + now; // Prevent overflow. if (end < 0) end = Long.MAX_VALUE; if (now > end) throw new GridComputeTaskTimeoutException("Timeout occurred while waiting for completion."); Collection<?> res = subgrid.compute().withTimeout(timeout == 0 ? 0L : (end - now)).execute( new GridifyDefaultRangeTask(cls, nodeFilter, threshold, splitSize, false), arg).get(); return result(arg.getMethodReturnType(), res); }
throw new GridComputeTaskTimeoutException("Timeout occurred while waiting for completion.");