kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From guozh...@apache.org
Subject [kafka] branch trunk updated: MINOR: Remove KafkaStreams#toString (#4909)
Date Fri, 04 May 2018 23:35:25 GMT
This is an automated email from the ASF dual-hosted git repository.

guozhang pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 564311f  MINOR: Remove KafkaStreams#toString (#4909)
564311f is described below

commit 564311f5cdedd63fa03052368c321db5ce15dc4f
Author: Guozhang Wang <wangguoz@gmail.com>
AuthorDate: Fri May 4 16:35:17 2018 -0700

    MINOR: Remove KafkaStreams#toString (#4909)
    
    Remove the deprecated KafkaStreams#toString function. Also override toString() for internal
classes for debugging purposes.
    
    Reviewers: Bill Bejeck <bill@confluent.io>, Damian Guy <damian@confluent.io>,
Matthias J. Sax <matthias@confluent.io>
---
 .../org/apache/kafka/streams/KafkaStreams.java     | 40 ----------------------
 .../streams/processor/internals/AbstractTask.java  |  8 ++---
 .../streams/processor/internals/AssignedTasks.java |  5 +++
 .../processor/internals/StreamsMetadataState.java  | 15 ++++++++
 .../streams/processor/internals/TaskManager.java   | 14 ++++++++
 .../org/apache/kafka/streams/KafkaStreamsTest.java | 13 -------
 6 files changed, 38 insertions(+), 57 deletions(-)

diff --git a/streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java b/streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java
index 56d031b..d656181 100644
--- a/streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java
+++ b/streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java
@@ -922,46 +922,6 @@ public class KafkaStreams {
     }
 
     /**
-     * Produce a string representation containing useful information about this {@code KafkaStream}
instance such as
-     * thread IDs, task IDs, and a representation of the topology DAG including {@link StateStore}s
(cf.
-     * {@link Topology} and {@link StreamsBuilder}).
-     *
-     * @return A string representation of the Kafka Streams instance.
-     *
-     * @deprecated Use {@link #localThreadsMetadata()} to retrieve runtime information.
-     */
-    @Override
-    @Deprecated
-    public String toString() {
-        return toString("");
-    }
-
-    /**
-     * Produce a string representation containing useful information about this {@code KafkaStream}
instance such as
-     * thread IDs, task IDs, and a representation of the topology DAG including {@link StateStore}s
(cf.
-     * {@link Topology} and {@link StreamsBuilder}).
-     *
-     * @param indent the top-level indent for each line
-     * @return A string representation of the Kafka Streams instance.
-     *
-     * @deprecated Use {@link #localThreadsMetadata()} to retrieve runtime information.
-     */
-    @Deprecated
-    public String toString(final String indent) {
-        final StringBuilder sb = new StringBuilder()
-            .append(indent)
-            .append("KafkaStreams processID: ")
-            .append(processId)
-            .append("\n");
-        for (final StreamThread thread : threads) {
-            sb.append(thread.toString(indent + "\t"));
-        }
-        sb.append("\n");
-
-        return sb.toString();
-    }
-
-    /**
      * Do a clean up of the local {@link StateStore} directory ({@link StreamsConfig#STATE_DIR_CONFIG})
by deleting all
      * data with regard to the {@link StreamsConfig#APPLICATION_ID_CONFIG application ID}.
      * <p>
diff --git a/streams/src/main/java/org/apache/kafka/streams/processor/internals/AbstractTask.java
b/streams/src/main/java/org/apache/kafka/streams/processor/internals/AbstractTask.java
index bbdb349..02a1a06 100644
--- a/streams/src/main/java/org/apache/kafka/streams/processor/internals/AbstractTask.java
+++ b/streams/src/main/java/org/apache/kafka/streams/processor/internals/AbstractTask.java
@@ -127,7 +127,7 @@ public abstract class AbstractTask implements Task {
     }
 
     /**
-     * Produces a string representation containing useful information about a StreamTask.
+     * Produces a string representation containing useful information about a Task.
      * This is useful in debugging scenarios.
      *
      * @return A string representation of the StreamTask instance.
@@ -138,15 +138,15 @@ public abstract class AbstractTask implements Task {
     }
 
     /**
-     * Produces a string representation containing useful information about a StreamTask
starting with the given indent.
+     * Produces a string representation containing useful information about a Task starting
with the given indent.
      * This is useful in debugging scenarios.
      *
-     * @return A string representation of the StreamTask instance.
+     * @return A string representation of the Task instance.
      */
     public String toString(final String indent) {
         final StringBuilder sb = new StringBuilder();
         sb.append(indent);
-        sb.append("StreamsTask taskId: ");
+        sb.append("TaskId: ");
         sb.append(id);
         sb.append("\n");
 
diff --git a/streams/src/main/java/org/apache/kafka/streams/processor/internals/AssignedTasks.java
b/streams/src/main/java/org/apache/kafka/streams/processor/internals/AssignedTasks.java
index 4c4941a..6f4f454 100644
--- a/streams/src/main/java/org/apache/kafka/streams/processor/internals/AssignedTasks.java
+++ b/streams/src/main/java/org/apache/kafka/streams/processor/internals/AssignedTasks.java
@@ -284,6 +284,11 @@ abstract class AssignedTasks<T extends Task> {
         return Collections.unmodifiableMap(running);
     }
 
+    @Override
+    public String toString() {
+        return toString("");
+    }
+
     public String toString(final String indent) {
         final StringBuilder builder = new StringBuilder();
         describe(builder, running.values(), indent, "Running:");
diff --git a/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java
b/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java
index 4ff6468..7fb0352 100644
--- a/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java
+++ b/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsMetadataState.java
@@ -56,6 +56,21 @@ public class StreamsMetadataState {
         this.thisHost = thisHost;
     }
 
+    @Override
+    public String toString() {
+        return toString("");
+    }
+
+    public String toString(final String indent) {
+        final StringBuilder builder = new StringBuilder();
+        builder.append(indent).append("GlobalMetadata: ").append(allMetadata).append("\n");
+        builder.append(indent).append("GlobalStores: ").append(globalStores).append("\n");
+        builder.append(indent).append("My HostInfo: ").append(thisHost).append("\n");
+        builder.append(indent).append(clusterMetadata).append("\n");
+
+        return builder.toString();
+    }
+
     /**
      * Find all of the {@link StreamsMetadata}s in a
      * {@link KafkaStreams application}
diff --git a/streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java
b/streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java
index 6308ca7..63224db 100644
--- a/streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java
+++ b/streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java
@@ -445,8 +445,22 @@ class TaskManager {
         }
     }
 
+    /**
+     * Produces a string representation containing useful information about the TaskManager.
+     * This is useful in debugging scenarios.
+     *
+     * @return A string representation of the TaskManager instance.
+     */
+    @Override
+    public String toString() {
+        return toString("");
+    }
+
     public String toString(final String indent) {
         final StringBuilder builder = new StringBuilder();
+        builder.append("TaskManager\n");
+        builder.append(indent).append("\tMetadataState:\n");
+        builder.append(streamsMetadataState.toString(indent + "\t\t"));
         builder.append(indent).append("\tActive tasks:\n");
         builder.append(active.toString(indent + "\t\t"));
         builder.append(indent).append("\tStandby tasks:\n");
diff --git a/streams/src/test/java/org/apache/kafka/streams/KafkaStreamsTest.java b/streams/src/test/java/org/apache/kafka/streams/KafkaStreamsTest.java
index 1c33f64..ec0e41d 100644
--- a/streams/src/test/java/org/apache/kafka/streams/KafkaStreamsTest.java
+++ b/streams/src/test/java/org/apache/kafka/streams/KafkaStreamsTest.java
@@ -500,19 +500,6 @@ public class KafkaStreamsTest {
         }
     }
 
-    @SuppressWarnings("deprecation")
-    @Test
-    public void testToString() {
-        streams.start();
-        final String streamString = streams.toString();
-        streams.close();
-        final String appId = streamString.split("\\n")[1].split(":")[1].trim();
-        Assert.assertNotEquals("streamString should not be empty", "", streamString);
-        Assert.assertNotNull("streamString should not be null", streamString);
-        Assert.assertNotEquals("streamString contains non-empty appId", "", appId);
-        Assert.assertNotNull("streamString contains non-null appId", appId);
-    }
-
     @Test
     public void shouldCleanupOldStateDirs() throws InterruptedException {
         props.setProperty(StreamsConfig.STATE_CLEANUP_DELAY_MS_CONFIG, "1");

-- 
To stop receiving notification emails like this one, please contact
guozhang@apache.org.

Mime
View raw message