2.17.2: 2011-06-17

net.sf.basedb.clients.jobagent.executors
Class ThreadJobExecutor

java.lang.Object
  extended by net.sf.basedb.clients.jobagent.executors.ThreadJobExecutor
All Implemented Interfaces:
JobExecutor

public class ThreadJobExecutor
extends Object
implements JobExecutor

This is a job executor which executes jobs in the current thread. This has the disadvantage that a misbehaving job can interfere with other jobs and the job agent. For example, a call to System.exit(int) would result in all other jobs as well as the job agent getting killed.

The advantage is that there is no overhead in time or memory.

Version:
2.0
Author:
nicklas
Last modified
$Date: 2008-09-11 22:05:50 +0200 (Thu, 11 Sep 2008) $

Nested Class Summary
private static class ThreadJobExecutor.ShutdownHook
           
 
Field Summary
private static Logger log
          Log job agent events.
private  SignalReceiver signalReceiver
           
 
Constructor Summary
ThreadJobExecutor()
           
 
Method Summary
 void close()
          This method is called at when the agent is stopped or paused.
 void executeJob(SessionControl sc, Agent agent, Job job, JobAgentSettings settings, Job.ExecutionTime usedSlot)
          Execute the specified job.
 void init(Agent agent)
          Initialize the job executor.
static void main(String[] args)
           
private  void setSignalReceiver(SignalReceiver signalReceiver)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final Logger log
Log job agent events.


signalReceiver

private SignalReceiver signalReceiver
Constructor Detail

ThreadJobExecutor

public ThreadJobExecutor()
Method Detail

init

public void init(Agent agent)
Description copied from interface: JobExecutor
Initialize the job executor. This method is called once immediately after the object has been created.

Specified by:
init in interface JobExecutor
Parameters:
agent - The agent

executeJob

public void executeJob(SessionControl sc,
                       Agent agent,
                       Job job,
                       JobAgentSettings settings,
                       Job.ExecutionTime usedSlot)
Description copied from interface: JobExecutor
Execute the specified job. This method is called in a new thread created specifically for running that job. If the agent is shutting down it will send an interrupt signal to all job threads. It is up to the job executor to decide how to handle this. It may either decide to kill the job or let it continue as if nothing happened.

The job sent to this method has it's status set to Job.Status.PREPARED. The implementation of this method must change the status to either Job.Status.DONE or Job.Status.ERROR. If the status hasn't changed the job agent will set the status to signal an unknown error.

Specified by:
executeJob in interface JobExecutor
Parameters:
sc - A SessionControl where the owner of the job is logged in and the correct active project is set
agent - The agent that sent the request to execute the job
job - The job to execute
settings - The specific settings used for the plugin on this job agent or null if no settings has been specified
usedSlot - The slot that was used to execut the job

close

public void close()
Description copied from interface: JobExecutor
This method is called at when the agent is stopped or paused. No more execution requests will be sent to the current job executor, but running jobs should NOT be terminated due to this method beeing called.

Specified by:
close in interface JobExecutor

setSignalReceiver

private void setSignalReceiver(SignalReceiver signalReceiver)

main

public static void main(String[] args)

2.17.2: 2011-06-17