public class MasterSlotManager extends InternalSlotManager
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.
FAILED
followed with an
explanation.Modifier and Type | Class and Description |
---|---|
(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.
|
Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
log |
private MasterSlotManager.RemoteSlotRequestHandler |
remoteRequestHandler |
private java.util.Map<java.lang.String,MasterSlotManager.RemoteSlot> |
remoteSlots |
private java.util.TimerTask |
timeoutChecker |
Constructor and Description |
---|
MasterSlotManager() |
Modifier and Type | Method and Description |
---|---|
(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(java.lang.String slotId)
Get the remote slot with the given id.
|
void |
init(Agent agent)
Initialize the slot manager.
|
(package private) MasterSlotManager.RemoteSlot |
releaseRemoteSlot(java.lang.String slotId)
Release the remote slot with the given id.
|
getAgent, getSlot, getSlot, releaseSlot
private static final org.slf4j.Logger log
private java.util.Map<java.lang.String,MasterSlotManager.RemoteSlot> remoteSlots
private MasterSlotManager.RemoteSlotRequestHandler remoteRequestHandler
private java.util.TimerTask timeoutChecker
public void init(Agent agent)
SlotManager
init
in interface SlotManager
init
in class InternalSlotManager
agent
- The job agentpublic void close()
SlotManager
close
in interface SlotManager
close
in class InternalSlotManager
MasterSlotManager.RemoteSlot getRemoteSlot(Job.ExecutionTime estimated)
InternalSlotManager.getSlot(net.sf.basedb.core.Job.ExecutionTime)
and then wrap the slot in a MasterSlotManager.RemoteSlot
instance.MasterSlotManager.RemoteSlot getRemoteSlot(java.lang.String slotId)
slotId
- The id of the slotMasterSlotManager.RemoteSlot releaseRemoteSlot(java.lang.String slotId)
slotId
- The id of the slotint checkTimeoutOnRemoteSlots()