|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.BasicItem<D> net.sf.basedb.core.OwnedItem<D> net.sf.basedb.core.SharedItem<D> net.sf.basedb.core.CommonItem<JobAgentData> net.sf.basedb.core.JobAgent
public class JobAgent
This class represents a job agent, which is a program running in another virtual machine on the same or a different server. The job agent is regularly checking the database for jobs that are waiting to be executed. It is not neccessary for a job agent to be registered in the database but if it is the core can provide services that are otherwise inaccesible.
Field Summary | |
---|---|
private static Map<Integer,JobAgentInfo> |
agentInfo
|
static int |
DEFAULT_PORT
The default port (47822) where job agents are listening for connections. |
private static Logger |
log
Log events. |
static int |
MAX_EXTERNAL_ID_LENGTH
The maximum length of the external ID that can be stored in the database. |
static int |
MAX_SERVER_LENGTH
The maximum length of the server name that can be stored in the database. |
static Item |
TYPE
The type of item represented by this class. |
Fields inherited from interface net.sf.basedb.core.Nameable |
---|
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH |
Constructor Summary | |
---|---|
JobAgent(JobAgentData data)
|
Method Summary | |
---|---|
private static JobAgentInfo |
getAgentInfo(JobAgent agent)
Get a JobAgentInfo for a job agent. |
static JobAgent |
getByExternalId(DbControl dc,
String externalId)
Get a JobAgent item when you know the external ID. |
static JobAgent |
getById(DbControl dc,
int id)
Get a JobAgent object when you know the ID. |
JobAgentConnection |
getConnection(Integer timeout)
Get a connection object for connecting to the job agent. |
Integer |
getCpuUsage()
Get the current CPU usage in percent of the server where the job agent is running. |
String |
getExternalId()
Get the external id for the job agent. |
JobAgentInfo |
getInfo()
Get info about the running job agent. |
static JobAgent |
getNew(DbControl dc,
String externalId)
Create a new JobAgent item. |
Integer |
getPort()
Get the port the job agent is listening on. |
static ItemQuery<JobAgent> |
getQuery()
Get an ItemQuery that returns job agents. |
String |
getServer()
Get the name or IP-adress of the server were the job agent is running. |
ItemQuery<JobAgentSettings> |
getSettings()
Get a query that returns all plugin-specific settings for this job agent. |
JobAgentSettings |
getSettings(Job job)
Get the settings for the plugin that is used for the specified job. |
JobAgentSettings |
getSettings(PluginDefinition plugin,
boolean create)
Get the settings for the specified plugin. |
Long |
getTotalMemory()
Get the total memory in bytes of the server where the job agent is running. |
Item |
getType()
Get the type of item represented by the object. |
Long |
getUsedMemory()
Get the current memory usage in bytes of the server where the job agent is running. |
ItemQuery<Job> |
getWaitingJobs()
Get a query that returns all jobs that are waiting to be executed sorted by their priority taking the priority boost into account. |
void |
setExternalId(String externalId)
Set the external id for the job agent. |
void |
setPort(Integer port)
Set the port the job agent is listening on. |
void |
setServer(String server)
Set the name/IP of the server where the job agent is running. |
Methods inherited from class net.sf.basedb.core.CommonItem |
---|
getDescription, getName, isRemoved, setDescription, setName, setRemoved, toTransferable |
Methods inherited from class net.sf.basedb.core.SharedItem |
---|
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey, toTransferable |
Methods inherited from class net.sf.basedb.core.OwnedItem |
---|
getOwner, isOwner, setOwner, takeOwnership, toTransferable |
Methods inherited from class net.sf.basedb.core.BasicItem |
---|
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.basedb.core.Identifiable |
---|
getId, getVersion |
Methods inherited from interface net.sf.basedb.core.AccessControlled |
---|
checkPermission, getPermissions, hasPermission |
Methods inherited from interface net.sf.basedb.core.Ownable |
---|
getOwner, isOwner, setOwner, takeOwnership |
Field Detail |
---|
private static final Logger log
public static final Item TYPE
Item.JOBAGENT
,
getType()
public static final int DEFAULT_PORT
public static final int MAX_EXTERNAL_ID_LENGTH
setExternalId(String)
,
Constant Field Valuespublic static final int MAX_SERVER_LENGTH
setServer(String)
,
Constant Field Valuesprivate static final Map<Integer,JobAgentInfo> agentInfo
Constructor Detail |
---|
JobAgent(JobAgentData data)
Method Detail |
---|
public static JobAgent getNew(DbControl dc, String externalId) throws BaseException
JobAgent
item.
dc
- The DbControl
which will be used for
permission checking and database accessexternalId
- The external ID, which must be unique, for the job agent
JobAgent
item
BaseException
- If there is an errorpublic static JobAgent getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
JobAgent
object when you know the ID.
dc
- The DbControl
which will be used for
permission checking and database access.id
- The ID of the item to load
JobAgent
item
ItemNotFoundException
- If an item with the specified ID is
not found
PermissionDeniedException
- If the logged in user doesn't
have read permission to the item
BaseException
- If there is another errorpublic static JobAgent getByExternalId(DbControl dc, String externalId) throws ItemNotFoundException, PermissionDeniedException, BaseException
JobAgent
item when you know the external ID.
dc
- The DbControl
which will be used for
permission checking and database access.externalId
- The external ID of the item to load
JobAgent
item
ItemNotFoundException
- If an item with the specified ID is not found
PermissionDeniedException
- If the logged in user doesn't have
read permission for the item
BaseException
- If there is another errorpublic static ItemQuery<JobAgent> getQuery()
ItemQuery
that returns job agents.
ItemQuery
objectpublic Item getType()
Identifiable
Item
enumeration.
public String getExternalId()
public void setExternalId(String externalId) throws PermissionDeniedException, InvalidDataException, BaseException
externalId
- External id to be set.
PermissionDeniedException
- If the logged in user doesn't have
write permission
InvalidDataException
- If the new value is longer than
MAX_EXTERNAL_ID_LENGTH
BaseException
- If there is another errorpublic String getServer()
public void setServer(String server) throws InvalidDataException, PermissionDeniedException
server
- The name/IP or null if not known
InvalidDataException
- If the new value is longer than MAX_SERVER_LENGTH
PermissionDeniedException
- If the logged in user doesn't have
write permissionpublic Integer getPort()
public void setPort(Integer port)
port
- The new port number or null if the job agent isn't listeningpublic JobAgentInfo getInfo()
agent.maxage
configuration setting.
JobAgentInfo
objectpublic JobAgentConnection getConnection(Integer timeout) throws PermissionDeniedException
timeout
- The timeout for the connection, null will use the default
timeout as configued by the agent.connection.timeout
setting
in the base.config
file
PermissionDeniedException
- If the logged in user doesn't have
WRITE permission on the job agentpublic Integer getCpuUsage()
agent.maxage
configuration setting.
public Long getUsedMemory()
agent.maxage
configuration setting.
public Long getTotalMemory()
agent.maxage
configuration
setting.
public JobAgentSettings getSettings(PluginDefinition plugin, boolean create)
JobAgentSettings
item is created if the create
parameter is true. You must call DbControl.saveItem(BasicItem)
to save the new settings to the database.
plugin
- The plugin to the settings for, or null if none exists
and the create
parameter is falsecreate
- TRUE if new settings should be created if no one was found, FALSE otherwise.
JobAgentSettings
object for the specified pluginpublic JobAgentSettings getSettings(Job job)
job
- The job to get the settings for
JobAgentSettings
object or null if not
settings exist for the jobpublic ItemQuery<JobAgentSettings> getSettings()
ItemQuery
objectpublic ItemQuery<Job> getWaitingJobs()
ItemQuery
objectprivate static JobAgentInfo getAgentInfo(JobAgent agent)
JobAgentInfo
for a job agent. If the job agent hasn't specified
a server and port or if there is an error while connecting to the job agent
an empty info object is returned.
agent
- The job agent to get the info for
JobAgentInfo
object
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |