当前位置: 首页>>代码示例>>Java>>正文


Java MongoClient.createShared方法代码示例

本文整理汇总了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);
}
 
开发者ID:folio-org,项目名称:okapi,代码行数:18,代码来源:MongoHandle.java

示例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();
		}
	});
		
}
 
开发者ID:fleetSim,项目名称:trucksimulation,代码行数:22,代码来源:BootstrapVerticle.java

示例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());

}
 
开发者ID:stump201,项目名称:mongiORM,代码行数:25,代码来源:Mongi.java

示例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());
		}
	});
}
 
开发者ID:aesteve,项目名称:vertx-feeds,代码行数:17,代码来源:WebServer.java

示例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);
}
 
开发者ID:vert-x3,项目名称:vertx-auth,代码行数:17,代码来源:MongoAuthOptions.java

示例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);
}
 
开发者ID:gmuecke,项目名称:grafana-vertx-datasource,代码行数:9,代码来源:AnnotationVerticle.java

示例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);

}
 
开发者ID:gmuecke,项目名称:grafana-vertx-datasource,代码行数:11,代码来源:AggregateTimeSeriesVerticle.java

示例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);
}
 
开发者ID:gmuecke,项目名称:grafana-vertx-datasource,代码行数:11,代码来源:LabelVerticle.java

示例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);
    });
}
 
开发者ID:codingchili,项目名称:chili-core,代码行数:11,代码来源:MongoDBMap.java

示例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);
  }
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:16,代码来源:MongoDataSourceImpl.java

示例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();
}
 
开发者ID:lysid,项目名称:scales,代码行数:15,代码来源:QueryVerticle.java

示例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;
}
 
开发者ID:amoAHCP,项目名称:kube_vertx_demo,代码行数:15,代码来源:InitMongoDB.java

示例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);
}
 
开发者ID:amoAHCP,项目名称:kube_vertx_demo,代码行数:15,代码来源:InitMongoDB.java

示例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);
}
 
开发者ID:fleetSim,项目名称:trucksimulation,代码行数:15,代码来源:SimulationControllerVerticle.java

示例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);
}
 
开发者ID:fleetSim,项目名称:trucksimulation,代码行数:12,代码来源:RouteCalculationVerticle.java


注:本文中的io.vertx.ext.mongo.MongoClient.createShared方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。