Package org.jgroups.protocols.pbcast
Class ViewHandler<R>
java.lang.Object
org.jgroups.protocols.pbcast.ViewHandler<R>
- Type Parameters:
R- the type of the request
Responsible for dispatching JOIN/LEAVE/MERGE requests to the GMS protocol. Bundles multiple concurrent requests into
a request list
- Since:
- 4.0.5
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final GMSprotected final BoundedList<String> protected final Lockprotected final AtomicBooleanprotected final Conditionprotected BiPredicate<R, R> protected Consumer<Collection<R>> protected final Collection<R> protected final AtomicBoolean -
Constructor Summary
ConstructorsConstructorDescriptionViewHandler(GMS gms, Consumer<Collection<R>> req_processor, BiPredicate<R, R> req_matcher) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean_add(Collection<R> reqs) protected booleanprotected booleanadd(Collection<R> reqs) protected Loglog()protected voidprocess()We're guaranteed that only one thread will be called with this method at any timeboolean<T extends ViewHandler<R>>
Tprocessing(boolean flag) To be used by testing only!protected Collection<R> remove(Collection<R> requests) Removes requests as long as they match - breaks at the first non-matching request or when requests is empty This method must catch all exceptions; or else process() might return without setting processing to true again!reqMatcher(BiPredicate<R, R> m) reqProcessor(Consumer<Collection<R>> p) voidresume()intsize()voidsuspend()Clears the queue and discards new requests from now onbooleantoString()voidBlocks the caller until the current set of requests being processed have been completed.voidwaitUntilComplete(long timeout) Blocks the caller until the current set of requests being processed have been completed, or the timeout elapsed.
-
Field Details
-
requests
-
lock
-
suspended
-
processing
-
processing_done
-
gms
-
req_processor
-
req_matcher
-
history
-
-
Constructor Details
-
ViewHandler
Constructor- Parameters:
gms- The ref to GMSreq_processor- A request processor which processes a list of requestsreq_matcher- The matcher which determines whether any given 2 requests can be processed together
-
-
Method Details
-
suspended
public boolean suspended() -
processing
public boolean processing() -
size
public int size() -
reqProcessor
-
reqProcessor
-
reqMatcher
-
reqMatcher
-
add
-
add
-
add
-
suspend
public void suspend()Clears the queue and discards new requests from now on -
resume
public void resume() -
waitUntilComplete
public void waitUntilComplete()Blocks the caller until the current set of requests being processed have been completed. Returns immediately if no requests are currently being processed -
waitUntilComplete
public void waitUntilComplete(long timeout) Blocks the caller until the current set of requests being processed have been completed, or the timeout elapsed.Returns immediately if no requests are currently being processed
- Parameters:
timeout- Max time to wait in milliseconds
-
processing
To be used by testing only! -
dumpQueue
-
dumpHistory
-
toString
-
log
-
_add
-
_add
-
_add
-
process
protected void process()We're guaranteed that only one thread will be called with this method at any time -
remove
Removes requests as long as they match - breaks at the first non-matching request or when requests is empty This method must catch all exceptions; or else process() might return without setting processing to true again!
-