/** * Executes a database command with the selected readPreference, and encodes the command using the given encoder. * * @param command The {@code DBObject} representation the command to be executed * @param readPreference Where to execute the command - this will only be applied for a subset of commands * @param encoder The DBEncoder that knows how to serialise the command * @return The result of executing the command, success or failure * @mongodb.driver.manual tutorial/use-database-commands Commands * @since 2.12 */ public CommandResult command(final DBObject command, final ReadPreference readPreference, @Nullable final DBEncoder encoder) { try { return executeCommand(wrap(command, encoder), getCommandReadPreference(command, readPreference)); } catch (MongoCommandException ex) { return new CommandResult(ex.getResponse(), ex.getServerAddress()); } }
CommandResult executeCommand(final BsonDocument commandDocument, final ReadPreference readPreference) { return new CommandResult(executor.execute(new CommandReadOperation<BsonDocument>(getName(), commandDocument, new BsonDocumentCodec()), readPreference, getReadConcern())); }
CommandResult executeCommand(final BsonDocument commandDocument) { return new CommandResult(executor.execute(new CommandWriteOperation<BsonDocument>(getName(), commandDocument, new BsonDocumentCodec()), getReadConcern())); }
/** * Return the explain plan for the aggregation pipeline. * * @param pipeline the aggregation pipeline to explain * @param options the options to apply to the aggregation * @return the command result. The explain output may change from release to release, so best to simply log this. * @mongodb.driver.manual core/aggregation-pipeline/ Aggregation * @mongodb.driver.manual reference/operator/meta/explain/ Explain query * @mongodb.server.release 2.6 */ public CommandResult explainAggregate(final List<? extends DBObject> pipeline, final AggregationOptions options) { AggregateOperation<BsonDocument> operation = new AggregateOperation<BsonDocument>(getNamespace(), preparePipeline(pipeline), new BsonDocumentCodec()) .maxTime(options.getMaxTime(MILLISECONDS), MILLISECONDS) .allowDiskUse(options.getAllowDiskUse()) .collation(options.getCollation()); return new CommandResult(executor.execute(operation.asExplainableOperation(ExplainVerbosity.QUERY_PLANNER), primaryPreferred(), getReadConcern())); }
public CommandResult okResult() { CommandResult result = new CommandResult(fongo.getServerAddress()); result.put("ok", 1.0); return result; }
return new CommandResult(true); if ("".equals(line.trim())) { setShellStatus(Status.EXECUTION_SUCCESS); return new CommandResult(true); return new CommandResult(false); return new CommandResult(true, result, null); } catch (RuntimeException e) { setShellStatus(Status.EXECUTION_FAILED, line, parseResult); logCommandIfRequired(line, false); } catch (Exception ignored) {} return new CommandResult(false, null, e); } finally { setShellStatus(Status.USER_INPUT);
public CommandResult notOkErrorResult(String err, String errmsg) { CommandResult result = new CommandResult(fongo.getServerAddress()); result.put("ok", 0.0); if (err != null) { result.put("err", err); } if (errmsg != null) { result.put("errmsg", errmsg); } return result; }
/** * Executes a database command with the selected readPreference, and encodes the command using the given encoder. * * @param command The {@code DBObject} representation the command to be executed * @param readPreference Where to execute the command - this will only be applied for a subset of commands * @param encoder The DBEncoder that knows how to serialise the command * @return The result of executing the command, success or failure * @mongodb.driver.manual tutorial/use-database-commands Commands * @since 2.12 */ public CommandResult command(final DBObject command, final ReadPreference readPreference, @Nullable final DBEncoder encoder) { try { return executeCommand(wrap(command, encoder), getCommandReadPreference(command, readPreference)); } catch (MongoCommandException ex) { return new CommandResult(ex.getResponse(), ex.getServerAddress()); } }
CommandResult executeCommand(final BsonDocument commandDocument, final ReadPreference readPreference) { return new CommandResult(executor.execute(new CommandReadOperation<BsonDocument>(getName(), commandDocument, new BsonDocumentCodec()), readPreference, getReadConcern())); }
CommandResult executeCommand(final BsonDocument commandDocument) { return new CommandResult(executor.execute(new CommandWriteOperation<BsonDocument>(getName(), commandDocument, new BsonDocumentCodec()), getReadConcern())); }
/** * Return the explain plan for the aggregation pipeline. * * @param pipeline the aggregation pipeline to explain * @param options the options to apply to the aggregation * @return the command result. The explain output may change from release to release, so best to simply log this. * @mongodb.driver.manual core/aggregation-pipeline/ Aggregation * @mongodb.driver.manual reference/operator/meta/explain/ Explain query * @mongodb.server.release 2.6 */ public CommandResult explainAggregate(final List<? extends DBObject> pipeline, final AggregationOptions options) { AggregateOperation<BsonDocument> operation = new AggregateOperation<BsonDocument>(getNamespace(), preparePipeline(pipeline), new BsonDocumentCodec()) .maxTime(options.getMaxTime(MILLISECONDS), MILLISECONDS) .allowDiskUse(options.getAllowDiskUse()) .collation(options.getCollation()); return new CommandResult(executor.execute(operation.asExplainableOperation(ExplainVerbosity.QUERY_PLANNER), primaryPreferred(), getReadConcern())); }