You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by Kevin Duling <kd...@pivotal.io> on 2016/12/20 22:11:49 UTC

The right way to remove a region's cache listener?

I'm looking at GEODE-2236
<https://issues.apache.org/jira/browse/GEODE-2236> and
protecting against the NPE is trivial.  But the question is, what is the
right way to do this?  What is the syntax people would expect to use?


What if there are multiple listeners and you wanted to delete one or more
of them?

Re: The right way to remove a region's cache listener?

Posted by Michael Stolz <ms...@pivotal.io>.
I think it would make sense to have a --remove_listener=ListenerTypeB.
Gfsh is really about verbs not end-state I think.

--
Mike Stolz
Principal Engineer, GemFire Product Manager
Mobile: 631-835-4771

On Tue, Jan 3, 2017 at 1:52 PM, Kevin Duling <kd...@pivotal.io> wrote:

> Is this an intuitive User Experience?
>
> Given these two classes:
>
> public class ListenerTypeA extends CacheListenerAdapter implements
> Declarable
>
> and
>
> public class ListenerTypeB extends CacheListenerAdapter implements
> Declarable
>
> And they are programmatically added to a region:
>
> CacheListener listener1 = new ListenerTypeA();
>
> CacheListener listener2 = new ListenerTypeB();
>
> Region region = cache.<String,
> Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
>
>         .initCacheListeners(new CacheListener[]{listener1,
> listener2}).create("regionA");
>
>
> What would the expected gfsh command to remove them.  Should we remove the
> listeners via omission?  For example, removing listener1 might be:
>
> alter region --name=data --cache-listener='my.package.ListenerTypeB'
>
>
> By only listing the listeners I want...either to keep and/or to add,
> listener1 which is a ListenerTypeA, would be removed.
>
>
>
>
>
> On Tue, Dec 20, 2016 at 2:11 PM, Kevin Duling <kd...@pivotal.io> wrote:
>
> > I'm looking at GEODE-2236
> > <https://issues.apache.org/jira/browse/GEODE-2236> and protecting
> against
> > the NPE is trivial.  But the question is, what is the right way to do
> > this?  What is the syntax people would expect to use?
> >
> >
> > What if there are multiple listeners and you wanted to delete one or more
> > of them?
> >
> >
>

Re: The right way to remove a region's cache listener?

Posted by Kirk Lund <kl...@apache.org>.
This is the perfect example of something that is very easy to do in Java
API but becomes overly complex in GFSH.

In the Java API, you can instantiate as many instances of the same
CacheListener class as you want, add them and then remove that specific
instance by passing it in to  public void removeCacheListener(CacheListener
cl) on Region (specifically org.apache.geode.cache.AttributesMutator).
Translating that level of complexity to GFSH commands results in an
explosion of options and reference ids.

For example, if I add the same CacheListener class 3 times, then 1st one is
reference id 1, 2nd is reference id 2, etc (or zero-based if you prefer).
The amount of work required to add that in probably isn't worth it for two
reasons: 1) it's probably not that common of a use case, 2) the user could
instead write a Function or custom mbean that is deployed to the cache
server that'll keep references to the CacheListeners and handle calls to
addCacheListener and removeCacheListener for you. For that matter, you
could deploy a custom GFSH command that then triggers the addCacheListener
and removeCacheListener calls in a deployed Function. Given the ability to
do this pretty easily in a customized way is probably better than trying to
make the command overly flexible (which translates to overly complex).

I would favor improving the docs and blogging new articles that provide
details on how the user can plugin their own GFSH commands and mbeans.


On Thu, Jan 5, 2017 at 7:57 AM, Deepak Dixit <de...@gmail.com>
wrote:

> I would like to suggest, adding "add-cache-listener" option in addition to
> "remove-cache-listener."
> As adding listeners is as difficult as removing when doing alter region.
>
> So alter region will have following options,
>
> 1) add-cache-listener - Will add provided cache listener to existing list.
> 2) remove-cache-listener - Will remove provided cache listeners. (Here we
> may consider passing empty list will remove all listeners)
>
> And old option of cache-listeners will be removed to eliminate confusion.
>
> On Thu, Jan 5, 2017 at 5:51 PM, Zhang Xiawei <zh...@hotmail.com>
> wrote:
>
> > Not sure whether I misunderstand/miss something or not, but isn't it
> > possible that you have multiple instances of the same type of
> > CacheListener? like 2 of ListenerTypeA and 3 of ListenerTypeB, so either
> > way shown below modifies at a "category" level?
> >
> > -Xiawei
> >
> > > On 5 Jan 2017, at 1:25 AM, Anthony Baker <ab...@pivotal.io> wrote:
> > >
> > > Another consideration is that gfsh commands should be easily
> scriptable,
> > IMO.
> > >
> > > If I want to remove just one of the N listeners using this approach, I
> > would need to acquire the list of existing listeners, remove the
> deselected
> > listener, format the list, then pass it to this command.  Is there a way
> to
> > do this in one simple command?
> > >
> > > Anthony
> > >
> > >> On Jan 3, 2017, at 11:08 AM, Kirk Lund <kl...@apache.org> wrote:
> > >>
> > >> +1 I'm for the approach you're proposing. As long as it's documented
> in
> > >> user docs (it's not currently) then this provides a straightforward
> use
> > of
> > >> the existing gfsh syntax without introducing too many new command
> > options.
> > >>
> > >> Create the region with two cache listeners:
> > >> $ create region --name=data
> > >> --cache-listener="my.package.ListenerTypeA,my.package.ListenerTypeB"
> > >>
> > >> Change my mind and decide to remove one of the cache listeners:
> > >> $ alter region --name=data --cache-listener="my.package.
> ListenerTypeB"
> > >>
> > >> -Kirk
> > >>
> > >>
> > >>> On Tue, Jan 3, 2017 at 10:52 AM, Kevin Duling <kd...@pivotal.io>
> > wrote:
> > >>>
> > >>> Is this an intuitive User Experience?
> > >>>
> > >>> Given these two classes:
> > >>>
> > >>> public class ListenerTypeA extends CacheListenerAdapter implements
> > >>> Declarable
> > >>>
> > >>> and
> > >>>
> > >>> public class ListenerTypeB extends CacheListenerAdapter implements
> > >>> Declarable
> > >>>
> > >>> And they are programmatically added to a region:
> > >>>
> > >>> CacheListener listener1 = new ListenerTypeA();
> > >>>
> > >>> CacheListener listener2 = new ListenerTypeB();
> > >>>
> > >>> Region region = cache.<String,
> > >>> Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_
> PROXY)
> > >>>
> > >>>       .initCacheListeners(new CacheListener[]{listener1,
> > >>> listener2}).create("regionA");
> > >>>
> > >>>
> > >>> What would the expected gfsh command to remove them.  Should we
> remove
> > the
> > >>> listeners via omission?  For example, removing listener1 might be:
> > >>>
> > >>> alter region --name=data --cache-listener='my.package.ListenerTypeB'
> > >>>
> > >>>
> > >>> By only listing the listeners I want...either to keep and/or to add,
> > >>> listener1 which is a ListenerTypeA, would be removed.
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>> On Tue, Dec 20, 2016 at 2:11 PM, Kevin Duling <kd...@pivotal.io>
> > wrote:
> > >>>>
> > >>>> I'm looking at GEODE-2236
> > >>>> <https://issues.apache.org/jira/browse/GEODE-2236> and protecting
> > >>> against
> > >>>> the NPE is trivial.  But the question is, what is the right way to
> do
> > >>>> this?  What is the syntax people would expect to use?
> > >>>>
> > >>>>
> > >>>> What if there are multiple listeners and you wanted to delete one or
> > more
> > >>>> of them?
> > >
> >
>
>
>
> --
> From:
>
> Deepak D Dixit
> deepakdixit2011@gmail.com
> +919028507537
>

Re: The right way to remove a region's cache listener?

Posted by Deepak Dixit <de...@gmail.com>.
I would like to suggest, adding "add-cache-listener" option in addition to
"remove-cache-listener."
As adding listeners is as difficult as removing when doing alter region.

So alter region will have following options,

1) add-cache-listener - Will add provided cache listener to existing list.
2) remove-cache-listener - Will remove provided cache listeners. (Here we
may consider passing empty list will remove all listeners)

And old option of cache-listeners will be removed to eliminate confusion.

On Thu, Jan 5, 2017 at 5:51 PM, Zhang Xiawei <zh...@hotmail.com>
wrote:

> Not sure whether I misunderstand/miss something or not, but isn't it
> possible that you have multiple instances of the same type of
> CacheListener? like 2 of ListenerTypeA and 3 of ListenerTypeB, so either
> way shown below modifies at a "category" level?
>
> -Xiawei
>
> > On 5 Jan 2017, at 1:25 AM, Anthony Baker <ab...@pivotal.io> wrote:
> >
> > Another consideration is that gfsh commands should be easily scriptable,
> IMO.
> >
> > If I want to remove just one of the N listeners using this approach, I
> would need to acquire the list of existing listeners, remove the deselected
> listener, format the list, then pass it to this command.  Is there a way to
> do this in one simple command?
> >
> > Anthony
> >
> >> On Jan 3, 2017, at 11:08 AM, Kirk Lund <kl...@apache.org> wrote:
> >>
> >> +1 I'm for the approach you're proposing. As long as it's documented in
> >> user docs (it's not currently) then this provides a straightforward use
> of
> >> the existing gfsh syntax without introducing too many new command
> options.
> >>
> >> Create the region with two cache listeners:
> >> $ create region --name=data
> >> --cache-listener="my.package.ListenerTypeA,my.package.ListenerTypeB"
> >>
> >> Change my mind and decide to remove one of the cache listeners:
> >> $ alter region --name=data --cache-listener="my.package.ListenerTypeB"
> >>
> >> -Kirk
> >>
> >>
> >>> On Tue, Jan 3, 2017 at 10:52 AM, Kevin Duling <kd...@pivotal.io>
> wrote:
> >>>
> >>> Is this an intuitive User Experience?
> >>>
> >>> Given these two classes:
> >>>
> >>> public class ListenerTypeA extends CacheListenerAdapter implements
> >>> Declarable
> >>>
> >>> and
> >>>
> >>> public class ListenerTypeB extends CacheListenerAdapter implements
> >>> Declarable
> >>>
> >>> And they are programmatically added to a region:
> >>>
> >>> CacheListener listener1 = new ListenerTypeA();
> >>>
> >>> CacheListener listener2 = new ListenerTypeB();
> >>>
> >>> Region region = cache.<String,
> >>> Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
> >>>
> >>>       .initCacheListeners(new CacheListener[]{listener1,
> >>> listener2}).create("regionA");
> >>>
> >>>
> >>> What would the expected gfsh command to remove them.  Should we remove
> the
> >>> listeners via omission?  For example, removing listener1 might be:
> >>>
> >>> alter region --name=data --cache-listener='my.package.ListenerTypeB'
> >>>
> >>>
> >>> By only listing the listeners I want...either to keep and/or to add,
> >>> listener1 which is a ListenerTypeA, would be removed.
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>> On Tue, Dec 20, 2016 at 2:11 PM, Kevin Duling <kd...@pivotal.io>
> wrote:
> >>>>
> >>>> I'm looking at GEODE-2236
> >>>> <https://issues.apache.org/jira/browse/GEODE-2236> and protecting
> >>> against
> >>>> the NPE is trivial.  But the question is, what is the right way to do
> >>>> this?  What is the syntax people would expect to use?
> >>>>
> >>>>
> >>>> What if there are multiple listeners and you wanted to delete one or
> more
> >>>> of them?
> >
>



-- 
From:

Deepak D Dixit
deepakdixit2011@gmail.com
+919028507537

Re: The right way to remove a region's cache listener?

Posted by Zhang Xiawei <zh...@hotmail.com>.
Not sure whether I misunderstand/miss something or not, but isn't it possible that you have multiple instances of the same type of CacheListener? like 2 of ListenerTypeA and 3 of ListenerTypeB, so either way shown below modifies at a "category" level?

-Xiawei

> On 5 Jan 2017, at 1:25 AM, Anthony Baker <ab...@pivotal.io> wrote:
> 
> Another consideration is that gfsh commands should be easily scriptable, IMO.
> 
> If I want to remove just one of the N listeners using this approach, I would need to acquire the list of existing listeners, remove the deselected listener, format the list, then pass it to this command.  Is there a way to do this in one simple command?
> 
> Anthony
> 
>> On Jan 3, 2017, at 11:08 AM, Kirk Lund <kl...@apache.org> wrote:
>> 
>> +1 I'm for the approach you're proposing. As long as it's documented in
>> user docs (it's not currently) then this provides a straightforward use of
>> the existing gfsh syntax without introducing too many new command options.
>> 
>> Create the region with two cache listeners:
>> $ create region --name=data
>> --cache-listener="my.package.ListenerTypeA,my.package.ListenerTypeB"
>> 
>> Change my mind and decide to remove one of the cache listeners:
>> $ alter region --name=data --cache-listener="my.package.ListenerTypeB"
>> 
>> -Kirk
>> 
>> 
>>> On Tue, Jan 3, 2017 at 10:52 AM, Kevin Duling <kd...@pivotal.io> wrote:
>>> 
>>> Is this an intuitive User Experience?
>>> 
>>> Given these two classes:
>>> 
>>> public class ListenerTypeA extends CacheListenerAdapter implements
>>> Declarable
>>> 
>>> and
>>> 
>>> public class ListenerTypeB extends CacheListenerAdapter implements
>>> Declarable
>>> 
>>> And they are programmatically added to a region:
>>> 
>>> CacheListener listener1 = new ListenerTypeA();
>>> 
>>> CacheListener listener2 = new ListenerTypeB();
>>> 
>>> Region region = cache.<String,
>>> Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
>>> 
>>>       .initCacheListeners(new CacheListener[]{listener1,
>>> listener2}).create("regionA");
>>> 
>>> 
>>> What would the expected gfsh command to remove them.  Should we remove the
>>> listeners via omission?  For example, removing listener1 might be:
>>> 
>>> alter region --name=data --cache-listener='my.package.ListenerTypeB'
>>> 
>>> 
>>> By only listing the listeners I want...either to keep and/or to add,
>>> listener1 which is a ListenerTypeA, would be removed.
>>> 
>>> 
>>> 
>>> 
>>> 
>>>> On Tue, Dec 20, 2016 at 2:11 PM, Kevin Duling <kd...@pivotal.io> wrote:
>>>> 
>>>> I'm looking at GEODE-2236
>>>> <https://issues.apache.org/jira/browse/GEODE-2236> and protecting
>>> against
>>>> the NPE is trivial.  But the question is, what is the right way to do
>>>> this?  What is the syntax people would expect to use?
>>>> 
>>>> 
>>>> What if there are multiple listeners and you wanted to delete one or more
>>>> of them?
> 

Re: The right way to remove a region's cache listener?

Posted by Anthony Baker <ab...@pivotal.io>.
Another consideration is that gfsh commands should be easily scriptable, IMO.

If I want to remove just one of the N listeners using this approach, I would need to acquire the list of existing listeners, remove the deselected listener, format the list, then pass it to this command.  Is there a way to do this in one simple command?

Anthony

> On Jan 3, 2017, at 11:08 AM, Kirk Lund <kl...@apache.org> wrote:
> 
> +1 I'm for the approach you're proposing. As long as it's documented in
> user docs (it's not currently) then this provides a straightforward use of
> the existing gfsh syntax without introducing too many new command options.
> 
> Create the region with two cache listeners:
> $ create region --name=data
> --cache-listener="my.package.ListenerTypeA,my.package.ListenerTypeB"
> 
> Change my mind and decide to remove one of the cache listeners:
> $ alter region --name=data --cache-listener="my.package.ListenerTypeB"
> 
> -Kirk
> 
> 
> On Tue, Jan 3, 2017 at 10:52 AM, Kevin Duling <kd...@pivotal.io> wrote:
> 
>> Is this an intuitive User Experience?
>> 
>> Given these two classes:
>> 
>> public class ListenerTypeA extends CacheListenerAdapter implements
>> Declarable
>> 
>> and
>> 
>> public class ListenerTypeB extends CacheListenerAdapter implements
>> Declarable
>> 
>> And they are programmatically added to a region:
>> 
>> CacheListener listener1 = new ListenerTypeA();
>> 
>> CacheListener listener2 = new ListenerTypeB();
>> 
>> Region region = cache.<String,
>> Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
>> 
>>        .initCacheListeners(new CacheListener[]{listener1,
>> listener2}).create("regionA");
>> 
>> 
>> What would the expected gfsh command to remove them.  Should we remove the
>> listeners via omission?  For example, removing listener1 might be:
>> 
>> alter region --name=data --cache-listener='my.package.ListenerTypeB'
>> 
>> 
>> By only listing the listeners I want...either to keep and/or to add,
>> listener1 which is a ListenerTypeA, would be removed.
>> 
>> 
>> 
>> 
>> 
>> On Tue, Dec 20, 2016 at 2:11 PM, Kevin Duling <kd...@pivotal.io> wrote:
>> 
>>> I'm looking at GEODE-2236
>>> <https://issues.apache.org/jira/browse/GEODE-2236> and protecting
>> against
>>> the NPE is trivial.  But the question is, what is the right way to do
>>> this?  What is the syntax people would expect to use?
>>> 
>>> 
>>> What if there are multiple listeners and you wanted to delete one or more
>>> of them?
>>> 
>>> 
>> 


Re: The right way to remove a region's cache listener?

Posted by Kevin Duling <kd...@pivotal.io>.
Yes, it does exist.  I'm sure I'm deploying correctly because when I add
the listeners programmatically, they write to the server.log file.

On Tue, Jan 3, 2017 at 3:13 PM, Jinmei Liao <ji...@pivotal.io> wrote:

> You probably did not deploy the jars correctly? See if that jar exist in
> your server's dir.
>
> On Tue, Jan 3, 2017 at 2:51 PM, Kevin Duling <kd...@pivotal.io> wrote:
>
> > I must have some syntax wrong, because I'm not able to add a cache
> listener
> > from the gfsh command line out of the jar I deployed.
> >
> > ListenerTypeA and ListenerTypeB exist in the package 'geode' in my
> > custard-1.0-SNAPSHOT.jar.  I'm able to add those programmatically as I
> > showed earlier.
> >
> > So that I could try to add these via gfsh, I changed my region creation
> > line to:
> >
> > Region region = cache.<String,
> > Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_
> > PROXY).create("regionA");
> >
> >
> > Then I go through the standard steps of starting a locator, server,
> region,
> > and deploy my jar.
> >
> > Now when I try to assign the listener, I get:
> >
> >
> > gfsh>alter region --cache-listener="geode.ListenerTypeA" --name=/regionA
> >
> > Member | Status
> >
> > ------ |
> > ------------------------------------------------------------
> > -----------------------
> >
> > server | ERROR: Could not find class "geode.ListenerTypeA" specified for
> > "cache-listener".
> >
> >
> > Am I doing something wrong, or is this not working as expected?  I wasn't
> > able to find documentation that illustrates how this should work.  The
> best
> > I could find was:
> > http://geode.apache.org/docs/guide/developing/events/cache_
> > event_handler_examples.html
> >
> >
> > On Tue, Jan 3, 2017 at 11:52 AM, John Blum <jb...@pivotal.io> wrote:
> >
> > > `describe region` will show the CacheListeners registered on a Region.
> > >
> > > On Tue, Jan 3, 2017 at 11:44 AM, Dave Barnes <db...@pivotal.io>
> wrote:
> > >
> > > > What gfsh command (if any) lists the cache-listeners available on a
> > given
> > > > region? Seems like if the intention is to support adding and deleting
> > by
> > > > name, there should be a way to list existing names.
> > > >
> > > > On Tue, Jan 3, 2017 at 11:29 AM, Jinmei Liao <ji...@pivotal.io>
> > wrote:
> > > >
> > > > > +1 for remove by specifying only the ones you want to keep:
> > > > >
> > > > > $ alter region --name=data --cache-listener="" will remove all the
> > > cache
> > > > > listeners
> > > > >
> > > > > On Tue, Jan 3, 2017 at 11:08 AM, Kirk Lund <kl...@apache.org>
> wrote:
> > > > >
> > > > > > +1 I'm for the approach you're proposing. As long as it's
> > documented
> > > in
> > > > > > user docs (it's not currently) then this provides a
> straightforward
> > > use
> > > > > of
> > > > > > the existing gfsh syntax without introducing too many new command
> > > > > options.
> > > > > >
> > > > > > Create the region with two cache listeners:
> > > > > > $ create region --name=data
> > > > > > --cache-listener="my.package.ListenerTypeA,my.package.
> > ListenerTypeB"
> > > > > >
> > > > > > Change my mind and decide to remove one of the cache listeners:
> > > > > > $ alter region --name=data --cache-listener="my.package.
> > > ListenerTypeB"
> > > > > >
> > > > > > -Kirk
> > > > > >
> > > > > >
> > > > > > On Tue, Jan 3, 2017 at 10:52 AM, Kevin Duling <
> kduling@pivotal.io>
> > > > > wrote:
> > > > > >
> > > > > > > Is this an intuitive User Experience?
> > > > > > >
> > > > > > > Given these two classes:
> > > > > > >
> > > > > > > public class ListenerTypeA extends CacheListenerAdapter
> > implements
> > > > > > > Declarable
> > > > > > >
> > > > > > > and
> > > > > > >
> > > > > > > public class ListenerTypeB extends CacheListenerAdapter
> > implements
> > > > > > > Declarable
> > > > > > >
> > > > > > > And they are programmatically added to a region:
> > > > > > >
> > > > > > > CacheListener listener1 = new ListenerTypeA();
> > > > > > >
> > > > > > > CacheListener listener2 = new ListenerTypeB();
> > > > > > >
> > > > > > > Region region = cache.<String,
> > > > > > > Customer>createClientRegionFactory(
> ClientRegionShortcut.CACHING_
> > > > PROXY)
> > > > > > >
> > > > > > >         .initCacheListeners(new CacheListener[]{listener1,
> > > > > > > listener2}).create("regionA");
> > > > > > >
> > > > > > >
> > > > > > > What would the expected gfsh command to remove them.  Should we
> > > > remove
> > > > > > the
> > > > > > > listeners via omission?  For example, removing listener1 might
> > be:
> > > > > > >
> > > > > > > alter region --name=data --cache-listener='my.package.
> > > ListenerTypeB'
> > > > > > >
> > > > > > >
> > > > > > > By only listing the listeners I want...either to keep and/or to
> > > add,
> > > > > > > listener1 which is a ListenerTypeA, would be removed.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Tue, Dec 20, 2016 at 2:11 PM, Kevin Duling <
> > kduling@pivotal.io>
> > > > > > wrote:
> > > > > > >
> > > > > > > > I'm looking at GEODE-2236
> > > > > > > > <https://issues.apache.org/jira/browse/GEODE-2236> and
> > > protecting
> > > > > > > against
> > > > > > > > the NPE is trivial.  But the question is, what is the right
> way
> > > to
> > > > do
> > > > > > > > this?  What is the syntax people would expect to use?
> > > > > > > >
> > > > > > > >
> > > > > > > > What if there are multiple listeners and you wanted to delete
> > one
> > > > or
> > > > > > more
> > > > > > > > of them?
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Cheers
> > > > >
> > > > > Jinmei
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > -John
> > > john.blum10101 (skype)
> > >
> >
>
>
>
> --
> Cheers
>
> Jinmei
>

Re: The right way to remove a region's cache listener?

Posted by Jinmei Liao <ji...@pivotal.io>.
You probably did not deploy the jars correctly? See if that jar exist in
your server's dir.

On Tue, Jan 3, 2017 at 2:51 PM, Kevin Duling <kd...@pivotal.io> wrote:

> I must have some syntax wrong, because I'm not able to add a cache listener
> from the gfsh command line out of the jar I deployed.
>
> ListenerTypeA and ListenerTypeB exist in the package 'geode' in my
> custard-1.0-SNAPSHOT.jar.  I'm able to add those programmatically as I
> showed earlier.
>
> So that I could try to add these via gfsh, I changed my region creation
> line to:
>
> Region region = cache.<String,
> Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_
> PROXY).create("regionA");
>
>
> Then I go through the standard steps of starting a locator, server, region,
> and deploy my jar.
>
> Now when I try to assign the listener, I get:
>
>
> gfsh>alter region --cache-listener="geode.ListenerTypeA" --name=/regionA
>
> Member | Status
>
> ------ |
> ------------------------------------------------------------
> -----------------------
>
> server | ERROR: Could not find class "geode.ListenerTypeA" specified for
> "cache-listener".
>
>
> Am I doing something wrong, or is this not working as expected?  I wasn't
> able to find documentation that illustrates how this should work.  The best
> I could find was:
> http://geode.apache.org/docs/guide/developing/events/cache_
> event_handler_examples.html
>
>
> On Tue, Jan 3, 2017 at 11:52 AM, John Blum <jb...@pivotal.io> wrote:
>
> > `describe region` will show the CacheListeners registered on a Region.
> >
> > On Tue, Jan 3, 2017 at 11:44 AM, Dave Barnes <db...@pivotal.io> wrote:
> >
> > > What gfsh command (if any) lists the cache-listeners available on a
> given
> > > region? Seems like if the intention is to support adding and deleting
> by
> > > name, there should be a way to list existing names.
> > >
> > > On Tue, Jan 3, 2017 at 11:29 AM, Jinmei Liao <ji...@pivotal.io>
> wrote:
> > >
> > > > +1 for remove by specifying only the ones you want to keep:
> > > >
> > > > $ alter region --name=data --cache-listener="" will remove all the
> > cache
> > > > listeners
> > > >
> > > > On Tue, Jan 3, 2017 at 11:08 AM, Kirk Lund <kl...@apache.org> wrote:
> > > >
> > > > > +1 I'm for the approach you're proposing. As long as it's
> documented
> > in
> > > > > user docs (it's not currently) then this provides a straightforward
> > use
> > > > of
> > > > > the existing gfsh syntax without introducing too many new command
> > > > options.
> > > > >
> > > > > Create the region with two cache listeners:
> > > > > $ create region --name=data
> > > > > --cache-listener="my.package.ListenerTypeA,my.package.
> ListenerTypeB"
> > > > >
> > > > > Change my mind and decide to remove one of the cache listeners:
> > > > > $ alter region --name=data --cache-listener="my.package.
> > ListenerTypeB"
> > > > >
> > > > > -Kirk
> > > > >
> > > > >
> > > > > On Tue, Jan 3, 2017 at 10:52 AM, Kevin Duling <kd...@pivotal.io>
> > > > wrote:
> > > > >
> > > > > > Is this an intuitive User Experience?
> > > > > >
> > > > > > Given these two classes:
> > > > > >
> > > > > > public class ListenerTypeA extends CacheListenerAdapter
> implements
> > > > > > Declarable
> > > > > >
> > > > > > and
> > > > > >
> > > > > > public class ListenerTypeB extends CacheListenerAdapter
> implements
> > > > > > Declarable
> > > > > >
> > > > > > And they are programmatically added to a region:
> > > > > >
> > > > > > CacheListener listener1 = new ListenerTypeA();
> > > > > >
> > > > > > CacheListener listener2 = new ListenerTypeB();
> > > > > >
> > > > > > Region region = cache.<String,
> > > > > > Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_
> > > PROXY)
> > > > > >
> > > > > >         .initCacheListeners(new CacheListener[]{listener1,
> > > > > > listener2}).create("regionA");
> > > > > >
> > > > > >
> > > > > > What would the expected gfsh command to remove them.  Should we
> > > remove
> > > > > the
> > > > > > listeners via omission?  For example, removing listener1 might
> be:
> > > > > >
> > > > > > alter region --name=data --cache-listener='my.package.
> > ListenerTypeB'
> > > > > >
> > > > > >
> > > > > > By only listing the listeners I want...either to keep and/or to
> > add,
> > > > > > listener1 which is a ListenerTypeA, would be removed.
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Tue, Dec 20, 2016 at 2:11 PM, Kevin Duling <
> kduling@pivotal.io>
> > > > > wrote:
> > > > > >
> > > > > > > I'm looking at GEODE-2236
> > > > > > > <https://issues.apache.org/jira/browse/GEODE-2236> and
> > protecting
> > > > > > against
> > > > > > > the NPE is trivial.  But the question is, what is the right way
> > to
> > > do
> > > > > > > this?  What is the syntax people would expect to use?
> > > > > > >
> > > > > > >
> > > > > > > What if there are multiple listeners and you wanted to delete
> one
> > > or
> > > > > more
> > > > > > > of them?
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Cheers
> > > >
> > > > Jinmei
> > > >
> > >
> >
> >
> >
> > --
> > -John
> > john.blum10101 (skype)
> >
>



-- 
Cheers

Jinmei

Re: The right way to remove a region's cache listener?

Posted by Kevin Duling <kd...@pivotal.io>.
I must have some syntax wrong, because I'm not able to add a cache listener
from the gfsh command line out of the jar I deployed.

ListenerTypeA and ListenerTypeB exist in the package 'geode' in my
custard-1.0-SNAPSHOT.jar.  I'm able to add those programmatically as I
showed earlier.

So that I could try to add these via gfsh, I changed my region creation
line to:

Region region = cache.<String,
Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("regionA");


Then I go through the standard steps of starting a locator, server, region,
and deploy my jar.

Now when I try to assign the listener, I get:


gfsh>alter region --cache-listener="geode.ListenerTypeA" --name=/regionA

Member | Status

------ |
-----------------------------------------------------------------------------------

server | ERROR: Could not find class "geode.ListenerTypeA" specified for
"cache-listener".


Am I doing something wrong, or is this not working as expected?  I wasn't
able to find documentation that illustrates how this should work.  The best
I could find was:
http://geode.apache.org/docs/guide/developing/events/cache_event_handler_examples.html


On Tue, Jan 3, 2017 at 11:52 AM, John Blum <jb...@pivotal.io> wrote:

> `describe region` will show the CacheListeners registered on a Region.
>
> On Tue, Jan 3, 2017 at 11:44 AM, Dave Barnes <db...@pivotal.io> wrote:
>
> > What gfsh command (if any) lists the cache-listeners available on a given
> > region? Seems like if the intention is to support adding and deleting by
> > name, there should be a way to list existing names.
> >
> > On Tue, Jan 3, 2017 at 11:29 AM, Jinmei Liao <ji...@pivotal.io> wrote:
> >
> > > +1 for remove by specifying only the ones you want to keep:
> > >
> > > $ alter region --name=data --cache-listener="" will remove all the
> cache
> > > listeners
> > >
> > > On Tue, Jan 3, 2017 at 11:08 AM, Kirk Lund <kl...@apache.org> wrote:
> > >
> > > > +1 I'm for the approach you're proposing. As long as it's documented
> in
> > > > user docs (it's not currently) then this provides a straightforward
> use
> > > of
> > > > the existing gfsh syntax without introducing too many new command
> > > options.
> > > >
> > > > Create the region with two cache listeners:
> > > > $ create region --name=data
> > > > --cache-listener="my.package.ListenerTypeA,my.package.ListenerTypeB"
> > > >
> > > > Change my mind and decide to remove one of the cache listeners:
> > > > $ alter region --name=data --cache-listener="my.package.
> ListenerTypeB"
> > > >
> > > > -Kirk
> > > >
> > > >
> > > > On Tue, Jan 3, 2017 at 10:52 AM, Kevin Duling <kd...@pivotal.io>
> > > wrote:
> > > >
> > > > > Is this an intuitive User Experience?
> > > > >
> > > > > Given these two classes:
> > > > >
> > > > > public class ListenerTypeA extends CacheListenerAdapter implements
> > > > > Declarable
> > > > >
> > > > > and
> > > > >
> > > > > public class ListenerTypeB extends CacheListenerAdapter implements
> > > > > Declarable
> > > > >
> > > > > And they are programmatically added to a region:
> > > > >
> > > > > CacheListener listener1 = new ListenerTypeA();
> > > > >
> > > > > CacheListener listener2 = new ListenerTypeB();
> > > > >
> > > > > Region region = cache.<String,
> > > > > Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_
> > PROXY)
> > > > >
> > > > >         .initCacheListeners(new CacheListener[]{listener1,
> > > > > listener2}).create("regionA");
> > > > >
> > > > >
> > > > > What would the expected gfsh command to remove them.  Should we
> > remove
> > > > the
> > > > > listeners via omission?  For example, removing listener1 might be:
> > > > >
> > > > > alter region --name=data --cache-listener='my.package.
> ListenerTypeB'
> > > > >
> > > > >
> > > > > By only listing the listeners I want...either to keep and/or to
> add,
> > > > > listener1 which is a ListenerTypeA, would be removed.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > On Tue, Dec 20, 2016 at 2:11 PM, Kevin Duling <kd...@pivotal.io>
> > > > wrote:
> > > > >
> > > > > > I'm looking at GEODE-2236
> > > > > > <https://issues.apache.org/jira/browse/GEODE-2236> and
> protecting
> > > > > against
> > > > > > the NPE is trivial.  But the question is, what is the right way
> to
> > do
> > > > > > this?  What is the syntax people would expect to use?
> > > > > >
> > > > > >
> > > > > > What if there are multiple listeners and you wanted to delete one
> > or
> > > > more
> > > > > > of them?
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Cheers
> > >
> > > Jinmei
> > >
> >
>
>
>
> --
> -John
> john.blum10101 (skype)
>

Re: The right way to remove a region's cache listener?

Posted by John Blum <jb...@pivotal.io>.
`describe region` will show the CacheListeners registered on a Region.

On Tue, Jan 3, 2017 at 11:44 AM, Dave Barnes <db...@pivotal.io> wrote:

> What gfsh command (if any) lists the cache-listeners available on a given
> region? Seems like if the intention is to support adding and deleting by
> name, there should be a way to list existing names.
>
> On Tue, Jan 3, 2017 at 11:29 AM, Jinmei Liao <ji...@pivotal.io> wrote:
>
> > +1 for remove by specifying only the ones you want to keep:
> >
> > $ alter region --name=data --cache-listener="" will remove all the cache
> > listeners
> >
> > On Tue, Jan 3, 2017 at 11:08 AM, Kirk Lund <kl...@apache.org> wrote:
> >
> > > +1 I'm for the approach you're proposing. As long as it's documented in
> > > user docs (it's not currently) then this provides a straightforward use
> > of
> > > the existing gfsh syntax without introducing too many new command
> > options.
> > >
> > > Create the region with two cache listeners:
> > > $ create region --name=data
> > > --cache-listener="my.package.ListenerTypeA,my.package.ListenerTypeB"
> > >
> > > Change my mind and decide to remove one of the cache listeners:
> > > $ alter region --name=data --cache-listener="my.package.ListenerTypeB"
> > >
> > > -Kirk
> > >
> > >
> > > On Tue, Jan 3, 2017 at 10:52 AM, Kevin Duling <kd...@pivotal.io>
> > wrote:
> > >
> > > > Is this an intuitive User Experience?
> > > >
> > > > Given these two classes:
> > > >
> > > > public class ListenerTypeA extends CacheListenerAdapter implements
> > > > Declarable
> > > >
> > > > and
> > > >
> > > > public class ListenerTypeB extends CacheListenerAdapter implements
> > > > Declarable
> > > >
> > > > And they are programmatically added to a region:
> > > >
> > > > CacheListener listener1 = new ListenerTypeA();
> > > >
> > > > CacheListener listener2 = new ListenerTypeB();
> > > >
> > > > Region region = cache.<String,
> > > > Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_
> PROXY)
> > > >
> > > >         .initCacheListeners(new CacheListener[]{listener1,
> > > > listener2}).create("regionA");
> > > >
> > > >
> > > > What would the expected gfsh command to remove them.  Should we
> remove
> > > the
> > > > listeners via omission?  For example, removing listener1 might be:
> > > >
> > > > alter region --name=data --cache-listener='my.package.ListenerTypeB'
> > > >
> > > >
> > > > By only listing the listeners I want...either to keep and/or to add,
> > > > listener1 which is a ListenerTypeA, would be removed.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On Tue, Dec 20, 2016 at 2:11 PM, Kevin Duling <kd...@pivotal.io>
> > > wrote:
> > > >
> > > > > I'm looking at GEODE-2236
> > > > > <https://issues.apache.org/jira/browse/GEODE-2236> and protecting
> > > > against
> > > > > the NPE is trivial.  But the question is, what is the right way to
> do
> > > > > this?  What is the syntax people would expect to use?
> > > > >
> > > > >
> > > > > What if there are multiple listeners and you wanted to delete one
> or
> > > more
> > > > > of them?
> > > > >
> > > > >
> > > >
> > >
> >
> >
> >
> > --
> > Cheers
> >
> > Jinmei
> >
>



-- 
-John
john.blum10101 (skype)

Re: The right way to remove a region's cache listener?

Posted by Dave Barnes <db...@pivotal.io>.
What gfsh command (if any) lists the cache-listeners available on a given
region? Seems like if the intention is to support adding and deleting by
name, there should be a way to list existing names.

On Tue, Jan 3, 2017 at 11:29 AM, Jinmei Liao <ji...@pivotal.io> wrote:

> +1 for remove by specifying only the ones you want to keep:
>
> $ alter region --name=data --cache-listener="" will remove all the cache
> listeners
>
> On Tue, Jan 3, 2017 at 11:08 AM, Kirk Lund <kl...@apache.org> wrote:
>
> > +1 I'm for the approach you're proposing. As long as it's documented in
> > user docs (it's not currently) then this provides a straightforward use
> of
> > the existing gfsh syntax without introducing too many new command
> options.
> >
> > Create the region with two cache listeners:
> > $ create region --name=data
> > --cache-listener="my.package.ListenerTypeA,my.package.ListenerTypeB"
> >
> > Change my mind and decide to remove one of the cache listeners:
> > $ alter region --name=data --cache-listener="my.package.ListenerTypeB"
> >
> > -Kirk
> >
> >
> > On Tue, Jan 3, 2017 at 10:52 AM, Kevin Duling <kd...@pivotal.io>
> wrote:
> >
> > > Is this an intuitive User Experience?
> > >
> > > Given these two classes:
> > >
> > > public class ListenerTypeA extends CacheListenerAdapter implements
> > > Declarable
> > >
> > > and
> > >
> > > public class ListenerTypeB extends CacheListenerAdapter implements
> > > Declarable
> > >
> > > And they are programmatically added to a region:
> > >
> > > CacheListener listener1 = new ListenerTypeA();
> > >
> > > CacheListener listener2 = new ListenerTypeB();
> > >
> > > Region region = cache.<String,
> > > Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
> > >
> > >         .initCacheListeners(new CacheListener[]{listener1,
> > > listener2}).create("regionA");
> > >
> > >
> > > What would the expected gfsh command to remove them.  Should we remove
> > the
> > > listeners via omission?  For example, removing listener1 might be:
> > >
> > > alter region --name=data --cache-listener='my.package.ListenerTypeB'
> > >
> > >
> > > By only listing the listeners I want...either to keep and/or to add,
> > > listener1 which is a ListenerTypeA, would be removed.
> > >
> > >
> > >
> > >
> > >
> > > On Tue, Dec 20, 2016 at 2:11 PM, Kevin Duling <kd...@pivotal.io>
> > wrote:
> > >
> > > > I'm looking at GEODE-2236
> > > > <https://issues.apache.org/jira/browse/GEODE-2236> and protecting
> > > against
> > > > the NPE is trivial.  But the question is, what is the right way to do
> > > > this?  What is the syntax people would expect to use?
> > > >
> > > >
> > > > What if there are multiple listeners and you wanted to delete one or
> > more
> > > > of them?
> > > >
> > > >
> > >
> >
>
>
>
> --
> Cheers
>
> Jinmei
>

Re: The right way to remove a region's cache listener?

Posted by Jinmei Liao <ji...@pivotal.io>.
+1 for remove by specifying only the ones you want to keep:

$ alter region --name=data --cache-listener="" will remove all the cache
listeners

On Tue, Jan 3, 2017 at 11:08 AM, Kirk Lund <kl...@apache.org> wrote:

> +1 I'm for the approach you're proposing. As long as it's documented in
> user docs (it's not currently) then this provides a straightforward use of
> the existing gfsh syntax without introducing too many new command options.
>
> Create the region with two cache listeners:
> $ create region --name=data
> --cache-listener="my.package.ListenerTypeA,my.package.ListenerTypeB"
>
> Change my mind and decide to remove one of the cache listeners:
> $ alter region --name=data --cache-listener="my.package.ListenerTypeB"
>
> -Kirk
>
>
> On Tue, Jan 3, 2017 at 10:52 AM, Kevin Duling <kd...@pivotal.io> wrote:
>
> > Is this an intuitive User Experience?
> >
> > Given these two classes:
> >
> > public class ListenerTypeA extends CacheListenerAdapter implements
> > Declarable
> >
> > and
> >
> > public class ListenerTypeB extends CacheListenerAdapter implements
> > Declarable
> >
> > And they are programmatically added to a region:
> >
> > CacheListener listener1 = new ListenerTypeA();
> >
> > CacheListener listener2 = new ListenerTypeB();
> >
> > Region region = cache.<String,
> > Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
> >
> >         .initCacheListeners(new CacheListener[]{listener1,
> > listener2}).create("regionA");
> >
> >
> > What would the expected gfsh command to remove them.  Should we remove
> the
> > listeners via omission?  For example, removing listener1 might be:
> >
> > alter region --name=data --cache-listener='my.package.ListenerTypeB'
> >
> >
> > By only listing the listeners I want...either to keep and/or to add,
> > listener1 which is a ListenerTypeA, would be removed.
> >
> >
> >
> >
> >
> > On Tue, Dec 20, 2016 at 2:11 PM, Kevin Duling <kd...@pivotal.io>
> wrote:
> >
> > > I'm looking at GEODE-2236
> > > <https://issues.apache.org/jira/browse/GEODE-2236> and protecting
> > against
> > > the NPE is trivial.  But the question is, what is the right way to do
> > > this?  What is the syntax people would expect to use?
> > >
> > >
> > > What if there are multiple listeners and you wanted to delete one or
> more
> > > of them?
> > >
> > >
> >
>



-- 
Cheers

Jinmei

Re: The right way to remove a region's cache listener?

Posted by Kirk Lund <kl...@apache.org>.
+1 I'm for the approach you're proposing. As long as it's documented in
user docs (it's not currently) then this provides a straightforward use of
the existing gfsh syntax without introducing too many new command options.

Create the region with two cache listeners:
$ create region --name=data
--cache-listener="my.package.ListenerTypeA,my.package.ListenerTypeB"

Change my mind and decide to remove one of the cache listeners:
$ alter region --name=data --cache-listener="my.package.ListenerTypeB"

-Kirk


On Tue, Jan 3, 2017 at 10:52 AM, Kevin Duling <kd...@pivotal.io> wrote:

> Is this an intuitive User Experience?
>
> Given these two classes:
>
> public class ListenerTypeA extends CacheListenerAdapter implements
> Declarable
>
> and
>
> public class ListenerTypeB extends CacheListenerAdapter implements
> Declarable
>
> And they are programmatically added to a region:
>
> CacheListener listener1 = new ListenerTypeA();
>
> CacheListener listener2 = new ListenerTypeB();
>
> Region region = cache.<String,
> Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
>
>         .initCacheListeners(new CacheListener[]{listener1,
> listener2}).create("regionA");
>
>
> What would the expected gfsh command to remove them.  Should we remove the
> listeners via omission?  For example, removing listener1 might be:
>
> alter region --name=data --cache-listener='my.package.ListenerTypeB'
>
>
> By only listing the listeners I want...either to keep and/or to add,
> listener1 which is a ListenerTypeA, would be removed.
>
>
>
>
>
> On Tue, Dec 20, 2016 at 2:11 PM, Kevin Duling <kd...@pivotal.io> wrote:
>
> > I'm looking at GEODE-2236
> > <https://issues.apache.org/jira/browse/GEODE-2236> and protecting
> against
> > the NPE is trivial.  But the question is, what is the right way to do
> > this?  What is the syntax people would expect to use?
> >
> >
> > What if there are multiple listeners and you wanted to delete one or more
> > of them?
> >
> >
>

Re: The right way to remove a region's cache listener?

Posted by Kevin Duling <kd...@pivotal.io>.
Is this an intuitive User Experience?

Given these two classes:

public class ListenerTypeA extends CacheListenerAdapter implements Declarable

and

public class ListenerTypeB extends CacheListenerAdapter implements Declarable

And they are programmatically added to a region:

CacheListener listener1 = new ListenerTypeA();

CacheListener listener2 = new ListenerTypeB();

Region region = cache.<String,
Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)

        .initCacheListeners(new CacheListener[]{listener1,
listener2}).create("regionA");


What would the expected gfsh command to remove them.  Should we remove the
listeners via omission?  For example, removing listener1 might be:

alter region --name=data --cache-listener='my.package.ListenerTypeB'


By only listing the listeners I want...either to keep and/or to add,
listener1 which is a ListenerTypeA, would be removed.





On Tue, Dec 20, 2016 at 2:11 PM, Kevin Duling <kd...@pivotal.io> wrote:

> I'm looking at GEODE-2236
> <https://issues.apache.org/jira/browse/GEODE-2236> and protecting against
> the NPE is trivial.  But the question is, what is the right way to do
> this?  What is the syntax people would expect to use?
>
>
> What if there are multiple listeners and you wanted to delete one or more
> of them?
>
>