Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EC060200C32 for ; Thu, 23 Feb 2017 01:37:51 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id EAA0F160B72; Thu, 23 Feb 2017 00:37:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AFE7D160B62 for ; Thu, 23 Feb 2017 01:37:50 +0100 (CET) Received: (qmail 78944 invoked by uid 500); 23 Feb 2017 00:37:49 -0000 Mailing-List: contact dev-help@kafka.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@kafka.apache.org Delivered-To: mailing list dev@kafka.apache.org Received: (qmail 78931 invoked by uid 99); 23 Feb 2017 00:37:49 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Feb 2017 00:37:49 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id B1A7D18E179 for ; Thu, 23 Feb 2017 00:37:48 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.498 X-Spam-Level: ** X-Spam-Status: No, score=2.498 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=confluent-io.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id jnwNtXCpqrOf for ; Thu, 23 Feb 2017 00:37:41 +0000 (UTC) Received: from mail-ua0-f176.google.com (mail-ua0-f176.google.com [209.85.217.176]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id CE4475F30F for ; Thu, 23 Feb 2017 00:37:40 +0000 (UTC) Received: by mail-ua0-f176.google.com with SMTP id g30so12828345uac.3 for ; Wed, 22 Feb 2017 16:37:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=confluent-io.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=L3W4u/VUfQBbvQApqboX77Vhcn6Tv2VW7LH1DSfV/20=; b=sVkk5wSePiUppzSlLWY6+Q5WjhzFIPf0JtR76hs50It1B7VLc11ryk0cI6Rf8hUpjr drR/LgygjtfZVWcb9WzXFl2ryFlSdh5wQIuW7bx0YZCJhAJLfEJHscDWNyqeBVR1io+L 5mLUgwMMdODpjz+pEt/+/NT0hCh3fxY9m2JGrSB6OBbfcGrW/g2A7WMoUv0nUPn/3Tsc OZrJf4jcdxrtFWS4/u+/eauloeYSR2bUo0Dh6c0cQtHJ9E7JIsoPbFLElgAMk/RvqJSZ eNAdJEDfyeQw6JUZRMpMEXuCVyEaakOPfuGoivScC5oLbxPSI7NIWQ2/ngNF0ZYzQlQ4 BbFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=L3W4u/VUfQBbvQApqboX77Vhcn6Tv2VW7LH1DSfV/20=; b=ISXqjEZhiKPtA7UJ7dpnZy2A+7DszLfn4gy6/gdyDHSfb0s5bum4mCN+I5Zy61hbun 90moU5lf60T+wk/1MqmeibsSQSJfdA0yquDn88uXlalFMf+cgoPDSyTxOHTX74cRmpCz XVacARDdxBaBl9VOwdbi4Ar5bsaZaB7CGZCLROUA3qvqNRMzadlBtgIm0Aw5B56wQ9uX BJ47rKbLrAj+RYoQ0vNtsB28N2X6oNUtL495Z7YdXYYs4Dv0O8huVkLLxhGxnOzuzPfN 3kAEShCI8Sp0U5EXkrqpxDE+1fJ1yE3rjkqxOgfYWNIaQVm3QK2GorjPmvBzwpaPvx9P gLZg== X-Gm-Message-State: AMke39nAJ63EIS7FuOS+nnM4JkqHV7s4Z8w0G4e+jH5gT9mm9l0202C3nm219KFxeCWvbAVpWtEqUY8eD0NelX2f X-Received: by 10.176.86.15 with SMTP id y15mr8717325uaa.74.1487810251415; Wed, 22 Feb 2017 16:37:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.151.131 with HTTP; Wed, 22 Feb 2017 16:37:30 -0800 (PST) In-Reply-To: <483538BD-65F9-4060-849C-27530129CBB4@ig.com> References: <126E4021-9FC6-4773-9548-24BEE306B1A6@ig.com> <93e47558e38a4323b05f164da234fab2@BMPRDEXC142.IGI.IG.LOCAL> <1487802174980.8025@ig.com> <489178A5-189C-4FCA-B0D9-52FF7DCFE801@ig.com> <483538BD-65F9-4060-849C-27530129CBB4@ig.com> From: Jason Gustafson Date: Wed, 22 Feb 2017 16:37:30 -0800 Message-ID: Subject: Re: [DISCUSS] KIP-82 - Add Record Headers To: dev@kafka.apache.org Content-Type: multipart/alternative; boundary=f403045e1e0087cb14054927d1a2 archived-at: Thu, 23 Feb 2017 00:37:52 -0000 --f403045e1e0087cb14054927d1a2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable The point about usability is fair. It's also reasonable to expect that common use cases such as appending headers should be done efficiently. Perhaps we could compromise with something like this? class Headers { Headers append(Iterable
headers); Headers prepend(Iterable
headers); } That retains ease of use while still giving ourselves some flexibility in the implementation. -Jason On Wed, Feb 22, 2017 at 3:03 PM, Michael Pearce wrote: > I wasn=E2=80=99t referring to the headers needing to be copied, im meanin= g the > fact we=E2=80=99d be forcing a new producer record to be created, with al= l the > contents copied. > > i.e what will happen is utility method will be created or end up being > used, which does this, and returns the new ProducerRecord instance. > > ProducerRecord addHeader(ProducerRecord record, Header header){ > Return New ProducerRecord(record.key, record.value, record.timestamp=E2= =80=A6.., > record.headers.concat(header)) > } > > To me this seems ugly, but will be inevitable if we don=E2=80=99t make ad= ding > headers to existing records a simple clean method call. > > > > On 22/02/2017, 22:57, "Michael Pearce" wrote: > > Lazy init can achieve/avoid that. > > Re the concat, why don=E2=80=99t we implement that inside the Headers= rather > than causing everyone to implement this as adding headers in interceptors > will be a dominant use case. We want a user friendly API. Having as a use= r > having to code this instead of having the headers handle this for me seem= s > redundant. > > On 22/02/2017, 22:34, "Jason Gustafson" wrote: > > I thought the argument was against creating the extra objects > unnecessarily > (i.e. if they were not accessed). And note that making the Header= s > immutable doesn't necessarily mean that they need to be copied: > you can do > a trick like Guava's Iterables.concat to add additional headers > without > changing the underlying collections. > > -Jason > > On Wed, Feb 22, 2017 at 2:22 PM, Michael Pearce < > Michael.Pearce@ig.com> > wrote: > > > If the argument for not having a map holding the key, value > pairs is due > > to garbage creation of HashMap entry's, forcing the creation of > a whole new > > producer record to simply add a head, surely is creating a-lot > more? > > ________________________________________ > > From: Jason Gustafson > > Sent: Wednesday, February 22, 2017 10:09 PM > > To: dev@kafka.apache.org > > Subject: Re: [DISCUSS] KIP-82 - Add Record Headers > > > > The current producer interceptor API is this: > > > > ProducerRecord onSend(ProducerRecord record); > > > > So adding a header means creating a new ProducerRecord with a > new header > > added to the current headers and returning it. Would that not > work? > > > > -Jason > > > > On Wed, Feb 22, 2017 at 1:45 PM, Michael Pearce < > Michael.Pearce@ig.com> > > wrote: > > > > > So how would you have this work if not mutable where > interceptors would > > > add headers? > > > > > > Sent using OWA for iPhone > > > ________________________________________ > > > From: Jason Gustafson > > > Sent: Wednesday, February 22, 2017 8:42:27 PM > > > To: dev@kafka.apache.org > > > Subject: Re: [DISCUSS] KIP-82 - Add Record Headers > > > > > > I think the point on the mutability of Headers is worth > discussing a > > little > > > more. As far as I can tell, once the ProducerRecord (or > ConsumerRecord) > > is > > > constructed, there should be no need to further change the > headers. Is > > that > > > correct? If so, then why not enforce that that is the case > through the > > API? > > > One problem with mutability it that it constrains the > implementation of > > > Headers. For example, if we were backing with a byte slice, > would we > > recopy > > > the bytes if a header is added or would we maintain a satelli= te > > collection > > > of added records. Seems not great either way. If we really > think > > mutability > > > is needed, perhaps we could add a method to headers to conver= t > it to a > > > mutable type (e.g. a Headers.toMap)? > > > > > > I'm also with Ismael about exposing Headers.get(). I thought > it might > > make > > > sense to have a method like this instead: > > > > > > Iterable
findMatching(Pattern pattern); > > > > > > This makes the (potential) need to scan the headers clear in > the API. I'd > > > also be fine exposing no getter at all. In general, =C3=8F th= ink > it's good to > > > start with a minimalistic API and work from there since it's > always > > easier > > > to add methods than remove them. > > > > > > -Jason > > > > > > On Wed, Feb 22, 2017 at 9:16 AM, Michael Pearce < > Michael.Pearce@ig.com> > > > wrote: > > > > > > > > > > > Hi Ismael > > > > > > > > On point 1, > > > > > > > > Sure makes sense will update shortly. > > > > > > > > On point 2, > > > > > > > > Setter/getter typical to properties/headers api=E2=80=99s > traditionally are map > > > > styled interfaces and what I believe is most expected style= d > thus the > > > Key, > > > > Value setter. > > > > Also it would mean rather than an interface, we would be > making our > > > > internal header impl object we have for the array, exposed. > E.g. if we > > > had > > > > a Map really this would be Map.Entry interface, this is the > same > > reasons > > > on > > > > the map interface I cannot actually make the underlying Nod= e > object > > > that=E2=80=99s > > > > the implementation for HashMap, so that internals can be > changed. > > > > > > > > > > > > On point 3, > > > > > > > > I think it people do expect it to be performant, thus why > originally > > > > concern I raised with using an array for to me is an early > memory > > > > optimisation. I think the user experience of > properties/headers is on a > > > > get/set model. This is why its important we have > encapsulated logic > > that > > > > then allows us to change this to a map, if this becomes and > issue, and > > > the > > > > memory overhead of hashmap is less so. > > > > > > > > > > > > > > > > > > > > On 22/02/2017, 15:56, "ismaelj@gmail.com on behalf of > Ismael Juma" < > > > > ismaelj@gmail.com on behalf of ismael@juma.me.uk> wrote: > > > > > > > > Hi all, > > > > > > > > Great to see the progress that has been achieved on thi= s > one. :) A > > > few > > > > comments regarding the APIs (I'm still reviewing the > message format > > > > changes): > > > > > > > > 1. Nit: `getHeaders` in `ProducerRecord` and > `ConsumerRecord` > > should > > > be > > > > named `headers` (we avoid the `get` prefix in Kafka) > > > > > > > > 2. The `Headers` class is mutable (there's an `add` > method). Does > > it > > > > need > > > > to be? If so, it would be good to explain why. Related > to that, we > > > > should > > > > also explain the thinking around thread-safety. If we > keep the > > `add` > > > > method, it may make sense for it to take a `Header` > (that way we > > can > > > > add > > > > things to `Header` without changing the interface). > > > > > > > > 3. Do we need the `Headers.get()` method? People usuall= y > assume > > that > > > > `get` > > > > would be efficient, but depending on the implementation > (the > > current > > > > proposal states that an array would be used), it may no= t > be. If we > > > > expect > > > > the number of headers to be small, it doesn't matter > though. > > > > > > > > Ismael > > > > > > > > On Tue, Feb 21, 2017 at 6:38 PM, Michael Pearce < > > > Michael.Pearce@ig.com > > > > > > > > > wrote: > > > > > > > > > Hi Jason, > > > > > > > > > > Have converted the interface/api bullets into > interface code > > > > snippets. > > > > > > > > > > Agreed implementation won=E2=80=99t take too long. We= have > early versions > > > > already. > > > > > Maybe a week before you think about merging I would > assume it > > would > > > > be more > > > > > stabilised? I was thinking then we could fork from > your confluent > > > > branch, > > > > > making and then holding KIP-82 changes in a patch > file, that we > > can > > > > then > > > > > re-fork from apache once KIP98 final is merged, and > apply patch > > > with > > > > last > > > > > minute changes. > > > > > > > > > > Cheers > > > > > Mike > > > > > > > > > > > > > > > On 22/02/2017, 00:56, "Jason Gustafson" < > jason@confluent.io> > > > wrote: > > > > > > > > > > Hey Michael, > > > > > > > > > > Awesome. I have a minor request. The APIs are > currently > > > > documented as a > > > > > wiki list. Would you mind adding a code snippet > instead? > > It's a > > > > bit > > > > > easier > > > > > to process. > > > > > > > > > > How will be best to manage this, as we will > obviously build > > off > > > > your > > > > > KIP=E2=80=99s > > > > > > protocol changes, to avoid a merge hell, should > we branch > > > from > > > > your > > > > > branch > > > > > > in the confluent repo or is it worth having a > KIP-98 > > special > > > > branch > > > > > in the > > > > > > apache git, that we can branch/fork from? > > > > > > > > > > > > > > > I was thinking about this also. Ideally we'd like > to get the > > > > changes > > > > > in as > > > > > close together as possible since we only want one > magic bump > > > and > > > > some > > > > > users > > > > > deploy trunk. The level of effort to change the > format for > > > > headers > > > > > seems > > > > > not too high. Do you agree? My guess is that the > KIP-98 > > message > > > > format > > > > > patch will take 2-3 weeks to review before we > merge to trunk, > > > so > > > > you > > > > > could > > > > > hold off implementing until that patch has somewh= at > > stabilized. > > > > That > > > > > would > > > > > save some potential rebase pain. > > > > > > > > > > -Jason > > > > > > > > > > > > > > > The information contained in this email is strictly > confidential > > > and > > > > for > > > > > the use of the addressee only, unless otherwise > indicated. If you > > > > are not > > > > > the intended recipient, please do not read, copy, use > or disclose > > > to > > > > others > > > > > this message or any attachment. Please also notify th= e > sender by > > > > replying > > > > > to this email or by telephone (+44(020 7896 0011) and > then delete > > > the > > > > > email and any copies of it. Opinions, conclusion (etc= ) > that do > > not > > > > relate > > > > > to the official business of this company shall be > understood as > > > > neither > > > > > given nor endorsed by it. IG is a trading name of IG > Markets > > > Limited > > > > (a > > > > > company registered in England and Wales, company > number 04008957) > > > > and IG > > > > > Index Limited (a company registered in England and > Wales, company > > > > number > > > > > 01190902). Registered address at Cannon Bridge House, > 25 Dowgate > > > > Hill, > > > > > London EC4R 2YA. Both IG Markets Limited (register > number 195355) > > > > and IG > > > > > Index Limited (register number 114059) are authorised > and > > regulated > > > > by the > > > > > Financial Conduct Authority. > > > > > > > > > > > > > > > > > The information contained in this email is strictly > confidential and > > for > > > > the use of the addressee only, unless otherwise indicated. > If you are > > not > > > > the intended recipient, please do not read, copy, use or > disclose to > > > others > > > > this message or any attachment. Please also notify the > sender by > > replying > > > > to this email or by telephone (+44(020 7896 0011) and then > delete the > > > email > > > > and any copies of it. Opinions, conclusion (etc) that do no= t > relate to > > > the > > > > official business of this company shall be understood as > neither given > > > nor > > > > endorsed by it. IG is a trading name of IG Markets Limited > (a company > > > > registered in England and Wales, company number 04008957) > and IG Index > > > > Limited (a company registered in England and Wales, company > number > > > > 01190902). Registered address at Cannon Bridge House, 25 > Dowgate Hill, > > > > London EC4R 2YA. Both IG Markets Limited (register number > 195355) and > > IG > > > > Index Limited (register number 114059) are authorised and > regulated by > > > the > > > > Financial Conduct Authority. > > > > > > > The information contained in this email is strictly > confidential and for > > > the use of the addressee only, unless otherwise indicated. If > you are not > > > the intended recipient, please do not read, copy, use or > disclose to > > others > > > this message or any attachment. Please also notify the sender > by replying > > > to this email or by telephone (+44(020 7896 0011) and then > delete the > > email > > > and any copies of it. Opinions, conclusion (etc) that do not > relate to > > the > > > official business of this company shall be understood as > neither given > > nor > > > endorsed by it. IG is a trading name of IG Markets Limited (a > company > > > registered in England and Wales, company number 04008957) and > IG Index > > > Limited (a company registered in England and Wales, company > number > > > 01190902). Registered address at Cannon Bridge House, 25 > Dowgate Hill, > > > London EC4R 2YA. Both IG Markets Limited (register number > 195355) and IG > > > Index Limited (register number 114059) are authorised and > regulated by > > the > > > Financial Conduct Authority. > > > > > The information contained in this email is strictly confidentia= l > and for > > the use of the addressee only, unless otherwise indicated. If > you are not > > the intended recipient, please do not read, copy, use or > disclose to others > > this message or any attachment. Please also notify the sender b= y > replying > > to this email or by telephone (+44(020 7896 0011) and then > delete the email > > and any copies of it. Opinions, conclusion (etc) that do not > relate to the > > official business of this company shall be understood as neithe= r > given nor > > endorsed by it. IG is a trading name of IG Markets Limited (a > company > > registered in England and Wales, company number 04008957) and I= G > Index > > Limited (a company registered in England and Wales, company > number > > 01190902). Registered address at Cannon Bridge House, 25 Dowgat= e > Hill, > > London EC4R 2YA. Both IG Markets Limited (register number > 195355) and IG > > Index Limited (register number 114059) are authorised and > regulated by the > > Financial Conduct Authority. > > > > > > > The information contained in this email is strictly confidential and for > the use of the addressee only, unless otherwise indicated. If you are not > the intended recipient, please do not read, copy, use or disclose to othe= rs > this message or any attachment. Please also notify the sender by replying > to this email or by telephone (+44(020 7896 0011) and then delete the ema= il > and any copies of it. Opinions, conclusion (etc) that do not relate to th= e > official business of this company shall be understood as neither given no= r > endorsed by it. IG is a trading name of IG Markets Limited (a company > registered in England and Wales, company number 04008957) and IG Index > Limited (a company registered in England and Wales, company number > 01190902). Registered address at Cannon Bridge House, 25 Dowgate Hill, > London EC4R 2YA. Both IG Markets Limited (register number 195355) and IG > Index Limited (register number 114059) are authorised and regulated by th= e > Financial Conduct Authority. > --f403045e1e0087cb14054927d1a2--