Search in sources :

Example 6 with ElasticsearchClient

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

the class BootstrapClusterStep method parseJson.

protected void parseJson(ElasticsearchClient client, Log log, Path path) {
    try {
        String json = new String(Files.readAllBytes(path));
        List<Map<String, Object>> commands = new ObjectMapper().readValue(json, new TypeReference<List<Map<String, Object>>>() {
        });
        commands.forEach(command -> {
            log.debug(String.format("Parsing command: %s", command));
            ElasticsearchCommand esCommand = parseMapCommand(command);
            executeInitCommand(client, log, esCommand);
        });
    } catch (IOException e) {
        throw new ElasticsearchSetupException("Cannot read the init json file", e);
    }
}
Also used : ElasticsearchCommand(com.github.alexcojocaru.mojo.elasticsearch.v2.client.ElasticsearchCommand) ElasticsearchSetupException(com.github.alexcojocaru.mojo.elasticsearch.v2.ElasticsearchSetupException) List(java.util.List) IOException(java.io.IOException) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 7 with ElasticsearchClient

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

the class BootstrapClusterStep method parseScript.

protected void parseScript(ElasticsearchClient client, Log log, Path path) {
    try (Stream<String> stream = Files.lines(path)) {
        stream.forEach(command -> {
            log.debug(String.format("Parsing command: %s", command));
            ElasticsearchCommand esCommand = parseStringCommand(command);
            if (esCommand.isSkip() == false) {
                executeInitCommand(client, log, esCommand);
            }
        });
    } catch (IOException e) {
        throw new ElasticsearchSetupException("Cannot read the init script file", e);
    }
}
Also used : ElasticsearchCommand(com.github.alexcojocaru.mojo.elasticsearch.v2.client.ElasticsearchCommand) ElasticsearchSetupException(com.github.alexcojocaru.mojo.elasticsearch.v2.ElasticsearchSetupException) IOException(java.io.IOException)

Aggregations

ElasticsearchSetupException (com.github.alexcojocaru.mojo.elasticsearch.v2.ElasticsearchSetupException)5 ElasticsearchClient (com.github.alexcojocaru.mojo.elasticsearch.v2.client.ElasticsearchClient)3 ElasticsearchCommand (com.github.alexcojocaru.mojo.elasticsearch.v2.client.ElasticsearchCommand)3 IOException (java.io.IOException)3 ElasticsearchClientException (com.github.alexcojocaru.mojo.elasticsearch.v2.client.ElasticsearchClientException)2 Monitor (com.github.alexcojocaru.mojo.elasticsearch.v2.client.Monitor)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 List (java.util.List)1 Map (java.util.Map)1