Package org.jppf.client
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.
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
-
Field Summary
Fields inherited from class org.jppf.client.AbstractJPPFClient
config, JCA_SERIALIZATION_HELPER -
Constructor Summary
ConstructorsConstructorDescriptionAbstractGenericClient(String uuid, org.jppf.utils.TypedProperties configuration, ConnectionPoolListener... listeners) Initialize this client with a specified application UUID. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddClientQueueListener(ClientQueueListener listener) Register the specified listener to receive client queue event notifications.voidaddDriverDiscovery(org.jppf.discovery.ClientDriverDiscovery discovery) Add a custom driver discovery mechanism to those already registered, if any.voidbundleAdded(org.jppf.queue.QueueEvent<ClientJob, ClientJob, ClientTaskBundle> event) voidbundleRemoved(org.jppf.queue.QueueEvent<ClientJob, ClientJob, ClientTaskBundle> event) booleanCancel the job with the specified id.voidclose()Close this client and release all the resources it is using.protected voidfireQueueEvent(org.jppf.queue.QueueEvent<ClientJob, ClientJob, ClientTaskBundle> qEvent, boolean jobAdded) Notify all client queue listeners that a queue event has occurred.Get the pool of threads used for submitting execution requests.Get the job manager for this JPPF client.org.jppf.load.balancer.persistence.LoadBalancerPersistenceManagementGet the object that manages the persisted states of the load-balancers.Get a class loader associated with a job.booleanDetermine whether there is a client connection available for execution.protected voidinit(org.jppf.utils.TypedProperties configuration) Initialize this client with the specified configuration.protected voidinitPools(org.jppf.utils.TypedProperties config) booleanDetermine whether local execution is enabled on this client.booleanDetermine whether the client should print connection events to stdout.registerClassLoader(ClassLoader cl, String uuid) Register a class loader for the specified job uuid.voidremoveClientQueueListener(ClientQueueListener listener) Unregister the specified listener.voidsetLocalExecutionEnabled(boolean localExecutionEnabled) Specify whether local execution is enabled on this client.voidInvoked when the status of a client connection has changed.voidunregisterClassLoaders(String uuid) Unregisters the class loader associated with the specified job uuid.Methods inherited from class org.jppf.client.AbstractJPPFClient
addConnectionPoolListener, findConnectionPool, findConnectionPool, findConnectionPool, findConnectionPools, findConnectionPools, findConnectionPools, getAllConnectionsCount, getClientConnection, getConfig, getConnectionPool, getConnectionPools, getConnectionPools, getPoolPriorities, getSerializationHelperClassName, getUuid, isClosed, isResetting, removeConnectionPoolListener
-
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:AbstractJPPFClientClose this client and release all the resources it is using.- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classAbstractJPPFClient
-
isLocalExecutionEnabled
public boolean isLocalExecutionEnabled()Determine whether local execution is enabled on this client.- Returns:
trueif local execution is enabled,falseotherwise.
-
setLocalExecutionEnabled
public void setLocalExecutionEnabled(boolean localExecutionEnabled) Specify whether local execution is enabled on this client.- Parameters:
localExecutionEnabled-trueto enable local execution,falseotherwise
-
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
Description copied from class:AbstractJPPFClientInvoked when the status of a client connection has changed.- Specified by:
statusChangedin interfaceClientConnectionStatusListener- Overrides:
statusChangedin classAbstractJPPFClient- Parameters:
event- the event to notify of.
-
getExecutor
Get the pool of threads used for submitting execution requests.- Returns:
- a
ThreadPoolExecutorinstance.
-
getJobManager
Get the job manager for this JPPF client.- Returns:
- a
JobManagerinstance.
-
cancelJob
Cancel the job with the specified id.- Parameters:
jobId- the id of the job to cancel.- Returns:
- a
truewhen cancel was successful,falseotherwise. - Throws:
Exception- if any error occurs.- See Also:
-
DriverJobManagementMBean.cancelJob(java.lang.String)
-
getRegisteredClassLoaders
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
CollectionofRegisteredClassLoaderinstances.
-
registerClassLoader
Register a class loader for the specified job uuid.- Parameters:
cl- theClassLoaderinstance to register.uuid- the uuid of the job for which the class loader is registered.- Returns:
- a
RegisteredClassLoaderinstance.
-
unregisterClassLoaders
Unregisters the class loader associated with the specified job uuid.- Parameters:
uuid- the uuid of the job the class loaders are associated with.
-
addClientQueueListener
Register the specified listener to receive client queue event notifications.- Parameters:
listener- the listener to register.- Since:
- 4.1
-
removeClientQueueListener
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-truefor a job added event,falsefor a job removed event.
-
bundleAdded
- Specified by:
bundleAddedin interfaceorg.jppf.queue.QueueListener<ClientJob,ClientJob, ClientTaskBundle>
-
bundleRemoved
- Specified by:
bundleRemovedin interfaceorg.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:
trueif the client should print ot the console,falseotherwise.
-