com.neeve.client
Class ClientConnection

java.lang.Object
  extended by com.neeve.root.RootObject
      extended by com.neeve.client.ClientConnectionPool
          extended by com.neeve.client.ClientConnection

public abstract class ClientConnection
extends ClientConnectionPool

Represents a connection between a client and server.

Threading:
Prior to opening (i.e. in ClientConnectionPool.State.INIT state), a connection object is not safe for concurrent access by multiple threads. Subsequent to open, it is safe for concurrent access provided the underlying link has been configured for concurrent thread access.

Nested Class Summary
 class ClientConnection.DiscoveredLinkContext
           
 
Nested classes/interfaces inherited from class com.neeve.client.ClientConnectionPool
ClientConnectionPool.State
 
Method Summary
 ClientConnection discoverLinkContext(String entityType, String entityName, Properties descriptorProps, Properties linkManagerProps)
          Discover the link context using the entity discovery protocol
 boolean getAutoReadStart()
          Gets whether the connection read machinery is automatically started on open.
 Client getClient()
          Get the connection's container client.
 ClientConnection.DiscoveredLinkContext getDiscoveredLinkContext()
          Get the discovered link context.
 boolean getFaultTolerant()
          Get a client connection's fault tolerant mode.
 String getGroup()
          Get the application group of the client represented by a connection.
 ClientLinkManager getLinkManager()
          Get the underlying link manager.
 String getLinkName()
          Get the underlying link name.
 String getName()
          Get the connection's name.
 int getReconnectTimeout()
          Get a client connection's reconnect timeout.
 short getThreadAffinity()
          Get a client connection's server thread affinity.
 ClientConnection setAutoReadStart(boolean val)
          Sets whether the connection read machinery is automatically started on open.
 ClientConnection setFaultTolerant(boolean val)
          Set whether a client connection should operate in a fault tolerant mode.
 ClientConnection setGroup(String group)
          Set a the application group of the client represented by a connection.
 ClientConnection setLinkContext(ClientLinkManager linkManager, String linkName)
          Set the underlying link context using a link name and manager.
 ClientConnection setLinkContext(String descriptor, Properties linkManagerProps)
          Create and set the underlying link context using a link descriptor.
 ClientConnection setReconnectTimeout(int timeout)
          Set a client connection's reconnect timeout.
 ClientConnection setThreadAffinity(short threadAffinity)
          Set a client connection's server thread affinity.
 
Methods inherited from class com.neeve.client.ClientConnectionPool
close, flush, getState, open, sendStreaming, sendSync, setMessageFactory
 
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

getName

public final String getName()
Get the connection's name.

Threading:
This method is safe for concurrent access by multiple threads independent of the connection threading model.

This method can be invoked at any time during the lifetime of a connection.


getClient

public final Client getClient()
Get the connection's container client.

Threading:
This method is safe for concurrent access by multiple threads independent of the connection threading model.

This method can be invoked at any time during the lifetime of a connection.


setGroup

public final ClientConnection setGroup(String group)
Set a the application group of the client represented by a connection.

Returns:
Returns this object for invocation chaining.
Threading:
This method is safe for concurrent access by multiple threads independent of the connection threading model.

This method is used to set the application group of the client represented by a connection to the server. A client can only connect to a server that is in the same application group as the client.

The client group can only be set before the connection is opened.


getGroup

public final String getGroup()
Get the application group of the client represented by a connection.

Threading:
This method is safe for concurrent access by multiple threads independent of the connection threading model.

This method can be invoked at any time during the lifetime of a connection.


setAutoReadStart

public final ClientConnection setAutoReadStart(boolean val)
Sets whether the connection read machinery is automatically started on open.

Threading:
This method is safe for concurrent access by multiple threads independent of the connection threading model.

By default, when a client connection is opened, the open method will start the read machinery on the link manager associated which the underlying link. This method toggles that behaviour.

The auto read start state can only be changed before the connection is opened.


getAutoReadStart

public final boolean getAutoReadStart()
Gets whether the connection read machinery is automatically started on open.

Threading:
This method is safe for concurrent access by multiple threads independent of the connection threading model.

This method can be invoked at any time during the lifetime of a connection.


setThreadAffinity

public final ClientConnection setThreadAffinity(short threadAffinity)
Set a client connection's server thread affinity.

Returns:
Returns this object for invocation chaining.
Threading:
This method is safe for concurrent access by multiple threads independent of a connection's threading model.

This method sets the server thread affinity for a client connection. The thread affinity indicates which server I/O thread will be responsible for processing inbound traffic. The user should treat this setting as a hint to the system. It is not guaranteed that the affinity set here will be honored.

A connection's thread affinity can only be set before the connection is opened.


getThreadAffinity

public final short getThreadAffinity()
Get a client connection's server thread affinity.

Threading:
This method is safe for concurrent access by multiple threads.

This method can be invoked at any time during the lifetime of a connection.


setFaultTolerant

public final ClientConnection setFaultTolerant(boolean val)
Set whether a client connection should operate in a fault tolerant mode.

Parameters:
val - A value of true sets the connection to be fault tolerant. A value of false switches off the connection's fault tolerance.
Returns:
Returns this object for invocation chaining.
Threading:
This method is safe for concurrent access by multiple threads independent of a connection's threading model.

This method sets whether a client connection should operate in a fault tolerant manner. If set, then in the event of an underlying link failure, the connection will attempt to reestablish the link for a maximum time specified by the 'reconnect timeout' (see setReconnectTimeout(int)) before deeming the connection to be a failure.

A connection's fault tolerant mode can only be set before the connection is opened.


getFaultTolerant

public final boolean getFaultTolerant()
Get a client connection's fault tolerant mode.

Threading:
This method is safe for concurrent access by multiple threads.

This method can be invoked at any time during the lifetime of a connection.


setReconnectTimeout

public final ClientConnection setReconnectTimeout(int timeout)
Set a client connection's reconnect timeout.

Parameters:
timeout - The maximum time, in seconds, that the reconnect logic will attempt to reconnect a fault tolerant connection after giving up and deeming the connection as failed.
Returns:
Returns this object for invocation chaining.
Threading:
This method is safe for concurrent access by multiple threads independent of a connection's threading model.

A connection's fault tolerant reconnect timeout can only be set before the connection is opened.


getReconnectTimeout

public final int getReconnectTimeout()
Get a client connection's reconnect timeout.

Threading:
This method is safe for concurrent access by multiple threads.

This method can be invoked at any time during the lifetime of a connection.


setLinkContext

public final ClientConnection setLinkContext(ClientLinkManager linkManager,
                                             String linkName)
Set the underlying link context using a link name and manager.

Parameters:
linkManager - The link manager managing the link.
linkName - The name of the link.
Throws:
IllegalArgumentException - Thrown in case the supplied link manager or link name are null.
IllegalStateException - Thrown in case the client is already open.
Threading:
This method is not safe for concurrent access by multiple threads.

This method stores the name of the link and its manager to use to connect to the server. The ClientConnectionPool.open() method uses this information to establish the underlying link.


setLinkContext

public final ClientConnection setLinkContext(String descriptor,
                                             Properties linkManagerProps)
                                      throws EClientException
Create and set the underlying link context using a link descriptor.

Parameters:
descriptor - The link descriptor to use. Link descriptors are of the format

://&&&&...&&
br> where
type specifies the link type e.g. tcp, ssl, http, fuc etc
addr specifies the peer address. The format of this is defined by the link type
prop=val pairs specify property values used to configure the link.
linkManagerProps - A set of properties used to configure the link manager created by this method.
Throws:
IllegalArgumentException - Thrown in case the supplied descriptor is null.
IllegalStateException - Thrown in case the client is already open.
EClientException - Thrown in case an error was encountered while creating the link context.

This method creates a link manager using the supplied properties, adds the descriptor to the manager, generates a unique name for the contained link and invokes setLinkContext(ClientLinkManager, String)

Threading:
This method is not safe for concurrent access by multiple threads.

discoverLinkContext

public final ClientConnection discoverLinkContext(String entityType,
                                                  String entityName,
                                                  Properties descriptorProps,
                                                  Properties linkManagerProps)
                                           throws EClientException
Discover the link context using the entity discovery protocol

Parameters:
entityType - The type of entity to connect to.
entityName - The name of the entity to connect to.
descriptorProps - A set of properties to add to the discovered link descriptor.
linkManagerProps - A set of properties used to configure the link manager created by this method.
Throws:
EClientException
Threading:
This method is not safe for concurrent access by multiple threads.

This method uses the link discovery protocol to discover the link descriptor of the entity specified by the entityType and entityName parameters. This method then invoked the setLinkContext(String, Properties) method with the discovered link descriptor to set the link context.


getDiscoveredLinkContext

public final ClientConnection.DiscoveredLinkContext getDiscoveredLinkContext()
Get the discovered link context.

Threading:
This method is safe for concurrent access by multiple threads independent of the connection threading model.

This method can be invoked at any time during the lifetime of a connection.


getLinkManager

public final ClientLinkManager getLinkManager()
Get the underlying link manager.

Threading:
This method is safe for concurrent access by multiple threads independent of the connection threading model.

This method can be invoked at any time during the lifetime of a connection.


getLinkName

public final String getLinkName()
Get the underlying link name.

Threading:
This method is safe for concurrent access by multiple threads independent of the connection threading model.

This method can be invoked at any time during the lifetime of a connection.



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