public static class ServiceStateLogic.ComputeServiceState extends AbstractEnricher implements SensorEventListener<java.lang.Object>
Attributes.SERVICE_STATE_ACTUAL
on changes to
Attributes.SERVICE_STATE_EXPECTED
, Attributes.SERVICE_PROBLEMS
, and Attributes.SERVICE_UP
The default implementation uses computeActualStateWhenExpectedRunning(Map, Boolean)
if the last expected transition
was to Lifecycle.RUNNING
and
computeActualStateWhenNotExpectedRunning(Map, Boolean, brooklyn.entity.basic.Lifecycle.Transition)
otherwise.
If these methods return null, the Attributes.SERVICE_STATE_ACTUAL
sensor will be cleared (removed).
Either of these methods can be overridden for custom logic, and that custom enricher can be created using
ServiceStateLogic.newEnricherForServiceState(Class)
and added to an entity.
AbstractEntityAdjunct.AdjunctTagSupport
BrooklynObject.TagSupport
Configurable.ConfigurationSupport
BrooklynObjectInternal.ConfigurationSupportInternal
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_ENRICHER_UNIQUE_TAG |
SUPPRESS_DUPLICATES
NOOP
Constructor and Description |
---|
ServiceStateLogic.ComputeServiceState() |
ServiceStateLogic.ComputeServiceState(java.util.Map<?,?> flags) |
Modifier and Type | Method and Description |
---|---|
void |
init()
Called by framework (in new-style instances where spec was used) after configuring etc,
but before a reference to this instance is shared.
|
void |
onEvent(SensorEvent<java.lang.Object> event)
The
SensorEvent handler method. |
void |
setEntity(EntityLocal entity) |
getEnricherType, getRebindSupport
config, configure, destroy, getAllConfig, getConfig, getConfigMap, getDisplayName, getName, getUniqueTag, isDestroyed, isRunning, setConfig, setDisplayName, setName, tags, toString
getCatalogItemId, getId, getManagementContext, getTagSupport, rebind, setCatalogItemId, setManagementContext
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAllConfig, getConfig, getId, getName, setConfig
getUniqueTag, isDestroyed, isRunning
getCatalogItemId, getDisplayName, getTagSupport, tags
config
setCatalogItemId
public static final java.lang.String DEFAULT_ENRICHER_UNIQUE_TAG
public ServiceStateLogic.ComputeServiceState()
public ServiceStateLogic.ComputeServiceState(java.util.Map<?,?> flags)
public void init()
AbstractBrooklynObject
To preserve backwards compatibility for if the instance is constructed directly, one can call the code below, but that means it will be called after references to this policy have been shared with other entities.
if (isLegacyConstruction()) {
init();
}
init
in class AbstractBrooklynObject
public void setEntity(EntityLocal entity)
setEntity
in class AbstractEnricher
public void onEvent(@Nullable SensorEvent<java.lang.Object> event)
SensorEventListener
SensorEvent
handler method.onEvent
in interface SensorEventListener<java.lang.Object>