You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2015/08/20 14:39:47 UTC

[09/16] incubator-brooklyn git commit: Deleted deprecated o.a.b.core.entity.lifecycle.QuorumCheck

Deleted deprecated o.a.b.core.entity.lifecycle.QuorumCheck


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

Branch: refs/heads/master
Commit: b1322495c762a9c43a3ba32d915e98512f0b4b71
Parents: 1ca4230
Author: Aled Sage <al...@gmail.com>
Authored: Wed Aug 19 18:43:38 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Aug 20 12:04:13 2015 +0100

----------------------------------------------------------------------
 .../core/entity/lifecycle/QuorumCheck.java      | 108 -------------------
 .../entity/group/DynamicClusterImpl.java        |   2 +-
 .../core/test/entity/TestClusterImpl.java       |   4 +-
 .../brooklyn/policy/ha/ServiceReplacerTest.java |   2 +-
 4 files changed, 4 insertions(+), 112 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b1322495/core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/QuorumCheck.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/QuorumCheck.java b/core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/QuorumCheck.java
deleted file mode 100644
index 29f8deb..0000000
--- a/core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/QuorumCheck.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.entity.lifecycle;
-
-import java.io.Serializable;
-
-/**
- * For checking if a group/cluster is quorate. That is, whether the group has sufficient
- * healthy members.
- * @deprecated since 0.7.0 use {@link org.apache.brooklyn.util.collections.QuorumCheck}. 
- * but keep this for a while as old quorum checks might be persisted. 
- */
-@Deprecated
-public interface QuorumCheck extends org.apache.brooklyn.util.collections.QuorumCheck {
-
-    /**
-     * @param sizeHealthy Number of healthy members
-     * @param totalSize   Total number of members one would expect to be healthy (i.e. ignoring stopped members)
-     * @return            Whether this group is healthy
-     */
-    public boolean isQuorate(int sizeHealthy, int totalSize);
-
-    public static class QuorumChecks {
-        /**
-         * Checks that all members that should be up are up (i.e. ignores stopped nodes).
-         */
-        public static QuorumCheck all() {
-            return new NumericQuorumCheck(0, 1.0, false);
-        }
-        /**
-         * Checks all members that should be up are up, and that there is at least one such member.
-         */
-        public static QuorumCheck allAndAtLeastOne() {
-            return new NumericQuorumCheck(1, 1.0, false);
-        }
-        /**
-         * Requires at least one member that should be up is up.
-         */
-        public static QuorumCheck atLeastOne() {
-            return new NumericQuorumCheck(1, 0.0, false);
-        }
-        /**
-         * Requires at least one member to be up if the total size is non-zero.
-         * i.e. okay if empty, or if non-empty and something is healthy, but not okay if not-empty and nothing is healthy.
-         * "Empty" means that no members are supposed to be up  (e.g. there may be stopped members).
-         */
-        public static QuorumCheck atLeastOneUnlessEmpty() {
-            return new NumericQuorumCheck(1, 0.0, true);
-        }
-        /**
-         * Always "healthy"
-         */
-        public static QuorumCheck alwaysTrue() {
-            return new NumericQuorumCheck(0, 0.0, true);
-        }
-        public static QuorumCheck newInstance(int minRequiredSize, double minRequiredRatio, boolean allowEmpty) {
-            return new NumericQuorumCheck(minRequiredSize, minRequiredRatio, allowEmpty);
-        }
-    }
-    
-    /** @deprecated since 0.7.0 use {@link org.apache.brooklyn.util.collections.QuorumCheck}. 
-    * but keep this until we have a transition defined. 
-    */
-    @Deprecated
-    public static class NumericQuorumCheck implements QuorumCheck, Serializable {
-        private static final long serialVersionUID = -5090669237460159621L;
-        
-        protected final int minRequiredSize;
-        protected final double minRequiredRatio;
-        protected final boolean allowEmpty;
-
-        public NumericQuorumCheck(int minRequiredSize, double minRequiredRatio, boolean allowEmpty) {
-            this.minRequiredSize = minRequiredSize;
-            this.minRequiredRatio = minRequiredRatio;
-            this.allowEmpty = allowEmpty;
-        }
-        
-        @Override
-        public boolean isQuorate(int sizeHealthy, int totalSize) {
-            if (allowEmpty && totalSize==0) return true;
-            if (sizeHealthy < minRequiredSize) return false;
-            if (sizeHealthy < totalSize*minRequiredRatio-0.000000001) return false;
-            return true;
-        }
-        
-        @Override
-        public String toString() {
-            return "QuorumCheck[require="+minRequiredSize+","+((int)100*minRequiredRatio)+"%"+(allowEmpty ? "|0" : "")+"]";
-        }
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b1322495/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 b330675..e335fd0 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
@@ -45,7 +45,6 @@ import org.apache.brooklyn.core.entity.factory.EntityFactory;
 import org.apache.brooklyn.core.entity.factory.EntityFactoryForLocation;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
-import org.apache.brooklyn.core.entity.lifecycle.QuorumCheck.QuorumChecks;
 import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic.ServiceProblemsLogic;
 import org.apache.brooklyn.core.entity.trait.Startable;
 import org.apache.brooklyn.core.entity.trait.StartableMethods;
@@ -56,6 +55,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.brooklyn.util.collections.MutableList;
 import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.collections.QuorumCheck.QuorumChecks;
 import org.apache.brooklyn.util.core.flags.TypeCoercions;
 import org.apache.brooklyn.util.core.task.DynamicTasks;
 import org.apache.brooklyn.util.core.task.TaskTags;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b1322495/core/src/test/java/org/apache/brooklyn/core/test/entity/TestClusterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/test/entity/TestClusterImpl.java b/core/src/test/java/org/apache/brooklyn/core/test/entity/TestClusterImpl.java
index 0bc9e32..debe110 100644
--- a/core/src/test/java/org/apache/brooklyn/core/test/entity/TestClusterImpl.java
+++ b/core/src/test/java/org/apache/brooklyn/core/test/entity/TestClusterImpl.java
@@ -18,9 +18,9 @@
  */
 package org.apache.brooklyn.core.test.entity;
 
-import org.apache.brooklyn.core.entity.lifecycle.QuorumCheck.QuorumChecks;
 import org.apache.brooklyn.core.entity.trait.Startable;
 import org.apache.brooklyn.entity.group.DynamicClusterImpl;
+import org.apache.brooklyn.util.collections.QuorumCheck.QuorumChecks;
 
 /**
 * Mock cluster entity for testing.
@@ -41,7 +41,7 @@ public class TestClusterImpl extends DynamicClusterImpl implements TestCluster {
     @Override
     protected void initEnrichers() {
         // say this is up if it has no children 
-        setConfig(UP_QUORUM_CHECK, QuorumChecks.atLeastOneUnlessEmpty());
+        config().set(UP_QUORUM_CHECK, QuorumChecks.atLeastOneUnlessEmpty());
         
         super.initEnrichers();
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b1322495/policy/src/test/java/org/apache/brooklyn/policy/ha/ServiceReplacerTest.java
----------------------------------------------------------------------
diff --git a/policy/src/test/java/org/apache/brooklyn/policy/ha/ServiceReplacerTest.java b/policy/src/test/java/org/apache/brooklyn/policy/ha/ServiceReplacerTest.java
index d984b0e..ba08666 100644
--- a/policy/src/test/java/org/apache/brooklyn/policy/ha/ServiceReplacerTest.java
+++ b/policy/src/test/java/org/apache/brooklyn/policy/ha/ServiceReplacerTest.java
@@ -40,7 +40,6 @@ import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.EntityInternal;
 import org.apache.brooklyn.core.entity.factory.ApplicationBuilder;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
-import org.apache.brooklyn.core.entity.lifecycle.QuorumCheck;
 import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic.ComputeServiceIndicatorsFromChildrenAndMembers;
 import org.apache.brooklyn.core.entity.trait.FailingEntity;
 import org.apache.brooklyn.core.location.SimulatedLocation;
@@ -50,6 +49,7 @@ import org.apache.brooklyn.core.test.entity.TestEntity;
 import org.apache.brooklyn.entity.group.DynamicCluster;
 import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.test.EntityTestUtils;
+import org.apache.brooklyn.util.collections.QuorumCheck;
 import org.apache.brooklyn.util.core.config.ConfigBag;
 import org.apache.brooklyn.util.javalang.JavaClassNames;
 import org.slf4j.Logger;