You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by sjcorbett <gi...@git.apache.org> on 2016/12/09 18:55:37 UTC
[GitHub] brooklyn-server pull request #484: Small JcloudsLocation refactor
GitHub user sjcorbett opened a pull request:
https://github.com/apache/brooklyn-server/pull/484
Small JcloudsLocation refactor
I took the opportunity to move a number of the supporting classes in `JcloudsLocation` to their own top-level classes. I particular I touched `RebindToMachinePredicate`, the logic for creating users, and all of the `CustomizeTemplateOptions` and `CustomizeTemplateBuilders`.
It's a fairly large PR but I haven't introduced much that's new or changed any existing functionality. Most of it is ASF license headers.
Suggest reviewing it with whitespace changes disabled (append `?w=1` to GitHub's URL).
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/sjcorbett/brooklyn-server jclouds-location
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/brooklyn-server/pull/484.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 #484
----
commit c82d1679ecb545045914fc5312cf6aef32a44bb1
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Date: 2016-12-01T15:11:24Z
Deletions, deprecations and typos
* Remove ComputeService arg from JcloudsLocation.resolveManagementHostAndPort
* Improve javadoc for Duration.of
* Deprecate Attributes.HOST_AND_PORT and delete Attributes.SERVICE_STATE
* Miscellaneous typos
* Readability of JcloudsLocation and related classes
* Delete method commented out for two years
* Remove ComputeService arg from JcloudsLocation.resolveManagementHostAndPort
commit cde849b4cbaecf2e8da5bd09809c279ad823b800
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Date: 2016-12-07T11:56:40Z
Move JcloudsLocation's logic for creating users to separate class
commit 2d6071f12eaff646bfd535e3d22648a6bfc84724
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Date: 2016-12-07T12:06:02Z
Extract RebindToMachinePredicate from JcloudsLocation
commit cfeb4109529f9578fa892d40acf7b7809df00335
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Date: 2016-12-09T16:46:46Z
Extract CustomizeTemplateOptions and its implementations from JcloudsLocation
commit 364218eb842c8af0b29324279d0cb8516c285a13
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Date: 2016-12-09T17:29:55Z
Extract CustomizeTemplateBuilder from JcloudsLocation
----
---
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 #484: Small JcloudsLocation refactor
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/484#discussion_r93065657
--- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/templates/customize/CustomizeTemplateOptions2.java ---
@@ -0,0 +1,103 @@
+/*
+ * 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.location.jclouds.templates.customize;
+
+// Has "2" in its name so JcloudsLocation can use it without having to use a fully qualified reference.
+public class CustomizeTemplateOptions2 {
--- End diff --
Unfortunate that `CustomizeTemplateOptions` is already taken. I don't like the "2" in the name, but not sure what to suggest that would be better (unless we can delete the existing interface `CustomizeTemplateOptions`).
I don't think the interface `JcloudsLocation.CustomizeTemplateOptions` will be mentioned in any persisted state, so deleting it is just about source-level compatibility with anything that uses it directly. I lean towards treating that as a part of our "internal" API, so deleting it. It should be easy to fix any downstream projects that then fail to compile.
We'd then use the nicer name of `CustomizeTemplateOptions` for this class.
@sjcorbett Thoughts?
---
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 #484: Small JcloudsLocation refactor
Posted by geomacy <gi...@git.apache.org>.
Github user geomacy commented on the issue:
https://github.com/apache/brooklyn-server/pull/484
Looks good @sjcorbett, a useful tidy-up to this big class; have had a look through PR but nothing to add to above comments.
---
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 #484: Small JcloudsLocation refactor
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/brooklyn-server/pull/484
---
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 #484: Small JcloudsLocation refactor
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on the issue:
https://github.com/apache/brooklyn-server/pull/484
@aledsage My intention was to avoid anything that was persisted. Of the classes touched:
* `RebindToMachinePredicate` was a private static class that is created in `getRebindToMachinePredicate` rather than injected through config.
* `UserCreation` shouldn't have been persisted unless someone has done something strange, but still exists and is usable as before.
* Nobody should have persisted `SUPPORTED_TEMPLATE_OPTIONS_PROPERTIES` and `SUPPORTED_TEMPLATE_BUILDER_PROPERTIES`. All related classes were anonymous inner classes.
---
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 #484: Small JcloudsLocation refactor
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/484#discussion_r93061840
--- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/RebindToMachinePredicate.java ---
@@ -0,0 +1,85 @@
+/*
+ * 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.location.jclouds;
+
+import org.apache.brooklyn.util.core.config.ConfigBag;
+import org.jclouds.compute.domain.ComputeMetadata;
+import org.jclouds.compute.domain.NodeMetadata;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Predicate;
+
+/**
+ * Determines whether a machine may be rebinded to by comparing the given id, hostname and region
+ * against the node's id, hostname, provider id and public addresses.
+ */
+class RebindToMachinePredicate implements Predicate<ComputeMetadata> {
--- End diff --
Great that this is extracted - we could write unit tests for it now, but there is most probably lower hanging fruit for improving our 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 #484: Small JcloudsLocation refactor
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/484#discussion_r93063249
--- Diff: utils/common/src/main/java/org/apache/brooklyn/util/text/Strings.java ---
@@ -827,6 +828,33 @@ public static String ies(Iterator<?> x) {
return result;
}
+ /**
+ * Tries to convert v to a list of strings.
+ * <p>
+ * If v is <code>null</code> then the method returns an empty immutable list.
+ * If v is {@link Iterable} or an <code>Object[]</code> then toString is called on its elements.
+ * If v is a {@link String} then a singleton list containing v is returned.
+ * Otherwise the method throws an {@link IllegalArgumentException}.
+ */
+ public static List<String> toStringList(Object v) {
--- End diff --
Would be good to add unit tests for this (but we can do that in a separate PR, given that this PR has just moved it from one place to another).
---
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 #484: Small JcloudsLocation refactor
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/484#discussion_r93069569
--- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/templates/customize/CustomizeTemplateOptions2.java ---
@@ -0,0 +1,103 @@
+/*
+ * 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.location.jclouds.templates.customize;
+
+// Has "2" in its name so JcloudsLocation can use it without having to use a fully qualified reference.
+public class CustomizeTemplateOptions2 {
--- End diff --
Or we could go for different naming, such as `TemplateOptionsCustomizer` (and `TemplateBuilderCustomizer`). That is tempting, in that it uses a noun rather verb for the classname (i.e. follows standard Java naming conventions).
---
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 #484: Small JcloudsLocation refactor
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/484#discussion_r93069881
--- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/templates/customize/CustomizeTemplateOptions2.java ---
@@ -0,0 +1,103 @@
+/*
+ * 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.location.jclouds.templates.customize;
+
+// Has "2" in its name so JcloudsLocation can use it without having to use a fully qualified reference.
+public class CustomizeTemplateOptions2 {
--- End diff --
I like your second suggestion. Will rename them when I resolve the conflict.
---
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 #484: Small JcloudsLocation refactor
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on the issue:
https://github.com/apache/brooklyn-server/pull/484
Thanks @aledsage and @geomacy. I will merge this 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 #484: Small JcloudsLocation refactor
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on the issue:
https://github.com/apache/brooklyn-server/pull/484
P.S. to preempt Jenkins: tests pass locally.
---
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 #484: Small JcloudsLocation refactor
Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on the issue:
https://github.com/apache/brooklyn-server/pull/484
Thanks @sjcorbett - looks great. Unfortunately there are merge conflicts again (probably due to https://github.com/apache/brooklyn-server/pull/496).
Once those are resolved, and you've taken a look through the comments to see what you think is worth addressing, then this is good to merge. Happy for you to do that as soon as you're ready, before any more conflicts come in!
---
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 #484: Small JcloudsLocation refactor
Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on the issue:
https://github.com/apache/brooklyn-server/pull/484
Thanks @sjcorbett - great to separate out this huge class, and improve this code!
I haven't had a proper chance to review yet. Does it change the names of any classes that might be referenced in persisted state? Do we need to add anything to `deserializingClassRenames.properties`?
---
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.
---