All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.alexcojocaru.mojo.elasticsearch.v2.step.WaitToStartClusterStep Maven / Gradle / Ivy

Go to download

A Maven plugin to run a single node Elasticsearch cluster during the integration test phase of a build

There is a newer version: 6.28
Show newest version
package com.github.alexcojocaru.mojo.elasticsearch.v2.step;

import com.github.alexcojocaru.mojo.elasticsearch.v2.ClusterConfiguration;
import com.github.alexcojocaru.mojo.elasticsearch.v2.client.ElasticsearchClient;
import com.github.alexcojocaru.mojo.elasticsearch.v2.client.Monitor;

/**
 * Wait until the ES cluster is up and running.
 * 
 * @author Alex Cojocaru
 */
public class WaitToStartClusterStep
        implements ClusterStep
{
    @Override
    public void execute(ClusterConfiguration config)
    {
    	// the instances have already started;
    	// waiting just 10 seconds for them to form the cluster
        int timeout = 10;

        ElasticsearchClient client = new ElasticsearchClient.Builder()
                .withInstanceConfiguration(config.getInstanceConfigurationList().get(0))
                .withHostname("localhost")
                .build();

        Monitor monitor = new Monitor(client, config.getLog());
        monitor.waitToStartCluster(
                config.getClusterName(),
                config.getInstanceConfigurationList().size(),
                timeout);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy