Package net.sf.basedb.core
Class JobAgentSettings
- java.lang.Object
-
- net.sf.basedb.core.BasicItem
-
- net.sf.basedb.core.ChildItem
-
- net.sf.basedb.core.JobAgentSettings
-
- All Implemented Interfaces:
AccessControlled
,Identifiable
public class JobAgentSettings extends ChildItem
This class contains a job agent's settings for a specific plugin. The settings may override the default settings for the JAR path where to plugin is located, maximum memory to use, and if the plugin is trusted or not.- Version:
- 2.0
- Author:
- nicklas
- Last modified
- $Date: 2015-04-17 14:02:22 +0200 (fr, 17 apr 2015) $
-
-
Field Summary
Fields Modifier and Type Field Description private static QueryRuntimeFilter
RUNTIME_FILTER
This filter will only return items if the logged in user has generic read permission to job agents.static Item
TYPE
The type of item represented by this class.
-
Constructor Summary
Constructors Constructor Description JobAgentSettings(JobAgentSettingsData data)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JobAgentSettings
getById(DbControl dc, int id)
Get aJobAgentSettings
item when you know the ID.(package private) JobAgentSettingsData
getData()
Get theBasicData
object that holds all data for this item.Long
getEffectiveMaxMemory()
Get the effective maximum amount of memory the plugin is allowed to use.int
getEffectivePriority(Job job)
Get the effective priority for the specified job, when the priority boost is taken into account.JobAgent
getJobAgent()
Get the job agent that owns these settings.Long
getMaxMemory()
Get the maximum amount of memory the plugin is allowed to use.(package private) static JobAgentSettings
getNew(DbControl dc, JobAgent agent, PluginDefinition plugin)
Create a newJobAgentSettings
item.PluginDefinition
getPluginDefinition()
Get the plugin that these settings are used for.int
getPriorityBoost()
Get the priority boost given to jobs executed by this plugin.(package private) static ItemQuery<JobAgentSettings>
getQuery(JobAgent agent)
Get a query configured to retrieve settings for the specified agent.(package private) static ItemQuery<JobAgentSettings>
getQuery(PluginDefinition plugin)
Get a query configured to retrieve settings for the specified plugin.(package private) SharedData
getSharedParent()
Get the shareable parent item of this child item.Item
getType()
Get the type of item represented by the object.boolean
isEffectivelyTrusted()
If the plugin is a trusted plugin or not.Boolean
isTrusted()
If the plugin is a trusted plugin or not.private void
setJobAgent(JobAgent agent)
void
setMaxMemory(Long maxMemory)
Set maximim amount of memory the plugin is allowed to use.private void
setPluginDefinition(PluginDefinition plugin)
void
setPriorityBoost(int priorityBoost)
Set the priority boost given to jobs executed by this plugin.void
setTrusted(Boolean trusted)
Set the trusted flag for this plugin.-
Methods inherited from class net.sf.basedb.core.ChildItem
getPermissionForUse, getPermissionForWriteDeleteAndCreate, getPluginPermissions, initPermissions
-
Methods inherited from class net.sf.basedb.core.BasicItem
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, validate
-
-
-
-
Field Detail
-
TYPE
public static final Item TYPE
The type of item represented by this class.- See Also:
Item.JOBAGENTSETTINGS
,getType()
-
RUNTIME_FILTER
private static final QueryRuntimeFilter RUNTIME_FILTER
This filter will only return items if the logged in user has generic read permission to job agents.
-
-
Constructor Detail
-
JobAgentSettings
JobAgentSettings(JobAgentSettingsData data)
-
-
Method Detail
-
getNew
static JobAgentSettings getNew(DbControl dc, JobAgent agent, PluginDefinition plugin)
Create a newJobAgentSettings
item.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database accessagent
- The job agent these settings belong toplugin
- The plugin definition these settings are for- Returns:
- The new
JobAgentSettings
item - Throws:
BaseException
- If there is another error
-
getById
public static JobAgentSettings getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
Get aJobAgentSettings
item when you know the ID.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database accessid
- The ID of the item to load- Returns:
- The
JobAgentSettings
item - Throws:
ItemNotFoundException
- If an item with the specified ID is not foundPermissionDeniedException
- If the logged in user doesn't have read permission for the itemBaseException
- If there is another error
-
getQuery
static ItemQuery<JobAgentSettings> getQuery(JobAgent agent)
Get a query configured to retrieve settings for the specified agent.- Parameters:
agent
- The job agent to retreive settings for, null is not allowed- Returns:
- An
ItemQuery
object - See Also:
JobAgent.getSettings()
-
getQuery
static ItemQuery<JobAgentSettings> getQuery(PluginDefinition plugin)
Get a query configured to retrieve settings for the specified plugin. This query only return items if the logged in user has generic read permission for all job agents.- Parameters:
plugin
- The plugin to retreive settings for, null is not allowed- Returns:
- An
ItemQuery
object
-
getData
JobAgentSettingsData getData()
Description copied from class:BasicItem
Get theBasicData
object that holds all data for this item.
-
getType
public Item getType()
Description copied from interface:Identifiable
Get the type of item represented by the object. The returned value is one of the values defined in theItem
enumeration.- Returns:
- A value indicating the type of item
-
getSharedParent
SharedData getSharedParent()
Description copied from class:ChildItem
Get the shareable parent item of this child item. This is used by theChildItem.initPermissions(int, int)
method to calculate the logged in user's permissions for the child item.- Specified by:
getSharedParent
in classChildItem
- Returns:
- The parent item
-
getJobAgent
public JobAgent getJobAgent() throws PermissionDeniedException, BaseException
Get the job agent that owns these settings.- Returns:
- The
JobAgent
item - Throws:
PermissionDeniedException
- If the logged in user doesn't have read permission to the itemBaseException
- If there is another error
-
setJobAgent
private void setJobAgent(JobAgent agent)
-
getPluginDefinition
public PluginDefinition getPluginDefinition()
Get the plugin that these settings are used for.- Returns:
- The
PluginDefinition
item - Throws:
PermissionDeniedException
- If the logged in user doesn't have read permission to the itemBaseException
- If there is another error
-
setPluginDefinition
private void setPluginDefinition(PluginDefinition plugin)
-
isTrusted
public Boolean isTrusted()
If the plugin is a trusted plugin or not. If null the trusted flag returned by the plugin definition should be used.- Returns:
- A boolean vaue or null
- See Also:
PluginDefinition.isTrusted()
,isEffectivelyTrusted()
-
isEffectivelyTrusted
public boolean isEffectivelyTrusted()
If the plugin is a trusted plugin or not. If these settings hasn't configured a value the trusted flag returned by the plugin definition is used.- Returns:
- TRUE if the plugin is trusted, FALSE otherwise
- See Also:
PluginDefinition.isTrusted()
,isTrusted()
-
setTrusted
public void setTrusted(Boolean trusted)
Set the trusted flag for this plugin.- Parameters:
trusted
- A boolean value or null if the plugin definition setting should be used- See Also:
PluginDefinition.isTrusted()
-
getMaxMemory
public Long getMaxMemory()
Get the maximum amount of memory the plugin is allowed to use. If null the max memory returned by the plugin definition should be used.- Returns:
- The maximum amount of memory or null
- See Also:
PluginDefinition.getMaxMemory()
,getEffectiveMaxMemory()
-
getEffectiveMaxMemory
public Long getEffectiveMaxMemory()
Get the effective maximum amount of memory the plugin is allowed to use. If these settings hasn't configured an amount, the max memory from the plugin definition is returned.- Returns:
- The maximum memory or null if no maximum has been specified
- See Also:
PluginDefinition.getMaxMemory()
,getMaxMemory()
-
setMaxMemory
public void setMaxMemory(Long maxMemory) throws PermissionDeniedException, InvalidDataException
Set maximim amount of memory the plugin is allowed to use.- Parameters:
maxMemory
- The maximum amount or null to use the amount specified by the plugin definition- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the new value is less than zero
-
getPriorityBoost
public int getPriorityBoost()
Get the priority boost given to jobs executed by this plugin. The priority boost is subtracted from the value job's priority value, resulting in a lower priority value for the job. Jobs with lower values are executed befor jobs with higher values.The priority boost is useful if we, for example, want to use one server mainly for importing data. By giving all import plugins a priority boost they will be executed before all other jobs.
- Returns:
- The priority boost, a value between 0 and 10
- See Also:
Job.getPriority()
-
setPriorityBoost
public void setPriorityBoost(int priorityBoost)
Set the priority boost given to jobs executed by this plugin.- Parameters:
priorityBoost
- The priority boost, must be between 0 and 10- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the new value is less than 0 or greater than 10
-
getEffectivePriority
public int getEffectivePriority(Job job) throws InvalidDataException
Get the effective priority for the specified job, when the priority boost is taken into account.- Parameters:
job
- The job to get the prioriy for- Returns:
- The effective priority
- Throws:
InvalidDataException
- If the job is null or has a different plugin definition than these settings- See Also:
Job.getPriority()
-
-