@Test public void execute_flow() throws Exception { ProfileBuilder builder = new ProfileBuilder(folder.getRoot()); File profile = builder.getProfile(); File script = builder.getScript(); List<String> arguments = new ArrayList<>(); Collections.addAll(arguments, "-profile", profile.getAbsolutePath()); Collections.addAll(arguments, "-script", script.getAbsolutePath()); Collections.addAll(arguments, "-batch", "tbatch"); Collections.addAll(arguments, "-flow", "right"); Collections.addAll(arguments, "-execution", "texec"); int exit = Yaess.execute(arguments.toArray(new String[arguments.size()])); assertThat(exit, is(0)); List<Record> records = SerialExecutionTracker.get(builder.trackingId); assertThat(flow(records, "testing"), hasSize(0)); assertThat(flow(records, "left"), hasSize(0)); assertThat(flow(records, "right").size(), is(greaterThan(0))); assertThat(flow(records, "last"), hasSize(0)); List<Record> flow = flow(records, "right"); assertThat(flow.get(0).context.getExecutionId(), is("texec")); }
static int execute(String[] args) { assert args != null; Configuration conf; try { conf = parseConfiguration(args); } catch (Exception e) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(Integer.MAX_VALUE); formatter.printHelp( MessageFormat.format( "java -classpath ... {0}", Yaess.class.getName()), OPTIONS, true); System.out.println("Phase name is one of:"); for (ExecutionPhase phase : ExecutionPhase.values()) { System.out.printf(" %s%n", phase.getSymbol()); } YSLOG.error(e, "E00001", Arrays.toString(args)); return 1; } try { ExecutionTask task; try { Map<String, Blob> blobs = new LinkedHashMap<>(); for (Extension extension : conf.extensions) { blobs.put(extension.getName(), extension.getData()); } task = ExecutionTask.load(conf.profile, conf.script, conf.arguments, conf.definitions, blobs); } catch (Exception e) { YSLOG.error(e, "E00002", conf); return 1; } YSLOG.info("I00001", conf); switch (conf.mode) { case BATCH: task.executeBatch(conf.batchId); break; case FLOW: task.executeFlow(conf.batchId, conf.flowId, conf.executionId); break; case PHASE: task.executePhase(conf.batchId, conf.flowId, conf.executionId, conf.phase); break; default: throw new AssertionError(conf.mode); } return 0; } catch (ExitCodeException e) { YSLOG.error("E00003", conf); return 1; } catch (Exception e) { YSLOG.error(e, "E00003", conf); return 1; } finally { for (Extension ext : conf.extensions) { try { ext.close(); } catch (IOException e) { LOG.debug("error occurred while closing extension: {}", ext, e); } } } }
Yaess { static int execute(String[] args) { assert args != null; Configuration conf; try { conf = parseConfiguration(args); } catch (Exception e) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(Integer.MAX_VALUE); formatter.printHelp( MessageFormat.format( "java -classpath ... {0}", Yaess.class.getName()), OPTIONS, true); System.out.println("Phase name is one of:"); for (ExecutionPhase phase : ExecutionPhase.values()) { System.out.printf(" %s%n", phase.getSymbol()); } YSLOG.error(e, "E00001", Arrays.toString(args)); return 1; } try { ExecutionTask task; try { Map<String, Blob> blobs = new LinkedHashMap<>(); for (Extension extension : conf.extensions) { blobs.put(extension.getName(), extension.getData()); } task = ExecutionTask.load(conf.profile, conf.script, conf.arguments, conf.definitions, blobs); } catch (Exception e) { YSLOG.error(e, "E00002", conf); return 1; } YSLOG.info("I00001", conf); switch (conf.mode) { case BATCH: task.executeBatch(conf.batchId); break; case FLOW: task.executeFlow(conf.batchId, conf.flowId, conf.executionId); break; case PHASE: task.executePhase(conf.batchId, conf.flowId, conf.executionId, conf.phase); break; default: throw new AssertionError(conf.mode); } return 0; } catch (ExitCodeException e) { YSLOG.error("E00003", conf); return 1; } catch (Exception e) { YSLOG.error(e, "E00003", conf); return 1; } finally { for (Extension ext : conf.extensions) { try { ext.close(); } catch (IOException e) { LOG.debug("error occurred while closing extension: {}", ext, e); } } } } }
Yaess { static int execute(String[] args) { assert args != null; Configuration conf; try { conf = parseConfiguration(args); } catch (Exception e) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(Integer.MAX_VALUE); formatter.printHelp( MessageFormat.format( "java -classpath ... {0}", Yaess.class.getName()), OPTIONS, true); System.out.println("Phase name is one of:"); for (ExecutionPhase phase : ExecutionPhase.values()) { System.out.printf(" %s%n", phase.getSymbol()); } YSLOG.error(e, "E00001", Arrays.toString(args)); return 1; } try { ExecutionTask task; try { Map<String, Blob> blobs = new LinkedHashMap<>(); for (Extension extension : conf.extensions) { blobs.put(extension.getName(), extension.getData()); } task = ExecutionTask.load(conf.profile, conf.script, conf.arguments, conf.definitions, blobs); } catch (Exception e) { YSLOG.error(e, "E00002", conf); return 1; } YSLOG.info("I00001", conf); switch (conf.mode) { case BATCH: task.executeBatch(conf.batchId); break; case FLOW: task.executeFlow(conf.batchId, conf.flowId, conf.executionId); break; case PHASE: task.executePhase(conf.batchId, conf.flowId, conf.executionId, conf.phase); break; default: throw new AssertionError(conf.mode); } return 0; } catch (ExitCodeException e) { YSLOG.error("E00003", conf); return 1; } catch (Exception e) { YSLOG.error(e, "E00003", conf); return 1; } finally { for (Extension ext : conf.extensions) { try { ext.close(); } catch (IOException e) { LOG.debug("error occurred while closing extension: {}", ext, e); } } } } private  Yaess(); }
Yaess { static int execute(String[] args) { assert args != null; Configuration conf; try { conf = parseConfiguration(args); } catch (Exception e) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(Integer.MAX_VALUE); formatter.printHelp( MessageFormat.format( "java -classpath ... {0}", Yaess.class.getName()), OPTIONS, true); System.out.println("Phase name is one of:"); for (ExecutionPhase phase : ExecutionPhase.values()) { System.out.printf(" %s%n", phase.getSymbol()); } YSLOG.error(e, "E00001", Arrays.toString(args)); return 1; } try { ExecutionTask task; try { Map<String, Blob> blobs = new LinkedHashMap<>(); for (Extension extension : conf.extensions) { blobs.put(extension.getName(), extension.getData()); } task = ExecutionTask.load(conf.profile, conf.script, conf.arguments, conf.definitions, blobs); } catch (Exception e) { YSLOG.error(e, "E00002", conf); return 1; } YSLOG.info("I00001", conf); switch (conf.mode) { case BATCH: task.executeBatch(conf.batchId); break; case FLOW: task.executeFlow(conf.batchId, conf.flowId, conf.executionId); break; case PHASE: task.executePhase(conf.batchId, conf.flowId, conf.executionId, conf.phase); break; default: throw new AssertionError(conf.mode); } return 0; } catch (ExitCodeException e) { YSLOG.error("E00003", conf); return 1; } catch (Exception e) { YSLOG.error(e, "E00003", conf); return 1; } finally { for (Extension ext : conf.extensions) { try { ext.close(); } catch (IOException e) { LOG.debug("error occurred while closing extension: {}", ext, e); } } } } private  Yaess(); static void main(String... args); }
Yaess { static int execute(String[] args) { assert args != null; Configuration conf; try { conf = parseConfiguration(args); } catch (Exception e) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(Integer.MAX_VALUE); formatter.printHelp( MessageFormat.format( "java -classpath ... {0}", Yaess.class.getName()), OPTIONS, true); System.out.println("Phase name is one of:"); for (ExecutionPhase phase : ExecutionPhase.values()) { System.out.printf(" %s%n", phase.getSymbol()); } YSLOG.error(e, "E00001", Arrays.toString(args)); return 1; } try { ExecutionTask task; try { Map<String, Blob> blobs = new LinkedHashMap<>(); for (Extension extension : conf.extensions) { blobs.put(extension.getName(), extension.getData()); } task = ExecutionTask.load(conf.profile, conf.script, conf.arguments, conf.definitions, blobs); } catch (Exception e) { YSLOG.error(e, "E00002", conf); return 1; } YSLOG.info("I00001", conf); switch (conf.mode) { case BATCH: task.executeBatch(conf.batchId); break; case FLOW: task.executeFlow(conf.batchId, conf.flowId, conf.executionId); break; case PHASE: task.executePhase(conf.batchId, conf.flowId, conf.executionId, conf.phase); break; default: throw new AssertionError(conf.mode); } return 0; } catch (ExitCodeException e) { YSLOG.error("E00003", conf); return 1; } catch (Exception e) { YSLOG.error(e, "E00003", conf); return 1; } finally { for (Extension ext : conf.extensions) { try { ext.close(); } catch (IOException e) { LOG.debug("error occurred while closing extension: {}", ext, e); } } } } private  Yaess(); static void main(String... args);  }