de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion Java Examples

The following examples show how to use de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion. 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: EmbeddedMongo.java    From spring-data-examples with Apache License 2.0 6 votes vote down vote up
ReplSet(IFeatureAwareVersion serverVersion, String replicaSetName, boolean silent, Integer... serverPorts) {

			this.serverVersion = serverVersion;
			this.replicaSetName = replicaSetName;
			this.serverPorts = defaultPortsIfRequired(serverPorts);
			this.configServerPorts = defaultPortsIfRequired(null);
			this.configServerReplicaSetName = DEFAULT_CONFIG_SERVER_REPLICA_SET_NAME;
			this.mongosPort = randomOrDefaultServerPort();

			if (silent) {
				outputFunction = it -> new ProcessOutput(Processors.silent(),
						Processors.namedConsole("[ " + it.commandName() + " error]"), Processors.console());
			} else {
				outputFunction = it -> ProcessOutput.getDefaultInstance(it.commandName());
			}
		}
 
Example #2
Source File: EmbeddedMongo.java    From spring-data-examples with Apache License 2.0 6 votes vote down vote up
/**
 * Create a default {@code mongos} config.
 *
 * @param version
 * @param port
 * @param cmdOptions
 * @param configServerReplicaSet
 * @param configServerPort
 * @return
 */
private static IMongosConfig defaultMongosConfig(IFeatureAwareVersion version, int port, IMongoCmdOptions cmdOptions,
		String configServerReplicaSet, int configServerPort) {

	try {

		MongosConfigBuilder builder = new MongosConfigBuilder() //
				.version(version) //
				.withLaunchArgument("--quiet", null) //
				.net(new Net(LOCALHOST, port, Network.localhostIsIPv6())) //
				.cmdOptions(cmdOptions);

		if (StringUtils.hasText(configServerReplicaSet)) {
			builder = builder.replicaSet(configServerReplicaSet) //
					.configDB(LOCALHOST + ":" + configServerPort);
		}

		return builder.build();
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
Example #3
Source File: MongoClientTestConfiguration.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
private IMongodConfig newMongodConfig(final IFeatureAwareVersion version) throws IOException {
  MongoCmdOptionsBuilder builder = new MongoCmdOptionsBuilder().useSmallFiles(false).useNoPrealloc(false);
  return new MongodConfigBuilder().version(version)
                                  .cmdOptions(builder.build())
                                  .net(new Net(LOCALHOST, Network.getFreeServerPort(),
                                               Network.localhostIsIPv6())).build();
}
 
Example #4
Source File: ReactiveMongoClientTestConfiguration.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
private IMongodConfig newMongodConfig(final IFeatureAwareVersion version) throws IOException {
  MongoCmdOptionsBuilder builder = new MongoCmdOptionsBuilder().useSmallFiles(false).useNoPrealloc(false);
  return new MongodConfigBuilder().version(version)
                                  .cmdOptions(builder.build())
                                  .net(new Net(LOCALHOST, Network.getFreeServerPort(),
                                                                Network.localhostIsIPv6())).build();
}
 
Example #5
Source File: NonReactiveMongoClientTestConfiguration.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
private IMongodConfig newMongodConfig(final IFeatureAwareVersion version) throws IOException {
  MongoCmdOptionsBuilder builder = new MongoCmdOptionsBuilder().useSmallFiles(false).useNoPrealloc(false);
  return new MongodConfigBuilder().version(version)
                                  .cmdOptions(builder.build())
                                  .net(new Net(LOCALHOST, Network.getFreeServerPort(),
                                               Network.localhostIsIPv6())).build();
}
 
Example #6
Source File: Mongo42xPaths.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
private String getBitSize(Distribution distribution) {
  String sbitSize;
  switch (distribution.getBitsize()) {
    case B32:
      if (distribution.getVersion() instanceof IFeatureAwareVersion) {
        IFeatureAwareVersion featuredVersion = (IFeatureAwareVersion) distribution.getVersion();
        if (featuredVersion.enabled(Feature.ONLY_64BIT)) {
          throw new IllegalArgumentException("this version does not support 32Bit: "+distribution);
        }
      }

      switch (distribution.getPlatform()) {
        case Linux:
          sbitSize = "i686";
          break;
        case Windows:
        case OS_X:
          sbitSize = "i386";
          break;
        default:
          throw new IllegalArgumentException("Platform " + distribution.getPlatform() + " not supported yet on 32Bit Platform");
      }
      break;
    case B64:
      sbitSize = "x86_64";
      break;
    default:
      throw new IllegalArgumentException("Unknown BitSize " + distribution.getBitsize());
  }
  return sbitSize;
}
 
Example #7
Source File: EmbeddedMongo.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
	}
}
 
Example #8
Source File: SingleMongoDBResource.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public SingleMongoDBResource(IFeatureAwareVersion version) {
  super(version);
}
 
Example #9
Source File: AbstractMongoDBResource.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
protected AbstractMongoDBResource(IFeatureAwareVersion version) {
  this.version = version;
}
 
Example #10
Source File: AbstractMongoDBResource.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public IFeatureAwareVersion getVersion() {
  return version;
}
 
Example #11
Source File: Mongo42xPaths.java    From mongodb-aggregate-query-support with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("SameParameterValue")
private static boolean isFeatureEnabled(Distribution distribution, Feature feature) {
  return (distribution.getVersion() instanceof IFeatureAwareVersion
          &&  ((IFeatureAwareVersion) distribution.getVersion()).enabled(feature));
}
 
Example #12
Source File: EmbeddedMongoFactory.java    From rya with Apache License 2.0 4 votes vote down vote up
public static EmbeddedMongoFactory with(final IFeatureAwareVersion version) throws IOException {
    return new EmbeddedMongoFactory(version);
}
 
Example #13
Source File: EmbeddedMongoFactory.java    From rya with Apache License 2.0 4 votes vote down vote up
private IMongodConfig newMongodConfig(final IFeatureAwareVersion version) throws UnknownHostException, IOException {
    final Net net = new Net(setPortToDefaultOrRandomOpen(), false);
    return new MongodConfigBuilder().version(version).net(net).build();
}
 
Example #14
Source File: EmbeddedMongoFactory.java    From rya with Apache License 2.0 2 votes vote down vote up
/**
 * Create the testing utility using the specified version of MongoDB.
 *
 * @param version
 *            version of MongoDB.
 */
private EmbeddedMongoFactory(final IFeatureAwareVersion version) throws IOException {
    final MongodStarter runtime = MongodStarter.getInstance(new RuntimeConfigBuilder().defaultsWithLogger(Command.MongoD, logger).build());
    mongodExecutable = runtime.prepare(newMongodConfig(version));
    mongodProcess = mongodExecutable.start();
}
 
Example #15
Source File: EmbeddedMongo.java    From spring-data-examples with Apache License 2.0 2 votes vote down vote up
/**
 * Configure the MongoDB {@link IFeatureAwareVersion version}.
 *
 * @param version
 * @return
 */
public Builder withVersion(IFeatureAwareVersion version) {

	this.version = version;
	return this;
}