Ah, with you now. You'll also need to use the results of
AdminClient.listOffsets which takes TopicPartition objects as an argument.

On Wed, Apr 22, 2020 at 7:43 PM 一直以来 <279377...@qq.com> wrote:

> i use :
>         private static void printConsumerGroupOffsets() throws
> InterruptedException, ExecutionException {
>                 Properties props = new Properties();
>                 props.setProperty("bootstrap.servers",
>                                 "192.168.1.100:9081,192.168.1.100:9082,
> 192.168.1.100:9083,,192.168.1.100:9087,,192.168.1.100:9088");
>                 AdminClient client = KafkaAdminClient.create(props);
>
>
>                 ListConsumerGroupOffsetsResult listConsumerGroupOffsets =
> client.listConsumerGroupOffsets("test");
>                 KafkaFuture<Map<TopicPartition, OffsetAndMetadata&gt;&gt;
> partitionsToOffsetAndMetadata = listConsumerGroupOffsets
>                                 .partitionsToOffsetAndMetadata();
>                 Map<TopicPartition, OffsetAndMetadata&gt; map =
> partitionsToOffsetAndMetadata.get();
>                 Iterator<TopicPartition&gt; iterator =
> map.keySet().iterator();
>                 while (iterator.hasNext()) {
>                         TopicPartition key = iterator.next();
>                         OffsetAndMetadata value = map.get(key);
>                         System.out.println(key.toString() + " " +
> value.toString());
>                 }
>         }
>
> but i not find PARTITION,CURRENT-OFFSET,LOG-END-OFFSET&nbsp;
> &nbsp;&nbsp;Corresponding java method&nbsp;
>
>
> ------------------&nbsp;原始邮件&nbsp;------------------
> 发件人:&nbsp;"Liam Clarke-Hutchinson"<liam.cla...@adscale.co.nz&gt;;
> 发送时间:&nbsp;2020年4月22日(星期三) 下午3:35
> 收件人:&nbsp;"users"<users@kafka.apache.org&gt;;
>
> 主题:&nbsp;Re: thank you ! which java-client api can has same effect about
> kafka-consumer-groups.sh command ?
>
>
>
> Looking at the source code, try listConsumerGroupOffsets(String
> groupId, ListConsumerGroupOffsetsOptions options) instead?
>
> On Wed, Apr 22, 2020 at 6:40 PM 一直以来 <279377...@qq.com&gt; wrote:
>
> &gt; ./kafka-consumer-groups.sh --bootstrap-server localhost:9081
> --describe
> &gt; --group test
> &gt;
> &gt;
> &gt; use describeConsumerGroups method ??
> &gt;
> &gt;
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private static void
> print() throws InterruptedException,
> &gt; ExecutionException {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> Properties props = new Properties();
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> props.setProperty("bootstrap.servers",
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> "192.168.1.100:9081,192.168.1.100:9082,
> &gt; 192.168.1.100:9083,,192.168.1.100:9087,,192.168.1.100:9088");
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> AdminClient client = KafkaAdminClient.create(props);
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> DescribeConsumerGroupsResult describeConsumerGroups =
> &gt; client.describeConsumerGroups(Arrays.asList("test"));
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> Map<String, KafkaFuture<ConsumerGroupDescription&amp;gt;&amp;gt;
> &gt; describedGroups = describeConsumerGroups.describedGroups();
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> Iterator<String&amp;gt; iterator =
> &gt; describedGroups.keySet().iterator();
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> while (iterator.hasNext()) {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> String key = iterator.next();
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> KafkaFuture<ConsumerGroupDescription&amp;gt; value =
> &gt; describedGroups.get(key);
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> ConsumerGroupDescription consumerGroupDescription
> &gt; = value.get();
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> Collection<MemberDescription&amp;gt; members =
> &gt; consumerGroupDescription.members();
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> }
> &gt;
> &gt;
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
> &gt;
> &gt;
> &gt;
> &gt; but i can't find about any method about bottom column:
> &gt; GROUP&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &amp;nbsp;TOPIC&amp;nbsp; &amp;nbsp; &amp;nbsp;
> &gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;PARTITION&amp;nbsp;
> CURRENT-OFFSET&amp;nbsp;
> &gt; LOG-END-OFFSET&amp;nbsp; LAG&amp;nbsp; &amp;nbsp; &amp;nbsp;
> &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &gt; &amp;nbsp;CONSUMER-ID&amp;nbsp; &amp;nbsp; &amp;nbsp;HOST&amp;nbsp;
> &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &gt; &amp;nbsp; CLIENT-ID
> &gt;
> &gt;
> &gt;
> &gt; By its three info :
> &gt; PARTITION&amp;nbsp; CURRENT-OFFSET&amp;nbsp; LOG-END-OFFSET&amp;nbsp;

Reply via email to