Package com.mongodb

Examples of com.mongodb.CommandResult.ok()


    }

    @Test
    public void testIsMaster() throws Exception {
        CommandResult isMaster = db.command("isMaster");
        assertThat(isMaster.ok()).isTrue();
        assertThat(isMaster.getBoolean("ismaster")).isTrue();
        assertThat(isMaster.getDate("localTime")).isInstanceOf(Date.class);
        assertThat(isMaster.getInt("maxBsonObjectSize")).isGreaterThan(1000);
        assertThat(isMaster.getInt("maxMessageSizeBytes")).isGreaterThan(isMaster.getInt("maxBsonObjectSize"));
    }
View Full Code Here


    BasicDBObject command = new BasicDBObject("geoNear", "geo");
    Double[] coordinates = {lat,lon};
    command.put("near", coordinates);
    command.put("maxDistance", MAXIMUM_DISTANCE_IN_METERS);
    CommandResult commandResult = MongoDbManager.getDB("feature").command(command);
    if ( commandResult.ok() && commandResult.containsField("results") )
    {
      BasicDBList results = (BasicDBList)commandResult.get("results");
      return results;     
    }
   
View Full Code Here

            if (logRes) {
                logObj.put("firstResult", lasterr);
            }
        } else if (res instanceof CommandResult) {
            CommandResult cres = (CommandResult) res;
            if (!cres.ok()) {
                UMongo.instance.showError(title, (Exception) cres.getException());
            }
            new DocView(null, title, this, sroot, (DBObject) res).addToTabbedDiv();
            if (logRes) {
                logObj.put("firstResult", res.toString());
View Full Code Here

        // Insert, if successful then get out of here.
        final WriteResult result = getDbCollection(pMongo, pSvcOptions).insert(lockDoc, WriteConcern.NORMAL);
        final CommandResult cmdResult = result.getLastError(WriteConcern.NORMAL);

        if (!cmdResult.ok() || cmdResult.getException() != null || cmdResult.getErrorMessage() != null) return null;

        if (pSvcOptions.getEnableHistory())
        { LockHistoryDao.insert( pMongo, pLockName, pSvcOptions, pLockOptions, serverTime, LockState.LOCKED, lockId, false); }

        return lockId;
View Full Code Here

        throw new MissingCellsFailureException(cells.text()
        + " requires an argument");
    }
    String cmdString = command.text();
    CommandResult result = db.doEval(cmdString);
    if (result.ok()) {
      right(command);
    } else {
      wrong(command, result.getErrorMessage());
    }
  }
View Full Code Here

      throw new MissingCellsFailureException(cells.text()
          + " requires an argument");
    }
    String cmdString = command.text();
    CommandResult result = db.doEval(cmdString);
    if (result.ok()) {
      right(command);
    } else {
      wrong(command, result.getErrorMessage());
    }
  }
View Full Code Here

    this.password = password;
  }

  public CommandResult getServerStatus() {
    CommandResult result = getDb("admin").command("serverStatus");
    if (!result.ok()) {
      logger.error("Could not query for server status.  Command Result = " + result);
      throw new MongoException("could not query for server status.  Command Result = " + result);
    }
    return result;
  }
View Full Code Here

      BasicDBObject dbo = new BasicDBObject("create", OLD_DOCUMENT_COLLECTION);
      dbo.put("capped", true);
      dbo.put("size", size);
      dbo.put("max", max);
      CommandResult cr = db.command(dbo);
      if(cr.ok()) {
        logger.info("Created a capped collection for old documents with {size: "+size+", max: "+max+"}");
      }
      else {
        if(db.getCollectionNames().contains(OLD_DOCUMENT_COLLECTION)) {
          logger.debug("Raced to create "+OLD_DOCUMENT_COLLECTION+" collection and lost");
View Full Code Here

        // Insert, if successful then get out of here.
        final WriteResult result = getDbCollection(pMongo, pSvcOptions).insert(lockDoc, WriteConcern.NORMAL);
        final CommandResult cmdResult = result.getLastError(WriteConcern.NORMAL);

        if (!cmdResult.ok() || cmdResult.getException() != null || cmdResult.getErrorMessage() != null) return null;

        if (pSvcOptions.getEnableHistory())
        { LockHistoryDao.insert( pMongo, pLockName, pSvcOptions, pLockOptions, serverTime, LockState.LOCKED, lockId, false); }

        return lockId;
View Full Code Here

            assertNotNull(wr.getCachedLastError());
        } else {
            assertNull(wr.getCachedLastError());
        }
        CommandResult cr = wr.getLastError();
        assertTrue(cr.ok());
    }
   
    @Test
    public void testDynamicWriteConcernSafe() throws Exception {
        assertEquals(0, testCollection.count());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.