public class ViewStateManagerImpl extends Object implements ViewStateManager
Note re synchronization: this class rquires a lock object to be passed in the constructor - this will be applied to all public methods appropriately. Additionally, the ClusterSyncService callback will also be locked using the provided lock object.
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.locks.Lock |
lock
The lock object with which all public methods are guarded - to be provided in the constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
bind(TopologyEventListener eventListener)
Binds the given eventListener, sending it an INIT event if applicable.
|
protected boolean |
hadPreviousView() |
void |
handleActivated()
Handles activation - ie marks this manager as activated thus the TOPOLOGY_INIT
event can be sent to already bound listeners and subsequent calls to
handleChanging/handleNewView will result in according/appropriate TOPOLOGY_CHANGING/
TOPOLOGY_CHANGED events.
|
void |
handleChanging()
Handles the fact that some (possibly early) indicator of a change in a topology
has been detected and that a new view is being agreed upon (whatever that means,
be it voting or similar).
|
void |
handleDeactivated()
Must be called when the corresponding service (typically a DiscoveryService implementation)
is deactivated.
|
void |
handleNewView(BaseTopologyView newView)
Handles the fact that a new view became true/established and sends out
TOPOLOGY_INIT to uninitialized listeners and TOPOLOGY_CHANGED to already initialized
listeners (in the latter case, also sends a TOPOLOGY_CHANGING if that has not yet been
done)
|
void |
installMinEventDelayHandler(DiscoveryService discoveryService,
Scheduler scheduler,
long minEventDelaySecs)
Installs an optional 'min event delay handler' which, using the given scheduler,
delays sending TOPOLOGY_CHANGED event after receiving a handleNewView - with the
idea as to limit the number of toggling between view states.
|
protected boolean |
onlyDiffersInProperties(BaseTopologyView newView) |
boolean |
unbind(TopologyEventListener eventListener)
Unbinds the given eventListener, returning whether or not it was bound at all.
|
protected boolean |
unchanged(BaseTopologyView newView) |
int |
waitForAsyncEvents(long timeout)
for testing only: wait for any potentially queued async events to be delivered
before returning.
|
protected final java.util.concurrent.locks.Lock lock
public void installMinEventDelayHandler(DiscoveryService discoveryService, Scheduler scheduler, long minEventDelaySecs)
ViewStateManager
installMinEventDelayHandler
in interface ViewStateManager
protected boolean hadPreviousView()
protected boolean unchanged(BaseTopologyView newView)
public void bind(TopologyEventListener eventListener)
ViewStateManager
bind
in interface ViewStateManager
eventListener
- the eventListener that is to bindpublic boolean unbind(TopologyEventListener eventListener)
ViewStateManager
unbind
in interface ViewStateManager
eventListener
- the eventListner that is to unbindpublic void handleActivated()
ViewStateManager
handleActivated
in interface ViewStateManager
public void handleDeactivated()
ViewStateManager
Will mark this manager as deactivated and flags the last available view as not current.
handleDeactivated
in interface ViewStateManager
public void handleChanging()
ViewStateManager
Will send out TOPOLOGY_CHANGING to all initialized listeners.
handleChanging
in interface ViewStateManager
public void handleNewView(BaseTopologyView newView)
ViewStateManager
handleNewView
in interface ViewStateManager
newView
- the new, established view
true if we were either in changing mode or the newView was different from the previous one.protected boolean onlyDiffersInProperties(BaseTopologyView newView)
public int waitForAsyncEvents(long timeout)
ViewStateManager
waitForAsyncEvents
in interface ViewStateManager
timeout
- time in millis to wait for at max - 0 to not wait at all - -1
to wait indefinitelyCopyright © 2017 The Apache Software Foundation. All rights reserved.