use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.
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 co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.
the class DescribeStreamCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString()));
StreamProperties config = streamClient.getConfig(streamId);
Table table = Table.builder().setHeader("ttl", "format", "schema", "notification.threshold.mb", "description").setRows(ImmutableList.of(config), new RowMaker<StreamProperties>() {
@Override
public List<?> makeRow(StreamProperties object) {
FormatSpecification format = object.getFormat();
return Lists.newArrayList(object.getTTL(), format.getName(), format.getSchema().toString(), object.getNotificationThresholdMB(), object.getDescription());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.
the class GetServiceEndpointsCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
ServiceId serviceId = new ServiceId(parseProgramId(arguments, ElementType.SERVICE));
List<ServiceHttpEndpoint> endpoints = serviceClient.getEndpoints(serviceId);
Table table = Table.builder().setHeader("method", "path").setRows(endpoints, new RowMaker<ServiceHttpEndpoint>() {
@Override
public List<?> makeRow(ServiceHttpEndpoint endpoint) {
return Lists.newArrayList(endpoint.getMethod(), endpoint.getPath());
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.
the class GetStreamEventsCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
long currentTime = System.currentTimeMillis();
StreamId streamId = cliConfig.getCurrentNamespace().stream(arguments.get(ArgumentName.STREAM.toString()));
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);
// Get a list of stream events and prints it.
List<StreamEvent> events = streamClient.getEvents(streamId, startTime, endTime, limit, Lists.<StreamEvent>newArrayList());
Table table = Table.builder().setHeader("timestamp", "headers", "body size", "body").setRows(events, new RowMaker<StreamEvent>() {
@Override
public List<?> makeRow(StreamEvent event) {
long bodySize = event.getBody().remaining();
return Lists.newArrayList(event.getTimestamp(), event.getHeaders().isEmpty() ? "" : formatHeader(event.getHeaders()), bodySize, getBody(event.getBody()));
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
output.printf("Fetched %d events from stream '%s'", events.size(), streamId.getEntityName());
output.println();
}
use of co.cask.cdap.cli.util.RowMaker in project cdap by caskdata.
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);
}
Aggregations