You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@karaf.apache.org by zaerymoghaddam <za...@gmail.com> on 2014/01/13 23:02:03 UTC

Having commands for scheduler module

Hi guys

There is a module in Karaf named scheduler. It's a simple scheduler
implemented using java.util.Timer, contains only 4 classes and registers a
TaskScheduler service manually. There is no dependency to this module in
Karaf.

Here is my questions:

1. Why this module registers its only service (TaskScheduler) manually in
Activator class (not using blueprint.xml like other modules) and the service
has no interface (just the implementation class)?

I Don't know whether this is intentional or not! If there is some reasons
behind this design, what are they and if it has been designed this way just
because its an old module, is it possible to refactor it and make it
consistent with other modules?  


2. Why there isn't any command to interact with scheduler?

The scheduler bundle have a ServiceListener which listens for any changes in
services and if a service class is an instance of Runnable (that means it's
a Thread), adds it to the list of task schedulers and tries to run it in
given time periods. So there is no way to stop a repetitive task other than
undeploying the service implementing it. Also it seems that it would be
reasonable to have an option to change the repeating pattern or pause it and
etc. I Think we can have a command module to implement these options and let
the user to have more control over the scheduler.

I've tried to implement such command and I like to know your ideas about
this topic before finalizing implementation.

Regards.




-----
E.Z.Moghaddam
zaerymoghaddam@gmail.com
--
View this message in context: http://karaf.922171.n3.nabble.com/Having-commands-for-scheduler-module-tp4030991.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Having commands for scheduler module

Posted by zaerymoghaddam <za...@gmail.com>.
roedll: Thanks for your info

I had checked Apache Sling but I didn't mentioned your previous
conversations in forum. I've read the  discussion
<http://karaf.922171.n3.nabble.com/Task-scheduler-in-Karaf-td4028481.html>  
and also checked the  KARAF-751
<https://issues.apache.org/jira/browse/KARAF-751>  .

The overall idea behind reusing modified version of sling bundle for
scheduler to prevent reinventing the wheel seems good. But I'm unable to
summarize the debate about the SCR vs Blueprint in KARAF-751 comments.

The SCR is part of OSGi spec and there is no reason not to use it. About a
month ago, there was a similar discussion about having  A Blueprint Free
Karaf
<http://karaf.922171.n3.nabble.com/A-Blueprint-Free-Karaf-td4030521.html>  
in forum. @iocanel had developed a version of Karaf by replacing Blueprint
with Felix SCR. But currently, all the modules in Karaf have implemented
using Blueprint, and I think it would be better to keep this design for now
and if someday in future, project committee decided to replace Blueprint
with SCR, all modules will be changed in one step (like what @iocanel did).

JB: What's your opinion?

Regards



-----
E.Z.Moghaddam
zaerymoghaddam@gmail.com
--
View this message in context: http://karaf.922171.n3.nabble.com/Having-commands-for-scheduler-module-tp4030991p4031026.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Having commands for scheduler module

Posted by roedll <lu...@ait.ac.at>.
Hi!

Some time ago there was a quite similar discussion about the sheduler
module.
See 
http://karaf.922171.n3.nabble.com/Task-scheduler-in-Karaf-td4028481.html
<http://karaf.922171.n3.nabble.com/Task-scheduler-in-Karaf-td4028481.html>  
for details.
I also opened a ticket for this and attached a patch: 
https://issues.apache.org/jira/browse/KARAF-751
<https://issues.apache.org/jira/browse/KARAF-751>  

As far as I remember the outcome of the various discussions was that it
would be possible to modify/extend the scheduler provided by the Apache
Sling project to make it more generally usable and to enrich it with
commands - like the ones you proposed - and then use it eg. in Karaf.

Regards
Lukas



--
View this message in context: http://karaf.922171.n3.nabble.com/Having-commands-for-scheduler-module-tp4030991p4031010.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Having commands for scheduler module

Posted by zaerymoghaddam <za...@gmail.com>.
Hi

imho we have two option:

    1. Extend the scheduler service and its related commands
        using classes in java.util.concurrent package, we can provide more
advanced scheduling capabilities like dynamically
adding/removing/suspending/resuming scheduled tasks. It can have commands
and options like these:

        scheduler:list
        lists already scheduled tasks

        scheduler:schedule
        schedules given task base on delay or repeating parameters

        scheduler:unschedule
        removes given scheduled task from the list
​​
        scheduler:suspend
        suspends given task 

        scheduler:resume
        resumes an already suspended task

    2. Define a new Karaf Feature to have Quartz scheduler in Karaf
        Currently there is an OSGi wrapper for Quartz in Apache ServiceMix
(org.apache.servicemix.bundles.quartz) that may be useful to provide
advanced scheduling capabilities.

I think both options have their own pros and cons. The first option would be
enough for most basic situations and no additional dependencies will be
added to the project. The second one is a must have for any enterprise level
project due to large number of options and features provided by Quartz. So a
Karaf Feature to install Quartz bundles into container (like Spring Feature)
could be devised in near future.


Regards





-----
E.Z.Moghaddam
zaerymoghaddam@gmail.com
--
View this message in context: http://karaf.922171.n3.nabble.com/Having-commands-for-scheduler-module-tp4030991p4031001.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: Having commands for scheduler module

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

the scheduler module is a very simple scheduler, that we added as a kind 
of PoC. It should be extended and enhanced.

We are open to proposal to add new features and extend the scheduler.

Regards
JB

On 01/13/2014 11:02 PM, zaerymoghaddam wrote:
> Hi guys
>
> There is a module in Karaf named scheduler. It's a simple scheduler
> implemented using java.util.Timer, contains only 4 classes and registers a
> TaskScheduler service manually. There is no dependency to this module in
> Karaf.
>
> Here is my questions:
>
> 1. Why this module registers its only service (TaskScheduler) manually in
> Activator class (not using blueprint.xml like other modules) and the service
> has no interface (just the implementation class)?
>
> I Don't know whether this is intentional or not! If there is some reasons
> behind this design, what are they and if it has been designed this way just
> because its an old module, is it possible to refactor it and make it
> consistent with other modules?
>
>
> 2. Why there isn't any command to interact with scheduler?
>
> The scheduler bundle have a ServiceListener which listens for any changes in
> services and if a service class is an instance of Runnable (that means it's
> a Thread), adds it to the list of task schedulers and tries to run it in
> given time periods. So there is no way to stop a repetitive task other than
> undeploying the service implementing it. Also it seems that it would be
> reasonable to have an option to change the repeating pattern or pause it and
> etc. I Think we can have a command module to implement these options and let
> the user to have more control over the scheduler.
>
> I've tried to implement such command and I like to know your ideas about
> this topic before finalizing implementation.
>
> Regards.
>
>
>
>
> -----
> E.Z.Moghaddam
> zaerymoghaddam@gmail.com
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Having-commands-for-scheduler-module-tp4030991.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com