|
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.protocol.RequestReplyExecutor
public abstract class RequestReplyExecutor
Request/reply simulates a local method invocation.
A common base class for socket or email based messaging. Allows to block during a request and deliver the return message to the waiting thread.
Nested Class Summary | |
---|---|
private class |
RequestReplyExecutor.LatchHolder
|
Field Summary | |
---|---|
protected AddressBase |
addressConfig
|
protected AddressServer |
addressServer
|
protected I_CallbackExtended |
cbClient
This is the client side |
protected boolean |
compressZlib
|
protected boolean |
compressZlibStream
|
protected ContextNode |
contextNode
|
protected Global |
glob
|
private java.util.Set |
latchSet
A set containing LatchHolder instances |
private static java.util.logging.Logger |
log
|
protected java.lang.Object |
mbeanHandle
My JMX registration, can be done optionally by implementing classes |
private java.lang.String |
ME
|
protected int |
minSizeForCompression
|
static boolean |
ONEWAY
Used for execute() |
protected long |
pingResponseTimeout
How long to block on remote call waiting on ping responses |
protected java.lang.String |
prefix
The prefix to create a unique requestId namspace (is set to the loginName) |
protected I_ProgressListener |
progressListener
A listener may register to receive send/receive progress informations |
protected java.util.Map |
responseListenerMap
For listeners who want to be informed about return messages or exceptions, the invocation is blocking during this period. |
private boolean |
responseListenerMapWasCleared
|
protected long |
responseTimeout
How long to block on remote call waiting on response |
protected long |
updateResponseTimeout
How long to block on remote call waiting on update responses |
protected boolean |
useEmailExpiryTimestamp
|
static boolean |
WAIT_ON_RESPONSE
Used for execute() |
private I_XmlBlaster |
xmlBlasterImpl
The singleton handle for this xmlBlaster server (the server side) |
Constructor Summary | |
---|---|
RequestReplyExecutor()
|
Method Summary | |
---|---|
private RequestReplyExecutor.LatchHolder |
addLatch(java.util.concurrent.CountDownLatch latch)
|
void |
addResponseListener(java.lang.String requestId,
I_ResponseListener l)
Adds the listener to receive response/exception events. |
void |
clearResponseListenerMap()
|
protected void |
executeException(MsgInfo receiver,
XmlBlasterException e,
boolean udp)
Send a one way exception back to the other side |
protected void |
executeResponse(MsgInfo receiver,
java.lang.Object response,
boolean udp)
Send a one way response message back to the other side |
void |
freePendingThreads()
If we detect somewhere that the socket is down use this method to free blocking threads which wait on responses |
AddressServer |
getAddressServer()
|
I_CallbackExtended |
getCbClient()
|
long |
getDefaultPingResponseTimeout()
How long to block on remote call waiting on a ping response. |
long |
getDefaultResponseTimeout()
How long to block on remote call waiting on response. |
long |
getDefaultUpdateResponseTimeout()
How long to block on remote call waiting on a update() response. |
java.sql.Timestamp |
getExpiryTimestamp(MethodName methodName)
Return the time in future when the email can be deleted. |
private RequestReplyExecutor.LatchHolder[] |
getLatches()
|
int |
getMinSizeForCompression()
Compressing too small messages won't reduce the size |
java.lang.String |
getPendingRequestList()
For logging only |
long |
getPingResponseTimeout()
The invocation timeout for "ping" method calls. |
I_ProgressListener |
getProgressListener()
|
I_ResponseListener |
getResponseListener(java.lang.String requestId)
Get the response listener object |
long |
getResponseTimeout()
The invocation timeout for all remaining method calls like "publish", "connect", "subscribe" but NOT for "ping" and "update" |
long |
getResponseTimeout(MethodName methodName)
|
long |
getResponseTimeout(java.lang.String methodName)
Access the timeout for method invocation. |
java.lang.String |
getResponseTimeoutPropertyName(MethodName methodName)
For logging. |
abstract java.lang.String |
getType()
The protocol type, used for logging |
long |
getUpdateResponseTimeout()
|
I_XmlBlaster |
getXmlBlasterCore()
|
protected boolean |
hasConnection()
|
protected void |
initialize(Global glob,
AddressBase addressConfig)
Used by SocketCallbackImpl on client side, uses I_CallbackExtended to invoke client classes Used by HandleClient on server side, uses I_XmlBlaster to invoke xmlBlaster core This executor has mixed client and server specific code for two reasons: - Possibly we can use the same socket between two xmlBlaster server (load balance) - Everything is together |
protected void |
initializeCb(AddressBase addressConfig)
|
int |
interruptInvocation()
Interrupts a blocking request with a not returning reply. |
boolean |
isCompressZlib()
|
boolean |
isCompressZlibStream()
|
boolean |
isShutdown()
Check status |
boolean |
isShutdownCompletly()
|
boolean |
isUseEmailExpiryTimestamp()
|
boolean |
receiveReply(MsgInfo receiver,
boolean udp)
Handle common messages |
I_ProgressListener |
registerProgressListener(I_ProgressListener listener)
|
private void |
removeLatch(RequestReplyExecutor.LatchHolder latchHolder)
|
void |
removeResponseListener(java.lang.String requestId)
Removes the specified listener. |
java.lang.Object |
requestAndBlockForReply(MsgInfo msgInfo,
boolean expectingResponse,
boolean udp)
Send a message and block until the response arrives. |
protected abstract void |
sendMessage(MsgInfo msgInfo,
java.lang.String requestId,
MethodName methodName,
boolean udp)
Flush the data to the protocol layer (socket, email, ...). |
void |
setCbClient(I_CallbackExtended cbClient)
|
void |
setCompressZlib(boolean compress)
|
void |
setCompressZlibStream(boolean compress)
|
protected void |
setLoginName(java.lang.String loginName)
Sets the loginName and automatically the requestId as well |
void |
setMinSizeForCompression(int minSizeForCompression)
|
void |
setPingResponseTimeout(long millis)
Set the given millis to protect against blocking client for ping invocations. |
void |
setResponseTimeout(long millis)
Set the given millis to protect against blocking client. |
void |
setUpdateResponseTimeout(long millis)
Set the given millis to protect against blocking client for update() invocations. |
void |
setUseEmailExpiryTimestamp(boolean useEmailExpiryTimestamp)
|
void |
setXmlBlasterCore(I_XmlBlaster xmlBlaster)
|
void |
shutdown()
Shutdown the plugin, free resources. |
java.lang.String |
usage()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.xmlBlaster.util.admin.I_AdminPlugin |
---|
getVersion |
Methods inherited from interface org.xmlBlaster.util.admin.I_AdminUsage |
---|
getUsageUrl, setUsageUrl |
Field Detail |
---|
private java.lang.String ME
protected Global glob
private static java.util.logging.Logger log
protected java.lang.String prefix
protected long responseTimeout
protected long pingResponseTimeout
protected long updateResponseTimeout
protected I_CallbackExtended cbClient
private I_XmlBlaster xmlBlasterImpl
private final java.util.Set latchSet
protected AddressBase addressConfig
protected AddressServer addressServer
protected I_ProgressListener progressListener
protected int minSizeForCompression
protected boolean compressZlib
protected boolean compressZlibStream
protected boolean useEmailExpiryTimestamp
protected final java.util.Map responseListenerMap
private boolean responseListenerMapWasCleared
public static final boolean ONEWAY
public static final boolean WAIT_ON_RESPONSE
protected java.lang.Object mbeanHandle
protected ContextNode contextNode
Constructor Detail |
---|
public RequestReplyExecutor()
Method Detail |
---|
protected void initialize(Global glob, AddressBase addressConfig)
addressConfig
- The configuration to useprotected void initializeCb(AddressBase addressConfig)
public AddressServer getAddressServer()
public abstract java.lang.String getType()
getType
in interface I_AdminPlugin
public I_ProgressListener registerProgressListener(I_ProgressListener listener)
public final I_ProgressListener getProgressListener()
public long getDefaultResponseTimeout()
public long getDefaultPingResponseTimeout()
public long getDefaultUpdateResponseTimeout()
public final void setResponseTimeout(long millis)
setResponseTimeout
in interface RequestReplyExecutorMBean
millis
- If <= 0 it is set to the default (forever).
An argument less than or equal to zero means not to wait at all
and is not supportedpublic final void setPingResponseTimeout(long millis)
setPingResponseTimeout
in interface RequestReplyExecutorMBean
millis
- If <= 0 it is set to the default (one minute).
An argument less than or equal to zero means not to wait at all
and is not supportedpublic final void setUpdateResponseTimeout(long millis)
setUpdateResponseTimeout
in interface RequestReplyExecutorMBean
millis
- If <= 0 it is set to the default (one minute).
An argument less than or equal to zero means not to wait at all
and is not supportedpublic long getResponseTimeout(MethodName methodName)
public long getResponseTimeout(java.lang.String methodName)
getResponseTimeout
in interface RequestReplyExecutorMBean
methodName
- e.g. "PING", "UPDATE", "SUBSCRIBE", "PUBLISH", ...
public java.sql.Timestamp getExpiryTimestamp(MethodName methodName)
public java.lang.String getResponseTimeoutPropertyName(MethodName methodName)
methodName
-
public final void setCbClient(I_CallbackExtended cbClient)
public final void setXmlBlasterCore(I_XmlBlaster xmlBlaster)
public final I_XmlBlaster getXmlBlasterCore()
public final I_CallbackExtended getCbClient()
protected void setLoginName(java.lang.String loginName)
public final void addResponseListener(java.lang.String requestId, I_ResponseListener l)
public final void removeResponseListener(java.lang.String requestId)
public final I_ResponseListener getResponseListener(java.lang.String requestId)
public final java.lang.String getPendingRequestList()
public void clearResponseListenerMap()
public boolean receiveReply(MsgInfo receiver, boolean udp) throws XmlBlasterException, java.io.IOException
XmlBlasterException
java.io.IOException
protected boolean hasConnection()
public java.lang.Object requestAndBlockForReply(MsgInfo msgInfo, boolean expectingResponse, boolean udp) throws XmlBlasterException, java.io.IOException
expectingResponse
- WAIT_ON_RESPONSE=true or ONEWAY=falseudp
- Some user info which is passed through
XmlBlasterException
java.io.IOException
public void shutdown()
I_AdminPlugin
shutdown
in interface I_AdminPlugin
public int interruptInvocation()
interruptInvocation
in interface RequestReplyExecutorMBean
private RequestReplyExecutor.LatchHolder addLatch(java.util.concurrent.CountDownLatch latch)
private void removeLatch(RequestReplyExecutor.LatchHolder latchHolder)
private RequestReplyExecutor.LatchHolder[] getLatches()
public final void freePendingThreads()
protected final void executeResponse(MsgInfo receiver, java.lang.Object response, boolean udp) throws XmlBlasterException, java.io.IOException
XmlBlasterException
java.io.IOException
protected final void executeException(MsgInfo receiver, XmlBlasterException e, boolean udp) throws XmlBlasterException, java.io.IOException
XmlBlasterException
java.io.IOException
protected abstract void sendMessage(MsgInfo msgInfo, java.lang.String requestId, MethodName methodName, boolean udp) throws XmlBlasterException, java.io.IOException
XmlBlasterException
java.io.IOException
public boolean isCompressZlib()
isCompressZlib
in interface RequestReplyExecutorMBean
public void setCompressZlib(boolean compress)
setCompressZlib
in interface RequestReplyExecutorMBean
public int getMinSizeForCompression()
getMinSizeForCompression
in interface RequestReplyExecutorMBean
public boolean isCompressZlibStream()
isCompressZlibStream
in interface RequestReplyExecutorMBean
public void setCompressZlibStream(boolean compress)
setCompressZlibStream
in interface RequestReplyExecutorMBean
public final long getUpdateResponseTimeout()
getUpdateResponseTimeout
in interface RequestReplyExecutorMBean
public boolean isUseEmailExpiryTimestamp()
isUseEmailExpiryTimestamp
in interface RequestReplyExecutorMBean
public void setUseEmailExpiryTimestamp(boolean useEmailExpiryTimestamp)
setUseEmailExpiryTimestamp
in interface RequestReplyExecutorMBean
useEmailExpiryTimestamp
- The useEmailExpiryTimestamp to set.public java.lang.String usage()
usage
in interface I_AdminUsage
public boolean isShutdownCompletly()
public boolean isShutdown()
I_AdminPlugin
isShutdown
in interface I_AdminPlugin
public final long getPingResponseTimeout()
getPingResponseTimeout
in interface RequestReplyExecutorMBean
public final long getResponseTimeout()
getResponseTimeout
in interface RequestReplyExecutorMBean
public void setMinSizeForCompression(int minSizeForCompression)
setMinSizeForCompression
in interface RequestReplyExecutorMBean
minSizeForCompression
- The minSizeForCompression to set.
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |