Examples of MongoClient


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

        mk = new MongoMK.Builder()
                .memoryCacheSize(cacheSize * MB)
                .setMongoDB(mongoDB)
                .open();
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

            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

                    }

                    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

   * @param database Mongo database name, e.g. "foodmart"
   */
  public MongoSchema(String host, String database) {
    super();
    try {
      MongoClient mongo = new MongoClient(host);
      this.mongoDb = mongo.getDB(database);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

Examples of com.mongodb.MongoClient

  @Override
  public void start() {
    if ( !isCacheStarted ) {
      try {
        ServerAddress serverAddress = new ServerAddress( config.getHost(), config.getPort() );
        this.mongo = new MongoClient( serverAddress, config.buildOptions() );
        this.isCacheStarted = true;
      }
      catch ( UnknownHostException e ) {
        throw log.mongoOnUnknownHost( config.getHost() );
      }
View Full Code Here

Examples of com.mongodb.MongoClient

    public OakSegmentMKRepositoryStub(Properties settings) throws RepositoryException {
        super(settings);

        Session session = null;
        try {
            this.connection = new MongoClient(HOST, PORT);
            Jcr jcr = new Jcr(new Oak(new SegmentNodeStore(
                    new MongoStore(connection.getDB(DB), 4))));
            this.repository = jcr.createRepository();

            session = getRepository().login(superuser);
View Full Code Here

Examples of com.mongodb.MongoClient

        }));
    }

    public static boolean isAvailable() {
        try {
            MongoClient mongo = new MongoClient(HOST, PORT);
            try {
                mongo.getDatabaseNames();
                return true;
            } finally {
                mongo.close();
            }
        } catch (Exception e) {
            return false;
        }
    }
View Full Code Here

Examples of com.mongodb.MongoClient

    String host = dbHost;
    int port = Integer.parseInt(dbPort);
    try {
      // New MongoDB Client, see http://docs.mongodb.org/manual/release-notes/drivers-write-concern/
      mongo = new MongoClient(host, port);
    } catch (UnknownHostException e) {
      throw new PersistenceStartException("Unable to resolve the MongoDb hostname", e);
    }

    try {
View Full Code Here

Examples of com.mongodb.MongoClient

        ServerAddress serverAddress = new ServerAddress( config.getHost(), config.getPort() );
        MongoClientOptions clientOptions = config.buildOptions();

        log.connectingToMongo( config.getHost(), config.getPort(), clientOptions.getConnectTimeout() );

        this.mongo = new MongoClient( serverAddress, clientOptions );
      }
      catch ( UnknownHostException e ) {
        throw log.mongoOnUnknownHost( config.getHost() );
      }
      catch ( RuntimeException e ) {
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.