Examples of MongoClientURI


Examples of com.mongodb.MongoClientURI

        }

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

Examples of com.mongodb.MongoClientURI

    protected void init() throws Exception {
        if (beanType == null) {
            throw SupportMessages.MESSAGES.invalidReaderWriterProperty(null, null, "beanType");
        }
        if (mongoClientLookup == null) {
            final MongoClientURI clientURI;
            if (uri != null) {
                clientURI = new MongoClientURI(uri);
                if (database == null) {
                    database = clientURI.getDatabase();
                }
                if (collection == null) {
                    collection = clientURI.getCollection();
                }
            } else {
                clientURI = MongoClientObjectFactory.createMongoClientURI(host, database, collection, options, user, password);
            }
            mongoClient = (MongoClient) Mongo.Holder.singleton().connect(clientURI);
View Full Code Here

Examples of com.mongodb.MongoClientURI

   
    @Inject
    public MongoStore(SeyrenConfig seyrenConfig) {
        try {
            String uri = seyrenConfig.getMongoUrl();
            MongoClientURI mongoClientUri = new MongoClientURI(uri);
            MongoClient mongoClient = new MongoClient(mongoClientUri);
            DB mongo = mongoClient.getDB(mongoClientUri.getDatabase());
            mongo.setWriteConcern(WriteConcern.ACKNOWLEDGED);
            this.mongo = mongo;
            bootstrapMongo();
        } catch (Exception e) {
            throw new RuntimeException(e);
View Full Code Here

Examples of com.mongodb.MongoClientURI

    protected void init() throws Exception {
        if (beanType == null) {
            throw SupportLogger.LOGGER.invalidReaderWriterProperty(null, null, "beanType");
        }
        if (mongoClientLookup == null) {
            final MongoClientURI clientURI;
            if (uri != null) {
                clientURI = new MongoClientURI(uri);
                if (database == null) {
                    database = clientURI.getDatabase();
                }
                if (collection == null) {
                    collection = clientURI.getCollection();
                }
            } else {
                clientURI = MongoClientObjectFactory.createMongoClientURI(host, database, collection, options, user, password);
            }
            mongoClient = (MongoClient) Mongo.Holder.singleton().connect(clientURI);
View Full Code Here

Examples of com.mongodb.MongoClientURI

public class StandaloneMongoSplitterTest {

    @Test
    public void unshardedCollection() throws UnknownHostException, SplitFailedException {
        MongoClient client = new MongoClient("localhost", 27017);
        MongoClientURI uri = new MongoClientURIBuilder()
                                 .collection("mongo_hadoop", "splitter_test")
                                 .build();
        DBCollection collection = client.getDB(uri.getDatabase()).getCollection(uri.getCollection());
        collection.drop();
        for (int i = 0; i < 10000; i++) {
            collection.insert(new BasicDBObject("_id", i)
                                  .append("value", i)
                             );
View Full Code Here

Examples of com.mongodb.MongoClientURI

public class TreasuryYieldMulti extends MongoTool {
    public static void main(final String[] pArgs) throws Exception {
        //Here is an example of how to use multiple collections as the input to
        //a hadoop job, from within Java code directly.
        MultiCollectionSplitBuilder builder = new MultiCollectionSplitBuilder();
        builder.add(new MongoClientURI("mongodb://localhost:27017/mongo_hadoop.yield_historical.in"), null, true, null, null, null, false,
                    null)
               .add(new MongoClientURI("mongodb://localhost:27017/mongo_hadoop.yield_historical.in"), null, true, null, null,
                    new BasicDBObject("_id", new BasicDBObject("$gt", new Date(883440000000L))), false, null);

        Configuration conf = new Configuration();
        conf.set(MultiMongoCollectionSplitter.MULTI_COLLECTION_CONF_KEY, builder.toJSON());
View Full Code Here

Examples of com.mongodb.MongoClientURI

        node.put(MONGO_SPLITTER_CLASS, SingleMongoSplitter.class.getName());
        node.put(SPLITS_USE_RANGEQUERY, true);
        node.put(INPUT_NOTIMEOUT, true);
        settings.add(node);

        MongoClientURI inputUri3 = authCheck(new MongoClientURIBuilder()
                                                 .collection("mongo_hadoop", "yield_historical.in3"))
                                       .build();

        node = new ObjectNode(JsonNodeFactory.instance);
        node.put(INPUT_URI, inputUri3.toString());
        node.put(SPLITS_USE_RANGEQUERY, true);
        node.put(INPUT_NOTIMEOUT, true);
        settings.add(node);

        return settings;
View Full Code Here

Examples of com.mongodb.MongoClientURI

    /**
     * Constructs a new instance against the given URI
     */
    public MongoDBSink(final String uriString) {
        uri = new MongoClientURI(uriString);
    }
View Full Code Here

Examples of com.mongodb.MongoClientURI

        compareResults(getMongos().getDB("mongo_hadoop").getCollection("yield_historical.out"), getReference());
    }

    @Test
    public void testMultiMongos() {
        MongoClientURI outputUri = getOutputUri();
        new MapReduceJob(TreasuryYieldXMLConfig.class.getName())
            .jar(JOBJAR_PATH)
            .param(INPUT_MONGOS_HOSTS, "localhost:27017 localhost:27018")
            .inputUris(getInputUri())
            .outputUris(outputUri)
            .execute(isRunTestInVm());
        compareResults(getMongos().getDB(outputUri.getDatabase()).getCollection(outputUri.getCollection()), getReference());
    }
View Full Code Here

Examples of com.mongodb.MongoClientURI

    @Test
    public void testMultiOutputs() {
        DBObject opCounterBefore1 = (DBObject) getMongos().getDB("admin").command("serverStatus").get("opcounters");
        DBObject opCounterBefore2 = (DBObject) getMongos2().getDB("admin").command("serverStatus").get("opcounters");
        MongoClientURI outputUri = getOutputUri();

        new MapReduceJob(TreasuryYieldXMLConfig.class.getName())
            .jar(JOBJAR_PATH)
            .inputUris(getInputUri())
            .outputUris(outputUri, new MongoClientURIBuilder(outputUri).port(27018).build())
            .execute(isRunTestInVm());

        compareResults(getMongos().getDB(outputUri.getDatabase()).getCollection(outputUri.getCollection()), getReference());

        DBObject opCounterAfter1 = (DBObject) getMongos().getDB("admin").command("serverStatus").get("opcounters");
        DBObject opCounterAfter2 = (DBObject) getMongos2().getDB("admin").command("serverStatus").get("opcounters");

        compare(opCounterBefore1, opCounterAfter1);
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.