Class ConnectionBasedDomainManager
- java.lang.Object
-
- org.opennms.features.distributed.coordination.common.AbstractDomainManager
-
- org.opennms.features.distributed.coordination.common.ConnectionBasedDomainManager
-
- All Implemented Interfaces:
DomainManager
- Direct Known Subclasses:
ZookeeperDomainManager
public abstract class ConnectionBasedDomainManager extends AbstractDomainManager
ADomainManagerthat must connect to an external source before being able to participate in a leadership election.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedConnectionBasedDomainManager(String domain)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidconnect()Implementations must connect via this method.protected abstract voiddisconnect()Implementations must disconnect via this method.protected voidfailedToConnect(Throwable exception)Implementations can optionally override this if they need special handling for a failure to connect.booleanisConnected()Checks if this domain manager is connected.protected voidonFirstRegister()Implementations must handle any specific logic for dealing with a registration that adds to the map of handlers for the first time (such as connecting).protected voidonLastDeregister()Implementations must handle any specific logic for dealing with a deregistration that empties the map of handlers (such as disconnecting).StringtoString()-
Methods inherited from class org.opennms.features.distributed.coordination.common.AbstractDomainManager
becomeActive, becomeStandby, deregister, getCurrentRole, getDomain, getRoleChangeHandlers, isAnythingRegistered, isRegistered, register
-
-
-
-
Constructor Detail
-
ConnectionBasedDomainManager
protected ConnectionBasedDomainManager(String domain)
Constructor.- Parameters:
domain- the domain to manage
-
-
Method Detail
-
isConnected
public boolean isConnected()
Checks if this domain manager is connected.- Returns:
- true if connected, false otherwise
-
failedToConnect
protected void failedToConnect(Throwable exception)
Implementations can optionally override this if they need special handling for a failure to connect.- Parameters:
exception- the exception that caused the failure the connect
-
connect
protected abstract void connect()
Implementations must connect via this method.This is executed in a separate thread so timeliness is not a factor. It is possible that multiple calls to connect() block waiting for the first one to finish so implementations of this method must be written to guard against this being a problem.
-
disconnect
protected abstract void disconnect()
Implementations must disconnect via this method.This is executed in a separate thread so timeliness is not a factor. It is possible that multiple calls to disconnect() block waiting for the first one to finish so implementations of this method must be written to guard against this being a problem.
-
onFirstRegister
protected final void onFirstRegister()
Description copied from class:AbstractDomainManagerImplementations must handle any specific logic for dealing with a registration that adds to the map of handlers for the first time (such as connecting).- Specified by:
onFirstRegisterin classAbstractDomainManager
-
onLastDeregister
protected final void onLastDeregister()
Description copied from class:AbstractDomainManagerImplementations must handle any specific logic for dealing with a deregistration that empties the map of handlers (such as disconnecting).- Specified by:
onLastDeregisterin classAbstractDomainManager
-
toString
public String toString()
- Overrides:
toStringin classAbstractDomainManager
-
-