Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 52C3A17952 for ; Sun, 9 Aug 2015 17:17:42 +0000 (UTC) Received: (qmail 90489 invoked by uid 500); 9 Aug 2015 17:17:42 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 90360 invoked by uid 500); 9 Aug 2015 17:17:41 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 90349 invoked by uid 99); 9 Aug 2015 17:17:41 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Aug 2015 17:17:41 +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 3896119FD40 for ; Sun, 9 Aug 2015 17:17:41 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.981 X-Spam-Level: *** X-Spam-Status: No, score=3.981 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=3, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id Ct_x3z6ge63e for ; Sun, 9 Aug 2015 17:17:35 +0000 (UTC) Received: from mail-ob0-f169.google.com (mail-ob0-f169.google.com [209.85.214.169]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 2BBA62104D for ; Sun, 9 Aug 2015 17:17:35 +0000 (UTC) Received: by obbhe7 with SMTP id he7so13221519obb.0 for ; Sun, 09 Aug 2015 10:17:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-type; bh=P8bXlkDn+DymgFMxFFwvSlirPMBrezagac32DUCXtlY=; b=A2VKWMvzdOdftxXkrmM6awy7LF9WrnLR9FHbwlnGiZSV/gFaQ8ll7ZNh3STvslwEtN UqjWqu4i9Ai3TjfwEC/WcoH5kYPspKS6+rCzqACKoYX0ddFvfeRpAsm+XQMglecfaGEu eph4Cx7Vvj4bqDhhdVdLCL0dBXBhbV+IrgQOK5BobxWDqX5Lm44Mlucu7d6jbpopgqgR mQm+zTeQk35SRutZ8LgvBh25c0u28YScJRB9dp4eicJa17yNpbBLSCs+sTAecZOrhUT3 +cw4oEDIw7+nsI4qdrqTrpxW7hVSlbCsQ8irozy95jtV6J9Ulz1oJltfKfa8FohvEU33 sFMw== X-Gm-Message-State: ALoCoQlYU0nBfiJfMD8ikHBu3oE7VwfujrsVkCpTeQ+MBGBMxbPZxVdF3umLw3LvY5jmt9MuCFVA X-Received: by 10.60.132.108 with SMTP id ot12mr16727560oeb.44.1439140647778; Sun, 09 Aug 2015 10:17:27 -0700 (PDT) MIME-Version: 1.0 References: <55C69232.8070400@gmail.com> <55C69BFF.1020207@gmail.com> <55C76CCC.1020409@oliver-heger.de> <55C77331.3090100@gmail.com> In-Reply-To: From: James Carman Date: Sun, 09 Aug 2015 17:17:17 +0000 Message-ID: Subject: Re: [pool] Interceptors To: Commons Developers List Content-Type: multipart/alternative; boundary=047d7b47238017d4e7051ce40bfd --047d7b47238017d4e7051ce40bfd Content-Type: text/plain; charset=UTF-8 Okay, how about this for a proposal? We create a new module in commons-proxy called commons-proxy-pool which has a nice base class for folks to be able to create proxy objects to be members of their pool. We could call it ProxiedPoolableObjectFactory or something like that. This class would have helper methods or whatever to make it easy to create proxy objects which can include interceptors and what not. Then, commons-pool doesn't have to know anything about proxies at all. It just continues to manage a pool of objects of a certain type. The objects just happen to be proxies that (may or may not) have interceptors. We don't have to worry about synchronization either. As for the logging (and metrics, etc) solution, I still think a listener pattern is the way to go. Furthermore, I would suggest we deliver the "events" asynchronously to avoid slowing down the pool. The events would be stuff like "object borrowed", "object returned", etc. On Sun, Aug 9, 2015 at 11:53 AM James Carman wrote: > If you want to decorate the calls to the pooled objects, then use commons > proxy and a delegator proxy. Let's not bleed into other areas. Let pool > concentrate on what it does best. > On Sun, Aug 9, 2015 at 11:45 AM James Carman > wrote: > >> I lean toward listeners instead. Much simpler >> On Sun, Aug 9, 2015 at 11:35 AM Phil Steitz >> wrote: >> >>> On 8/9/15 8:07 AM, Oliver Heger wrote: >>> > >>> > >>> > On 09.08.2015 02:49, James Carman wrote: >>> >> Yep, same thing I said back in the day. Would we want it to be a >>> >> true >>> >> "interceptor" or more of a "listener"? >>> > >>> > Sounds like a usual and interesting feature. IIUC the proposal of >>> > Phil, it goes more in the direction of interceptors. >>> > >>> > A point to keep in mind is how does this feature impact >>> > synchronization? Can interceptors be invoked outside of >>> > synchronized blocks? Otherwise, there is a certain risk of >>> > introducing subtle bugs. Bloch calls this "calling an alien method >>> > with a lock held". >>> >>> Thanks, Oliver and very good point on synchronization. This would >>> require care. The nice thing about pool2 is that we have vastly >>> reduced the scope of synchronization. Most importantly (actually >>> since about pool 1.5), factory methods are all outside of sync >>> blocks and no locks are held on objects checked out by the pool >>> [1]. That said, we would need to be careful not to create liveness >>> or performance issues and we would have to provide good >>> documentation on things to look out for when implementing interceptors. >>> >>> Phil >>> >>> [1] The pool maintenance thread and borrow / return operations do >>> acquire locks on the PooledObject wrappers used by the pool, but not >>> on the objects that the interceptors would be working with. >>> Thread-safety of pool methods should ensure that use of pool >>> references in interceptors would also be safe. >>> >>> >>> > >>> > My 2 cents >>> > Oliver >>> > >>> >> >>> >> On Sat, Aug 8, 2015 at 8:18 PM Phil Steitz >>> >> wrote: >>> >> >>> >>> On 8/8/15 5:04 PM, James Carman wrote: >>> >>>> We talked about this a while back with respect to logging,, >>> >>>> having a >>> >>>> PoolListener interface or something. >>> >>> >>> >>> Right. That could be one use. The nice thing there is the >>> >>> interceptor could bring in whatever logging / event propagation >>> >>> infrastructure it wanted to use. >>> >>> >>> >>> Phil >>> >>>> On Sat, Aug 8, 2015 at 7:36 PM Phil Steitz >>> >>> wrote: >>> >>>> >>> >>>>> Tomcat's jdbc-pool has an interceptor feature that allows custom >>> >>>>> code to be inserted into methods called on connections managed by >>> >>>>> the pool. In [pool], we have the core infrastructure to support >>> >>>>> this in a generic way via the ProxiedObjectPool. I propose >>> >>>>> that we >>> >>>>> extend this to allow users to configure interceptors to be called >>> >>>>> when registered methods are invoked on checked out objects. I >>> >>>>> haven't really thought through how configuration would work, but >>> >>>>> basically clients would register methods and possibly interceptor >>> >>>>> properties and the interceptors would get references to the >>> >>>>> method, >>> >>>>> arguments, pool and pooled object. Configuring interceptors in a >>> >>>>> GOP or GKOP would cause it to be wrapped in a ProxiedObjectPool. >>> >>>>> Eventually, we could use this [pool] capability to enable the >>> >>>>> kind >>> >>>>> of thing that jdbc-pool provides with its interceptors in DBCP. >>> >>>>> With [pool] itself, I could see providing method stats >>> >>>>> collectors, >>> >>>>> abandoned timer reset (avoiding having to implement use()) and >>> >>>>> maybe >>> >>>>> a pooled object properties cache. If there are no objections, I >>> >>>>> will open a JIRA and start experimenting. >>> >>>>> >>> >>>>> Phil >>> >>>>> >>> >>>>> >>> >>>>> >>> >>>>> >>> >>>>> >>> >>>>> >>> --------------------------------------------------------------------- >>> >>>>> >>> >>>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >>> >>>>> For additional commands, e-mail: dev-help@commons.apache.org >>> >>>>> >>> >>>>> >>> >>> >>> >>> >>> >>> --------------------------------------------------------------------- >>> >>> >>> >>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >>> >>> For additional commands, e-mail: dev-help@commons.apache.org >>> >>> >>> >>> >>> >> >>> > >>> > --------------------------------------------------------------------- >>> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >>> > For additional commands, e-mail: dev-help@commons.apache.org >>> > >>> > >>> >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >>> For additional commands, e-mail: dev-help@commons.apache.org >>> >>> --047d7b47238017d4e7051ce40bfd--