You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@marmotta.apache.org by Rajika Kumarasiri <ra...@gmail.com> on 2014/02/28 06:23:10 UTC

How to register a new service to start at the server start up time

hello,

I have created a new service for JMX(api and implementation) and now I want
to start it with the server start up. Where should I register the service
so that JMX service will start at the server boot up time ?

Thank you.

Re: How to register a new service to start at the server start up time

Posted by Rajika Kumarasiri <ra...@gmail.com>.
I commented on the jira, let me know your feedback there.

Thank you.


On Sun, Mar 2, 2014 at 12:03 PM, Rajika Kumarasiri <
rajika.kumarasiri@gmail.com> wrote:

> hello,
>
> I got the proposed POC working for
> https://issues.apache.org/jira/browse/MARMOTTA-408. It seems the jira is
> offline for maintenance so I will add the information here. I will copy
>  the same information into the jira when it's online.
>
> Please find the attached patch and the screenshot.
>
> The screenshot shows how I exposed the OS and JDK run-time
> information(similar to System->Statistics->System ) using a MBean from the
> newly developed JMX infrastructure.
>
>
> The classes;
> a). org.apache.marmotta.platform.core.api.jmx.JMXService
> b). org.apache.marmotta.platform.core.services.jmx.JMXServiceImpl
> c). org.apache.marmotta.platform.core.services.jmx.JMXRMIRegistryController
> d). org.apache.marmotta.platform.core.services.jmx.JMXMBeansRegister
> e). org.apache.marmotta.platform.core.services.jmx.JMXAdapter
>
> are responsible for #1 in the jira. The mentioned MBeanRegister API is
> defined in JMXMBeansRegister (d)). It has the APIs to register and
> unregister the MBeans. The other classes basically create a JMX connector
> and starts it with the platform. I consumed the SystemStartupEvent to
> start the JMX CDI service.
>
>
> The interface and class;
> a). org.apache.marmotta.platform.core.services.jmx.SystemStatisticsMBean
> b). org.apache.marmotta.platform.core.services.jmx.SystemStatistics
>
> are an example for #2. They collects the stats about the OS/JDK run time
> data and register them into  #1 using MBeans so that we can view that
> statistics using JConsole(or any other JMX client). This is what can be
> seen in the screen shot. I just implemented this logic inside
> org.apache.marmotta.platform.core.services.jmx.JMXServiceImpl itself but it
> should be implemented in each place where those stats will be collected
> (for example
> org.apache.marmotta.platform.core.services.statistics.system.SystemStatisticsModule).
>
> Now the next step is to identify various places, components or modules
> across the platform and other places and replace them with relevant MBeans
> and register them with the MBean server similar to #2 above. #1 also need
> to improve so that other jmx parameters can be configured(for example SSL
> connections).
>
> Do you think I am heading in the correct direction ? I would like to start
> writing my proposal based on this information once I compiled a list of
> places to have new MBeans to collect respective statistics. I am aware of
> JUnit and each of this new feature will be covered with a JUnit test case.
> Please let me know your feedback or any comment.
>
> Sorry for the long email. For sure if you prefer we can continue the
> discussion in the jira as well.
>
> Thank you.
>
>
>
>
> On Sun, Mar 2, 2014 at 10:17 AM, Rajika Kumarasiri <
> rajika.kumarasiri@gmail.com> wrote:
>
>> hello,
>>
>> Thank you for your replies. I got this to work. I am reading about the
>> Weld framework as well.
>>
>> Thank you.
>>
>>
>> On Sat, Mar 1, 2014 at 3:37 AM, Jakob Frank <ja...@apache.org> wrote:
>>
>>> Hi Rajika,
>>>
>>> if you want your CDI service to startup automatically (e.g. because it
>>> needs to register something somewhere) you should listen on the
>>> SystemStartupEvent which is fired once the system has come up
>>> completely:
>>>
>>> // trigger startup once configuration service is finished with
>>> initialisation
>>> public void initEvent(@Observes SystemStartupEvent e) {
>>>     // nop;
>>> }
>>>
>>> Best,
>>> Jakob
>>>
>>> On 28 February 2014 12:28, Rajika Kumarasiri
>>> <ra...@gmail.com> wrote:
>>> > helo Sergio,
>>> >
>>> > Thanks, will try that. Sure will provide a documentation enhancement
>>> patch
>>> > too.
>>> >
>>> > Thank you.
>>> >
>>> >
>>> > On Fri, Feb 28, 2014 at 2:38 AM, Sergio Fernández <
>>> > sergio.fernandez@salzburgresearch.at> wrote:
>>> >
>>> >> Hi Rajika,
>>> >>
>>> >>
>>> >> On 28/02/14 06:23, Rajika Kumarasiri wrote:
>>> >>
>>> >>> I have created a new service for JMX(api and implementation) and now
>>> I
>>> >>> want
>>> >>> to start it with the server start up. Where should I register the
>>> service
>>> >>> so that JMX service will start at the server boot up time ?
>>> >>>
>>> >>
>>> >> The services are in the end CDI services (JSR346), using the JBoss
>>> Weld
>>> >> implementation.
>>> >>
>>> >> So you just need to add to your service class the annotation with the
>>> >> necessary scope, in this case @ApplicationScope. Then the platform
>>> will
>>> >> instantiate it, and you can normally use IoC with your new service in
>>> the
>>> >> rest of the platform.
>>> >>
>>> >> Further details at:
>>> >>
>>> >> http://marmotta.apache.org/platform
>>> >> http://docs.jboss.org/weld/reference/2.1.0.Final/en-US/html/
>>> >>
>>> >> If you miss anything else in the documentation, contributions there
>>> are
>>> >> also welcomed ;-)
>>> >>
>>> >> Cheers,
>>> >>
>>> >> --
>>> >> Sergio Fernández
>>> >> Senior Researcher
>>> >> Knowledge and Media Technologies
>>> >> Salzburg Research Forschungsgesellschaft mbH
>>> >> Jakob-Haringer-Straße 5/3 | 5020 Salzburg, Austria
>>> >> T: +43 662 2288 318 | M: +43 660 2747 925
>>> >> sergio.fernandez@salzburgresearch.at
>>> >> http://www.salzburgresearch.at
>>> >>
>>>
>>
>>
>

Re: How to register a new service to start at the server start up time

Posted by Rajika Kumarasiri <ra...@gmail.com>.
hello,

I got the proposed POC working for
https://issues.apache.org/jira/browse/MARMOTTA-408. It seems the jira is
offline for maintenance so I will add the information here. I will copy
 the same information into the jira when it's online.

Please find the attached patch and the screenshot.

The screenshot shows how I exposed the OS and JDK run-time
information(similar to System->Statistics->System ) using a MBean from the
newly developed JMX infrastructure.


The classes;
a). org.apache.marmotta.platform.core.api.jmx.JMXService
b). org.apache.marmotta.platform.core.services.jmx.JMXServiceImpl
c). org.apache.marmotta.platform.core.services.jmx.JMXRMIRegistryController
d). org.apache.marmotta.platform.core.services.jmx.JMXMBeansRegister
e). org.apache.marmotta.platform.core.services.jmx.JMXAdapter

are responsible for #1 in the jira. The mentioned MBeanRegister API is
defined in JMXMBeansRegister (d)). It has the APIs to register and
unregister the MBeans. The other classes basically create a JMX connector
and starts it with the platform. I consumed the SystemStartupEvent to start
the JMX CDI service.


The interface and class;
a). org.apache.marmotta.platform.core.services.jmx.SystemStatisticsMBean
b). org.apache.marmotta.platform.core.services.jmx.SystemStatistics

are an example for #2. They collects the stats about the OS/JDK run time
data and register them into  #1 using MBeans so that we can view that
statistics using JConsole(or any other JMX client). This is what can be
seen in the screen shot. I just implemented this logic inside
org.apache.marmotta.platform.core.services.jmx.JMXServiceImpl itself but it
should be implemented in each place where those stats will be collected
(for example
org.apache.marmotta.platform.core.services.statistics.system.SystemStatisticsModule).

Now the next step is to identify various places, components or modules
across the platform and other places and replace them with relevant MBeans
and register them with the MBean server similar to #2 above. #1 also need
to improve so that other jmx parameters can be configured(for example SSL
connections).

Do you think I am heading in the correct direction ? I would like to start
writing my proposal based on this information once I compiled a list of
places to have new MBeans to collect respective statistics. I am aware of
JUnit and each of this new feature will be covered with a JUnit test case.
Please let me know your feedback or any comment.

Sorry for the long email. For sure if you prefer we can continue the
discussion in the jira as well.

Thank you.




On Sun, Mar 2, 2014 at 10:17 AM, Rajika Kumarasiri <
rajika.kumarasiri@gmail.com> wrote:

> hello,
>
> Thank you for your replies. I got this to work. I am reading about the
> Weld framework as well.
>
> Thank you.
>
>
> On Sat, Mar 1, 2014 at 3:37 AM, Jakob Frank <ja...@apache.org> wrote:
>
>> Hi Rajika,
>>
>> if you want your CDI service to startup automatically (e.g. because it
>> needs to register something somewhere) you should listen on the
>> SystemStartupEvent which is fired once the system has come up
>> completely:
>>
>> // trigger startup once configuration service is finished with
>> initialisation
>> public void initEvent(@Observes SystemStartupEvent e) {
>>     // nop;
>> }
>>
>> Best,
>> Jakob
>>
>> On 28 February 2014 12:28, Rajika Kumarasiri
>> <ra...@gmail.com> wrote:
>> > helo Sergio,
>> >
>> > Thanks, will try that. Sure will provide a documentation enhancement
>> patch
>> > too.
>> >
>> > Thank you.
>> >
>> >
>> > On Fri, Feb 28, 2014 at 2:38 AM, Sergio Fernández <
>> > sergio.fernandez@salzburgresearch.at> wrote:
>> >
>> >> Hi Rajika,
>> >>
>> >>
>> >> On 28/02/14 06:23, Rajika Kumarasiri wrote:
>> >>
>> >>> I have created a new service for JMX(api and implementation) and now I
>> >>> want
>> >>> to start it with the server start up. Where should I register the
>> service
>> >>> so that JMX service will start at the server boot up time ?
>> >>>
>> >>
>> >> The services are in the end CDI services (JSR346), using the JBoss Weld
>> >> implementation.
>> >>
>> >> So you just need to add to your service class the annotation with the
>> >> necessary scope, in this case @ApplicationScope. Then the platform will
>> >> instantiate it, and you can normally use IoC with your new service in
>> the
>> >> rest of the platform.
>> >>
>> >> Further details at:
>> >>
>> >> http://marmotta.apache.org/platform
>> >> http://docs.jboss.org/weld/reference/2.1.0.Final/en-US/html/
>> >>
>> >> If you miss anything else in the documentation, contributions there are
>> >> also welcomed ;-)
>> >>
>> >> Cheers,
>> >>
>> >> --
>> >> Sergio Fernández
>> >> Senior Researcher
>> >> Knowledge and Media Technologies
>> >> Salzburg Research Forschungsgesellschaft mbH
>> >> Jakob-Haringer-Straße 5/3 | 5020 Salzburg, Austria
>> >> T: +43 662 2288 318 | M: +43 660 2747 925
>> >> sergio.fernandez@salzburgresearch.at
>> >> http://www.salzburgresearch.at
>> >>
>>
>
>

Re: How to register a new service to start at the server start up time

Posted by Rajika Kumarasiri <ra...@gmail.com>.
hello,

Thank you for your replies. I got this to work. I am reading about the Weld
framework as well.

Thank you.


On Sat, Mar 1, 2014 at 3:37 AM, Jakob Frank <ja...@apache.org> wrote:

> Hi Rajika,
>
> if you want your CDI service to startup automatically (e.g. because it
> needs to register something somewhere) you should listen on the
> SystemStartupEvent which is fired once the system has come up
> completely:
>
> // trigger startup once configuration service is finished with
> initialisation
> public void initEvent(@Observes SystemStartupEvent e) {
>     // nop;
> }
>
> Best,
> Jakob
>
> On 28 February 2014 12:28, Rajika Kumarasiri
> <ra...@gmail.com> wrote:
> > helo Sergio,
> >
> > Thanks, will try that. Sure will provide a documentation enhancement
> patch
> > too.
> >
> > Thank you.
> >
> >
> > On Fri, Feb 28, 2014 at 2:38 AM, Sergio Fernández <
> > sergio.fernandez@salzburgresearch.at> wrote:
> >
> >> Hi Rajika,
> >>
> >>
> >> On 28/02/14 06:23, Rajika Kumarasiri wrote:
> >>
> >>> I have created a new service for JMX(api and implementation) and now I
> >>> want
> >>> to start it with the server start up. Where should I register the
> service
> >>> so that JMX service will start at the server boot up time ?
> >>>
> >>
> >> The services are in the end CDI services (JSR346), using the JBoss Weld
> >> implementation.
> >>
> >> So you just need to add to your service class the annotation with the
> >> necessary scope, in this case @ApplicationScope. Then the platform will
> >> instantiate it, and you can normally use IoC with your new service in
> the
> >> rest of the platform.
> >>
> >> Further details at:
> >>
> >> http://marmotta.apache.org/platform
> >> http://docs.jboss.org/weld/reference/2.1.0.Final/en-US/html/
> >>
> >> If you miss anything else in the documentation, contributions there are
> >> also welcomed ;-)
> >>
> >> Cheers,
> >>
> >> --
> >> Sergio Fernández
> >> Senior Researcher
> >> Knowledge and Media Technologies
> >> Salzburg Research Forschungsgesellschaft mbH
> >> Jakob-Haringer-Straße 5/3 | 5020 Salzburg, Austria
> >> T: +43 662 2288 318 | M: +43 660 2747 925
> >> sergio.fernandez@salzburgresearch.at
> >> http://www.salzburgresearch.at
> >>
>

Re: How to register a new service to start at the server start up time

Posted by Jakob Frank <ja...@apache.org>.
Hi Rajika,

if you want your CDI service to startup automatically (e.g. because it
needs to register something somewhere) you should listen on the
SystemStartupEvent which is fired once the system has come up
completely:

// trigger startup once configuration service is finished with initialisation
public void initEvent(@Observes SystemStartupEvent e) {
    // nop;
}

Best,
Jakob

On 28 February 2014 12:28, Rajika Kumarasiri
<ra...@gmail.com> wrote:
> helo Sergio,
>
> Thanks, will try that. Sure will provide a documentation enhancement patch
> too.
>
> Thank you.
>
>
> On Fri, Feb 28, 2014 at 2:38 AM, Sergio Fernández <
> sergio.fernandez@salzburgresearch.at> wrote:
>
>> Hi Rajika,
>>
>>
>> On 28/02/14 06:23, Rajika Kumarasiri wrote:
>>
>>> I have created a new service for JMX(api and implementation) and now I
>>> want
>>> to start it with the server start up. Where should I register the service
>>> so that JMX service will start at the server boot up time ?
>>>
>>
>> The services are in the end CDI services (JSR346), using the JBoss Weld
>> implementation.
>>
>> So you just need to add to your service class the annotation with the
>> necessary scope, in this case @ApplicationScope. Then the platform will
>> instantiate it, and you can normally use IoC with your new service in the
>> rest of the platform.
>>
>> Further details at:
>>
>> http://marmotta.apache.org/platform
>> http://docs.jboss.org/weld/reference/2.1.0.Final/en-US/html/
>>
>> If you miss anything else in the documentation, contributions there are
>> also welcomed ;-)
>>
>> Cheers,
>>
>> --
>> Sergio Fernández
>> Senior Researcher
>> Knowledge and Media Technologies
>> Salzburg Research Forschungsgesellschaft mbH
>> Jakob-Haringer-Straße 5/3 | 5020 Salzburg, Austria
>> T: +43 662 2288 318 | M: +43 660 2747 925
>> sergio.fernandez@salzburgresearch.at
>> http://www.salzburgresearch.at
>>

Re: How to register a new service to start at the server start up time

Posted by Rajika Kumarasiri <ra...@gmail.com>.
helo Sergio,

Thanks, will try that. Sure will provide a documentation enhancement patch
too.

Thank you.


On Fri, Feb 28, 2014 at 2:38 AM, Sergio Fernández <
sergio.fernandez@salzburgresearch.at> wrote:

> Hi Rajika,
>
>
> On 28/02/14 06:23, Rajika Kumarasiri wrote:
>
>> I have created a new service for JMX(api and implementation) and now I
>> want
>> to start it with the server start up. Where should I register the service
>> so that JMX service will start at the server boot up time ?
>>
>
> The services are in the end CDI services (JSR346), using the JBoss Weld
> implementation.
>
> So you just need to add to your service class the annotation with the
> necessary scope, in this case @ApplicationScope. Then the platform will
> instantiate it, and you can normally use IoC with your new service in the
> rest of the platform.
>
> Further details at:
>
> http://marmotta.apache.org/platform
> http://docs.jboss.org/weld/reference/2.1.0.Final/en-US/html/
>
> If you miss anything else in the documentation, contributions there are
> also welcomed ;-)
>
> Cheers,
>
> --
> Sergio Fernández
> Senior Researcher
> Knowledge and Media Technologies
> Salzburg Research Forschungsgesellschaft mbH
> Jakob-Haringer-Straße 5/3 | 5020 Salzburg, Austria
> T: +43 662 2288 318 | M: +43 660 2747 925
> sergio.fernandez@salzburgresearch.at
> http://www.salzburgresearch.at
>

Re: How to register a new service to start at the server start up time

Posted by Sergio Fernández <se...@salzburgresearch.at>.
Hi Rajika,

On 28/02/14 06:23, Rajika Kumarasiri wrote:
> I have created a new service for JMX(api and implementation) and now I want
> to start it with the server start up. Where should I register the service
> so that JMX service will start at the server boot up time ?

The services are in the end CDI services (JSR346), using the JBoss Weld 
implementation.

So you just need to add to your service class the annotation with the 
necessary scope, in this case @ApplicationScope. Then the platform will 
instantiate it, and you can normally use IoC with your new service in 
the rest of the platform.

Further details at:

http://marmotta.apache.org/platform
http://docs.jboss.org/weld/reference/2.1.0.Final/en-US/html/

If you miss anything else in the documentation, contributions there are 
also welcomed ;-)

Cheers,

-- 
Sergio Fernández
Senior Researcher
Knowledge and Media Technologies
Salzburg Research Forschungsgesellschaft mbH
Jakob-Haringer-Straße 5/3 | 5020 Salzburg, Austria
T: +43 662 2288 318 | M: +43 660 2747 925
sergio.fernandez@salzburgresearch.at
http://www.salzburgresearch.at