You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2015/02/18 13:41:50 UTC
[1/4] incubator-brooklyn git commit: Add
ExceptionsTest.testCollapseTextWhenExceptionMessageEmpty
Repository: incubator-brooklyn
Updated Branches:
refs/heads/master 1d1cfe713 -> 217bd0182
Add ExceptionsTest.testCollapseTextWhenExceptionMessageEmpty
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/a710bb71
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/a710bb71
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/a710bb71
Branch: refs/heads/master
Commit: a710bb7190cf4c05a9c08156e90e7c4593b5e336
Parents: 2227415
Author: Aled Sage <al...@gmail.com>
Authored: Wed Feb 18 10:18:14 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Feb 18 12:06:26 2015 +0000
----------------------------------------------------------------------
.../src/test/java/brooklyn/util/exceptions/ExceptionsTest.java | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a710bb71/utils/common/src/test/java/brooklyn/util/exceptions/ExceptionsTest.java
----------------------------------------------------------------------
diff --git a/utils/common/src/test/java/brooklyn/util/exceptions/ExceptionsTest.java b/utils/common/src/test/java/brooklyn/util/exceptions/ExceptionsTest.java
index 94b49af..5bb83aa 100644
--- a/utils/common/src/test/java/brooklyn/util/exceptions/ExceptionsTest.java
+++ b/utils/common/src/test/java/brooklyn/util/exceptions/ExceptionsTest.java
@@ -53,6 +53,12 @@ public class ExceptionsTest {
assertContains(e, "ConcurrentModification");
}
+ @Test
+ public void testCollapseTextWhenExceptionMessageEmpty() throws Exception {
+ String text = Exceptions.collapseText(new ExecutionException(new IllegalStateException()));
+ Assert.assertNotNull(text);
+ }
+
private void assert12StandardChecks(RuntimeException e, boolean isPropagated) {
String collapseText = Exceptions.collapseText(e);
log.info("Exception collapsing got: "+collapseText+" ("+e+")");
[2/4] incubator-brooklyn git commit: Jclouds openIptables: avoid NPE
if no inboundPorts
Posted by al...@apache.org.
Jclouds openIptables: avoid NPE if no inboundPorts
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/2227415b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/2227415b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/2227415b
Branch: refs/heads/master
Commit: 2227415b25f0b821f23c1899181f6040195fc54b
Parents: 0416bd1
Author: Aled Sage <al...@gmail.com>
Authored: Wed Feb 18 10:08:24 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Feb 18 12:06:26 2015 +0000
----------------------------------------------------------------------
.../location/jclouds/JcloudsLocation.java | 38 +++++++++++---------
1 file changed, 22 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2227415b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
index 37272d4..706b3ee 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
@@ -742,25 +742,31 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im
}
if (setup.get(OPEN_IPTABLES)) {
- customisationForLogging.add("open iptables");
-
@SuppressWarnings("unchecked")
- List<String> iptablesRules = createIptablesRulesForNetworkInterface((Iterable<Integer>) setup.get(INBOUND_PORTS));
- iptablesRules.add(IptablesCommands.saveIptablesRules());
- List<String> batch = Lists.newArrayList();
- // Some entities, such as Riak (erlang based) have a huge range of ports, which leads to a script that
- // is too large to run (fails with a broken pipe). Batch the rules into batches of 50
- for (String rule : iptablesRules) {
- batch.add(rule);
- if (batch.size() == 50) {
- sshMachineLocation.execCommands("Inserting iptables rules, 50 command batch", batch);
- batch.clear();
+ Iterable<Integer> inboundPorts = (Iterable<Integer>) setup.get(INBOUND_PORTS);
+
+ if (inboundPorts == null || Iterables.isEmpty(inboundPorts)) {
+ LOG.info("No ports to open in iptables (no inbound ports) for {} at {}", sshMachineLocation, this);
+ } else {
+ customisationForLogging.add("open iptables");
+
+ List<String> iptablesRules = createIptablesRulesForNetworkInterface(inboundPorts);
+ iptablesRules.add(IptablesCommands.saveIptablesRules());
+ List<String> batch = Lists.newArrayList();
+ // Some entities, such as Riak (erlang based) have a huge range of ports, which leads to a script that
+ // is too large to run (fails with a broken pipe). Batch the rules into batches of 50
+ for (String rule : iptablesRules) {
+ batch.add(rule);
+ if (batch.size() == 50) {
+ sshMachineLocation.execCommands("Inserting iptables rules, 50 command batch", batch);
+ batch.clear();
+ }
}
+ if (batch.size() > 0) {
+ sshMachineLocation.execCommands("Inserting iptables rules", batch);
+ }
+ sshMachineLocation.execCommands("List iptables rules", ImmutableList.of(IptablesCommands.listIptablesRule()));
}
- if (batch.size() > 0) {
- sshMachineLocation.execCommands("Inserting iptables rules", batch);
- }
- sshMachineLocation.execCommands("List iptables rules", ImmutableList.of(IptablesCommands.listIptablesRule()));
}
if (setup.get(STOP_IPTABLES)) {
[3/4] incubator-brooklyn git commit: PortRanges: check range is valid
Posted by al...@apache.org.
PortRanges: check range is valid
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/0416bd1a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/0416bd1a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/0416bd1a
Branch: refs/heads/master
Commit: 0416bd1aa04a01c0985c44d710312ebc711f798d
Parents: e0cc1a6
Author: Aled Sage <al...@gmail.com>
Authored: Wed Feb 18 10:07:32 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Feb 18 12:06:26 2015 +0000
----------------------------------------------------------------------
.../brooklyn/location/basic/PortRanges.java | 7 +++-
.../brooklyn/location/basic/PortRangesTest.java | 41 +++++++++++++++++++-
2 files changed, 45 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0416bd1a/core/src/main/java/brooklyn/location/basic/PortRanges.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/basic/PortRanges.java b/core/src/main/java/brooklyn/location/basic/PortRanges.java
index 63d9b23..75cd5a5 100644
--- a/core/src/main/java/brooklyn/location/basic/PortRanges.java
+++ b/core/src/main/java/brooklyn/location/basic/PortRanges.java
@@ -18,6 +18,8 @@
*/
package brooklyn.location.basic;
+import static com.google.common.base.Preconditions.checkArgument;
+
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
@@ -80,7 +82,10 @@ public class PortRanges {
this.start = start;
this.end = end;
this.delta = delta;
- assert delta!=0;
+ checkArgument(start > 0 && start <= MAX_PORT, "start port %s out of range", start);
+ checkArgument(end > 0 && end <= MAX_PORT, "end port %s out of range", end);
+ checkArgument(delta > 0 ? start <= end : start >= end, "start and end out of order: %s to %s, delta %s", start, end, delta);
+ checkArgument(delta != 0, "delta must be non-zero");
}
public LinearPortRange(int start, int end) {
this(start, end, (start<=end?1:-1));
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0416bd1a/core/src/test/java/brooklyn/location/basic/PortRangesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/basic/PortRangesTest.java b/core/src/test/java/brooklyn/location/basic/PortRangesTest.java
index c533490..506628b 100644
--- a/core/src/test/java/brooklyn/location/basic/PortRangesTest.java
+++ b/core/src/test/java/brooklyn/location/basic/PortRangesTest.java
@@ -18,16 +18,20 @@
*/
package brooklyn.location.basic;
+import static org.testng.Assert.assertEquals;
+
import java.util.Iterator;
import org.testng.Assert;
import org.testng.annotations.Test;
-import com.google.common.collect.ImmutableList;
-
import brooklyn.location.PortRange;
+import brooklyn.location.basic.PortRanges.LinearPortRange;
import brooklyn.util.flags.TypeCoercions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
public class PortRangesTest {
@Test
@@ -65,6 +69,12 @@ public class PortRangesTest {
}
@Test
+ public void testFromStringThrowsIllegalArgumentException() {
+ assertFromStringThrowsIllegalArgumentException("80-100000");
+ assertFromStringThrowsIllegalArgumentException("0-80");
+ }
+
+ @Test
public void testCoercion() {
PortRanges.init();
PortRange r = TypeCoercions.coerce("80", PortRange.class);
@@ -77,6 +87,33 @@ public class PortRangesTest {
PortRange r = TypeCoercions.coerce(80, PortRange.class);
assertContents(r, 80);
}
+
+ @Test
+ public void testLinearRangeOfSizeOne() throws Exception {
+ LinearPortRange range = new LinearPortRange(80, 80);
+ assertEquals(Lists.newArrayList(range), ImmutableList.of(80));
+ }
+
+ @Test
+ public void testLinearRangeCountingUpwards() throws Exception {
+ LinearPortRange range = new LinearPortRange(80, 81);
+ assertEquals(Lists.newArrayList(range), ImmutableList.of(80, 81));
+ }
+
+ @Test
+ public void testLinearRangeCountingDownwards() throws Exception {
+ LinearPortRange range = new LinearPortRange(80, 79);
+ assertEquals(Lists.newArrayList(range), ImmutableList.of(80, 79));
+ }
+
+ protected void assertFromStringThrowsIllegalArgumentException(String range) {
+ try {
+ PortRanges.fromString(range);
+ Assert.fail();
+ } catch (IllegalArgumentException e) {
+ // success
+ }
+ }
private static <T> void assertContents(Iterable<T> actual, T ...expected) {
Iterator<T> i = actual.iterator();
[4/4] incubator-brooklyn git commit: This closes #518
Posted by al...@apache.org.
This closes #518
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/217bd018
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/217bd018
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/217bd018
Branch: refs/heads/master
Commit: 217bd018297f629b7e3176c7e042f67d97c39a6f
Parents: 1d1cfe7 a710bb7
Author: Aled Sage <al...@gmail.com>
Authored: Wed Feb 18 12:41:27 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Feb 18 12:41:27 2015 +0000
----------------------------------------------------------------------
.../brooklyn/location/basic/PortRanges.java | 7 +++-
.../brooklyn/location/basic/PortRangesTest.java | 41 +++++++++++++++++++-
.../location/jclouds/JcloudsLocation.java | 38 ++++++++++--------
.../util/exceptions/ExceptionsTest.java | 6 +++
4 files changed, 73 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/217bd018/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------