You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by David Wynter <da...@btclick.com> on 2002/04/24 15:06:37 UTC

How do you stop long running scheduled jobs?

I have a screen that shows an active jobs running as a result of the
TurbineScheduledJob service running them. I have an action as a result of
that screen that returns a list of active jobs I want to terminate. It seems
the best way to do this in Java is Thread.interrupt() them.

So in my action class I have the following code:

                    if(je.isActive()) {

if(aData.getParameters().getString(aSchedule.getScheduleName()) != null) {
                            ScheduledJob
runningjob=ScheduledJobLoader.getInstance().getInstance(je.getTask());
                            // How do I get the Thread that this job is
running in so I can call interrupt()?
                        }
                    }

The job itself has been modified so that the main loop where it does it's
work has:

	  try
        {   while( !Thread.interrupted() )
            {
                // Do your work
            }
        }
        catch( InterruptedException e ){/*terminate thread by returning*/}

Any ideas on this or a different way of doing it?

Thanks

David Wynter
Director
roamware Ltd.
(+44) (0) 208 922 7539 B.
(+44) (0) 7879 605 706 M.
david@roamware.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Quartz Scheduler?

Posted by Jason van Zyl <jv...@zenplex.com>.
On Tue, 2002-04-30 at 10:02, Eric Pugh wrote:
> Hi,
> 
> Has anyone here used the Quartz scheduler (quartz.sf.net)?  I need to
> integrate some scheduler functionality in with my Turbine based app.  I
> remeber (at least under 2.1) that the scheduler was okay, but not great..
> And a lot of the tasks that I wanted to do where very difficult to do using
> that scheduler.

I just sent a message to the maven list that mentions quartz :-) I want
to use it for the scheduled builds in Maven.
 
> I was thinking about trying to get Quartz to work under Turbine, has anyone
> made any headway doing that, or have another scheduler to recommend?

It's the only one that I've found. I stopped writing the scheduler I was
making when I found quartz.

> I think I am going to work under 2.1 just because it seems there are a lot
> of problems with services working under 2.2/fulcrum/decoupled torque.

Try making a component, I think you will find it's ok when things are
torque related. I'm not going to be here for a while but I think a
scheduler component using quartz would be great.
 
> Eric
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
-- 
jvz.

Jason van Zyl
jvanzyl@apache.org

http://tambora.zenplex.org


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Quartz Scheduler?

Posted by Eric Pugh <ep...@upstate.com>.
Hi,

Has anyone here used the Quartz scheduler (quartz.sf.net)?  I need to
integrate some scheduler functionality in with my Turbine based app.  I
remeber (at least under 2.1) that the scheduler was okay, but not great..
And a lot of the tasks that I wanted to do where very difficult to do using
that scheduler.

I was thinking about trying to get Quartz to work under Turbine, has anyone
made any headway doing that, or have another scheduler to recommend?

I think I am going to work under 2.1 just because it seems there are a lot
of problems with services working under 2.2/fulcrum/decoupled torque.

Eric


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How do you stop long running scheduled jobs?

Posted by Daniel Rall <dl...@finemaltcoding.com>.
We're using a combination of the latest Fulcrum scheduler (CVS HEAD)
and *nix crond.  Though we do use it, we found the scheduler service
poorly documented and difficult to work with.  In this case, I would
rather see the existing scheduler replaced entirely, preferably with
something which better emulates the functionality of Vixie cron, but
is easier to setup configuration for.  Perhaps the some of the
existing service code could be salvaged with a non-backwards
compatible overhaul, which I'd be +1 on.

- Dan

"Eric Pugh" <ep...@upstate.com> writes:

> I am looking forward to seeing these changes..  I am going to be using
> Turbine primarily for running a series of scheduled jobs that do various
> tasks..  Being able to stop and start them will be very useful to me.  I
> would love to see this code, and help as I dig into this aspect.
>
> What code base are people using for scheduled jobs?  T2.1 or T2.2?  Or T3?
>
> -----Original Message-----
> From: David Wynter [mailto:david.wynter@btclick.com]
> Sent: Wednesday, April 24, 2002 11:58 AM
> To: Turbine Users List
> Subject: RE: How do you stop long running scheduled jobs?
>
>
> I have researched this problem further. Basically the
> TurbineSchedulerService is not really suited to being able to intervene in
> currently running jobs. Since my application can have jobs that run for a
> couple of hours it is very useful to be able to kill them off without having
> to stop Tomcat to do it.
>
> It looks like I am going to have to extend (replace) TurbineSchedulerService
> to achieve my end. This would involve caching all threads started by
> MainLoop in TurbineSchedulerService. The cache would be keyed on
> je.toString() and hold a reference to the Thread object. An additional
> method in TurbineSchedulerService ( public Thread
> getJobEntryThread(je.toString()) ) would allow the user to pass in a
> je.toString() argument and have the Thread returned. Then the caller could
> use the method interrupt() which would interrupt the WorkerThread which in
> turn used ScheduledJobLoader to get an instance of and run the ScheduledJob
> object. I assume this means the ScheduledJob is running in that Thread and
> will respond to the Thread.isInterrupted() call so we can then go about
> shutting the job down gracefully.
>
> Comments, ideas, alternatives?
>
> David
> -----Original Message-----
> From: David Wynter [mailto:david.wynter@btclick.com]
> Sent: 24 April 2002 14:07
> To: Turbine-User
> Subject: How do you stop long running scheduled jobs?
>
>
> I have a screen that shows an active jobs running as a result of the
> TurbineScheduledJob service running them. I have an action as a result of
> that screen that returns a list of active jobs I want to terminate. It seems
> the best way to do this in Java is Thread.interrupt() them.
>
> So in my action class I have the following code:
>
>                     if(je.isActive()) {
>
> if(aData.getParameters().getString(aSchedule.getScheduleName()) != null) {
>                             ScheduledJob
> runningjob=ScheduledJobLoader.getInstance().getInstance(je.getTask());
>                             // How do I get the Thread that this job is
> running in so I can call interrupt()?
>                         }
>                     }
>
> The job itself has been modified so that the main loop where it does it's
> work has:
>
> 	  try
>         {   while( !Thread.interrupted() )
>             {
>                 // Do your work
>             }
>         }
>         catch( InterruptedException e ){/*terminate thread by returning*/}
>
> Any ideas on this or a different way of doing it?

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How do you stop long running scheduled jobs?

Posted by Daniel Rall <dl...@finemaltcoding.com>.
We're using a combination of the latest Fulcrum scheduler (CVS HEAD)
and *nix crond.  Though we do use it, we found the scheduler service
poorly documented and difficult to work with.  In this case, I would
rather see the existing scheduler replaced entirely, preferably with
something which better emulates the functionality of Vixie cron, but
is easier to setup configuration for.  Perhaps the some of the
existing service code could be salvaged with a non-backwards
compatible overhaul, which I'd be +1 on.

- Dan

"Eric Pugh" <ep...@upstate.com> writes:

> I am looking forward to seeing these changes..  I am going to be using
> Turbine primarily for running a series of scheduled jobs that do various
> tasks..  Being able to stop and start them will be very useful to me.  I
> would love to see this code, and help as I dig into this aspect.
>
> What code base are people using for scheduled jobs?  T2.1 or T2.2?  Or T3?
>
> -----Original Message-----
> From: David Wynter [mailto:david.wynter@btclick.com]
> Sent: Wednesday, April 24, 2002 11:58 AM
> To: Turbine Users List
> Subject: RE: How do you stop long running scheduled jobs?
>
>
> I have researched this problem further. Basically the
> TurbineSchedulerService is not really suited to being able to intervene in
> currently running jobs. Since my application can have jobs that run for a
> couple of hours it is very useful to be able to kill them off without having
> to stop Tomcat to do it.
>
> It looks like I am going to have to extend (replace) TurbineSchedulerService
> to achieve my end. This would involve caching all threads started by
> MainLoop in TurbineSchedulerService. The cache would be keyed on
> je.toString() and hold a reference to the Thread object. An additional
> method in TurbineSchedulerService ( public Thread
> getJobEntryThread(je.toString()) ) would allow the user to pass in a
> je.toString() argument and have the Thread returned. Then the caller could
> use the method interrupt() which would interrupt the WorkerThread which in
> turn used ScheduledJobLoader to get an instance of and run the ScheduledJob
> object. I assume this means the ScheduledJob is running in that Thread and
> will respond to the Thread.isInterrupted() call so we can then go about
> shutting the job down gracefully.
>
> Comments, ideas, alternatives?
>
> David
> -----Original Message-----
> From: David Wynter [mailto:david.wynter@btclick.com]
> Sent: 24 April 2002 14:07
> To: Turbine-User
> Subject: How do you stop long running scheduled jobs?
>
>
> I have a screen that shows an active jobs running as a result of the
> TurbineScheduledJob service running them. I have an action as a result of
> that screen that returns a list of active jobs I want to terminate. It seems
> the best way to do this in Java is Thread.interrupt() them.
>
> So in my action class I have the following code:
>
>                     if(je.isActive()) {
>
> if(aData.getParameters().getString(aSchedule.getScheduleName()) != null) {
>                             ScheduledJob
> runningjob=ScheduledJobLoader.getInstance().getInstance(je.getTask());
>                             // How do I get the Thread that this job is
> running in so I can call interrupt()?
>                         }
>                     }
>
> The job itself has been modified so that the main loop where it does it's
> work has:
>
> 	  try
>         {   while( !Thread.interrupted() )
>             {
>                 // Do your work
>             }
>         }
>         catch( InterruptedException e ){/*terminate thread by returning*/}
>
> Any ideas on this or a different way of doing it?

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: How do you stop long running scheduled jobs?

Posted by David Wynter <da...@btclick.com>.
I am using T2.1, but from what I saw when I peeked into 2.2 a few months
back the TurbineScheduleService has not changed. The other change I need and
had hoped to have time for months ago is the ability to start a job
immediately. At the moment you can only set a job to start at least 60
seconds from the time you addJob(). I have not found out why this is so yet,
do you know why this is so?

David

-----Original Message-----
From: Eric Pugh [mailto:epugh@upstate.com]
Sent: 24 April 2002 17:02
To: 'Turbine Users List'
Subject: RE: How do you stop long running scheduled jobs?


I am looking forward to seeing these changes..  I am going to be using
Turbine primarily for running a series of scheduled jobs that do various
tasks..  Being able to stop and start them will be very useful to me.  I
would love to see this code, and help as I dig into this aspect.

What code base are people using for scheduled jobs?  T2.1 or T2.2?  Or T3?

Eric

-----Original Message-----
From: David Wynter [mailto:david.wynter@btclick.com]
Sent: Wednesday, April 24, 2002 11:58 AM
To: Turbine Users List
Subject: RE: How do you stop long running scheduled jobs?


I have researched this problem further. Basically the
TurbineSchedulerService is not really suited to being able to intervene in
currently running jobs. Since my application can have jobs that run for a
couple of hours it is very useful to be able to kill them off without having
to stop Tomcat to do it.

It looks like I am going to have to extend (replace) TurbineSchedulerService
to achieve my end. This would involve caching all threads started by
MainLoop in TurbineSchedulerService. The cache would be keyed on
je.toString() and hold a reference to the Thread object. An additional
method in TurbineSchedulerService ( public Thread
getJobEntryThread(je.toString()) ) would allow the user to pass in a
je.toString() argument and have the Thread returned. Then the caller could
use the method interrupt() which would interrupt the WorkerThread which in
turn used ScheduledJobLoader to get an instance of and run the ScheduledJob
object. I assume this means the ScheduledJob is running in that Thread and
will respond to the Thread.isInterrupted() call so we can then go about
shutting the job down gracefully.

Comments, ideas, alternatives?

David
-----Original Message-----
From: David Wynter [mailto:david.wynter@btclick.com]
Sent: 24 April 2002 14:07
To: Turbine-User
Subject: How do you stop long running scheduled jobs?


I have a screen that shows an active jobs running as a result of the
TurbineScheduledJob service running them. I have an action as a result of
that screen that returns a list of active jobs I want to terminate. It seems
the best way to do this in Java is Thread.interrupt() them.

So in my action class I have the following code:

                    if(je.isActive()) {

if(aData.getParameters().getString(aSchedule.getScheduleName()) != null) {
                            ScheduledJob
runningjob=ScheduledJobLoader.getInstance().getInstance(je.getTask());
                            // How do I get the Thread that this job is
running in so I can call interrupt()?
                        }
                    }

The job itself has been modified so that the main loop where it does it's
work has:

	  try
        {   while( !Thread.interrupted() )
            {
                // Do your work
            }
        }
        catch( InterruptedException e ){/*terminate thread by returning*/}

Any ideas on this or a different way of doing it?

Thanks

David Wynter
Director
roamware Ltd.
(+44) (0) 208 922 7539 B.
(+44) (0) 7879 605 706 M.
david@roamware.com


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: How do you stop long running scheduled jobs?

Posted by Eric Pugh <ep...@upstate.com>.
I am looking forward to seeing these changes..  I am going to be using
Turbine primarily for running a series of scheduled jobs that do various
tasks..  Being able to stop and start them will be very useful to me.  I
would love to see this code, and help as I dig into this aspect.

What code base are people using for scheduled jobs?  T2.1 or T2.2?  Or T3?

Eric

-----Original Message-----
From: David Wynter [mailto:david.wynter@btclick.com]
Sent: Wednesday, April 24, 2002 11:58 AM
To: Turbine Users List
Subject: RE: How do you stop long running scheduled jobs?


I have researched this problem further. Basically the
TurbineSchedulerService is not really suited to being able to intervene in
currently running jobs. Since my application can have jobs that run for a
couple of hours it is very useful to be able to kill them off without having
to stop Tomcat to do it.

It looks like I am going to have to extend (replace) TurbineSchedulerService
to achieve my end. This would involve caching all threads started by
MainLoop in TurbineSchedulerService. The cache would be keyed on
je.toString() and hold a reference to the Thread object. An additional
method in TurbineSchedulerService ( public Thread
getJobEntryThread(je.toString()) ) would allow the user to pass in a
je.toString() argument and have the Thread returned. Then the caller could
use the method interrupt() which would interrupt the WorkerThread which in
turn used ScheduledJobLoader to get an instance of and run the ScheduledJob
object. I assume this means the ScheduledJob is running in that Thread and
will respond to the Thread.isInterrupted() call so we can then go about
shutting the job down gracefully.

Comments, ideas, alternatives?

David
-----Original Message-----
From: David Wynter [mailto:david.wynter@btclick.com]
Sent: 24 April 2002 14:07
To: Turbine-User
Subject: How do you stop long running scheduled jobs?


I have a screen that shows an active jobs running as a result of the
TurbineScheduledJob service running them. I have an action as a result of
that screen that returns a list of active jobs I want to terminate. It seems
the best way to do this in Java is Thread.interrupt() them.

So in my action class I have the following code:

                    if(je.isActive()) {

if(aData.getParameters().getString(aSchedule.getScheduleName()) != null) {
                            ScheduledJob
runningjob=ScheduledJobLoader.getInstance().getInstance(je.getTask());
                            // How do I get the Thread that this job is
running in so I can call interrupt()?
                        }
                    }

The job itself has been modified so that the main loop where it does it's
work has:

	  try
        {   while( !Thread.interrupted() )
            {
                // Do your work
            }
        }
        catch( InterruptedException e ){/*terminate thread by returning*/}

Any ideas on this or a different way of doing it?

Thanks

David Wynter
Director
roamware Ltd.
(+44) (0) 208 922 7539 B.
(+44) (0) 7879 605 706 M.
david@roamware.com


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: How do you stop long running scheduled jobs?

Posted by David Wynter <da...@btclick.com>.
I have researched this problem further. Basically the
TurbineSchedulerService is not really suited to being able to intervene in
currently running jobs. Since my application can have jobs that run for a
couple of hours it is very useful to be able to kill them off without having
to stop Tomcat to do it.

It looks like I am going to have to extend (replace) TurbineSchedulerService
to achieve my end. This would involve caching all threads started by
MainLoop in TurbineSchedulerService. The cache would be keyed on
je.toString() and hold a reference to the Thread object. An additional
method in TurbineSchedulerService ( public Thread
getJobEntryThread(je.toString()) ) would allow the user to pass in a
je.toString() argument and have the Thread returned. Then the caller could
use the method interrupt() which would interrupt the WorkerThread which in
turn used ScheduledJobLoader to get an instance of and run the ScheduledJob
object. I assume this means the ScheduledJob is running in that Thread and
will respond to the Thread.isInterrupted() call so we can then go about
shutting the job down gracefully.

Comments, ideas, alternatives?

David
-----Original Message-----
From: David Wynter [mailto:david.wynter@btclick.com]
Sent: 24 April 2002 14:07
To: Turbine-User
Subject: How do you stop long running scheduled jobs?


I have a screen that shows an active jobs running as a result of the
TurbineScheduledJob service running them. I have an action as a result of
that screen that returns a list of active jobs I want to terminate. It seems
the best way to do this in Java is Thread.interrupt() them.

So in my action class I have the following code:

                    if(je.isActive()) {

if(aData.getParameters().getString(aSchedule.getScheduleName()) != null) {
                            ScheduledJob
runningjob=ScheduledJobLoader.getInstance().getInstance(je.getTask());
                            // How do I get the Thread that this job is
running in so I can call interrupt()?
                        }
                    }

The job itself has been modified so that the main loop where it does it's
work has:

	  try
        {   while( !Thread.interrupted() )
            {
                // Do your work
            }
        }
        catch( InterruptedException e ){/*terminate thread by returning*/}

Any ideas on this or a different way of doing it?

Thanks

David Wynter
Director
roamware Ltd.
(+44) (0) 208 922 7539 B.
(+44) (0) 7879 605 706 M.
david@roamware.com


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>