Java Code Examples for com.mongodb.CommandResult#containsField()

The following examples show how to use com.mongodb.CommandResult#containsField() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DBusMongoClient.java    From DBus with Apache License 2.0 5 votes vote down vote up
private boolean isReplSet() {
    boolean ret = false;
    DB db = new DB(mongoClient, "admin");
    CommandResult cr = db.command("replSetGetStatus");
    logger.info("isReplSet: {}", cr.toJson());
    if (cr.containsField("set") && cr.containsField("members")) {
        ret = true;
    }
    return ret;
}
 
Example 2
Source File: DBusMongoClient.java    From DBus with Apache License 2.0 5 votes vote down vote up
private boolean isShard() {
    boolean ret = false;
    DB db = new DB(mongoClient, "admin");
    CommandResult cr = db.command("isdbgrid");
    logger.info("isShard: {}", cr.toJson());
    if (cr.containsField("isdbgrid") && cr.getInt("isdbgrid") == 1) {
        ret = true;
    }
    return ret;
}