2.17.2: 2011-06-17

net.sf.basedb.clients.jobagent.slotmanager
Class MasterSlotManager

java.lang.Object
  extended by net.sf.basedb.clients.jobagent.slotmanager.InternalSlotManager
      extended by net.sf.basedb.clients.jobagent.slotmanager.MasterSlotManager
All Implemented Interfaces:
SlotManager

public class MasterSlotManager
extends InternalSlotManager

An extension to the internal slot manager which also accepts slot assignment from remote job agents. A custom request handler (MasterSlotManager.RemoteSlotRequestHandler) is installed to take care of the communication. Remotely assigned slots has a time-out (30 seconds) associated with them. This means that if the connection with the remote host is lost, the assigned slots are re-cycled.

The requst handler uses a simple protocol with the following actions:

If a request fails, the request handler returns FAILED followed with an explanation.

Since:
2.16
Author:
Nicklas
Last modified
$Date: 2010-10-19 13:02:17 +0200 (Tue, 19 Oct 2010) $

Nested Class Summary
(package private) static class MasterSlotManager.RemoteSlot
          A remote slot is a slot with some information about when it was created and last updated.
(package private) static class MasterSlotManager.RemoteSlotRequestHandler
          Request handler implementation that accepts requests for slots from remote hosts.
(package private) static class MasterSlotManager.RemoteSlotTimeoutChecker
          Task that is scheduled at regular intervals to check for timed out slots.
 
Field Summary
private static Logger log
           
private  MasterSlotManager.RemoteSlotRequestHandler remoteRequestHandler
           
private  Map<String,MasterSlotManager.RemoteSlot> remoteSlots
           
private  TimerTask timeoutChecker
           
 
Constructor Summary
MasterSlotManager()
           
 
Method Summary
(package private)  int checkTimeoutOnRemoteSlots()
          Check the remote slots to see if they have timed out.
 void close()
          This method is called when the job agent is shutting down.
(package private)  MasterSlotManager.RemoteSlot getRemoteSlot(Job.ExecutionTime estimated)
          Create a slot for a job on a remote job agent with the specified estimated execution time.
(package private)  MasterSlotManager.RemoteSlot getRemoteSlot(String slotId)
          Get the remote slot with the given id.
 void init(Agent agent)
          Initialize the slot manager.
(package private)  MasterSlotManager.RemoteSlot releaseRemoteSlot(String slotId)
          Release the remote slot with the given id.
 
Methods inherited from class net.sf.basedb.clients.jobagent.slotmanager.InternalSlotManager
getAgent, getSlot, getSlot, releaseSlot
 
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

remoteSlots

private Map<String,MasterSlotManager.RemoteSlot> remoteSlots

remoteRequestHandler

private MasterSlotManager.RemoteSlotRequestHandler remoteRequestHandler

timeoutChecker

private TimerTask timeoutChecker
Constructor Detail

MasterSlotManager

public MasterSlotManager()
Method Detail

init

public void init(Agent agent)
Description copied from interface: SlotManager
Initialize the slot manager. This method is called once when the job agent is starting up. The slot manager may read configuration settings, and intialize local resources.

Specified by:
init in interface SlotManager
Overrides:
init in class InternalSlotManager
Parameters:
agent - The job agent

close

public void close()
Description copied from interface: SlotManager
This method is called when the job agent is shutting down. The slot manager should clean up any resources it is using.

Specified by:
close in interface SlotManager
Overrides:
close in class InternalSlotManager

getRemoteSlot

MasterSlotManager.RemoteSlot getRemoteSlot(Job.ExecutionTime estimated)
Create a slot for a job on a remote job agent with the specified estimated execution time. This method will call the InternalSlotManager.getSlot(net.sf.basedb.core.Job.ExecutionTime) and then wrap the slot in a MasterSlotManager.RemoteSlot instance.

Returns:
A remote slot, or null if not slot is available

getRemoteSlot

MasterSlotManager.RemoteSlot getRemoteSlot(String slotId)
Get the remote slot with the given id.

Parameters:
slotId - The id of the slot
Returns:
A remote slot or null if no slot with the given id exists

releaseRemoteSlot

MasterSlotManager.RemoteSlot releaseRemoteSlot(String slotId)
Release the remote slot with the given id.

Parameters:
slotId - The id of the slot
Returns:
A remote slot or null if no slot with the given id exists

checkTimeoutOnRemoteSlots

int checkTimeoutOnRemoteSlots()
Check the remote slots to see if they have timed out. If so, release them.

Returns:
The number of timed out slots

2.17.2: 2011-06-17