public abstract class AbstractMessageConnector extends Object implements MessageConnector
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractMessageConnector.Joinable |
MessageConnector.Bindable
Modifier and Type | Field and Description |
---|---|
protected com.devexperts.logging.Logging |
log |
Modifier | Constructor and Description |
---|---|
protected |
AbstractMessageConnector(com.devexperts.connector.proto.ApplicationConnectionFactory factory)
Constructs new abstract message connector.
|
Modifier and Type | Method and Description |
---|---|
void |
addClosedConnectionStats(com.devexperts.transport.stats.ConnectionStats stats) |
void |
addMessageConnectorListener(MessageConnectorListener listener)
Adds the specified
listener to this message connector. |
void |
close()
Permanently closes connector and releases its resources.
|
protected void |
closeImpl() |
long |
getClosedConnectionCount()
Returns total number of closed connector since the creation of connector.
|
String |
getEndpointStats()
Endpoint statistics since last reset
|
com.devexperts.connector.proto.ApplicationConnectionFactory |
getFactory()
Returns
ApplicationConnectionFactory that is used by this message connector. |
String |
getFieldReplacer()
Returns configured input field replacers.
|
com.devexperts.logging.Logging |
getLogging()
Returns
Logging instance that is tied to this MessageConnector and
includes this connector's name into the logs. |
String |
getName()
Returns short string description of this connector for management and logging purposes.
|
String |
getPassword()
User password for authorization.
|
long |
getReconnectDelay()
Delay between reconnection attempts in milliseconds
|
QDStats |
getStats()
Returns
QDStats associated with this message connector. |
int |
getThreadPriority()
Priority for threads associated with this connector
|
String |
getUser()
User login name
Returns connector's user name for authorization.
|
protected void |
handlerClosed(AbstractConnectionHandler handler)
Invoked by handler to notify about associated connector about handler's death.
|
protected boolean |
isClosed() |
void |
notifyMessageConnectorListeners() |
protected void |
reconfigure() |
void |
reconnect()
Reconnects connector.
|
void |
removeMessageConnectorListener(MessageConnectorListener listener)
Removes the specified
listener from this message connector. |
void |
resetEndpointStats()
Resets endpoint statistics
|
void |
restart()
Restarts connector (connection is immediately dropped and established again).
|
protected void |
restartImpl(boolean fullStop)
Restart logic implementation; If fullStop is
false , connection context
(like last chosen address for multi-host connections) may be preserved. |
com.devexperts.transport.stats.EndpointStats |
retrieveCompleteEndpointStats()
Retrieves endpoint statistics for this message connector since its creation
|
void |
setFactory(com.devexperts.connector.proto.ApplicationConnectionFactory factory)
Changes
ApplicationConnectionFactory that is used by this message connector. |
void |
setFieldReplacer(String fieldReplacer)
Sets input field replacers.
|
void |
setName(String name)
Overrides name of this connector for management and logging purposes.
|
void |
setPassword(String password)
Sets password for authorization.
|
void |
setReconnectDelay(long reconnectDelay)
Sets reconnection delay.
|
void |
setStats(QDStats stats)
Changes
QDStats associated with this message connector. |
void |
setThreadPriority(int priority)
Sets thread priority for all threads created by this connector.
|
void |
setUser(String user)
Sets connector's user name for authorization.
|
abstract void |
start()
Starts connector (connection is immediately established).
|
void |
stop()
Stops connector (connection is immediately dropped).
|
void |
stopAndWait()
Stops connector and waits while all its threads are terminated.
|
protected abstract AbstractMessageConnector.Joinable |
stopImpl() |
String |
toString()
Returns name of this connector.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
awaitProcessed
getAddress, getConnectionCount, getState, isActive
protected AbstractMessageConnector(com.devexperts.connector.proto.ApplicationConnectionFactory factory)
factory
- application connection factory to useNullPointerException
- if factory
is null
public String toString()
public String getName()
name
of the corresponding ApplicationConnectionFactory
.
This description may be manually overridden to arbitrary value via setName(java.lang.String)
method.getName
in interface MessageConnectorMBean
setName(String)
public void setName(String name)
name
of the corresponding ApplicationConnectionFactory
.setName
in interface MessageConnectorMBean
name
- connector name to set; it may be null
in which case default
autogenerated name will be used.getName()
public String getUser()
MessageConnectorMBean
getUser
in interface MessageConnectorMBean
public void setUser(String user)
MessageConnectorMBean
setUser
in interface MessageConnectorMBean
user
- connector's user name for authorization.public String getPassword()
MessageConnectorMBean
getPassword
in interface MessageConnectorMBean
public void setPassword(String password)
MessageConnectorMBean
setPassword
in interface MessageConnectorMBean
password
- password for authorization.public com.devexperts.connector.proto.ApplicationConnectionFactory getFactory()
MessageConnector
ApplicationConnectionFactory
that is used by this message connector.getFactory
in interface MessageConnector
ApplicationConnectionFactory
that is used by this message connector.public void setFactory(com.devexperts.connector.proto.ApplicationConnectionFactory factory)
MessageConnector
ApplicationConnectionFactory
that is used by this message connector.setFactory
in interface MessageConnector
factory
- ApplicationConnectionFactory
that will be used by this message connector.public long getReconnectDelay()
MessageConnectorMBean
getReconnectDelay
in interface MessageConnectorMBean
public void setReconnectDelay(long reconnectDelay)
MessageConnectorMBean
setReconnectDelay
in interface MessageConnectorMBean
reconnectDelay
- reconnection delaypublic String getFieldReplacer()
MessageConnectorMBean
getFieldReplacer
in interface MessageConnectorMBean
public void setFieldReplacer(String fieldReplacer)
MessageConnectorMBean
setFieldReplacer
in interface MessageConnectorMBean
fieldReplacer
- field replacers specification.public QDStats getStats()
MessageConnector
QDStats
associated with this message connector.getStats
in interface MessageConnector
public void setStats(QDStats stats)
MessageConnector
QDStats
associated with this message connector.setStats
in interface MessageConnector
public abstract void start()
MessageConnectorMBean
start
in interface MessageConnectorMBean
protected abstract AbstractMessageConnector.Joinable stopImpl()
protected void handlerClosed(AbstractConnectionHandler handler)
Recommended implementation template:
- check if handler is still actual (beware of asynchronous execution) and cut-out local handler reference
- restart processing (if needed)
handler
- - the notifying handlerpublic final void stop()
MessageConnectorMBean
stop
in interface MessageConnectorMBean
public final void stopAndWait() throws InterruptedException
MessageConnector
stopAndWait
in interface MessageConnector
InterruptedException
- if interrupted.public void restart()
MessageConnectorMBean
MessageConnectorMBean.stop()
and MessageConnectorMBean.start()
in sequence.restart
in interface MessageConnectorMBean
public void reconnect()
MessageConnectorMBean
MessageConnectorMBean.restart()
method, reconnect should try to follow specified
reconnection policy (like choosing next node in cluster) if applicable.
Default behavior is just performing MessageConnectorMBean.restart()
.
reconnect
in interface MessageConnectorMBean
protected void restartImpl(boolean fullStop)
false
, connection context
(like last chosen address for multi-host connections) may be preserved.fullStop
- protected void reconfigure()
public int getThreadPriority()
MessageConnectorMBean
getThreadPriority
in interface MessageConnectorMBean
public void setThreadPriority(int priority)
MessageConnectorMBean
setThreadPriority
in interface MessageConnectorMBean
priority
- thread priority for all threads created by this connectorpublic String getEndpointStats()
MessageConnectorMBean
getEndpointStats
in interface MessageConnectorMBean
MessageConnectorMBean.resetEndpointStats()
.public void resetEndpointStats()
MessageConnectorMBean
resetEndpointStats
in interface MessageConnectorMBean
public com.devexperts.transport.stats.EndpointStats retrieveCompleteEndpointStats()
MessageConnectorMBean
retrieveCompleteEndpointStats
in interface MessageConnectorMBean
public long getClosedConnectionCount()
MessageConnector
getClosedConnectionCount
in interface MessageConnector
public void addClosedConnectionStats(com.devexperts.transport.stats.ConnectionStats stats)
public final void close()
MessageConnector
close
in interface MessageConnector
protected void closeImpl()
protected boolean isClosed()
public void addMessageConnectorListener(MessageConnectorListener listener)
MessageConnector
listener
to this message connector.addMessageConnectorListener
in interface MessageConnector
listener
- newly adding MessageConnectorListener
.public void removeMessageConnectorListener(MessageConnectorListener listener)
MessageConnector
listener
from this message connector.removeMessageConnectorListener
in interface MessageConnector
listener
- removing MessageConnectorListener
.public void notifyMessageConnectorListeners()
public com.devexperts.logging.Logging getLogging()
Logging
instance that is tied to this MessageConnector and
includes this connector's name into the logs.Copyright © 2002–2025 Devexperts LLC. All rights reserved.