.net(new Net(LOCALHOST, port, Network.localhostIsIPv6())) // .cmdOptions(cmdOptions);
.net(new Net(LOCALHOST, port, Network.localhostIsIPv6())) //
protected static MongodConfigBuilder createMongodConfigBuilder(int port) throws Exception { return new MongodConfigBuilder() .version(Version.Main.V2_4) .net(new Net(port, Network.localhostIsIPv6())); }
public static boolean localhostIsIPv6() { try { return Network.localhostIsIPv6(); } catch (UnknownHostException e) { return false; } } }
public static boolean localhostIsIPv6() { try { return Network.localhostIsIPv6(); } catch (UnknownHostException e) { return false; } } }
public Net() throws IOException { this(null, Network.getFreeServerPort(), Network.localhostIsIPv6()); }
private IMongodConfig buildMongodConfig() throws IOException { return new MongodConfigBuilder() .version(version) .net(new Net(bindIp, getPort(), Network.localhostIsIPv6())) .build(); }
private boolean startMongoExe(boolean startMongoLocal, int localPort) { if (startMongoLocal) { LOGGER.info("STARTING MONGO EXE"); try { IMongodConfig config = new MongodConfigBuilder().version(Version.Main.PRODUCTION) .net(new Net(localPort, Network.localhostIsIPv6())).build(); exe = MongodStarter.getDefaultInstance().prepare(config); exe.start(); return true; } catch (IOException e) { throw new RuntimeException(e); } } return false; }
public static void startMongoDB() throws IOException { if (!started.compareAndSet(false, true)) { throw new RuntimeException("Embedded mongo already running, call stopMongoDB before starting it again!"); } final String bindIp = "localhost"; try { final int port = Network.getFreeServerPort(); final IMongodConfig mongodConfig = new MongodConfigBuilder() .version(Version.Main.PRODUCTION) .net(new Net(bindIp, port, Network.localhostIsIPv6())) .build(); final MongodStarter runtime = MongodStarter.getInstance(new RuntimeConfigBuilder() .defaultsWithLogger(Command.MongoD, LOG) .build()); mongodExecutable = runtime.prepare(mongodConfig, Distribution.detectFor(Version.Main.PRODUCTION)); mongodProcess = mongodExecutable.start(); mongoClient = new MongoClient(bindIp, port); } catch (final IOException e) { stopMongoDB(); throw e; } }
@Override public void before() throws Exception { if(defaultPort < 0) { currentPort = Helper.findRandomOpenPortOnAllLocalInterfaces(); } else { currentPort = defaultPort; } IMongodConfig mongodConfig = new MongodConfigBuilder() .version(version) .net(new Net("localhost", currentPort, Network.localhostIsIPv6())) .build(); MongodStarter runtime = MongodStarter.getDefaultInstance(); mongodExe = runtime.prepare(mongodConfig); mongod = mongodExe.start(); }
public void start() throws Exception { MongodStarter starter = MongodStarter.getDefaultInstance(); mongodExe = starter.prepare(new MongodConfigBuilder().version(Version.V3_2_1) .net(new Net(27017, Network.localhostIsIPv6())).build()); mongod = mongodExe.start(); client = new MongoClient("localhost"); }
@Override protected void before() throws IOException { MongodStarter runtime = MongodStarter.getDefaultInstance(); IMongodConfig config = new MongodConfigBuilder(). version(getMongoVersion()). net(new Net(getPort(), Network.localhostIsIPv6())). build(); mongodExe = runtime.prepare(config); try { mongod = mongodExe.start(); } catch (IOException e) { //Mongo failed to start for the previously stated reason. A single retry will be attempted. mongod = mongodExe.start(); } }
@BeforeClass public static void startMongo() throws Exception { String uri = getConnectionString(); if (uri == null ) { Version.Main version = Version.Main.V3_4; int port = 27018; System.out.println("Starting Mongo " + version + " on port " + port); IMongodConfig config = new MongodConfigBuilder(). version(version). net(new Net(port, Network.localhostIsIPv6())). build(); exe = MongodStarter.getDefaultInstance().prepare(config); exe.start(); } else { System.out.println("Using existing Mongo " + uri); } }
@BeforeClass public static void setUpClass() throws Exception { RuntimeConfig config = RuntimeConfig.getInstance(LOGGER); MongodStarter runtime = MongodStarter.getInstance(config); int freeServerPort = Network.getFreeServerPort(); mongodExecutable = runtime.prepare(new MongodConfig(Version.Main.V2_3, freeServerPort, Network.localhostIsIPv6())); mongodProcess = mongodExecutable.start(); binaryStore = new MongodbBinaryStore("localhost", freeServerPort, "test-" + UUID.randomUUID(), null, null, null); binaryStore.setMimeTypeDetector(DEFAULT_DETECTOR); binaryStore.start(); }
/** * Start MongoDB instance. Don't forget to call {@link #stop()} * if you don't need it anymore! * @throws IOException if the instance could not be started */ public MongoDBTestConnector() throws IOException { mongodExe = starter.prepare(new MongodConfigBuilder() .version(Version.Main.PRODUCTION) .net(new Net(serverAddress.getPort(), Network.localhostIsIPv6())) .build()); mongod = mongodExe.start(); }
private void prepareExecutable(boolean authEnabled) throws IOException { final MongoCmdOptionsBuilder cmdBuilder = new MongoCmdOptionsBuilder(); cmdBuilder.enableAuth(authEnabled); if (useWiredTiger && isMongo3()) { cmdBuilder.useStorageEngine(WIRED_TIGER); } final IMongoCmdOptions cmdOptions = cmdBuilder.build(); MongodConfigBuilder builder = new MongodConfigBuilder() .version(useVersion) .cmdOptions(cmdOptions) .net(new Net(host, port, Network.localhostIsIPv6())); if (authEnabled && isMongo3()) { builder.setParameter("authenticationMechanisms", authMechanisms); } if (replSetName != null) { removeLockFile(builder); builder.replication(new Storage(dataDirectory, replSetName, oplogSizeMb)); } mongodConfig = builder.build(); executable = null; executable = runtime.prepare(mongodConfig); }
@BeforeClass public static void beforeClass() throws Exception { MongodStarter runtime = MongodStarter.getDefaultInstance(); mongodExe = runtime.prepare( new MongodConfigBuilder().version(Version.V3_3_1) .net(new Net(12345, Network.localhostIsIPv6())) .build()); MongodProcess process = mongodExe.start(); await().until(() -> process != null); }
@BeforeClass public static void beforeClass() throws Exception { MongodStarter runtime = MongodStarter.getDefaultInstance(); mongodExe = runtime.prepare( new MongodConfigBuilder().version(Version.V3_3_1) .net(new Net(12345, Network.localhostIsIPv6())) .build()); MongodProcess process = mongodExe.start(); await().until(() -> process != null); }
@BeforeClass public static void beforeClass() throws Exception { MongodStarter runtime = MongodStarter.getDefaultInstance(); mongodExe = runtime.prepare( new MongodConfigBuilder().version(Version.V3_3_1) .net(new Net(12345, Network.localhostIsIPv6())) .build()); MongodProcess process = mongodExe.start(); await().until(() -> process != null); }
@BeforeClass public static void beforeClass() throws Exception { MongodStarter runtime = MongodStarter.getDefaultInstance(); mongodExe = runtime.prepare( new MongodConfigBuilder().version(Version.V3_3_1) .net(new Net(12345, Network.localhostIsIPv6())) .build()); MongodProcess process = mongodExe.start(); await().until(() -> process != null); }