@Override public void configurePipeline(PipelineConfigurer pipelineConfigurer) { delegate.configurePipeline(pipelineConfigurer); } }
@Override public void run(ActionContext context) throws Exception { delegate.run(context); }
@Override public void run(ActionContext context) throws Exception { context.execute(new TxRunnable() { @Override public void run(DatasetContext context) throws Exception { FileSet sourceFileSet = context.getDataset(conf.sourceFileset); FileSet destinationFileSet = context.getDataset(conf.destinationFileset); Pattern pattern = Pattern.compile(conf.filterRegex); for (Location sourceFile : sourceFileSet.getBaseLocation().list()) { if (pattern.matcher(sourceFile.getName()).matches()) { Location destFile = destinationFileSet.getBaseLocation().append(sourceFile.getName()); sourceFile.renameTo(destFile); } } } }); }
@Override public void run(ActionContext context) throws Exception { context.execute(new TxRunnable() { @Override public void run(DatasetContext context) throws Exception { Table table = context.getDataset(config.tableName); Put put = new Put(config.rowKey); put.add(config.columnKey, config.value); table.put(put); } }); // Set the same value in the arguments as well. context.getArguments().set(config.rowKey + config.columnKey, config.value); if (config.argumentKey != null && config.argumentValue != null) { if (!context.getArguments().get(config.argumentKey).equals(config.argumentValue)) { throw new IllegalStateException(String.format("Expected %s to be present in the argument map with value %s.", config.argumentKey, config.argumentValue)); } } }
context.getArguments().set(config.outputKey, out); } finally { connection.close();
@Override public boolean apply(final ConditionContext context) throws Exception { String propertyName = config.name + ".branch.to.execute"; String propertyValue = context.getArguments().get(propertyName); // write stage statistics if table name is provided if (config.tableName != null) { context.execute(new TxRunnable() { @Override public void run(DatasetContext datasetContext) throws Exception { Table table = datasetContext.getDataset(config.tableName); for (Map.Entry<String, StageStatistics> entry : context.getStageStatistics().entrySet()) { String stageName = entry.getKey(); StageStatistics statistics = entry.getValue(); Put put = new Put("stats"); put.add(stageName + ".input.records", String.valueOf(statistics.getInputRecordsCount())); put.add(stageName + ".output.records", String.valueOf(statistics.getOutputRecordsCount())); put.add(stageName + ".error.records", String.valueOf(statistics.getErrorRecordsCount())); table.put(put); } } }); } return propertyValue != null && propertyValue.equals("true"); }
@Override public void run() throws Exception { CustomActionContext context = getContext(); Map<String, String> properties = context.getSpecification().getProperties(); BatchPhaseSpec phaseSpec = GSON.fromJson(properties.get(Constants.PIPELINEID), BatchPhaseSpec.class); PipelinePhase phase = phaseSpec.getPhase(); StageSpec stageSpec = phase.iterator().next(); PluginContext pluginContext = new PipelinePluginContext(context, metrics, phaseSpec.isStageLoggingEnabled(), phaseSpec.isProcessTimingEnabled()); PipelineRuntime pipelineRuntime = new PipelineRuntime(context, metrics); Action action = pluginContext.newPluginInstance(stageSpec.getName(), new DefaultMacroEvaluator(pipelineRuntime.getArguments(), context.getLogicalStartTime(), context, context.getNamespace())); ActionContext actionContext = new BasicActionContext(context, pipelineRuntime, stageSpec); if (!context.getDataTracer(stageSpec.getName()).isEnabled()) { action.run(actionContext); } WorkflowToken token = context.getWorkflowToken(); if (token == null) { throw new IllegalStateException("WorkflowToken cannot be null when action is executed through Workflow."); } for (Map.Entry<String, String> entry : pipelineRuntime.getArguments().getAddedArguments().entrySet()) { token.put(entry.getKey(), entry.getValue()); } } }