org.jboss.ha.framework.interfaces
Interface ResponseFilter


public interface ResponseFilter

Interface defining when a group request is done, allowing early termination of a group request based on logic implemented by the caller. For example, an RPC could be invoked on all members of a group, but as soon as a single valid response is received the needMoreResponses() method could return false allowing the call to return without waiting for other slower-to-arrive responses. Based on JGroups' RspFilter concept, but with a separate abstraction. The abstraction has be done to avoid leaking JGroups classes to ha-server-api consumers and to avoid adding an absolute dependency on JGroups to HAPartition implementations.

Author:
Galder Zamarreno
See Also:
HAPartition.callMethodOnCluster(String, String, Object[], Class[], boolean, ResponseFilter)

Method Summary
 boolean isAcceptable(Object response, ClusterNode sender)
          Determines whether a response from a given sender should be added to the response list of the request
 boolean needMoreResponses()
          Right after a call to isAcceptable(Object, ClusterNode), this method is called to see whether we are done with the request and can unblock the caller.
 

Method Detail

isAcceptable

boolean isAcceptable(Object response,
                     ClusterNode sender)
Determines whether a response from a given sender should be added to the response list of the request

Parameters:
response - The response (usually a serializable value)
sender - The sender of response
Returns:
true if we should add the response to the response list of returned by HAPartition.callMethodOnCluster(String, String, Object[], Class[], boolean, ResponseFilter) otherwise false. In the latter case, the response will not be included in the list returned to the RPC caller.

needMoreResponses

boolean needMoreResponses()
Right after a call to isAcceptable(Object, ClusterNode), this method is called to see whether we are done with the request and can unblock the caller.

Returns:
true if the request is done, otherwise falsealse


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.