brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [07/11] incubator-brooklyn git commit: Couchbase: fix upQuorumCheck config so serializable
Date Sun, 29 Mar 2015 02:31:34 GMT
Couchbase: fix upQuorumCheck config so serializable


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

Branch: refs/heads/master
Commit: aa4b61a73d2850c6003ed974d2bacedf9e0feb6f
Parents: c76b9de
Author: Aled Sage <aled.sage@gmail.com>
Authored: Tue Mar 10 16:23:14 2015 +0000
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Thu Mar 26 10:09:41 2015 +0000

----------------------------------------------------------------------
 .../nosql/couchbase/CouchbaseCluster.java       |  1 +
 .../nosql/couchbase/CouchbaseClusterImpl.java   | 23 ++++++++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aa4b61a7/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseCluster.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseCluster.java
b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseCluster.java
index fb52650..69cab58 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseCluster.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseCluster.java
@@ -130,4 +130,5 @@ public interface CouchbaseCluster extends DynamicCluster {
     ConfigKey<List<Map<String,Object>>> REPLICATION = ConfigKeys.newConfigKey(new
TypeToken<List<Map<String,Object>>>() {}, 
             "couchbase.cluster.replicationConfiguration", "List of replication rules to configure,
each rule including target (id of another cluster) and mode (unidirectional or bidirectional)");
 
+    int getQuorumSize();
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aa4b61a7/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseClusterImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseClusterImpl.java
b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseClusterImpl.java
index ca12a89..dcdafb6 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseClusterImpl.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseClusterImpl.java
@@ -376,8 +376,8 @@ public class CouchbaseClusterImpl extends DynamicClusterImpl implements
Couchbas
         return EntitySpec.create(CouchbaseNode.class);
     }
 
-
-    protected int getQuorumSize() {
+    @Override
+    public int getQuorumSize() {
         Integer quorumSize = getConfig(CouchbaseCluster.INITIAL_QUORUM_SIZE);
         if (quorumSize != null && quorumSize > 0)
             return quorumSize;
@@ -411,7 +411,10 @@ public class CouchbaseClusterImpl extends DynamicClusterImpl implements
Couchbas
                 }
             }).build());
         
-        if (getConfigRaw(UP_QUORUM_CHECK, false).isAbsent()) {
+        if (config().getLocalRaw(UP_QUORUM_CHECK).isAbsent()) {
+            // TODO Only leaving CouchbaseQuorumCheck here in case it is contained in persisted
state.
+            // If so, need a transformer and then to delete it
+            @Deprecated
             class CouchbaseQuorumCheck implements QuorumCheck {
                 @Override
                 public boolean isQuorate(int sizeHealthy, int totalSize) {
@@ -420,11 +423,23 @@ public class CouchbaseClusterImpl extends DynamicClusterImpl implements
Couchbas
                     return true;
                 }
             }
-            setConfig(UP_QUORUM_CHECK, new CouchbaseQuorumCheck());
+            config().set(UP_QUORUM_CHECK, new CouchbaseClusterImpl.CouchbaseQuorumCheck(this));
         }
         super.initEnrichers();
     }
     
+    static class CouchbaseQuorumCheck implements QuorumCheck {
+        private final CouchbaseCluster cluster;
+        CouchbaseQuorumCheck(CouchbaseCluster cluster) {
+            this.cluster = cluster;
+        }
+        @Override
+        public boolean isQuorate(int sizeHealthy, int totalSize) {
+            // check members count passed in AND the sensor  
+            if (sizeHealthy < cluster.getQuorumSize()) return false;
+            return true;
+        }
+    }
     protected void addServers(Set<Entity> serversToAdd) {
         Preconditions.checkNotNull(serversToAdd);
         for (Entity s : serversToAdd) {


Mime
View raw message