public abstract class Connector extends Object implements ConnectorMBean
Modifier and Type | Field and Description |
---|---|
protected static boolean |
isAdvancedStatEnabled |
static String |
SYS_PROPERTY_NO_ADV_STATISTICS |
Constructor and Description |
---|
Connector() |
Modifier and Type | Method and Description |
---|---|
protected abstract ConnectionAdapter |
createConnectionAdapter(Socket socket)
|
protected void |
fireConnectorListenerProcessing(String message,
Throwable error,
String state) |
String |
getAddress()
Returns address string of this connector.
|
ConnectorListener |
getConnectorListener() |
int |
getHeartbeatPeriod()
Returns heartbeat period (in milliseconds) or 0 if heartbeats are disabled.
|
int |
getHeartbeatTimeout()
Returns heartbeat timeout (in milliseconds) or 0 if heartbeats are disabled.
|
int |
getReconnectionPeriod()
Returns reconnection period (in milliseconds) or 0 for immediate reeconnect.
|
protected int |
getSkewedPeriod(int period)
Applies skew factor to specified period and returns result.
|
double |
getSkewFactor()
Returns skew factor in a range [0,1].
|
protected String |
getSocketAddress(Socket socket)
Returns string representation of specified socket address.
|
protected void |
log(String message,
Throwable error,
boolean shouldBePrintStackTrace,
String state)
Logs specified message and error if not null.
|
protected void |
log(String message,
Throwable error,
String state)
Logs specified message and error if not null.
|
void |
restart()
Restarts this connector by calling
ConnectorMBean.stop() and ConnectorMBean.start() methods in succession. |
void |
setAddress(String address)
Sets new address string for this connector, closes connections that were established for
addresses that are no longer in the address string, starts (if required) new connections
for new addresses, does nothing for connections those addresses have not changed.
|
void |
setConnectorListener(ConnectorListener connectorListener) |
void |
setHeartbeatPeriod(int heartbeat_period)
Sets new heartbeat period (in milliseconds) or 0 to disable heartbeats.
|
void |
setHeartbeatTimeout(int heartbeat_timeout)
The timeout must be >= 0.
|
void |
setReconnectionPeriod(int reconnection_period)
Sets new reconnection period (in milliseconds) or 0 for immediate reconnect.
|
void |
setSkewFactor(double skew_factor)
Sets new skew factor in a range [0,1].
|
void |
start()
Starts this connector.
|
void |
stop()
Stops this connector and closes all open connections.
|
String |
toString() |
public static final String SYS_PROPERTY_NO_ADV_STATISTICS
protected static final boolean isAdvancedStatEnabled
public int getHeartbeatPeriod()
ConnectorMBean
getHeartbeatPeriod
in interface ConnectorMBean
public void setHeartbeatPeriod(int heartbeat_period)
ConnectorMBean
setHeartbeatPeriod
in interface ConnectorMBean
public int getHeartbeatTimeout()
ConnectorMBean
getHeartbeatTimeout
in interface ConnectorMBean
public void setHeartbeatTimeout(int heartbeat_timeout)
setHeartbeatTimeout
in interface ConnectorMBean
heartbeat_timeout
- timeout in mspublic int getReconnectionPeriod()
ConnectorMBean
getReconnectionPeriod
in interface ConnectorMBean
public void setReconnectionPeriod(int reconnection_period)
ConnectorMBean
setReconnectionPeriod
in interface ConnectorMBean
public double getSkewFactor()
ConnectorMBean
getSkewFactor
in interface ConnectorMBean
public void setSkewFactor(double skew_factor)
ConnectorMBean
ConnectorMBean.getSkewFactor()
for details.setSkewFactor
in interface ConnectorMBean
public String getAddress()
ConnectorMBean
getAddress
in interface ConnectorMBean
public void setAddress(String address)
ConnectorMBean
ConnectorMBean.getAddress()
for details.setAddress
in interface ConnectorMBean
public void start()
ConnectorMBean
start
in interface ConnectorMBean
public void stop()
ConnectorMBean
stop
in interface ConnectorMBean
public void restart()
ConnectorMBean
ConnectorMBean.stop()
and ConnectorMBean.start()
methods in succession.restart
in interface ConnectorMBean
public ConnectorListener getConnectorListener()
public void setConnectorListener(ConnectorListener connectorListener)
protected abstract ConnectionAdapter createConnectionAdapter(Socket socket) throws Throwable
ConnectionAdapter
for specified Socket
.If this method returns 'null' or throws an exception, then connection is closed.
Throwable
protected int getSkewedPeriod(int period)
protected void log(String message, Throwable error, String state)
message
- a message to logerror
- is null for information messagesstate
- see and use ConnectorStates for this field only or nullprotected void fireConnectorListenerProcessing(String message, Throwable error, String state)
protected void log(String message, Throwable error, boolean shouldBePrintStackTrace, String state)
message
- infoerror
- is null for information messages.shouldBePrintStackTrace
- print StackTrace?Copyright © 2002–2025 Devexperts LLC. All rights reserved.