@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(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)); } } }