protected Object execute()

in modules/aop-ext/src/main/java/org/apache/ignite/compute/gridify/aop/GridifySetToValueAbstractAspect.java [131:169]


    protected Object execute(Method mtd, IgniteCompute compute, Class<?> cls, GridifyRangeArgument arg,
        GridifyNodeFilter nodeFilter, int threshold, int splitSize, long timeout) throws IgniteCheckedException {
        long now = U.currentTimeMillis();

        long end = timeout == 0 ? Long.MAX_VALUE : timeout + now;

        // Prevent overflow.
        if (end < 0)
            end = Long.MAX_VALUE;

        Collection<?> res = null;

        while (true) {
            if (now > end)
                throw new ComputeTaskTimeoutCheckedException("Timeout occurred while waiting for completion.");

            GridifyRangeArgument taskArg = createGridifyArgument(arg, res);

            if (taskArg == null)
                return result(res);
            else if (taskArg.getInputSize() != UNKNOWN_SIZE && taskArg.getInputSize() <= threshold) {
                // Note, that we can't cancel by timeout locally started method.
                try {
                    mtd.setAccessible(true);

                    return mtd.invoke(arg.getTarget(), taskArg.getMethodParameters());
                }
                catch (IllegalAccessException | InvocationTargetException e) {
                    throw new IgniteCheckedException("Failed to execute method locally.", e);
                }
            }
            else {
                res = compute.withTimeout(timeout == 0 ? 0L : (end - now)).execute(
                    new GridifyDefaultRangeTask(cls, nodeFilter, threshold, splitSize, true), taskArg);
            }

            now = U.currentTimeMillis();
        }
    }