This is an automated email from the ASF dual-hosted git repository.

mimaison 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 3f2cb55a759 KAFKA-14705: Remove redirections and unused tools (#17386)
3f2cb55a759 is described below

commit 3f2cb55a759c562f0ccbfc89fb54f395caf45d9e
Author: Federico Valeri <[email protected]>
AuthorDate: Mon Oct 7 17:24:43 2024 +0200

    KAFKA-14705: Remove redirections and unused tools (#17386)
    
    
    Reviewers: Mickael Maison <[email protected]>
---
 .../main/scala/kafka/admin/FeatureCommand.scala    |  28 ---
 core/src/main/scala/kafka/tools/ClusterTool.scala  |  29 ---
 .../main/scala/kafka/tools/EndToEndLatency.scala   |  30 ----
 core/src/main/scala/kafka/tools/JmxTool.scala      |  29 ---
 .../scala/kafka/tools/StateChangeLogMerger.scala   | 196 ---------------------
 .../main/scala/kafka/tools/StreamsResetter.java    |  31 ----
 docs/upgrade.html                                  |   7 +
 gradle/spotbugs-exclude.xml                        |   6 -
 8 files changed, 7 insertions(+), 349 deletions(-)

diff --git a/core/src/main/scala/kafka/admin/FeatureCommand.scala 
b/core/src/main/scala/kafka/admin/FeatureCommand.scala
deleted file mode 100644
index a7082bcca00..00000000000
--- a/core/src/main/scala/kafka/admin/FeatureCommand.scala
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package kafka.admin
-
-@deprecated(since = "3.5")
-object FeatureCommand {
-  def main(args: Array[String]): Unit = {
-    println("WARNING: The 'kafka.tools' package is deprecated and will change 
to 'org.apache.kafka.tools' in the next major release.")
-    val toolClass = Class.forName("org.apache.kafka.tools.FeatureCommand")
-    val toolMethod = toolClass.getDeclaredMethod("main", 
classOf[Array[String]])
-    toolMethod.invoke(null, args)
-  }
-}
diff --git a/core/src/main/scala/kafka/tools/ClusterTool.scala 
b/core/src/main/scala/kafka/tools/ClusterTool.scala
deleted file mode 100644
index 3fff4485e88..00000000000
--- a/core/src/main/scala/kafka/tools/ClusterTool.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package kafka.tools
-
-@deprecated(since = "3.5")
-object ClusterTool {
-  def main(args: Array[String]): Unit = {
-    println("WARNING: The 'kafka.tools' package is deprecated and will change 
to 'org.apache.kafka.tools' in the next major release.")
-    val toolClass = Class.forName("org.apache.kafka.tools.ClusterTool")
-    val toolMethod = toolClass.getDeclaredMethod("main", 
classOf[Array[String]])
-    toolMethod.invoke(null, args)
-  }
-}
diff --git a/core/src/main/scala/kafka/tools/EndToEndLatency.scala 
b/core/src/main/scala/kafka/tools/EndToEndLatency.scala
deleted file mode 100644
index 28933ca692b..00000000000
--- a/core/src/main/scala/kafka/tools/EndToEndLatency.scala
+++ /dev/null
@@ -1,30 +0,0 @@
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package kafka.tools
-
-@deprecated(since = "3.5")
-object EndToEndLatency {
-  def main(args: Array[String]): Unit = {
-    println("WARNING: The 'kafka.tools' package is deprecated and will change 
to 'org.apache.kafka.tools' in the next major release.")
-    val toolClass = Class.forName("org.apache.kafka.tools.EndToEndLatency")
-    val toolMethod = toolClass.getDeclaredMethod("main", 
classOf[Array[String]])
-    toolMethod.invoke(null, args)
-  }
-}
diff --git a/core/src/main/scala/kafka/tools/JmxTool.scala 
b/core/src/main/scala/kafka/tools/JmxTool.scala
deleted file mode 100644
index 90ffb510aed..00000000000
--- a/core/src/main/scala/kafka/tools/JmxTool.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package kafka.tools
-
-@deprecated(since = "3.5")
-object JmxTool {
-  def main(args: Array[String]): Unit = {
-    println("WARNING: The 'kafka.tools' package is deprecated and will change 
to 'org.apache.kafka.tools' in the next major release.")
-    val toolClass = Class.forName("org.apache.kafka.tools.JmxTool")
-    val toolMethod = toolClass.getDeclaredMethod("main", 
classOf[Array[String]])
-    toolMethod.invoke(null, args)
-  }
-}
diff --git a/core/src/main/scala/kafka/tools/StateChangeLogMerger.scala 
b/core/src/main/scala/kafka/tools/StateChangeLogMerger.scala
deleted file mode 100755
index cd840c88a69..00000000000
--- a/core/src/main/scala/kafka/tools/StateChangeLogMerger.scala
+++ /dev/null
@@ -1,196 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package kafka.tools
-
-import joptsimple._
-
-import scala.util.matching.Regex
-import collection.mutable
-import java.util.Date
-import java.text.SimpleDateFormat
-import kafka.utils.{CoreUtils, Logging}
-
-import java.io.{BufferedOutputStream, OutputStream}
-import java.nio.charset.StandardCharsets
-import org.apache.kafka.common.internals.Topic
-import org.apache.kafka.common.utils.Exit
-import org.apache.kafka.server.util.CommandLineUtils
-
-/**
- * A utility that merges the state change logs (possibly obtained from 
different brokers and over multiple days).
- *
- * This utility expects at least one of the following two arguments -
- * 1. A list of state change log files
- * 2. A regex to specify state change log file names.
- *
- * This utility optionally also accepts the following arguments -
- * 1. The topic whose state change logs should be merged
- * 2. A list of partitions whose state change logs should be merged (can be 
specified only when the topic argument
- * is explicitly specified)
- * 3. Start time from when the logs should be merged
- * 4. End time until when the logs should be merged
- */
-@deprecated(since = "3.6")
-object StateChangeLogMerger extends Logging {
-  val dateFormatString = "yyyy-MM-dd HH:mm:ss,SSS"
-  val topicPartitionRegex = new Regex("\\[(" + Topic.LEGAL_CHARS + "+),( 
)*([0-9]+)\\]")
-  val dateRegex = new Regex("[0-9]{4}-[0-9]{2}-[0-9]{2} 
[0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3}")
-  val dateFormat = new SimpleDateFormat(dateFormatString)
-  var files: List[String] = List()
-  var topic: String = _
-  var partitions: List[Int] = List()
-  var startDate: Date = _
-  var endDate: Date = _
-
-  def main(args: Array[String]): Unit = {
-    println("WARNING: This tool is deprecated and will be removed in the next 
major release.")
-
-    // Parse input arguments.
-    val parser = new OptionParser(false)
-    val filesOpt = parser.accepts("logs", "Comma separated list of state 
change logs or a regex for the log file names")
-                              .withRequiredArg
-                              .describedAs("file1,file2,...")
-                              .ofType(classOf[String])
-    val regexOpt = parser.accepts("logs-regex", "Regex to match the state 
change log files to be merged")
-                              .withRequiredArg
-                              .describedAs("for example: 
/tmp/state-change.log*")
-                              .ofType(classOf[String])
-    val topicOpt = parser.accepts("topic", "The topic whose state change logs 
should be merged")
-                              .withRequiredArg
-                              .describedAs("topic")
-                              .ofType(classOf[String])
-    val partitionsOpt = parser.accepts("partitions", "Comma separated list of 
partition ids whose state change logs should be merged")
-                              .withRequiredArg
-                              .describedAs("0,1,2,...")
-                              .ofType(classOf[String])
-    val startTimeOpt = parser.accepts("start-time", "The earliest timestamp of 
state change log entries to be merged")
-                              .withRequiredArg
-                              .describedAs("start timestamp in the format " + 
dateFormat)
-                              .ofType(classOf[String])
-                              .defaultsTo("0000-00-00 00:00:00,000")
-    val endTimeOpt = parser.accepts("end-time", "The latest timestamp of state 
change log entries to be merged")
-                              .withRequiredArg
-                              .describedAs("end timestamp in the format " + 
dateFormat)
-                              .ofType(classOf[String])
-                              .defaultsTo("9999-12-31 23:59:59,999")
-                              
-    if (args.isEmpty)
-      CommandLineUtils.printUsageAndExit(parser, "A tool for merging the log 
files from several brokers to reconnstruct a unified history of what happened.")
-
-
-    val options = parser.parse(args : _*)
-    if ((!options.has(filesOpt) && !options.has(regexOpt)) || 
(options.has(filesOpt) && options.has(regexOpt))) {
-      System.err.println("Provide arguments to exactly one of the two options 
\"" + filesOpt + "\" or \"" + regexOpt + "\"")
-      parser.printHelpOn(System.err)
-      Exit.exit(1)
-    }
-    if (options.has(partitionsOpt) && !options.has(topicOpt)) {
-      System.err.println("The option \"" + topicOpt + "\" needs to be provided 
an argument when specifying partition ids")
-      parser.printHelpOn(System.err)
-      Exit.exit(1)
-    }
-
-    // Populate data structures.
-    if (options.has(filesOpt)) {
-      files :::= options.valueOf(filesOpt).split(",").toList
-    } else if (options.has(regexOpt)) {
-      val regex = options.valueOf(regexOpt)
-      val fileNameIndex = regex.lastIndexOf('/') + 1
-      val dirName = if (fileNameIndex == 0) "." else regex.substring(0, 
fileNameIndex - 1)
-      val fileNameRegex = new Regex(regex.substring(fileNameIndex))
-      files :::= new java.io.File(dirName).listFiles.filter(f => 
fileNameRegex.findFirstIn(f.getName).isDefined).map(dirName + "/" + 
_.getName).toList
-    }
-    if (options.has(topicOpt)) {
-      topic = options.valueOf(topicOpt)
-    }
-    if (options.has(partitionsOpt)) {
-      partitions = 
options.valueOf(partitionsOpt).split(",").toList.map(_.toInt)
-      val duplicatePartitions = CoreUtils.duplicates(partitions)
-      if (duplicatePartitions.nonEmpty) {
-        System.err.println("The list of partitions contains repeated entries: 
%s".format(duplicatePartitions.mkString(",")))
-        Exit.exit(1)
-      }
-    }
-    startDate = dateFormat.parse(options.valueOf(startTimeOpt).replace('\"', ' 
').trim)
-    endDate = dateFormat.parse(options.valueOf(endTimeOpt).replace('\"', ' 
').trim)
-
-    /**
-     * n-way merge from m input files:
-     * 1. Read a line that matches the specified topic/partitions and date 
range from every input file in a priority queue.
-     * 2. Take the line from the file with the earliest date and add it to a 
buffered output stream.
-     * 3. Add another line from the file selected in step 2 in the priority 
queue.
-     * 4. Flush the output buffer at the end. (The buffer will also be 
automatically flushed every K bytes.)
-     */
-    val pqueue = new mutable.PriorityQueue[LineIterator]()(dateBasedOrdering)
-    val output: OutputStream = new BufferedOutputStream(System.out, 1024*1024)
-    val lineIterators = files.map(scala.io.Source.fromFile(_).getLines())
-    var lines: List[LineIterator] = List()
-
-    for (itr <- lineIterators) {
-      val lineItr = getNextLine(itr)
-      if (!lineItr.isEmpty)
-        lines ::= lineItr
-    }
-    if (lines.nonEmpty) pqueue.enqueue(lines:_*)
-
-    while (pqueue.nonEmpty) {
-      val lineItr = pqueue.dequeue()
-      output.write((lineItr.line + "\n").getBytes(StandardCharsets.UTF_8))
-      val nextLineItr = getNextLine(lineItr.itr)
-      if (!nextLineItr.isEmpty)
-        pqueue.enqueue(nextLineItr)
-    }
-
-    output.flush()
-  }
-
-  /**
-   * Returns the next line that matches the specified topic/partitions from 
the file that has the earliest date
-   * from the specified date range.
-   * @param itr Line iterator of a file
-   * @return (line from a file, line iterator for the same file)
-   */
-  def getNextLine(itr: Iterator[String]): LineIterator = {
-    while (itr != null && itr.hasNext) {
-      val nextLine = itr.next()
-      dateRegex.findFirstIn(nextLine).foreach { d =>
-        val date = dateFormat.parse(d)
-        if ((date.equals(startDate) || date.after(startDate)) && 
(date.equals(endDate) || date.before(endDate))) {
-          topicPartitionRegex.findFirstMatchIn(nextLine).foreach { matcher =>
-            if ((topic == null || topic == matcher.group(1)) && 
(partitions.isEmpty || partitions.contains(matcher.group(3).toInt)))
-              return new LineIterator(nextLine, itr)
-          }
-        }
-      }
-    }
-    new LineIterator()
-  }
-
-  class LineIterator(val line: String, val itr: Iterator[String]) {
-    def this() = this("", null)
-    def isEmpty = line == "" && itr == null
-  }
-
-  implicit object dateBasedOrdering extends Ordering[LineIterator] {
-    def compare(first: LineIterator, second: LineIterator) = {
-      val firstDate = dateRegex.findFirstIn(first.line).get
-      val secondDate = dateRegex.findFirstIn(second.line).get
-      secondDate.compareTo(firstDate)
-    }
-  }
-}
diff --git a/core/src/main/scala/kafka/tools/StreamsResetter.java 
b/core/src/main/scala/kafka/tools/StreamsResetter.java
deleted file mode 100644
index 1eb362286b7..00000000000
--- a/core/src/main/scala/kafka/tools/StreamsResetter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package kafka.tools;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-@Deprecated
-public class StreamsResetter {
-
-    public static void main(String[] args) throws ClassNotFoundException, 
NoSuchMethodException, InvocationTargetException, IllegalAccessException {
-        System.out.println("WARNING: The 'kafka.tools' package is deprecated 
and will change to 'org.apache.kafka.tools' in the next major release.");
-        Class<?> toolClass = 
Class.forName("org.apache.kafka.tools.StreamsResetter");
-        Method main = toolClass.getDeclaredMethod("main", String[].class);
-        main.invoke(null, (Object) args);
-    }
-}
diff --git a/docs/upgrade.html b/docs/upgrade.html
index c52862ef158..17cab2b58b8 100644
--- a/docs/upgrade.html
+++ b/docs/upgrade.html
@@ -75,6 +75,13 @@
                         <li>The <code>--whitelist</code> option was removed 
from the <code>kafka-console-consumer</code> command line tool.
                             Please use <code>--include</code> instead.
                         </li>
+                        <li>Redirections from the old tools packages have been 
removed: 
+                            <code>kafka.admin.FeatureCommand</code>, 
+                            <code>kafka.tools.ClusterTool</code>, 
+                            <code>kafka.tools.EndToEndLatency</code>,
+                            <code>kafka.tools.StateChangeLogMerger</code>, 
+                            <code>kafka.tools.StreamsResetter</code>, 
+                            <code>kafka.tools.JmxTool</code>.</li>
                     </ul>
                 </li>
                 <li><b>Connect</b>
diff --git a/gradle/spotbugs-exclude.xml b/gradle/spotbugs-exclude.xml
index e38ed4e21bf..198a3774b9f 100644
--- a/gradle/spotbugs-exclude.xml
+++ b/gradle/spotbugs-exclude.xml
@@ -168,12 +168,6 @@ For a detailed description of spotbugs bug categories, see 
https://spotbugs.read
         <Bug pattern="REC_CATCH_EXCEPTION"/>
     </Match>
 
-    <Match>
-        <!-- A spurious null check after inlining by the scalac optimizer 
confuses spotBugs -->
-        <Class name="kafka.tools.StateChangeLogMerger$"/>
-        <Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
-    </Match>
-
     <Match>
         <Or>
             <!-- Unboxing to Int to make scalac happy makes spotBugs unhappy 
-->

Reply via email to