@Override public Document executeCommand(Document command, @Nullable ReadPreference readPreference) { Assert.notNull(command, "Command must not be null!"); return execute(db -> readPreference != null // ? db.runCommand(command, readPreference, Document.class) // : db.runCommand(command, Document.class)); }
@Override public Document executeCommand(final Document command) { Assert.notNull(command, "Command must not be null!"); return execute(db -> db.runCommand(command, Document.class)); }
@Override public Object doInDB(MongoDatabase db) throws MongoException, DataAccessException { return db.runCommand(new Document("eval", String.format("%s(%s)", scriptName, convertAndJoinScriptArgs(args)))) .get("retval"); } });
public Document doInDB(MongoDatabase db) throws MongoException, DataAccessException { return db.runCommand(Document.parse(jsonCommand), Document.class); } });
@Signature public Document runCommand(BasicDBObject command) { return getWrappedObject().runCommand(command); } }
public Document getServerStatus() { return getDb("admin").runCommand(new Document("serverStatus", 1).append("rangeDeleter", 1).append("repl", 1)); }
private void syncTtl() { if (!ttlSync.get()) { ttlSync.set(true); if (timeout <= 0) { return; } log.debug("creating session timeout index"); if (existsIdx(SESSION_IDX)) { Document command = new Document("collMod", collection) .append("index", new Document("keyPattern", new Document("_accessedAt", 1)) .append("expireAfterSeconds", timeout)); log.debug("{}", command); Document result = db.runCommand(command); log.debug("{}", result); } else { sessions.createIndex( new Document("_accessedAt", 1), new IndexOptions() .name(SESSION_IDX) .expireAfter(timeout, TimeUnit.SECONDS)); } } }
@Override public Object doInDB(MongoDatabase db) throws MongoException, DataAccessException { Document command = new Document("$eval", script.getCode()); BasicDBList commandArgs = new BasicDBList(); commandArgs.addAll(Arrays.asList(convertScriptArgs(false, args))); command.append("args", commandArgs); return db.runCommand(command).get("retval"); } });
@ManagedOperation public String getDatabaseStats(String databaseName) { return getDB(databaseName).runCommand(new Document("dbStats", 1).append("scale", 1024)).toJson(); }
@ManagedOperation public String getServerStatus() { return getDB("admin").runCommand(new Document("serverStatus", 1).append("rangeDeleter", 1).append("repl", 1)) .toJson(); }
@SuppressWarnings("unchecked") private Document getValidation() { Document document = getMongoClient().getDatabase(TEST_DB_NAME) .runCommand(new Document("listCollections", 1) .append("filter", new Document("name", "validation"))); List<Document> firstBatch = (List<Document>) ((Document) document.get("cursor")).get("firstBatch"); return (Document) firstBatch.get(0).get("options"); }
@Override public Document executeCommand(Document command, @Nullable ReadPreference readPreference) { Assert.notNull(command, "Command must not be null!"); return execute(db -> readPreference != null // ? db.runCommand(command, readPreference, Document.class) // : db.runCommand(command, Document.class)); }
@Override public Document executeCommand(final Document command) { Assert.notNull(command, "Command must not be null!"); return execute(db -> db.runCommand(command, Document.class)); }
@Override public Object doInDB(MongoDatabase db) throws MongoException, DataAccessException { return db.runCommand(new Document("eval", String.format("%s(%s)", scriptName, convertAndJoinScriptArgs(args)))) .get("retval"); } });
public Document doInDB(MongoDatabase db) throws MongoException, DataAccessException { return db.runCommand(Document.parse(jsonCommand), Document.class); } });
public List<StatInfoEntry> getDbStats(ServerConfiguration configuration, final MongoDatabase mongoDatabase) { TaskWithReturnedObject<List<StatInfoEntry>> task = mongoClient -> { com.mongodb.client.MongoDatabase database = mongoClient.getDatabase(mongoDatabase.getName()); return adaptToDatabaseInfos(database.runCommand(new Document("dbStats", 1))); }; return executeTask(configuration, task); }
@Override public Object doInDB(MongoDatabase db) throws MongoException, DataAccessException { Document command = new Document("$eval", script.getCode()); BasicDBList commandArgs = new BasicDBList(); commandArgs.addAll(Arrays.asList(convertScriptArgs(false, args))); command.append("args", commandArgs); return db.runCommand(command).get("retval"); } });
public List<StatInfoEntry> getCollStats(ServerConfiguration configuration, final MongoCollection mongoCollection) { TaskWithReturnedObject<List<StatInfoEntry>> task = mongoClient -> { com.mongodb.client.MongoDatabase database = mongoClient.getDatabase(mongoCollection.getParentDatabase().getName()); return adaptToCollectionInfos(database.runCommand(new Document("collStats", mongoCollection.getName()))); }; return executeTask(configuration, task); }
@ManagedOperation public String getDatabaseStats(String databaseName) { return getDB(databaseName).runCommand(new Document("dbStats", 1).append("scale", 1024)).toJson(); }
@ManagedOperation public String getServerStatus() { return getDB("admin").runCommand(new Document("serverStatus", 1).append("rangeDeleter", 1).append("repl", 1)) .toJson(); }