Class ServiceRegistryJpaImpl
java.lang.Object
org.opencastproject.serviceregistry.impl.ServiceRegistryJpaImpl
- All Implemented Interfaces:
ServiceRegistry,org.osgi.service.cm.ManagedService
public class ServiceRegistryJpaImpl
extends Object
implements ServiceRegistry, org.osgi.service.cm.ManagedService
JPA implementation of the
ServiceRegistry-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BooleanWhether to accept a job whose load exceeds the host’s max loadprotected TrustedHttpClientThe http client to use when connecting to remote serversprotected booleanWhether to collect detailed job statisticsprotected DBSessionprotected DBSessionFactoryprotected javax.persistence.EntityManagerFactoryThe factory used to generate the entity managerprotected static doubleThreshold value under which defined workers get preferred when dispatching encoding jobsComma-seperate list with URLs of encoding specialised workersprotected StringThis host's base URLprotected Incidentsprotected IncidentServiceprotected List<ObjectInstance> The list of registered JMX beansprotected static final List<Job.Status> A static list of statuses that influence how load balancing is calculatedprotected StringThe base URL for job URLsprotected floatprotected intNumber of failed jobs on a service before to set it in error state. -1 will disable error states completely.protected intMaximum age of jobs being considering for service statisticsprotected StringThis host's descriptive node name eg admin, worker01protected static final StringConfiguration key for the encoding workers load thresholdprotected static final StringConfiguration key for the encoding preferred worker nodesprotected static final StringConfiguration key for the interval to check whether the hosts in the service registry are still alive, in secondsprotected static final StringConfiguration key for the collection of job statisticsprotected static final StringConfiguration key for the maximum loadprotected static final StringConfiguration key for the retrieval of service statistics: Do not consider jobs older than max_job_age (in days)static final StringJPA persistence unit namestatic final StringId of the workflow's resume operation, need to match the corresponding enum value in WorkflowServiceImplprotected ScheduledExecutorServiceThe thread pool to use for dispatching queued jobs and checking on phantom services.protected SecurityServiceThe security servicestatic final StringId of the workflow's start operation operation, need to match the corresponding enum value in WorkflowServiceImplstatic final StringId of the workflow's start workflow operation, need to match the corresponding enum value in WorkflowServiceImplstatic final StringIdentifier for the workflow service -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) longcount(String serviceType, String host, String operation, Job.Status status) Count the number of jobs executing the given operation in thisJob.Statuson this host.longcount(String serviceType, Job.Status status) Count the number of jobs that match the specified parameters.Count active jobs and group them by organization and host.countActiveTypeByOrganization(String operation) Count active jobs of a given operation type and group them by organization.longcountByHost(String serviceType, String host, Job.Status status) Count the number of jobs in thisJob.Statuson this hostlongcountByOperation(String serviceType, String operation, Job.Status status) Count the number of jobs running the given operation in thisJob.Status.Create and store a new job that will be dispatched as soon as possible.createJob(String host, String serviceType, String operation, List<String> arguments, String payload, boolean dispatchable, Job parentJob) Creates a job on a remote host with a jobLoad of 1.0.createJob(String host, String serviceType, String operation, List<String> arguments, String payload, boolean dispatchable, Job parentJob, float jobLoad) Creates a job on a remote host.Create and store a new job that will be dispatched as soon as possible.Create and store a new job that will be dispatched as soon as possible.createJob(String type, String operation, List<String> arguments, String payload, boolean dispatchable) Create and store a new job.createJob(String type, String operation, List<String> arguments, String payload, boolean dispatchable, Float jobLoad) Create and store a new job.createJob(String type, String operation, List<String> arguments, String payload, boolean dispatchable, Job parentJob) createJob(String type, String operation, List<String> arguments, String payload, boolean dispatchable, Job parentJob, Float jobLoad) Create and store a new job.voidvoiddisableHost(String host) Disables a Opencast server from service.voidenableHost(String host) Enable an inactive host as a provider of Opencast services.protected Function<javax.persistence.EntityManager, Optional<HostRegistrationJpaImpl>> Fetches a host registration from persistence.Get the list of active jobs.getChildJobs(long id) Get all child jobs from a jobGets a map of hosts to the number of jobs currently loading that hostGets the current running jobgetDispatchableJobsWithStatusQuery(int offset, int limit, Job.Status... statuses) Gets jobs of all types that are in the given state.getHostRegistration(String hostname) Finds host registration for the given hostname.protected Function<javax.persistence.EntityManager, HostRegistration> getHostRegistrationQuery(String hostname) Gets all host registrationsprotected Function<javax.persistence.EntityManager, List<HostRegistration>> Gets all host registrationsGet statistics about jobs active on hosts.getJob(long id) Gets a receipt by its ID, or null if not foundintgetJobCount(String operation) Return the number of jobs for a specified operation type.getJobPayloads(String operation) Return the payload of all jobs for a specified operation type.getJobPayloads(String operation, int limit, int offset) Return the payload of a specified number of jobs for a specified operation type.getJobs(String type, Job.Status status) Gets the list of jobs that match the specified parameters.getJobsByStatusQuery(Job.Status... statuses) Get the list of jobs with status from the given statuses.getMaxLoadOnNode(String host) Returns the maximum load that can be handled by a given node.Returns the maximum load that can be handled by the currently registered hosts.floatGets the load value for the current host (ie, the host this service registry lives onReturns the service regstry's hostname.getServiceRegistration(String serviceType, String host) Finds a single service registration by host and type, even if the service is offline or in maintenance mode.protected Function<javax.persistence.EntityManager, Optional<ServiceRegistrationJpaImpl>> getServiceRegistrationQuery(String serviceType, String host) Finds all service registrations, including offline services and those in maintenance mode.Finds the service registrations on the given host, including offline services and those in maintenance mode.getServiceRegistrationsByLoad(String serviceType) Do not look at this, it will burn your eyes!protected List<ServiceRegistration> getServiceRegistrationsByLoad(String jobType, List<ServiceRegistration> serviceRegistrations, List<HostRegistration> hostRegistrations, SystemLoad systemLoad) Returns a filtered list of service registrations, containing only those that are online, not in maintenance mode, and with a specific service type, ordered by load.getServiceRegistrationsByType(String serviceType) Finds the service registrations for this kind of job, including offline services and those in maintenance mode.protected Function<javax.persistence.EntityManager, List<ServiceRegistration>> Gets all service registrations.protected List<ServiceRegistration> getServiceRegistrationsWithCapacity(String jobType, List<ServiceRegistration> serviceRegistrations, List<HostRegistration> hostRegistrations, SystemLoad systemLoad) Returns a filtered list of service registrations, containing only those that are online, not in maintenance mode, and with a specific service type that are running on a host which is not already maxed out.Gets performance and runtime statistics for each known service registration.incident()Return a facility to record job incidents.voidOSGI callback when the configuration is updated.voidregisterHost(String host, String address, String nodeName, long memory, int cores, float maxLoad) Registers a host as a provider of Opencast services.registerService(String serviceType, String baseUrl, String path) Registers a host to handle a specific type of jobregisterService(String serviceType, String baseUrl, String path, boolean jobProducer) Registers a host to handle a specific type of jobvoidremoveJobs(List<Long> jobIds) Deletes the given jobs from the service registryvoidremoveParentlessJobs(int lifetime) Removes all jobs which do not have a parent job (except workflow instance jobs) and which have passed their lifetime.voidSets the given service to NORMAL statevoidsetCurrentJob(Job job) Sets the current running jobvoidsetDBSessionFactory(DBSessionFactory dbSessionFactory) voidsetIncidentService(IncidentService incidentService) OSGi DI.protected JpaJobvoidsetMaintenanceStatus(String baseUrl, boolean maintenance) Sets a registered host's maintenance statusprotected ServiceRegistrationsetOnlineStatus(String serviceType, String baseUrl, String path, boolean online, Boolean jobProducer) Sets the online status of a service registration.voidsetSecurityService(SecurityService securityService) Callback for setting the security service.voidunregisterHost(String host) Removes an Opencast server from service.voidunRegisterService(String serviceType, String baseUrl) Unregisters a host from handling a specific type of jobvoidunsetIncidentService(IncidentService incidentService) voidupdated(Dictionary properties) protected JpaJobupdateInternal(JpaJob job) Internal method to update a job, throwing unwrapped JPA exceptions.Update the job in the databasevoid
-
Field Details
-
PERSISTENCE_UNIT
JPA persistence unit name- See Also:
-
START_OPERATION
Id of the workflow's start operation operation, need to match the corresponding enum value in WorkflowServiceImpl- See Also:
-
START_WORKFLOW
Id of the workflow's start workflow operation, need to match the corresponding enum value in WorkflowServiceImpl- See Also:
-
RESUME
Id of the workflow's resume operation, need to match the corresponding enum value in WorkflowServiceImpl- See Also:
-
TYPE_WORKFLOW
Identifier for the workflow service- See Also:
-
jmxBeans
The list of registered JMX beans -
OPT_MAXLOAD
Configuration key for the maximum load- See Also:
-
OPT_HEARTBEATINTERVAL
Configuration key for the interval to check whether the hosts in the service registry are still alive, in seconds- See Also:
-
OPT_JOBSTATISTICS
Configuration key for the collection of job statistics- See Also:
-
OPT_SERVICE_STATISTICS_MAX_JOB_AGE
Configuration key for the retrieval of service statistics: Do not consider jobs older than max_job_age (in days)- See Also:
-
OPT_ENCODING_WORKERS
Configuration key for the encoding preferred worker nodes- See Also:
-
OPT_ENCODING_THRESHOLD
Configuration key for the encoding workers load threshold- See Also:
-
client
The http client to use when connecting to remote servers -
maxAttemptsBeforeErrorState
protected int maxAttemptsBeforeErrorStateNumber of failed jobs on a service before to set it in error state. -1 will disable error states completely. -
hostName
This host's base URL -
nodeName
This host's descriptive node name eg admin, worker01 -
jobHost
The base URL for job URLs -
encodingWorkers
Comma-seperate list with URLs of encoding specialised workers -
encodingThreshold
protected static double encodingThresholdThreshold value under which defined workers get preferred when dispatching encoding jobs -
emf
protected javax.persistence.EntityManagerFactory emfThe factory used to generate the entity manager -
dbSessionFactory
-
db
-
scheduledExecutor
The thread pool to use for dispatching queued jobs and checking on phantom services. -
securityService
The security service -
incidentService
-
incidents
-
collectJobstats
protected boolean collectJobstatsWhether to collect detailed job statistics -
maxJobAge
protected int maxJobAgeMaximum age of jobs being considering for service statistics -
JOB_STATUSES_INFLUENCING_LOAD_BALANCING
A static list of statuses that influence how load balancing is calculated -
jobCache
-
acceptJobLoadsExeedingMaxLoad
Whether to accept a job whose load exceeds the host’s max load -
localSystemLoad
protected float localSystemLoad
-
-
Constructor Details
-
ServiceRegistryJpaImpl
public ServiceRegistryJpaImpl()
-
-
Method Details
-
setDBSessionFactory
-
activate
public void activate(org.osgi.service.component.ComponentContext cc) -
getOwnLoad
public float getOwnLoad()Description copied from interface:ServiceRegistryGets the load value for the current host (ie, the host this service registry lives on- Specified by:
getOwnLoadin interfaceServiceRegistry- Returns:
- the load value for this host
-
getRegistryHostname
Description copied from interface:ServiceRegistryReturns the service regstry's hostname. This can be used to fetch the list of services on the local host.- Specified by:
getRegistryHostnamein interfaceServiceRegistry- Returns:
- The hostname that the service registry is running on.
-
deactivate
public void deactivate() -
createJob
Create and store a new job that will be dispatched as soon as possible. This is equivalent to callingServiceRegistry.createJob(String, String, List, String, boolean)with an empty argument list.Note that this job will be linked to the current job as its parent.
- Specified by:
createJobin interfaceServiceRegistry- Parameters:
type- the type of service responsible for this joboperation- the operation for this service to run- Returns:
- the job
- Throws:
ServiceRegistryException- if there is a problem creating the job- See Also:
-
createJob
public Job createJob(String type, String operation, List<String> arguments) throws ServiceRegistryException Create and store a new job that will be dispatched as soon as possible. This is equivalent to callingServiceRegistry.createJob(String, String, List, String, boolean).Note that this job will be linked to the current job as its parent.
- Specified by:
createJobin interfaceServiceRegistry- Parameters:
type- the type of service responsible for this joboperation- the operation for this service to runarguments- the arguments to the operation- Returns:
- the job
- Throws:
ServiceRegistryException- if there is a problem creating the job- See Also:
-
createJob
public Job createJob(String type, String operation, List<String> arguments, Float jobLoad) throws ServiceRegistryException Create and store a new job that will be dispatched as soon as possible. This is equivalent to callingServiceRegistry.createJob(String, String, List, String, boolean).Note that this job will be linked to the current job as its parent.
- Specified by:
createJobin interfaceServiceRegistry- Parameters:
type- the type of service responsible for this joboperation- the operation for this service to runarguments- the arguments to the operationjobLoad- the load caused by this job, roughly equivalent to the number of cores used this job- Returns:
- the job
- Throws:
ServiceRegistryException- if there is a problem creating the job- See Also:
-
createJob
public Job createJob(String type, String operation, List<String> arguments, String payload, boolean dispatchable) throws ServiceRegistryException Create and store a new job. IfenqueueImmediatelyis true, the job will be in theJob.Status.QUEUEDstate and will be dispatched as soon as possible. Otherwise, it will beJob.Status.INSTANTIATED.Note that this job will be linked to the current job as its parent.
- Specified by:
createJobin interfaceServiceRegistry- Parameters:
type- the type of service responsible for this joboperation- the operation for this service to runarguments- the arguments to the operationpayload- an optional initial payloaddispatchable- whether the job can be enqueued for dispatch. If false, the job's initial state will beJob.Status.INSTANTIATEDand will not be dispatched.- Returns:
- the job
- Throws:
ServiceRegistryException- if there is a problem creating the job- See Also:
-
createJob
public Job createJob(String type, String operation, List<String> arguments, String payload, boolean dispatchable, Float jobLoad) throws ServiceRegistryException Create and store a new job. IfenqueueImmediatelyis true, the job will be in theJob.Status.QUEUEDstate and will be dispatched as soon as possible. Otherwise, it will beJob.Status.INSTANTIATED.Note that this job will be linked to the current job as its parent.
- Specified by:
createJobin interfaceServiceRegistry- Parameters:
type- the type of service responsible for this joboperation- the operation for this service to runarguments- the arguments to the operationpayload- an optional initial payloaddispatchable- whether the job can be enqueued for dispatch. If false, the job's initial state will beJob.Status.INSTANTIATEDand will not be dispatched.jobLoad- the load caused by this job, roughly equivalent to the number of cores used this job- Returns:
- the job
- Throws:
ServiceRegistryException- if there is a problem creating the job- See Also:
-
createJob
public Job createJob(String type, String operation, List<String> arguments, String payload, boolean dispatchable, Job parentJob) throws ServiceRegistryException - Throws:
ServiceRegistryException
-
createJob
public Job createJob(String type, String operation, List<String> arguments, String payload, boolean dispatchable, Job parentJob, Float jobLoad) throws ServiceRegistryException Create and store a new job. IfenqueueImmediatelyis true, the job will be in theJob.Status.QUEUEDstate and will be dispatched as soon as possible. Otherwise, it will beJob.Status.INSTANTIATED.- Specified by:
createJobin interfaceServiceRegistry- Parameters:
type- the type of service responsible for this joboperation- the operation for this service to runarguments- the arguments to the operationpayload- an optional initial payloaddispatchable- whether the job can be enqueued for dispatch. If false, the job's initial state will beJob.Status.INSTANTIATEDand will not be dispatched.parentJob- the parent jobjobLoad- the load caused by this job, roughly equivalent to the number of cores used this job- Returns:
- the job
- Throws:
ServiceRegistryException- if there is a problem creating the job- See Also:
-
createJob
public Job createJob(String host, String serviceType, String operation, List<String> arguments, String payload, boolean dispatchable, Job parentJob) throws ServiceRegistryException Creates a job on a remote host with a jobLoad of 1.0.- Throws:
ServiceRegistryException
-
createJob
public Job createJob(String host, String serviceType, String operation, List<String> arguments, String payload, boolean dispatchable, Job parentJob, float jobLoad) throws ServiceRegistryException Creates a job on a remote host.- Throws:
ServiceRegistryException
-
removeJobs
Description copied from interface:ServiceRegistryDeletes the given jobs from the service registry- Specified by:
removeJobsin interfaceServiceRegistry- Parameters:
jobIds- the job ids- Throws:
NotFoundExceptionServiceRegistryException
-
removeParentlessJobs
Description copied from interface:ServiceRegistryRemoves all jobs which do not have a parent job (except workflow instance jobs) and which have passed their lifetime.- Specified by:
removeParentlessJobsin interfaceServiceRegistry- Parameters:
lifetime- lifetime in days- Throws:
ServiceRegistryException- if removing the jobs fails
-
updated
- Specified by:
updatedin interfaceorg.osgi.service.cm.ManagedService- Throws:
org.osgi.service.cm.ConfigurationException- See Also:
-
modified
OSGI callback when the configuration is updated. This method is only here to prevent the configuration admin service from calling the service deactivate and activate methods for a config update. It does not have to do anything as the updates are handled by updated().- Throws:
org.osgi.service.cm.ConfigurationException
-
getJob
Description copied from interface:ServiceRegistryGets a receipt by its ID, or null if not found- Specified by:
getJobin interfaceServiceRegistry- Parameters:
id- the job id- Returns:
- the job or null
- Throws:
NotFoundExceptionServiceRegistryException
-
getCurrentJob
Gets the current running job- Specified by:
getCurrentJobin interfaceServiceRegistry- Returns:
- the current job
- See Also:
-
setCurrentJob
Sets the current running job- Specified by:
setCurrentJobin interfaceServiceRegistry- Parameters:
job- the current job- See Also:
-
updateJob
Description copied from interface:ServiceRegistryUpdate the job in the database- Specified by:
updateJobin interfaceServiceRegistry- Parameters:
job-- Returns:
- the updated job
- Throws:
ServiceRegistryException- if there is a problem updating the job
-
setJobUri
-
updateInternal
Internal method to update a job, throwing unwrapped JPA exceptions.- Parameters:
job- the job to update- Returns:
- the updated job
- Throws:
NotFoundException
-
updateStatisticsJobData
public void updateStatisticsJobData() -
fetchHostRegistrationQuery
protected Function<javax.persistence.EntityManager,Optional<HostRegistrationJpaImpl>> fetchHostRegistrationQuery(String host) Fetches a host registration from persistence.- Parameters:
host- the host name- Returns:
- the host registration, or null if none exists
-
registerHost
public void registerHost(String host, String address, String nodeName, long memory, int cores, float maxLoad) throws ServiceRegistryException Registers a host as a provider of Opencast services.- Specified by:
registerHostin interfaceServiceRegistry- Parameters:
host- The base URL for this serveraddress- The IP address of this hostnodeName- Human readable description of this nodememory- The allocated memory of this hostcores- The available cores of this hostmaxLoad- the maximum load this host can support- Throws:
ServiceRegistryException- if communication with the service registry fails- See Also:
-
unregisterHost
Removes an Opencast server from service.- Specified by:
unregisterHostin interfaceServiceRegistry- Parameters:
host- The base URL for this server- Throws:
ServiceRegistryException- if communication with the service registry fails- See Also:
-
enableHost
Enable an inactive host as a provider of Opencast services.- Specified by:
enableHostin interfaceServiceRegistry- Parameters:
host- The base URL for this server- Throws:
ServiceRegistryException- if communication with the service registry failsNotFoundException- if the host does not exist- See Also:
-
disableHost
Disables a Opencast server from service.- Specified by:
disableHostin interfaceServiceRegistry- Parameters:
host- The base URL for this server- Throws:
ServiceRegistryException- if communication with the service registry failsNotFoundException- if the host does not exist- See Also:
-
registerService
public ServiceRegistration registerService(String serviceType, String baseUrl, String path) throws ServiceRegistryException Registers a host to handle a specific type of job- Specified by:
registerServicein interfaceServiceRegistry- Parameters:
serviceType- The job typebaseUrl- The base URL where the service that can handle this service type can be foundpath- The path to the service endpoint- Returns:
- the service registration
- Throws:
ServiceRegistryException- if communication with the service registry fails- See Also:
-
registerService
public ServiceRegistration registerService(String serviceType, String baseUrl, String path, boolean jobProducer) throws ServiceRegistryException Registers a host to handle a specific type of job- Specified by:
registerServicein interfaceServiceRegistry- Parameters:
serviceType- The service typebaseUrl- The base URL where the service that can handle this job type can be foundpath- The path to the service endpointjobProducer- Whether this service registration producesJobs to track long running operations- Returns:
- the service registration
- Throws:
ServiceRegistryException- if communication with the service registry fails- See Also:
-
getServiceRegistrationQuery
protected Function<javax.persistence.EntityManager,Optional<ServiceRegistrationJpaImpl>> getServiceRegistrationQuery(String serviceType, String host) -
setOnlineStatus
protected ServiceRegistration setOnlineStatus(String serviceType, String baseUrl, String path, boolean online, Boolean jobProducer) throws ServiceRegistryException Sets the online status of a service registration.- Parameters:
serviceType- The job typebaseUrl- the host URLonline- whether the service is online or offjobProducer- whether this service produces jobs for long running operations- Returns:
- the service registration
- Throws:
ServiceRegistryException
-
unRegisterService
Unregisters a host from handling a specific type of job- Specified by:
unRegisterServicein interfaceServiceRegistry- Parameters:
serviceType- The service typebaseUrl- The base URL where the service that can handle this job type can be found- Throws:
ServiceRegistryException- if communication with the service registry fails- See Also:
-
setMaintenanceStatus
Sets a registered host's maintenance status- Specified by:
setMaintenanceStatusin interfaceServiceRegistry- Parameters:
baseUrl- The base URL where the service that can handle this service type can be foundmaintenance- the new maintenance status for this service- Throws:
NotFoundException- if the host does not exist- See Also:
-
getServiceRegistrations
Finds all service registrations, including offline services and those in maintenance mode.- Specified by:
getServiceRegistrationsin interfaceServiceRegistry- Returns:
- A list of service registrations
- See Also:
-
incident
Description copied from interface:ServiceRegistryReturn a facility to record job incidents.- Specified by:
incidentin interfaceServiceRegistry- See Also:
-
getServiceRegistrationsQuery
protected Function<javax.persistence.EntityManager,List<ServiceRegistration>> getServiceRegistrationsQuery()Gets all service registrations.- Returns:
- the list of service registrations
-
getHostRegistrations
Gets all host registrations- Specified by:
getHostRegistrationsin interfaceServiceRegistry- Returns:
- the list of host registrations
-
getHostStatistics
Description copied from interface:ServiceRegistryGet statistics about jobs active on hosts.- Specified by:
getHostStatisticsin interfaceServiceRegistry- Returns:
- Host statistics
-
getHostRegistrationsQuery
protected Function<javax.persistence.EntityManager,List<HostRegistration>> getHostRegistrationsQuery()Gets all host registrations- Returns:
- the list of host registrations
-
getHostRegistration
Description copied from interface:ServiceRegistryFinds host registration for the given hostname.- Specified by:
getHostRegistrationin interfaceServiceRegistry- Parameters:
hostname- to lookup- Returns:
- host registrations
- Throws:
ServiceRegistryException- if there is a problem accessing the service registry or the hostname is not found
-
getHostRegistrationQuery
protected Function<javax.persistence.EntityManager,HostRegistration> getHostRegistrationQuery(String hostname) -
getChildJobs
Get all child jobs from a job- Specified by:
getChildJobsin interfaceServiceRegistry- Parameters:
id- the parent job id- Returns:
- a list of the child jobs ordered by execution
- Throws:
ServiceRegistryException- if there is a problem accessing the service registry- See Also:
-
getJobs
Gets the list of jobs that match the specified parameters.- Specified by:
getJobsin interfaceServiceRegistry- Parameters:
type- The jobs run by this type of service. If null, jobs from all hosts will be returned.status- The status of the jobs. If null, jobs in all status will be returned.- Returns:
- the jobs matching these criteria
- Throws:
ServiceRegistryException- if there is a problem accessing the service registry- See Also:
-
getJobPayloads
Description copied from interface:ServiceRegistryReturn the payload of all jobs for a specified operation type.- Specified by:
getJobPayloadsin interfaceServiceRegistry- Parameters:
operation- Operation type to get payload for- Returns:
- Serialized workflows
- Throws:
ServiceRegistryException- if there is a problem accessing the service registry
-
getJobPayloads
public List<String> getJobPayloads(String operation, int limit, int offset) throws ServiceRegistryException Description copied from interface:ServiceRegistryReturn the payload of a specified number of jobs for a specified operation type.- Specified by:
getJobPayloadsin interfaceServiceRegistry- Parameters:
operation- Operation type to get payload forlimit- How many results to returnoffset- Offset for the set of returned results- Returns:
- Serialized workflows
- Throws:
ServiceRegistryException- if there is a problem accessing the service registry
-
getJobCount
Description copied from interface:ServiceRegistryReturn the number of jobs for a specified operation type.- Specified by:
getJobCountin interfaceServiceRegistry- Parameters:
operation- Operation type to check for- Returns:
- Number of jobs for the specified operation type.
- Throws:
ServiceRegistryException
-
getActiveJobs
Get the list of active jobs.- Specified by:
getActiveJobsin interfaceServiceRegistry- Returns:
- list of active jobs
- Throws:
ServiceRegistryException- if there is a problem accessing the service registry- See Also:
-
getJobsByStatusQuery
public Function<javax.persistence.EntityManager,List<JpaJob>> getJobsByStatusQuery(Job.Status... statuses) Get the list of jobs with status from the given statuses.- Parameters:
statuses- variable sized array of status values to test on jobs- Returns:
- list of jobs with status from statuses
-
countActiveByOrganizationAndHost
Description copied from interface:ServiceRegistryCount active jobs and group them by organization and host.- Specified by:
countActiveByOrganizationAndHostin interfaceServiceRegistry- Returns:
- Map of organizations, hosts and the number of jobs.
-
countActiveTypeByOrganization
Description copied from interface:ServiceRegistryCount active jobs of a given operation type and group them by organization.- Specified by:
countActiveTypeByOrganizationin interfaceServiceRegistry- Returns:
- Map of organizations and the number of jobs.
-
getDispatchableJobsWithStatusQuery
protected Function<javax.persistence.EntityManager,List<JpaJob>> getDispatchableJobsWithStatusQuery(int offset, int limit, Job.Status... statuses) Gets jobs of all types that are in the given state.- Parameters:
offset- apply offset to the db query if offset > 0limit- apply limit to the db query if limit > 0statuses- the job status should be one from the given statuses- Returns:
- the list of jobs waiting for dispatch
-
count
Count the number of jobs that match the specified parameters.- Specified by:
countin interfaceServiceRegistry- Parameters:
serviceType- The jobs run by this type of service. If null, the returned count will refer to all types of jobs.status- The status of the receipts. If null, the returned count will refer to jobs in any status.- Returns:
- the number of jobs
- Throws:
ServiceRegistryException- if there is a problem accessing the service registry- See Also:
-
countByHost
public long countByHost(String serviceType, String host, Job.Status status) throws ServiceRegistryException Count the number of jobs in thisJob.Statuson this host- Specified by:
countByHostin interfaceServiceRegistry- Parameters:
serviceType- The jobs run by this type of servicehost- The server that created and will be handling the jobstatus- The status of the jobs- Returns:
- the number of jobs
- Throws:
ServiceRegistryException- if there is a problem accessing the service registry- See Also:
-
countByOperation
public long countByOperation(String serviceType, String operation, Job.Status status) throws ServiceRegistryException Count the number of jobs running the given operation in thisJob.Status.- Specified by:
countByOperationin interfaceServiceRegistry- Parameters:
serviceType- The jobs run by this type of serviceoperation- the operationstatus- The status of the jobs- Returns:
- the number of jobs
- Throws:
ServiceRegistryException- if there is a problem accessing the service registry- See Also:
-
count
public long count(String serviceType, String host, String operation, Job.Status status) throws ServiceRegistryException Count the number of jobs executing the given operation in thisJob.Statuson this host.- Specified by:
countin interfaceServiceRegistry- Parameters:
serviceType- The jobs run by this type of servicehost- The server that created and will be handling the joboperation- the operationstatus- The status of the jobs- Returns:
- the number of jobs
- Throws:
ServiceRegistryException- if there is a problem accessing the service registry- See Also:
-
getServiceStatistics
Gets performance and runtime statistics for each known service registration.- Specified by:
getServiceStatisticsin interfaceServiceRegistry- Returns:
- the service statistics
- Throws:
ServiceRegistryException- if there is a problem accessing the service registry- See Also:
-
getServiceRegistrationsByLoad
public List<ServiceRegistration> getServiceRegistrationsByLoad(String serviceType) throws ServiceRegistryException Do not look at this, it will burn your eyes! This is due to JPA's inability to do a left outer join with join conditions. Finds the service registrations for this kind of job, ordered by load (lightest to heaviest).- Specified by:
getServiceRegistrationsByLoadin interfaceServiceRegistry- Parameters:
serviceType- The type of service that must be handled by the hosts- Returns:
- A list of hosts that handle this job type, in order of their running and queued job load
- Throws:
ServiceRegistryException- if there is a problem accessing the service registry- See Also:
-
getCurrentHostLoads
Gets a map of hosts to the number of jobs currently loading that host- Specified by:
getCurrentHostLoadsin interfaceServiceRegistry- Returns:
- the map of hosts to job counts
- See Also:
-
getServiceRegistrationsByType
public List<ServiceRegistration> getServiceRegistrationsByType(String serviceType) throws ServiceRegistryException Finds the service registrations for this kind of job, including offline services and those in maintenance mode.- Specified by:
getServiceRegistrationsByTypein interfaceServiceRegistry- Parameters:
serviceType- The type of service that must be handled by the hosts- Returns:
- A list of hosts that handle this job type
- Throws:
ServiceRegistryException- if there is a problem accessing the service registry- See Also:
-
getServiceRegistrationsByHost
public List<ServiceRegistration> getServiceRegistrationsByHost(String host) throws ServiceRegistryException Finds the service registrations on the given host, including offline services and those in maintenance mode.- Specified by:
getServiceRegistrationsByHostin interfaceServiceRegistry- Parameters:
host- The host- Returns:
- A list of service registrations on a single host
- Throws:
ServiceRegistryException- if there is a problem accessing the service registry- See Also:
-
getServiceRegistration
Finds a single service registration by host and type, even if the service is offline or in maintenance mode.- Specified by:
getServiceRegistrationin interfaceServiceRegistry- Parameters:
serviceType- The type of servicehost- the base URL of the host- Returns:
- The service registration, or null
- See Also:
-
setSecurityService
Callback for setting the security service.- Parameters:
securityService- the securityService to set
-
setIncidentService
OSGi DI. -
unsetIncidentService
-
sanitize
Sets the given service to NORMAL state- Specified by:
sanitizein interfaceServiceRegistry- Parameters:
serviceType- the service typehost- the host- Throws:
NotFoundException- if the service does not exist- See Also:
-
getServiceRegistrationsWithCapacity
protected List<ServiceRegistration> getServiceRegistrationsWithCapacity(String jobType, List<ServiceRegistration> serviceRegistrations, List<HostRegistration> hostRegistrations, SystemLoad systemLoad) Returns a filtered list of service registrations, containing only those that are online, not in maintenance mode, and with a specific service type that are running on a host which is not already maxed out.- Parameters:
jobType- the job type for which the services registrations are filteredserviceRegistrations- the complete list of service registrationshostRegistrations- the complete list of available host registrationssystemLoad- the map of hosts to the number of running jobs
-
getServiceRegistrationsByLoad
protected List<ServiceRegistration> getServiceRegistrationsByLoad(String jobType, List<ServiceRegistration> serviceRegistrations, List<HostRegistration> hostRegistrations, SystemLoad systemLoad) Returns a filtered list of service registrations, containing only those that are online, not in maintenance mode, and with a specific service type, ordered by load.- Parameters:
jobType- the job type for which the services registrations are filteredserviceRegistrations- the complete list of service registrationshostRegistrations- the complete list of available host registrationssystemLoad-
-
getMaxLoads
Returns the maximum load that can be handled by the currently registered hosts. Note that this load is *not* 1-to-1 equivalent with number of jobs. A job may take up more than one load.- Specified by:
getMaxLoadsin interfaceServiceRegistry- Returns:
- the total load that can be processed concurrently
- Throws:
ServiceRegistryException- if communication with the service registry fails- See Also:
-
getMaxLoadOnNode
public SystemLoad.NodeLoad getMaxLoadOnNode(String host) throws ServiceRegistryException, NotFoundException Returns the maximum load that can be handled by a given node. Note that this load is *not* 1-to-1 equivalent with number of jobs. A job may take up more than one load.- Specified by:
getMaxLoadOnNodein interfaceServiceRegistry- Parameters:
host- The base URL for this server- Returns:
- the total load that can be processed concurrently on that node
- Throws:
ServiceRegistryException- if communication with the service registry failsNotFoundException- See Also:
-