Class MasterSlotManager

All Implemented Interfaces:

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:

  • slotmanager://host:port/get-slot?TIME: Get a new slot for the TIME estimated execution time. TIME is a name from the Job.ExecutionTime enumeration. If succcessful, the request handler answers with OK on the first line and then Id:slot-id and Slot:TIME on the following lines. It is recommended that the answer is parsed with JobAgentConnection.parseSimpleAnswer(String).
  • slotmanger://slot-id@host:port/release-slot: Release the slot with the given id.
  • slotmanager://slot-id@host:port/ping-slot: Ping the slot with the given id to indicate that the job is still running on the remote job agent. A remote slot has a timeout of 30 seconds so the remote job agent has to send a ping at least at that interval or the slot will be returned to the pool.
If a request fails, the request handler returns FAILED followed with an explanation.
Last modified
$Date: 2014-04-09 14:21:20 +0200 (on, 09 apr 2014) $
  • Field Details

  • Constructor Details

    • MasterSlotManager

      public MasterSlotManager()
  • Method Details

    • 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
      init in class InternalSlotManager
      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
      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.
      A remote slot, or null if not slot is available
    • getRemoteSlot

      MasterSlotManager.RemoteSlot getRemoteSlot​(String slotId)
      Get the remote slot with the given id.
      slotId - The id of the slot
      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.
      slotId - The id of the slot
      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.
      The number of timed out slots