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
  • 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

      protected void addConnection(ChannelWrapper wrapper)
      Add the specified connection wrapper to the list of connections handled by this manager.
      Parameters:
      wrapper - the connection wrapper to add.
    • removeConnection

      protected void removeConnection(ChannelWrapper wrapper)
      Remove the specified connection wrapper from the list of connections handled by this manager.
      Parameters:
      wrapper - the connection wrapper to remove.
    • addConnection

      public ChannelWrapper addConnection(JPPFClientConnection cnn)
      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

      protected ChannelWrapper removeConnection(JPPFClientConnection connection)
      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

      public List<ChannelWrapper> getAllConnections()
      Get all the client connections handled by this manager.
      Returns:
      a list of ChannelWrapper instances.
    • getWorkingConnections

      public List<ChannelWrapper> getWorkingConnections()
      Get all the client connections with a working status.
      Returns:
      a list of ChannelWrapper instances.
    • getWorkingRemoteConnections

      public List<ChannelWrapper> getWorkingRemoteConnections()
      Get all the client connections with a working status, excluding the local executor if it is enabled.
      Returns:
      a list of ChannelWrapper instances.
    • hasWorkingConnection

      public boolean hasWorkingConnection()
      Determine whether there is at least one working connection, idle or not.
      Returns:
      true if there is at least one connection, false otherwise.
    • submitJob

      public String submitJob(JPPFJob job)
      Description copied from interface: JobManager
      Add a job to the execution queue.
      Specified by:
      submitJob in interface JobManager
      Parameters:
      job - encapsulation of the execution data.
      Returns:
      the unique id of the job.
    • submitJob

      public String submitJob(JPPFJob job, JobStatusListener listener)
      Description copied from interface: JobManager
      Add a task job to the execution queue.
      Specified by:
      submitJob in interface JobManager
      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

      public String resubmitJob(JPPFJob job)
      Description copied from interface: JobManager
      Add an existing job back into the execution queue.
      Specified by:
      resubmitJob in interface JobManager
      Parameters:
      job - encapsulation of the execution data.
      Returns:
      the unique id of the job.
    • cancelJob

      public boolean cancelJob(String jobId) throws Exception
      Description copied from interface: JobManager
      Cancel the job with the specified id.
      Specified by:
      cancelJob in interface JobManager
      Parameters:
      jobId - the id of the job to cancel.
      Returns:
      a true when cancel was successful false otherwise.
      Throws:
      Exception - if any error occurs.
    • hasAvailableConnection

      public boolean hasAvailableConnection()
      Description copied from interface: JobManager
      Determine whether there is a client connection available for execution.
      Specified by:
      hasAvailableConnection in interface JobManager
      Returns:
      true if at least one connection is available, false otherwise.
    • isLocalExecutionEnabled

      public boolean isLocalExecutionEnabled()
      Description copied from interface: JobManager
      Determine whether local execution is enabled on this client.
      Specified by:
      isLocalExecutionEnabled in interface JobManager
      Returns:
      true if local execution is enabled, false otherwise.
    • setLocalExecutionEnabled

      public void setLocalExecutionEnabled(boolean localExecutionEnabled)
      Description copied from interface: JobManager
      Specify whether local execution is enabled on this client.
      Specified by:
      setLocalExecutionEnabled in interface JobManager
      Parameters:
      localExecutionEnabled - true to enable local execution, false otherwise
    • nbAvailableConnections

      public int nbAvailableConnections()
      Get the number of connections available for job scheduling.
      Returns:
      the number of available connections.
    • getAvailableConnections

      public Vector<JPPFClientConnection> getAvailableConnections()
      Description copied from interface: JobManager
      Get the list of available connections.
      Specified by:
      getAvailableConnections in interface JobManager
      Returns:
      a vector of connections instances.
    • getClientConnectionStatusListener

      public ClientConnectionStatusListener getClientConnectionStatusListener()
      Description copied from interface: JobManager
      Get a listener to the status of the managed connections.
      Specified by:
      getClientConnectionStatusListener in interface JobManager
      Returns:
      a ClientConnectionStatusListener instance.
    • reset

      public void reset()
      Description copied from interface: JobManager
      Reset this job manager.
      Specified by:
      reset in interface JobManager
    • close

      public void close()
      Description copied from interface: JobManager
      Close this job manager and all the resources it uses.
      Specified by:
      close in interface JobManager
    • getLoadBalancerSettings

      public org.jppf.load.balancer.LoadBalancingInformation getLoadBalancerSettings()
      Description copied from interface: JobManager
      Get the current load-balancer settings.
      Specified by:
      getLoadBalancerSettings in interface JobManager
      Returns:
      a LoadBalancingInformation instance, which encapsulates a load-balancing alfgorithm name, along with its parameters.
    • setLoadBalancerSettings

      public void setLoadBalancerSettings(String algorithm, Properties parameters) throws Exception
      Description copied from interface: JobManager
      Change the load balancer settings for the client.
      Specified by:
      setLoadBalancerSettings in interface JobManager
      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 is null or not known.
    • getJobScheduler

      public JobScheduler getJobScheduler()
      Returns:
      the job scheuler.
    • getQueue

      public JPPFPriorityQueue getQueue()
      Returns:
      the job queue.