@Override protected void setEntityLoadingTargetConfig() { if (getConfig(TARGET_SENSOR)!=null) throw new IllegalArgumentException("Must not set "+TARGET_SENSOR+" when using "+this); }
protected Object computeServiceNotUp() { Map<Entity, Boolean> values = getValues(SERVICE_UP); List<Entity> violators = MutableList.of(); boolean ignoreNull = getConfig(IGNORE_ENTITIES_WITH_SERVICE_UP_NULL); Set<Lifecycle> ignoreStates = getConfig(IGNORE_ENTITIES_WITH_THESE_SERVICE_STATES); int entries=0; int numUp=0; QuorumCheck qc = getConfig(UP_QUORUM_CHECK); if (qc!=null) { if (qc.isQuorate(numUp, violators.size()+numUp))
protected Object computeServiceProblems() { Map<Entity, Lifecycle> values = getValues(SERVICE_STATE_ACTUAL); int numRunning=0; List<Entity> onesNotHealthy=MutableList.of(); Set<Lifecycle> ignoreStates = getConfig(IGNORE_ENTITIES_WITH_THESE_SERVICE_STATES); for (Map.Entry<Entity,Lifecycle> state: values.entrySet()) { if (state.getValue()==Lifecycle.RUNNING) numRunning++; else if (!ignoreStates.contains(state.getValue())) onesNotHealthy.add(state.getKey()); } QuorumCheck qc = getConfig(RUNNING_QUORUM_CHECK); if (qc!=null) { if (qc.isQuorate(numRunning, onesNotHealthy.size()+numRunning)) // quorate return null; if (onesNotHealthy.isEmpty()) return "Not enough entities running to be quorate"; } else { if (onesNotHealthy.isEmpty()) return null; } return "Required entit"+Strings.ies(onesNotHealthy.size())+" not healthy: "+ (onesNotHealthy.size()>3 ? nameOfEntity(onesNotHealthy.get(0))+" and "+(onesNotHealthy.size()-1)+" others" : Strings.join(nameOfEntity(onesNotHealthy), ", ")); }
@Override protected void onUpdated() { if (entity==null || !Entities.isManaged(entity)) { // either invoked during setup or entity has become unmanaged; just ignore BrooklynLogging.log(log, BrooklynLogging.levelDebugOrTraceIfReadOnly(entity), "Ignoring {} onUpdated when entity is not in valid state ({})", this, entity); return; } // override superclass to publish multiple sensors if (getConfig(DERIVE_SERVICE_PROBLEMS)) { updateMapSensor(SERVICE_PROBLEMS, computeServiceProblems()); } if (getConfig(DERIVE_SERVICE_NOT_UP)) { updateMapSensor(SERVICE_NOT_UP_INDICATORS, computeServiceNotUp()); } }