com.neeve.client
Class Client<T extends ClientConnectionPool>

java.lang.Object
  extended by com.neeve.root.RootObject
      extended by com.neeve.client.Client<T>

public abstract class Client<T extends ClientConnectionPool>
extends RootObject

Represents an X Platform client.

This class serves as the base class for X Platform clients. The core functionality implemented by this class is reliable, fault tolerant and load balanced communication with a server cluster using a pooled set of connections.

Threading:
Prior to opening (i.e. in Client.State.INIT state), a client is not safe for concurrent access by multiple threads. Subsequent to open, it is safe for concurrent access provided the contained connection pool and the concrete client implementation are safe for concurrent thread access.

Nested Class Summary
static class Client.State
          Enumerates a client's states.
 
Method Summary
 void close()
          Close a client.
 T createConnection()
          Create a nameless client connection for use with a client.
 T createConnection(String name)
          Create a client connection for use with a client.
 void flush(ILnkPeerEndpoint.FlushContext flushContext)
          Flush outbound messages buffered by a client's connection pool.
 ClientConnectionPool getConnectionPool()
          Get a client's connection pool.
 String getName()
          Get a client's name.
 Client.State getState()
          Get a client's state
 String getType()
          Get a client's type.
 void open()
          Open a client.
 Client setConnectionPool(ClientConnectionPool pool)
          Set a client's connection pool.
 
Methods inherited from class com.neeve.root.RootObject
getChecked, getThreaded, getTracer, setChecked, setTracer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getType

public final String getType()
Get a client's type.

The client type is a string describing the type of the concrete client implementation.


getName

public final String getName()
Get a client's name.


getState

public final Client.State getState()
Get a client's state


setConnectionPool

public final Client setConnectionPool(ClientConnectionPool pool)
Set a client's connection pool.

A client's connection pool can only be set before the client is opened.


getConnectionPool

public final ClientConnectionPool getConnectionPool()
Get a client's connection pool.

This method can be invoked at any time during a client's lifetime.


createConnection

public final T createConnection(String name)
Create a client connection for use with a client.

Parameters:
name - The name to be associated with the connection. This value can be null in which case a nameless connection is created.

A client serves as the factory for connections compatible with itself. Therefore, the user should always use a client's connection factory method to create connections for use with the client.


createConnection

public final T createConnection()
Create a nameless client connection for use with a client.


open

public final void open()
                throws EClientException
Open a client.

Throws:
IllegalStateException - Thrown in case the client is already open or if a connection pool has not been set with the connection.
EClientException - Thrown in case an error was encountered while opening the client.
Threading:
This method is not safe for concurrent access by multiple threads.

This method opens the connection pool.


flush

public final void flush(ILnkPeerEndpoint.FlushContext flushContext)
                 throws EClientException
Flush outbound messages buffered by a client's connection pool.

Parameters:
flushContext - The flush context used to govern the flushing of dirty connections in the connection pool. In case multiple connections are flushed by this method, the pool is responsible for preserving the semantics of the flush context by mapping the context to the individual contexts of the flushed connections.
Throws:
IllegalStateException - Thrown in case the client is already open or if a link context has not been set with the connection.
EClientException - Thrown in case an error was encountered while flushing the client's connection pool.
Threading:
This method is not safe for concurrent access by multiple threads.

This method performs basic validations and forwards the call to the contained pool. This method can only be invoked on an open client.


close

public final void close()
Close a client.

This method closes all client connections.



Copyright © 2015 Neeve Research, LLC. All Rights Reserved.