You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sv...@apache.org on 2015/10/21 08:18:59 UTC
[1/5] incubator-brooklyn git commit: Add log.trace to
executionManager.submitNewTask
Repository: incubator-brooklyn
Updated Branches:
refs/heads/master db12b1776 -> 74f23fab1
Add log.trace to executionManager.submitNewTask
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/dfe78a68
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/dfe78a68
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/dfe78a68
Branch: refs/heads/master
Commit: dfe78a68bba6ac79f55bf0fbbb1cfe1f648c9e38
Parents: c2494dc
Author: Aled Sage <al...@gmail.com>
Authored: Wed Oct 14 15:25:47 2015 +0200
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Oct 20 16:14:48 2015 +0100
----------------------------------------------------------------------
.../apache/brooklyn/util/core/task/BasicExecutionManager.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dfe78a68/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java b/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java
index acdee37..4c9858a 100644
--- a/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java
+++ b/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java
@@ -546,6 +546,10 @@ public class BasicExecutionManager implements ExecutionManager {
@SuppressWarnings("unchecked")
protected <T> Task<T> submitNewTask(final Map<?,?> flags, final Task<T> task) {
+ if (log.isTraceEnabled()) log.trace("Submitting task {} ({}), with flags {}, and tags {}, job {}",
+ new Object[] {task.getId(), task, flags, task.getTags(),
+ (task instanceof TaskInternal ? ((TaskInternal<T>)task).getJob() : "<unavailable>")});
+
if (task instanceof ScheduledTask)
return (Task<T>) submitNewScheduledTask(flags, (ScheduledTask)task);
[3/5] incubator-brooklyn git commit: Re-add
Machines.findUniqueSshMachineLocation
Posted by sv...@apache.org.
Re-add Machines.findUniqueSshMachineLocation
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/32fa1ae9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/32fa1ae9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/32fa1ae9
Branch: refs/heads/master
Commit: 32fa1ae98fe14632bb69e870934bbc9e00a4ad89
Parents: ac58462
Author: Aled Sage <al...@gmail.com>
Authored: Tue Oct 20 17:46:27 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Oct 20 17:46:27 2015 +0100
----------------------------------------------------------------------
.../apache/brooklyn/core/location/Machines.java | 21 ++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/32fa1ae9/core/src/main/java/org/apache/brooklyn/core/location/Machines.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/location/Machines.java b/core/src/main/java/org/apache/brooklyn/core/location/Machines.java
index 9ec97e7..c4eb84c 100644
--- a/core/src/main/java/org/apache/brooklyn/core/location/Machines.java
+++ b/core/src/main/java/org/apache/brooklyn/core/location/Machines.java
@@ -27,15 +27,15 @@ import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.location.Location;
import org.apache.brooklyn.api.location.MachineLocation;
import org.apache.brooklyn.core.entity.Attributes;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Iterables;
-
import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation.LocalhostMachine;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
import org.apache.brooklyn.util.guava.Maybe;
import org.apache.brooklyn.util.net.HasNetworkAddresses;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Iterables;
/** utilities for working with MachineLocations */
public class Machines {
@@ -98,7 +98,16 @@ public class Machines {
return Maybe.absent(new IllegalStateException("No instances of "+type+" available (in "+items+")"));
return Maybe.of(result);
}
-
+
+ /**
+ * @deprecated since 0.9.0; see {@link #findUniqueMachineLocation(Iterable, Class)},
+ * e.g. {@code findUniqueMachineLocation(locations, SshMachineLocation.class)}
+ */
+ @Deprecated
+ public static Maybe<SshMachineLocation> findUniqueSshMachineLocation(Iterable<? extends Location> locations) {
+ return findUniqueMachineLocation(locations, SshMachineLocation.class);
+ }
+
public static Maybe<MachineLocation> findUniqueMachineLocation(Iterable<? extends Location> locations) {
return findUniqueMachineLocation(locations, MachineLocation.class);
}
[4/5] incubator-brooklyn git commit: Adds MachinesTest
Posted by sv...@apache.org.
Adds MachinesTest
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/6d155662
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/6d155662
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/6d155662
Branch: refs/heads/master
Commit: 6d155662a0d9188ef3c842817fb3ecf6d1e64b4f
Parents: 32fa1ae
Author: Aled Sage <al...@gmail.com>
Authored: Tue Oct 20 17:46:39 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Oct 20 17:54:49 2015 +0100
----------------------------------------------------------------------
.../brooklyn/core/location/MachinesTest.java | 158 +++++++++++++++++++
1 file changed, 158 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6d155662/core/src/test/java/org/apache/brooklyn/core/location/MachinesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/location/MachinesTest.java b/core/src/test/java/org/apache/brooklyn/core/location/MachinesTest.java
new file mode 100644
index 0000000..6e3875f
--- /dev/null
+++ b/core/src/test/java/org/apache/brooklyn/core/location/MachinesTest.java
@@ -0,0 +1,158 @@
+/*
+ * 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.core.location;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.core.entity.Attributes;
+import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
+import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation.LocalhostMachine;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+public class MachinesTest extends BrooklynAppUnitTestSupport {
+
+ protected String publicAddr = "1.2.3.4";
+ protected String privateAddr = "10.1.2.3";
+
+ protected SshMachineLocation sshMachine;
+ protected SshMachineLocation sshMachineWithoutPrivate;
+ protected SshMachineLocation localMachine;
+ protected LocalhostMachineProvisioningLocation otherLoc;
+
+ @BeforeMethod(alwaysRun=true)
+ public void setUp() throws Exception {
+ super.setUp();
+ sshMachine = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
+ .configure("address", publicAddr)
+ .configure(SshMachineLocation.PRIVATE_ADDRESSES, ImmutableList.of(privateAddr)));
+ sshMachineWithoutPrivate = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
+ .configure("address", publicAddr));
+ otherLoc = app.newLocalhostProvisioningLocation();
+ localMachine = otherLoc.obtain();
+ }
+
+ @Test
+ public void testFindUniqueMachineLocation() throws Exception {
+ assertEquals(Machines.findUniqueMachineLocation(ImmutableList.of(sshMachine, otherLoc)).get(), sshMachine);
+ assertFalse(Machines.findUniqueMachineLocation(ImmutableList.of(otherLoc)).isPresent());
+ }
+
+ @Test
+ @SuppressWarnings("deprecation")
+ public void testFindUniqueSshMachineLocation() throws Exception {
+ assertEquals(Machines.findUniqueSshMachineLocation(ImmutableList.of(sshMachine, otherLoc)).get(), sshMachine);
+ assertFalse(Machines.findUniqueSshMachineLocation(ImmutableList.of(otherLoc)).isPresent());
+ }
+
+ @Test
+ public void testFindUniqueMachineLocationOfType() throws Exception {
+ assertEquals(Machines.findUniqueMachineLocation(ImmutableList.of(sshMachine, otherLoc), SshMachineLocation.class).get(), sshMachine);
+ assertFalse(Machines.findUniqueMachineLocation(ImmutableList.of(sshMachine), LocalhostMachine.class).isPresent());
+ }
+
+ @Test
+ public void testFindSubnetIpFromAttribute() throws Exception {
+ TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
+ .location(sshMachine));
+ entity.sensors().set(Attributes.SUBNET_ADDRESS, "myaddr");
+
+ assertEquals(Machines.findSubnetIp(entity).get(), "myaddr");
+ }
+
+ @Test
+ public void testFindSubnetIpFromLocation() throws Exception {
+ TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
+ .location(sshMachine));
+
+ assertEquals(Machines.findSubnetIp(entity).get(), privateAddr);
+ }
+
+ @Test
+ public void testFindSubnetHostnameFromAttribute() throws Exception {
+ TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
+ .location(sshMachine));
+ entity.sensors().set(Attributes.SUBNET_HOSTNAME, "myval");
+ assertEquals(Machines.findSubnetHostname(entity).get(), "myval");
+ }
+
+ @Test
+ public void testFindSubnetHostnameFromLocation() throws Exception {
+ TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
+ .location(sshMachine));
+
+ assertEquals(Machines.findSubnetHostname(entity).get(), publicAddr);
+ }
+
+ @Test
+ public void testFindSubnetOrPrivateIpWithAddressAttributePrefersLocationPrivateIp() throws Exception {
+ TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
+ .location(sshMachine));
+ entity.sensors().set(Attributes.ADDRESS, "myval");
+
+ assertEquals(Machines.findSubnetOrPrivateIp(entity).get(), privateAddr);
+ }
+
+ // TODO Why do we only return the "myval" (rather than publicAddr) if Attributes.ADDRESS is set?
+ @Test
+ public void testFindSubnetOrPrivateIpFromAttribute() throws Exception {
+ TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
+ .location(sshMachine));
+ entity.sensors().set(Attributes.ADDRESS, "ignored-val");
+ entity.sensors().set(Attributes.SUBNET_ADDRESS, "myval");
+
+ assertEquals(Machines.findSubnetOrPrivateIp(entity).get(), "myval");
+ }
+
+ // TODO Why do we only return the privateAddr (rather than publicAddr) if Attributes.ADDRESS is set?
+ @Test
+ public void testFindSubnetOrPrivateIpFromLocation() throws Exception {
+ TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
+ .location(sshMachine));
+ entity.sensors().set(Attributes.ADDRESS, "ignored-val");
+
+ assertEquals(Machines.findSubnetOrPrivateIp(entity).get(), privateAddr);
+ }
+
+ @Test
+ public void testFindSubnetOrPrivateIpFromLocationWithoutPrivate() throws Exception {
+ TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
+ .location(sshMachineWithoutPrivate));
+ entity.sensors().set(Attributes.ADDRESS, "ignored-val");
+
+ assertEquals(Machines.findSubnetOrPrivateIp(entity).get(), publicAddr);
+ }
+
+ @Test
+ public void testWarnIfLocalhost() throws Exception {
+ assertFalse(Machines.warnIfLocalhost(ImmutableList.of(sshMachine), "my message"));
+
+ // Visual inspection test - expect a log.warn
+ assertTrue(Machines.warnIfLocalhost(ImmutableList.of(localMachine), "my message"));
+ }
+}
[2/5] incubator-brooklyn git commit: Test class
BailOutJcloudsLocation: improve exceptions
Posted by sv...@apache.org.
Test class BailOutJcloudsLocation: improve exceptions
Previously it threw an exception defined as a constant, so the
stacktrace was useless. Now it throws an exception that has as
its cause the constant-exception.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/ac58462a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/ac58462a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/ac58462a
Branch: refs/heads/master
Commit: ac58462ac3fa7a48924a81428cccf0bc4569b35f
Parents: dfe78a6
Author: Aled Sage <al...@gmail.com>
Authored: Thu Oct 15 15:30:42 2015 +0200
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Oct 20 16:15:04 2015 +0100
----------------------------------------------------------------------
.../location/jclouds/BailOutJcloudsLocation.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac58462a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java
index d31d7e5..10a32b4 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java
@@ -42,6 +42,8 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
+import com.google.common.base.Throwables;
+import com.google.common.collect.Iterables;
import com.google.common.reflect.TypeToken;
public class BailOutJcloudsLocation extends JcloudsLocation {
@@ -81,7 +83,7 @@ public class BailOutJcloudsLocation extends JcloudsLocation {
if (Boolean.TRUE.equals(getConfig(BUILD_TEMPLATE))) {
template = super.buildTemplate(computeService, config);
}
- throw BAIL_OUT_FOR_TESTING;
+ throw new RuntimeException(BAIL_OUT_FOR_TESTING);
}
public Template getTemplate() {
@@ -100,8 +102,14 @@ public class BailOutJcloudsLocation extends JcloudsLocation {
try {
obtain(flags);
} catch (Exception e) {
- if (e == BAIL_OUT_FOR_TESTING || e.getCause() == BAIL_OUT_FOR_TESTING
- || (e instanceof CompoundRuntimeException && ((CompoundRuntimeException) e).getAllCauses().contains(BAIL_OUT_FOR_TESTING))) {
+ boolean found = Iterables.tryFind(Throwables.getCausalChain(e), Predicates.<Throwable>equalTo(e)).isPresent();
+ if (!found && e instanceof CompoundRuntimeException) {
+ for (Throwable cause : ((CompoundRuntimeException) e).getAllCauses()) {
+ found = Iterables.tryFind(Throwables.getCausalChain(cause), Predicates.<Throwable>equalTo(e)).isPresent();
+ if (found) break;
+ }
+ }
+ if (found) {
test.apply(lastConfigBag);
} else {
throw Exceptions.propagate(e);
[5/5] incubator-brooklyn git commit: This closes #974
Posted by sv...@apache.org.
This closes #974
Various minor
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/74f23fab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/74f23fab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/74f23fab
Branch: refs/heads/master
Commit: 74f23fab154b2f33ba9ebc8c70b21210bd6e7814
Parents: db12b17 6d15566
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Wed Oct 21 09:17:59 2015 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Wed Oct 21 09:17:59 2015 +0300
----------------------------------------------------------------------
.../apache/brooklyn/core/location/Machines.java | 21 ++-
.../util/core/task/BasicExecutionManager.java | 4 +
.../brooklyn/core/location/MachinesTest.java | 158 +++++++++++++++++++
.../jclouds/BailOutJcloudsLocation.java | 14 +-
4 files changed, 188 insertions(+), 9 deletions(-)
----------------------------------------------------------------------