Package com.mongodb

Examples of com.mongodb.MongoClientURI


        properties = new Properties();
        InputStream is = MongoDbConversionsTest.class.getResourceAsStream("/mongodb.test.properties");
        properties.load(is);
        // ping Mongo and populate db and collection
        try {
            mongo = new MongoClient(new MongoClientURI(properties.getProperty("mongodb.connectionURI")));
            mongo.getDatabaseNames();
            dbName = properties.getProperty("mongodb.testDb");
            db = mongo.getDB(dbName);
        } catch (Exception e) {
            Assume.assumeNoException(e);
View Full Code Here


    public Object getObjectInstance(final Object obj,
                                    final Name name,
                                    final Context nameCtx,
                                    final Hashtable<?, ?> environment) throws Exception {
        final MongoClient mongoClient;
        final MongoClientURI clientURI;
        final String uri = (String) environment.get("uri");
        if (uri != null) {
            clientURI = new MongoClientURI(uri);
        } else {
            clientURI = createMongoClientURI((String) environment.get("host"),
                    (String) environment.get("database"),
                    (String) environment.get("collection"),
                    (String) environment.get("options"),
View Full Code Here

        }

        if (options != null) {
            uriVal.append('?').append(options);
        }
        return new MongoClientURI(uriVal.toString());
    }
View Full Code Here

            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(
View Full Code Here

            String uri = dialog.getStringFieldValue(ConnectDialog.Item.uri);
            if (!uri.trim().isEmpty()) {
                if (!uri.startsWith(MongoURI.MONGODB_PREFIX)) {
                    uri = MongoURI.MONGODB_PREFIX + uri;
                }
                MongoClientURI muri = new MongoClientURI(uri);
                mongo = new MongoClient(muri);
                String db = muri.getDatabase();
                if (db != null && !db.trim().isEmpty()) {
                    dbs.add(db.trim());
                }
            } else {
                String servers = dialog.getStringFieldValue(ConnectDialog.Item.servers);
View Full Code Here

            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(
View Full Code Here

        properties = new Properties();
        InputStream is = MongoDbConversionsTest.class.getResourceAsStream("/mongodb.test.properties");
        properties.load(is);
        // ping Mongo and populate db and collection
        try {
            mongo = new MongoClient(new MongoClientURI(properties.getProperty("mongodb.connectionURI")));
            mongo.getDatabaseNames();
            dbName = properties.getProperty("mongodb.testDb");
            db = mongo.getDB(dbName);
        } catch (Exception e) {
            Assume.assumeNoException(e);
View Full Code Here

        int changesSize = PropertiesUtil.toInteger(prop(PROP_CHANGES_SIZE), DEFAULT_CHANGES_SIZE);
        boolean useMK = PropertiesUtil.toBoolean(context.getProperties().get(PROP_USE_MK), false);


        MongoClientOptions.Builder builder = MongoConnection.getDefaultBuilder();
        MongoClientURI mongoURI = new MongoClientURI(uri, builder);

        if (log.isInfoEnabled()) {
            // Take care around not logging the uri directly as it
            // might contain passwords
            String type = useMK ? "MK" : "NodeStore";
            log.info("Starting Document{} with host={}, db={}, cache size (MB)={}, Off Heap Cache size (MB)={}, " +
                            "'changes' collection size (MB)={}, maxReplicationLagInSecs={}",
                    type, mongoURI.getHosts(), db, cacheSize, offHeapCache, changesSize, maxReplicationLagInSecs);
            log.info("Mongo Connection details {}", MongoConnection.toString(mongoURI.getOptions()));
        }

        MongoClient client = new MongoClient(mongoURI);
        DB mongoDB = client.getDB(db);
View Full Code Here

        try {
            String rwModeUri = readWriteMode;
            if(!readWriteMode.startsWith("mongodb://")){
                rwModeUri = String.format("mongodb://localhost/?%s", readWriteMode);
            }
            MongoClientURI uri = new MongoClientURI(rwModeUri);
            ReadPreference readPref = uri.getOptions().getReadPreference();

            if (!readPref.equals(nodes.getReadPreference())) {
                nodes.setReadPreference(readPref);
                LOG.info("Using ReadPreference {} ",readPref);
            }

            WriteConcern writeConcern = uri.getOptions().getWriteConcern();
            if (!writeConcern.equals(nodes.getWriteConcern())) {
                nodes.setWriteConcern(writeConcern);
                LOG.info("Using WriteConcern " + writeConcern);
            }
        } catch (Exception e) {
View Full Code Here

            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(
View Full Code Here

TOP

Related Classes of com.mongodb.MongoClientURI

Copyright © 2018 www.massapicom. 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.