Search in sources :

Example 6 with Table

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);
            }
        }
    }
}
Also used : Table(io.confluent.ksql.cli.console.table.Table) Builder(io.confluent.ksql.cli.console.table.Table.Builder) QueryOffsetSummary(io.confluent.ksql.rest.entity.QueryOffsetSummary) QueryTopicOffsetSummary(io.confluent.ksql.rest.entity.QueryTopicOffsetSummary)

Example 7 with Table

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")));
}
Also used : Table(io.confluent.ksql.cli.console.table.Table) PropertiesList(io.confluent.ksql.rest.entity.PropertiesList) Property(io.confluent.ksql.rest.entity.PropertiesList.Property) Test(org.junit.Test)

Example 8 with Table

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")));
}
Also used : Table(io.confluent.ksql.cli.console.table.Table) PropertiesList(io.confluent.ksql.rest.entity.PropertiesList) Property(io.confluent.ksql.rest.entity.PropertiesList.Property) Test(org.junit.Test)

Example 9 with Table

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")));
}
Also used : Table(io.confluent.ksql.cli.console.table.Table) PropertiesList(io.confluent.ksql.rest.entity.PropertiesList) Property(io.confluent.ksql.rest.entity.PropertiesList.Property) Test(org.junit.Test)

Aggregations

Table (io.confluent.ksql.cli.console.table.Table)9 Test (org.junit.Test)6 PropertiesList (io.confluent.ksql.rest.entity.PropertiesList)4 Property (io.confluent.ksql.rest.entity.PropertiesList.Property)4 Builder (io.confluent.ksql.cli.console.table.Table.Builder)3 QueryId (io.confluent.ksql.query.QueryId)2 RunningQuery (io.confluent.ksql.rest.entity.RunningQuery)2 ImmutableList (com.google.common.collect.ImmutableList)1 Stat (io.confluent.ksql.metrics.TopicSensors.Stat)1 QueryHostStat (io.confluent.ksql.rest.entity.QueryHostStat)1 QueryOffsetSummary (io.confluent.ksql.rest.entity.QueryOffsetSummary)1 QueryTopicOffsetSummary (io.confluent.ksql.rest.entity.QueryTopicOffsetSummary)1 ConnectorStateInfo (org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo)1