@Override public String getId() { return script.getId(); }
@Override public String getJobLabel() { return script.getId(); }
private String getAsakusaHomePath( ExecutionContext context, ExecutionScript script, ExecutionScriptHandler<?> handler) throws IOException, InterruptedException { assert context != null; assert script != null; assert handler != null; String inScript = script.getEnvironmentVariables().get(ENV_ASAKUSA_HOME); if (inScript != null && inScript.equals(PLACEHOLDER_HOME) == false) { LOG.debug("Asakusa location is found in script: {} -> {}", script.getId(), inScript); return inScript; } Map<String, String> environmentVariables = handler.getEnvironmentVariables(context, script); String inHandler = environmentVariables.get(ENV_ASAKUSA_HOME); if (inHandler != null) { LOG.debug("Asakusa location is found in handler: {} -> {}", script.getId(), inHandler); return inHandler; } throw new IOException(MessageFormat.format( "{0} is not defined for \"{1}\"", ENV_ASAKUSA_HOME, handler.getHandlerId())); }
@Override String getKey(ExecutionContext context, ExecutionScript script) { if (script == null) { return null; } return MessageFormat.format( "{0}.{1}.{2}", context.getFlowId(), context.getPhase().getSymbol(), script.getId()); } },
private ExecutionScriptHandler<T> resolve( ExecutionContext context, ExecutionScript script) throws IOException { assert context != null; Properties batchConf = getBatchConf(context, script); String key = findKey(context, script, batchConf); if (key != null) { ExecutionScriptHandler<T> target = delegations.get(key); if (target != null) { return target; } throw new IOException(MessageFormat.format( "Invalid dispatch target for multidispatch plugin: " + "{4} (batchId={0}, flowId={1}, phase={2}, stageId={3})", context.getBatchId(), context.getFlowId(), context.getPhase(), script == null ? LABEL_UNDEFINED : script.getId(), key)); } ExecutionScriptHandler<T> defaultTarget = delegations.get(PREFIX_DEFAULT); assert defaultTarget != null; return defaultTarget; }
/** * Computes the tracking ID. * @param context target context * @param script target script * @return the operation ID * @since 0.5.0 */ public static String computeTrackingId(ExecutionContext context, ExecutionScript script) { return MessageFormat.format( "YAESS/{0}/{1}/{2}/{3}/{4}", context.getBatchId(), context.getFlowId(), context.getPhase(), context.getExecutionId(), script.getId()); }
for (ExecutionScript script : phase.getValue()) { String scriptPrefix = getPrefix(getId(), phase.getKey(), String.format("%04d", index++)); properties.setProperty(scriptPrefix + KEY_ID, script.getId()); properties.setProperty(scriptPrefix + KEY_KIND, script.getKind().getSymbol()); properties.setProperty(scriptPrefix + KEY_BLOCKERS, join(script.getBlockerIds()));
@Override public void execute( ExecutionMonitor monitor, ExecutionContext context, T script) throws InterruptedException, IOException { ExecutionScriptHandler<T> target = resolve(context, script); assert target != null; YSLOG.info("I01002", target.getHandlerId(), context.getBatchId(), context.getFlowId(), context.getPhase(), context.getExecutionId(), script.getId()); target.execute(monitor, context, script); }