Package com.mongodb

Examples of com.mongodb.CommandResult


            if (addr != null) {
                setStringFieldValue(Item.host, addr.toString());
                setStringFieldValue(Item.address, addr.getSocketAddress().toString());
            }

            CommandResult res = svrMongo.getDB("local").command("isMaster");
            boolean master = res.getBoolean("ismaster");
            String replication = MongoUtils.makeInfoString("master", master,
                    "secondary", res.getBoolean("secondary"),
                    "passive", res.getBoolean("passive"));
            setStringFieldValue(Item.replication, replication);
            ((Text) getBoundUnit(Item.replication)).showIcon = master;

            setStringFieldValue(Item.maxObjectSize, String.valueOf(svrMongo.getMaxBsonObjectSize()));
View Full Code Here


        final DBObject cmd = new BasicDBObject("getLog", type);
        new DbJob() {

            @Override
            public Object doRun() throws Exception {
                CommandResult res = db.command(cmd);
                res.throwOnError();
                StringBuilder sb = new StringBuilder();
                BasicDBList list = (BasicDBList) res.get("log");
                for (Object str : list){
                    sb.append(str);
                    sb.append("\n");
                }
                return sb.toString();
View Full Code Here

        }
    }

    @Override
    protected void refreshNode() {
        CommandResult res = collection.getStats();
        res.throwOnError();
        stats = res;
    }
View Full Code Here

        theDb = db;
        theCmd = cmd;
        if (theDb == null || theCmd == null) {
            return;
        }
        CommandResult res = db.command(cmd, db.getOptions());
        setDoc(res);
    }
View Full Code Here

     * @param wc
     * @param wr
     */
    protected void throwOnError(WriteConcern wc, WriteResult wr) {
        if (wc == null && wr.getLastConcern() == null) {
            CommandResult cr = wr.getLastError();
            if (cr != null && cr.getErrorMessage() != null && cr.getErrorMessage().length() > 0)
                cr.throwOnError();
        }
    }
View Full Code Here

        DBObject dbObj = mapr.toDBObject(entity, involvedObjects);

        UpdateResults<T> res = update(query, dbObj, createIfMissing, false, getWriteConcern(entity));

        //update _id field
        CommandResult gle = res.getWriteResult().getCachedLastError();
        if (gle != null && res.getInsertedCount() > 0)
            dbObj.put(Mapper.ID_KEY, res.getNewId());

        postSaveOperations(entity, dbObj, involvedObjects);
        return res;
View Full Code Here

        UpdateResults<T> res = new UpdateResults<T>(wr);

        throwOnError(wc, wr);

        //check for updated count if we have a gle
        CommandResult gle = wr.getCachedLastError();
        if (gle != null && res.getUpdatedCount() == 0)
            throw new UpdateException("Not updated: " + gle);

        postSaveOperations(entity, dbObj, involvedObjects);
        return key;
View Full Code Here

            if (!dbPresent) {
                throw new DatabaseException(ErrorCodes.DB_DOES_NOT_EXISTS, "DB with name '" + dbName + "'  DOES NOT EXIST");
            }

            DB db = mongoInstance.getDB(dbName);
            CommandResult stats = db.getStats();
            Set<String> keys = stats.keySet();

            Iterator<String> keyIterator = keys.iterator();

            while (keyIterator.hasNext()) {
                JSONObject temp = new JSONObject();
                String key = keyIterator.next();
                temp.put("Key", key);
                String value = stats.get(key).toString();
                temp.put("Value", value);
                String type = stats.get(key).getClass().toString();
                temp.put("Type", type.substring(type.lastIndexOf('.') + 1));
                dbStats.put(temp);
            }
        } catch (MongoException m) {
            throw new DatabaseException(ErrorCodes.GET_DB_STATS_EXCEPTION, m.getMessage());
View Full Code Here

     * @throws IOException
     * @throws JSONException
     */
    private JSONArray processQuery(DB db) throws IOException, JSONException {

        CommandResult cr = db.command("serverStatus");
        BasicDBObject obj = (BasicDBObject) cr.get("opcounters");
        int currentValue;
        JSONObject temp = new JSONObject();

        num = num + jump;
        temp.put("TimeStamp", num);
View Full Code Here

        JSONObject respObj = new JSONObject();
        array = new JSONArray();
        num = 0;
        try {

            CommandResult cr = db.command("serverStatus");
            BasicDBObject obj = (BasicDBObject) cr.get("opcounters");
            lastNoOfQueries = (Integer) obj.get("query");
            lastNoOfInserts = (Integer) obj.get("insert");
            lastNoOfUpdates = (Integer) obj.get("update");
            lastNoOfDeletes = (Integer) obj.get("delete");
View Full Code Here

TOP

Related Classes of com.mongodb.CommandResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.