use of io.confluent.ksql.cli.console.table.Table in project ksql by confluentinc.
the class Console method printSourceDescription.
private void printSourceDescription(final SourceDescription source) {
final boolean isTable = source.getType().equalsIgnoreCase("TABLE");
writer().println(String.format("%-20s : %s", "Name", source.getName()));
if (!source.isExtended()) {
printSchema(source.getWindowType(), source.getFields(), isTable);
writer().println("For runtime statistics and query details run: DESCRIBE <Stream,Table> EXTENDED;");
return;
}
writer().println(String.format("%-20s : %s", "Type", source.getType()));
printTopicInfo(source);
writer().println(String.format("%-20s : %s", "Statement", source.getStatement()));
writer().println("");
printSchema(source.getWindowType(), source.getFields(), isTable);
printSourceConstraints(source.getSourceConstraints());
printQueries(source.getReadQueries(), source.getType(), "read");
printQueries(source.getWriteQueries(), source.getType(), "write");
printStatistics(source);
writer().println(String.format("(%s)", "Statistics of the local KSQL server interaction with the Kafka topic " + source.getTopic()));
if (!source.getQueryOffsetSummaries().isEmpty()) {
writer().println();
writer().println("Consumer Groups summary:");
for (QueryOffsetSummary entry : source.getQueryOffsetSummaries()) {
writer().println();
writer().println(String.format("%-20s : %s", "Consumer Group", entry.getGroupId()));
if (entry.getTopicSummaries().isEmpty()) {
writer().println("<no offsets committed by this group yet>");
}
for (QueryTopicOffsetSummary topicSummary : entry.getTopicSummaries()) {
writer().println();
writer().println(String.format("%-20s : %s", "Kafka topic", topicSummary.getKafkaTopic()));
writer().println(String.format("%-20s : %s", "Max lag", topicSummary.getOffsets().stream().mapToLong(s -> s.getLogEndOffset() - s.getConsumerOffset()).max().orElse(0)));
writer().println("");
final Table taskTable = new Table.Builder().withColumnHeaders(ImmutableList.of("Partition", "Start Offset", "End Offset", "Offset", "Lag")).withRows(topicSummary.getOffsets().stream().map(offset -> ImmutableList.of(String.valueOf(offset.getPartition()), String.valueOf(offset.getLogStartOffset()), String.valueOf(offset.getLogEndOffset()), String.valueOf(offset.getConsumerOffset()), String.valueOf(offset.getLogEndOffset() - offset.getConsumerOffset())))).build();
taskTable.print(this);
}
}
}
}
use of io.confluent.ksql.cli.console.table.Table in project ksql by confluentinc.
the class PropertiesListTableBuilderTest method shouldHandleClientOverwrittenProperties.
@Test
public void shouldHandleClientOverwrittenProperties() {
// Given:
final PropertiesList propList = new PropertiesList("list properties;", ImmutableList.of(new Property(SOME_KEY, "KSQL", "earliest")), ImmutableList.of(SOME_KEY), Collections.emptyList());
// When:
final Table table = builder.buildTable(propList);
// Then:
assertThat(getRows(table), contains(row(SOME_KEY, "KSQL", "SESSION", "earliest")));
}
use of io.confluent.ksql.cli.console.table.Table in project ksql by confluentinc.
the class PropertiesListTableBuilderTest method shouldHandleDefaultProperties.
@Test
public void shouldHandleDefaultProperties() {
// Given:
final PropertiesList propList = new PropertiesList("list properties;", ImmutableList.of(new Property(SOME_KEY, "KSQL", "earliest")), Collections.emptyList(), ImmutableList.of(SOME_KEY));
// When:
final Table table = builder.buildTable(propList);
// Then:
assertThat(getRows(table), contains(row(SOME_KEY, "KSQL", "", "earliest")));
}
use of io.confluent.ksql.cli.console.table.Table in project ksql by confluentinc.
the class PropertiesListTableBuilderTest method shouldHandleServerOverwrittenProperties.
@Test
public void shouldHandleServerOverwrittenProperties() {
// Given:
final PropertiesList propList = new PropertiesList("list properties;", ImmutableList.of(new Property(SOME_KEY, "KSQL", "earliest")), Collections.emptyList(), Collections.emptyList());
// When:
final Table table = builder.buildTable(propList);
// Then:
assertThat(getRows(table), contains(row(SOME_KEY, "KSQL", "SERVER", "earliest")));
}
Aggregations