org.opennms.protocols.rt
Class RequestTracker<ReqT extends Request<?,ReqT,ReplyT>,ReplyT extends Response>

java.lang.Object
  extended by org.opennms.protocols.rt.RequestTracker<ReqT,ReplyT>

public class RequestTracker<ReqT extends Request<?,ReqT,ReplyT>,ReplyT extends Response>
extends java.lang.Object

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:
Mathew Brozowski

Constructor Summary
RequestTracker(java.lang.String name, Messenger<ReqT,ReplyT> messenger, RequestLocator<ReqT,ReplyT> requestLocator)
          Construct a RequestTracker that sends and received messages using the indicated messenger.
 
Method Summary
 void assertStarted()
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestTracker

public RequestTracker(java.lang.String name,
                      Messenger<ReqT,ReplyT> messenger,
                      RequestLocator<ReqT,ReplyT> requestLocator)
               throws java.io.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:
java.io.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 java.lang.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:
java.lang.Exception


Copyright © 2009. All Rights Reserved.