You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by geomacy <gi...@git.apache.org> on 2016/09/21 09:05:51 UTC
[GitHub] brooklyn-server pull request #338: Not for merge, work in progress - testCat...
GitHub user geomacy opened a pull request:
https://github.com/apache/brooklyn-server/pull/338
Not for merge, work in progress - testCatalogItemIdInReferencedItems
For [testCatalogItemIdInReferencedItems](https://github.com/apache/brooklyn-server/blob/master/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java#L955), work in progress.
Current status, updates BrooklynObject and BrooklynObjectSpec to support nested catalogItemIds. This lets testCatalogItemIdInReferencedItems work in its modified form, i.e. it correctly identifies the nested items structure of outer/inner, but there is still plenty to do as noted below. The unit tests of brooklyn-server all work with this change in place, but will have to think about how to get good enough test coverage in place for this when remaining changes are done.
### TODO:
* doesn't include changes to persistence to allow the nested item ids to be persisted and retrieved during rebind
* Need to review what changes may be needed to EntityTransientCopyInternal.
* Looks like catalogItemIdIfNotNull can be removed.
### Things to review
Everything, really; but some things I made a note of particularly
* review places where setCatalogItemIdIfNotNull has been replaced with nestCatalogItemIds and see if they make sense from a sanity viewpoint
* review use of setCatalogItemIds()
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/geomacy/brooklyn-server catalog-update
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/brooklyn-server/pull/338.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #338
----
commit 0b4fc215d32a274f5839cbe18d54f1c0d6959074
Author: Geoff Macartney <ge...@cloudsoftcorp.com>
Date: 2016-09-14T13:44:14Z
Osgi loader change
commit 3f97a65c7222fd30ebbf3137b02e2db9e51214d0
Author: Geoff Macartney <ge...@cloudsoftcorp.com>
Date: 2016-09-19T13:22:43Z
Add nested catalog item ids to AbstractBrooklynObjectSpec.
commit 6f73177888fd332e56be4ed61a371617095950b8
Author: Geoff Macartney <ge...@cloudsoftcorp.com>
Date: 2016-09-20T10:16:36Z
Add catalog item super id support.
commit b945ec1865b11ef0477fb77a54d7863bc4409108
Author: Geoff Macartney <ge...@cloudsoftcorp.com>
Date: 2016-09-20T14:51:47Z
Fixes to get CatalogYamlEntityTest.testCatalogItemIdInReferencedItems working.
Haven't re-run all unit tests yet.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
Still going through it, but so far looks really good.
The test `CatalogYamlRebindTest.testRebindWithCatalogAndAppRebindCatalogItemIds` seems to take a long time (28s). I'll look at it as part of this, and if it's quick to fix I'll just do it.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
Caught up and rebased against master.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
@neykov, have addressed some of the review comments, see the links in the commit messages. Will add a couple more remarks above.
The main outstanding changes are those from the comments on CatalogUtils from 5th January https://github.com/apache/brooklyn-server/pull/338#discussion_r94623208, and on AbstractBrooklynObject https://github.com/apache/brooklyn-server/pull/338#discussion_r94763625. I can just get on with doing the former but the latter will need a bit of thought and more discussion.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
As for `catalogItemId`, I think we should continue to populate and persist this. It is useful to know from whence something came, and for audit purposes this will become even more important: e.g. which version is it running. I realize for persistence purposes we can get the exact same class back using the search paths, but we want to be able to find instances of `item:1.0` e.g. so we can upgrade them to `item:2.0`, and I think without the `catalogItemId` field we won't be able to do that. WDYT?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94763625
--- Diff: core/src/main/java/org/apache/brooklyn/core/objs/AbstractBrooklynObject.java ---
@@ -80,7 +84,7 @@ public AbstractBrooklynObject(Map<?, ?> properties) {
_legacyConstruction = true;
}
- catalogItemId = ApiObjectsFactory.get().getCatalogItemIdFromContext();
+ setCatalogItemId(ApiObjectsFactory.get().getCatalogItemIdFromContext());
--- End diff --
Previously `catalogItemId` would be overwritten by any code that knows better. Now most locations should be calling `nestCatalogItemId`. Could this introduce a non-completely-correct inner-most catalog item?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94763362
--- Diff: core/src/main/java/org/apache/brooklyn/core/objs/AbstractBrooklynObject.java ---
@@ -51,7 +55,7 @@
@SetFromFlag("id")
private String id = Identifiers.makeRandomLowercaseId(10);
- private String catalogItemId;
+ private Deque<String> catalogItemIdStack = new ArrayDeque<>();
--- End diff --
`BrooklynObject`s get created by calling their constructors so removing `catalogItemId` and initializing `catalogItemIdStack` should be safe.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94612120
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -22,9 +22,12 @@
import java.io.Serializable;
import java.lang.reflect.Modifier;
+import java.util.ArrayDeque;
import java.util.Collections;
+import java.util.Deque;
import java.util.List;
import java.util.Map;
+import java.util.Queue;
--- End diff --
Unused import
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94751531
--- Diff: core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindIteration.java ---
@@ -910,70 +911,55 @@ protected Entity newEntity(EntityMementoManifest entityManifest) {
((AbstractEntity)entity).setManagementContext(managementContext);
managementContext.prePreManage(entity);
}
-
- setCatalogItemId(entity, transformedCatalogItemId);
+
+ setCatalogItemIds(entity, loaded.catalogItemIds);
+
return entity;
}
- protected void setCatalogItemId(BrooklynObject item, String catalogItemId) {
- if (catalogItemId!=null) {
- ((BrooklynObjectInternal)item).setCatalogItemId(catalogItemId);
- }
+ protected void setCatalogItemIds(BrooklynObject object, List<String> superIds) {
+ ((BrooklynObjectInternal)object).setCatalogItemIds(superIds);
}
+
protected <T extends BrooklynObject> LoadedClass<? extends T> load(Class<T> bType, Memento memento) {
- return load(bType, memento.getType(), memento.getCatalogItemId(), memento.getId());
+ return load(bType, memento.getType(), memento.getCatalogItemSuperIds(), memento.getId());
}
@SuppressWarnings("unchecked")
- protected <T extends BrooklynObject> LoadedClass<? extends T> load(Class<T> bType, String jType, String catalogItemId, String contextSuchAsId) {
+ protected <T extends BrooklynObject> LoadedClass<? extends T> load(Class<T> bType, String jType, List<String> catalogItemIds, String contextSuchAsId) {
checkNotNull(jType, "Type of %s (%s) must not be null", contextSuchAsId, bType.getSimpleName());
-
- if (catalogItemId != null) {
- CatalogItem<?, ?> catalogItem = rebindContext.lookup().lookupCatalogItem(catalogItemId);
- if (catalogItem == null) {
- if (BrooklynFeatureEnablement.isEnabled(BrooklynFeatureEnablement.FEATURE_AUTO_FIX_CATALOG_REF_ON_REBIND)) {
- // See https://issues.apache.org/jira/browse/BROOKLYN-149
- // This is a dangling reference to the catalog item (which will have been logged by lookupCatalogItem).
- // Try loading as any version.
- if (CatalogUtils.looksLikeVersionedId(catalogItemId)) {
- String symbolicName = CatalogUtils.getSymbolicNameFromVersionedId(catalogItemId);
- catalogItem = rebindContext.lookup().lookupCatalogItem(symbolicName);
-
- if (catalogItem != null) {
- LOG.warn("Unable to load catalog item "+catalogItemId+" for "+contextSuchAsId
- +" ("+bType.getSimpleName()+"); will auto-upgrade to "+catalogItem.getCatalogItemId());
- catalogItemId = catalogItem.getCatalogItemId();
- }
- }
- }
- }
- if (catalogItem != null) {
- BrooklynClassLoadingContext loader = CatalogUtils.newClassLoadingContext(managementContext, catalogItem);
- return new LoadedClass<T>(loader.loadClass(jType, bType), catalogItemId);
+
+ List<String> idsFromReboundCatalog = MutableList.of();
+ if (catalogItemIds != null && !catalogItemIds.isEmpty()) {
+ findCatalogIdsInReboundCatalog(bType, catalogItemIds, contextSuchAsId, idsFromReboundCatalog);
+ if (idsFromReboundCatalog.size() == catalogItemIds.size()) {
+ BrooklynClassLoadingContext loader = CatalogUtils.newClassLoadingContextForCatalogItems(managementContext, idsFromReboundCatalog);
+ return new LoadedClass<T>(loader.loadClass(jType, bType), idsFromReboundCatalog);
} else {
- LOG.warn("Unable to load catalog item "+catalogItemId+" for "+contextSuchAsId
+ LOG.warn("Unable to load all catalog items "+ Iterables.toString(catalogItemIds) +" for "+contextSuchAsId
--- End diff --
Fall through only if `loader.loadClass(jType, bType)` fails with the available catalog items. Any catalog items being able to load the class here is better than any of the fall backs.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94617757
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -187,7 +202,24 @@ public final String getDisplayName() {
}
public final String getCatalogItemId() {
- return catalogItemId;
+ if (catalogItemIdStack.size() != 0) {
+ return catalogItemIdStack.getFirst();
+ }
+ return null;
+ }
+
+ /**
+ * An immutable list of ids of this object's catalog item and its defining catalog items.
+ * e.g. if the catalog item is defined as
+ * <pre>
+ * items:
+ * - id: X
+ * item: Y
+ * </pre>
+ * then the list will contain X, Y.
--- End diff --
Can you add as a clarification something like - wrapping items are first in the list (or wrapping items precede wrapped items)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94752687
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -65,7 +68,7 @@
private final Class<? extends T> type;
private String displayName;
- private String catalogItemId;
--- End diff --
Keep for persistence backwards compatibility
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Not for merge, work in progress - testCat...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r79872120
--- Diff: core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogUtils.java ---
@@ -170,6 +173,13 @@ public static void installLibraries(ManagementContext managementContext, @Nullab
public static String getCatalogItemIdFromLoader(BrooklynClassLoadingContext loader) {
if (loader instanceof OsgiBrooklynClassLoadingContext) {
return ((OsgiBrooklynClassLoadingContext)loader).getCatalogItemId();
+ } else if (loader instanceof BrooklynClassLoadingContextSequential) {
+ final Iterator<BrooklynClassLoadingContext> iterator = ((BrooklynClassLoadingContextSequential) loader).getPrimaries().iterator();
+ if (iterator.hasNext()) {
+ BrooklynClassLoadingContext osgiLoader = iterator.next();
+ return getCatalogItemIdFromLoader(osgiLoader);
+ }
+ else return null;
--- End diff --
Comment from @neykov ([here](https://github.com/neykov/brooklyn-server/pull/3#discussion_r79803301)):
Need to revisit this logic in light of latest updates.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94619869
--- Diff: api/src/main/java/org/apache/brooklyn/api/mgmt/rebind/mementos/Memento.java ---
@@ -43,11 +44,19 @@
String getId();
- public String getType();
-
- public String getCatalogItemId();
-
- public String getDisplayName();
+ String getType();
+
+ /**
+ * The principal catalog item id.
+ */
+ String getCatalogItemId();
--- End diff --
This is just for persistence backwards compatibility, right? If so mark it as deprecated.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Not for merge, work in progress - testCat...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r80220390
--- Diff: core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractManagementContext.java ---
@@ -128,20 +128,18 @@ private static DataGridFactory loadDataGridFactory(BrooklynProperties properties
public BrooklynClassLoadingContext apply(@Nullable Object input) {
if (input instanceof EntityInternal) {
EntityInternal internal = (EntityInternal)input;
- if (internal.getCatalogItemId() != null) {
- RegisteredType item = internal.getManagementContext().getTypeRegistry().get(internal.getCatalogItemId());
-
- if (item != null) {
- BrooklynClassLoadingContext itemLoader = CatalogUtils.newClassLoadingContext(internal.getManagementContext(), item);
- // Falls back to the entity's class loader
- JavaBrooklynClassLoadingContext entityLoader = JavaBrooklynClassLoadingContext.create(input.getClass().getClassLoader());
- BrooklynClassLoadingContext seqLoader = new BrooklynClassLoadingContextSequential(internal.getManagementContext(), itemLoader, entityLoader);
- return seqLoader;
- } else {
- log.error("Can't find catalog item " + internal.getCatalogItemId() +
- " used for instantiating entity " + internal +
- ". Falling back to application classpath.");
+ final List<String> catalogItemSuperIds = internal.getCatalogItemSuperIds();
+ if (catalogItemSuperIds.size() > 0) {
+ BrooklynClassLoadingContextSequential seqLoader = new BrooklynClassLoadingContextSequential(internal.getManagementContext());
+ for (String catalogItemId : catalogItemSuperIds) {
--- End diff --
Agree, the entity could be coming from another place like the white list (included in the distribution). Makes sense to include the entity's class loader as well.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
@ahgittin, @neykov I've made the changes to rework the previous commits as suggested by Alex, so instead of a single stack of catalogItemIds, the original catalogItemId is preserved and a searchPath is added.
I haven't included updates to address the TODO items in #573 here. I did make a start on that but found some issues, so I have included those changes in a separate PR, https://github.com/apache/brooklyn-server/pull/604. Perhaps we can treat that as a separate issue and review this one in its own right.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94621436
--- Diff: core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogUtils.java ---
@@ -170,6 +173,13 @@ public static void installLibraries(ManagementContext managementContext, @Nullab
public static String getCatalogItemIdFromLoader(BrooklynClassLoadingContext loader) {
if (loader instanceof OsgiBrooklynClassLoadingContext) {
return ((OsgiBrooklynClassLoadingContext)loader).getCatalogItemId();
+ } else if (loader instanceof BrooklynClassLoadingContextSequential) {
+ final Iterator<BrooklynClassLoadingContext> iterator = ((BrooklynClassLoadingContextSequential) loader).getPrimaries().iterator();
+ if (iterator.hasNext()) {
+ BrooklynClassLoadingContext osgiLoader = iterator.next();
+ return getCatalogItemIdFromLoader(osgiLoader);
+ }
+ else return null;
--- End diff --
Can you remind me, is this still needed? What was the use case.
Should it return a list of catalog ids now?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
Very cool. Haven't reviewed in depth but looks on point at a high level. A few specific comments:
* this will conflict with https://github.com/apache/brooklyn-server/pull/573 -- should be easy to resolve, and this is a better solution to the underlying problem
* I think we want _both_ `catalogItemId` with the semantics of #573 and the `stack` introduced here for searching, on the spec (that's what we have on entity)
* there may be persistence errors migrating from older version if we persist specs and remove the `catalogItemId` here (?); the previous suggestion to keep both should resolve this (perhaps with an additional check when initializing an entity that if `catalogItemId` is set then `stack.get(0)` equals that id
And one general comment -- there is an issue if e.g. `my-cluster` and `my-node` are set in the same BOM, both at version `1` with the former referring to the latter omitting the version. If we then install a version `2` of that bom, then `my-cluster:1` creates a cluster of `my-node:2` which is surprising. It would be nice to solve that (and also be able to retrieve the `bom` file and bundle list where an entity is defined, for subsequent editting). It's a separate problem to this, but the solutions may be interrelated. Very happy to have this merged (once someone else does a detailed review and we resolve #573 conflicts) without solving the version and catalog-group / bom questions, expecting a bit more change afterwards, but wanted to flag that. cc @geomacy @neykov @aledsage
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94752045
--- Diff: core/src/main/java/org/apache/brooklyn/core/location/access/PortForwardManagerClient.java ---
@@ -19,13 +19,15 @@
package org.apache.brooklyn.core.location.access;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.location.Location;
import org.apache.brooklyn.api.sensor.AttributeSensor;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.config.ConfigKey.HasConfigKey;
+import org.apache.brooklyn.core.location.AbstractLocation;
--- End diff --
Unused
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
been through it. looks good. may be some subtleties which will only come out as we use it but feels like the right idea and rightly done. minor changes. i'll look at the failing test -- seems like a real problem, maybe due to not deduping the list? -- then merge with the fix, unless there is anything non-obvious.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94613348
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -99,23 +102,35 @@ public SpecT displayName(String val) {
}
public SpecT catalogItemId(String val) {
- catalogItemId = val;
+ catalogItemIdStack.clear();
+ return nestCatalogItemId(val);
+ }
+
+ public SpecT catalogItemIds(List<String> ids) {
+ catalogItemIdStack.clear();
+ catalogItemIdStack.addAll(ids);
return self();
}
- // TODO in many places (callers to this method) we prefer a wrapper item ID;
- // that is right, because the wrapper's defn will refer to the wrapped,
- // but we might need also to collect the item ID's so that *all* can be searched.
- // e.g. if R3 references R2 which references R1 any one of these might supply config keys
- // referencing resources or types in their local bundles.
+
+ /**
+ * Adds (stacks) the catalog item id of a wrapping specification.
+ * Does nothing if the value is null.
+ *
+ * Used when we to collect nested item ID's so that *all* can be searched.
+ * e.g. if R3 references R2 which references R1 any one of these might supply config keys
--- End diff --
It's not a mere reference but R3 **extending** R2, etc.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94620662
--- Diff: camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/RebindOsgiTest.java ---
@@ -63,6 +67,8 @@
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
+import javax.xml.xpath.XPathConstants;
--- End diff --
Unused, plus Strings, XmlUtil.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r112699602
--- Diff: core/src/main/java/org/apache/brooklyn/core/objs/AbstractBrooklynObject.java ---
@@ -83,11 +90,18 @@ public AbstractBrooklynObject(Map<?, ?> properties) {
// correct behaviour should be to inherit context's search path, perhaps, though maybe that's better done as spec?
// in any case, should not define it as _the_ catalog item ID; also see assignment based on parent
// in CatalogUtils.setCatalogItemIdOnAddition
- catalogItemId = ApiObjectsFactory.get().getCatalogItemIdFromContext();
+ setCatalogItemId(ApiObjectsFactory.get().getCatalogItemIdFromContext());
--- End diff --
context ID should be added to the _search path_ not used to set the ID of the item itself -- this was the problem spot that prompted keeping the IDs separate
and can remove the TODO now! :)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94616812
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -187,7 +202,24 @@ public final String getDisplayName() {
}
public final String getCatalogItemId() {
--- End diff --
Suggest deprecating this one and creating `getOuterCatalogItemId`, `getInnerCatalogItemId`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
Caught up and rebased against master.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94756103
--- Diff: core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/EntityMementoManifestImpl.java ---
@@ -50,7 +54,12 @@ public String getParent() {
@Override
public String getCatalogItemId() {
- return catalogItemId;
+ return Iterables.getFirst(catalogItemIds, null);
--- End diff --
Remove/deprecate this method and use `getCatalogItemSuperIds` instead in callers.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94620517
--- Diff: camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigInheritanceYamlTest.java ---
@@ -39,6 +39,7 @@
import org.apache.brooklyn.core.test.entity.TestEntity;
import org.apache.brooklyn.core.test.entity.TestEntityImpl;
import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
+import org.apache.brooklyn.entity.software.base.SoftwareProcess;
--- End diff --
Unused.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
Thanks @ahgittin I will have a look at #573 hopefully today or very soon. Nice to have extra tests!
Regarding the persistence, basically in the persisted XML my change replaces `<catalogItemId>` with the hierarchy of the catalog ids that defined the item (so if `foo` is defined as an extension of `bam` which is in turn a `bar`, you get
```
<catalogItemIdHierarchy>
<string>foo</string>
<string>bam</string>
<string>bar</string>
</catalogItemIdHierarchy>
```
so I am continuing to populate and persist catalogItemId, just implemented as this list. Also I have code in place to handle previously persisted state (still using `<catalogItemId>foo</catalogItemId>`) and load it into this new model.
Re. the question of upgrades from 1.0 to 2.0 I will need to have a look at it, I can't remember what the test coverage is like for this scenario (I think there are some tests).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94762563
--- Diff: core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/AbstractMemento.java ---
@@ -85,7 +103,9 @@ public B customFields(Map<String,?> vals) {
private String type;
private String id;
private String displayName;
- private String catalogItemId;
+ // catalogItemId is retained to support rebind of previously persisted state (prior to catalogItemSuperIds)
+ protected String catalogItemId;
+ private List<String> catalogItemSuperIds = MutableList.of();
--- End diff --
Constructors are not called during xstream deserialization so this is not guaranteed to be non-null. Might be better to leave it null and explicitly deal with it in the code (as you already do) - to prevent others making false assumptions about the code.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
I expect the code comments introduced in #573 will clear up https://github.com/apache/brooklyn-server/pull/338#discussion_r94763625 .
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94762969
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -65,7 +68,7 @@
private final Class<? extends T> type;
private String displayName;
- private String catalogItemId;
+ private Deque<String> catalogItemIdStack = new ArrayDeque<>();
--- End diff --
Not called on xstream deserialize, could be null - take into account in following code.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r112693227
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -51,21 +54,23 @@
* <p>
* In addition to the contract defined by the code,
* subclasses should provide a public static <code>create(Class)</code>
- * method to create an instance of the spec for the target type indicated by the argument.
+ * method to create an instance of the spec for the target type indicated by the argument.
* <p>
* The spec is then passed to type-specific methods,
* e.g. {@link EntityManager#createEntity(org.apache.brooklyn.api.entity.EntitySpec)}
* to create a managed instance of the target type.
*/
-public abstract class AbstractBrooklynObjectSpec<T,SpecT extends AbstractBrooklynObjectSpec<T,SpecT>> implements Serializable {
+public abstract class AbstractBrooklynObjectSpec<T, SpecT extends AbstractBrooklynObjectSpec<T, SpecT>> implements Serializable {
private static final long serialVersionUID = 3010955277740333030L;
private static final Logger log = LoggerFactory.getLogger(AbstractBrooklynObjectSpec.class);
-
+
private final Class<? extends T> type;
private String displayName;
private String catalogItemId;
+ private Deque<String> catalogItemIdSearchPath = new ArrayDeque<>();
--- End diff --
minor - would be nice to avoid duplicates
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94618204
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -187,7 +202,24 @@ public final String getDisplayName() {
}
public final String getCatalogItemId() {
- return catalogItemId;
+ if (catalogItemIdStack.size() != 0) {
+ return catalogItemIdStack.getFirst();
+ }
+ return null;
+ }
+
+ /**
+ * An immutable list of ids of this object's catalog item and its defining catalog items.
+ * e.g. if the catalog item is defined as
+ * <pre>
+ * items:
+ * - id: X
+ * item: Y
+ * </pre>
+ * then the list will contain X, Y.
+ */
+ public final List<String> getCatalogItemSuperIds() {
--- End diff --
`Super` (here and same name in other classes) could be misinterpreted as in "don't include the outer-most item" - just leave it out? Alternatives: `getCatalogItemHierarchy`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r102679601
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -65,7 +68,7 @@
private final Class<? extends T> type;
private String displayName;
- private String catalogItemId;
--- End diff --
surely I take this into account already? See testRebindWithCatalogAndAppRebindCatalogItemIds,
and BrooklynMementoPersisterToObjectStore.getCatalogItemIds().
Could add it back but maybe don't need to?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
Thanks @ahgittin and @neykov for comments; I will try to address the remaining items as noted above (https://github.com/apache/brooklyn-server/pull/338#issuecomment-281950519) soon.
I will have a look at #573 to see how this can be merged with it.
Just on the point of omitting or retaining the `catalogItemId` member (https://github.com/apache/brooklyn-server/pull/338#discussion_r102679601), for rebind purposes, what do you think of my changes to `BrooklynMementoPersisterToObjectStore` which as far as I can see allow me to avoid keeping that member. I am able to re-run all the tests from `testRebindWithCatalogAndApp` with persisted content with the format prior to this change (see https://github.com/apache/brooklyn-server/pull/338/files#diff-3804f33dfb6d89e123adcff13f9c114dR173). It looked to me as if we don't need to retain that member, hence the changes above, but if you think there's another case to cover then I can put it back (and will probably need to think about adding more tests to catch that case).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Not for merge, work in progress - testCat...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r79871837
--- Diff: core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogItemDtoAbstract.java ---
@@ -45,6 +45,8 @@
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
+// TODO add support for nested catalog items, implement nestCatalogItemId in terms of symbolicName/Version
+// TODO also getCatalogItemSuperIds.
--- End diff --
Comment from @neykov ([here](https://github.com/neykov/brooklyn-server/pull/3#discussion_r79803420)):
I think we should either override with NOPs, or just keep the default behaviour from AbstractBrooklynObject. The catalog items don't know what's the meaning of the plan in them.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94616318
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -99,23 +102,35 @@ public SpecT displayName(String val) {
}
public SpecT catalogItemId(String val) {
- catalogItemId = val;
+ catalogItemIdStack.clear();
+ return nestCatalogItemId(val);
+ }
+
+ public SpecT catalogItemIds(List<String> ids) {
+ catalogItemIdStack.clear();
+ catalogItemIdStack.addAll(ids);
return self();
}
- // TODO in many places (callers to this method) we prefer a wrapper item ID;
- // that is right, because the wrapper's defn will refer to the wrapped,
- // but we might need also to collect the item ID's so that *all* can be searched.
- // e.g. if R3 references R2 which references R1 any one of these might supply config keys
- // referencing resources or types in their local bundles.
+
+ /**
+ * Adds (stacks) the catalog item id of a wrapping specification.
+ * Does nothing if the value is null.
+ *
+ * Used when we to collect nested item ID's so that *all* can be searched.
+ * e.g. if R3 references R2 which references R1 any one of these might supply config keys
+ * referencing resources or types in their local bundles.
+ */
@Beta
- public SpecT catalogItemIdIfNotNull(String val) {
- if (val!=null) {
- catalogItemId = val;
+ public SpecT nestCatalogItemId(String val) {
--- End diff --
I don't associate "nest" with anything in this context, perhaps `stackCatalogItemId` would be more appropriate?
What about `wrapCatalogItemId`, `extendingCatalogItemId`, `pushOuterCatalogItemId`?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94609346
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -99,23 +102,35 @@ public SpecT displayName(String val) {
}
public SpecT catalogItemId(String val) {
- catalogItemId = val;
+ catalogItemIdStack.clear();
+ return nestCatalogItemId(val);
+ }
+
+ public SpecT catalogItemIds(List<String> ids) {
+ catalogItemIdStack.clear();
+ catalogItemIdStack.addAll(ids);
return self();
}
- // TODO in many places (callers to this method) we prefer a wrapper item ID;
- // that is right, because the wrapper's defn will refer to the wrapped,
- // but we might need also to collect the item ID's so that *all* can be searched.
- // e.g. if R3 references R2 which references R1 any one of these might supply config keys
- // referencing resources or types in their local bundles.
+
+ /**
+ * Adds (stacks) the catalog item id of a wrapping specification.
+ * Does nothing if the value is null.
+ *
+ * Used when we to collect nested item ID's so that *all* can be searched.
--- End diff --
missing word - `we to collect`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
i think #646 adds what is missing for those tests to run better - TBC tho!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94618943
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -99,23 +102,35 @@ public SpecT displayName(String val) {
}
public SpecT catalogItemId(String val) {
- catalogItemId = val;
+ catalogItemIdStack.clear();
+ return nestCatalogItemId(val);
+ }
+
+ public SpecT catalogItemIds(List<String> ids) {
+ catalogItemIdStack.clear();
+ catalogItemIdStack.addAll(ids);
return self();
}
- // TODO in many places (callers to this method) we prefer a wrapper item ID;
- // that is right, because the wrapper's defn will refer to the wrapped,
- // but we might need also to collect the item ID's so that *all* can be searched.
- // e.g. if R3 references R2 which references R1 any one of these might supply config keys
- // referencing resources or types in their local bundles.
+
+ /**
+ * Adds (stacks) the catalog item id of a wrapping specification.
+ * Does nothing if the value is null.
+ *
+ * Used when we to collect nested item ID's so that *all* can be searched.
+ * e.g. if R3 references R2 which references R1 any one of these might supply config keys
+ * referencing resources or types in their local bundles.
+ */
@Beta
- public SpecT catalogItemIdIfNotNull(String val) {
--- End diff --
I'd deprecate it, even if marked as `@Beta`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94623208
--- Diff: core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogUtils.java ---
@@ -318,4 +327,26 @@ public static void setDisabled(ManagementContext mgmt, String symbolicName, Stri
mgmt.getCatalog().persist(item);
}
+ public static BrooklynClassLoadingContextSequential newClassLoadingContextForCatalogItems(
--- End diff --
Some (non-exhaustive) candidates to migrate to this method:
* [`ClassLoaderUtils:229`](https://github.com/geomacy/brooklyn-server/blob/cf5afcfc853498be2ffefd2c9eed7ac17b3376a0/core/src/main/java/org/apache/brooklyn/util/core/ClassLoaderUtils.java#L229)
* [`BrooklynMementoPersisterToObjectStore:189`](https://github.com/geomacy/brooklyn-server/blob/cf5afcfc853498be2ffefd2c9eed7ac17b3376a0/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterToObjectStore.java#L189)
* [`XmlMementoSerializer:496`](https://github.com/geomacy/brooklyn-server/blob/cf5afcfc853498be2ffefd2c9eed7ac17b3376a0/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/XmlMementoSerializer.java#L496)
Also any place that uses `getCatalogItemId` should start using either `getOuterCatalogItemId` or `getCatalogItemSuperIds`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94753362
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -187,7 +202,24 @@ public final String getDisplayName() {
}
public final String getCatalogItemId() {
- return catalogItemId;
+ if (catalogItemIdStack.size() != 0) {
+ return catalogItemIdStack.getFirst();
+ }
+ return null;
--- End diff --
As a fallback return `catalogItemId`. To fix the persisted state could move the value to `catalogItemIdStack`. Alternatively implement [`readResolve`](https://github.com/apache/brooklyn-server/blob/master/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java#L78-L84) method to patch the object - called by xstream.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/brooklyn-server/pull/338
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
Hi @geomacy - have added another commit to #573 ; hadn't realized other inheritance semantics re catalog item id. It now has tests and several explicit TODO comments which this PR should look at. If you've done this right all those TODOs should be resolved or trivially resolvable, but there were quite a few so I marked anything that might be able to fall through the cracks.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94618471
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -187,7 +202,24 @@ public final String getDisplayName() {
}
public final String getCatalogItemId() {
- return catalogItemId;
+ if (catalogItemIdStack.size() != 0) {
+ return catalogItemIdStack.getFirst();
+ }
+ return null;
+ }
+
+ /**
+ * An immutable list of ids of this object's catalog item and its defining catalog items.
+ * e.g. if the catalog item is defined as
+ * <pre>
+ * items:
+ * - id: X
+ * item: Y
+ * </pre>
+ * then the list will contain X, Y.
+ */
+ public final List<String> getCatalogItemSuperIds() {
+ return ImmutableList.copyOf(catalogItemIdStack);
}
public final Set<Object> getTags() {
--- End diff --
Lots of naming suggestions above - can be treated as bikeshedding/personal preference.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94751965
--- Diff: core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogUtils.java ---
@@ -318,4 +327,26 @@ public static void setDisabled(ManagementContext mgmt, String symbolicName, Stri
mgmt.getCatalog().persist(item);
}
+ public static BrooklynClassLoadingContextSequential newClassLoadingContextForCatalogItems(
--- End diff --
Return a generic `BrooklynClassLoadingContext` and create a new `BrooklynClassLoadingContextSequential` in the caller, adding the return value - it has smarts to figure out it's dealing with `BrooklynClassLoadingContextSequential`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
@geomacy I think we want `catalogItemId` explicit as the catalog item ID of the item, in addition to the "hierarchy" (which is maybe better called `catalogItemsSearchPath` ?). It is a separate concept, and feels messy assuming the first in the hierarchy is the ID of the item (would be cleaner IMO to always put the ID of the item at the top of the hierarchy and drop the hierarchy if superfluous). We also need to be able to tell if an item does not have a catalog item ID (but possibly things in a search path from its creation context) eg it was created straight from a java class.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Not for merge, work in progress - testCatalogIte...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
Latest update - adds resource lookup from nested catalog definitions.
Nested resources already have a test, [`testIndirectCatalogItemCanLoadResources`](https://github.com/geomacy/brooklyn-server/blob/master/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java#L919), which succeeds, however, this is because of the workaround @neykov mentions [here](https://github.com/geomacy/brooklyn-server/blob/master/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java#L952-L953).
The latest couple of commits above first introduce a test, `testDeepCatalogItemCanLoadResources`, which illustrates that the workaround doesn't cover the more general case, and then updates the resource loading code to use the nested catalog item ids to load resources, which fixes the test.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94762655
--- Diff: core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/transformer/CompoundTransformer.java ---
@@ -179,21 +180,29 @@ public Builder renameField(String clazz, String oldVal, String newVal) {
}
/** Changes the contents of an XML tag 'catalogItemId' where the
* old text matches oldSymbolicName and optionally oldVersion
- * to have newSymbolicName and newVersion.
+ * to have newSymbolicName and newVersion.
* <p>
+ * Also changes contents of elements within a list of 'catalogItemSuperIds' e.g.
+ * <pre>
+ * <catalogItemSuperIds>
+ * <string>one</string>
+ * <string>two</string>
+ * </catalogItemSuperIds>
--- End diff --
Change the `>` to `>`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94756363
--- Diff: core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindIteration.java ---
@@ -792,12 +793,12 @@ protected String findCatalogItemId(ClassLoader cl, Map<String, EntityMementoMani
if (ptr.getCatalogItemId() != null) {
--- End diff --
Use and return `getCatalogItemSuperIds` instead.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94615424
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -99,23 +102,35 @@ public SpecT displayName(String val) {
}
public SpecT catalogItemId(String val) {
- catalogItemId = val;
+ catalogItemIdStack.clear();
+ return nestCatalogItemId(val);
+ }
+
+ public SpecT catalogItemIds(List<String> ids) {
+ catalogItemIdStack.clear();
+ catalogItemIdStack.addAll(ids);
--- End diff --
Don't see this used, do you think we should keep it?
Since catalog items are added in reverse order is it fine to add the list as is, should it be reversed?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94612579
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -99,23 +102,35 @@ public SpecT displayName(String val) {
}
public SpecT catalogItemId(String val) {
--- End diff --
Should we deprecate this one? When is this one used vs `nestCatalogItemId`?
I'd think (before looking at the code in details) that this shouldn't be called at all, we should only be "nesting" catalog items.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r112694452
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -91,26 +96,39 @@ public String toString() {
}
protected abstract void checkValidType(Class<? extends T> type);
-
+
public SpecT displayName(String val) {
displayName = val;
return self();
}
-
- /** Set the catalog item ID that defined this object, also used for searching for type and resources referenced */
- // since https://issues.apache.org/jira/browse/BROOKLYN-445 this must no longer be used to indicate
- // a caller-context catalog item that should be used for search purposes;
- // if that behaviour is desired, the child should be refactored to be its own item in the catalog BOM
- // (or TODO we add a separate field to record other catalog item IDs that could be applied for searching, see below)
+
+ /**
+ * Set the catalog item ID that defined this object;
+ * since https://issues.apache.org/jira/browse/BROOKLYN-445 this must no longer be used to indicate
+ * a caller-context catalog item that should be used for search purposes;
+ * instead use {@link #catalogItemIdAndSearchPath}.
+ */
public SpecT catalogItemId(String val) {
catalogItemId = val;
return self();
}
- // TODO in many places (callers to this method) we prefer a wrapper item ID;
- // that is right, because the wrapper's defn will refer to the wrapped,
- // but we might need also to collect the item ID's so that *all* can be searched, see #catalogItemId.
- // e.g. if R3 references R2 which references R1 any one of these might supply config keys
- // referencing resources or types in their local bundles.
+
+ /**
+ * Set the immediate catalog item ID of this object, and the search path of other catalog items used to define it.
+ */
+ public synchronized SpecT catalogItemIdAndSearchPath(String catalogItemId, Collection<String> searchPath) {
+ if (catalogItemId != null) {
--- End diff --
what is the reason for this behaviour on null? ignoring searchPath seems weird.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
Caught up and rebased against master. Going to make a start on the review comments from Svet.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
Thanks for the detailed review comments @neykov, will work through them as soon as I get a chance.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r104922028
--- Diff: core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogUtils.java ---
@@ -318,4 +327,26 @@ public static void setDisabled(ManagementContext mgmt, String symbolicName, Stri
mgmt.getCatalog().persist(item);
}
+ public static BrooklynClassLoadingContextSequential newClassLoadingContextForCatalogItems(
--- End diff --
Have done `ClassLoaderUtils:229` and `BrooklynMementoPersisterToObjectStore:189`, but `XmlMementoSerializer` is calling `newClassLoadingContext(ManagementContext mgmt, RegisteredType item)` rather than `ewClassLoadingContext(ManagementContext mgmt, CatalogItem<?, ?> item)`, and the hierarchy is not available on `RegisteredType`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r102679856
--- Diff: api/src/main/java/org/apache/brooklyn/api/internal/AbstractBrooklynObjectSpec.java ---
@@ -187,7 +202,24 @@ public final String getDisplayName() {
}
public final String getCatalogItemId() {
- return catalogItemId;
+ if (catalogItemIdStack.size() != 0) {
+ return catalogItemIdStack.getFirst();
+ }
+ return null;
--- End diff --
Seems preferable not to retain catalogItemId if we can get away without it, see
comment https://github.com/apache/brooklyn-server/pull/338#discussion_r102679601 above.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94753587
--- Diff: core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogUtils.java ---
@@ -318,4 +327,26 @@ public static void setDisabled(ManagementContext mgmt, String symbolicName, Stri
mgmt.getCatalog().persist(item);
}
+ public static BrooklynClassLoadingContextSequential newClassLoadingContextForCatalogItems(
+ ManagementContext managementContext, List<String> catalogItemIds) {
+
+ BrooklynClassLoadingContextSequential seqLoader =
+ new BrooklynClassLoadingContextSequential(managementContext);
+ for (String catalogItemId : catalogItemIds) {
+ addCatalogItemContext(managementContext, seqLoader, catalogItemId);
+ }
+ return seqLoader;
+ }
+
+ private static void addCatalogItemContext(ManagementContext managementContext, BrooklynClassLoadingContextSequential loader, String catalogItemId) {
+ RegisteredType item = managementContext.getTypeRegistry().get(catalogItemId);
+
+ if (item != null) {
+ BrooklynClassLoadingContext itemLoader = newClassLoadingContext(managementContext, item);
+ loader.add(itemLoader);
+ } else {
+ // TODO review what to do here
+ log.debug("Can't find catalog item " + catalogItemId);
--- End diff --
At the very least could log at higher level - code at `AbstractManagementContext` used to log at `error`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r112698386
--- Diff: core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindIteration.java ---
@@ -1076,7 +1151,7 @@ protected Policy newPolicy(PolicyMemento memento) {
policy = invokeConstructor(null, policyClazz, new Object[] {flags});
}
- setCatalogItemId(policy, transformedCatalogItemId);
+ setCatalogItemIds(policy, memento.getCatalogItemId(), memento.getCatalogItemIdSearchPath());
--- End diff --
i think this should be:
> setCatalogItemIds(policy, loaded.catalogItemId, loaded.searchPath);
in case there were any transformations that were applied (by `load(...)`)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r94756992
--- Diff: core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/dto/AbstractMemento.java ---
@@ -64,14 +68,28 @@ public B from(Memento other) {
type = other.getType();
typeClass = other.getTypeClass();
displayName = other.getDisplayName();
- catalogItemId = other.getCatalogItemId();
+ setCatalogItemIds(other.getCatalogItemSuperIds(), other.getCatalogItemId());
--- End diff --
Move the logic inside `getCatalogItemSuperIds` so it's accessible to other callers as well.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server issue #338: Support nested catalog item definitions - testCa...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the issue:
https://github.com/apache/brooklyn-server/pull/338
In maven, this tests fails eventually with an OOME:
```
2017-04-21 15:11:29,630 INFO TESTNG INVOKING: "Surefire test" - org.apache.brooklyn.camp.brooklyn.catalog.CatalogYamlRebindTest.testRebindWithCatalogAndAppRebindCatalogItemIds(org.apache.brooklyn.camp.brooklyn.catalog.CatalogYamlRebindTest$RebindWithCatalogTestMode, org.apache.brooklyn.camp.brooklyn.catalog.CatalogYamlRebindTest$OsgiMode)(value(s): DISABLE_CATALOG, LIBRARY)
```
i see lots of GC at around 700MB, and failed bundle loads beforehand. but it runs fine in the IDE.
curious.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Not for merge, work in progress - testCat...
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r79995509
--- Diff: core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractManagementContext.java ---
@@ -128,20 +128,18 @@ private static DataGridFactory loadDataGridFactory(BrooklynProperties properties
public BrooklynClassLoadingContext apply(@Nullable Object input) {
if (input instanceof EntityInternal) {
EntityInternal internal = (EntityInternal)input;
- if (internal.getCatalogItemId() != null) {
- RegisteredType item = internal.getManagementContext().getTypeRegistry().get(internal.getCatalogItemId());
-
- if (item != null) {
- BrooklynClassLoadingContext itemLoader = CatalogUtils.newClassLoadingContext(internal.getManagementContext(), item);
- // Falls back to the entity's class loader
- JavaBrooklynClassLoadingContext entityLoader = JavaBrooklynClassLoadingContext.create(input.getClass().getClassLoader());
- BrooklynClassLoadingContext seqLoader = new BrooklynClassLoadingContextSequential(internal.getManagementContext(), itemLoader, entityLoader);
- return seqLoader;
- } else {
- log.error("Can't find catalog item " + internal.getCatalogItemId() +
- " used for instantiating entity " + internal +
- ". Falling back to application classpath.");
+ final List<String> catalogItemSuperIds = internal.getCatalogItemSuperIds();
+ if (catalogItemSuperIds.size() > 0) {
+ BrooklynClassLoadingContextSequential seqLoader = new BrooklynClassLoadingContextSequential(internal.getManagementContext());
+ for (String catalogItemId : catalogItemSuperIds) {
--- End diff --
check - probably as well as the catalog items we *should* still also use the entity class loader?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] brooklyn-server pull request #338: Support nested catalog item definitions -...
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/338#discussion_r112694873
--- Diff: api/src/main/java/org/apache/brooklyn/api/mgmt/rebind/mementos/Memento.java ---
@@ -43,11 +44,19 @@
String getId();
- public String getType();
-
- public String getCatalogItemId();
-
- public String getDisplayName();
+ String getType();
+
+ /**
+ * The principal catalog item id.
+ */
+ String getCatalogItemId();
--- End diff --
it's for more than persistence i think -- javadoc is accurate
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---