Class AbstractDomainManager
- java.lang.Object
-
- org.opennms.features.distributed.coordination.common.AbstractDomainManager
-
- All Implemented Interfaces:
DomainManager
- Direct Known Subclasses:
ConnectionBasedDomainManager
public abstract class AbstractDomainManager extends Object implements DomainManager
A skeleton implementation ofDomainManager.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractDomainManager(String domain)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidbecomeActive()Executed when becoming ACTIVE for the managed domain.protected voidbecomeStandby()Executed when becoming STANDBY for the managed domain.voidderegister(String id)Deregister with the domain being managed.protected RolegetCurrentRole()protected StringgetDomain()Map<String,RoleChangeHandler>getRoleChangeHandlers()Check the current view of the registered change handlers.booleanisAnythingRegistered()Checks if anything is currently registered with the domain being managed.booleanisRegistered(String id)Checks if a given Id is registered.protected abstract 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 abstract voidonLastDeregister()Implementations must handle any specific logic for dealing with a deregistration that empties the map of handlers (such as disconnecting).voidregister(String id, RoleChangeHandler roleChangeHandler)Register with the domain being managed.StringtoString()
-
-
-
Constructor Detail
-
AbstractDomainManager
protected AbstractDomainManager(String domain)
Constructor.- Parameters:
domain- the domain to manage
-
-
Method Detail
-
getRoleChangeHandlers
public final Map<String,RoleChangeHandler> getRoleChangeHandlers()
Check the current view of the registered change handlers.- Returns:
- an immutable copy of the currently registered change handlers
-
becomeActive
protected final void becomeActive()
Executed when becoming ACTIVE for the managed domain. This blocks until all registrants have processed the becomeActive() in their handler.
-
becomeStandby
protected final void becomeStandby()
Executed when becoming STANDBY for the managed domain. This blocks until all registrants have processed the becomeStandby() in their handler.
-
getCurrentRole
protected final Role getCurrentRole()
-
getDomain
protected final String getDomain()
-
onFirstRegister
protected abstract 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).
-
onLastDeregister
protected abstract void onLastDeregister()
Implementations must handle any specific logic for dealing with a deregistration that empties the map of handlers (such as disconnecting).
-
register
public final void register(String id, RoleChangeHandler roleChangeHandler)
Description copied from interface:DomainManagerRegister with the domain being managed. This is a non-blocking call.Ids must be unique to this manager. Attempting to register the same Id twice will result in an exception.
The methods specified by the
RoleChangeHandlerpassed to this method must not block.- Specified by:
registerin interfaceDomainManager- Parameters:
id- the Id to registerroleChangeHandler- the role change handler to register
-
deregister
public final void deregister(String id)
Description copied from interface:DomainManagerDeregister with the domain being managed. This is a non-blocking call.- Specified by:
deregisterin interfaceDomainManager- Parameters:
id- the Id to register
-
isRegistered
public final boolean isRegistered(String id)
Description copied from interface:DomainManagerChecks if a given Id is registered.- Specified by:
isRegisteredin interfaceDomainManager- Parameters:
id- the Id to check- Returns:
- true if registered, false otherwise
-
isAnythingRegistered
public final boolean isAnythingRegistered()
Description copied from interface:DomainManagerChecks if anything is currently registered with the domain being managed.- Specified by:
isAnythingRegisteredin interfaceDomainManager- Returns:
- true if one or more registrants are currently registered, false otherwise
-
-