From d791ae613c9a3b33c880df8d051c7a2abdc76710 Mon Sep 17 00:00:00 2001 From: Jason Tedor <jason@tedor.me> Date: Thu, 10 Aug 2017 11:25:08 +0900 Subject: [PATCH] Elasticsearch 5: Change es.newdb to es.new_index This commit changes the name of a property, es.newdb, to es.new_index as this is more consistent with the terminology used in Elasticsearch. --- elasticsearch5/README.md | 2 +- .../yahoo/ycsb/db/elasticsearch5/ElasticsearchClient.java | 6 +++--- .../ycsb/db/elasticsearch5/ElasticsearchRestClient.java | 6 +++--- .../yahoo/ycsb/db/elasticsearch5/ElasticsearchClientIT.java | 2 +- .../ycsb/db/elasticsearch5/ElasticsearchRestClientIT.java | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/elasticsearch5/README.md b/elasticsearch5/README.md index 846f10f2..015d1511 100644 --- a/elasticsearch5/README.md +++ b/elasticsearch5/README.md @@ -59,7 +59,7 @@ The default setting for the Elasticsearch node that is created is as follows: es.index.key=es.ycsb es.number_of_shards=1 es.number_of_replicas=0 - es.newdb=false + es.new_index=false es.hosts.list=localhost:9300 ### Custom Configuration diff --git a/elasticsearch5/src/main/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchClient.java b/elasticsearch5/src/main/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchClient.java index 1d2bec93..d6a77bd3 100644 --- a/elasticsearch5/src/main/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchClient.java +++ b/elasticsearch5/src/main/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchClient.java @@ -80,7 +80,7 @@ public class ElasticsearchClient extends DB { final int numberOfShards = parseIntegerProperty(props, "es.number_of_shards", NUMBER_OF_SHARDS); final int numberOfReplicas = parseIntegerProperty(props, "es.number_of_replicas", NUMBER_OF_REPLICAS); - final Boolean newdb = Boolean.parseBoolean(props.getProperty("es.newdb", "false")); + final Boolean newIndex = Boolean.parseBoolean(props.getProperty("es.new_index", "false")); final Builder settings = Settings.builder().put("cluster.name", DEFAULT_CLUSTER_NAME); // if properties file contains elasticsearch user defined properties @@ -123,10 +123,10 @@ public class ElasticsearchClient extends DB { client.admin().indices() .exists(Requests.indicesExistsRequest(indexKey)).actionGet() .isExists(); - if (exists && newdb) { + if (exists && newIndex) { client.admin().indices().prepareDelete(indexKey).get(); } - if (!exists || newdb) { + if (!exists || newIndex) { client.admin().indices().create( new CreateIndexRequest(indexKey) .settings( diff --git a/elasticsearch5/src/main/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchRestClient.java b/elasticsearch5/src/main/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchRestClient.java index c6b83626..ebc8f66b 100644 --- a/elasticsearch5/src/main/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchRestClient.java +++ b/elasticsearch5/src/main/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchRestClient.java @@ -76,7 +76,7 @@ public class ElasticsearchRestClient extends DB { final int numberOfShards = parseIntegerProperty(props, "es.number_of_shards", NUMBER_OF_SHARDS); final int numberOfReplicas = parseIntegerProperty(props, "es.number_of_replicas", NUMBER_OF_REPLICAS); - final Boolean newdb = Boolean.parseBoolean(props.getProperty("es.newdb", "false")); + final Boolean newIndex = Boolean.parseBoolean(props.getProperty("es.new_index", "false")); final String[] nodeList = props.getProperty("es.hosts.list", DEFAULT_REMOTE_HOST).split(","); @@ -91,7 +91,7 @@ public class ElasticsearchRestClient extends DB { final Response existsResponse = performRequest(restClient, "HEAD", "/" + indexKey); final boolean exists = existsResponse.getStatusLine().getStatusCode() == 200; - if (exists && newdb) { + if (exists && newIndex) { final Response deleteResponse = performRequest(restClient, "DELETE", "/" + indexKey); final int statusCode = deleteResponse.getStatusLine().getStatusCode(); if (statusCode != 200) { @@ -99,7 +99,7 @@ public class ElasticsearchRestClient extends DB { } } - if (!exists || newdb) { + if (!exists || newIndex) { try (XContentBuilder builder = jsonBuilder()) { builder.startObject(); builder.startObject("settings"); diff --git a/elasticsearch5/src/test/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchClientIT.java b/elasticsearch5/src/test/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchClientIT.java index 1e7ac3f0..2f8eabe0 100644 --- a/elasticsearch5/src/test/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchClientIT.java +++ b/elasticsearch5/src/test/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchClientIT.java @@ -48,7 +48,7 @@ public class ElasticsearchClientIT { @Before public void setUp() throws DBException { final Properties props = new Properties(); - props.put("es.newdb", "true"); + props.put("es.new_index", "true"); props.put("es.setting.cluster.name", "test"); instance.setProperties(props); instance.init(); diff --git a/elasticsearch5/src/test/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchRestClientIT.java b/elasticsearch5/src/test/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchRestClientIT.java index 20aeb6a7..5b833c14 100644 --- a/elasticsearch5/src/test/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchRestClientIT.java +++ b/elasticsearch5/src/test/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchRestClientIT.java @@ -49,7 +49,7 @@ public class ElasticsearchRestClientIT { @Before public void setUp() throws DBException, IOException { final Properties props = new Properties(); - props.put("es.newdb", "true"); + props.put("es.new_index", "true"); instance.setProperties(props); instance.init(); for (int i = 0; i < 16; i++) { -- GitLab