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 5B335200CA4 for ; Wed, 7 Jun 2017 21:47:27 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 59F50160BD0; Wed, 7 Jun 2017 19:47:27 +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 531FE160BBF for ; Wed, 7 Jun 2017 21:47:26 +0200 (CEST) Received: (qmail 30672 invoked by uid 500); 7 Jun 2017 19:47:25 -0000 Mailing-List: contact dev-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list dev@geode.apache.org Received: (qmail 30660 invoked by uid 99); 7 Jun 2017 19:47:25 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jun 2017 19:47:25 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id C30AFC2002 for ; Wed, 7 Jun 2017 19:47:24 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.019 X-Spam-Level: X-Spam-Status: No, score=-0.019 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, MIME_QP_LONG_LINE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=pivotal-io.20150623.gappssmtp.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id mbwZl2ZvEAQR for ; Wed, 7 Jun 2017 19:47:21 +0000 (UTC) Received: from mail-ot0-f174.google.com (mail-ot0-f174.google.com [74.125.82.174]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id A43555F5B3 for ; Wed, 7 Jun 2017 19:47:20 +0000 (UTC) Received: by mail-ot0-f174.google.com with SMTP id t31so12640795ota.1 for ; Wed, 07 Jun 2017 12:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pivotal-io.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:date:subject:message-id :references:in-reply-to:to; bh=uT19cRKhaeVnrTIqZDeK4iVW6YmZygh6jIAcZtMP9Mo=; b=zCcJaflGuE8v+QgYwiwBolHcZU3yrbTaBxc7sxTzvFtzink6c8BOqTLgFIhZ6WBJvS La6XJR06R48HszFO2+R/nfhbdWUEvwbxEkqkcjGSlQ9G3OUh67TU2kjF92Wk6IOpP/ck PgqU0ziRZRp1wmdeAOKgu3OFmgBEC3E6djFYxn1gUT2FK1cQqa0f4zTU+eQsz+eFHxOO qOqv0e6dTUq89kiCNUIT7V2mDj/iHOFg5fgQbouCP7U36bngqTBqKvf1by/e+1greuMy DdyZfkZ9KsynyVI/DbBmBu3bCho5+eD2eFCTKzJaMXvNUuuaTd9EtAc5vvwp5EIQ2Hul M6Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version:date :subject:message-id:references:in-reply-to:to; bh=uT19cRKhaeVnrTIqZDeK4iVW6YmZygh6jIAcZtMP9Mo=; b=rBjTODMZZIFLD812Eza1SCC290O2u4p3pFc7rHclsKEyF7W4QstHYnEPIgJ6VJNPn9 SXwKaC2bWo9wtAsJTsBP+vZ3aHWT/ue74cxBuv4ISolQ/QydxqyWZw6qucQgB7kVTEKC 1jQPRMdO+6ijh/EZBhWJGv4caDf65PMN++gTPFm0w9BhWElIgfUNp26McfJugZDf5Ht0 +mnHDLQCL9Hoi8LanhSuJb+UkbbjZsCETG+ExZmthhWB5qRNFDWq3sSZLQ8RH4r7VG3R 7f7ZLrdSS+v10rYg1b+P5UX72NJT9KbDwjJ82NSyxNf83gYwzzMcJiXferFJyLIvrbYi kTeg== X-Gm-Message-State: AODbwcC0QM0KlyqdcYa6TbwSfl1HM89KhS0nSAhMfzcE6ZTRbJSv+FmS eokvx6tfQRRVW3jmMKeU+A== X-Received: by 10.157.14.90 with SMTP id n26mr17724960otd.176.1496864833599; Wed, 07 Jun 2017 12:47:13 -0700 (PDT) Received: from [192.168.1.92] (216-64-164-6.static.twtelecom.net. [216.64.164.6]) by smtp.gmail.com with ESMTPSA id f68sm1363468otb.32.2017.06.07.12.47.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jun 2017 12:47:13 -0700 (PDT) From: Jacob Barrett Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (1.0) Date: Wed, 7 Jun 2017 12:47:12 -0700 Subject: Re: [DISCUSS] easy string based partitioning Message-Id: References: <3777c347-f832-5422-a7a2-a279e63fefed@pivotal.io> <25b9712b-e8c1-b572-4a35-3c227ca602ae@pivotal.io> In-Reply-To: To: dev@geode.apache.org X-Mailer: iPhone Mail (14F89) archived-at: Wed, 07 Jun 2017 19:47:27 -0000 In regard to sending the configuration state to the clients for the partitio= n resolver maybe the config should be a domain object independent of the bus= iness object rather than the serialized form of the partition resolver itsel= f. The rational for this would be that non-Java clients could get the config= as PDX (or some other language neutral scheme) and initialize their native l= anguage version of the partition resolver with this config. -Jake Sent from my iPhone > On Jun 7, 2017, at 11:42 AM, Darrel Schneider wrot= e: >=20 > Thanks for all the feedback. Since this is such a simple resolver with a > fixed delimiter the following changes were made to the original proposal: > 1. The StringPrefixPartitionResolver will be in the > "org.apache.geode.cache.util" package. > This was done to keep it from being viewed as part of the core API. It > is just a simple implementation > of one of the core API interfaces that user can use if they find it > helpful. > 2. The fixed delimiter was changed from ":" to "|". The character still ha= s > the visual appearance of > delimiting two fields with the benefit of being used less often than > ":". Since the delimiter can not > be configured that makes it more likely someone can use this resolver. >=20 > I think the ideas about more complex resolvers are interesting and the > existence of this simple resolver does not prevent other resolver > implementations from also being added to the util package. For example one= > that is regex based or spring expression based. >=20 > One of the things discovered was that if a PartitionResolver has state (fo= r > example a configured delimiter, or regex, or spring expression) then that > java clients will not be able to single hop to the server region with that= > resolver. Our servers send the single hop java clients just the class name= > of the PartitionResolver. The instance of the actual resolver is not > serialized to the client. The java client single hop code attempts to > create an instance of it by invoking a no-arg constructor. So any state > stored in the server's resolver instance will be lost. If the resolver > class does not have a no-arg constructor then the java client will be > unable to load an instance and just disable single hop. But if it had two > constructors, say one that has no-arg and configures a default delimiter > and another that take a delimiter as an arg, then in that case the single > hop client would lose the delimiter configured on the server and revert to= > the default one from the no-arg constructor. It seems like this could caus= e > all kinds of bad things to happen. For example in the case of a > StringPrefixPartitionResolver that allows the delimiter to be configured > that one used on this client to route keys to the server would have the > wrong delimiter and complain that the key does not contain the delimiter. I= > will file a geode ticket about this issue but wanted to have it on this > thread to help explain why this initial resolver is not configurable. >=20 >=20 >> On Tue, Jun 6, 2017 at 1:20 PM, Jacob Barrett wrote= : >>=20 >> I have to agree. Something this trivial an limiting is better suited for a= >> blog post or examples somewhere and not a part of the core codebase. >>=20 >> -Jake >>=20 >> On Mon, Jun 5, 2017 at 1:27 PM Udo Kohlmeyer >> wrote: >>=20 >>> My concern with this approach is that we provide an implementation that >>> might be a white elephant and only used by a 1% user base. In addition >>> to that, it does really restrict the user on his keys. >>>=20 >>> Whereas something a little more configurable, like a SPEL >>> implementation, would provide a lot more flexibility. Which means that >>> one could easily change the partition resolver expression upon region >>> creation/configuration. >>>=20 >>> --Udo >>>=20 >>>=20 >>>> On 6/5/17 08:46, Jens Deppe wrote: >>>> I like the idea of keeping the configuration 'conventional' and thus >> not >>>> requiring any server configuration. As soon as you need to define a >> regex >>>> on the server you might as well be writing PartitionResolver code. >>>>=20 >>>> As an aside I also think that using regexes to parse keys would also >>>> introduce a measurable performance hit. >>>>=20 >>>> --Jens >>>>=20 >>>> On Mon, Jun 5, 2017 at 8:21 AM, Udo Kohlmeyer >>> wrote: >>>>=20 >>>>> Whilst I like the idea to make something (and yes, >>>>> DelimitedStringPartitionResolver is the simplest), I feel that we >> might >>>>> be able to do one better. >>>>>=20 >>>>> */Could/* one possibly have an /*SPEL*/ < >> https://docs.spring.io/spring >>>>>=20 >>> -framework/docs/current/spring-framework-reference/ >> html/expressions.html>-based >>>>> PartitionResolver for this? At least this way, we don't have to rely >> on >>>>> delimiters or a strong knowledge of REGEX. >>>>>=20 >>>>> IMO, this would provide the greatest bang for buck implementation. >>>>>=20 >>>>> --Udo >>>>>=20 >>>>>=20 >>>>>=20 >>>>>=20 >>>>>> On 6/2/17 19:15, Jacob Barrett wrote: >>>>>>=20 >>>>>> If you implement as regular expression the user doesn't have to >>> reformat >>>>>> their key to a specific format (akin to making them implement a >>> class). I >>>>>> would concat the matching groups for generate the routing key. >>>>>>=20 >>>>>> Consider RegEx: .*\bcorrelation=3D(\d+).*\bmaybe-something-else=3D(\w= ) >>>>>> With Keys: >>>>>> A: my,key;with:any-chars;unique=3D12345;correlation=3D678/and,maybe >>>>>> -something-else=3Da >>>>>> B: my,key;unique=3D876324;correlation=3D678;and,maybe- >> something-else=3Da,foo >>>>>> C: >>> somthing;different=3D988975;correlation=3D678;then,maybe-something-else=3D= ba >>>>>>=20 >>>>>> Keys A and B would have routing key '678a'. Key C would have routing >>> key >>>>>> '678b'. >>>>>>=20 >>>>>> -Jake >>>>>>=20 >>>>>>=20 >>>>>>=20 >>>>>> Consider >>>>>>=20 >>>>>> On Fri, Jun 2, 2017 at 4:02 PM Darrel Schneider < >> dschneider@pivotal.io >>>>=20 >>>>>> wrote: >>>>>>=20 >>>>>> Geode partitioned regions usually partition the data based on the >> key's >>>>>>> hashcode. >>>>>>> You can do your own partitioning by implementing the >> PartitionResolver >>>>>>> interface and configuring it on the partitioned region. >>>>>>>=20 >>>>>>> In some use cases needing to deploy your class that implements >>>>>>> PartitionResolver can be problematic so we would like to find a way >> to >>>>>>> offer partitioning based on a portion of the key (instead of the >>> default >>>>>>> which uses the entire key) that does not require you to implement >> your >>>>>>> own >>>>>>> PartitionResolver and does not require you to deploy your own code >> to >>> do >>>>>>> the custom partitioning. >>>>>>>=20 >>>>>>> Another group of users that do not want to implement >> PartitionResolver >>>>>>> are >>>>>>> non-java clients. So the solution is required to be usable by >> non-java >>>>>>> geode clients without needing to reimplement the client to support a= >>> new >>>>>>> feature. >>>>>>>=20 >>>>>>> Another constraint on the solution is for it to be both easy to use >>> and >>>>>>> easy to implement. >>>>>>>=20 >>>>>>> The proposed solution is to provide a class named: >>>>>>> org.apache.geode.cache.StringPrefixPartitionResolver >>>>>>> This class will implement PartitionResolver and have a default >>>>>>> constructor. >>>>>>> To use it you need to configure a partitioned region's >>> PartitionResolver >>>>>>> using the already existing mechanism for this (api, gfsh, or xml). >>>>>>> The StringPrefixPartitionResolver will require all keys on its >> region >>> to >>>>>>> be >>>>>>> of type String. >>>>>>> It also requires that the string key contains at least one ':' >>> character. >>>>>>> The substring of the key that precedes the first ':' is the prefix >>> that >>>>>>> will be returned from "getRoutingObject". >>>>>>>=20 >>>>>>> An example of doing this in gfsh is: >>>>>>> create region --name=3Dr1 --type=3DPARTITION >>>>>>> --partition-resolver=3Dorg.apache.geode.cache.StringPrefixPart >>>>>>> itionResolver >>>>>>>=20 >>>>>>> Note that attempting to use a key that is not a String or does not >>>>>>> contain >>>>>>> a ':' will throw an exception. This is to help developers realize >> they >>>>>>> made >>>>>>> a mistake. >>>>>>>=20 >>>>>>> Note that the delimiter is always a ':'. It would be easy to made >> the >>>>>>> delimiter configurable when using apis or xml but currently gfsh >> does >>> not >>>>>>> provide a way to pass parameters to the --partition-resolver create >>>>>>> region >>>>>>> option. >>>>>>>=20 >>>>>>> The only public api change this proposal makes is the new >>>>>>> StringPrefixPartitionResolver class. >>>>>>>=20 >>>>>>>=20 >>>=20 >>>=20 >>=20