use of co.cask.cdap.cli.exception.CommandInputError in project cdap by caskdata.
the class GetWorkflowCurrentRunCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\.");
ApplicationId appId = cliConfig.getCurrentNamespace().app(programIdParts[0]);
List<WorkflowActionNode> nodes;
if (elementType.getProgramType() != null) {
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
String workflowId = programIdParts[1];
String runId = arguments.get(ArgumentName.RUN_ID.toString());
nodes = programClient.getWorkflowCurrent(appId.workflow(workflowId), runId);
} else {
throw new IllegalArgumentException("Unrecognized program element type for current runs: " + elementType);
}
Table table = Table.builder().setHeader("node id", "program name", "program type").setRows(nodes, new RowMaker<WorkflowActionNode>() {
@Override
public List<?> makeRow(WorkflowActionNode object) {
return Lists.newArrayList(object.getNodeId(), object.getProgram().getProgramName(), object.getProgram().getProgramType());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of co.cask.cdap.cli.exception.CommandInputError in project cdap by caskdata.
the class GetWorkflowLocalDatasetsCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream printStream) throws Exception {
String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\.");
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
ProgramRunId programRunId = cliConfig.getCurrentNamespace().app(programIdParts[0]).workflow(programIdParts[1]).run(arguments.get(ArgumentName.RUN_ID.toString()));
Table table = getWorkflowLocalDatasets(programRunId);
cliConfig.getTableRenderer().render(cliConfig, printStream, table);
}
use of co.cask.cdap.cli.exception.CommandInputError in project cdap by caskdata.
the class GetWorkflowStateCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream printStream) throws Exception {
String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\.");
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
ProgramRunId programRunId = cliConfig.getCurrentNamespace().app(programIdParts[0]).workflow(programIdParts[1]).run(arguments.get(ArgumentName.RUN_ID.toString()));
Table table = getWorkflowNodeStates(programRunId);
cliConfig.getTableRenderer().render(cliConfig, printStream, table);
}
use of co.cask.cdap.cli.exception.CommandInputError in project cdap by caskdata.
the class GetWorkflowTokenCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\.");
ApplicationId appId = cliConfig.getCurrentNamespace().app(programIdParts[0]);
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
ProgramId workflowId = appId.workflow(programIdParts[1]);
ProgramRunId runId = workflowId.run(arguments.get(ArgumentName.RUN_ID.toString()));
WorkflowToken.Scope workflowTokenScope = null;
if (arguments.hasArgument(ArgumentName.WORKFLOW_TOKEN_SCOPE.toString())) {
String scope = arguments.get(ArgumentName.WORKFLOW_TOKEN_SCOPE.toString()).toUpperCase();
workflowTokenScope = WorkflowToken.Scope.valueOf(scope);
}
String key = null;
if (arguments.hasArgument(ArgumentName.WORKFLOW_TOKEN_KEY.toString())) {
key = arguments.get(ArgumentName.WORKFLOW_TOKEN_KEY.toString());
}
Table table;
if (arguments.hasArgument(ArgumentName.WORKFLOW_NODE.toString())) {
table = getWorkflowToken(runId, workflowTokenScope, key, arguments.get(ArgumentName.WORKFLOW_NODE.toString()));
} else {
table = getWorkflowToken(runId, workflowTokenScope, key);
}
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of co.cask.cdap.cli.exception.CommandInputError in project cdap by caskdata.
the class GetProgramRunsCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\.");
String appId = programIdParts[0];
long currentTime = System.currentTimeMillis();
long startTime = getTimestamp(arguments.getOptional(ArgumentName.START_TIME.toString(), "min"), currentTime);
long endTime = getTimestamp(arguments.getOptional(ArgumentName.END_TIME.toString(), "max"), currentTime);
int limit = arguments.getIntOptional(ArgumentName.LIMIT.toString(), Integer.MAX_VALUE);
List<RunRecord> records;
if (elementType.getProgramType() != null) {
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
String programName = programIdParts[1];
ProgramId programId = cliConfig.getCurrentNamespace().app(appId).program(elementType.getProgramType(), programName);
if (arguments.hasArgument(ArgumentName.RUN_STATUS.toString())) {
records = programClient.getProgramRuns(programId, arguments.get(ArgumentName.RUN_STATUS.toString()), startTime, endTime, limit);
} else {
records = programClient.getAllProgramRuns(programId, startTime, endTime, limit);
}
} else {
throw new IllegalArgumentException("Unrecognized program element type for history: " + elementType);
}
Table table = Table.builder().setHeader("pid", "end status", "start", "stop").setRows(records, new RowMaker<RunRecord>() {
@Override
public List<?> makeRow(RunRecord object) {
return Lists.newArrayList(object.getPid(), object.getStatus(), object.getStartTs(), object.getStatus().name().equals("RUNNING") ? "" : object.getStopTs());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Aggregations