Examples of MongoClient


Examples of com.mongodb.MongoClient

            private MongoClient mongo;
            @Override
            protected Repository[] internalSetUpCluster(int n) throws Exception {
                Repository[] cluster = new Repository[n];
                stores = new SegmentStore[cluster.length];
                mongo = new MongoClient(host, port);
                for (int i = 0; i < cluster.length; i++) {
                    stores[i] = new MongoStore(mongo.getDB(unique), cacheSizeMB);
                    Oak oak = new Oak(new SegmentNodeStore(stores[i]));
                    cluster[i] = new Jcr(oak).createRepository();
                }
View Full Code Here

Examples of com.mongodb.MongoClient

            logger.info("Starting Document{} with host={}, db={}, cache size (MB)={}, Off Heap Cache size (MB)={}",
                    new Object[] {type, mongoURI.getHosts(), db, cacheSize, offHeapCache});
            logger.info("Mongo Connection details {}", MongoConnection.toString(mongoURI.getOptions()));
        }

        MongoClient client = new MongoClient(mongoURI);
        DB mongoDB = client.getDB(db);

        mk = new DocumentMK.Builder()
                .memoryCacheSize(cacheSize * MB)
                .offHeapCacheSize(offHeapCache * MB)
                .setMongoDB(mongoDB)
View Full Code Here

Examples of com.mongodb.MongoClient

            RepositoryContext source =
                    RepositoryContext.create(RepositoryConfig.create(dir, xml));
            try {
                if (dst.startsWith("mongodb://")) {
                    MongoClientURI uri = new MongoClientURI(dst);
                    MongoClient client = new MongoClient(uri);
                    try {
                        DocumentNodeStore target = new DocumentMK.Builder()
                            .setMongoDB(client.getDB(uri.getDatabase()))
                            .getNodeStore();
                        try {
                            RepositoryUpgrade upgrade =
                                    new RepositoryUpgrade(source, target);
                            upgrade.setCopyBinariesByReference(
                                    options.has("datastore"));
                            upgrade.copy(null);
                        } finally {
                            target.dispose();
                        }
                    } finally {
                        client.close();
                    }
                } else {
                    FileStore store = new FileStore(new File(dst), 256);
                    try {
                        NodeStore target = new SegmentNodeStore(store);
View Full Code Here

Examples of com.mongodb.MongoClient

                            "'changes' collection size (MB)={}, blobCacheSize (MB)={}, maxReplicationLagInSecs={}",
                    type, mongoURI.getHosts(), db, cacheSize, offHeapCache, changesSize, blobCacheSize, maxReplicationLagInSecs);
            log.info("Mongo Connection details {}", MongoConnection.toString(mongoURI.getOptions()));
        }

        MongoClient client = new MongoClient(mongoURI);
        DB mongoDB = client.getDB(db);

        DocumentMK.Builder mkBuilder =
                new DocumentMK.Builder().
                memoryCacheSize(cacheSize * MB).
                offHeapCacheSize(offHeapCache * MB);
 
View Full Code Here

Examples of com.mongodb.MongoClient

                if (server != null && server.length() > 0) {
                    final int portInt = AbstractAppender.parseInt(port, 0);
                    description += ", server=" + server;
                    if (portInt > 0) {
                        description += ", port=" + portInt;
                        database = new MongoClient(server, portInt).getDB(databaseName);
                    } else {
                        database = new MongoClient(server).getDB(databaseName);
                    }
                } else {
                    database = new MongoClient().getDB(databaseName);
                }
            } catch (final Exception e) {
                LOGGER.error("Failed to obtain a database instance from the MongoClient at server [{}] and "
                        + "port [{}].", server, port);
                return null;
View Full Code Here

Examples of com.mongodb.MongoClient

     * @throws Exception If an error occurred while trying to connect.
     */
    public MongoConnection(String host, int port, String database) throws Exception {
        MongoClientOptions options = getDefaultBuilder().build();
        ServerAddress serverAddress = new ServerAddress(host, port);
        mongo = new MongoClient(serverAddress, options);
        db = mongo.getDB(database);
    }
View Full Code Here

Examples of com.mongodb.MongoClient

            logger.info("Starting MongoDB {} with host={}, db={}",
                    new Object[] {type,mongoURI.getHosts(), db});
            logger.info("Mongo Connection details {}",MongoConnection.toString(mongoURI.getOptions()));
        }

        MongoClient client = new MongoClient(mongoURI);
        DB mongoDB = client.getDB(db);

        MongoMK mk = new MongoMK.Builder()
                .memoryCacheSize(cacheSize * MB)
                .setMongoDB(mongoDB)
                .open();
View Full Code Here

Examples of com.mongodb.MongoClient

    try {

      _mongodExe = runtime.prepare(mongodConfig);
      _mongod = _mongodExe.start();

      _mongo = new MongoClient("localhost", port);
    } catch (Exception e) {
      log.error("Error starting embedded Mongodb server... tearing down test driver.");
      tearDownClass();
    }
  }
View Full Code Here

Examples of com.mongodb.MongoClient

  public void start(Map<String, Object> properties) {
    properties.keySet();
    String seeds = properties.get(Bootstrap.MONGODB_SEEDS).toString();
    try {
      if (seeds == null)
        mongoClient = new MongoClient();
      else if (seeds.contains(",")) {
        // It has multiple nodes
        StringTokenizer st = new StringTokenizer(seeds, ",");
        List<ServerAddress> addrs = new ArrayList<ServerAddress>();
        while (st.hasMoreElements()) {
          String serverName = st.nextElement().toString();
          ServerAddress server = new ServerAddress(serverName);
          addrs.add(server);
        }
        mongoClient = new MongoClient(addrs);
      } else
        mongoClient = new MongoClient(seeds);
    } catch (UnknownHostException e) {
      throw new RuntimeException(e.getMessage(), e);
    }
    String keySpace = properties.get(Bootstrap.MONGODB_KEYSPACE).toString();
    db = mongoClient.getDB(keySpace);
View Full Code Here

Examples of com.mongodb.MongoClient

                if (server != null && server.length() > 0) {
                    final int portInt = AbstractAppender.parseInt(port, 0);
                    description += ", server=" + server;
                    if (portInt > 0) {
                        description += ", port=" + portInt;
                        database = new MongoClient(server, portInt).getDB(databaseName);
                    } else {
                        database = new MongoClient(server).getDB(databaseName);
                    }
                } else {
                    database = new MongoClient().getDB(databaseName);
                }
            } catch (final Exception e) {
                LOGGER.error("Failed to obtain a database instance from the MongoClient at server [{}] and "
                        + "port [{}].", server, port);
                return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.