Search in sources :

Example 1 with ClusterConfiguration

use of com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration in project elasticsearch-maven-plugin by alexcojocaru.

the class BootstrapClusterStep method execute.

@Override
public void execute(ClusterConfiguration config) {
    if (StringUtils.isBlank(config.getPathInitScript())) {
        // nothing to do; return
        return;
    }
    String filePath = config.getPathInitScript();
    validateFile(filePath);
    // we'll run all commands against the first node in the cluster
    ElasticsearchClient client = new ElasticsearchClient.Builder().withInstanceConfiguration(config.getInstanceConfigurationList().get(0)).withHostname("localhost").build();
    Stream<String> stream = null;
    try {
        stream = Files.lines(Paths.get(filePath));
        stream.forEach(command -> executeInitCommand(client, config.getLog(), command));
    } catch (IOException e) {
        throw new ElasticsearchSetupException("Cannot read the init script file", e);
    } finally {
        if (stream != null) {
            stream.close();
        }
    }
}
Also used : ElasticsearchSetupException(com.github.alexcojocaru.mojo.elasticsearch.v2.ElasticsearchSetupException) IOException(java.io.IOException) ElasticsearchClient(com.github.alexcojocaru.mojo.elasticsearch.v2.client.ElasticsearchClient)

Example 2 with ClusterConfiguration

use of com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration in project elasticsearch-maven-plugin by alexcojocaru.

the class ValidateVersionStepTest method testCheckVersionWithIncorrectVersion.

/**
 * Test the version check with incorrect version
 */
@Test(expected = ElasticsearchSetupException.class)
public void testCheckVersionWithIncorrectVersion() {
    String version = "1.0.0";
    ClusterConfiguration config = buildConfig(version);
    new ValidateVersionStep().execute(config);
}
Also used : ClusterConfiguration(com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration) Test(org.junit.Test)

Example 3 with ClusterConfiguration

use of com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration in project elasticsearch-maven-plugin by alexcojocaru.

the class ValidateClusterNameStepTest method TestWithClusterNameContainingDot.

@Test
public void TestWithClusterNameContainingDot() {
    ClusterConfiguration clusterConfiguration = configBuilder.withClusterName("ONE.TWO.THREE").build();
    validateClusterNameStep.execute(clusterConfiguration);
}
Also used : ClusterConfiguration(com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration) Test(org.junit.Test)

Example 4 with ClusterConfiguration

use of com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration in project elasticsearch-maven-plugin by alexcojocaru.

the class ValidateClusterNameStepTest method TestWithClusterNameContainingQuote.

@Test(expected = ElasticsearchSetupException.class)
public void TestWithClusterNameContainingQuote() {
    ClusterConfiguration clusterConfiguration = configBuilder.withClusterName("ONE'TWO'THREE").build();
    validateClusterNameStep.execute(clusterConfiguration);
}
Also used : ClusterConfiguration(com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration) Test(org.junit.Test)

Example 5 with ClusterConfiguration

use of com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration in project elasticsearch-maven-plugin by alexcojocaru.

the class ValidateUniquePortsStepTest method testWithTwoInstancesWithUniquePorts.

/**
 * Test with 2 instances; all ports are unique.
 */
@Test
public void testWithTwoInstancesWithUniquePorts() {
    ClusterConfiguration config = buildConfig(2000, 2010, 2001, 2011);
    new ValidateUniquePortsStep().execute(config);
}
Also used : ClusterConfiguration(com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration) Test(org.junit.Test)

Aggregations

ClusterConfiguration (com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration)13 Test (org.junit.Test)12 ElasticsearchSetupException (com.github.alexcojocaru.mojo.elasticsearch.v2.ElasticsearchSetupException)2 InstanceConfiguration (com.github.alexcojocaru.mojo.elasticsearch.v2.InstanceConfiguration)2 ElasticsearchClient (com.github.alexcojocaru.mojo.elasticsearch.v2.client.ElasticsearchClient)2 Monitor (com.github.alexcojocaru.mojo.elasticsearch.v2.client.Monitor)1 PostStartClusterSequence (com.github.alexcojocaru.mojo.elasticsearch.v2.step.PostStartClusterSequence)1 PostStartInstanceSequence (com.github.alexcojocaru.mojo.elasticsearch.v2.step.PostStartInstanceSequence)1 PreStartClusterSequence (com.github.alexcojocaru.mojo.elasticsearch.v2.step.PreStartClusterSequence)1 File (java.io.File)1 IOException (java.io.IOException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1