org.jppf.client
Class AbstractGenericClient

java.lang.Object
  extended by org.jppf.client.AbstractJPPFClient
      extended by org.jppf.client.AbstractGenericClient
All Implemented Interfaces:
EventListener, ClientConnectionStatusListener
Direct Known Subclasses:
JPPFClient, JPPFJcaClient

public abstract class AbstractGenericClient
extends AbstractJPPFClient

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

Nested Class Summary
protected static class AbstractGenericClient.ConnectionInitializer
          Wrapper class for the initialization of a client connection.
 
Field Summary
protected  Vector<JPPFClientConnection> availableConnections
          Keeps a list of the valid connections not currently executring tasks.
protected  TypedProperties config
          The JPPF configuration properties.
protected  ThreadPoolExecutor executor
          The pool of threads used for submitting execution requests.
protected  LoadBalancer loadBalancer
          The load balancer for local versus remote execution.
protected  org.jppf.client.JPPFMulticastReceiverThread receiverThread
          Performs server discovery.
 
Fields inherited from class org.jppf.client.AbstractJPPFClient
allConnections, credentials, listeners, pools, totalTaskCount, uuid
 
Constructor Summary
AbstractGenericClient(Object configuration)
          Initialize this client with an automatically generated application UUID.
AbstractGenericClient(String uuid, Object configuration)
          Initialize this client with a specified application UUID.
 
Method Summary
 void addRequestClassLoader(String uuid, ClassLoader cl)
          Add a request uuid to class loader mapping to this submission manager.
 void close()
          Close this client and release all the resources it is using.
protected abstract  AbstractJPPFClientConnection createConnection(String uuid, String name, JPPFConnectionInformation info)
          Create a new driver connection based on the specified parameters.
 Vector<JPPFClientConnection> getAvailableConnections()
          Get the list of available connections.
 TypedProperties getConfig()
          Get the JPPF configuration properties.
 ThreadPoolExecutor getExecutor()
          Get the pool of threads used for submitting execution requests.
 LoadBalancer getLoadBalancer()
          Get the load balancer for local versus remote execution.
 ClassLoader getRequestClassLoader(String uuid)
          Get a class loader from its request uuid.
 Pair<Boolean,Boolean> handleAvailableConnection()
          Determine whether there is a client connection available for execution.
 boolean handleAvailableConnection2()
          Determine whether there is a client connection available for execution.
 boolean hasAvailableConnection()
          Determine whether there is a client connection available for execution.
protected abstract  void initConfig(Object configuration)
          Initialize this client's configuration.
protected  void initPools()
          Read all client connection information from the configuration and initialize the connection pools accordingly.
 boolean isLocalExecutionEnabled()
          Determine whether local execution is enabled on this client.
 void newConnection(JPPFClientConnection c)
          Invoked when a new connection is created.
 void removeRequestClassLoader(String uuid)
          Add a request uuid to class loader mapping to this submission manager.
 void setLocalExecutionEnabled(boolean localExecutionEnabled)
          Specifiy whether local execution is enabled on this client.
 void statusChanged(ClientConnectionStatusEvent event)
          Invoked when the status of a client connection has changed.
 
Methods inherited from class org.jppf.client.AbstractJPPFClient
addClientListener, connectionFailed, getAllConnectionNames, getAllConnections, getClientConnection, getClientConnection, getClientConnection, getClientConnection, getUuid, initCredentials, removeClientListener, submit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

executor

protected ThreadPoolExecutor executor
The pool of threads used for submitting execution requests.


config

protected TypedProperties config
The JPPF configuration properties.


receiverThread

protected org.jppf.client.JPPFMulticastReceiverThread receiverThread
Performs server discovery.


loadBalancer

protected LoadBalancer loadBalancer
The load balancer for local versus remote execution.


availableConnections

protected Vector<JPPFClientConnection> availableConnections
Keeps a list of the valid connections not currently executring tasks.

Constructor Detail

AbstractGenericClient

public AbstractGenericClient(Object configuration)
Initialize this client with an automatically generated application UUID.

Parameters:
configuration - the object holding the JPPF configuration.

AbstractGenericClient

public AbstractGenericClient(String uuid,
                             Object configuration)
Initialize this client with a specified application UUID.

Parameters:
uuid - the unique identifier for this local client.
configuration - the object holding the JPPF configuration.
Method Detail

initConfig

protected abstract void initConfig(Object configuration)
Initialize this client's configuration.

Parameters:
configuration - an object holding the JPPF configuration.

initPools

protected void initPools()
Read all client connection information from the configuration and initialize the connection pools accordingly.

Specified by:
initPools in class AbstractJPPFClient

createConnection

protected abstract AbstractJPPFClientConnection createConnection(String uuid,
                                                                 String name,
                                                                 JPPFConnectionInformation info)
Create a new driver connection based on the specified parameters.

Parameters:
uuid - the uuid of the JPPF client.
name - the name of the connection.
info - the driver connection information.
Returns:
an instance of a subclass of AbstractJPPFClientConnection.

newConnection

public void newConnection(JPPFClientConnection c)
Invoked when a new connection is created.

Overrides:
newConnection in class AbstractJPPFClient
Parameters:
c - the connection that failed.
See Also:
AbstractJPPFClient.newConnection(org.jppf.client.JPPFClientConnection)

close

public void close()
Close this client and release all the resources it is using.

Overrides:
close in class AbstractJPPFClient

getLoadBalancer

public LoadBalancer getLoadBalancer()
Get the load balancer for local versus remote execution.

Returns:
a LoadBalancer instance.

getConfig

public TypedProperties getConfig()
Get the JPPF configuration properties.

Returns:
the configurationa as a TypedProperties instance.

addRequestClassLoader

public void addRequestClassLoader(String uuid,
                                  ClassLoader cl)
Add a request uuid to class loader mapping to this submission manager.

Parameters:
uuid - the uuid of the request.
cl - the class loader for the request.

removeRequestClassLoader

public void removeRequestClassLoader(String uuid)
Add a request uuid to class loader mapping to this submission manager.

Parameters:
uuid - the uuid of the request.

getRequestClassLoader

public ClassLoader getRequestClassLoader(String uuid)
Get a class loader from its request uuid.

Parameters:
uuid - the uuid of the request.
Returns:
a ClassLoader instance, or null if none exists for the key.

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)
Specifiy 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.

handleAvailableConnection

public Pair<Boolean,Boolean> handleAvailableConnection()
Determine whether there is a client connection available for execution.

Returns:
true if at least one connection is available, false otherwise.

handleAvailableConnection2

public boolean handleAvailableConnection2()
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)
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.
See Also:
ClientConnectionStatusListener.statusChanged(org.jppf.client.event.ClientConnectionStatusEvent)

getAvailableConnections

public Vector<JPPFClientConnection> getAvailableConnections()
Get the list of available connections.

Returns:
a vector of connections instances.

getExecutor

public ThreadPoolExecutor getExecutor()
Get the pool of threads used for submitting execution requests.

Returns:
a ThreadPoolExecutor instance.


Copyright © 2005-2010 JPPF Team.