org.jppf.client
Class AbstractJPPFClient

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

public abstract class AbstractJPPFClient
extends Object
implements ClientConnectionStatusListener

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

Field Summary
protected  List<JPPFClientConnection> allConnections
          A list of all the connections initially created.
protected  JPPFSecurityContext credentials
          Security credentials associated with the application.
protected  List<ClientListener> listeners
          List of listeners to this JPPF client.
protected  TreeMap<Integer,org.jppf.client.ClientPool> pools
          Contains all the connections pools in ascending priority order.
protected  int totalTaskCount
          Total count of the tasks submitted by this client.
protected  String uuid
          Unique universal identifier for this JPPF client.
 
Constructor Summary
protected AbstractJPPFClient()
          Initialize this client with an automatically generated application UUID.
protected AbstractJPPFClient(String uuid)
          Initialize this client with a specified application UUID.
 
Method Summary
 void addClientListener(ClientListener listener)
          Add a listener to the list of listeners to this client.
 void close()
          Close this client and release all the resources it is using.
protected  void connectionFailed(JPPFClientConnection c)
          Invoked when the status of a connection has changed to JPPFClientConnectionStatus.FAILED.
 List<String> getAllConnectionNames()
          Get the names of all the client connections handled by this JPPFClient.
 List<JPPFClientConnection> getAllConnections()
          Get all the client connections handled by this JPPFClient.
 JPPFClientConnection getClientConnection()
          Get an available connection with the highest possible priority.
 JPPFClientConnection getClientConnection(boolean oneAttempt)
          Get an available connection with the highest possible priority.
 JPPFClientConnection getClientConnection(boolean oneAttempt, boolean anyState)
          Get an available connection with the highest possible priority.
 JPPFClientConnection getClientConnection(String name)
          Get a connection given its name.
 String getUuid()
          Get the unique universal identifier for this JPPF client.
 void initCredentials()
          Initialize this client's security credentials.
protected abstract  void initPools()
          Read all client connection information from the configuration and initialize the connection pools accordingly.
 void newConnection(JPPFClientConnection c)
          Notify all listeners that a new connection was created.
 void removeClientListener(ClientListener listener)
          Remove a listener from the list of listeners to this client.
 void statusChanged(ClientConnectionStatusEvent event)
          Invoked when the status of a client connection has changed.
abstract  List<JPPFTask> submit(JPPFJob job)
          Submit a JPPFJob for execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

credentials

protected JPPFSecurityContext credentials
Security credentials associated with the application.


totalTaskCount

protected int totalTaskCount
Total count of the tasks submitted by this client.


pools

protected TreeMap<Integer,org.jppf.client.ClientPool> pools
Contains all the connections pools in ascending priority order.


uuid

protected String uuid
Unique universal identifier for this JPPF client.


allConnections

protected List<JPPFClientConnection> allConnections
A list of all the connections initially created.


listeners

protected List<ClientListener> listeners
List of listeners to this JPPF client.

Constructor Detail

AbstractJPPFClient

protected AbstractJPPFClient()
Initialize this client with an automatically generated application UUID.


AbstractJPPFClient

protected AbstractJPPFClient(String uuid)
Initialize this client with a specified application UUID.

Parameters:
uuid - the unique identifier for this local client.
Method Detail

initPools

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


getAllConnections

public List<JPPFClientConnection> getAllConnections()
Get all the client connections handled by this JPPFClient.

Returns:
a list of JPPFClientConnection instances.

getAllConnectionNames

public List<String> getAllConnectionNames()
Get the names of all the client connections handled by this JPPFClient.

Returns:
a list of connection names as strings.

getClientConnection

public JPPFClientConnection getClientConnection(String name)
Get a connection given its name.

Parameters:
name - the name of the connection to find.
Returns:
a JPPFClientConnection with the highest possible priority.

getClientConnection

public JPPFClientConnection getClientConnection()
Get an available connection with the highest possible priority.

Returns:
a JPPFClientConnection with the highest possible priority.

getClientConnection

public JPPFClientConnection getClientConnection(boolean oneAttempt)
Get an available connection with the highest possible priority.

Parameters:
oneAttempt - determines whether this method should wait until a connection becomes available (ACTIVE status) or fail immeditately if no available connection is found.
This enables the excution to be performed locally if the client is not connected to a server.
Returns:
a JPPFClientConnection with the highest possible priority.

getClientConnection

public JPPFClientConnection getClientConnection(boolean oneAttempt,
                                                boolean anyState)
Get an available connection with the highest possible priority.

Parameters:
oneAttempt - determines whether this method should wait until a connection becomes available (ACTIVE status) or fail immeditately if no available connection is found.
This enables the execution to be performed locally if the client is not connected to a server.
anyState - specifies whether this method should look for an active connection or not care about the connection state.
Returns:
a JPPFClientConnection with the highest possible priority.

initCredentials

public void initCredentials()
                     throws Exception
Initialize this client's security credentials.

Throws:
Exception - if an error is raised during initialization.

submit

public abstract List<JPPFTask> submit(JPPFJob job)
                               throws Exception
Submit a JPPFJob for execution.

Parameters:
job - the job to execute.
Returns:
the results of the tasks' execution, as a list of JPPFTask instances for a blocking job, or null if the job is non-blocking.
Throws:
Exception - if an error occurs while sending the job for execution.

statusChanged

public void statusChanged(ClientConnectionStatusEvent event)
Invoked when the status of a client connection has changed.

Specified by:
statusChanged in interface ClientConnectionStatusListener
Parameters:
event - the event to notify of.
See Also:
ClientConnectionStatusListener.statusChanged(org.jppf.client.event.ClientConnectionStatusEvent)

connectionFailed

protected void connectionFailed(JPPFClientConnection c)
Invoked when the status of a connection has changed to JPPFClientConnectionStatus.FAILED.

Parameters:
c - the connection that failed.

close

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


addClientListener

public void addClientListener(ClientListener listener)
Add a listener to the list of listeners to this client.

Parameters:
listener - the listener to add.

removeClientListener

public void removeClientListener(ClientListener listener)
Remove a listener from the list of listeners to this client.

Parameters:
listener - the listener to remove.

newConnection

public void newConnection(JPPFClientConnection c)
Notify all listeners that a new connection was created.

Parameters:
c - the connection that was created.

getUuid

public String getUuid()
Get the unique universal identifier for this JPPF client.

Returns:
the uuid as a string.


Copyright © 2005-2010 JPPF Team.