Example usage for com.mongodb CommandResult toMap

List of usage examples for com.mongodb CommandResult toMap

Introduction

In this page you can find the example usage for com.mongodb CommandResult toMap.

Prototype

public Map toMap() 

Source Link

Document

Converts a DBObject to a map.

Usage

From source file:com.socialsky.mods.MongoPersistor.java

License:Apache License

private void getCollectionStats(Message<JsonObject> message) {
    String collection = getMandatoryString("collection", message);

    if (collection == null) {
        return;/*w w w . j a va  2  s .  c  o m*/
    }

    DBCollection coll = db.getCollection(collection);
    CommandResult stats = coll.getStats();

    JsonObject reply = new JsonObject();
    reply.putObject("stats", new JsonObject(stats.toMap()));
    sendOK(message, reply);

}

From source file:com.socialsky.mods.MongoPersistor.java

License:Apache License

private void runCommand(Message<JsonObject> message) {
    JsonObject reply = new JsonObject();

    String command = getMandatoryString("command", message);

    if (command == null) {
        return;/* www .j  a  va2 s.  co  m*/
    }

    DBObject commandObject = (DBObject) JSON.parse(command);
    CommandResult result = db.command(commandObject);

    reply.putObject("result", new JsonObject(result.toMap()));
    sendOK(message, reply);
}

From source file:com.socialsky.mods.MongoPersistor.java

License:Apache License

private void runMapReduce(Message<JsonObject> message) {
    JsonObject reply = new JsonObject();

    String command = getMandatoryString("command", message);

    if (command == null) {
        return;//from   w  w  w  .  j a  v a  2 s .c  om
    }

    DBObject commandObject = (DBObject) JSON.parse(command);
    CommandResult result = db.command(commandObject);

    reply.putObject("result", new JsonObject(result.toMap()));
    sendOK(message, reply);
}

From source file:org.aw20.mongoworkbench.command.DBStatsMongoCommand.java

License:Open Source License

@Override
public void execute() throws Exception {
    MongoClient mdb = MongoFactory.getInst().getMongo(sName);

    if (mdb == null)
        throw new Exception("no server selected");

    setDBNames(mdb);//from w w  w . j  a v  a 2 s  . c  om
    Iterator<String> it = dbNames.iterator();
    while (it.hasNext()) {
        String db = it.next();

        CommandResult cmdr = mdb.getDB(db).getStats();
        statsListMap.add(transform(cmdr.toMap()));
    }

    setMessage("Retrived Database Stats; db=" + statsListMap.size());
}