Package com.mongodb

Examples of com.mongodb.CommandResult$CommandFailure


        lockDoc.put(LockDef.LOCK_ATTEMPT_COUNT.field, 0);
        lockDoc.put(LockDef.INACTIVE_LOCK_TIMEOUT.field, pLockOptions.getInactiveLockTimeout());

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

        if (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


  /**
   * {@inheritDoc}
   */
  public CommandResult executeCommand(DBObject cmd) {
    CommandResult result = getDB().command(cmd);
    result.throwOnError();
    return result;
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public CommandResult executeCommand(String cmd) {
    CommandResult result = getDB().command(cmd);
    result.throwOnError();
    return result;
  }
View Full Code Here

   * Creates the {@link MapReduceResult}.
   * @param result the {@link MapReduceOutput}
   */
  public MapReduceResult(MapReduceOutput output) {
    this.resultCollection = output.getOutputCollection();
    CommandResult result = output.getCommandResult();
    if (result.containsField("counts")) {
      DBObject counts = (DBObject)result.get("counts");
      this.numObjectsScanned  = new Long(counts.get("input").toString());
      this.numEmits       = new Long(counts.get("emit").toString());
      this.numObjectsOutput   = new Long(counts.get("output").toString());
    }
    if (result.containsField("timeMillis")) {
      this.timeMillis = new Long(result.get("timeMillis").toString());
    }
  }
View Full Code Here

    this.mongoTemplate = mongoTemplate;
  }

  @Override
  protected void doHealthCheck(Health.Builder builder) throws Exception {
    CommandResult result = this.mongoTemplate.executeCommand("{ buildInfo: 1 }");
    builder.up().withDetail("version", result.getString("version"));
  }
View Full Code Here

    assertNotNull(healthIndicator);
  }

  @Test
  public void mongoIsUp() throws Exception {
    CommandResult commandResult = mock(CommandResult.class);
    given(commandResult.getString("version")).willReturn("2.6.4");
    MongoTemplate mongoTemplate = mock(MongoTemplate.class);
    given(mongoTemplate.executeCommand("{ buildInfo: 1 }")).willReturn(commandResult);
    MongoHealthIndicator healthIndicator = new MongoHealthIndicator(mongoTemplate);

    Health health = healthIndicator.health();
View Full Code Here

        return mapper;
    }

    protected void assumeThatMongoVersionIsGreaterThan(String expectedVersion) throws UnknownHostException {
        int expectedVersionAsInt = Integer.valueOf(expectedVersion.replaceAll("\\.", ""));
        CommandResult buildInfo = getDatabase().command("buildInfo");
        String version = (String) buildInfo.get("version");
        int currentVersion = Integer.valueOf(version.replaceAll("\\.", ""));
        assumeTrue(currentVersion >= expectedVersionAsInt);
    }
View Full Code Here

    public <T> T as(final Class<T> clazz) {
        return map(newResultHandler(clazz, unmarshaller));
    }

    public <T> T map(ResultHandler<T> resultHandler) {
        CommandResult commandResult = executeCommand();
        return resultHandler.map(commandResult);
    }
View Full Code Here

        CommandResult commandResult = executeCommand();
        return resultHandler.map(commandResult);
    }

    private CommandResult executeCommand() {
        CommandResult commandResult = db.command(query.toDBObject());
        if (throwOnError) {
            commandResult.throwOnError();
        }
        return commandResult;
    }
View Full Code Here

        public <T> List<T> as(final Class<T> clazz) {
            return map(newResultHandler(clazz, unmarshaller));
        }

        public <T> List<T> map(ResultHandler<T> resultHandler) {
            CommandResult commandResult = executeCommand();
            List<DBObject> results = (List<DBObject>) commandResult.get(fieldName);
            if (results == null) {
                return new ArrayList<T>();
            }
            List<T> mappedResult = new ArrayList<T>(results.size());
            for (DBObject dbObject : results) {
View Full Code Here

TOP

Related Classes of com.mongodb.CommandResult$CommandFailure

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.