org.jgroups.util
Class ResponseCollector<T>

java.lang.Object
  extended by org.jgroups.util.ResponseCollector<T>

public class ResponseCollector<T>
extends java.lang.Object

Similar to AckCollector, but collects responses, not just acks. Null is not a valid key.

Author:
Bela Ban

Constructor Summary
ResponseCollector()
           
ResponseCollector(Address... members)
           
ResponseCollector(java.util.Collection<Address> members)
           
 
Method Summary
 void add(Address member, T data)
           
 java.util.List<Address> getMissing()
          Returns a list of members which didn't send a valid response
 java.util.Map<Address,T> getResults()
           
 java.util.List<Address> getValidResults()
           
 boolean hasAllResponses()
           
 int numberOfValidResponses()
           
 void remove(Address member)
           
 void remove(java.util.List<Address> members)
           
 void reset()
           
 void reset(Address... members)
           
 void reset(java.util.Collection<Address> members)
           
 void retainAll(java.util.List<Address> members)
           
 int size()
           
 void suspect(Address member)
           
 java.lang.String toString()
           
 boolean waitForAllResponses(long timeout)
          Waits until all responses have been received, or until a timeout has elapsed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResponseCollector

public ResponseCollector(java.util.Collection<Address> members)
Parameters:
members - List of members from which we expect responses

ResponseCollector

public ResponseCollector(Address... members)

ResponseCollector

public ResponseCollector()
Method Detail

add

public void add(Address member,
                T data)

remove

public void remove(Address member)

remove

public void remove(java.util.List<Address> members)

retainAll

public void retainAll(java.util.List<Address> members)

suspect

public void suspect(Address member)

hasAllResponses

public boolean hasAllResponses()

numberOfValidResponses

public int numberOfValidResponses()

getMissing

public java.util.List<Address> getMissing()
Returns a list of members which didn't send a valid response


getValidResults

public java.util.List<Address> getValidResults()

getResults

public java.util.Map<Address,T> getResults()

size

public int size()

waitForAllResponses

public boolean waitForAllResponses(long timeout)
Waits until all responses have been received, or until a timeout has elapsed.

Parameters:
timeout - Number of milliseconds to wait max. This value needs to be greater than 0, or else it will be adjusted to 2000
Returns:
boolean True if all responses have been received within timeout ms, else false (e.g. if interrupted)

reset

public void reset()

reset

public void reset(java.util.Collection<Address> members)

reset

public void reset(Address... members)

toString

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


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.