/** * @return Default {@link IMongoCmdOptions command options}. */ private static IMongoCmdOptions defaultCommandOptions() { return new MongoCmdOptionsBuilder() // .useNoPrealloc(false) // .useSmallFiles(false) // .useNoJournal(false) // .useStorageEngine(STORAGE_ENGINE) // .verbose(false) // .build(); }
MongodConfigBuilder builder = new MongodConfigBuilder() // .version(version) // .withLaunchArgument("--quiet") // .net(new Net(LOCALHOST, port, Network.localhostIsIPv6())) // .configServer(configServer).cmdOptions(cmdOptions); // .replication(new Storage(null, replicaSet, 0)); builder = builder.shardServer(shardServer); } else { builder = builder.shardServer(false); return builder.build(); } catch (IOException e) { throw new RuntimeException(e);
MongosConfigBuilder builder = new MongosConfigBuilder() // .version(version) // .withLaunchArgument("--quiet", null) // .net(new Net(LOCALHOST, port, Network.localhostIsIPv6())) // .cmdOptions(cmdOptions); builder = builder.replicaSet(configServerReplicaSet) // .configDB(LOCALHOST + ":" + configServerPort); return builder.build(); } catch (IOException e) { throw new RuntimeException(e);
protected static MongodConfigBuilder createMongodConfigBuilder(int port) throws Exception { return new MongodConfigBuilder() .version(Version.Main.V2_4) .net(new Net(port, Network.localhostIsIPv6())); }
if (!mongoConfig.replication().getReplSetName().equals(replicaName)) { throw new Exception( "Replica set name must match in mongo configuration"); IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder() .defaultsWithLogger(Command.MongoD,logger) .processOutput(outputFunction.apply(Command.MongoD)) .build(); MongodStarter starter = MongodStarter.getInstance(runtimeConfig); .connectTimeout(10) .build(); MongoClient mongo = new MongoClient(new ServerAddress(mongoConfigList.get(0).net() .getServerAddress().getHostName(), mongoConfigList.get(0).net() .getPort()), mo); DB mongoAdminDB = mongo.getDB(ADMIN_DATABASE_NAME); DBObject host = new BasicDBObject(); host.put("_id", i++); host.put("host", mongoConfig.net().getServerAddress().getHostName() + ":" + mongoConfig.net().getPort()); members.add(host);
public AbstractMongoConfigBuilder() throws IOException { timeout().setDefault(new Timeout()); net().setDefault(new Net()); cmdOptions().setDefault(new MongoCmdOptionsBuilder().build()); username().setDefault(""); password().setDefault(""); dbName().setDefault(""); stopTimeout().setDefault(TimeUnit.SECONDS.toMillis(5)); }
private void initializeMongos() throws Exception { MongosStarter runtime = MongosStarter.getInstance(new RuntimeConfigBuilder() .defaultsWithLogger(Command.MongoS,logger) .processOutput(outputFunction.apply(Command.MongoS)) .build()); mongosExecutable = runtime.prepare(config); mongosProcess = mongosExecutable.start(); }
.build(); try (MongoClient mongo = new MongoClient( new ServerAddress(this.config.net().getServerAddress() .getHostName(), this.config.net().getPort()), options)) { DB mongoAdminDB = mongo.getDB(ADMIN_DATABASE_NAME); command += ","; command += mongodConfig.net().getServerAddress().getHostName() + ":" + mongodConfig.net().getPort();
protected static IMongodConfig createMongodConfig(int port) throws Exception { return createMongodConfigBuilder(port).build(); }
public Mongo getMongo() throws UnknownHostException, MongoException { return new MongoClient(new ServerAddress(mongosProcess.getConfig().net() .getServerAddress(), mongosProcess.getConfig().net().getPort())); }
@Override public IMongosConfig build() { IFeatureAwareVersion version = version().get(); Net net = net().get(); Timeout timeout = timeout().get(); String configDB = get(CONFIG_DB); String replicaSet = get(RELICA_SET); IMongoCmdOptions cmdOptions=get(CMD_OPTIONS); String pidFile = get(PID_FILE); return new ImmutableMongosConfig(version, net, timeout, cmdOptions, pidFile, configDB, replicaSet, args); }
private void initializeConfigServer(IMongodConfig config) throws Exception { if (!config.isConfigServer()) { throw new Exception( "Mongo configuration is not a defined for a config server."); } MongodStarter starter = MongodStarter.getDefaultInstance(); MongodExecutable mongodExe = starter.prepare(config); MongodProcess process = mongodExe.start(); mongodProcessList.add(process); }
@Override public IMongoCmdOptions build() { Integer syncDelay = get(SYNC_DELAY, null); String storageEngine = get(STORAGE_ENGINE, null); boolean verbose = get(VERBOSE); boolean noPrealloc = get(NOPREALLOC); boolean smallFiles = get(SMALLFILES); boolean noJournal = get(NOJOURNAL); boolean enableTextSearch = get(ENABLE_TEXTSEARCH); boolean auth = get(ENABLE_AUTH); boolean master = get(MASTER); return new MongoCmdOptions(syncDelay, storageEngine, verbose, noPrealloc, smallFiles, noJournal, enableTextSearch, auth, master); }
public MongoCmdOptionsBuilder useNoJournal(boolean value) { set(NOJOURNAL, value); return this; }
@Override public String messageOnException(Class<?> context, Exception exception) { if (exception instanceof ExecutableFileAlreadyExistsException) { return "\n\n" + "-----------------------------------------------------\n" + "There was a file name collision extracting the executable.\n" + "See "+SupportConfig.baseUrl()+"#executable-collision\n" + "-----------------------------------------------------\n\n"; } return null; }
public MongoImportConfigBuilder headerline(boolean headerline) { set(HEADERLINE, headerline); return this; }
public MongoDumpConfigBuilder verbose(Boolean verbose) { set(VERBOSE, verbose); return this; }
@Override public void configure() throws Exception { conf = new MongodConfigBuilder() .version(Version.Main.PRODUCTION) .net(new Net(ip, port, false)) .build(); }
public MongoCmdOptionsBuilder master(boolean enable) { set(MASTER, enable); return this; }
@Override public void configure() throws Exception { conf = new MongodConfigBuilder() .version(Version.Main.PRODUCTION) .net(new Net(ip, port, false)) .build(); }