You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by Jun Aoki <ja...@pivotal.io> on 2016/09/13 23:06:04 UTC

How to get an Mbean of client federated by JMX Manager?

Hi Geode community,

We have a use case where we would like a client side JVM to register Mbean
and federated by JMX Manager on a locator. (As a result,  jconsole that
connects to JMX Manager can see what's happening on the client JVM that
"connects" to the cluster. We do so currently ClientCache [1])
We are referring
https://cwiki.apache.org/confluence/display/GEODE/Creating+Custom+MXBean
and are able to get MBean on a *GF Server* federated.
But we would like to do the same with MBean on a client JVM.

We are assuming that if we can get a cache of server (not ClientCache) then
we can pass it to ManagementService([2]just like the doc said) but we don't
know how to get a server Cache instance on a client JVM.

This might be an unpolished question but could you please let us know if we
are thinking right way and / or how we can achieve it?


[1] This is how we get "connected" through ClientCache to the GF cluster.
Region region = clientCache.createClientRegionFactory("PROXY").create(REGION
)


[2] This is what the doc says and it works for us on server side.
ManagementService service = ManagementService.getManagementService(cache);
// where the cache is Cache instance)
service.registerMBean(bean, beanName);
service.federate(beanName, CustomMXBean.class, false);


-- 
Thank you,
- jun

*Pivotal*

Re: How to get an Mbean of client federated by JMX Manager?

Posted by Kirk Lund <kl...@pivotal.io>.
Barry's suggestion is a good alternative. You could write a function that
the client executes on a server -- the function would create and register a
custom MBean that includes a CacheListener for a dedicated Region. The
client would then perform puts into that dedicated Region, the
CacheListener would be notified for every update and the CacheListener code
would then update state on the MBean. I've never tried it but if you do,
please share!

Thanks,
Kirk


On Thu, Sep 15, 2016 at 12:07 PM, Kirk Lund <kl...@pivotal.io> wrote:

> The MBean federation mechanism is implemented using REPLICATED regions so
> it requires that the JVM joins the Geode cluster. The only way to make this
> work is to convert your Geode Java client to be a Geode member that
> actually joins the cluster.
>
> Each Geode Java client does have its own PlatformMBeanServer which
> contains Geode MBeans for itself (which you can view via JConsole if you
> connect directly to that JVM) but these MBeans are never federated into any
> other Geode process unless that JVM is a member of the cluster.
>
> Thanks,
> Kirk
>
>
> On Wed, Sep 14, 2016 at 4:40 PM, Jun Aoki <ja...@pivotal.io> wrote:
>
>> Jinmei/Barry, thank you for responding! Will investigate more and bring
>> more solid questions.
>>
>> On Tue, Sep 13, 2016 at 5:15 PM, Barry Oglesby <bo...@pivotal.io>
>> wrote:
>>
>> > The way that is done internally is that the client periodically puts
>> stats
>> > about itself into a local region. See
>> > ClientStatsManager.publishClientStats. These stats get sent to the
>> server
>> > where they used by CacheServerMBean.showClientStats. You could do
>> > something
>> > similar with your client data either using a region like this or a
>> > function. Either way, you probably want a server MBean providing this
>> data,
>> > not a client MBean.
>> >
>> >
>> > Thanks,
>> > Barry Oglesby
>> >
>> >
>> > On Tue, Sep 13, 2016 at 4:48 PM, Jinmei Liao <ji...@pivotal.io> wrote:
>> >
>> > > It looks like you want to register an MBean in a remote MBeanServer.
>> > First
>> > > of all, the mBean needs to be serializable to be sent across the wire,
>> > > secondly, mBeans usually reflect the states of the application
>> resource,
>> > > and this mBean will need to have some pointer back to your client JVM
>> to
>> > > gather status. Thirdly and probably the most important of all, is that
>> > > mBeanServerConnection doesn't have a "registerMbean" method at all,
>> and
>> > > probably for good reasons. See if this article would be any help to
>> you:
>> > >
>> > > https://blogs.oracle.com/jmxetc/entry/do_not_do_this_but
>> > >
>> > > Thanks!
>> > >
>> > > On Tue, Sep 13, 2016 at 4:06 PM, Jun Aoki <ja...@pivotal.io> wrote:
>> > >
>> > > > Hi Geode community,
>> > > >
>> > > > We have a use case where we would like a client side JVM to register
>> > > Mbean
>> > > > and federated by JMX Manager on a locator. (As a result,  jconsole
>> that
>> > > > connects to JMX Manager can see what's happening on the client JVM
>> that
>> > > > "connects" to the cluster. We do so currently ClientCache [1])
>> > > > We are referring
>> > > > https://cwiki.apache.org/confluence/display/GEODE/
>> > Creating+Custom+MXBean
>> > > > and are able to get MBean on a *GF Server* federated.
>> > > > But we would like to do the same with MBean on a client JVM.
>> > > >
>> > > > We are assuming that if we can get a cache of server (not
>> ClientCache)
>> > > then
>> > > > we can pass it to ManagementService([2]just like the doc said) but
>> we
>> > > don't
>> > > > know how to get a server Cache instance on a client JVM.
>> > > >
>> > > > This might be an unpolished question but could you please let us
>> know
>> > if
>> > > we
>> > > > are thinking right way and / or how we can achieve it?
>> > > >
>> > > >
>> > > > [1] This is how we get "connected" through ClientCache to the GF
>> > cluster.
>> > > > Region region = clientCache.createClientRegionFactory("
>> > > > PROXY").create(REGION
>> > > > )
>> > > >
>> > > >
>> > > > [2] This is what the doc says and it works for us on server side.
>> > > > ManagementService service = ManagementService.
>> > > getManagementService(cache);
>> > > > // where the cache is Cache instance)
>> > > > service.registerMBean(bean, beanName);
>> > > > service.federate(beanName, CustomMXBean.class, false);
>> > > >
>> > > >
>> > > > --
>> > > > Thank you,
>> > > > - jun
>> > > >
>> > > > *Pivotal*
>> > > >
>> > >
>> > >
>> > >
>> > > --
>> > > Cheers
>> > >
>> > > Jinmei
>> > >
>> >
>>
>>
>>
>> --
>> Thank you,
>> - jun
>>
>> *Pivotal*
>>
>
>

Re: How to get an Mbean of client federated by JMX Manager?

Posted by Kirk Lund <kl...@pivotal.io>.
The MBean federation mechanism is implemented using REPLICATED regions so
it requires that the JVM joins the Geode cluster. The only way to make this
work is to convert your Geode Java client to be a Geode member that
actually joins the cluster.

Each Geode Java client does have its own PlatformMBeanServer which contains
Geode MBeans for itself (which you can view via JConsole if you connect
directly to that JVM) but these MBeans are never federated into any other
Geode process unless that JVM is a member of the cluster.

Thanks,
Kirk


On Wed, Sep 14, 2016 at 4:40 PM, Jun Aoki <ja...@pivotal.io> wrote:

> Jinmei/Barry, thank you for responding! Will investigate more and bring
> more solid questions.
>
> On Tue, Sep 13, 2016 at 5:15 PM, Barry Oglesby <bo...@pivotal.io>
> wrote:
>
> > The way that is done internally is that the client periodically puts
> stats
> > about itself into a local region. See
> > ClientStatsManager.publishClientStats. These stats get sent to the
> server
> > where they used by CacheServerMBean.showClientStats. You could do
> > something
> > similar with your client data either using a region like this or a
> > function. Either way, you probably want a server MBean providing this
> data,
> > not a client MBean.
> >
> >
> > Thanks,
> > Barry Oglesby
> >
> >
> > On Tue, Sep 13, 2016 at 4:48 PM, Jinmei Liao <ji...@pivotal.io> wrote:
> >
> > > It looks like you want to register an MBean in a remote MBeanServer.
> > First
> > > of all, the mBean needs to be serializable to be sent across the wire,
> > > secondly, mBeans usually reflect the states of the application
> resource,
> > > and this mBean will need to have some pointer back to your client JVM
> to
> > > gather status. Thirdly and probably the most important of all, is that
> > > mBeanServerConnection doesn't have a "registerMbean" method at all, and
> > > probably for good reasons. See if this article would be any help to
> you:
> > >
> > > https://blogs.oracle.com/jmxetc/entry/do_not_do_this_but
> > >
> > > Thanks!
> > >
> > > On Tue, Sep 13, 2016 at 4:06 PM, Jun Aoki <ja...@pivotal.io> wrote:
> > >
> > > > Hi Geode community,
> > > >
> > > > We have a use case where we would like a client side JVM to register
> > > Mbean
> > > > and federated by JMX Manager on a locator. (As a result,  jconsole
> that
> > > > connects to JMX Manager can see what's happening on the client JVM
> that
> > > > "connects" to the cluster. We do so currently ClientCache [1])
> > > > We are referring
> > > > https://cwiki.apache.org/confluence/display/GEODE/
> > Creating+Custom+MXBean
> > > > and are able to get MBean on a *GF Server* federated.
> > > > But we would like to do the same with MBean on a client JVM.
> > > >
> > > > We are assuming that if we can get a cache of server (not
> ClientCache)
> > > then
> > > > we can pass it to ManagementService([2]just like the doc said) but we
> > > don't
> > > > know how to get a server Cache instance on a client JVM.
> > > >
> > > > This might be an unpolished question but could you please let us know
> > if
> > > we
> > > > are thinking right way and / or how we can achieve it?
> > > >
> > > >
> > > > [1] This is how we get "connected" through ClientCache to the GF
> > cluster.
> > > > Region region = clientCache.createClientRegionFactory("
> > > > PROXY").create(REGION
> > > > )
> > > >
> > > >
> > > > [2] This is what the doc says and it works for us on server side.
> > > > ManagementService service = ManagementService.
> > > getManagementService(cache);
> > > > // where the cache is Cache instance)
> > > > service.registerMBean(bean, beanName);
> > > > service.federate(beanName, CustomMXBean.class, false);
> > > >
> > > >
> > > > --
> > > > Thank you,
> > > > - jun
> > > >
> > > > *Pivotal*
> > > >
> > >
> > >
> > >
> > > --
> > > Cheers
> > >
> > > Jinmei
> > >
> >
>
>
>
> --
> Thank you,
> - jun
>
> *Pivotal*
>

Re: How to get an Mbean of client federated by JMX Manager?

Posted by Jun Aoki <ja...@pivotal.io>.
Jinmei/Barry, thank you for responding! Will investigate more and bring
more solid questions.

On Tue, Sep 13, 2016 at 5:15 PM, Barry Oglesby <bo...@pivotal.io> wrote:

> The way that is done internally is that the client periodically puts stats
> about itself into a local region. See
> ClientStatsManager.publishClientStats. These stats get sent to the server
> where they used by CacheServerMBean.showClientStats. You could do
> something
> similar with your client data either using a region like this or a
> function. Either way, you probably want a server MBean providing this data,
> not a client MBean.
>
>
> Thanks,
> Barry Oglesby
>
>
> On Tue, Sep 13, 2016 at 4:48 PM, Jinmei Liao <ji...@pivotal.io> wrote:
>
> > It looks like you want to register an MBean in a remote MBeanServer.
> First
> > of all, the mBean needs to be serializable to be sent across the wire,
> > secondly, mBeans usually reflect the states of the application resource,
> > and this mBean will need to have some pointer back to your client JVM to
> > gather status. Thirdly and probably the most important of all, is that
> > mBeanServerConnection doesn't have a "registerMbean" method at all, and
> > probably for good reasons. See if this article would be any help to you:
> >
> > https://blogs.oracle.com/jmxetc/entry/do_not_do_this_but
> >
> > Thanks!
> >
> > On Tue, Sep 13, 2016 at 4:06 PM, Jun Aoki <ja...@pivotal.io> wrote:
> >
> > > Hi Geode community,
> > >
> > > We have a use case where we would like a client side JVM to register
> > Mbean
> > > and federated by JMX Manager on a locator. (As a result,  jconsole that
> > > connects to JMX Manager can see what's happening on the client JVM that
> > > "connects" to the cluster. We do so currently ClientCache [1])
> > > We are referring
> > > https://cwiki.apache.org/confluence/display/GEODE/
> Creating+Custom+MXBean
> > > and are able to get MBean on a *GF Server* federated.
> > > But we would like to do the same with MBean on a client JVM.
> > >
> > > We are assuming that if we can get a cache of server (not ClientCache)
> > then
> > > we can pass it to ManagementService([2]just like the doc said) but we
> > don't
> > > know how to get a server Cache instance on a client JVM.
> > >
> > > This might be an unpolished question but could you please let us know
> if
> > we
> > > are thinking right way and / or how we can achieve it?
> > >
> > >
> > > [1] This is how we get "connected" through ClientCache to the GF
> cluster.
> > > Region region = clientCache.createClientRegionFactory("
> > > PROXY").create(REGION
> > > )
> > >
> > >
> > > [2] This is what the doc says and it works for us on server side.
> > > ManagementService service = ManagementService.
> > getManagementService(cache);
> > > // where the cache is Cache instance)
> > > service.registerMBean(bean, beanName);
> > > service.federate(beanName, CustomMXBean.class, false);
> > >
> > >
> > > --
> > > Thank you,
> > > - jun
> > >
> > > *Pivotal*
> > >
> >
> >
> >
> > --
> > Cheers
> >
> > Jinmei
> >
>



-- 
Thank you,
- jun

*Pivotal*

Re: How to get an Mbean of client federated by JMX Manager?

Posted by Barry Oglesby <bo...@pivotal.io>.
The way that is done internally is that the client periodically puts stats
about itself into a local region. See
ClientStatsManager.publishClientStats. These stats get sent to the server
where they used by CacheServerMBean.showClientStats. You could do something
similar with your client data either using a region like this or a
function. Either way, you probably want a server MBean providing this data,
not a client MBean.


Thanks,
Barry Oglesby


On Tue, Sep 13, 2016 at 4:48 PM, Jinmei Liao <ji...@pivotal.io> wrote:

> It looks like you want to register an MBean in a remote MBeanServer. First
> of all, the mBean needs to be serializable to be sent across the wire,
> secondly, mBeans usually reflect the states of the application resource,
> and this mBean will need to have some pointer back to your client JVM to
> gather status. Thirdly and probably the most important of all, is that
> mBeanServerConnection doesn't have a "registerMbean" method at all, and
> probably for good reasons. See if this article would be any help to you:
>
> https://blogs.oracle.com/jmxetc/entry/do_not_do_this_but
>
> Thanks!
>
> On Tue, Sep 13, 2016 at 4:06 PM, Jun Aoki <ja...@pivotal.io> wrote:
>
> > Hi Geode community,
> >
> > We have a use case where we would like a client side JVM to register
> Mbean
> > and federated by JMX Manager on a locator. (As a result,  jconsole that
> > connects to JMX Manager can see what's happening on the client JVM that
> > "connects" to the cluster. We do so currently ClientCache [1])
> > We are referring
> > https://cwiki.apache.org/confluence/display/GEODE/Creating+Custom+MXBean
> > and are able to get MBean on a *GF Server* federated.
> > But we would like to do the same with MBean on a client JVM.
> >
> > We are assuming that if we can get a cache of server (not ClientCache)
> then
> > we can pass it to ManagementService([2]just like the doc said) but we
> don't
> > know how to get a server Cache instance on a client JVM.
> >
> > This might be an unpolished question but could you please let us know if
> we
> > are thinking right way and / or how we can achieve it?
> >
> >
> > [1] This is how we get "connected" through ClientCache to the GF cluster.
> > Region region = clientCache.createClientRegionFactory("
> > PROXY").create(REGION
> > )
> >
> >
> > [2] This is what the doc says and it works for us on server side.
> > ManagementService service = ManagementService.
> getManagementService(cache);
> > // where the cache is Cache instance)
> > service.registerMBean(bean, beanName);
> > service.federate(beanName, CustomMXBean.class, false);
> >
> >
> > --
> > Thank you,
> > - jun
> >
> > *Pivotal*
> >
>
>
>
> --
> Cheers
>
> Jinmei
>

Re: How to get an Mbean of client federated by JMX Manager?

Posted by Jinmei Liao <ji...@pivotal.io>.
It looks like you want to register an MBean in a remote MBeanServer. First
of all, the mBean needs to be serializable to be sent across the wire,
secondly, mBeans usually reflect the states of the application resource,
and this mBean will need to have some pointer back to your client JVM to
gather status. Thirdly and probably the most important of all, is that
mBeanServerConnection doesn't have a "registerMbean" method at all, and
probably for good reasons. See if this article would be any help to you:

https://blogs.oracle.com/jmxetc/entry/do_not_do_this_but

Thanks!

On Tue, Sep 13, 2016 at 4:06 PM, Jun Aoki <ja...@pivotal.io> wrote:

> Hi Geode community,
>
> We have a use case where we would like a client side JVM to register Mbean
> and federated by JMX Manager on a locator. (As a result,  jconsole that
> connects to JMX Manager can see what's happening on the client JVM that
> "connects" to the cluster. We do so currently ClientCache [1])
> We are referring
> https://cwiki.apache.org/confluence/display/GEODE/Creating+Custom+MXBean
> and are able to get MBean on a *GF Server* federated.
> But we would like to do the same with MBean on a client JVM.
>
> We are assuming that if we can get a cache of server (not ClientCache) then
> we can pass it to ManagementService([2]just like the doc said) but we don't
> know how to get a server Cache instance on a client JVM.
>
> This might be an unpolished question but could you please let us know if we
> are thinking right way and / or how we can achieve it?
>
>
> [1] This is how we get "connected" through ClientCache to the GF cluster.
> Region region = clientCache.createClientRegionFactory("
> PROXY").create(REGION
> )
>
>
> [2] This is what the doc says and it works for us on server side.
> ManagementService service = ManagementService.getManagementService(cache);
> // where the cache is Cache instance)
> service.registerMBean(bean, beanName);
> service.federate(beanName, CustomMXBean.class, false);
>
>
> --
> Thank you,
> - jun
>
> *Pivotal*
>



-- 
Cheers

Jinmei