brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjcorb...@apache.org
Subject [2/7] incubator-brooklyn git commit: subscribe to the ROOT_USERNAME sensor from children of replica set
Date Thu, 17 Sep 2015 13:27:54 GMT
subscribe to the ROOT_USERNAME sensor from children of replica set


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

Branch: refs/heads/master
Commit: 3bb9cfc91a5b46a09890aa30dcd24acd3dfbbfab
Parents: 16b8b1e
Author: Robert Moss <robertgmoss@gmail.com>
Authored: Tue Sep 15 15:38:29 2015 +0100
Committer: Robert Moss <robertgmoss@gmail.com>
Committed: Wed Sep 16 15:35:28 2015 +0100

----------------------------------------------------------------------
 .../nosql/mongodb/MongoDBReplicaSetImpl.java       | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3bb9cfc9/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBReplicaSetImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBReplicaSetImpl.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBReplicaSetImpl.java
index c4d675d..59e6524 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBReplicaSetImpl.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBReplicaSetImpl.java
@@ -134,6 +134,23 @@ public class MongoDBReplicaSetImpl extends DynamicClusterImpl implements
MongoDB
             return Iterables.tryFind(entities, Predicates.not(IS_PRIMARY)).or(Iterables.get(entities,
0));
         }
     };
+    
+    @Override
+    public void init() {
+        addEnricher(Enrichers.builder()
+                .aggregating(MongoDBAuthenticationMixins.ROOT_USERNAME)
+                .publishing(MongoDBAuthenticationMixins.ROOT_USERNAME)
+                .fromMembers()
+                .valueToReportIfNoSensors(null)
+                .computing(new Function<Collection<String>, String>() {
+                        @Override
+                        public String apply(Collection<String> input) {
+                            if (input==null || input.isEmpty()) return null;
+                            // when authentication is used all members have the same value
+                            return Iterables.getFirst(input, null);
+                        }})
+                .build());
+    };
 
     /** @return {@link #NON_PRIMARY_REMOVAL_STRATEGY} */
     @Override


Mime
View raw message