|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.util.dispatch.DispatchConnection
public abstract class DispatchConnection
Holding all necessary infos to establish a remote connection and check this connection.
State chart of a single connection: +<--toAlive()----+ | | ######### ########## ########## # # # # # # # ALIVE # # POLLING # # DEAD # # # # # # # ######### ########## ########## | | | | | | | +--toPolling()-->+ +--toDead()-->+ | | | +-------------toDead()---------------------->+
Note that DispatchConnection can't recover from DEAD state you need to create a new instance if desired
Field Summary | |
---|---|
protected AddressBase |
address
|
private boolean |
bypassPingOnActivity
|
protected DispatchConnectionsHandler |
connectionsHandler
|
private boolean |
connectionWasDown
|
protected Global |
glob
|
private static java.util.logging.Logger |
log
|
private long |
logEveryMillis
|
private int |
logInterval
|
java.lang.String |
ME
|
protected java.lang.String |
myId
For logging only |
protected boolean |
physicalConnectionOk
|
static java.lang.String |
PING_THREAD_NAME
|
private java.lang.Object |
PING_TIMER_MONITOR
Protects timerKey refresh |
protected long |
previousBytesRead
|
protected long |
previousBytesWritten
|
protected int |
retryCounter
|
protected boolean |
serverAcceptsRequests
Flag if the remote server is reachable but is not willing to process our requests (standby mode). |
protected ConnectionStateEnum |
state
|
private Timestamp |
timerKey
|
Constructor Summary | |
---|---|
DispatchConnection(Global glob,
DispatchConnectionsHandler connectionsHandler,
AddressBase address)
Our loadPlugin() and initialize() needs to be called next. |
Method Summary | |
---|---|
abstract void |
connectLowlevel()
Connect on protocol layer and try an initial low level ping. |
abstract java.lang.String |
doPing(java.lang.String data)
Does the real ping to the remote server instance. |
abstract void |
doSend(MsgQueueEntry[] msgArr_,
boolean isAsyncMode)
Send the messages. |
void |
finalize()
|
protected abstract boolean |
forcePingFailure()
|
AddressBase |
getAddress()
|
abstract java.lang.String |
getDriverName()
A human readable name of the protocol plugin |
abstract java.lang.String |
getName()
|
ConnectionStateEnum |
getState()
|
void |
handleTransition(boolean byDispatchConnectionsHandler,
java.lang.Throwable throwable)
|
void |
initialize()
Connects on protocol level to the server and tries a ping. |
boolean |
isAlive()
|
private boolean |
isAuthenticationException(XmlBlasterException ex)
|
boolean |
isConnectionWasDown()
|
boolean |
isDead()
|
boolean |
isPolling()
|
private static boolean |
isResponseTimeout(java.lang.Throwable e)
Returns true if it is an XmlBlasterException with error code COMMUNICATION_RESPONSETIMEOUT, false otherwise |
boolean |
isUndef()
|
abstract void |
loadPlugin()
The derived class should create an instance of the protocol driver. |
java.lang.String |
ping(java.lang.String data)
Ping the remote server instance (callback of the client or xmlBlaster itself) |
protected java.lang.String |
ping(java.lang.String data,
boolean byDispatchConnectionsHandler)
Ping the xmlBlaster server or callback server of the client. |
private java.lang.Throwable |
processResponseTimeoutException(DispatchStatistic stats,
java.lang.Throwable e)
|
protected abstract void |
reconnect()
On reconnect polling try to establish the connection |
abstract I_ProgressListener |
registerProgressListener(I_ProgressListener listener)
Should be overwritten by extending classes. |
abstract void |
resetConnection()
Called on COMMUNICATION errors, reset protocol driver for reconnect polling |
private boolean |
retry(XmlBlasterException e)
|
void |
send(MsgQueueEntry[] msgArr,
boolean isAsyncMode)
Send the messages back to the client. |
void |
setAddress(AddressBase address)
|
void |
setConnectionWasDown(boolean connectionWasDown)
|
void |
shutdown(boolean delayed)
Stop all remote connections. |
protected void |
spanPingTimer(long timeout,
boolean isPing)
|
void |
timeout(java.lang.Object userData)
We are notified to do the next ping or reconnect polling. |
abstract java.lang.String |
toXml(java.lang.String extraOffset)
Dump state of this object into a XML ASCII string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final java.lang.String ME
protected final Global glob
private static java.util.logging.Logger log
public static final java.lang.String PING_THREAD_NAME
protected DispatchConnectionsHandler connectionsHandler
protected final java.lang.String myId
protected AddressBase address
private Timestamp timerKey
private final java.lang.Object PING_TIMER_MONITOR
protected ConnectionStateEnum state
protected int retryCounter
private final long logEveryMillis
private int logInterval
private boolean connectionWasDown
protected boolean serverAcceptsRequests
protected boolean physicalConnectionOk
protected long previousBytesWritten
protected long previousBytesRead
private boolean bypassPingOnActivity
Constructor Detail |
---|
public DispatchConnection(Global glob, DispatchConnectionsHandler connectionsHandler, AddressBase address)
connectionsHandler
- The DevliveryConnectionsHandler witch i belong toaddress
- The address i shall connect toMethod Detail |
---|
public void setAddress(AddressBase address) throws XmlBlasterException
XmlBlasterException
public abstract java.lang.String getName()
public final void initialize() throws XmlBlasterException
Calls connectLowLevel() which needs to be implemented by derived classes loadPlugin() needs to be called before.
Called by ClientDispatchConnectionsHandler or CbDispatchConnectionsHandler
XmlBlasterException
private boolean retry(XmlBlasterException e)
public void finalize()
finalize
in class java.lang.Object
public final AddressBase getAddress()
public abstract void resetConnection()
public abstract void loadPlugin() throws XmlBlasterException
XmlBlasterException
public abstract void connectLowlevel() throws XmlBlasterException
XmlBlasterException
- with ErrorCode.COMMUNICATION* if server is not reachable
or other exceptions on other errorspublic abstract java.lang.String getDriverName()
public abstract void doSend(MsgQueueEntry[] msgArr_, boolean isAsyncMode) throws XmlBlasterException
msgArr
- Should be a copy of the original, since we export it which changes/encrypts the content.
msgArr[i].getReturnObj() transports the returned string array from the client which is decrypted
if necessary, for oneway updates it is nullisAsyncMode
- true if coming from queue
XmlBlasterException
public abstract I_ProgressListener registerProgressListener(I_ProgressListener listener)
public void send(MsgQueueEntry[] msgArr, boolean isAsyncMode) throws XmlBlasterException
msgArr
- Should be a copy of the original, since we export it which changes/encrypts the contentisAsyncMode
- true if coming from queue
XmlBlasterException
public abstract java.lang.String doPing(java.lang.String data) throws XmlBlasterException
data
- QoS, never null
XmlBlasterException
org.xmlBlaster.protocol.I_XmlBlaster#ping(String)
public final java.lang.String ping(java.lang.String data) throws XmlBlasterException
XmlBlasterException
protected final java.lang.String ping(java.lang.String data, boolean byDispatchConnectionsHandler) throws XmlBlasterException
byDispatchConnectionsHandler
- true if invoked by DispatchConnectionsHandler
we can throw exceptions back.
false: If invoked by our timer/ping thread, we need to notify the situation
XmlBlasterException
private static final boolean isResponseTimeout(java.lang.Throwable e)
e
-
public boolean isConnectionWasDown()
public void setConnectionWasDown(boolean connectionWasDown)
private final java.lang.Throwable processResponseTimeoutException(DispatchStatistic stats, java.lang.Throwable e)
e
- the original Communication Exception
protected abstract void reconnect() throws XmlBlasterException
XmlBlasterException
public final void timeout(java.lang.Object userData)
timeout
in interface I_Timeout
userData
- You get bounced back your userData which you passed
with Timeout.addTimeoutListener()
here it is "poll" or nullprotected void spanPingTimer(long timeout, boolean isPing) throws XmlBlasterException
XmlBlasterException
private boolean isAuthenticationException(XmlBlasterException ex)
public final void handleTransition(boolean byDispatchConnectionsHandler, java.lang.Throwable throwable) throws XmlBlasterException
toReconnected
- If true if the connection is OK (it is a transition to reconnected)byDispatchConnectionsHandler
- true if invoked by DispatchConnectionsHandler,
false if invoked by our timer/pingThe
- problem, is expected to be not null for toReconnected==false
XmlBlasterException
- If delivery failedpublic void shutdown(boolean delayed) throws XmlBlasterException
XmlBlasterException
public final ConnectionStateEnum getState()
public final boolean isUndef()
public final boolean isAlive()
public final boolean isPolling()
public final boolean isDead()
public abstract java.lang.String toXml(java.lang.String extraOffset)
extraOffset
- indenting of tags for nice output
protected abstract boolean forcePingFailure()
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |