Class AbstractGenericClient

java.lang.Object
org.jppf.client.AbstractJPPFClient
org.jppf.client.AbstractGenericClient
All Implemented Interfaces:
AutoCloseable, EventListener, ClientConnectionStatusListener, org.jppf.queue.QueueListener<ClientJob,ClientJob,ClientTaskBundle>
Direct Known Subclasses:
JPPFClient

public abstract class AbstractGenericClient extends AbstractJPPFClient implements org.jppf.queue.QueueListener<ClientJob,ClientJob,ClientTaskBundle>
This class provides an API to submit execution requests and administration commands, and request server information data.
It has its own unique identifier, used by the nodes, to determine whether classes from the submitting application should be dynamically reloaded or not, depending on whether the uuid has changed or not.
Author:
Laurent Cohen
  • Constructor Details

    • AbstractGenericClient

      public AbstractGenericClient(String uuid, org.jppf.utils.TypedProperties configuration, ConnectionPoolListener... listeners)
      Initialize this client with a specified application UUID.
      Parameters:
      uuid - the unique identifier for this local client.
      configuration - the object holding the JPPF configuration.
      listeners - the listeners to add to this JPPF client to receive notifications of new connections.
  • Method Details

    • init

      protected void init(org.jppf.utils.TypedProperties configuration)
      Initialize this client with the specified configuration.
      Parameters:
      configuration - the configuration to use with this client.
    • initPools

      protected void initPools(org.jppf.utils.TypedProperties config)
    • close

      public void close()
      Description copied from class: AbstractJPPFClient
      Close this client and release all the resources it is using.
      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class AbstractJPPFClient
    • isLocalExecutionEnabled

      public boolean isLocalExecutionEnabled()
      Determine whether local execution is enabled on this client.
      Returns:
      true if local execution is enabled, false otherwise.
    • setLocalExecutionEnabled

      public void setLocalExecutionEnabled(boolean localExecutionEnabled)
      Specify whether local execution is enabled on this client.
      Parameters:
      localExecutionEnabled - true to enable local execution, false otherwise
    • hasAvailableConnection

      public boolean hasAvailableConnection()
      Determine whether there is a client connection available for execution.
      Returns:
      true if at least one connection is available, false otherwise.
    • statusChanged

      public void statusChanged(ClientConnectionStatusEvent event)
      Description copied from class: AbstractJPPFClient
      Invoked when the status of a client connection has changed.
      Specified by:
      statusChanged in interface ClientConnectionStatusListener
      Overrides:
      statusChanged in class AbstractJPPFClient
      Parameters:
      event - the event to notify of.
    • getExecutor

      public ThreadPoolExecutor getExecutor()
      Get the pool of threads used for submitting execution requests.
      Returns:
      a ThreadPoolExecutor instance.
    • getJobManager

      public JobManager getJobManager()
      Get the job manager for this JPPF client.
      Returns:
      a JobManager instance.
    • cancelJob

      public boolean cancelJob(String jobId) throws Exception
      Cancel the job with the specified id.
      Parameters:
      jobId - the id of the job to cancel.
      Returns:
      a true when cancel was successful, false otherwise.
      Throws:
      Exception - if any error occurs.
      See Also:
      • DriverJobManagementMBean.cancelJob(java.lang.String)
    • getRegisteredClassLoaders

      public Collection<ClassLoader> getRegisteredClassLoaders(String uuid)
      Get a class loader associated with a job.
      Parameters:
      uuid - unique id assigned to classLoader. Added as temporary fix for problems hanging jobs.
      Returns:
      a Collection of RegisteredClassLoader instances.
    • registerClassLoader

      public ClassLoader registerClassLoader(ClassLoader cl, String uuid)
      Register a class loader for the specified job uuid.
      Parameters:
      cl - the ClassLoader instance to register.
      uuid - the uuid of the job for which the class loader is registered.
      Returns:
      a RegisteredClassLoader instance.
    • unregisterClassLoaders

      public void unregisterClassLoaders(String uuid)
      Unregisters the class loader associated with the specified job uuid.
      Parameters:
      uuid - the uuid of the job the class loaders are associated with.
    • addClientQueueListener

      public void addClientQueueListener(ClientQueueListener listener)
      Register the specified listener to receive client queue event notifications.
      Parameters:
      listener - the listener to register.
      Since:
      4.1
    • removeClientQueueListener

      public void removeClientQueueListener(ClientQueueListener listener)
      Unregister the specified listener.
      Parameters:
      listener - the listener to unregister.
      Since:
      4.1
    • fireQueueEvent

      protected void fireQueueEvent(org.jppf.queue.QueueEvent<ClientJob,ClientJob,ClientTaskBundle> qEvent, boolean jobAdded)
      Notify all client queue listeners that a queue event has occurred.
      Parameters:
      qEvent - the actual event which occurred in the queue.
      jobAdded - true for a job added event, false for a job removed event.
    • bundleAdded

      public void bundleAdded(org.jppf.queue.QueueEvent<ClientJob,ClientJob,ClientTaskBundle> event)
      Specified by:
      bundleAdded in interface org.jppf.queue.QueueListener<ClientJob,ClientJob,ClientTaskBundle>
    • bundleRemoved

      public void bundleRemoved(org.jppf.queue.QueueEvent<ClientJob,ClientJob,ClientTaskBundle> event)
      Specified by:
      bundleRemoved in interface org.jppf.queue.QueueListener<ClientJob,ClientJob,ClientTaskBundle>
    • getLoadBalancerPersistenceManagement

      public org.jppf.load.balancer.persistence.LoadBalancerPersistenceManagement getLoadBalancerPersistenceManagement()
      Get the object that manages the persisted states of the load-balancers.
      Returns:
      an instance of LoadBalancerPersistenceManagement.
      Since:
      6.0
    • addDriverDiscovery

      public void addDriverDiscovery(org.jppf.discovery.ClientDriverDiscovery discovery)
      Add a custom driver discovery mechanism to those already registered, if any.
      Parameters:
      discovery - the driver discovery to add.
    • isSysoutEnabled

      public boolean isSysoutEnabled()
      Determine whether the client should print connection events to stdout.
      Returns:
      true if the client should print ot the console, false otherwise.