Search in sources :

Example 16 with ClusterConfiguration

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

the class ValidateBaseDirectoryStep method execute.

@Override
public void execute(ClusterConfiguration config) {
    String baseDir = config.getInstanceConfigurationList().get(0).getBaseDir();
    try {
        Validate.notBlank(baseDir);
        // this should catch erroneous paths
        new File(baseDir).getCanonicalPath();
    } catch (Exception e) {
        throw new ElasticsearchSetupException(String.format("The value of the 'baseDir' parameter ('%1$s') is not a valid file path.", baseDir));
    }
}
Also used : ElasticsearchSetupException(com.github.alexcojocaru.mojo.elasticsearch.v2.ElasticsearchSetupException) File(java.io.File) ElasticsearchSetupException(com.github.alexcojocaru.mojo.elasticsearch.v2.ElasticsearchSetupException)

Example 17 with ClusterConfiguration

use of com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration 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);
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) PostStartClusterSequence(com.github.alexcojocaru.mojo.elasticsearch.v2.step.PostStartClusterSequence) PreStartClusterSequence(com.github.alexcojocaru.mojo.elasticsearch.v2.step.PreStartClusterSequence) PostStartInstanceSequence(com.github.alexcojocaru.mojo.elasticsearch.v2.step.PostStartInstanceSequence) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

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