@Override @Deprecated @SuppressWarnings("rawtypes") public Map<AttributeSensor, Object> getAllAttributes() { return Collections.<AttributeSensor, Object>unmodifiableMap(sensors().getAll()); }
@Override @Deprecated public <T> void emit(Sensor<T> sensor, T val) { sensors().emit(sensor, val); }
@Override @Deprecated public <T> T setAttributeWithoutPublishing(AttributeSensor<T> attribute, T val) { return sensors().setWithoutPublishing(attribute, val); }
@Override @Deprecated public <T> T setAttribute(AttributeSensor<T> attribute, T val) { return sensors().set(attribute, val); }
@Beta @Override @Deprecated public <T> T modifyAttribute(AttributeSensor<T> attribute, Function<? super T, Maybe<T>> modifier) { return sensors().modify(attribute, modifier); }
@Override @Deprecated public void removeAttribute(AttributeSensor<?> attribute) { sensors().remove(attribute); }
/** * Warning: for internal purposes only; this method may be deleted without notice in future releases. */ public <T> void emitInternal(Sensor<T> sensor, T val) { sensors().emitInternal(sensor, val); }
@Override public <T> T getAttribute(AttributeSensor<T> attribute) { return sensors().get(attribute); }
/** * Removes the named {@link Sensor} from this entity. */ public Sensor<?> removeSensor(String sensorName) { Sensor<?> result = sensors.remove(sensorName); if (result != null) { invalidateSnapshot(); instance.sensors().emit(AbstractEntity.SENSOR_REMOVED, result); } return result; }
@Override public void add(Group group) { boolean changed = groupsInternal.add(group); getApplication(); if (changed) { sensors().emit(AbstractEntity.GROUP_ADDED, group); } }
@Override public void remove(Group group) { boolean changed = groupsInternal.remove(group); getApplication(); if (changed) { sensors().emit(AbstractEntity.GROUP_REMOVED, group); } } }
public void clearConfigKeys() { Map<String, FieldAndValue<ConfigKey<?>>> oldKeys = MutableMap.copyOf(configKeys); configKeys.clear(); invalidateSnapshot(); for (FieldAndValue<ConfigKey<?>> k: oldKeys.values()) { instance.sensors().emit(AbstractEntity.CONFIG_KEY_REMOVED, k.value); } }
public void addSensorIfAbsent(Sensor<?> newSensor) { Sensor<?> prev = addSensorIfAbsentWithoutPublishing(newSensor); if (prev == null) { instance.sensors().emit(AbstractEntity.SENSOR_ADDED, newSensor); } }
/** * Adds the given {@link Effector} to this entity. */ @Beta public void addEffector(Effector<?> newEffector) { Effector<?> oldEffector = effectors.put(Preconditions.checkNotNull(newEffector.getName(), "Missing 'name' for effector"), newEffector); invalidateSnapshot(); if (oldEffector!=null) instance.sensors().emit(AbstractEntity.EFFECTOR_CHANGED, newEffector.getName()); else instance.sensors().emit(AbstractEntity.EFFECTOR_ADDED, newEffector.getName()); }
/** * Adds the given {@link Sensor} to this entity. */ public void addSensor(Sensor<?> newSensor) { sensors.put(newSensor.getName(), newSensor); invalidateSnapshot(); instance.sensors().emit(AbstractEntity.SENSOR_ADDED, newSensor); }
/** * Removes the named {@link ConfigKey} from this entity. */ public boolean removeConfigKey(ConfigKey<?> key) { FieldAndValue<ConfigKey<?>> result = configKeys.remove(key.getName()); if (result != null) { invalidateSnapshot(); ConfigKey<?> removedKey = result.value; instance.sensors().emit(AbstractEntity.CONFIG_KEY_REMOVED, removedKey); return true; } else { return false; } }
/** * Adds the given {@link ConfigKey} to this entity. */ public void addConfigKey(ConfigKey<?> newKey) { configKeys.put(newKey.getName(), new FieldAndValue<ConfigKey<?>>(null, newKey)); invalidateSnapshot(); instance.sensors().emit(AbstractEntity.CONFIG_KEY_ADDED, newKey); }
@Override public <T> T setAttribute(AttributeSensor<T> attribute, T val) { if (LOG.isDebugEnabled()) LOG.debug("Mocks: item {} setting {} to {}", new Object[] {this, attribute, val}); return super.sensors().set(attribute, val); }
@Override public boolean remove(Policy policy) { ((AbstractPolicy)policy).destroy(); boolean changed = policiesInternal.remove(policy); if (changed) { getManagementSupport().getEntityChangeListener().onPolicyRemoved(policy); sensors().emit(AbstractEntity.POLICY_REMOVED, new PolicyDescriptor(policy)); } return changed; }
@Override public void add(Policy policy) { Policy old = findApparentlyEqualAndWarnIfNotSameUniqueTag(policiesInternal, policy); if (old!=null) { LOG.debug("Removing "+old+" when adding "+policy+" to "+AbstractEntity.this); remove(old); } CatalogUtils.setCatalogItemIdOnAddition(AbstractEntity.this, policy); policiesInternal.add((AbstractPolicy)policy); ((AbstractPolicy)policy).setEntity(AbstractEntity.this); ConfigConstraints.assertValid(policy); getManagementSupport().getEntityChangeListener().onPolicyAdded(policy); sensors().emit(AbstractEntity.POLICY_ADDED, new PolicyDescriptor(policy)); }