2.17.2: 2011-06-17

net.sf.basedb.core
Class JobAgentSettings

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<D>
      extended by net.sf.basedb.core.ChildItem<JobAgentSettingsData>
          extended by net.sf.basedb.core.JobAgentSettings
All Implemented Interfaces:
AccessControlled, Identifiable

public class JobAgentSettings
extends ChildItem<JobAgentSettingsData>

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: 2008-09-11 22:11:02 +0200 (Thu, 11 Sep 2008) $

Field Summary
static int MAX_JARPATH_LENGTH
          The maximum length of the jar path that can be stored in the database.
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
JobAgentSettings(JobAgentSettingsData data)
           
 
Method Summary
static JobAgentSettings getById(DbControl dc, int id)
          Get a JobAgentSettings item when you know the ID.
 String getEffectiveJarPath()
          Get the effective path to the JAR file that contains the plugin implementation.
 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.
 String getJarPath()
          Get the path to the JAR file that contains the plugin implementation.
 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 new JobAgentSettings 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.
 void setJarPath(String jarPath)
          Set the path to the JAR file that contains the plugin implementation.
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
getPermissionForWriteDeleteAndCreate, getPluginPermissions, initPermissions
 
Methods inherited from class net.sf.basedb.core.BasicItem
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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.


MAX_JARPATH_LENGTH

public static final int MAX_JARPATH_LENGTH
The maximum length of the jar path that can be stored in the database.

See Also:
setJarPath(String), Constant Field Values
Constructor Detail

JobAgentSettings

JobAgentSettings(JobAgentSettingsData data)
Method Detail

getNew

static JobAgentSettings getNew(DbControl dc,
                               JobAgent agent,
                               PluginDefinition plugin)
Create a new JobAgentSettings item.

Parameters:
dc - The DbControl which will be used for permission checking and database access
agent - The job agent these settings belong to
plugin - 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 a JobAgentSettings item when you know the ID.

Parameters:
dc - The DbControl which will be used for permission checking and database access
id - The ID of the item to load
Returns:
The JobAgentSettings item
Throws:
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 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

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 the Item 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 the ChildItem.initPermissions(int, int) method to calculate the logged in user's permissions for the child item.

Specified by:
getSharedParent in class ChildItem<JobAgentSettingsData>
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 item
BaseException - 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 item
BaseException - If there is another error

setPluginDefinition

private void setPluginDefinition(PluginDefinition plugin)

getJarPath

public String getJarPath()
Get the path to the JAR file that contains the plugin implementation. If null the jar path returned by the plugin definition should be used.

Returns:
The JAR path or null
See Also:
PluginDefinition.getJarPath(), getEffectiveJarPath()

getEffectiveJarPath

public String getEffectiveJarPath()
Get the effective path to the JAR file that contains the plugin implementation. If these settings hasn't configured a special JAR path, the JAR path from the plugin definition is returned.

Returns:
The JAR path
See Also:
PluginDefinition.getJarPath(), getJarPath()

setJarPath

public void setJarPath(String jarPath)
                throws PermissionDeniedException,
                       InvalidDataException
Set the path to the JAR file that contains the plugin implementation.

Parameters:
jarPath - The JAR path or null to use the JAR path specified by the plugin definition
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the new value is longer than MAX_JARPATH_LENGTH

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 permission
InvalidDataException - 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 permission
InvalidDataException - 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()

2.17.2: 2011-06-17