Package org.jppf.client.balancer
Class JobManagerClient
java.lang.Object
org.jppf.utils.concurrent.ThreadSynchronization
org.jppf.client.balancer.JobManagerClient
- All Implemented Interfaces:
JobManager
public class JobManagerClient
extends org.jppf.utils.concurrent.ThreadSynchronization
implements JobManager
This task provides asynchronous management of tasks submitted through the resource adapter.
It relies on a queue where job are first added, then submitted when a connection becomes available.
It also provides methods to check the status of a job and retrieve the results.
- Author:
- Laurent Cohen, Martin JANDA
-
Field Summary
Fields inherited from class org.jppf.utils.concurrent.ThreadSynchronization
stopped -
Constructor Summary
ConstructorsConstructorDescriptionJobManagerClient(JPPFClient client, org.jppf.load.balancer.spi.JPPFBundlerFactory bundlerFactory) Instantiates client job manager. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddConnection(ChannelWrapper wrapper) Add the specified connection wrapper to the list of connections handled by this manager.Add the specified client connection to the list of connections handled by this manager.booleanCancel the job with the specified id.voidclose()Close this job manager and all the resources it uses.Get all the client connections handled by this manager.Get the list of available connections.Get a listener to the status of the managed connections.org.jppf.load.balancer.LoadBalancingInformationGet the current load-balancer settings.getQueue()Get all the client connections with a working status.Get all the client connections with a working status, excluding the local executor if it is enabled.booleanDetermine whether there is a client connection available for execution.booleanDetermine whether there is at least one working connection, idle or not.booleanDetermine whether local execution is enabled on this client.intGet the number of connections available for job scheduling.protected voidremoveConnection(ChannelWrapper wrapper) Remove the specified connection wrapper from the list of connections handled by this manager.protected ChannelWrapperremoveConnection(JPPFClientConnection connection) Remove the specified client connection from the list of connections handled by this manager.voidreset()Reset this job manager.resubmitJob(JPPFJob job) Add an existing job back into the execution queue.voidsetLoadBalancerSettings(String algorithm, Properties parameters) Change the load balancer settings for the client.voidsetLocalExecutionEnabled(boolean localExecutionEnabled) Specify whether local execution is enabled on this client.Add a job to the execution queue.submitJob(JPPFJob job, JobStatusListener listener) Add a task job to the execution queue.Methods inherited from class org.jppf.utils.concurrent.ThreadSynchronization
goToSleep, goToSleep, goToSleep, isStopped, setStopped, wakeUp
-
Constructor Details
-
JobManagerClient
public JobManagerClient(JPPFClient client, org.jppf.load.balancer.spi.JPPFBundlerFactory bundlerFactory) throws Exception Instantiates client job manager.- Parameters:
client- JPPF client that manages connections to the JPPF drivers.bundlerFactory- the factory that creates load-balancer instances.- Throws:
Exception- if any error occurs.
-
-
Method Details
-
addConnection
Add the specified connection wrapper to the list of connections handled by this manager.- Parameters:
wrapper- the connection wrapper to add.
-
removeConnection
Remove the specified connection wrapper from the list of connections handled by this manager.- Parameters:
wrapper- the connection wrapper to remove.
-
addConnection
Add the specified client connection to the list of connections handled by this manager.- Parameters:
cnn- the client connection to add.- Returns:
- wrapper for the added client connection.
-
removeConnection
Remove the specified client connection from the list of connections handled by this manager.- Parameters:
connection- the client connection to remove.- Returns:
- wrapper for the removed client connection or null.
-
getAllConnections
Get all the client connections handled by this manager.- Returns:
- a list of
ChannelWrapperinstances.
-
getWorkingConnections
Get all the client connections with a working status.- Returns:
- a list of
ChannelWrapperinstances.
-
getWorkingRemoteConnections
Get all the client connections with a working status, excluding the local executor if it is enabled.- Returns:
- a list of
ChannelWrapperinstances.
-
hasWorkingConnection
public boolean hasWorkingConnection()Determine whether there is at least one working connection, idle or not.- Returns:
trueif there is at least one connection,falseotherwise.
-
submitJob
Description copied from interface:JobManagerAdd a job to the execution queue.- Specified by:
submitJobin interfaceJobManager- Parameters:
job- encapsulation of the execution data.- Returns:
- the unique id of the job.
-
submitJob
Description copied from interface:JobManagerAdd a task job to the execution queue.- Specified by:
submitJobin interfaceJobManager- Parameters:
job- encapsulation of the execution data.listener- an optional listener to receive job status change notifications, may be null.- Returns:
- the unique id of the job.
-
resubmitJob
Description copied from interface:JobManagerAdd an existing job back into the execution queue.- Specified by:
resubmitJobin interfaceJobManager- Parameters:
job- encapsulation of the execution data.- Returns:
- the unique id of the job.
-
cancelJob
Description copied from interface:JobManagerCancel the job with the specified id.- Specified by:
cancelJobin interfaceJobManager- Parameters:
jobId- the id of the job to cancel.- Returns:
- a
truewhen cancel was successfulfalseotherwise. - Throws:
Exception- if any error occurs.
-
hasAvailableConnection
public boolean hasAvailableConnection()Description copied from interface:JobManagerDetermine whether there is a client connection available for execution.- Specified by:
hasAvailableConnectionin interfaceJobManager- Returns:
- true if at least one connection is available, false otherwise.
-
isLocalExecutionEnabled
public boolean isLocalExecutionEnabled()Description copied from interface:JobManagerDetermine whether local execution is enabled on this client.- Specified by:
isLocalExecutionEnabledin interfaceJobManager- Returns:
trueif local execution is enabled,falseotherwise.
-
setLocalExecutionEnabled
public void setLocalExecutionEnabled(boolean localExecutionEnabled) Description copied from interface:JobManagerSpecify whether local execution is enabled on this client.- Specified by:
setLocalExecutionEnabledin interfaceJobManager- Parameters:
localExecutionEnabled-trueto enable local execution,falseotherwise
-
nbAvailableConnections
public int nbAvailableConnections()Get the number of connections available for job scheduling.- Returns:
- the number of available connections.
-
getAvailableConnections
Description copied from interface:JobManagerGet the list of available connections.- Specified by:
getAvailableConnectionsin interfaceJobManager- Returns:
- a vector of connections instances.
-
getClientConnectionStatusListener
Description copied from interface:JobManagerGet a listener to the status of the managed connections.- Specified by:
getClientConnectionStatusListenerin interfaceJobManager- Returns:
- a
ClientConnectionStatusListenerinstance.
-
reset
public void reset()Description copied from interface:JobManagerReset this job manager.- Specified by:
resetin interfaceJobManager
-
close
public void close()Description copied from interface:JobManagerClose this job manager and all the resources it uses.- Specified by:
closein interfaceJobManager
-
getLoadBalancerSettings
public org.jppf.load.balancer.LoadBalancingInformation getLoadBalancerSettings()Description copied from interface:JobManagerGet the current load-balancer settings.- Specified by:
getLoadBalancerSettingsin interfaceJobManager- Returns:
- a
LoadBalancingInformationinstance, which encapsulates a load-balancing alfgorithm name, along with its parameters.
-
setLoadBalancerSettings
Description copied from interface:JobManagerChange the load balancer settings for the client.- Specified by:
setLoadBalancerSettingsin interfaceJobManager- Parameters:
algorithm- the name of load-balancing alogrithm to use.parameters- the algorithm's parameters, if any. The parmeter names are assumed no to be prefixed.- Throws:
Exception- if any error occurs or if the algorithm name isnullor not known.
-
getJobScheduler
- Returns:
- the job scheuler.
-
getQueue
- Returns:
- the job queue.
-