use of io.cdap.cdap.cli.util.RowMaker in project cdap by cdapio.
the class DescribeDatasetInstanceCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
DatasetId instance = cliConfig.getCurrentNamespace().dataset(arguments.get(ArgumentName.DATASET.toString()));
DatasetMeta meta = datasetClient.get(instance);
Table table = Table.builder().setHeader("hive table", "spec", "type", "principal").setRows(ImmutableList.of(meta), new RowMaker<DatasetMeta>() {
@Override
public List<?> makeRow(DatasetMeta object) {
return Lists.newArrayList(object.getHiveTableName(), GSON.toJson(object.getSpec()), GSON.toJson(object.getType()), object.getOwnerPrincipal());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.util.RowMaker in project cdap by cdapio.
the class DescribeDatasetModuleCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
DatasetModuleId moduleId = cliConfig.getCurrentNamespace().datasetModule(arguments.get(ArgumentName.DATASET_MODULE.toString()));
DatasetModuleMeta datasetModuleMeta = datasetModuleClient.get(moduleId);
Table table = Table.builder().setHeader("name", "className", "jarLocationPath", "types", "usesModules", "usedByModules").setRows(ImmutableList.of(datasetModuleMeta), new RowMaker<DatasetModuleMeta>() {
@Override
public List<?> makeRow(DatasetModuleMeta object) {
return Lists.newArrayList(object.getName(), object.getClassName(), object.getJarLocationPath(), Joiner.on(", ").join(object.getTypes()), Joiner.on(", ").join(object.getUsesModules()), Joiner.on(", ").join(object.getUsedByModules()));
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.util.RowMaker in project cdap by cdapio.
the class DescribeDatasetTypeCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
DatasetTypeId type = cliConfig.getCurrentNamespace().datasetType(arguments.get(ArgumentName.DATASET_TYPE.toString()));
DatasetTypeMeta datasetTypeMeta = datasetTypeClient.get(type);
Table table = Table.builder().setHeader("name", "modules").setRows(ImmutableList.of(datasetTypeMeta), new RowMaker<DatasetTypeMeta>() {
@Override
public List<?> makeRow(DatasetTypeMeta object) {
return Lists.newArrayList(object.getName(), Joiner.on(", ").join(object.getModules()));
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.util.RowMaker in project cdap by cdapio.
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", "init time", "start time", "stop time").setRows(records, new RowMaker<RunRecord>() {
@Override
public List<?> makeRow(RunRecord object) {
return Lists.newArrayList(object.getPid(), object.getStatus(), object.getStartTs(), object.getRunTs() == null ? "" : object.getRunTs(), object.getStopTs() == null ? "" : object.getStopTs());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of io.cdap.cdap.cli.util.RowMaker in project cdap by cdapio.
the class DescribeAppCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
ApplicationId appId = parseApplicationId(arguments);
List<ProgramRecord> programsList = applicationClient.listPrograms(appId);
Table table = Table.builder().setHeader("type", "id", "description").setRows(programsList, new RowMaker<ProgramRecord>() {
@Override
public List<?> makeRow(ProgramRecord object) {
return Lists.newArrayList(object.getType().getPrettyName(), object.getName(), object.getDescription());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Aggregations