org.ow2.orchestra.pvm.internal.jobexecutor
Class AbstractJobExecutor

java.lang.Object
  extended by org.ow2.orchestra.pvm.internal.jobexecutor.AbstractJobExecutor
All Implemented Interfaces:
JobExecutor
Direct Known Subclasses:
JdkJobExecutor, PvmJobExecutor

public abstract class AbstractJobExecutor
extends Object
implements JobExecutor

Common part of jobExecutor implementations based on a Dispatcher thread

Author:
Tom Baeyens, Guillaume Porcher

Field Summary
protected  Command<Collection<Collection<JobImpl<?>>>> acquireJobsCommand
           
protected  CommandService commandService
           
protected  DeadJobHandler deadJobHandler
           
protected  int idleMillis
           
protected  boolean isActive
           
protected  boolean limitSameInstanceJobs
           
protected  int lockMillis
           
protected static Log LOG
           
protected  String name
           
protected  Command<Date> nextDueDateCommand
           
 
Constructor Summary
AbstractJobExecutor()
           
 
Method Summary
 Command<Collection<Collection<JobImpl<?>>>> getAcquireJobsCommand()
           
protected abstract  int getAcquireJobSize()
           
 CommandService getCommandExecutor()
           
 DeadJobHandler getDeadJobHandler()
           
protected abstract  AbstractDispatcherThread getDispatcherThread()
           
protected static String getHostName()
           
 int getIdleMillis()
           
 int getLockMillis()
           
 String getName()
          returns JobExecutor name
 Command<Date> getNextDueDateCommand()
           
 boolean isActive()
          returns true if this JobExecutor is started
 boolean isLimitSameInstanceJobs()
           
 void jobWasAdded()
          signals jobExecutor that a job has been added
 void setCommandExecutor(CommandService commandExecutor)
           
 void setDeadJobHandler(DeadJobHandler deadJobHandler)
           
 void setIdleInterval(int idleInterval)
           
 void setLimitSameInstanceJobs(boolean limitSameInstanceJobs)
           
 void setMaxLockTime(int maxLockTime)
           
 void setName(String name)
           
abstract  void start()
          starts the DispatcherThread and org.ow2.orchestra.pvm.internal.jobexecutor.pvm.JobExecutorThreads for this jobImpl executor
abstract  void stop()
          stops with join set to false.
abstract  void stop(boolean join)
          signals to all threads managed by this jobImpl executor to stop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final Log LOG

commandService

protected CommandService commandService

name

protected String name

idleMillis

protected int idleMillis

lockMillis

protected int lockMillis

acquireJobsCommand

protected Command<Collection<Collection<JobImpl<?>>>> acquireJobsCommand

nextDueDateCommand

protected Command<Date> nextDueDateCommand

isActive

protected boolean isActive

limitSameInstanceJobs

protected boolean limitSameInstanceJobs

deadJobHandler

protected DeadJobHandler deadJobHandler
Constructor Detail

AbstractJobExecutor

public AbstractJobExecutor()
Method Detail

stop

public abstract void stop(boolean join)
Description copied from interface: JobExecutor
signals to all threads managed by this jobImpl executor to stop. Stopping the dispatcher thread is blocking till the dispatcher is no more alive. If join is set to true, this method will block until all jobImpl executor threads are joined and actually dead. If join is false, the jobImpl executor threads are only told to stop, without waiting till they are actually stopped. It may be that jobImpl executor threads are in the middle of executing a jobImpl and they may finish after this method returned.

Specified by:
stop in interface JobExecutor

stop

public abstract void stop()
Description copied from interface: JobExecutor
stops with join set to false.

Specified by:
stop in interface JobExecutor
See Also:
JobExecutor.stop(boolean)

start

public abstract void start()
Description copied from interface: JobExecutor
starts the DispatcherThread and org.ow2.orchestra.pvm.internal.jobexecutor.pvm.JobExecutorThreads for this jobImpl executor

Specified by:
start in interface JobExecutor

getHostName

protected static String getHostName()

jobWasAdded

public void jobWasAdded()
Description copied from interface: JobExecutor
signals jobExecutor that a job has been added

Specified by:
jobWasAdded in interface JobExecutor

getName

public String getName()
Description copied from interface: JobExecutor
returns JobExecutor name

Specified by:
getName in interface JobExecutor

getIdleMillis

public int getIdleMillis()

isActive

public boolean isActive()
Description copied from interface: JobExecutor
returns true if this JobExecutor is started

Specified by:
isActive in interface JobExecutor

getLockMillis

public int getLockMillis()

getCommandExecutor

public CommandService getCommandExecutor()

getAcquireJobsCommand

public Command<Collection<Collection<JobImpl<?>>>> getAcquireJobsCommand()

getNextDueDateCommand

public Command<Date> getNextDueDateCommand()

setCommandExecutor

public void setCommandExecutor(CommandService commandExecutor)

setName

public void setName(String name)

setIdleInterval

public void setIdleInterval(int idleInterval)

setMaxLockTime

public void setMaxLockTime(int maxLockTime)

getDeadJobHandler

public DeadJobHandler getDeadJobHandler()
Specified by:
getDeadJobHandler in interface JobExecutor
Returns:
the handler to execute when a job has no retries left.

setDeadJobHandler

public void setDeadJobHandler(DeadJobHandler deadJobHandler)
Parameters:
deadJobHandler - the deadJobHandler to set

setLimitSameInstanceJobs

public void setLimitSameInstanceJobs(boolean limitSameInstanceJobs)
Parameters:
limitSameInstanceJobs - the limitSameInstanceJobs to set

isLimitSameInstanceJobs

public boolean isLimitSameInstanceJobs()
Returns:
the limitSameInstanceJobs

getDispatcherThread

protected abstract AbstractDispatcherThread getDispatcherThread()

getAcquireJobSize

protected abstract int getAcquireJobSize()


Copyright © 2011 OW2 Consortium. All Rights Reserved.