Skip to content

Conversation

@geomacy
Copy link
Contributor

@geomacy geomacy commented Mar 22, 2017

Make initial changes as suggested by Alex in #573.
To be merged after #338. Only the last (a5cdc19) of the changes in this PR is actually not part of 338.

Add addToCatalogSearchPathOnAddition and make it set search paths.
Update management context classloader provider
Add getCatalogItemIdAndSearchPathFromContext.
Set context details as search path in AbstractBrooklynObject constructor.
Update testManuallyAddWithParentFromCatalog assertion as suggested.
Update testManuallyAddInTaskOfOtherEntity assertion as suggested.

The changes above allow the tests just named to succeed, however
they have knock-on effects in other tests, as they change the
behaviour of DSL "scopeRoot", which effectively relies on
the catalogItemId of children being copied from that of their
parents. This means the following tests fail:

Failed tests:
EntitiesYamlTest.testScopeReferences:569->assertScopes:581 expected [ReferencingYamlTestEntityImpl{id=f3z5pyzt8r}] but found [ReferencingYamlTestEntityImpl{id=witrlgcuo1}]
EntityRefsYamlTest.testRefToScopeRoot:101 expected [TestEntityImpl{id=fc9nfhoj8x}] but found [TestEntityImpl{id=g2ai718knw}]
DslYamlTest.testDslScopeRoot:253->assertScopeRoot:261 expected [BasicEntityImpl{id=a860h6w3at}] but found [BasicEntityImpl{id=aoxrtylbv2}]

geomacy added 30 commits March 21, 2017 09:15
… working.

Haven't re-run all unit tests yet.
The purpose of this test is to illustrate that the full stack of nested
catalog items is not searched for classloaders.
Fixes testDeepCatalogItemCanLoadResources.
This fails with the following exception:

org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: Failure rebinding: problem creating ENTITY zmm0lmrzll of type org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl: Unable to load org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl from []: Invalid class: org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl: ClassNotFoundException: org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl
	at org.apache.brooklyn.util.exceptions.Exceptions.propagate(Exceptions.java:129)
	at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl.rebind(RebindManagerImpl.java:513)
	at org.apache.brooklyn.core.mgmt.rebind.RebindTestUtils.rebindAll(RebindTestUtils.java:446)
	at org.apache.brooklyn.core.mgmt.rebind.RebindTestUtils.rebind(RebindTestUtils.java:328)
	at org.apache.brooklyn.core.mgmt.rebind.RebindTestFixture.rebind(RebindTestFixture.java:281)
	at org.apache.brooklyn.camp.brooklyn.AbstractYamlRebindTest.rebind(AbstractYamlRebindTest.java:86)
	at org.apache.brooklyn.core.mgmt.rebind.RebindTestFixture.rebind(RebindTestFixture.java:217)
	at org.apache.brooklyn.camp.brooklyn.RebindOsgiTest.testReboundDeepCatalogItemCanLoadResources(RebindOsgiTest.java:201)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
	at org.testng.TestRunner.privateRun(TestRunner.java:767)
	at org.testng.TestRunner.run(TestRunner.java:617)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
	at org.testng.SuiteRunner.run(SuiteRunner.java:254)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
	at org.testng.TestNG.run(TestNG.java:1057)
	at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
	at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:124)
Caused by: java.util.concurrent.ExecutionException: org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: Failure rebinding: problem creating ENTITY zmm0lmrzll of type org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl: Unable to load org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl from []: Invalid class: org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl: ClassNotFoundException: org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:63)
	at org.apache.brooklyn.util.core.task.BasicTask.get(BasicTask.java:361)
	at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl.rebind(RebindManagerImpl.java:511)
	... 29 more
Caused by: org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: Failure rebinding: problem creating ENTITY zmm0lmrzll of type org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl: Unable to load org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl from []: Invalid class: org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl: ClassNotFoundException: org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl
	at org.apache.brooklyn.util.exceptions.Exceptions.create(Exceptions.java:430)
	at org.apache.brooklyn.core.mgmt.rebind.RebindExceptionHandlerImpl.onDoneImpl(RebindExceptionHandlerImpl.java:497)
	at org.apache.brooklyn.core.mgmt.rebind.RebindExceptionHandlerImpl.onDone(RebindExceptionHandlerImpl.java:413)
	at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.run(RebindIteration.java:268)
	at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl.rebindImpl(RebindManagerImpl.java:558)
	at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:508)
	at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:506)
	at org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:519)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: problem creating ENTITY zmm0lmrzll of type org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl
	at org.apache.brooklyn.core.mgmt.rebind.RebindExceptionHandlerImpl.onCreateFailed(RebindExceptionHandlerImpl.java:265)
	at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.instantiateLocationsAndEntities(RebindIteration.java:459)
	at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.doRun(RebindIteration.java:240)
	at org.apache.brooklyn.core.mgmt.rebind.InitialFullRebindIteration.doRun(InitialFullRebindIteration.java:69)
	at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.run(RebindIteration.java:266)
	... 8 more
Caused by: java.lang.IllegalStateException: Unable to load org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl from []: Invalid class: org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl: ClassNotFoundException: org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl
	at org.apache.brooklyn.util.guava.IllegalStateExceptionSupplier.get(IllegalStateExceptionSupplier.java:40)
	at org.apache.brooklyn.util.guava.IllegalStateExceptionSupplier.get(IllegalStateExceptionSupplier.java:26)
	at org.apache.brooklyn.util.guava.Maybe$Absent.getException(Maybe.java:327)
	at org.apache.brooklyn.util.guava.Maybe$Absent.get(Maybe.java:321)
	at org.apache.brooklyn.core.mgmt.classloading.AbstractBrooklynClassLoadingContext.loadClass(AbstractBrooklynClassLoadingContext.java:55)
	at org.apache.brooklyn.core.mgmt.rebind.RebindIteration$BrooklynObjectInstantiator.load(RebindIteration.java:954)
	at org.apache.brooklyn.core.mgmt.rebind.RebindIteration$BrooklynObjectInstantiator.newEntity(RebindIteration.java:874)
	at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.instantiateLocationsAndEntities(RebindIteration.java:454)
	... 11 more
Caused by: org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: Unable to load org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl from []: Invalid class: org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl: ClassNotFoundException: org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl
	at org.apache.brooklyn.util.exceptions.Exceptions.create(Exceptions.java:430)
	at org.apache.brooklyn.core.mgmt.classloading.BrooklynClassLoadingContextSequential.tryLoadClass(BrooklynClassLoadingContextSequential.java:88)
	at org.apache.brooklyn.core.mgmt.classloading.AbstractBrooklynClassLoadingContext.tryLoadClass(AbstractBrooklynClassLoadingContext.java:61)
	... 15 more
Caused by: java.lang.IllegalStateException: Invalid class: org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl
	at org.apache.brooklyn.util.guava.IllegalStateExceptionSupplier.get(IllegalStateExceptionSupplier.java:40)
	at org.apache.brooklyn.util.guava.IllegalStateExceptionSupplier.get(IllegalStateExceptionSupplier.java:26)
	at org.apache.brooklyn.util.guava.Maybe$Absent.getException(Maybe.java:327)
	at org.apache.brooklyn.core.mgmt.classloading.BrooklynClassLoadingContextSequential.tryLoadClass(BrooklynClassLoadingContextSequential.java:85)
	... 16 more
Caused by: java.lang.ClassNotFoundException: org.apache.brooklyn.test.osgi.entities.SimpleEntityImpl
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.apache.brooklyn.util.javalang.AggregateClassLoader.findClass(AggregateClassLoader.java:135)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.apache.brooklyn.core.mgmt.classloading.JavaBrooklynClassLoadingContext.tryLoadClass0(JavaBrooklynClassLoadingContext.java:101)
	at org.apache.brooklyn.core.mgmt.classloading.JavaBrooklynClassLoadingContext.tryLoadClass(JavaBrooklynClassLoadingContext.java:84)
	at org.apache.brooklyn.core.mgmt.classloading.BrooklynClassLoadingContextSequential.tryLoadClass(BrooklynClassLoadingContextSequential.java:81)
	... 16 more
Fixes testReboundDeepCatalogItemCanLoadResources.
It's perfectly possible for the catalog item loader to have just the launcher management context in the secondaries.
Working on review comments for catalog-update PR

apache#338 (comment)
Unused import in AbstractBrooklynObjectSpec.java  - done in merge

apache#338 (comment)
Keep for persistence backwards compatibility
- surely I take this into account already? See testRebindWithCatalogAndAppRebindCatalogItemIds,
and BrooklynMementoPersisterToObjectStore.getCatalogItemIds().

apache#338 (comment)
Not called on xstream deserialize, could be null - take into account in following code.
- Introduced getCatalogItemIdStack().  What about the other pre-existing fields that also have initializers?

apache#338 (comment)
  public SpecT catalogItemId(String val) {
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.
- deprecated

https://github.com/apache/brooklyn-server/pull/338/files#r94615424
Don't see this used, do you think we should keep it?
- replaced it with protected SpecT catalogItemIdStack(Collection<String> catalogItemIdStack),
used in AbstractBrooklynObjectSpec#copyFrom().

https://github.com/apache/brooklyn-server/pull/338/files#r94609346
missing word
- fixed

https://github.com/apache/brooklyn-server/pull/338/files#r94613348
It's not a mere reference but R3 extending R2, etc.
- fixed

apache#338 (comment)
public SpecT catalogItemIdIfNotNull(String val) {
I'd deprecate it, even if marked as @beta.
- done

https://github.com/apache/brooklyn-server/pull/338/files#r94616318
I don't associate "nest" with anything in this context, perhaps stackCatalogItemId would be more appropriate?
- changed to "stackCatalogItemId".

apache#338 (comment)
public final String getCatalogItemId() {
Suggest deprecating this one and creating getOuterCatalogItemId, getInnerCatalogItemId.
- created getOuterCatalogItemId; getInner not needed as there is getCatalogItemHierarchy

apache#338 (comment)
As a fallback return catalogItemId.
- Seems preferable not to retain catalogItemId if we can get away without it, see
comment on apache#338 (comment)
above.

apache#338 (comment)
Can you add as a clarification
- Added.

apache#338 (comment)
"Super" (here and same name in other classes) could be misinterpreted
- changed name to getCatalogItemHierarchy
apache#338 (comment)
This is just for persistence backwards compatibility, right? If so mark it as deprecated.
- done

apache#338 (comment)
Unused.
- done

apache#338 (comment)
Unused, plus Strings, XmlUtil.
- done

apache#338 (comment)
At the very least could log at higher level - code at AbstractManagementContext used to log at error.
- changed to warn.

apache#338 (comment)
Use and return getCatalogItemSuperIds instead.
- updated
apache#338 (comment)
Remove/deprecate this method and use getCatalogItemSuperIds instead in callers.
- done; also renames "SuperIds" to "Hierarchy" everywhere.
apache#338 (comment)

The change was done during the early investigation of the issue.
The nested-item tests work without it.
https://github.com/apache/brooklyn-server/pull/338/files#r94623208

Use in

org.apache.brooklyn.util.core.ClassLoaderUtils#load
org.apache.brooklyn.core.mgmt.persist.BrooklynMementoPersisterToObjectStore#getCustomClassLoaderForBrooklynObject
org.apache.brooklyn.core.catalog.internal.JavaCatalogToSpecTransformer#createCatalogSpec

Not doing XmlMementoSerializer as it is calling
  newClassLoadingContext(ManagementContext mgmt, RegisteredType item)
rather than
  newClassLoadingContext(ManagementContext mgmt, CatalogItem<?, ?> item),
and the hierarchy is not available on RegisteredType.
Restore catalogItemId; change getCatalogItemIdHierarchy to getCatalogItemIdSearchPath.
Update "stackCatalogItemId" to work with catalogItemId + search path.
Use catalogItemIdAndSearchPath when merging wrapper parent to child.
Rebind changes for  catalogItemId + search path.
Update AbstractBrooklynObject[Spec] for catalogItemId + searchPath
Do catalogItemIdAndSearchPath only if non-null
Update "catalogItemIdHierarchy" -> "searchPath" in persistence
geomacy added 6 commits March 21, 2017 09:37
Add addToCatalogSearchPathOnAddition and make it set search paths.
Update management context classloader provider
Add getCatalogItemIdAndSearchPathFromContext.
Set context details as search path in AbstractBrooklynObject constructor.
Update testManuallyAddWithParentFromCatalog assertion as suggested.
Update testManuallyAddInTaskOfOtherEntity assertion as suggested.

The changes above allow the tests just named to succeed, however
they have knock-on effects in other tests, as they change the
behaviour of DSL "scopeRoot", which effectively relies on
the catalogItemId of children being copied from that of their
parents. This means the following tests fail:

Failed tests:
  EntitiesYamlTest.testScopeReferences:569->assertScopes:581 expected [ReferencingYamlTestEntityImpl{id=f3z5pyzt8r}] but found [ReferencingYamlTestEntityImpl{id=witrlgcuo1}]
  EntityRefsYamlTest.testRefToScopeRoot:101 expected [TestEntityImpl{id=fc9nfhoj8x}] but found [TestEntityImpl{id=g2ai718knw}]
  DslYamlTest.testDslScopeRoot:253->assertScopeRoot:261 expected [BasicEntityImpl{id=a860h6w3at}] but found [BasicEntityImpl{id=aoxrtylbv2}]
@geomacy geomacy changed the title Catalog update continued WIP DO NOT MERGE Fixes to testManuallyAdd... Mar 23, 2017
@geomacy geomacy mentioned this pull request Apr 24, 2017
@geomacy
Copy link
Contributor Author

geomacy commented Jun 6, 2017

Just going to close this PR, it can be revived when we think it's important to get round to those comments.

@geomacy geomacy closed this Jun 6, 2017
@geomacy geomacy deleted the catalog-update-continued branch June 12, 2017 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant