org.apache.uima.aae.delegate
Class Delegate

java.lang.Object
  extended by org.apache.uima.aae.delegate.Delegate
Direct Known Subclasses:
ClientServiceDelegate, ControllerDelegate

public abstract class Delegate
extends java.lang.Object


Nested Class Summary
static class Delegate.DelegateEntry
          Entry in the list of CASes pending reply.
 
Field Summary
protected  java.lang.String delegateKey
           
static int DISABLED_STATE
           
static int OK_STATE
           
static int TIMEOUT_STATE
           
 
Constructor Summary
Delegate()
           
 
Method Summary
 void addCasToOutstandingList(java.lang.String aCasReferenceId)
          Adds a given Cas ID to the list of CASes pending reply.
 int addCasToPendingDispatchList(java.lang.String aCasReferenceId)
          Adds given CAS ID to the list of CASes pending dispatch.
 void addNewCasToOutstandingList(java.lang.String aCasReferenceId)
           
 void addNewCasToOutstandingList(java.lang.String aCasReferenceId, boolean isCasGeneratingChildren)
           
 void cancelDelegateTimer()
          Cancels current timer
 void cleanup()
          Cancels timer and clears a list of CASes pending reply
 int getCasPendingDispatchListSize()
           
 int getCasPendingReplyListSize()
           
 long getCasProcessTimeout()
           
abstract  java.lang.String getComponentName()
           
 long getCpcTimeout()
           
 java.util.List<Delegate.DelegateEntry> getDelegateCasesPendingDispatch()
           
 java.util.List<Delegate.DelegateEntry> getDelegateCasesPendingReply()
           
 Endpoint getEndpoint()
          Returns an Endpoint object
 long getGetMetaTimeout()
           
 java.lang.String getKey()
          Returns delegate key
 Endpoint getNotificationEndpoint()
           
 java.lang.String getOldestCasIdFromOutstandingList()
           
 int getState()
           
abstract  void handleError(java.lang.Exception e, ErrorContext errorContext)
           
 boolean hasConcurrentConsumersOnReplyQueue()
           
 void incrementRetryCount(java.lang.String aCasReferenceId)
          Increments retry count
 boolean isAwaitingPingReply()
           
 boolean isGeneratingChildrenFrom(java.lang.String aCasReferenceId)
           
 boolean removeCasFromOutstandingList(java.lang.String aCasReferenceId)
          Removes Delegate.DelegateEntry from the list of CASes pending reply.
 boolean removeCasFromPendingDispatchList(java.lang.String aCasReferenceId)
          Removes an entry from the list of CASes pending dispatch that matches a given CAS Id.A CAS is delayed and placed on this list when the delegate status changes to TIMED_OUT and a PING message is sent to test delegate availability.
 java.lang.String removeOldestCasFromOutstandingList()
          Removes Delegate.DelegateEntry from the list of CASes pending reply.
 java.lang.String removeOldestFromPendingDispatchList()
          Removes the oldest entry from the list of CASes pending dispatch.
 void resetAwaitingPingReply()
           
 void restartTimerForOldestCasInOutstandingList()
          Forces Timer restart for the oldest CAS sitting in the list of CASes pending reply.
 void setAwaitingPingReply()
           
 void setCasProcessTimeout(long casProcessTimeout)
           
 void setConcurrentConsumersOnReplyQueue()
           
 void setCpcTimeout(long cpcTimeout)
           
 void setEndpoint(Endpoint anEndpoint)
          Sets an Endpoint object
 void setGeneratingChildrenFrom(java.lang.String aCasReferenceId, boolean tOf)
           
 void setGetMetaTimeout(long getMetaTimeout)
           
 void setNotificationEndpoint(Endpoint notificationEndpoint)
           
 void setState(int aState)
           
 void startGetMetaRequestTimer()
          Starts GetMeta Request timer
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OK_STATE

public static final int OK_STATE
See Also:
Constant Field Values

TIMEOUT_STATE

public static final int TIMEOUT_STATE
See Also:
Constant Field Values

DISABLED_STATE

public static final int DISABLED_STATE
See Also:
Constant Field Values

delegateKey

protected java.lang.String delegateKey
Constructor Detail

Delegate

public Delegate()
Method Detail

getNotificationEndpoint

public Endpoint getNotificationEndpoint()

setNotificationEndpoint

public void setNotificationEndpoint(Endpoint notificationEndpoint)

isAwaitingPingReply

public boolean isAwaitingPingReply()

setAwaitingPingReply

public void setAwaitingPingReply()

resetAwaitingPingReply

public void resetAwaitingPingReply()

getKey

public java.lang.String getKey()
Returns delegate key

Returns:

setEndpoint

public void setEndpoint(Endpoint anEndpoint)
Sets an Endpoint object

Parameters:
anEndpoint - - an endpoint object

getEndpoint

public Endpoint getEndpoint()
Returns an Endpoint object

Returns:

restartTimerForOldestCasInOutstandingList

public void restartTimerForOldestCasInOutstandingList()
Forces Timer restart for the oldest CAS sitting in the list of CASes pending reply.


getDelegateCasesPendingReply

public java.util.List<Delegate.DelegateEntry> getDelegateCasesPendingReply()

getDelegateCasesPendingDispatch

public java.util.List<Delegate.DelegateEntry> getDelegateCasesPendingDispatch()

addNewCasToOutstandingList

public void addNewCasToOutstandingList(java.lang.String aCasReferenceId)

addNewCasToOutstandingList

public void addNewCasToOutstandingList(java.lang.String aCasReferenceId,
                                       boolean isCasGeneratingChildren)

addCasToOutstandingList

public void addCasToOutstandingList(java.lang.String aCasReferenceId)
Adds a given Cas ID to the list of CASes pending reply. A new timer will be started to handle delegate's timeout if either: 1) the list of CASes pending reply is empty AND delegate timeout > 0 2) the list already contains the CAS ID AND delegate timeout > 0. This is a retry logic.

Parameters:
aCasReferenceId - - CAS ID to add to pending list if not already there

addCasToPendingDispatchList

public int addCasToPendingDispatchList(java.lang.String aCasReferenceId)
Adds given CAS ID to the list of CASes pending dispatch. These CASes are delayed due to a questionable state of the delegate that most likely timed out on a previous CAS. When the timeout occurs, the subsequent CASes are queued (delayed) and a GetMeta request is sent to the delegate. When the delegate responds to GetMeta request, the state of the delegate is reset back to normal and the CASes queued (delayed) are immediately send to the delegate.

Parameters:
aCasReferenceId - - CAS ID to add to the delayed list

incrementRetryCount

public void incrementRetryCount(java.lang.String aCasReferenceId)
Increments retry count

Parameters:
aCasReferenceId -

removeOldestFromPendingDispatchList

public java.lang.String removeOldestFromPendingDispatchList()
Removes the oldest entry from the list of CASes pending dispatch. A CAS is delayed and placed on this list when the delegate status changes to TIMED_OUT and a PING message is sent to test delegate availability. Until the PING message is acked by the delegate OR the PING times out, all CASes are delayed. When the PING is acked by the delegate ALL delayed CASes are sent to the delegate one at a time.

Returns:
- ID of the oldest CAS in the list

removeCasFromPendingDispatchList

public boolean removeCasFromPendingDispatchList(java.lang.String aCasReferenceId)
Removes an entry from the list of CASes pending dispatch that matches a given CAS Id.A CAS is delayed and placed on this list when the delegate status changes to TIMED_OUT and a PING message is sent to test delegate availability. Until the PING message is acked by the delegate OR the PING times out, all CASes are delayed. When the PING is acked by the delegate ALL delayed CASes are sent to the delegate one at a time.

Returns:
- ID of the oldest CAS in the list

removeCasFromOutstandingList

public boolean removeCasFromOutstandingList(java.lang.String aCasReferenceId)
Removes Delegate.DelegateEntry from the list of CASes pending reply. The entry is removed when either: 1) reply is received from the delegate before the timeout 2) the timeout occurs with no retry 3) an error occurs and the CAS is dropped as part of Error Handling

Parameters:
aCasReferenceId - - id of the CAS to remove from the list

removeOldestCasFromOutstandingList

public java.lang.String removeOldestCasFromOutstandingList()
Removes Delegate.DelegateEntry from the list of CASes pending reply. The entry is removed when either: 1) reply is received from the delegate before the timeout 2) the timeout occurs with no retry 3) an error occurs and the CAS is dropped as part of Error Handling

Parameters:
aCasReferenceId - - id of the CAS to remove from the list

getOldestCasIdFromOutstandingList

public java.lang.String getOldestCasIdFromOutstandingList()

cleanup

public void cleanup()
Cancels timer and clears a list of CASes pending reply


getCasPendingReplyListSize

public int getCasPendingReplyListSize()

getCasPendingDispatchListSize

public int getCasPendingDispatchListSize()

cancelDelegateTimer

public void cancelDelegateTimer()
Cancels current timer


startGetMetaRequestTimer

public void startGetMetaRequestTimer()
Starts GetMeta Request timer


getCasProcessTimeout

public long getCasProcessTimeout()

setCasProcessTimeout

public void setCasProcessTimeout(long casProcessTimeout)

getGetMetaTimeout

public long getGetMetaTimeout()

setGetMetaTimeout

public void setGetMetaTimeout(long getMetaTimeout)

getCpcTimeout

public long getCpcTimeout()

setCpcTimeout

public void setCpcTimeout(long cpcTimeout)

getState

public int getState()

setState

public void setState(int aState)

setConcurrentConsumersOnReplyQueue

public void setConcurrentConsumersOnReplyQueue()

hasConcurrentConsumersOnReplyQueue

public boolean hasConcurrentConsumersOnReplyQueue()

isGeneratingChildrenFrom

public boolean isGeneratingChildrenFrom(java.lang.String aCasReferenceId)

setGeneratingChildrenFrom

public void setGeneratingChildrenFrom(java.lang.String aCasReferenceId,
                                      boolean tOf)

handleError

public abstract void handleError(java.lang.Exception e,
                                 ErrorContext errorContext)

getComponentName

public abstract java.lang.String getComponentName()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2012. All Rights Reserved.