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
ADomainManager
that must connect to an external source before being able to participate in a leadership election.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ConnectionBasedDomainManager(String domain)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
connect()
Implementations must connect via this method.protected abstract void
disconnect()
Implementations must disconnect via this method.protected void
failedToConnect(Throwable exception)
Implementations can optionally override this if they need special handling for a failure to connect.boolean
isConnected()
Checks if this domain manager is connected.protected void
onFirstRegister()
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 void
onLastDeregister()
Implementations must handle any specific logic for dealing with a deregistration that empties the map of handlers (such as disconnecting).String
toString()
-
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:AbstractDomainManager
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).- Specified by:
onFirstRegister
in classAbstractDomainManager
-
onLastDeregister
protected final void onLastDeregister()
Description copied from class:AbstractDomainManager
Implementations must handle any specific logic for dealing with a deregistration that empties the map of handlers (such as disconnecting).- Specified by:
onLastDeregister
in classAbstractDomainManager
-
toString
public String toString()
- Overrides:
toString
in classAbstractDomainManager
-
-