use of com.github.alexcojocaru.mojo.elasticsearch.v2.InstanceConfiguration in project elasticsearch-maven-plugin by alexcojocaru.
the class RemoveExistingDataStepTest method testRemoveExistingData.
@Test
public void testRemoveExistingData() {
InstanceConfiguration instanceConfig = mock(InstanceConfiguration.class);
when(instanceConfig.getBaseDir()).thenReturn(".");
ClusterConfiguration clusterConfig = new ClusterConfiguration.Builder().withKeepExistingData(false).build();
when(instanceConfig.getClusterConfiguration()).thenReturn(clusterConfig);
new RemoveExistingDataStep().execute(instanceConfig);
// a bit convoluted, but this check that getBaseDir()
// was called in order to build the data and logs directories.
Mockito.verify(instanceConfig).getBaseDir();
}
use of com.github.alexcojocaru.mojo.elasticsearch.v2.InstanceConfiguration in project elasticsearch-maven-plugin by alexcojocaru.
the class RemoveExistingDataStepTest method testKeepExistingData.
@Test
public void testKeepExistingData() {
InstanceConfiguration instanceConfig = mock(InstanceConfiguration.class);
ClusterConfiguration clusterConfig = new ClusterConfiguration.Builder().withKeepExistingData(true).build();
when(instanceConfig.getClusterConfiguration()).thenReturn(clusterConfig);
new RemoveExistingDataStep().execute(instanceConfig);
// a bit convoluted, but this check that getBaseDir()
// was never called in order to build the data and logs directories.
Mockito.verify(instanceConfig, never()).getBaseDir();
}
use of com.github.alexcojocaru.mojo.elasticsearch.v2.InstanceConfiguration in project elasticsearch-maven-plugin by alexcojocaru.
the class ResolveElasticsearchStep method execute.
@Override
public void execute(InstanceConfiguration config) {
File unpackDirectory = null;
try {
File artifact = new ElasticsearchArtifactResolver(config.getClusterConfiguration()).resolve();
unpackDirectory = unpackToElasticsearchDirectory(artifact, config);
setupElasticsearchConf(config);
} catch (ArtifactException | IOException e) {
throw new RuntimeException(e);
} finally {
cleanUp(unpackDirectory, config.getClusterConfiguration());
}
}
use of com.github.alexcojocaru.mojo.elasticsearch.v2.InstanceConfiguration in project elasticsearch-maven-plugin by alexcojocaru.
the class InstallPluginsStep method execute.
@Override
public void execute(InstanceConfiguration config) {
if (config.getClusterConfiguration().getPlugins().size() > 0) {
if (VersionUtil.isEqualOrGreater_6_4_0(config.getClusterConfiguration().getVersion())) {
FilesystemUtil.setScriptPermission(config, "elasticsearch-cli");
}
FilesystemUtil.setScriptPermission(config, "elasticsearch-plugin");
}
Log log = config.getClusterConfiguration().getLog();
for (PluginConfiguration plugin : config.getClusterConfiguration().getPlugins()) {
log.info(String.format("Installing plugin '%s' with options '%s'", plugin.getUri(), plugin.getEsJavaOpts()));
Map<String, String> environment = new HashMap<>(config.getEnvironmentVariables());
if (StringUtils.isNotBlank(plugin.getEsJavaOpts())) {
environment.put("ES_JAVA_OPTS", plugin.getEsJavaOpts());
}
CommandLine cmd = ProcessUtil.buildCommandLine("bin/elasticsearch-plugin").addArgument("install").addArgument("--batch").addArgument(plugin.getUri());
ProcessUtil.executeScript(config, cmd, environment);
}
}
use of com.github.alexcojocaru.mojo.elasticsearch.v2.InstanceConfiguration in project elasticsearch-maven-plugin by alexcojocaru.
the class RunForkedMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping plugin execution");
return;
}
ClusterConfiguration clusterConfig = buildClusterConfiguration();
new PreStartClusterSequence().execute(clusterConfig);
for (InstanceConfiguration config : clusterConfig.getInstanceConfigurationList()) {
getLog().info(String.format("Using Elasticsearch [%d] configuration: %s", config.getId(), config));
try {
ForkedInstance instance = new ForkedInstance(config);
instance.configureInstance();
Thread thread = new Thread(instance);
thread.start();
new PostStartInstanceSequence().execute(config);
} catch (Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
new PostStartClusterSequence().execute(clusterConfig);
}
Aggregations