[jira] [Commented] (BROOKLYN-352) ConcurrentModificationException when using $brooklyn:entity

2016-11-22 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/BROOKLYN-352?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15687768#comment-15687768
 ] 

ASF GitHub Bot commented on BROOKLYN-352:
-

Github user asfgit closed the pull request at:

https://github.com/apache/brooklyn-server/pull/453


> ConcurrentModificationException when using $brooklyn:entity
> ---
>
> Key: BROOKLYN-352
> URL: https://issues.apache.org/jira/browse/BROOKLYN-352
> Project: Brooklyn
>  Issue Type: Bug
>Reporter: Svetoslav Neykov
>
> Got the following exception when running a fairly complex blueprint on a cpu 
> starved machine. Looking at the sources and the javadoc makes sense - we 
> should guard iterating over the entities with a synchronized block.
> From Collections.synchronizedMap:
> {noformat}
>  * It is imperative that the user manually synchronize on the returned
>  * map when iterating over any of its collection views:
> {noformat}
> {noformat}
> Failed after 13ms: Execution failed, invocation error for launching 
> VanillaSoftwareProcessImpl{id=w4ixqlmhdh}: Error resolving config 
> shell.env.KUBERNETES_URL, 
> $brooklyn:entity("kubernetes-master").attributeWhenReady("kubernetes.url"), 
> in 
> org.apache.brooklyn.util.core.task.BasicExecutionContext@1d028d95([Wrapped[contextEntity:VanillaSoftwareProcessImpl{id=w4ixqlmhdh}],
>  LocalManagementContext[i5xdJAZa-yAstcnrg]]): 
> org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
> ConcurrentModificationException
> java.lang.IllegalStateException: Execution failed, invocation error for 
> launching VanillaSoftwareProcessImpl{id=w4ixqlmhdh}: Error resolving config 
> shell.env.KUBERNETES_URL, 
> $brooklyn:entity("kubernetes-master").attributeWhenReady("kubernetes.url"), 
> in 
> org.apache.brooklyn.util.core.task.BasicExecutionContext@1d028d95([Wrapped[contextEntity:VanillaSoftwareProcessImpl{id=w4ixqlmhdh}],
>  LocalManagementContext[i5xdJAZa-yAstcnrg]]): 
> org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
> ConcurrentModificationException
>   at 
> org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper.logWithDetailsAndThrow(ScriptHelper.java:387)
>   at 
> org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper.executeInternal(ScriptHelper.java:370)
>   at 
> org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper$8.call(ScriptHelper.java:287)
>   at 
> org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper$8.call(ScriptHelper.java:285)
>   at 
> org.apache.brooklyn.util.core.task.DynamicSequentialTask$DstJob.call(DynamicSequentialTask.java:359)
>   at 
> org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:519)
>   at java.util.concurrent.FutureTask.run(FutureTask.java:262)
>   at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>   at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>   at java.lang.Thread.run(Thread.java:745)
> Caused by: java.lang.IllegalArgumentException: Error resolving config 
> shell.env.KUBERNETES_URL, 
> $brooklyn:entity("kubernetes-master").attributeWhenReady("kubernetes.url"), 
> in 
> org.apache.brooklyn.util.core.task.BasicExecutionContext@1d028d95([Wrapped[contextEntity:VanillaSoftwareProcessImpl{id=w4ixqlmhdh}],
>  LocalManagementContext[i5xdJAZa-yAstcnrg]]): 
> org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
> ConcurrentModificationException
>   at 
> org.apache.brooklyn.util.core.task.ValueResolver.getMaybeInternal(ValueResolver.java:411)
>   at 
> org.apache.brooklyn.util.core.task.ValueResolver.getMaybe(ValueResolver.java:257)
>   at 
> org.apache.brooklyn.util.core.task.ValueResolver.get(ValueResolver.java:250)
>   at org.apache.brooklyn.util.core.task.Tasks.resolveValue(Tasks.java:147)
>   at 
> org.apache.brooklyn.core.config.BasicConfigKey.resolveValue(BasicConfigKey.java:355)
>   at 
> org.apache.brooklyn.core.config.BasicConfigKey.extractValue(BasicConfigKey.java:340)
>   at 
> org.apache.brooklyn.core.config.SubElementConfigKey.extractValue(SubElementConfigKey.java:48)
>   at 
> org.apache.brooklyn.core.config.internal.AbstractStructuredConfigKey.extractValue(AbstractStructuredConfigKey.java:111)
>   at 
> org.apache.brooklyn.core.config.internal.AbstractStructuredConfigKey.extractValue(AbstractStructuredConfigKey.java:124)
>   at 
> org.apache.brooklyn.core.entity.internal.EntityConfigMap.getConfigImpl(EntityConfigMap.java:139)
>   at 
> org.apache.brooklyn.core.entity.internal.EntityConfigMap.getConfig(EntityConfigMap.java:113)
>   at 
> org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl.getConfig(AbstractConfigMapImpl.java:50)
>   at 
> 

[jira] [Commented] (BROOKLYN-352) ConcurrentModificationException when using $brooklyn:entity

2016-11-22 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/BROOKLYN-352?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15686642#comment-15686642
 ] 

ASF GitHub Bot commented on BROOKLYN-352:
-

Github user geomacy commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/453#discussion_r89106124
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalEntityManager.java
 ---
@@ -212,13 +213,41 @@ public EntityTypeRegistry getEntityTypeRegistry() {
 
 @Override
 public Iterable getAllEntitiesInApplication(Application 
application) {
+// To fix https://issues.apache.org/jira/browse/BROOKLYN-352, we 
need to synchronize on
+// preRegisteredEntitiesById and preManagedEntitiesById while 
iterating over them (because
+// they are synchronizedMaps). entityProxiesById is a 
ConcurrentMap, so no need to 
+// synchronize on that.
+// Only synchronize on one at a time, to avoid the risk of 
deadlock.
+
 Predicate predicate = 
EntityPredicates.applicationIdEqualTo(application.getId());
-Iterable allentities = 
Iterables.concat(preRegisteredEntitiesById.values(), 
preManagedEntitiesById.values(), entityProxiesById.values());
-Iterable result = Iterables.filter(allentities, predicate);
-return ImmutableSet.copyOf(Iterables.transform(result, new 
Function() {
-@Override public Entity apply(Entity input) {
-return Entities.proxy(input);
-}}));
+Set result = Sets.newLinkedHashSet();
+
+synchronized (preRegisteredEntitiesById) {
--- End diff --

Maybe it would be worth making `preRegisteredEntitiesById` and 
`preManagedEntitiesById` private, and providing access to them with code like 
this loop, but put into a `protected` method.  At the moment it's not 
impossible that some derived class in future would again use one of the maps 
but forget the synchronization. 


> ConcurrentModificationException when using $brooklyn:entity
> ---
>
> Key: BROOKLYN-352
> URL: https://issues.apache.org/jira/browse/BROOKLYN-352
> Project: Brooklyn
>  Issue Type: Bug
>Reporter: Svetoslav Neykov
>
> Got the following exception when running a fairly complex blueprint on a cpu 
> starved machine. Looking at the sources and the javadoc makes sense - we 
> should guard iterating over the entities with a synchronized block.
> From Collections.synchronizedMap:
> {noformat}
>  * It is imperative that the user manually synchronize on the returned
>  * map when iterating over any of its collection views:
> {noformat}
> {noformat}
> Failed after 13ms: Execution failed, invocation error for launching 
> VanillaSoftwareProcessImpl{id=w4ixqlmhdh}: Error resolving config 
> shell.env.KUBERNETES_URL, 
> $brooklyn:entity("kubernetes-master").attributeWhenReady("kubernetes.url"), 
> in 
> org.apache.brooklyn.util.core.task.BasicExecutionContext@1d028d95([Wrapped[contextEntity:VanillaSoftwareProcessImpl{id=w4ixqlmhdh}],
>  LocalManagementContext[i5xdJAZa-yAstcnrg]]): 
> org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
> ConcurrentModificationException
> java.lang.IllegalStateException: Execution failed, invocation error for 
> launching VanillaSoftwareProcessImpl{id=w4ixqlmhdh}: Error resolving config 
> shell.env.KUBERNETES_URL, 
> $brooklyn:entity("kubernetes-master").attributeWhenReady("kubernetes.url"), 
> in 
> org.apache.brooklyn.util.core.task.BasicExecutionContext@1d028d95([Wrapped[contextEntity:VanillaSoftwareProcessImpl{id=w4ixqlmhdh}],
>  LocalManagementContext[i5xdJAZa-yAstcnrg]]): 
> org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
> ConcurrentModificationException
>   at 
> org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper.logWithDetailsAndThrow(ScriptHelper.java:387)
>   at 
> org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper.executeInternal(ScriptHelper.java:370)
>   at 
> org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper$8.call(ScriptHelper.java:287)
>   at 
> org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper$8.call(ScriptHelper.java:285)
>   at 
> org.apache.brooklyn.util.core.task.DynamicSequentialTask$DstJob.call(DynamicSequentialTask.java:359)
>   at 
> org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:519)
>   at java.util.concurrent.FutureTask.run(FutureTask.java:262)
>   at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>   at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>   at 

[jira] [Commented] (BROOKLYN-352) ConcurrentModificationException when using $brooklyn:entity

2016-10-15 Thread Svetoslav Neykov (JIRA)

[ 
https://issues.apache.org/jira/browse/BROOKLYN-352?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15577739#comment-15577739
 ] 

Svetoslav Neykov commented on BROOKLYN-352:
---

Hit this once again:
{noformat}
Failed after 266ms: Error invoking start at DynamicClusterImpl{id=biagm3ha42}: 
Error resolving config cluster.initial.size, 
$brooklyn:entity("kubernetes-cluster").config("kubernetes.master.size"), in 
org.apache.brooklyn.util.core.task.BasicExecutionContext@1f77fbbe([Wrapped[contextEntity:DynamicClusterImpl{id=biagm3ha42}],
 LocalManagementContext[lvMtifon-xhTxtHy5]]): 
org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
ConcurrentModificationException

org.apache.brooklyn.core.mgmt.internal.EffectorUtils$EffectorCallPropagatedRuntimeException:
 Error invoking start at DynamicClusterImpl{id=biagm3ha42}: Error resolving 
config cluster.initial.size, 
$brooklyn:entity("kubernetes-cluster").config("kubernetes.master.size"), in 
org.apache.brooklyn.util.core.task.BasicExecutionContext@1f77fbbe([Wrapped[contextEntity:DynamicClusterImpl{id=biagm3ha42}],
 LocalManagementContext[lvMtifon-xhTxtHy5]]): 
org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
ConcurrentModificationException
at 
org.apache.brooklyn.core.mgmt.internal.EffectorUtils$EffectorCallPropagatedRuntimeException.propagate(EffectorUtils.java:318)
at 
org.apache.brooklyn.core.mgmt.internal.EffectorUtils$EffectorCallPropagatedRuntimeException.access$100(EffectorUtils.java:285)
at 
org.apache.brooklyn.core.mgmt.internal.EffectorUtils.handleEffectorException(EffectorUtils.java:326)
at 
org.apache.brooklyn.core.mgmt.internal.EffectorUtils.invokeMethodEffector(EffectorUtils.java:281)
at 
org.apache.brooklyn.core.effector.MethodEffector.call(MethodEffector.java:148)
at 
org.apache.brooklyn.core.entity.trait.Startable$StartEffectorBody.call(Startable.java:56)
at 
org.apache.brooklyn.core.entity.trait.Startable$StartEffectorBody.call(Startable.java:50)
at 
org.apache.brooklyn.core.effector.EffectorTasks$EffectorBodyTaskFactory$1.call(EffectorTasks.java:82)
at 
org.apache.brooklyn.util.core.task.DynamicSequentialTask$DstJob.call(DynamicSequentialTask.java:359)
at 
org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:522)
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.util.concurrent.ExecutionException: 
java.lang.IllegalArgumentException: Error resolving config 
cluster.initial.size, 
$brooklyn:entity("kubernetes-cluster").config("kubernetes.master.size"), in 
org.apache.brooklyn.util.core.task.BasicExecutionContext@1f77fbbe([Wrapped[contextEntity:DynamicClusterImpl{id=biagm3ha42}],
 LocalManagementContext[lvMtifon-xhTxtHy5]]): 
org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
ConcurrentModificationException
at 
org.apache.brooklyn.core.mgmt.internal.AbstractManagementContext.invokeEffectorMethodSync(AbstractManagementContext.java:343)
at 
org.apache.brooklyn.core.mgmt.internal.EffectorUtils.invokeMethodEffector(EffectorUtils.java:276)
... 10 more
Caused by: java.lang.IllegalArgumentException: Error resolving config 
cluster.initial.size, 
$brooklyn:entity("kubernetes-cluster").config("kubernetes.master.size"), in 
org.apache.brooklyn.util.core.task.BasicExecutionContext@1f77fbbe([Wrapped[contextEntity:DynamicClusterImpl{id=biagm3ha42}],
 LocalManagementContext[lvMtifon-xhTxtHy5]]): 
org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: 
ConcurrentModificationException
at 
org.apache.brooklyn.util.core.task.ValueResolver.getMaybeInternal(ValueResolver.java:426)
at 
org.apache.brooklyn.util.core.task.ValueResolver.getMaybe(ValueResolver.java:267)
at 
org.apache.brooklyn.util.core.task.ValueResolver.get(ValueResolver.java:260)
at org.apache.brooklyn.util.core.task.Tasks.resolveValue(Tasks.java:147)
at 
org.apache.brooklyn.core.config.BasicConfigKey.resolveValue(BasicConfigKey.java:405)
at 
org.apache.brooklyn.core.config.BasicConfigKey.extractValue(BasicConfigKey.java:390)
at 
org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl.resolveRawValueFromContainer(AbstractConfigMapImpl.java:308)
at 
org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl$3.apply(AbstractConfigMapImpl.java:360)
at 
org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl$3.apply(AbstractConfigMapImpl.java:357)
at 
org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl.getConfigImpl(AbstractConfigMapImpl.java:372)
at