com.devexperts.qd.qtp
Class AbstractMessageConnector

java.lang.Object
  extended by com.devexperts.qd.qtp.AbstractMessageConnector
All Implemented Interfaces:
MessageConnector
Direct Known Subclasses:
ClientSocketConnector, FileConnector, HttpConnector, NioServerConnector, ServerSocketConnector

public abstract class AbstractMessageConnector
extends java.lang.Object
implements MessageConnector


Field Summary
static long DEFAULT_READ_AGGREGATION_SIZE
          Maximum number of bytes to aggregate before processing when reading data from socket.
static long DEFAULT_RECONNECT_DELAY
          Default reconnection delay.
protected  com.devexperts.logging.Logging log
           
 
Constructor Summary
protected AbstractMessageConnector(com.devexperts.connector.proto.ApplicationConnectionFactory factory)
          Constructs new abstract message connector.
 
Method Summary
 void addClosedConnectionStats(com.devexperts.transport.stats.ConnectionStats stats)
           
 void addMessageConnectorListener(MessageConnectorListener listener)
          Adds the specified listener to this message connector.
 com.devexperts.transport.stats.EndpointStats getEndpointStats()
          Returns statistics for this message connector.
 com.devexperts.connector.proto.ApplicationConnectionFactory getFactory()
           
 com.devexperts.logging.Logging getLogging()
          Returns Logging instance that is tied to this MessageConnector and includes this connector's name into the logs.
 java.lang.String getName()
          Returns short string description of thic connector for management and logging purposes.
 long getReconnectDelay()
          Returns reconnection delay.
 QDStats getStats()
          Returns QDStats assosiated with this message connector.
 int getThreadPriority()
          Returns thread priority for all threads created by this connector.
 void notifyMessageConnectorListeners()
           
protected  void reconfigure()
           
 void removeMessageConnectorListener(MessageConnectorListener listener)
          Removes the specified listener from this message connector.
 void restart()
          Restarts connector (connection is immediately dropped and established again).
 void setName(java.lang.String name)
          Overrides short string description of this connector for management and logging purposes.
 void setReconnectDelay(long reconnectDelay)
          Sets reconnection delay.
 void setStats(QDStats stats)
           
 void setThreadPriority(int priority)
          Sets thread priority for all threads created by this connector.
abstract  void start()
          Starts connector (connection is immediately established).
abstract  void stop()
          Stops connector (connection is immediately dropped).
 java.lang.String toString()
          Returns name of this connector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.devexperts.qd.qtp.MessageConnector
getAddress, getConnectionCount, getState, isActive
 

Field Detail

log

protected com.devexperts.logging.Logging log

DEFAULT_RECONNECT_DELAY

public static final long DEFAULT_RECONNECT_DELAY
Default reconnection delay.

See Also:
Constant Field Values

DEFAULT_READ_AGGREGATION_SIZE

public static final long DEFAULT_READ_AGGREGATION_SIZE
Maximum number of bytes to aggregate before processing when reading data from socket.

See Also:
Constant Field Values
Constructor Detail

AbstractMessageConnector

protected AbstractMessageConnector(com.devexperts.connector.proto.ApplicationConnectionFactory factory)
Constructs new abstract message connector.

Parameters:
factory - application connection factory to use
Throws:
java.lang.NullPointerException - if factory is null
Method Detail

toString

public java.lang.String toString()
Returns name of this connector.

Overrides:
toString in class java.lang.Object
Returns:
name of this connector
See Also:
getName()

getName

public java.lang.String getName()
Returns short string description of thic connector for management and logging purposes. This description may be manually overriden to arbitrary value via setName(java.lang.String) method.

Specified by:
getName in interface MessageConnector
Returns:
short string description of thic connector for management and logging purposes
See Also:
setName(String)

setName

public void setName(java.lang.String name)
Overrides short string description of this connector for management and logging purposes.

Specified by:
setName in interface MessageConnector
Parameters:
name - connector name to set; it may be null in which case default autogenerated name will be used.
See Also:
getName()

getFactory

public com.devexperts.connector.proto.ApplicationConnectionFactory getFactory()

getReconnectDelay

public long getReconnectDelay()
Description copied from interface: MessageConnector
Returns reconnection delay.

Specified by:
getReconnectDelay in interface MessageConnector
Returns:
reconnection delay

setReconnectDelay

public void setReconnectDelay(long reconnectDelay)
Description copied from interface: MessageConnector
Sets reconnection delay.

Specified by:
setReconnectDelay in interface MessageConnector
Parameters:
reconnectDelay - reconnection delay

getStats

public QDStats getStats()
Description copied from interface: MessageConnector
Returns QDStats assosiated with this message connector.

Specified by:
getStats in interface MessageConnector
Returns:
QDStats assosiated with this message connector

setStats

public void setStats(QDStats stats)
Specified by:
setStats in interface MessageConnector

start

public abstract void start()
Description copied from interface: MessageConnector
Starts connector (connection is immediately established). Does nothing if connector is already started.

Specified by:
start in interface MessageConnector

stop

public abstract void stop()
Description copied from interface: MessageConnector
Stops connector (connection is immediately dropped). Does nothing if connector is stopped.

Specified by:
stop in interface MessageConnector

restart

public void restart()
Description copied from interface: MessageConnector
Restarts connector (connection is immediately dropped and established again). It basically does MessageConnector.stop() and MessageConnector.start() in sequence.

Specified by:
restart in interface MessageConnector

reconfigure

protected void reconfigure()

setThreadPriority

public void setThreadPriority(int priority)
Description copied from interface: MessageConnector
Sets thread priority for all threads created by this connector.

Specified by:
setThreadPriority in interface MessageConnector
Parameters:
priority - thread priority for all threads created by this connector

getThreadPriority

public int getThreadPriority()
Description copied from interface: MessageConnector
Returns thread priority for all threads created by this connector.

Specified by:
getThreadPriority in interface MessageConnector
Returns:
thread priority for all threads created by this connector

getEndpointStats

public com.devexperts.transport.stats.EndpointStats getEndpointStats()
Description copied from interface: MessageConnector
Returns statistics for this message connector.

Specified by:
getEndpointStats in interface MessageConnector
Returns:
statistics for this message connector

addClosedConnectionStats

public void addClosedConnectionStats(com.devexperts.transport.stats.ConnectionStats stats)

addMessageConnectorListener

public void addMessageConnectorListener(MessageConnectorListener listener)
Description copied from interface: MessageConnector
Adds the specified listener to this message connector.

Specified by:
addMessageConnectorListener in interface MessageConnector
Parameters:
listener - newly adding MessageConnectorListener.

removeMessageConnectorListener

public void removeMessageConnectorListener(MessageConnectorListener listener)
Description copied from interface: MessageConnector
Removes the specified listener from this message connector.

Specified by:
removeMessageConnectorListener in interface MessageConnector
Parameters:
listener - removing MessageConnectorListener.

notifyMessageConnectorListeners

public void notifyMessageConnectorListeners()

getLogging

public com.devexperts.logging.Logging getLogging()
Returns Logging instance that is tied to this MessageConnector and includes this connector's name into the logs.