use of io.cdap.cdap.cli.exception.CommandInputError in project cdap by caskdata.
the class GetScheduleStatusCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream printStream) throws Exception {
String[] programIdParts = arguments.get(ElementType.SCHEDULE.getArgumentName().toString()).split("\\.");
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
String appId = programIdParts[0];
String scheduleName = programIdParts[1];
ScheduleId scheduleId = cliConfig.getCurrentNamespace().app(appId).schedule(scheduleName);
printStream.println(scheduleClient.getStatus(scheduleId));
}
use of io.cdap.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 io.cdap.cdap.cli.exception.CommandInputError in project cdap by caskdata.
the class GetProgramInstancesCommand method perform.
@Override
@SuppressWarnings("deprecation")
public void perform(Arguments arguments, PrintStream output) throws Exception {
String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\.");
ApplicationId appId = cliConfig.getCurrentNamespace().app(programIdParts[0]);
int instances;
switch(elementType) {
case WORKER:
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
String workerId = programIdParts[1];
ProgramId worker = appId.worker(workerId);
instances = programClient.getWorkerInstances(worker);
break;
case SERVICE:
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
String serviceName = programIdParts[1];
instances = programClient.getServiceInstances(appId.service(serviceName));
break;
default:
// TODO: remove this
throw new IllegalArgumentException("Unrecognized program element type for scaling: " + elementType);
}
output.println(instances);
}
use of io.cdap.cdap.cli.exception.CommandInputError in project cdap by caskdata.
the class GetProgramLiveInfoCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\.");
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
String appId = programIdParts[0];
String programName = programIdParts[1];
ProgramId program = cliConfig.getCurrentNamespace().app(appId).program(elementType.getProgramType(), programName);
DistributedProgramLiveInfo liveInfo = programClient.getLiveInfo(program);
if (liveInfo == null) {
output.println("No live info found");
return;
}
Table table = Table.builder().setHeader("app", "type", "id", "runtime", "yarn app id").setRows(ImmutableList.of(liveInfo), new RowMaker<DistributedProgramLiveInfo>() {
@Override
public List<?> makeRow(DistributedProgramLiveInfo object) {
return Lists.newArrayList(object.getApp(), object.getType(), object.getName(), object.getRuntime(), object.getYarnAppId());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
if (liveInfo.getContainers() != null) {
Table containersTable = Table.builder().setHeader("containers", "instance", "host", "container", "memory", "virtual cores", "debug port").setRows(liveInfo.getContainers(), new RowMaker<Containers.ContainerInfo>() {
@Override
public List<?> makeRow(Containers.ContainerInfo object) {
return Lists.newArrayList("", object.getInstance(), object.getHost(), object.getContainer(), object.getMemory(), object.getVirtualCores(), object.getDebugPort());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, containersTable);
}
}
use of io.cdap.cdap.cli.exception.CommandInputError in project cdap by caskdata.
the class GetProgramStatusCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
String[] programIdParts = arguments.get(elementType.getArgumentName().toString()).split("\\.");
if (programIdParts.length < 2) {
throw new CommandInputError(this);
}
String appId = programIdParts[0];
String programName = programIdParts[1];
ProgramId programId = cliConfig.getCurrentNamespace().app(appId).program(elementType.getProgramType(), programName);
String status = programClient.getStatus(programId);
output.println(status);
}
Aggregations