本文整理了Java中io.vertx.ext.mongo.MongoClient.getCollections()
方法的一些代码示例,展示了MongoClient.getCollections()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MongoClient.getCollections()
方法的具体详情如下:
包路径:io.vertx.ext.mongo.MongoClient
类名称:MongoClient
方法名:getCollections
暂无
代码示例来源:origin: vert-x3/vertx-rx
/**
* Get a list of all collections in the database.
* @param resultHandler will be called with a list of collections.
* @return
*/
public io.vertx.rxjava.ext.mongo.MongoClient getCollections(Handler<AsyncResult<List<String>>> resultHandler) {
delegate.getCollections(resultHandler);
return this;
}
代码示例来源:origin: io.vertx/vertx-rx-java
/**
* Get a list of all collections in the database.
* @param resultHandler will be called with a list of collections.
* @return
*/
public io.vertx.rxjava.ext.mongo.MongoClient getCollections(Handler<AsyncResult<List<String>>> resultHandler) {
delegate.getCollections(resultHandler);
return this;
}
代码示例来源:origin: io.vertx/vertx-mongo-service
@Override
public MongoService getCollections(Handler<AsyncResult<List<String>>> resultHandler) {
client.getCollections(resultHandler);
return this;
}
代码示例来源:origin: de.braintags/vertx-key-generator
private void initMongoClient(Handler<AsyncResult<Void>> handler) {
try {
Vertx vertx = getVertx();
JsonObject config = getConfig();
LOGGER.info("STARTING MONGO CLIENT with config " + config);
mongoClient = shared ? MongoClient.createShared(vertx, config) : MongoClient.createNonShared(vertx, config);
if (mongoClient == null) {
handler.handle(Future.failedFuture(new InitException("No MongoClient created")));
} else {
mongoClient.getCollections(resultHandler -> {
if (resultHandler.failed()) {
LOGGER.error("", resultHandler.cause());
handler.handle(Future.failedFuture(resultHandler.cause()));
} else {
LOGGER.info(String.format("found %d collections", resultHandler.result().size()));
handler.handle(Future.succeededFuture());
}
});
}
} catch (Exception e) {
handler.handle(Future.failedFuture(new InitException(e)));
}
}
代码示例来源:origin: io.vertx/vertx-auth-mongo
/**
* Method drops all collections which are starting with the prefix {@link #TABLE_PREFIX}
*
* @param latch
* the latch to be used
*/
protected void dropCollections(CountDownLatch latch) {
// Drop all the collections in the db
mongoClient.getCollections(onSuccess(list -> {
AtomicInteger collCount = new AtomicInteger();
List<String> toDrop = getOurCollections(list);
int count = toDrop.size();
if (!toDrop.isEmpty()) {
for (String collection : toDrop) {
mongoClient.dropCollection(collection, onSuccess(v -> {
if (collCount.incrementAndGet() == count) {
latch.countDown();
}
}));
}
} else {
latch.countDown();
}
}));
}
代码示例来源:origin: io.vertx/vertx-service-discovery
@Test
public void testWithSugar() throws InterruptedException {
Record record = MongoDataSource.createRecord("some-mongo-db",
new JsonObject().put("connection_string", "mongodb://localhost:12345"),
new JsonObject().put("database", "some-raw-data"));
discovery.publish(record, r -> { });
await().until(() -> record.getRegistration() != null);
AtomicBoolean success = new AtomicBoolean();
MongoDataSource.getMongoClient(discovery, new JsonObject().put("name", "some-mongo-db"),
ar -> {
MongoClient client = ar.result();
client.getCollections(coll -> {
client.close();
success.set(coll.succeeded());
});
});
await().untilAtomic(success, is(true));
}
}
代码示例来源:origin: vert-x3/vertx-service-discovery
@Test
public void testWithSugar() throws InterruptedException {
Record record = MongoDataSource.createRecord("some-mongo-db",
new JsonObject().put("connection_string", "mongodb://localhost:12345"),
new JsonObject().put("database", "some-raw-data"));
discovery.publish(record, r -> { });
await().until(() -> record.getRegistration() != null);
AtomicBoolean success = new AtomicBoolean();
MongoDataSource.getMongoClient(discovery, new JsonObject().put("name", "some-mongo-db"),
ar -> {
MongoClient client = ar.result();
client.getCollections(coll -> {
client.close();
success.set(coll.succeeded());
});
});
await().untilAtomic(success, is(true));
}
}
代码示例来源:origin: vert-x3/vertx-service-discovery
@Test
public void test() throws InterruptedException {
Record record = MongoDataSource.createRecord("some-mongo-db",
new JsonObject().put("connection_string", "mongodb://localhost:12345"),
new JsonObject().put("database", "some-raw-data"));
discovery.publish(record, (r) -> {
});
await().until(() -> record.getRegistration() != null);
AtomicReference<Record> found = new AtomicReference<>();
discovery.getRecord(new JsonObject().put("name", "some-mongo-db"), ar -> {
found.set(ar.result());
});
await().until(() -> found.get() != null);
ServiceReference service = discovery.getReference(found.get());
MongoClient client = service.get();
AtomicBoolean success = new AtomicBoolean();
client.getCollections(ar -> {
success.set(ar.succeeded());
});
await().untilAtomic(success, is(true));
service.release();
// Just there to be sure we can call it twice
service.release();
}
代码示例来源:origin: io.vertx/vertx-service-discovery
@Test
public void test() throws InterruptedException {
Record record = MongoDataSource.createRecord("some-mongo-db",
new JsonObject().put("connection_string", "mongodb://localhost:12345"),
new JsonObject().put("database", "some-raw-data"));
discovery.publish(record, (r) -> {
});
await().until(() -> record.getRegistration() != null);
AtomicReference<Record> found = new AtomicReference<>();
discovery.getRecord(new JsonObject().put("name", "some-mongo-db"), ar -> {
found.set(ar.result());
});
await().until(() -> found.get() != null);
ServiceReference service = discovery.getReference(found.get());
MongoClient client = service.get();
AtomicBoolean success = new AtomicBoolean();
client.getCollections(ar -> {
success.set(ar.succeeded());
});
await().untilAtomic(success, is(true));
service.release();
// Just there to be sure we can call it twice
service.release();
}
内容来源于网络,如有侵权,请联系作者删除!