/** as {@link #newEnricherFromChildren()} but only publishing service not-up indicators, * using a different unique tag ({@link ComputeServiceIndicatorsFromChildrenAndMembers#DEFAULT_UNIQUE_TAG_UP}), * listening to children only, ignoring lifecycle/service-state, * and using the same logic * (viz looking only at children (not members) and requiring either no children or at least one child up) by default */ public static ComputeServiceIndicatorsFromChildrenAndMembersSpec newEnricherFromChildrenUp() { return newEnricherFromChildren() .uniqueTag(ComputeServiceIndicatorsFromChildrenAndMembers.DEFAULT_UNIQUE_TAG_UP) .checkChildrenOnly() .configure(ComputeServiceIndicatorsFromChildrenAndMembers.DERIVE_SERVICE_PROBLEMS, false); }
/** as {@link #newEnricherFromChildren()} but only publishing service problems, * listening to children and members, ignoring service up, * and using the same logic * (viz looking at children and members and requiring none are on fire) by default */ public static ComputeServiceIndicatorsFromChildrenAndMembersSpec newEnricherFromChildrenState() { return newEnricherFromChildren() .configure(ComputeServiceIndicatorsFromChildrenAndMembers.DERIVE_SERVICE_NOT_UP, false); }
@Override public void start(Collection<? extends Location> locations) { ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING); ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(this, START.getName(), "starting"); }
public void testTwoIndicatorsAreBetterThanOne() { // if we set a not up indicator, entity service up should become false ServiceNotUpLogic.updateNotUpIndicator(entity, INDICATOR_KEY_1, "We're pretending to block service up"); assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, false); ServiceNotUpLogic.updateNotUpIndicator(entity, INDICATOR_KEY_2, "We're also pretending to block service up"); ServiceNotUpLogic.clearNotUpIndicator(entity, INDICATOR_KEY_1); // clearing one indicator is not sufficient assertAttributeEquals(entity, Attributes.SERVICE_UP, false); // but it does not become true when both are cleared ServiceNotUpLogic.clearNotUpIndicator(entity, INDICATOR_KEY_2); assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, true); }
public ComputeServiceIndicatorsFromChildrenAndMembersSpec checkChildrenAndMembers() { configure(ComputeServiceIndicatorsFromChildrenAndMembers.FROM_MEMBERS, true); configure(ComputeServiceIndicatorsFromChildrenAndMembers.FROM_CHILDREN, true); return self(); } public ComputeServiceIndicatorsFromChildrenAndMembersSpec checkMembersOnly() {
protected void updateMapSensor(AttributeSensor<Map<String, Object>> sensor, Object value) { if (log.isTraceEnabled()) log.trace("{} updating map sensor {} with {}", new Object[] { this, sensor, value }); if (value!=null) { updateMapSensorEntry(entity, sensor, getKeyForMapSensor(), value); } else { clearMapSensorEntry(entity, sensor, getKeyForMapSensor()); } }
/** as {@link #updateProblemsIndicator(Entity, Sensor, Object)} */ public static void updateProblemsIndicator(Entity entity, String key, Object value) { updateMapSensorEntry(entity, Attributes.SERVICE_PROBLEMS, key, value); } /** as {@link #clearProblemsIndicator(Entity, Sensor)} */
/** as {@link #clearProblemsIndicator(Entity, Sensor)} */ public static void clearProblemsIndicator(Entity entity, String key) { clearMapSensorEntry(entity, Attributes.SERVICE_PROBLEMS, key); } }
/** provides the default {@link ComputeServiceIndicatorsFromChildrenAndMembers} enricher, * using the default unique tag ({@link ComputeServiceIndicatorsFromChildrenAndMembers#DEFAULT_UNIQUE_TAG}), * configured here to require none on fire, and either no children or at least one up child, * the spec can be further configured as appropriate */ public static ComputeServiceIndicatorsFromChildrenAndMembersSpec newEnricherFromChildren() { return new ComputeServiceIndicatorsFromChildrenAndMembersSpec() .uniqueTag(ComputeServiceIndicatorsFromChildrenAndMembers.DEFAULT_UNIQUE_TAG); }
public void testAppStoppedAndEntityNullBeforeStarting() { // AbstractApplication has default logic to ensure service is not up if it hasn't been started, // (this can be removed by updating the problem indicator associated with the SERVICE_STATE_ACTUAL sensor) assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, false); // and from that it imputes stopped state assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); // TestEntity has no such indicators however assertAttributeEquals(entity, Attributes.SERVICE_UP, null); assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, null); }
@Override public void start(Collection<? extends Location> locations) { ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING); ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(this, START.getName(), "starting"); }
public ComputeServiceIndicatorsFromChildrenAndMembersSpec checkMembersOnly() { configure(ComputeServiceIndicatorsFromChildrenAndMembers.FROM_MEMBERS, true); configure(ComputeServiceIndicatorsFromChildrenAndMembers.FROM_CHILDREN, false); return self(); } public ComputeServiceIndicatorsFromChildrenAndMembersSpec checkChildrenOnly() {
/** puts the given value into the {@link Attributes#SERVICE_NOT_UP_INDICATORS} map as if the * {@link UpdatingMap} enricher for the given key */ public static void updateNotUpIndicator(Entity entity, String key, Object value) { updateMapSensorEntry(entity, Attributes.SERVICE_NOT_UP_INDICATORS, key, value); } /** clears any entry for the given key in the {@link Attributes#SERVICE_NOT_UP_INDICATORS} map */
/** clears any entry for the given key in the {@link Attributes#SERVICE_NOT_UP_INDICATORS} map */ public static void clearNotUpIndicator(Entity entity, String key) { clearMapSensorEntry(entity, Attributes.SERVICE_NOT_UP_INDICATORS, key); } /** as {@link #updateNotUpIndicator(Entity, String, Object)} using the given sensor as the key */
@Override public void start(Collection<? extends Location> locations) { ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING); ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(this, START.getName(), "starting"); }