Java Code Examples for de.flapdoodle.embed.mongo.config.MongodConfigBuilder#replication()
The following examples show how to use
de.flapdoodle.embed.mongo.config.MongodConfigBuilder#replication() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MongodManager.java From jpa-unit with Apache License 2.0 | 5 votes |
private IMongodConfig buildMongodConfiguration(final HostAndPort hostAndPort, final boolean configureReplicaSet) throws IOException { final InetAddress address = InetAddress.getByName(hostAndPort.getHost()); // @formatter:off final MongodConfigBuilder builder = new MongodConfigBuilder() .version(Version.Main.PRODUCTION) .net(new Net(hostAndPort.getHost(), hostAndPort.getPort(), address instanceof Inet6Address)); // @formatter:on if (configureReplicaSet) { builder.replication(new Storage(null, "test001", 0)); } return builder.build(); }
Example 2
Source File: EmbeddedMongo.java From spring-data-examples with Apache License 2.0 | 5 votes |
/** * Create a default {@code mongod} config. * * @param version * @param port * @param cmdOptions * @param configServer * @param shardServer * @param replicaSet * @return */ private static IMongodConfig defaultMongodConfig(IFeatureAwareVersion version, int port, IMongoCmdOptions cmdOptions, boolean configServer, boolean shardServer, String replicaSet) { try { MongodConfigBuilder builder = new MongodConfigBuilder() // .version(version) // .withLaunchArgument("--quiet") // .net(new Net(LOCALHOST, port, Network.localhostIsIPv6())) // .configServer(configServer).cmdOptions(cmdOptions); // if (StringUtils.hasText(replicaSet)) { builder = builder // .replication(new Storage(null, replicaSet, 0)); if (!configServer) { builder = builder.shardServer(shardServer); } else { builder = builder.shardServer(false); } } return builder.build(); } catch (IOException e) { throw new RuntimeException(e); } }