Package org.opennms.core.tracker
Class RequestTracker<ReqT extends Request<?,ReqT,ReplyT>,ReplyT extends Response>
- java.lang.Object
-
- org.opennms.core.tracker.RequestTracker<ReqT,ReplyT>
-
- All Implemented Interfaces:
ReplyHandler<ReplyT>
public class RequestTracker<ReqT extends Request<?,ReqT,ReplyT>,ReplyT extends Response> extends Object implements ReplyHandler<ReplyT>
A class for tracking sending and received of arbitrary messages. The transport mechanism is irrelevant and is encapsulated in the Messenger request. Timeouts and Retries are handled by this mechanism and provided to the request object so they can be processed. A request is guaranteed to have one of its process method called no matter what happens. This makes it easier to write code because some kind of indication is always provided and so timing out is not needed in the client.- Author:
- jwhite, Mathew Brozowski
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RequestTracker.ReplyCallback<ReqT extends Request<?,?,ReplyT>,ReplyT>
static class
RequestTracker.TimedOutRequestCallback<ReqT extends Request<?,ReqT,?>,ReplyT>
-
Constructor Summary
Constructors Constructor Description RequestTracker(String name, Messenger<ReqT,ReplyT> messenger, RequestLocator<ReqT,ReplyT> requestLocator)
Construct a RequestTracker that sends and received messages using the indicated messenger.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assertStarted()
void
handleReply(ReplyT reply)
void
sendRequest(ReqT request)
Send a tracked request via the messenger.void
start()
This method starts all the threads that are used to process the messages and also starts the messenger.
-
-
-
Constructor Detail
-
RequestTracker
public RequestTracker(String name, Messenger<ReqT,ReplyT> messenger, RequestLocator<ReqT,ReplyT> requestLocator) throws IOException
Construct a RequestTracker that sends and received messages using the indicated messenger. The name is using to name the threads created by the tracker.- Throws:
IOException
-
-
Method Detail
-
start
public void start()
This method starts all the threads that are used to process the messages and also starts the messenger.
-
assertStarted
public void assertStarted()
-
sendRequest
public void sendRequest(ReqT request) throws Exception
Send a tracked request via the messenger. The request is tracked for timeouts and retries. Retries are sent if the timeout processing indicates that they should be.- Throws:
Exception
-
handleReply
public void handleReply(ReplyT reply)
- Specified by:
handleReply
in interfaceReplyHandler<ReqT extends Request<?,ReqT,ReplyT>>
-
-