private BrooklynObjectInternal.ConfigurationSupportInternal getConfigurationSupportInternal() { return ((BrooklynObjectInternal) brooklynObject).config(); }
public static Memento newObjectMemento(BrooklynObject instance) { return ((BrooklynObjectInternal)instance).getRebindSupport().getMemento(); }
/** * As {@link RelationSupport#getRelationshipTypes()} for the given object. Callers can use either method. * See {@link AbstractBasicRelationSupport} for a discussion of why double dispatch is used and both methods are present. */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static <T extends BrooklynObject> Set<RelationshipType<? super T,? extends BrooklynObject>> getRelationshipTypes(T source) { return (Set) ((BrooklynObjectInternal)source).relations().getLocalBackingStore().getRelationshipTypes(); }
protected void setCatalogItemIds(BrooklynObject object, String catalogItemId, List<String> searchPath) { final BrooklynObjectInternal internal = (BrooklynObjectInternal) object; internal.setCatalogItemIdAndSearchPath(catalogItemId, searchPath); }
public static String getIconUrl(BrooklynObject object) { if (object==null) return null; NamedStringTag fromTag = BrooklynTags.findFirst(BrooklynTags.ICON_URL, object.tags().getTags()); if (fromTag!=null) return fromTag.getContents(); ManagementContext mgmt = ((BrooklynObjectInternal)object).getManagementContext(); if (mgmt==null) return null; BrooklynTypeRegistry registry = mgmt.getTypeRegistry(); if (registry==null) return null; RegisteredType item = registry.get( object.getCatalogItemId() ); if (item==null) return null; return item.getIconUrl(); }
public static void setCatalogItemIdOnAddition(Entity entity, BrooklynObject itemBeingAdded) { if (entity.getCatalogItemId()!=null) { if (itemBeingAdded.getCatalogItemId()==null) { if (log.isDebugEnabled()) BrooklynLogging.log(log, BrooklynLogging.levelDebugOrTraceIfReadOnly(entity), "Catalog item addition: "+entity+" from "+entity.getCatalogItemId()+" applying its catalog item ID to "+itemBeingAdded); final BrooklynObjectInternal addInternal = (BrooklynObjectInternal) itemBeingAdded; addInternal.setCatalogItemIdAndSearchPath(entity.getCatalogItemId(), entity.getCatalogItemIdSearchPath()); } else { if (!itemBeingAdded.getCatalogItemId().equals(entity.getCatalogItemId())) { // not a problem, but something to watch out for log.debug("Cross-catalog item detected: "+entity+" from "+entity.getCatalogItemId()+" has "+itemBeingAdded+" from "+itemBeingAdded.getCatalogItemId()); } } } else if (itemBeingAdded.getCatalogItemId()!=null) { if (log.isDebugEnabled()) BrooklynLogging.log(log, BrooklynLogging.levelDebugOrTraceIfReadOnly(entity), "Catalog item addition: "+entity+" without catalog item ID has "+itemBeingAdded+" from "+itemBeingAdded.getCatalogItemId()); } }
protected Maybe<Object> getRawValueAtContainer(TContainer container, ConfigKey<? extends Object> configKey) { return ((BrooklynObjectInternal)container).config().getInternalConfigMap().getConfigLocalRaw(configKey); } /** finds the value at the given container/key, taking in to account any resolution expected by the key (eg for map keys).
/** * As {@link RelationSupport#getRelations(RelationshipType)} for the given object. Callers can use either method. * See {@link AbstractBasicRelationSupport} for a discussion of why double dispatch is used and both methods are present. */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static <T extends BrooklynObject,U extends BrooklynObject> Set<U> getRelations(RelationshipType<? super T,U> relationship, T source) { return ((BrooklynObjectInternal)source).relations().getLocalBackingStore().getRelations((RelationshipType)relationship); }
@Override public void onChanged(BrooklynObject instance) { if (running && persister != null) { PersisterDeltaImpl delta = new PersisterDeltaImpl(); Memento memento = ((BrooklynObjectInternal)instance).getRebindSupport().getMemento(); if (instance instanceof Entity) { delta.entities.add((EntityMemento) memento); addEntityAdjuncts((Entity)instance, delta); } else if (instance instanceof Location) { delta.locations.add((LocationMemento) memento); } else if (instance instanceof Policy) { delta.policies.add((PolicyMemento) memento); } else if (instance instanceof Enricher) { delta.enrichers.add((EnricherMemento) memento); } else if (instance instanceof CatalogItem) { delta.catalogItems.add((CatalogItemMemento) instance); } else if (instance instanceof ManagedBundle) { delta.bundles.add((ManagedBundleMemento) memento); } else { throw new IllegalStateException("Unexpected brooklyn type: "+instance); } persister.delta(delta, exceptionHandler); } }
public static void dumpInfo(Feed feed, Writer out, String currentIndentation, String tab) throws IOException { out.append(currentIndentation+feed.toString()+"\n"); // TODO create a FeedType cf EnricherType ? for (ConfigKey<?> key : sortConfigKeys(((BrooklynObjectInternal)feed).config().getBag().getAllConfigAsConfigKeyMap().keySet())) { Maybe<Object> val = ((BrooklynObjectInternal)feed).config().getRaw(key); if (!isTrivial(val)) { out.append(currentIndentation+tab+tab+key); out.append(" = "); if (isSecret(key.getName())) out.append("xxxxxxxx"); else out.append(""+val.get()); out.append("\n"); } } out.flush(); }
/** * As {@link RelationSupport#remove(RelationshipType, BrooklynObject)} for the given object. Callers can use either method. * See {@link AbstractBasicRelationSupport} for a discussion of why double dispatch is used and both methods are present. */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static <T extends BrooklynObject,U extends BrooklynObject> void remove(T source, RelationshipType<? super T,? super U> relationship, U target) { ((BrooklynObjectInternal)source).relations().getLocalBackingStore().remove((RelationshipType)relationship, target); if (relationship.getInverseRelationshipType()!=null) ((BrooklynObjectInternal)target).relations().getLocalBackingStore().remove((RelationshipType)relationship.getInverseRelationshipType(), source); }
for (BrooklynObject instance: prevDeltaCollector.getCollectionOfType(type)) { try { persisterDelta.add(type, ((BrooklynObjectInternal)instance).getRebindSupport().getMemento()); } catch (Exception e) { exceptionHandler.onGenerateMementoFailed(type, instance, e);
/** an immutable copy of the config visible at this entity, local and inherited (preferring local) */ @Override @Deprecated public Map<ConfigKey<?>,Object> getAllConfig() { Map<ConfigKey<?>,Object> result = new LinkedHashMap<ConfigKey<?>,Object>(); if (getParent()!=null) result.putAll( getParentInternal().config().getInternalConfigMap().getAllConfig() ); putAllOwnConfigIntoSafely(result); return Collections.unmodifiableMap(result); }
/** * As {@link RelationSupport#add(RelationshipType, BrooklynObject)} for the given object. Callers can use either method. * See {@link AbstractBasicRelationSupport} for a discussion of why double dispatch is used and both methods are present. */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static <T extends BrooklynObject,U extends BrooklynObject> void add(T source, RelationshipType<? super T,? super U> relationship, U target) { ((BrooklynObjectInternal)source).relations().getLocalBackingStore().add((RelationshipType)relationship, target); if (relationship.getInverseRelationshipType()!=null) ((BrooklynObjectInternal)target).relations().getLocalBackingStore().add((RelationshipType)relationship.getInverseRelationshipType(), source); }
Memento m = ((BrooklynObjectInternal)bo).getRebindSupport().getMemento(); BrooklynMementoPersister p = rebindManager.getPersister(); String mr = ((BrooklynMementoPersisterToObjectStore)p).getMementoSerializer().toString(m);
public static void dumpInfo(Policy pol, Writer out, String currentIndentation, String tab) throws IOException { out.append(currentIndentation+pol.toString()+"\n"); for (ConfigKey<?> key : sortConfigKeys(pol.getPolicyType().getConfigKeys())) { Maybe<Object> val = ((BrooklynObjectInternal)pol).config().getRaw(key); if (!isTrivial(val)) { out.append(currentIndentation+tab+tab+key); out.append(" = "); if (isSecret(key.getName())) out.append("xxxxxxxx"); else out.append(""+val.get()); out.append("\n"); } } out.flush(); }
public static void dumpInfo(Enricher enr, Writer out, String currentIndentation, String tab) throws IOException { out.append(currentIndentation+enr.toString()+"\n"); for (ConfigKey<?> key : sortConfigKeys(enr.getEnricherType().getConfigKeys())) { Maybe<Object> val = ((BrooklynObjectInternal)enr).config().getRaw(key); if (!isTrivial(val)) { out.append(currentIndentation+tab+tab+key); out.append(" = "); if (isSecret(key.getName())) out.append("xxxxxxxx"); else out.append(""+val.get()); out.append("\n"); } } out.flush(); } public static void dumpInfo(Feed feed, String currentIndentation, String tab) throws IOException {
@Override public Map<String, Object> batchConfigRead(String application, String entityToken, String policyToken) { // TODO: add test Policy policy = brooklyn().getPolicy(application, entityToken, policyToken); Map<String, Object> source = ConfigBag.newInstance( ((BrooklynObjectInternal)policy).config().getInternalConfigMap().getAllConfigInheritedRawValuesIgnoringErrors() ).getAllConfig(); Map<String, Object> result = Maps.newLinkedHashMap(); for (Map.Entry<String, Object> ek : source.entrySet()) { result.put(ek.getKey(), getStringValueForDisplay(brooklyn(), policy, ek.getValue())); } return result; }
@Override @Deprecated public Maybe<Object> getConfigRaw(ConfigKey<?> key, boolean includeInherited) { // does not currently respect inheritance modes if (ownConfig.containsKey(key)) { return Maybe.of(ownConfig.get(key)); } for (String deprecatedName : key.getDeprecatedNames()) { // Unfortunately `config.putAll(map.of(string, val))` (for dynamic config keys, // i.e. where the key is not pre-defined on the entity). Unfortunately that // means subsequent lookup must synthesise keys for each deprecated name. ConfigKey<?> deprecatedKey = ConfigKeys.newConfigKeyRenamed(deprecatedName, key); if (ownConfig.containsKey(deprecatedKey)) { LOG.warn("Retrieving value with deprecated config key name '"+deprecatedName+"' for key "+key); return Maybe.of(ownConfig.get(deprecatedKey)); } } if (!includeInherited || getParent()==null) return Maybe.absent(); return getParentInternal().config().getInternalConfigMap().getConfigRaw(key, includeInherited); }
/** Creates an immutable copy of the config visible at this entity, local and inherited (preferring local), including those that did not match config keys */ @Deprecated public ConfigBag getAllConfigBag() { ConfigBag result = putAllOwnConfigIntoSafely(ConfigBag.newInstance()); if (getParent()!=null) { result.putIfAbsent( ((AbstractConfigMapImpl<?>)getParentInternal().config().getInternalConfigMap()).getAllConfigBag() ); } return result.seal(); }