[ 
https://issues.apache.org/jira/browse/KAFKA-7373?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16605931#comment-16605931
 ] 

ASF GitHub Bot commented on KAFKA-7373:
---------------------------------------

stanislavkozlovski closed pull request #5617: KAFKA-7373: Allow GetOffsetShell 
command to accept a configurations file
URL: https://github.com/apache/kafka/pull/5617
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/src/main/scala/kafka/tools/GetOffsetShell.scala 
b/core/src/main/scala/kafka/tools/GetOffsetShell.scala
index eafddc66de4..6174479217f 100644
--- a/core/src/main/scala/kafka/tools/GetOffsetShell.scala
+++ b/core/src/main/scala/kafka/tools/GetOffsetShell.scala
@@ -26,6 +26,7 @@ import org.apache.kafka.clients.consumer.{ConsumerConfig, 
KafkaConsumer}
 import org.apache.kafka.common.{PartitionInfo, TopicPartition}
 import org.apache.kafka.common.requests.ListOffsetRequest
 import org.apache.kafka.common.serialization.ByteArrayDeserializer
+import org.apache.kafka.common.utils.Utils
 
 import scala.collection.JavaConverters._
 
@@ -61,6 +62,10 @@ object GetOffsetShell {
                            .describedAs("ms")
                            .ofType(classOf[java.lang.Integer])
                            .defaultsTo(1000)
+    val configOpt = parser.accepts("config", s"Configuration properties file. 
Useful for configuring authentication. Note that all argument options take 
precedence over this config.")
+      .withOptionalArg()
+      .describedAs("config file")
+      .ofType(classOf[String])
 
    if (args.length == 0)
       CommandLineUtils.printUsageAndDie(parser, "An interactive shell for 
getting topic offsets.")
@@ -89,7 +94,10 @@ object GetOffsetShell {
     }
     val listOffsetsTimestamp = options.valueOf(timeOpt).longValue
 
-    val config = new Properties
+    val config = if (options.has(configOpt))
+      Utils.loadProps(options.valueOf(configOpt))
+    else
+      new Properties
     config.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList)
     config.setProperty(ConsumerConfig.CLIENT_ID_CONFIG, clientId)
     val consumer = new KafkaConsumer(config, new ByteArrayDeserializer, new 
ByteArrayDeserializer)


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> GetOffsetShell doesn't work when SSL authentication is enabled
> --------------------------------------------------------------
>
>                 Key: KAFKA-7373
>                 URL: https://issues.apache.org/jira/browse/KAFKA-7373
>             Project: Kafka
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Andy Bryant
>            Assignee: Stanislav Kozlovski
>            Priority: Major
>
> GetOffsetShell doesn't provide a mechanism to provide additional 
> configuration for the underlying KafkaConsumer as does the `ConsoleConsumer`. 
> Passing SSL config as system properties doesn't propagate to the consumer 
> either.
> {code:java}
> 10:47 $ ./kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list 
> ${BROKER_LIST} --topic cld-dev-sor-crods-crodsdba_contact
> Exception in thread "main" org.apache.kafka.common.errors.TimeoutException: 
> Timeout expired while fetching topic metadata{code}
> Editing {{GetOffsetShell.scala}} to include the SSL properties in the 
> KafkaConsumer configuration resolved the issue.
> Providing {{consumer-property}} and {{consumer-config}} configuration options 
> for {{kafka-run-class-sh}} or creating a separate run script for offsets and 
> using these properties in {{GetOffsetShell.scala}} seems like a good solution.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to