Examples of MongoConnection


Examples of org.apache.jackrabbit.mongomk.MongoConnection

        String host = properties.getProperty("host");
        int port = Integer.parseInt(properties.getProperty("port"));
        String database = properties.getProperty("db");

        mongoConnection = new MongoConnection(host, port, database);
    }
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.impl.MongoConnection

    public ArrayList<MicroKernel> init(Configuration conf, int mksNumber)
            throws Exception {

        ArrayList<MicroKernel> mks = new ArrayList<MicroKernel>();

        MongoConnection mongoConnection;
        mongoConnection = new MongoConnection(conf.getHost(),
                conf.getMongoPort(), conf.getMongoDatabase());

        Thread.sleep(1000);
        MongoClearCollections.clearAllCollections(mongoConnection);
        mongoConnection.close();

        mongoConnection = new MongoConnection(conf.getHost(),
                conf.getMongoPort(), "admin");
        // set the shard key
        mongoConnection.getDB()
                .command(
                        BasicDBObjectBuilder
                                .start("shardCollection", "test.nodes")
                                .push("key").add("path", 1).add("revId", 1)
                                .pop().get());

        for (int i = 0; i < mksNumber; i++) {
            mongoConnection = new MongoConnection(conf.getHost(),
                    conf.getMongoPort(), conf.getMongoDatabase());
            MongoNodeStore nodeStore = new MongoNodeStore(
                    mongoConnection.getDB());
            // MongoAssert.setNodeStore(nodeStore);
            BlobStore blobStore = new MongoGridFSBlobStore(
                    mongoConnection.getDB());
            mks.add(new MongoMicroKernel(mongoConnection, nodeStore, blobStore));
        }

        return mks;
    }
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.impl.MongoConnection

        BlobStore blobStore = new BlobStoreFS(System.getProperty("java.io.tmpdir"));
        microKernel = new MongoMicroKernel(mongoConnection, nodeStore, blobStore);
    }

    private void initMongo() throws Exception {
        mongoConnection = new MongoConnection(config.getMongoHost(), config.getMongoPort(), config.getMongoDatabase());
    }
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.util.MongoConnection

    private static final int NB_THREADS = 16;

    private List<MongoConnection> connections = new ArrayList<MongoConnection>();

    private MicroKernel createMicroKernel() throws Exception {
        MongoConnection connection = new MongoConnection(HOST,
                PORT, DB);
        connections.add(connection);
        DB mongoDB = connection.getDB();
        return new MongoMK.Builder().setMongoDB(mongoDB).open();
    }
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.util.MongoConnection

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

        Session session = null;
        try {
            this.connection = new MongoConnection(HOST, PORT, DB);
            Jcr jcr = new Jcr(new MongoMK.Builder().
                    setMongoDB(connection.getDB()).open());
            jcr.with(Executors.newScheduledThreadPool(1));
            this.repository = jcr.createRepository();
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.util.MongoConnection

            }
        }
    }

    public static boolean isMongoDBAvailable() {
        MongoConnection connection = null;
        try {
            connection = new MongoConnection(HOST, PORT, DB);
            connection.getDB().command(new BasicDBObject("ping", 1));
            return true;
        } catch (Exception e) {
            return false;
        } finally {
            if (connection != null) {
                connection.close();
            }
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.util.MongoConnection

            this.reference = new WeakReference<MongoConnection>(connection);
        }

        @Override
        public void run() {
            MongoConnection connection = reference.get();
            if (connection != null) {
                connection.close();
            }
        }
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.util.MongoConnection

        String db = PropertiesUtil.toString(config.get(PROP_DB), DEFAULT_DB);

        logger.info("Starting MongoDB MicroKernel with host={}, port={}, db={}",
                new Object[] {host, port, db});

        MongoConnection connection = new MongoConnection(host, port, db);
        DB mongoDB = connection.getDB();

        logger.info("Connected to database {}", mongoDB);

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

Examples of org.apache.jackrabbit.mongomk.util.MongoConnection

            @Override
            public Repository[] setUpCluster(int n) throws Exception {
                Repository[] cluster = new Repository[n];
                kernels = new MongoMK[cluster.length];
                for (int i = 0; i < cluster.length; i++) {
                    MongoConnection mongo =
                            new MongoConnection(host, port, unique);
                    kernels[i] = new MongoMK.Builder().
                            setMongoDB(mongo.getDB()).
                            setClusterId(i).open();
                    Oak oak = new Oak(new KernelNodeStore(kernels[i], cacheSize));
                    cluster[i] = new Jcr(oak).createRepository();
                }
                return cluster;
            }
            @Override
            public void tearDownCluster() {
                for (MongoMK kernel : kernels) {
                    kernel.dispose();
                }
                try {
                    MongoConnection mongo =
                            new MongoConnection(host, port, unique);
                    mongo.getDB().dropDatabase();
                    mongo.close();
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        };
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.util.MongoConnection

    private static MicroKernel mk2;
    private static MicroKernel mk3;

    @BeforeClass
    public static void createMongoConnections() throws Exception {
        mongoConnection2 = new MongoConnection(HOST, PORT, DB2);
        mongoConnection3 = new MongoConnection(HOST, PORT, DB);
    }
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.