/** * Creates a new instance. * @param script target script * @param context current execution context * @param handler handler which will attempt to resolve placeholders * @throws InterruptedException if interrupted to prepare this resolver * @throws IOException if failed to prepare replacements * @throws IllegalArgumentException if some parameters were {@code null} */ public PlaceholderResolver( ExecutionScript script, ExecutionContext context, ExecutionScriptHandler<?> handler) throws InterruptedException, IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); //$NON-NLS-1$ } if (context == null) { throw new IllegalArgumentException("context must not be null"); //$NON-NLS-1$ } if (handler == null) { throw new IllegalArgumentException("handler must not be null"); //$NON-NLS-1$ } replacements = new HashMap<>(); replacements.put(PLACEHOLDER_HOME, getAsakusaHomePath(context, script, handler)); replacements.put(PLACEHOLDER_EXECUTION_ID, context.getExecutionId()); replacements.put(PLACEHOLDER_ARGUMENTS, context.getArgumentsAsString()); }
private List<String> buildExecutionCommand( ExecutionContext context, HadoopScript script) throws IOException, InterruptedException { assert context != null; assert script != null; List<String> command = new ArrayList<>(); command.add(getCommand(context, PATH_EXECUTE, script)); command.add(script.getClassName()); command.add(context.getBatchId()); command.add(context.getFlowId()); command.add(context.getExecutionId()); command.add(context.getArgumentsAsString()); Map<String, String> props = buildHadoopProperties(context, script); for (Map.Entry<String, String> entry : props.entrySet()) { command.add("-D"); command.add(MessageFormat.format("{0}={1}", entry.getKey(), entry.getValue())); } return command; }