You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Ismael Juma <is...@juma.me.uk> on 2016/02/03 15:34:01 UTC

Re: [DISCUSS] KIP-45 Standardize all client sequence interaction on j.u.Collection.

Hi Becket,

On Wed, Jan 27, 2016 at 10:51 PM, Becket Qin <be...@gmail.com> wrote:

> 2. For seek(), pause(), resume(), it depends on how easily user can use
> them.
>     If we take current interface, and user have a list of partitions to
> pause(), what they can do is something like:
>     pause(patitionList.toArray());
>     If we change that to take a collection and user have only one partition
> to pause. They have to do:
>     pause(new List<>(partition));
>     Personally I think the current interface handles both single partition
> and a list of partitions better. It is not ideal that we have to adapt to
> the interface. I just feel it is weirder to create a new list.
>

This is not quite right. `toArray` returns an `Object[]`, you would need
the more verbose:

consumer.pause(partitionList.toArray(new TopicPartition[0]));

And for the other case, the recommended approach would be:

consumer.assign(Collections.singleton(partition));

Or, more concisely (with a static import):

consumer.assign(singletonList(partition));

Do people often call `seek()`, `pause()` and `resume()` with a single
partition?

Ismael

Re: [DISCUSS] KIP-45 Standardize all client sequence interaction on j.u.Collection.

Posted by Pierre-Yves Ritschard <py...@spootnik.org>.
A good compromise would be to add an arity with a single TopicPartition.

Jason Gustafson writes:

> Most of the use cases of pause/resume that I've seen work only on single
> partitions (e.g in Kafka Streams), so the current varargs method is kind of
> nice. It would also be nice to be able to do the following:
>
> consumer.pause(consumer.assignment());
>
> Both variants seem convenient in different situations.
>
> -Jason
>
> On Wed, Feb 3, 2016 at 6:34 AM, Ismael Juma <is...@juma.me.uk> wrote:
>
>> Hi Becket,
>>
>> On Wed, Jan 27, 2016 at 10:51 PM, Becket Qin <be...@gmail.com> wrote:
>>
>> > 2. For seek(), pause(), resume(), it depends on how easily user can use
>> > them.
>> >     If we take current interface, and user have a list of partitions to
>> > pause(), what they can do is something like:
>> >     pause(patitionList.toArray());
>> >     If we change that to take a collection and user have only one
>> partition
>> > to pause. They have to do:
>> >     pause(new List<>(partition));
>> >     Personally I think the current interface handles both single
>> partition
>> > and a list of partitions better. It is not ideal that we have to adapt to
>> > the interface. I just feel it is weirder to create a new list.
>> >
>>
>> This is not quite right. `toArray` returns an `Object[]`, you would need
>> the more verbose:
>>
>> consumer.pause(partitionList.toArray(new TopicPartition[0]));
>>
>> And for the other case, the recommended approach would be:
>>
>> consumer.assign(Collections.singleton(partition));
>>
>> Or, more concisely (with a static import):
>>
>> consumer.assign(singletonList(partition));
>>
>> Do people often call `seek()`, `pause()` and `resume()` with a single
>> partition?
>>
>> Ismael
>>


Re: [DISCUSS] KIP-45 Standardize all client sequence interaction on j.u.Collection.

Posted by Jason Gustafson <ja...@confluent.io>.
Most of the use cases of pause/resume that I've seen work only on single
partitions (e.g in Kafka Streams), so the current varargs method is kind of
nice. It would also be nice to be able to do the following:

consumer.pause(consumer.assignment());

Both variants seem convenient in different situations.

-Jason

On Wed, Feb 3, 2016 at 6:34 AM, Ismael Juma <is...@juma.me.uk> wrote:

> Hi Becket,
>
> On Wed, Jan 27, 2016 at 10:51 PM, Becket Qin <be...@gmail.com> wrote:
>
> > 2. For seek(), pause(), resume(), it depends on how easily user can use
> > them.
> >     If we take current interface, and user have a list of partitions to
> > pause(), what they can do is something like:
> >     pause(patitionList.toArray());
> >     If we change that to take a collection and user have only one
> partition
> > to pause. They have to do:
> >     pause(new List<>(partition));
> >     Personally I think the current interface handles both single
> partition
> > and a list of partitions better. It is not ideal that we have to adapt to
> > the interface. I just feel it is weirder to create a new list.
> >
>
> This is not quite right. `toArray` returns an `Object[]`, you would need
> the more verbose:
>
> consumer.pause(partitionList.toArray(new TopicPartition[0]));
>
> And for the other case, the recommended approach would be:
>
> consumer.assign(Collections.singleton(partition));
>
> Or, more concisely (with a static import):
>
> consumer.assign(singletonList(partition));
>
> Do people often call `seek()`, `pause()` and `resume()` with a single
> partition?
>
> Ismael
>

Re: [DISCUSS] KIP-45 Standardize all client sequence interaction on j.u.Collection.

Posted by Jason Gustafson <ja...@confluent.io>.
Most of the use cases of pause/resume that I've seen work only on single
partitions (e.g in Kafka Streams), so the current varargs method is kind of
nice. It would also be nice to be able to do the following:

consumer.pause(consumer.assignment());

Both variants seem convenient in different situations.

-Jason

On Wed, Feb 3, 2016 at 6:34 AM, Ismael Juma <is...@juma.me.uk> wrote:

> Hi Becket,
>
> On Wed, Jan 27, 2016 at 10:51 PM, Becket Qin <be...@gmail.com> wrote:
>
> > 2. For seek(), pause(), resume(), it depends on how easily user can use
> > them.
> >     If we take current interface, and user have a list of partitions to
> > pause(), what they can do is something like:
> >     pause(patitionList.toArray());
> >     If we change that to take a collection and user have only one
> partition
> > to pause. They have to do:
> >     pause(new List<>(partition));
> >     Personally I think the current interface handles both single
> partition
> > and a list of partitions better. It is not ideal that we have to adapt to
> > the interface. I just feel it is weirder to create a new list.
> >
>
> This is not quite right. `toArray` returns an `Object[]`, you would need
> the more verbose:
>
> consumer.pause(partitionList.toArray(new TopicPartition[0]));
>
> And for the other case, the recommended approach would be:
>
> consumer.assign(Collections.singleton(partition));
>
> Or, more concisely (with a static import):
>
> consumer.assign(singletonList(partition));
>
> Do people often call `seek()`, `pause()` and `resume()` with a single
> partition?
>
> Ismael
>