This is an automated email from the ASF dual-hosted git repository. cmccabe pushed a commit to branch metashell in repository https://gitbox.apache.org/repos/asf/kafka.git
commit c89f15369d75ba374d327f4e3d94722525ab76e2 Author: Colin P. Mccabe <[email protected]> AuthorDate: Wed Feb 10 13:15:17 2021 -0800 Address review comments --- build.gradle | 1 - .../java/org/apache/kafka/shell/MetadataShell.java | 28 +++++++++++----------- .../org/apache/kafka/shell/SnapshotReader.java | 8 +++---- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/build.gradle b/build.gradle index ca9b341..d037488 100644 --- a/build.gradle +++ b/build.gradle @@ -1370,7 +1370,6 @@ project(':shell') { testCompile project(':clients') testCompile libs.junitJupiter - testCompile project(':clients').sourceSets.test.output testRuntime libs.slf4jlog4j } diff --git a/shell/src/main/java/org/apache/kafka/shell/MetadataShell.java b/shell/src/main/java/org/apache/kafka/shell/MetadataShell.java index 16e5e31..49a5a33 100644 --- a/shell/src/main/java/org/apache/kafka/shell/MetadataShell.java +++ b/shell/src/main/java/org/apache/kafka/shell/MetadataShell.java @@ -89,7 +89,7 @@ public final class MetadataShell { throw new RuntimeException("If you specify a snapshot path, you " + "must not also specify controllers to connect to."); } - return buildWithSnapshotReader(); + return buildWithSnapshotFileReader(); } else { return buildWithControllerConnect(); } @@ -149,17 +149,17 @@ public final class MetadataShell { return new MetadataShell(raftManager, null, nodeManager); } - public MetadataShell buildWithSnapshotReader() throws Exception { + public MetadataShell buildWithSnapshotFileReader() throws Exception { MetadataNodeManager nodeManager = null; - SnapshotReader snapshotReader = null; + SnapshotFileReader reader = null; try { nodeManager = new MetadataNodeManager(); - snapshotReader = new SnapshotReader(snapshotPath, nodeManager.logListener()); - return new MetadataShell(null, snapshotReader, nodeManager); + reader = new SnapshotFileReader(snapshotPath, nodeManager.logListener()); + return new MetadataShell(null, reader, nodeManager); } catch (Throwable e) { log.error("Initialization error", e); - if (snapshotReader != null) { - snapshotReader.close(); + if (reader != null) { + reader.close(); } if (nodeManager != null) { nodeManager.close(); @@ -171,15 +171,15 @@ public final class MetadataShell { private final KafkaRaftManager<ApiMessageAndVersion> raftManager; - private final SnapshotReader snapshotReader; + private final SnapshotFileReader reader; private final MetadataNodeManager nodeManager; public MetadataShell(KafkaRaftManager<ApiMessageAndVersion> raftManager, - SnapshotReader snapshotReader, + SnapshotFileReader snapshotFileReader, MetadataNodeManager nodeManager) { this.raftManager = raftManager; - this.snapshotReader = snapshotReader; + this.snapshotFileReader = snapshotFileReader; this.nodeManager = nodeManager; } @@ -188,8 +188,8 @@ public final class MetadataShell { if (raftManager != null) { raftManager.startup(); raftManager.register(nodeManager.logListener()); - } else if (snapshotReader != null) { - snapshotReader.startup(); + } else if (snapshotFileReader != null) { + snapshotFileReader.startup(); } else { throw new RuntimeException("Expected either a raft manager or snapshot reader"); } @@ -214,8 +214,8 @@ public final class MetadataShell { if (raftManager != null) { raftManager.shutdown(); } - if (snapshotReader != null) { - snapshotReader.close(); + if (snapshotFileReader != null) { + snapshotFileReader.close(); } nodeManager.close(); } diff --git a/shell/src/main/java/org/apache/kafka/shell/SnapshotReader.java b/shell/src/main/java/org/apache/kafka/shell/SnapshotReader.java index 5de1dfb..7155ec8 100644 --- a/shell/src/main/java/org/apache/kafka/shell/SnapshotReader.java +++ b/shell/src/main/java/org/apache/kafka/shell/SnapshotReader.java @@ -42,10 +42,10 @@ import java.util.concurrent.CompletableFuture; /** - * The Kafka metadata tool. + * Reads Kafka metadata snapshots. */ -public final class SnapshotReader implements AutoCloseable { - private static final Logger log = LoggerFactory.getLogger(SnapshotReader.class); +public final class SnapshotFileReader implements AutoCloseable { + private static final Logger log = LoggerFactory.getLogger(SnapshotFileReader.class); private final String snapshotPath; private final MetaLogListener listener; @@ -53,7 +53,7 @@ public final class SnapshotReader implements AutoCloseable { private FileRecords fileRecords; private Iterator<FileChannelRecordBatch> batchIterator; - public SnapshotReader(String snapshotPath, MetaLogListener listener) { + public SnapshotFileReader(String snapshotPath, MetaLogListener listener) { this.snapshotPath = snapshotPath; this.listener = listener; this.queue = new KafkaEventQueue(Time.SYSTEM,
