@Override public String apply(Identifiable input) { return (input == null) ? null : input.getId(); } }
public static BrooklynObjectType of(Class<?> objectTypeOrSpecType) { if (objectTypeOrSpecType!=null) { for (BrooklynObjectType t: values()) { if (t.getInterfaceType()!=null && t.getInterfaceType().isAssignableFrom(objectTypeOrSpecType)) return t; if (t.getSpecType()!=null && t.getSpecType().isAssignableFrom(objectTypeOrSpecType)) return t; } } return UNKNOWN; }
private static String getContainerNameFromPlan(Entity target) { String planId = target.config().get(BrooklynCampConstants.PLAN_ID); if (planId != null) { // Plan IDs are not unique even in a single application return planId + "_" + target.getId(); } else { return null; } }
private void assertInput(SpecParameter<?> input, String label, boolean pinned, ConfigKey<?> type) { assertEquals(input.getLabel(), label); assertEquals(input.isPinned(), pinned); assertEquals(input.getConfigKey(), type); }
@Test(dataProvider = "brooklynObjects") public void testCannotUpdateConfigToInvalidValue(BrooklynObject object) { try { object.config().set(EntityRequiringConfigKeyInRange.RANGE, -1); fail("Expected exception when calling config().set with invalid value on " + object); } catch (Exception e) { Throwable t = Exceptions.getFirstThrowableOfType(e, ConstraintViolationException.class); assertNotNull(t, "Original exception was: " + Exceptions.collapseText(e)); } }
@Override public void apply(EntityLocal entity) { entity.config().set(KEY_1, key1); } }
protected <T> SubscriptionHandle recordEvents(Entity entity, AttributeSensor<T> sensor, final List<SensorEvent<T>> events) { SensorEventListener<T> listener = new SensorEventListener<T>() { @Override public void onEvent(SensorEvent<T> event) { log.info("onEvent: {}", event); events.add(event); } }; return entity.subscriptions().subscribe(entity, sensor, listener); }
@Override public void onRebindFailed(BrooklynObjectType type, BrooklynObject instance, Exception e) { rebindFailures.put(instance, new IllegalStateException("problem rebinding "+type.toCamelCase()+" "+instance.getId()+" ("+instance+")", e)); super.onRebindFailed(type, instance, e); }
public Builder rawDataTransformer(RawDataTransformer val) { for (BrooklynObjectType type : BrooklynObjectType.values()) { rawDataTransformer(type, val); } return this; } public Builder rawDataTransformer(BrooklynObjectType type, RawDataTransformer val) {
@Override public void apply(EntityLocal entity) { for (Object tag: tags) entity.tags().addTag(tag); } }
/** As {@link #setHighlight(String, HighlightTuple)}, convenience for recording an item which is intended to be ongoing. */ protected void highlightOngoing(String name, String description) { setHighlight(name, new HighlightTuple(description, 0, null)); } /** As {@link #setHighlight(String, HighlightTuple)}, convenience for recording an item with the current time. */
@Override public boolean apply(String input, BrooklynObject context) { return context != null && context.getDisplayName().equals(input); } }
@Override public void onManageFailed(BrooklynObjectType type, BrooklynObject instance, Exception e) { manageFailures.put(instance, new IllegalStateException("problem managing "+type.toCamelCase()+" "+instance.getId()+" ("+instance+")", e)); super.onManageFailed(type, instance, e); }