本文整理汇总了Java中io.vertx.ext.mongo.MongoClient.createShared方法的典型用法代码示例。如果您正苦于以下问题:Java MongoClient.createShared方法的具体用法?Java MongoClient.createShared怎么用?Java MongoClient.createShared使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.mongo.MongoClient
的用法示例。
在下文中一共展示了MongoClient.createShared方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MongoHandle
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
public MongoHandle(Vertx vertx, JsonObject conf) {
JsonObject opt = new JsonObject();
String h = Config.getSysConf("mongo_host", "localhost", conf);
if (!h.isEmpty()) {
opt.put("host", h);
}
String p = Config.getSysConf("mongo_port", "27017", conf);
if (!p.isEmpty()) {
opt.put("port", Integer.parseInt(p));
}
String dbName = Config.getSysConf("mongo_db_name", "", conf);
if (!dbName.isEmpty()) {
opt.put("db_name", dbName);
}
logger.info("Using mongo backend at " + h + " : " + p + " / " + dbName);
this.cli = MongoClient.createShared(vertx, opt);
}
示例2: start
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
@Override
public void start() throws Exception {
int cores = Runtime.getRuntime().availableProcessors();
LOGGER.info("Deploying {0} RouteCalculationVerticles", cores - 1);
DeploymentOptions routeMgrOptions = new DeploymentOptions().setWorker(true).setInstances(cores - 1).setConfig(config());
mongo = MongoClient.createShared(vertx, config().getJsonObject("mongodb", new JsonObject()));
vertx.deployVerticle(RouteCalculationVerticle.class.getName(), routeMgrOptions, w -> {
if (w.failed()) {
LOGGER.error("Deployment of RouteManager failed." + w.cause());
} else {
createDemoSimulation();
indexRoutes();
indexTraffic();
indexTrucks();
createLargeDemoSimulation();
}
});
}
示例3: Mongi
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
/**
*
* @param vertx
*/
public Mongi(Vertx vertx) {
this.vertx = vertx;
/*
* We need a list of classes, These will need to be linked to TypeAdapters
*/
Class[] allow = {
String.class,
Integer.class,
Boolean.class,
Double.class,
Date.class,
Calendar.class,
LocalTime.class
};
mongoClient = MongoClient.createShared(vertx, new JsonObject());
}
示例4: start
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
@Override
public void start(Future<Void> future) {
mongo = new MongoDAO(MongoClient.createShared(vertx, config.getJsonObject("mongo")));
RedisDAO redis = new RedisDAO(RedisClient.create(vertx, RedisUtils.createRedisOptions(config.getJsonObject("redis"))));
authApi = new AuthenticationApi(mongo);
feedsApi = new FeedsApi(mongo, redis);
server = vertx.createHttpServer(createOptions());
server.requestHandler(createRouter()::accept);
server.listen(result -> {
if (result.succeeded()) {
future.complete();
} else {
future.fail(result.cause());
}
});
}
示例5: createProvider
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
@Override
public MongoAuth createProvider(Vertx vertx) {
MongoClient client;
if (shared) {
if (datasourceName != null) {
client = MongoClient.createShared(vertx, config, datasourceName);
} else {
client = MongoClient.createShared(vertx, config);
}
} else {
client = MongoClient.createNonShared(vertx, config);
}
JsonObject authConfig = new JsonObject();
MongoAuthOptionsConverter.toJson(this, authConfig);
return MongoAuth.create(client, authConfig);
}
示例6: start
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
@Override
public void start(Future<Void> startFuture) throws Exception {
final JsonObject mongoConfig = config().getJsonObject(MONGO);
this.client = MongoClient.createShared(vertx, mongoConfig);
this.collectionName = mongoConfig.getString("col_name");
this.address = config().getString(ADDRESS, "/annotations");
vertx.eventBus().consumer(address, this::searchAnnotations);
}
示例7: start
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
@Override
public void start(Future<Void> startFuture) throws Exception {
final JsonObject mongoConfig = config().getJsonObject(MONGO);
this.client = MongoClient.createShared(vertx, mongoConfig);
this.collectionName = mongoConfig.getString("col_name");
this.address = config().getString(ADDRESS, "/query");
vertx.eventBus().consumer(address, this::queryTimeSeries);
}
示例8: start
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
@Override
public void start(Future<Void> startFuture) throws Exception {
final JsonObject mongoConfig = config().getJsonObject(MONGO);
this.client = MongoClient.createShared(vertx, mongoConfig);
this.collectionName = mongoConfig.getString("col_name");
this.address = config().getString(ADDRESS, "/search");
vertx.eventBus().consumer(this.address, this::searchLabels);
}
示例9: MongoDBMap
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
public MongoDBMap(Future<AsyncStorage<Value>> future, StorageContext<Value> context) {
client = MongoClient.createShared(context.vertx(), Serializer.json(context.storage()));
this.collection = context.collection();
this.context = context;
addIndex(ID, done -> {
future.complete(this);
});
}
示例10: retrieve
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
@Override
public MongoClient retrieve() {
JsonObject result = record().getMetadata().copy();
result.mergeIn(record().getLocation());
if (config != null) {
result.mergeIn(config);
}
if (result.getBoolean("shared", false)) {
return MongoClient.createShared(vertx, result);
} else {
return MongoClient.createNonShared(vertx, result);
}
}
示例11: start
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
@Override
public void start(Future<Void> startFuture) throws Exception {
JsonObject dbConfig = new JsonObject()
.put("connection_string", "mongodb://localhost:27017")
.put("db_name","scales-query");
this.db = MongoClient.createShared(this.vertx, dbConfig);
new EventBusServiceHelper(this.vertx, logger)
.publish(QueryScaleService.class, new QueryScaleServiceImpl(this.db), Service.QueryScale.address);
startFuture.complete();
}
示例12: initMongoData
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
public static MongoClient initMongoData(Vertx vertx,JsonObject config) {
MongoClient mongo;
// Create a mongo client using all defaults (connect to localhost and default port) using the database name "demo".
String connectionUrl = connectionURL();
boolean local = config.getBoolean("local", false);
if (connectionUrl != null && !local) {
String dbName = config.getString("dbname", "vxmsdemo");
mongo = MongoClient.createShared(vertx, new JsonObject().put("connection_string", connectionUrl).put("db_name", dbName));
} else {
mongo = MongoClient.createShared(vertx, new JsonObject().put("db_name", "demo"));
}
// the load function just populates some data on the storage
return mongo;
}
示例13: initMongoData
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
public static void initMongoData(Vertx vertx,JsonObject config) {
MongoClient mongo;
// Create a mongo client using all defaults (connect to localhost and default port) using the database name "demo".
String connectionUrl = connectionURL();
boolean local = config.getBoolean("local", false);
if (connectionUrl != null && !local) {
String dbName = config.getString("dbname", "vxmsdemo");
mongo = MongoClient.createShared(vertx, new JsonObject().put("connection_string", connectionUrl).put("db_name", dbName));
} else {
mongo = MongoClient.createShared(vertx, new JsonObject().put("db_name", "demo"));
}
// the load function just populates some data on the storage
loadData(mongo);
}
示例14: start
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
@Override
public void start() throws Exception {
mongo = MongoClient.createShared(vertx, config().getJsonObject("mongodb", new JsonObject()));
intervalMS = config().getJsonObject("simulation", new JsonObject()).getInteger("interval_ms", 1000);
msgInterval = config().getJsonObject("simulation", new JsonObject()).getInteger("msgInterval", 1);
SharedData sd = vertx.sharedData();
simulationStatus = sd.getLocalMap("simStatusMap");
vertx.eventBus().consumer(Bus.START_SIMULATION.address(), this::startSimulation);
vertx.eventBus().consumer(Bus.STOP_SIMULATION.address(), this::stopSimulation);
vertx.eventBus().consumer(Bus.SIMULATION_STATUS.address(), this::getSimulationStatus);
vertx.eventBus().consumer(Bus.SIMULATION_ENDED.address(), this::handleSimulationEnded);
}
示例15: start
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
@Override
public void start() throws Exception {
mongo = MongoClient.createShared(vertx, config().getJsonObject("mongodb", new JsonObject()));
JsonObject simConf = config().getJsonObject("simulation", new JsonObject());
osmFile = simConf.getString("osmFile", new File("osm", "denmark-latest.osm.pbf").getAbsolutePath());
LOGGER.info("Using osm file " + osmFile + " for route calculations.");
loadGraphHopper(osmFile);
vertx.eventBus().consumer(Bus.CALC_ROUTE.address(), this::calcRoute);
vertx.eventBus().consumer(Bus.CITY_SAMPLE.address(), this::getCitySample);
}