Package com.mongodb

Examples of com.mongodb.MongoClientURI


            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


  @Override
  public void connect() throws IOException {
    MongoClient mongo;
    try {
      mongo = new MongoClient(new MongoClientURI(conf.getDatabaseUrl()));
    } catch (UnknownHostException e) {
      logger.error("Failed to establish connection to MongoDB at URL: "
          + conf.getDatabaseUrl(), e);
      throw new ConnectionException(e);
View Full Code Here

                mkBuilder.setRDBConnection(dataSource);
                log.info("Connected to datasource {}", dataSource);
            }
        } else {
            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)={}, 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);
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

            System.exit(1);
        }

        NodeStoreFixture fixture;
        if (nonOptions.get(0).startsWith(MongoURI.MONGODB_PREFIX)) {
            MongoClientURI uri = new MongoClientURI(nonOptions.get(0));
            if (uri.getDatabase() == null) {
                System.err.println("Database missing in MongoDB URI: " + uri.getURI());
                System.exit(1);
            }
            MongoConnection mongo = new MongoConnection(uri.getURI());
            DocumentNodeStore store = new DocumentMK.Builder().
                    setMongoDB(mongo.getDB()).
                    setClusterId(clusterId.value(options)).getNodeStore();
            fixture = new MongoFixture(store);
        } else {
View Full Code Here

      .stageGroupName(FullScaleIT.class.getName())
      .buildAndSave(mongoConnector);
  }

  private MongoDocumentIO buildMongoDocumentIO(MongoConfiguration mongoConfiguration) throws UnknownHostException {
    MongoClient mongo = new MongoClient(new MongoClientURI(mongoConfiguration.getDatabaseUrl()));
    DB db = mongo.getDB(mongoConfiguration.getNamespace());
    WriteConcern concern = mongo.getWriteConcern();
    long documentsToKeep = mongoConfiguration.getOldMaxCount();
    int oldDocsMaxSizeMB = mongoConfiguration.getOldMaxSize();
    StatusUpdater updater = new StatusUpdater(new MongoConnector(mongoConfiguration));
View Full Code Here

  private static RESTServer server;

  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    CoreConfiguration conf = ConfigurationFactory.getConfiguration(TEST_NAME);
    new MongoClient(new MongoClientURI(conf.getDatabaseUrl())).getDB(TEST_NAME).dropDatabase();
    dbc = new MongoConnector(conf);
   
    ShutdownHandler shutdownHandler = Mockito.mock(ShutdownHandler.class);
   
    Mockito.when(shutdownHandler.isShuttingDown()).thenReturn(false);
View Full Code Here

  }
 
  @AfterClass
  public static void tearDownClass() throws Exception {
    CoreConfiguration conf = ConfigurationFactory.getConfiguration(TEST_NAME);
    new MongoClient(new MongoClientURI(conf.getDatabaseUrl())).getDB(TEST_NAME).dropDatabase();
  }
View Full Code Here

public class StdinInput {

  private static DatabaseConfiguration conf = new MongoConfiguration();

  public static void main(String[] args) throws IOException, JsonException {
    MongoClient mongo = new MongoClient(new MongoClientURI(conf.getDatabaseUrl()));
    DB db = mongo.getDB(conf.getNamespace());
    WriteConcern concern = mongo.getWriteConcern();
    long documentsToKeep = conf.getOldMaxCount();
    int oldDocsMaxSizeMB = conf.getOldMaxSize();
    StatusUpdater updater = new StatusUpdater(new MongoConnector(conf));
View Full Code Here

            }
        } else {
            if (dbUrl != null) {
                dbUrl = dbUrl.trim();
                try {
                    final MongoClientURI uri = new MongoClientURI(dbUrl);
                    mongoClient = (MongoClient) Mongo.Holder.singleton().connect(uri);
                    db = mongoClient.getDB(uri.getDatabase());
                } catch (final Exception e) {
                    throw BatchMessages.MESSAGES.invalidConfigProperty(e, JdbcRepository.DB_URL_KEY, dbUrl);
                }
            }
        }
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.