brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [1/2] brooklyn-server git commit: BROOKLYN-303: Fix EmptyWindowsProcess
Date Thu, 16 Jun 2016 16:39:33 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 460db56a4 -> b6a65650e


BROOKLYN-303: Fix EmptyWindowsProcess

Previously gave NPE in driver


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/8fe41409
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/8fe41409
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/8fe41409

Branch: refs/heads/master
Commit: 8fe4140936792581b311cff39510b84f06ee22a0
Parents: 82511c3
Author: Aled Sage <aled.sage@gmail.com>
Authored: Thu Jun 16 12:33:12 2016 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Thu Jun 16 12:41:41 2016 +0100

----------------------------------------------------------------------
 .../brooklyn/camp/brooklyn/EmptyWindowsProcessYamlTest.java | 7 +++++--
 .../software/base/EmptyWindowsProcessWinRmDriver.java       | 5 ++++-
 .../org/apache/brooklyn/util/net/UserAndHostAndPort.java    | 9 +++++++++
 3 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8fe41409/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/EmptyWindowsProcessYamlTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/EmptyWindowsProcessYamlTest.java
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/EmptyWindowsProcessYamlTest.java
index 77043c7..3eaa963 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/EmptyWindowsProcessYamlTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/EmptyWindowsProcessYamlTest.java
@@ -32,14 +32,17 @@ import com.google.common.collect.Iterables;
 @Test
 public class EmptyWindowsProcessYamlTest extends AbstractYamlTest {
 
-    @Test(groups="Integration")
+    // takes couple of seconds unfortunately (why?!), but our only unit-test coverage of

+    // EmptyWindowsProcess so including in unit tests anyway.
+    @Test
     public void testNoWinrm() throws Exception {
         Entity app = createAndStartApplication(
                 "location: byon:(hosts=\"1.2.3.4\",osFamily=windows)",
                 "services:",
                 "- type: "+EmptyWindowsProcess.class.getName(),
                 "  brooklyn.config:",
-                "    winrmMonitoring.enabled: false");
+                "    winrmMonitoring.enabled: false",
+                "    onbox.base.dir.skipResolution: true");
         waitForApplicationTasks(app);
 
         EmptyWindowsProcess entity = Iterables.getOnlyElement(Entities.descendants(app, EmptyWindowsProcess.class));

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8fe41409/software/base/src/main/java/org/apache/brooklyn/entity/software/base/EmptyWindowsProcessWinRmDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/EmptyWindowsProcessWinRmDriver.java
b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/EmptyWindowsProcessWinRmDriver.java
index 98d40d87..c7842ba 100644
--- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/EmptyWindowsProcessWinRmDriver.java
+++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/EmptyWindowsProcessWinRmDriver.java
@@ -28,6 +28,8 @@ import org.apache.brooklyn.util.net.UserAndHostAndPort;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Optional;
+
 public class EmptyWindowsProcessWinRmDriver extends AbstractSoftwareProcessWinRmDriver implements
VanillaWindowsProcessDriver {
     @SuppressWarnings("unused")
     private static final Logger LOG = LoggerFactory.getLogger(EmptyWindowsProcessWinRmDriver.class);
@@ -41,7 +43,8 @@ public class EmptyWindowsProcessWinRmDriver extends AbstractSoftwareProcessWinRm
     @Override
     public void start() {
         WinRmMachineLocation machine = (WinRmMachineLocation) location;
-        UserAndHostAndPort winrmAddress = UserAndHostAndPort.fromParts(machine.getUser(),
machine.getAddress().getHostName(), entity.getConfig(WinRmTool.PROP_PORT));
+        Integer port = entity.getConfig(WinRmTool.PROP_PORT);
+        UserAndHostAndPort winrmAddress = UserAndHostAndPort.fromParts(machine.getUser(),
machine.getAddress().getHostName(), Optional.fromNullable(port));
         getEntity().sensors().set(Attributes.WINRM_ADDRESS, winrmAddress);
 
         super.start();

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8fe41409/utils/common/src/main/java/org/apache/brooklyn/util/net/UserAndHostAndPort.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/net/UserAndHostAndPort.java
b/utils/common/src/main/java/org/apache/brooklyn/util/net/UserAndHostAndPort.java
index d48dccd..558af0c 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/net/UserAndHostAndPort.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/net/UserAndHostAndPort.java
@@ -21,6 +21,7 @@ package org.apache.brooklyn.util.net;
 import java.io.Serializable;
 
 import com.google.common.base.Objects;
+import com.google.common.base.Optional;
 import com.google.common.net.HostAndPort;
 
 public class UserAndHostAndPort implements Serializable {
@@ -31,6 +32,14 @@ public class UserAndHostAndPort implements Serializable {
         return new UserAndHostAndPort(user, HostAndPort.fromParts(host, port));
     }
 
+    public static UserAndHostAndPort fromParts(String user, String host, Optional<Integer>
port) {
+        HostAndPort hostAndPort = port.isPresent() ? HostAndPort.fromParts(host, port.get())
: HostAndPort.fromString(host);
+        if (!port.isPresent() && hostAndPort.hasPort()) {
+            throw new IllegalArgumentException("optional port absent, but host '"+host+"'
parsed as containing port");
+        }
+        return new UserAndHostAndPort(user, hostAndPort);
+    }
+
     public static UserAndHostAndPort fromParts(String user, HostAndPort hostAndPort) {
         return new UserAndHostAndPort(user, hostAndPort);
     }


Mime
View raw message