List of usage examples for com.mongodb ReplicaSetStatus toString
@Override
public String toString()
From source file:com.ebay.cloud.cms.sysmgmt.monitor.metrics.MongoMetric.java
License:Apache License
private void snapshot() { MongoClient client = dataSource.getMongoInstance(); Map<String, Object> status = new TreeMap<String, Object>(); // update driver status.put(MetricConstants.MONGO_DRIVER_VERSION, client.getVersion()); // update status ReplicaSetStatus rss = client.getReplicaSetStatus(); String master = NOT_FOUND;/* ww w . j a va 2s .c o m*/ if (rss != null) { status.put(MetricConstants.REPL_STATUS, rss.toString()); ServerAddress masterServer = rss.getMaster(); if (masterServer != null) { master = masterServer.getHost(); } } else { status.put(MetricConstants.REPL_STATUS, "no repl set found!"); } // update mongo cluster master status.put(MetricConstants.REPL_MASTER, master); // list mongo databases Map<String, Object> databaseSizeMap = listDatabases(client); String databases = StringUtils.join(databaseSizeMap.keySet(), ','); status.put(MetricConstants.REPL_DATABASES, databases); status.put(MetricConstants.MONGO_DB_SIZE, databaseSizeMap); mongoStatus = status; }