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 2017/12/21 15:06:00 UTC
[1/2] brooklyn-server git commit: DynamicCluster's max size applies
to all calls to grow
Repository: brooklyn-server
Updated Branches:
refs/heads/master b65451764 -> cd5be2070
DynamicCluster's max size applies to all calls to grow
Previously the limit was ignored by resizeByDelta.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/c0f409f6
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/c0f409f6
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/c0f409f6
Branch: refs/heads/master
Commit: c0f409f6437e5abcaf5a703ea5c7b92b388263ce
Parents: 21c2853
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Tue Dec 12 12:18:29 2017 +0000
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Tue Dec 12 15:51:41 2017 +0000
----------------------------------------------------------------------
.../brooklyn/entity/group/DynamicClusterImpl.java | 12 ++++++++----
.../brooklyn/entity/group/DynamicClusterTest.java | 16 ++++++++++------
2 files changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c0f409f6/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
index 75f3d83..7102b3b 100644
--- a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
+++ b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
@@ -621,10 +621,6 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus
@Override
public Integer resize(Integer desiredSize) {
synchronized (mutex) {
- Optional<Integer> optionalMaxSize = Optional.fromNullable(config().get(MAX_SIZE));
- if (optionalMaxSize.isPresent() && desiredSize > optionalMaxSize.get()) {
- throw new Resizable.InsufficientCapacityException("Desired cluster size " + desiredSize + " exceeds maximum size of " + optionalMaxSize.get());
- }
int originalSize = getCurrentSize();
int delta = desiredSize - originalSize;
if (delta != 0) {
@@ -799,6 +795,14 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus
/** <strong>Note</strong> for sub-classes; this method can be called while synchronized on {@link #mutex}. */
protected Collection<Entity> grow(int delta) {
Preconditions.checkArgument(delta > 0, "Must call grow with positive delta.");
+ Integer maxSize = config().get(MAX_SIZE);
+ if (maxSize != null) {
+ final int desiredSize = getCurrentSize() + delta;
+ if (desiredSize > maxSize) {
+ throw new Resizable.InsufficientCapacityException(
+ "Desired cluster size " + desiredSize + " exceeds maximum size of " + maxSize);
+ }
+ }
// choose locations to be deployed to
List<Location> chosenLocations;
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c0f409f6/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java b/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java
index 76a8100..f7dc408 100644
--- a/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java
+++ b/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java
@@ -1398,14 +1398,18 @@ public class DynamicClusterTest extends AbstractDynamicClusterOrFabricTest {
public void testClusterMaxSize() {
DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
.configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(TestEntity.class))
- .configure(DynamicCluster.INITIAL_SIZE, 2)
- .configure(DynamicCluster.MAX_SIZE, 6));
+ .configure(DynamicCluster.INITIAL_SIZE, 1)
+ .configure(DynamicCluster.MAX_SIZE, 1));
cluster.start(ImmutableList.of(loc));
-
- cluster.resize(4);
- EntityAsserts.assertAttributeEqualsEventually(cluster, DynamicCluster.GROUP_SIZE, 4);
try {
- cluster.resize(8);
+ cluster.resize(3);
+ Asserts.shouldHaveFailedPreviously("Cluster resize should have failed because max size was exceeded");
+ } catch (Exception e) {
+ assertNotNull(Exceptions.getFirstThrowableOfType(e, Resizable.InsufficientCapacityException.class), "Expected InsufficientCapacityException");
+ }
+ // resizeByDelta should also fail.
+ try {
+ cluster.resizeByDelta(2);
Asserts.shouldHaveFailedPreviously("Cluster resize should have failed because max size was exceeded");
} catch (Exception e) {
assertNotNull(Exceptions.getFirstThrowableOfType(e, Resizable.InsufficientCapacityException.class), "Expected InsufficientCapacityException");
[2/2] brooklyn-server git commit: This closes #916
Posted by al...@apache.org.
This closes #916
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/cd5be207
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/cd5be207
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/cd5be207
Branch: refs/heads/master
Commit: cd5be2070d317f9e30be9e3493455d0386323e16
Parents: b654517 c0f409f
Author: Aled Sage <al...@gmail.com>
Authored: Thu Dec 21 15:05:46 2017 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Dec 21 15:05:46 2017 +0000
----------------------------------------------------------------------
.../brooklyn/entity/group/DynamicClusterImpl.java | 12 ++++++++----
.../brooklyn/entity/group/DynamicClusterTest.java | 16 ++++++++++------
2 files changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------