@Override protected ExecuteResult doWork(ExecutableContext context) throws ExecuteException { List<? extends Executable> executables = getTasks(); final int size = executables.size(); for (int i = 0; i < size; ++i) { Executable subTask = executables.get(i); ExecutableState state = subTask.getStatus(); if (state == ExecutableState.RUNNING) { // there is already running subtask, no need to start a new subtask break; } else if (state == ExecutableState.STOPPED) { // the job is paused break; } else if (state == ExecutableState.ERROR) { throw new IllegalStateException( "invalid subtask state, subtask:" + subTask.getName() + ", state:" + subTask.getStatus()); } if (subTask.isRunnable()) { return subTask.execute(context); } } return new ExecuteResult(ExecuteResult.State.SUCCEED); }
private static void assertJobEqual(Executable one, Executable another) { assertEquals(one.getClass(), another.getClass()); assertEquals(one.getId(), another.getId()); assertEquals(one.getStatus(), another.getStatus()); assertEquals(one.isRunnable(), another.isRunnable()); assertEquals(one.getOutput(), another.getOutput()); assertTrue((one.getParams() == null && another.getParams() == null) || (one.getParams() != null && another.getParams() != null)); if (one.getParams() != null) { assertEquals(one.getParams().size(), another.getParams().size()); for (String key : one.getParams().keySet()) { assertEquals(one.getParams().get(key), another.getParams().get(key)); } } if (one instanceof ChainedExecutable) { assertTrue(another instanceof ChainedExecutable); List<? extends Executable> onesSubs = ((ChainedExecutable) one).getTasks(); List<? extends Executable> anotherSubs = ((ChainedExecutable) another).getTasks(); assertTrue((onesSubs == null && anotherSubs == null) || (onesSubs != null && anotherSubs != null)); if (onesSubs != null) { assertEquals(onesSubs.size(), anotherSubs.size()); for (int i = 0; i < onesSubs.size(); ++i) { assertJobEqual(onesSubs.get(i), anotherSubs.get(i)); } } } } }
@Override protected ExecuteResult doWork(ExecutableContext context) throws ExecuteException { List<? extends Executable> executables = getTasks(); final int size = executables.size(); for (int i = 0; i < size; ++i) { Executable subTask = executables.get(i); if (subTask.isRunnable()) { return subTask.execute(context); } } return new ExecuteResult(ExecuteResult.State.SUCCEED, null); }
private static void assertJobEqual(Executable one, Executable another) { assertEquals(one.getClass(), another.getClass()); assertEquals(one.getId(), another.getId()); assertEquals(one.getStatus(), another.getStatus()); assertEquals(one.isRunnable(), another.isRunnable()); assertEquals(one.getOutput(), another.getOutput()); assertTrue((one.getParams() == null && another.getParams() == null) || (one.getParams() != null && another.getParams() != null)); if (one.getParams() != null) { assertEquals(one.getParams().size(), another.getParams().size()); for (String key : one.getParams().keySet()) { assertEquals(one.getParams().get(key), another.getParams().get(key)); } } if (one instanceof ChainedExecutable) { assertTrue(another instanceof ChainedExecutable); List<? extends Executable> onesSubs = ((ChainedExecutable) one).getTasks(); List<? extends Executable> anotherSubs = ((ChainedExecutable) another).getTasks(); assertTrue((onesSubs == null && anotherSubs == null) || (onesSubs != null && anotherSubs != null)); if (onesSubs != null) { assertEquals(onesSubs.size(), anotherSubs.size()); for (int i = 0; i < onesSubs.size(); ++i) { assertJobEqual(onesSubs.get(i), anotherSubs.get(i)); } } } } }
@Override protected ExecuteResult doWork(ExecutableContext context) throws ExecuteException { List<? extends Executable> executables = getTasks(); final int size = executables.size(); for (int i = 0; i < size; ++i) { Executable subTask = executables.get(i); if (subTask.isRunnable()) { return subTask.execute(context); } } return new ExecuteResult(ExecuteResult.State.SUCCEED, null); }
@Override protected ExecuteResult doWork(ExecutableContext context) throws ExecuteException { List<? extends Executable> executables = getTasks(); final int size = executables.size(); for (int i = 0; i < size; ++i) { Executable subTask = executables.get(i); ExecutableState state = subTask.getStatus(); if (state == ExecutableState.RUNNING) { // there is already running subtask, no need to start a new subtask break; } else if (state == ExecutableState.STOPPED) { // the job is paused break; } else if (state == ExecutableState.ERROR) { throw new IllegalStateException( "invalid subtask state, subtask:" + subTask.getName() + ", state:" + subTask.getStatus()); } if (subTask.isRunnable()) { return subTask.execute(context); } } return new ExecuteResult(ExecuteResult.State.SUCCEED); }