brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (BROOKLYN-451) Rebind of old persisted state for yaml-DSL broken
Date Tue, 14 Mar 2017 16:14:41 GMT

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

ASF GitHub Bot commented on BROOKLYN-451:
-----------------------------------------

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

    https://github.com/apache/brooklyn-server/pull/593#discussion_r105952999
  
    --- Diff: core/src/main/java/org/apache/brooklyn/util/core/xstream/ObjectWithDefaultStringImplConverter.java
---
    @@ -0,0 +1,86 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.brooklyn.util.core.xstream;
    +
    +import org.apache.brooklyn.util.exceptions.Exceptions;
    +import org.apache.brooklyn.util.javalang.Boxing;
    +
    +import com.thoughtworks.xstream.converters.Converter;
    +import com.thoughtworks.xstream.converters.ConverterLookup;
    +import com.thoughtworks.xstream.converters.MarshallingContext;
    +import com.thoughtworks.xstream.converters.UnmarshallingContext;
    +import com.thoughtworks.xstream.io.HierarchicalStreamReader;
    +import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
    +
    +/**
    + * A converter that delegates to {@link ConverterLookup#lookupConverterForType(Class)},
where
    + * possible. On unmarshalling, if there is no {@code class} attribute then it assumes
that the
    + * type must be a {@link String}.
    + * 
    + * This is useful if a class has its field changed from type {@link String} to {@link
Object}.
    + * The old persisted state will look like {@code <mykey>myval</mykey>}, rather
than 
    + * {@code <mykey class="string">myval</mykey>}.
    + * 
    + * Use this converter by annotation the field with
    + * {@code @XStreamConverter(ObjectWithDefaultStringImplConverter.class)}. One must also
call
    + * {@code xstream.processAnnotations(MyClazz.class)} to ensure the annotation is actually
parsed.
    + */
    +public class ObjectWithDefaultStringImplConverter implements Converter {
    +    private final ConverterLookup lookup;
    +    private final ClassLoader loader;
    +    private final Class<?> defaultImpl = String.class;
    +
    +    public ObjectWithDefaultStringImplConverter(ConverterLookup lookup, ClassLoader loader)
{
    +        this.lookup = lookup;
    +        this.loader = loader;
    +    }
    +
    +    @Override
    +    public boolean canConvert(@SuppressWarnings("rawtypes") Class type) {
    +        return true;
    --- End diff --
    
    Worth adding a comment here as to why this is hardcoded


> Rebind of old persisted state for yaml-DSL broken
> -------------------------------------------------
>
>                 Key: BROOKLYN-451
>                 URL: https://issues.apache.org/jira/browse/BROOKLYN-451
>             Project: Brooklyn
>          Issue Type: Bug
>            Reporter: Aled Sage
>            Priority: Blocker
>
> As discovered by Ivana, rebinding to old persisted state of yaml-DSL is broken (in 0.11.0-SNAPSHOT
only).
> I've added example failing tests at https://github.com/apache/brooklyn-server/pull/593.
> The error message that Ivana hit is shown below:
> {noformat}
> 2017-03-13 18:32:45,954 WARN  120 o.a.b.c.m.r.RebindExceptionHandlerImpl [nager-o3dVnQ0i-0]
problem adding enricher klcueb1ide (Transformer{name=org.apache.brooklyn.enricher.stock.Transformer,
uniqueTag=docker-bind-url-generator, running=true, entity=VanillaSoftwareProcessImpl{id=ofov78knm2},
id=klcueb1ide}) to entity ofov78knm2 (VanillaSoftwareProcessImpl{id=ofov78knm2}); continuing
> java.lang.IllegalArgumentException: Error resolving config enricher.targetSensor, $brooklyn:sensorName(java.lang.Object@74d44767),
in org.apache.brooklyn.util.core.task.BasicExecutionContext@700e5716([Wrapped[contextEntity:VanillaSoftwareProcessImpl{id=ofov78knm2}],
LocalManagementContext[Sm0k6v6V-o3dVnQ0i]]): Cannot resolve 'java.lang.Object@74d44767' as
a sensor (got type java.lang.Object)
> 	at org.apache.brooklyn.util.core.task.ValueResolver.getMaybeInternal(ValueResolver.java:548)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.util.core.task.ValueResolver.getMaybe(ValueResolver.java:319)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.util.core.task.ValueResolver.get(ValueResolver.java:312)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.util.core.task.Tasks.resolveValue(Tasks.java:147)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.config.BasicConfigKey.resolveValue(BasicConfigKey.java:405)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.config.BasicConfigKey.extractValue(BasicConfigKey.java:390)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl.resolveRawValueFromContainer(AbstractConfigMapImpl.java:316)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl$3.apply(AbstractConfigMapImpl.java:376)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl$3.apply(AbstractConfigMapImpl.java:372)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl.getConfigImpl(AbstractConfigMapImpl.java:388)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl.getConfig(AbstractConfigMapImpl.java:109)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.objs.AbstractConfigurationSupportInternal.get(AbstractConfigurationSupportInternal.java:173)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.objs.AbstractEntityAdjunct.getConfig(AbstractEntityAdjunct.java:330)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.enricher.stock.AbstractTransformer.setEntity(AbstractTransformer.java:82)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.entity.AbstractEntity$BasicEnricherSupport.add(AbstractEntity.java:1695)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.mgmt.rebind.BasicEntityRebindSupport.addEnrichers(BasicEntityRebindSupport.java:157)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.mgmt.rebind.BasicEntityRebindSupport.addEnrichers(BasicEntityRebindSupport.java:56)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.associateAdjunctsWithEntities(RebindIteration.java:649)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.doRun(RebindIteration.java:243)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.mgmt.rebind.InitialFullRebindIteration.doRun(InitialFullRebindIteration.java:69)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.run(RebindIteration.java:265)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl.rebindImpl(RebindManagerImpl.java:560)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:510)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:508)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:529)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_101]
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_101]
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_101]
> 	at java.lang.Thread.run(Thread.java:745)[:1.8.0_101]
> Caused by: org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: Cannot resolve
'java.lang.Object@74d44767' as a sensor (got type java.lang.Object)
> 	at org.apache.brooklyn.util.exceptions.Exceptions.propagate(Exceptions.java:130)[141:org.apache.brooklyn.utils-common:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.util.time.Durations.get(Durations.java:63)[141:org.apache.brooklyn.utils-common:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.util.time.Durations.get(Durations.java:68)[141:org.apache.brooklyn.utils-common:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.util.core.task.ValueResolver.getMaybeInternal(ValueResolver.java:483)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	... 28 more
> Caused by: java.util.concurrent.ExecutionException: org.apache.brooklyn.util.exceptions.PropagatedRuntimeException:
Cannot resolve 'java.lang.Object@74d44767' as a sensor (got type java.lang.Object)
> 	at java.util.concurrent.FutureTask.report(FutureTask.java:122)[:1.8.0_101]
> 	at java.util.concurrent.FutureTask.get(FutureTask.java:192)[:1.8.0_101]
> 	at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:63)[68:com.google.guava:18.0.0]
> 	at org.apache.brooklyn.util.core.task.BasicTask.get(BasicTask.java:361)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.util.time.Durations.get(Durations.java:43)[141:org.apache.brooklyn.utils-common:0.11.0.20170310_1638]
> 	... 30 more
> Caused by: org.apache.brooklyn.util.exceptions.PropagatedRuntimeException: Cannot resolve
'java.lang.Object@74d44767' as a sensor (got type java.lang.Object)
> 	at org.apache.brooklyn.util.exceptions.Exceptions.propagate(Exceptions.java:130)[141:org.apache.brooklyn.utils-common:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.camp.brooklyn.spi.dsl.BrooklynDslDeferredSupplier.get(BrooklynDslDeferredSupplier.java:120)[118:org.apache.brooklyn.camp:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.util.core.task.ValueResolver$2.call(ValueResolver.java:468)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.util.core.task.DynamicSequentialTask$DstJob.call(DynamicSequentialTask.java:362)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	... 5 more
> Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException:
Cannot resolve 'java.lang.Object@74d44767' as a sensor (got type java.lang.Object)
> 	at java.util.concurrent.FutureTask.report(FutureTask.java:122)[:1.8.0_101]
> 	at java.util.concurrent.FutureTask.get(FutureTask.java:192)[:1.8.0_101]
> 	at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:63)[68:com.google.guava:18.0.0]
> 	at org.apache.brooklyn.util.core.task.BasicTask.get(BasicTask.java:361)[120:org.apache.brooklyn.core:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.camp.brooklyn.spi.dsl.BrooklynDslDeferredSupplier.get(BrooklynDslDeferredSupplier.java:114)[118:org.apache.brooklyn.camp:0.11.0.20170310_1638]
> 	... 7 more
> Caused by: java.lang.IllegalStateException: Cannot resolve 'java.lang.Object@74d44767'
as a sensor (got type java.lang.Object)
> 	at org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent$DslSensorSupplier$1.resolve(DslComponent.java:710)[118:org.apache.brooklyn.camp:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent$DslSensorSupplier$1.resolve(DslComponent.java:708)[118:org.apache.brooklyn.camp:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent$DslSensorSupplier$1.call(DslComponent.java:691)[118:org.apache.brooklyn.camp:0.11.0.20170310_1638]
> 	at org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent$DslSensorSupplier$1.call(DslComponent.java:688)[118:org.apache.brooklyn.camp:0.11.0.20170310_1638]
> 	... 5 more
> {noformat}
> The persisted state contains things like:
> {noformat}
>   <config>
>     <myConfigKeyName>myval</myConfigKeyName>
>     <sensorSupplier1>
>       <org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent_-DslSensorSupplier>
>         <component>
>           <componentId></componentId>
>           <scope>THIS</scope>
>         </component>
>         <sensorName>mySensorName</sensorName>
>       </org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent_-DslSensorSupplier>
>     </sensorSupplier1>
>  {noformat}
>  
> More recent persisted state would instead say {{<sensorName class="string">mySensorName</sensorName>}}.
> This is because the field {{DslSensorSupplier.sensorName}} was changed from type String
to Object in commit https://github.com/apache/brooklyn-server/commit/b70346cc6fd6c7a898305157082565e527649104
> When xstream tries to deserialize the persisted state, it doesn't know what type the
field should be. It therefore instantiates a {{java.lang.Object}} (and ignores the actual
xml element such as "mySensorName" in the example above!).



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message