You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by aledsage <gi...@git.apache.org> on 2017/03/14 11:45:55 UTC

[GitHub] brooklyn-server pull request #593: Adds yaml-dsl rebind tests (for historic ...

GitHub user aledsage opened a pull request:

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

    Adds yaml-dsl rebind tests (for historic state) [WIP]

    Tests currently fail (because the DSL class field was changed from `String` to `Object`).
    @m4rkmckenna and myself are looking into fixing this.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/aledsage/brooklyn-server test-dsl-rebind

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-server/pull/593.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 #593
    
----
commit 0dd7132fa7a9deadfe29d3b97fb2263f446f40bf
Author: Aled Sage <al...@gmail.com>
Date:   2017-03-14T11:44:31Z

    Adds yaml-dsl rebind tests (for historic state)

----


---
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 #593: BROOKLYN-451: Adds yaml-dsl rebind tests ...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

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


---
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 #593: BROOKLYN-451: Adds yaml-dsl rebind tests ...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/593#discussion_r105973026
  
    --- Diff: core/src/main/java/org/apache/brooklyn/util/core/xstream/XmlSerializer.java ---
    @@ -80,6 +80,11 @@ protected MapperWrapper wrapMapper(MapperWrapper next) {
     
             xstream.registerConverter(new EnumCaseForgivingConverter());
             xstream.registerConverter(new Inet4AddressConverter());
    +        
    +        // See ObjectWithDefaultStringImplConverter (and its usage) for why we want to auto-detect 
    +        // annotations (usages of this is in the camp project, so we can't just list it statically
    +        // here unfortunately).
    +        xstream.autodetectAnnotations(true);
    --- End diff --
    
    Seems to be about 5-10% overhead (when testing with a simple EntityMemento that has lots of string keys and brooklyn.parameters). That's certainly acceptable, to fix the issue!


---
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 #593: BROOKLYN-451: Adds yaml-dsl rebind tests (for hi...

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on the issue:

    https://github.com/apache/brooklyn-server/pull/593
  
    LGTM


---
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 #593: BROOKLYN-451: Adds yaml-dsl rebind tests ...

Posted by m4rkmckenna <gi...@git.apache.org>.
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


---
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 #593: Adds yaml-dsl rebind tests (for historic ...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/593#discussion_r105950198
  
    --- Diff: core/src/main/java/org/apache/brooklyn/util/core/xstream/XmlSerializer.java ---
    @@ -80,6 +80,11 @@ protected MapperWrapper wrapMapper(MapperWrapper next) {
     
             xstream.registerConverter(new EnumCaseForgivingConverter());
             xstream.registerConverter(new Inet4AddressConverter());
    +        
    +        // See ObjectWithDefaultStringImplConverter (and its usage) for why we want to auto-detect 
    +        // annotations (usages of this is in the camp project, so we can't just list it statically
    +        // here unfortunately).
    +        xstream.autodetectAnnotations(true);
    --- End diff --
    
    What are the performance implications of this?!


---
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 #593: BROOKLYN-451: Adds yaml-dsl rebind tests (for hi...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on the issue:

    https://github.com/apache/brooklyn-server/pull/593
  
    Thanks @neykov @m4rkmckenna. I've added the comment you suggested. Merging 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 #593: BROOKLYN-451: Adds yaml-dsl rebind tests ...

Posted by m4rkmckenna <gi...@git.apache.org>.
Github user m4rkmckenna commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/593#discussion_r105952235
  
    --- Diff: core/src/main/java/org/apache/brooklyn/util/core/xstream/XmlSerializer.java ---
    @@ -80,6 +80,11 @@ protected MapperWrapper wrapMapper(MapperWrapper next) {
     
             xstream.registerConverter(new EnumCaseForgivingConverter());
             xstream.registerConverter(new Inet4AddressConverter());
    +        
    +        // See ObjectWithDefaultStringImplConverter (and its usage) for why we want to auto-detect 
    +        // annotations (usages of this is in the camp project, so we can't just list it statically
    +        // here unfortunately).
    +        xstream.autodetectAnnotations(true);
    --- End diff --
    
    From http://x-stream.github.io/annotations-tutorial.html#AutoDetect
    
    > In auto-detection mode XStream will have to examine any unknown class type for annotations. This will slow down the marshalling process until all processed types have been examined once.


---
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.
---