Skip to content
Snippets Groups Projects
Commit 18fb4bd8 authored by Jeffrey Phillips Freeman's avatar Jeffrey Phillips Freeman :boom:
Browse files

Added syncDelay support.

parent 01f76197
No related branches found
No related tags found
No related merge requests found
...@@ -71,6 +71,9 @@ Usage ...@@ -71,6 +71,9 @@ Usage
<executableNaming>user</executableNaming> <executableNaming>user</executableNaming>
<!-- optional (user|uuid), sets the executable naming style, default is uuid --> <!-- optional (user|uuid), sets the executable naming style, default is uuid -->
<syncDelay>0</syncDelay>
<!-- optional, Sets the sync delay, 0 prevents all writing to disk, default lets MongoDB automatically determine value -->
<skip>false</skip> <skip>false</skip>
<!-- optional, skips this plugin entirely, use on the command line like -Dembedmongo.skip --> <!-- optional, skips this plugin entirely, use on the command line like -Dembedmongo.skip -->
......
...@@ -23,6 +23,7 @@ import de.flapdoodle.embed.mongo.MongodExecutable; ...@@ -23,6 +23,7 @@ import de.flapdoodle.embed.mongo.MongodExecutable;
import de.flapdoodle.embed.mongo.MongodProcess; import de.flapdoodle.embed.mongo.MongodProcess;
import de.flapdoodle.embed.mongo.MongodStarter; import de.flapdoodle.embed.mongo.MongodStarter;
import de.flapdoodle.embed.mongo.config.*; import de.flapdoodle.embed.mongo.config.*;
import de.flapdoodle.embed.mongo.config.processlistener.ProcessListenerBuilder;
import de.flapdoodle.embed.mongo.distribution.Feature; import de.flapdoodle.embed.mongo.distribution.Feature;
import de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion; import de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion;
import de.flapdoodle.embed.mongo.distribution.Version; import de.flapdoodle.embed.mongo.distribution.Version;
...@@ -226,20 +227,20 @@ public class StartMongoMojo extends AbstractMojo { ...@@ -226,20 +227,20 @@ public class StartMongoMojo extends AbstractMojo {
private String artifactDirectory; private String artifactDirectory;
/** /**
* The maven project. * Specifies the sync delay for MongoDB, 0 never syncs to disk, no value indicates default.
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@Parameter(property = "project", readonly = true) @Parameter(property = "mongodb.syncDelay")
private MavenProject project; private Integer syncDelay;
/** /**
* A list of the MongoDB features enabled. * The maven project.
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@Parameter @Parameter(property = "project", readonly = true)
private String[] features; private MavenProject project;
/** /**
* If true the plugin does nothing at all, allows you to skip from the command line. * If true the plugin does nothing at all, allows you to skip from the command line.
...@@ -249,6 +250,14 @@ public class StartMongoMojo extends AbstractMojo { ...@@ -249,6 +250,14 @@ public class StartMongoMojo extends AbstractMojo {
@Parameter(property = "mongodb.skip", defaultValue = "false") @Parameter(property = "mongodb.skip", defaultValue = "false")
private boolean skip; private boolean skip;
/**
* A list of the MongoDB features enabled.
*
* @since 1.0.0
*/
@Parameter
private String[] features;
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void execute() throws MojoExecutionException, MojoFailureException { public void execute() throws MojoExecutionException, MojoFailureException {
...@@ -291,11 +300,25 @@ public class StartMongoMojo extends AbstractMojo { ...@@ -291,11 +300,25 @@ public class StartMongoMojo extends AbstractMojo {
} }
savePortToProjectProperties(); savePortToProjectProperties();
final IMongodConfig config = new MongodConfigBuilder() MongodConfigBuilder configBuilder = new MongodConfigBuilder()
.version(getVersion()) .version(getVersion())
.net(new Net(bindIp, port, Network.localhostIsIPv6())) .net(new Net(bindIp, port, Network.localhostIsIPv6()))
.replication(new Storage(getDataDirectory(), replSet, oplogSize)) .replication(new Storage(getDataDirectory(), replSet, oplogSize));
.build();
if(this.syncDelay == null) {
configBuilder = configBuilder
.cmdOptions(new MongoCmdOptionsBuilder()
.defaultSyncDelay()
.build());
}
else if(this.syncDelay > 0) {
configBuilder = configBuilder
.cmdOptions(new MongoCmdOptionsBuilder()
.syncDelay(this.syncDelay)
.build());
}
final IMongodConfig config = configBuilder.build();
executable = MongodStarter.getInstance(runtimeConfig).prepare(config); executable = MongodStarter.getInstance(runtimeConfig).prepare(config);
} catch (final UnknownHostException e) { } catch (final UnknownHostException e) {
...@@ -433,7 +456,10 @@ public class StartMongoMojo extends AbstractMojo { ...@@ -433,7 +456,10 @@ public class StartMongoMojo extends AbstractMojo {
}; };
} }
return Versions.withFeatures(determinedVersion, (featuresSet.isEmpty() ? null : (Feature[]) featuresSet.toArray())); if(featuresSet.isEmpty())
return Versions.withFeatures(determinedVersion);
else
return Versions.withFeatures(determinedVersion, (Feature[]) featuresSet.toArray());
} }
private String getDataDirectory() { private String getDataDirectory() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment