Package org.jppf.client
Class JPPFClient
java.lang.Object
org.jppf.client.AbstractJPPFClient
org.jppf.client.AbstractGenericClient
org.jppf.client.JPPFClient
- All Implemented Interfaces:
AutoCloseable,EventListener,ClientConnectionStatusListener,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
ConstructorsConstructorDescriptionInitialize this client with an automatically generated application UUID.JPPFClient(String uuid) Initialize this client with the specified application UUID.JPPFClient(String uuid, ConnectionPoolListener... listeners) Initialize this client with the specified application UUID and new connection listeners.JPPFClient(String uuid, org.jppf.utils.TypedProperties config, ConnectionPoolListener... listeners) Initialize this client with the specified application UUID and new connection listeners.JPPFClient(ConnectionPoolListener... listeners) Initialize this client with an automatically generated application UUID.JPPFClient(org.jppf.utils.TypedProperties config, ConnectionPoolListener... listeners) Initialize this client with the specified configuration and connection listeners. -
Method Summary
Modifier and TypeMethodDescriptionWait until there is at least one connection pool with at least one connection in theACTIVEstatus.awaitConnectionPool(long timeout, JPPFClientConnectionStatus... statuses) Wait until at least one connection pool with at least one connection in one of the specified statuses, or until the specified timeout to expire, whichever happens first.awaitConnectionPool(JPPFClientConnectionStatus... statuses) Wait until there is at least one connection pool with at least one connection in one of the specified statuses.awaitConnectionPools(long timeout, ConnectionPoolFilter<JPPFConnectionPool> filter) Wait until there is at least one connection pool where at least one connections passes the specified filter, or until the specified timeout expires, whichever happens first.awaitConnectionPools(long timeout, JPPFClientConnectionStatus... statuses) Wait until at least one connection pool with at least one connection in one of the specified statuses, or until the specified timeout to expire, whichever happens first.awaitConnectionPools(org.jppf.utils.ComparisonOperator operator, int expectedConnections, long timeout, JPPFClientConnectionStatus... statuses) Wait until there is at least one connection pool where the number of connections with the specified statuses satisfy the specified condition, or until the specified timeout expires, whichever happens first.awaitConnectionPools(org.jppf.utils.ComparisonOperator poolOperator, int expectedPools, org.jppf.utils.ComparisonOperator connectionOperator, int expectedConnections, long timeout, JPPFClientConnectionStatus... statuses) Wait until at least the specified expected connection pools satisfy the condition where the number of connections with the specified statuses satisfy the specified connection operator, or until the specified timeout expires, whichever happens first.awaitWorkingConnectionPools(long timeout) voidclose()Close this client and release all the resources it is using.protected JobManagerorg.jppf.load.balancer.spi.JPPFBundlerFactoryGet the factory that creates load-balancer instances.org.jppf.node.policy.ExecutionPolicyGet the default client-side job execution policy.org.jppf.node.policy.ExecutionPolicyGet the default server-side job execution policy.org.jppf.load.balancer.LoadBalancingInformationGet the current load-balancer settings.Get the list of currently queued jobs.getQueuedJobs(org.jppf.job.JobSelector selector) Get a list of currently queued jobs, filtered by aJobSelector.intGet the current number of queued jobs.intgetQueuedJobsCount(org.jppf.job.JobSelector selector) Get the current number of jobs that satisfy a job selector.intvoidremoveDriverDiscovery(org.jppf.discovery.ClientDriverDiscovery discovery) Remove a custom driver discovery mechanism from those already registered.voidreset()Reset this client, that is, close it if necessary, reload its configuration, then open it again.voidreset(org.jppf.utils.TypedProperties configuration) Reset this client, that is, close it if necessary, then open it again, using the specified confguration.voidsetDefaultClientPolicy(org.jppf.node.policy.ExecutionPolicy defaultClientPolicy) Set the default client-side job execution policy.voidsetDefaultPolicy(org.jppf.node.policy.ExecutionPolicy defaultPolicy) Set the default server-side job execution policy.voidsetLoadBalancerSettings(String algorithm, Properties parameters) Change the load balancer settings.List<org.jppf.node.protocol.Task<?>>Submit the specified job for execution and wait for its completion.submitAsync(JPPFJob job) Submit the specified job asynchronously for execution, without waiting for the job to complete.List<org.jppf.node.protocol.Task<?>>Deprecated.a job should be submittable either synchronously or asynchronously, regardless of its state.Methods inherited from class org.jppf.client.AbstractGenericClient
addClientQueueListener, addDriverDiscovery, bundleAdded, bundleRemoved, cancelJob, fireQueueEvent, getExecutor, getJobManager, getLoadBalancerPersistenceManagement, getRegisteredClassLoaders, hasAvailableConnection, init, initPools, isLocalExecutionEnabled, isSysoutEnabled, registerClassLoader, removeClientQueueListener, setLocalExecutionEnabled, statusChanged, unregisterClassLoadersMethods 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
-
JPPFClient
public JPPFClient()Initialize this client with an automatically generated application UUID. -
JPPFClient
Initialize this client with the specified application UUID.- Parameters:
uuid- the unique identifier for this local client.
-
JPPFClient
Initialize this client with an automatically generated application UUID.- Parameters:
listeners- the optional listeners to add to this JPPF client to receive notifications of new connections.
-
JPPFClient
Initialize this client with the specified application UUID and new connection listeners.- Parameters:
uuid- the unique identifier for this local client.listeners- the optional listeners to add to this JPPF client to receive notifications of new connections.
-
JPPFClient
Initialize this client with the specified configuration and connection listeners.- Parameters:
config- the JPPF configuration to use for this client.listeners- the optional listeners to add to this JPPF client to receive notifications of new connections.
-
JPPFClient
public JPPFClient(String uuid, org.jppf.utils.TypedProperties config, ConnectionPoolListener... listeners) Initialize this client with the specified application UUID and new connection listeners.- Parameters:
uuid- the unique identifier for this local client.config- the JPPF configuration to use for this client.listeners- the optional listeners to add to this JPPF client to receive notifications of new connections.
-
-
Method Details
-
submitJob
Deprecated.a job should be submittable either synchronously or asynchronously, regardless of its state. The way it is submitted is the user's choice at the time of submission, using one ofsubmit(JPPFJob)orsubmitAsync(JPPFJob).Submit the specified job for execution.- Parameters:
job- the job to submit and execute.- Returns:
- the job's results as a list of
tasksif the job isblocking, ornullif it is non-blocking.
-
submit
Submit the specified job for execution and wait for its completion.- Parameters:
job- the job to submit and execute.- Returns:
- the job's results as a list of
tasks. - Since:
- 6.1
-
submitAsync
Submit the specified job asynchronously for execution, without waiting for the job to complete.- Parameters:
job- the job to submit and execute.- Returns:
- the submitted job.
- Since:
- 6.1
-
createJobManager
-
reset
public void reset()Reset this client, that is, close it if necessary, reload its configuration, then open it again. If the client is already closed or reseeting, this method has no effect.- Since:
- 4.0
- See Also:
-
reset
public void reset(org.jppf.utils.TypedProperties configuration) Reset this client, that is, close it if necessary, then open it again, using the specified confguration. If the client is already closed or reseeting, this method has no effect.- Parameters:
configuration- the configuration to initialize this client with.- Since:
- 4.0
- See Also:
-
awaitActiveConnectionPool
Wait until there is at least one connection pool with at least one connection in theACTIVEstatus. This is a shorthand forawaitConnectionPool(Long.MAX_VALUE, JPPFClientConnectionStatus.ACTIVE).- Returns:
- a
JPPFConnectionPoolinstance, or null if no pool has a connection in one of the desired statuses. - Since:
- 5.0
-
awaitWorkingConnectionPool
Wait until there is at least one connection pool with at least one connection in theACTIVEorEXECUTINGstatus. This is a shorthand forawaitConnectionPool(Long.MAX_VALUE, JPPFClientConnectionStatus.ACTIVE, JPPFClientConnectionStatus.EXECUTING).- Returns:
- a
JPPFConnectionPoolinstance, or null if no pool has a connection in one of the desired statuses. - Since:
- 5.0
-
awaitConnectionPool
Wait until there is at least one connection pool with at least one connection in one of the specified statuses. This is a shorthand forawaitConnectionPool(Long.MAX_VALUE, statuses).- Parameters:
statuses- the possible statuses of the connections in the pools to wait for.- Returns:
- a
JPPFConnectionPoolinstance, or null if no pool has a connection in one of the desired statuses. - Since:
- 5.0
-
awaitConnectionPool
Wait until at least one connection pool with at least one connection in one of the specified statuses, or until the specified timeout to expire, whichever happens first.- Parameters:
timeout- the maximum time to wait, in milliseconds. A value of zero means an infinite timeout.statuses- the possible statuses of the connections in the pools to wait for.- Returns:
- a
JPPFConnectionPoolinstance, or null if no pool has a connection in one of the desired statuses. - Since:
- 5.0
-
awaitWorkingConnectionPools
Wait until there is at least one connection pool with at least one connection in theACTIVEorEXECUTINGstatus. This is a shorthand forawaitConnectionPools(Long.MAX_VALUE, JPPFClientConnectionStatus.ACTIVE, JPPFClientConnectionStatus.EXECUTING).- Returns:
- a list of
JPPFConnectionPoolinstances, possibly empty but never null. - Since:
- 5.1
-
awaitWorkingConnectionPools
Wait until there is at least one connection pool with at least one connection in theACTIVEorEXECUTINGstatus, or the specified tiemoput expires, whichever happens first. This is a shorthand forawaitConnectionPools(tiemout, JPPFClientConnectionStatus.ACTIVE, JPPFClientConnectionStatus.EXECUTING).- Parameters:
timeout- the maximum time to wait, in milliseconds. A value of zero means an infinite timeout.- Returns:
- a list of
JPPFConnectionPoolinstances, possibly empty but never null. - Since:
- 5.1
-
awaitConnectionPools
public List<JPPFConnectionPool> awaitConnectionPools(long timeout, JPPFClientConnectionStatus... statuses) Wait until at least one connection pool with at least one connection in one of the specified statuses, or until the specified timeout to expire, whichever happens first.- Parameters:
timeout- the maximum time to wait, in milliseconds. A value of zero means an infinite timeout.statuses- the possible statuses of the connections in the pools to wait for.- Returns:
- a list of
JPPFConnectionPoolinstances, possibly empty but never null. - Since:
- 5.0
-
awaitConnectionPools
public List<JPPFConnectionPool> awaitConnectionPools(org.jppf.utils.ComparisonOperator operator, int expectedConnections, long timeout, JPPFClientConnectionStatus... statuses) Wait until there is at least one connection pool where the number of connections with the specified statuses satisfy the specified condition, or until the specified timeout expires, whichever happens first.- Parameters:
operator- the condition on the number of connections to wait for. Ifnull, it is assumed to beOperator.EQUAL.expectedConnections- the expected number of connections to wait for.timeout- the maximum time to wait, in milliseconds. A value of zero means an infinite timeout.statuses- the possible statuses of the connections in the pools to wait for.- Returns:
- a list of
JPPFConnectionPoolinstances, possibly empty but never null. - Since:
- 5.0
-
awaitConnectionPools
public List<JPPFConnectionPool> awaitConnectionPools(org.jppf.utils.ComparisonOperator poolOperator, int expectedPools, org.jppf.utils.ComparisonOperator connectionOperator, int expectedConnections, long timeout, JPPFClientConnectionStatus... statuses) Wait until at least the specified expected connection pools satisfy the condition where the number of connections with the specified statuses satisfy the specified connection operator, or until the specified timeout expires, whichever happens first.As an example, to wait for at least 2 pools having each at least one ACTIVE connection, with a timeout of 5 seconds, one would use:
JPPFClient client = new JPPFClient(); client.awaitConnectionPools(Operator.AT_LEAST, 2, Operator.AT_LEAST, 1, 5000L, JPPFClientConnectionStatus.ACTIVE);
- Parameters:
poolOperator- the condition on the number of expected pools to wait for. Ifnull, it is assumed to beOperator.EQUAL.expectedPools- the expected number of pools to wait for.connectionOperator- the condition on the number of connections to wait for. Ifnull, it is assumed to beOperator.EQUAL.expectedConnections- the expected number of connections to wait for.timeout- the maximum time to wait, in milliseconds. A value of zero means an infinite timeout.statuses- the possible statuses of the connections in the pools to wait for.- Returns:
- a list of
JPPFConnectionPoolinstances, possibly empty but never null. - Since:
- 6.0
-
awaitConnectionPools
public List<JPPFConnectionPool> awaitConnectionPools(long timeout, ConnectionPoolFilter<JPPFConnectionPool> filter) Wait until there is at least one connection pool where at least one connections passes the specified filter, or until the specified timeout expires, whichever happens first.- Parameters:
timeout- the maximum time to wait, in milliseconds. A value of zero means an infinite timeout.filter- an implementation of theConnectionPoolFilterinterface. Anullvalue is interpreted as no filter (all pools are accepted).- Returns:
- a list of
JPPFConnectionPoolinstances, possibly empty but never null. - Since:
- 5.0
-
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 classAbstractGenericClient
-
removeDriverDiscovery
public void removeDriverDiscovery(org.jppf.discovery.ClientDriverDiscovery discovery) Remove a custom driver discovery mechanism from those already registered.- Parameters:
discovery- the driver discovery to remove.
-
getLoadBalancerSettings
public org.jppf.load.balancer.LoadBalancingInformation getLoadBalancerSettings()Get the current load-balancer settings.- Returns:
- a
LoadBalancingInformationinstance, which encapsulates a load-balancing alfgorithm name, along with its parameters. - Since:
- 5.2.7
-
setLoadBalancerSettings
Change the load balancer settings.- 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.- Since:
- 5.2.7
-
getBundlerFactory
public org.jppf.load.balancer.spi.JPPFBundlerFactory getBundlerFactory()Get the factory that creates load-balancer instances.- Returns:
- an istance of
JPPFBundlerFactory.
-
nbIdleCOnnections
public int nbIdleCOnnections()- Returns:
- the number of idle connections in this client.
-
getDefaultPolicy
public org.jppf.node.policy.ExecutionPolicy getDefaultPolicy()Get the default server-side job execution policy.- Returns:
- an
ExecutionPolicy, ornullif none was specified.
-
setDefaultPolicy
public void setDefaultPolicy(org.jppf.node.policy.ExecutionPolicy defaultPolicy) Set the default server-side job execution policy.- Parameters:
defaultPolicy- the execution policy to set as default, may benull.
-
getDefaultClientPolicy
public org.jppf.node.policy.ExecutionPolicy getDefaultClientPolicy()Get the default client-side job execution policy.- Returns:
- an
ExecutionPolicy, ornullif none was specified.
-
setDefaultClientPolicy
public void setDefaultClientPolicy(org.jppf.node.policy.ExecutionPolicy defaultClientPolicy) Set the default client-side job execution policy.- Parameters:
defaultClientPolicy- the execution policy to set as default, may benull.
-
getQueuedJobs
Get the list of currently queued jobs.- Returns:
- a list of
JPPFJobinstances, possibly empty.
-
getQueuedJobs
Get a list of currently queued jobs, filtered by aJobSelector.- Parameters:
selector- a job filter to apply. May benull, in which case all queued jobs are returned.- Returns:
- a list of
JPPFJobinstances that satisfy the provided job selector, possibly empty.
-
getQueuedJobsCount
public int getQueuedJobsCount()Get the current number of queued jobs.- Returns:
- the current queued jobs count as an
int.
-
getQueuedJobsCount
public int getQueuedJobsCount(org.jppf.job.JobSelector selector) Get the current number of jobs that satisfy a job selector.- Parameters:
selector- a job filter to apply. May benull, in which case the count of all queued jobs is returned.- Returns:
- the number of queued jobs that satisfy the filter.
-