in software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseClusterImpl.java [120:172]
public void init() {
log.info("Initializing the Couchbase cluster...");
super.init();
enrichers().add(
Enrichers.builder()
.transforming(COUCHBASE_CLUSTER_UP_NODES)
.from(this)
.publishing(COUCHBASE_CLUSTER_UP_NODE_ADDRESSES)
.computing(new ListOfHostAndPort()).build() );
enrichers().add(
Enrichers.builder()
.transforming(COUCHBASE_CLUSTER_UP_NODE_ADDRESSES)
.from(this)
.publishing(COUCHBASE_CLUSTER_CONNECTION_URL)
.computing(
IfFunctions.<List<String>>ifPredicate(
Predicates.compose(MathPredicates.lessThan(getConfig(CouchbaseCluster.INITIAL_QUORUM_SIZE)),
CollectionFunctionals.sizeFunction(0)) )
.value((String)null)
.defaultApply(
Functionals.chain(
CollectionFunctionals.<String,List<String>>limit(4),
StringFunctions.joiner(","),
StringFunctions.formatter("http://%s/"))) )
.build() );
Map<? extends AttributeSensor<? extends Number>, ? extends AttributeSensor<? extends Number>> enricherSetup =
ImmutableMap.<AttributeSensor<? extends Number>, AttributeSensor<? extends Number>>builder()
.put(CouchbaseNode.OPS, CouchbaseCluster.OPS_PER_NODE)
.put(CouchbaseNode.COUCH_DOCS_DATA_SIZE, CouchbaseCluster.COUCH_DOCS_DATA_SIZE_PER_NODE)
.put(CouchbaseNode.COUCH_DOCS_ACTUAL_DISK_SIZE, CouchbaseCluster.COUCH_DOCS_ACTUAL_DISK_SIZE_PER_NODE)
.put(CouchbaseNode.EP_BG_FETCHED, CouchbaseCluster.EP_BG_FETCHED_PER_NODE)
.put(CouchbaseNode.MEM_USED, CouchbaseCluster.MEM_USED_PER_NODE)
.put(CouchbaseNode.COUCH_VIEWS_ACTUAL_DISK_SIZE, CouchbaseCluster.COUCH_VIEWS_ACTUAL_DISK_SIZE_PER_NODE)
.put(CouchbaseNode.CURR_ITEMS, CouchbaseCluster.CURR_ITEMS_PER_NODE)
.put(CouchbaseNode.VB_REPLICA_CURR_ITEMS, CouchbaseCluster.VB_REPLICA_CURR_ITEMS_PER_NODE)
.put(CouchbaseNode.COUCH_VIEWS_DATA_SIZE, CouchbaseCluster.COUCH_VIEWS_DATA_SIZE_PER_NODE)
.put(CouchbaseNode.GET_HITS, CouchbaseCluster.GET_HITS_PER_NODE)
.put(CouchbaseNode.CMD_GET, CouchbaseCluster.CMD_GET_PER_NODE)
.put(CouchbaseNode.CURR_ITEMS_TOT, CouchbaseCluster.CURR_ITEMS_TOT_PER_NODE)
.build();
for (AttributeSensor<? extends Number> nodeSensor : enricherSetup.keySet()) {
addSummingMemberEnricher(nodeSensor);
addAveragingMemberEnricher(nodeSensor, enricherSetup.get(nodeSensor));
}
enrichers().add(Enrichers.builder().updatingMap(Attributes.SERVICE_NOT_UP_INDICATORS)
.from(IS_CLUSTER_INITIALIZED).computing(
IfFunctions.ifNotEquals(true).value("The cluster is not yet completely initialized")
.defaultValue(null).build()).build() );
}