From 23c035da35bffbfd99091f1c349c10cf49906bfc Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Wed, 2 Oct 2013 10:36:37 +0200 Subject: [PATCH] Use simple class name as cluster name --- .../ChildSearchAndIndexingBenchmark.java | 39 ++++++++++++++----- .../search/child/ChildSearchBenchmark.java | 4 +- .../ChildSearchShortCircuitBenchmark.java | 5 ++- .../facet/HistogramFacetSearchBenchmark.java | 7 +++- .../QueryFilterFacetSearchBenchmark.java | 5 ++- .../facet/TermsFacetSearchBenchmark.java | 9 ++++- 6 files changed, 53 insertions(+), 16 deletions(-) diff --git a/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchAndIndexingBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchAndIndexingBenchmark.java index 460cc719f02..f1da371c28f 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchAndIndexingBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchAndIndexingBenchmark.java @@ -66,7 +66,10 @@ public class ChildSearchAndIndexingBenchmark { .put(SETTING_NUMBER_OF_REPLICAS, 0) .build(); - Node node1 = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "node1")).node(); + String clusterName = ChildSearchAndIndexingBenchmark.class.getSimpleName(); + Node node1 = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "node1")) + .clusterName(clusterName) + .node(); Client client = node1.client(); client.admin().cluster().prepareHealth(indexName).setWaitForGreenStatus().setTimeout("10s").execute().actionGet(); @@ -114,9 +117,16 @@ public class ChildSearchAndIndexingBenchmark { } client.admin().indices().prepareRefresh().execute().actionGet(); System.out.println("--> Number of docs in index: " + client.prepareCount().setQuery(matchAllQuery()).execute().actionGet().getCount()); - new Thread(new SearchThread(client)).start(); - new Thread(new IndexThread(client)).start(); - Thread.sleep(Long.MAX_VALUE); + + SearchThread searchThread = new SearchThread(client); + new Thread(searchThread).start(); + IndexThread indexThread = new IndexThread(client); + new Thread(indexThread).start(); + + System.in.read(); + + indexThread.stop(); + searchThread.stop(); client.close(); node1.close(); } @@ -132,6 +142,7 @@ public class ChildSearchAndIndexingBenchmark { static class IndexThread implements Runnable { private final Client client; + private volatile boolean run = true; IndexThread(Client client) { this.client = client; @@ -139,8 +150,8 @@ public class ChildSearchAndIndexingBenchmark { @Override public void run() { - while (true) { - for (int i = 1; i < COUNT; i++) { + while (run) { + for (int i = 1; run && i < COUNT; i++) { try { client.prepareIndex(indexName, "parent", Integer.toString(i)) .setSource(parentSource(Integer.toString(i), "test" + i)).execute().actionGet(); @@ -163,11 +174,16 @@ public class ChildSearchAndIndexingBenchmark { } } + public void stop() { + run = false; + } + } static class SearchThread implements Runnable { private final Client client; + private volatile boolean run = true; SearchThread(Client client) { this.client = client; @@ -175,7 +191,7 @@ public class ChildSearchAndIndexingBenchmark { @Override public void run() { - while (true) { + while (run) { try { long totalQueryTime = 0; for (int j = 0; j < QUERY_COUNT; j++) { @@ -191,7 +207,7 @@ public class ChildSearchAndIndexingBenchmark { System.err.println("Search Failures " + Arrays.toString(searchResponse.getShardFailures())); } if (searchResponse.getHits().totalHits() != COUNT) { - System.err.println("--> mismatch on hits [" + j + "], got [" + searchResponse.getHits().totalHits() + "], expected [" + COUNT + "]"); +// System.err.println("--> mismatch on hits [" + j + "], got [" + searchResponse.getHits().totalHits() + "], expected [" + COUNT + "]"); } totalQueryTime += searchResponse.getTookInMillis(); } @@ -212,7 +228,7 @@ public class ChildSearchAndIndexingBenchmark { } long expected = (COUNT / BATCH) * BATCH; if (searchResponse.getHits().totalHits() != expected) { - System.err.println("--> mismatch on hits [" + j + "], got [" + searchResponse.getHits().totalHits() + "], expected [" + expected + "]"); +// System.err.println("--> mismatch on hits [" + j + "], got [" + searchResponse.getHits().totalHits() + "], expected [" + expected + "]"); } totalQueryTime += searchResponse.getTookInMillis(); } @@ -228,6 +244,11 @@ public class ChildSearchAndIndexingBenchmark { } } } + + public void stop() { + run = false; + } + } } diff --git a/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchBenchmark.java index 94c67e42550..8b8436e5955 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchBenchmark.java @@ -59,7 +59,9 @@ public class ChildSearchBenchmark { .put(SETTING_NUMBER_OF_REPLICAS, 0) .build(); - Node node1 = nodeBuilder().clusterName("classic").settings(settingsBuilder().put(settings).put("name", "node1")).node(); + String clusterName = ChildSearchBenchmark.class.getSimpleName(); + Node node1 = nodeBuilder().clusterName(clusterName) + .settings(settingsBuilder().put(settings).put("name", "node1")).node(); Client client = node1.client(); long COUNT = SizeValue.parseSizeValue("10m").singles(); diff --git a/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchShortCircuitBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchShortCircuitBenchmark.java index 770b21d182c..fd3be14a76a 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchShortCircuitBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/child/ChildSearchShortCircuitBenchmark.java @@ -58,7 +58,10 @@ public class ChildSearchShortCircuitBenchmark { .put(SETTING_NUMBER_OF_REPLICAS, 0) .build(); - Node node1 = nodeBuilder().clusterName("bench1").settings(settingsBuilder().put(settings).put("name", "node1")).node(); + String clusterName = ChildSearchShortCircuitBenchmark.class.getSimpleName(); + Node node1 = nodeBuilder().clusterName(clusterName) + .settings(settingsBuilder().put(settings).put("name", "node1")) + .node(); Client client = node1.client(); long PARENT_COUNT = SizeValue.parseSizeValue("10M").singles(); diff --git a/src/test/java/org/elasticsearch/benchmark/search/facet/HistogramFacetSearchBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/facet/HistogramFacetSearchBenchmark.java index 3822a8673c8..7f1bbcaee2a 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/facet/HistogramFacetSearchBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/facet/HistogramFacetSearchBenchmark.java @@ -56,9 +56,12 @@ public class HistogramFacetSearchBenchmark { .put(SETTING_NUMBER_OF_REPLICAS, 1) .build(); - Node node1 = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "node1")).node(); + String clusterName = HistogramFacetSearchBenchmark.class.getSimpleName(); + Node node1 = nodeBuilder() + .clusterName(clusterName) + .settings(settingsBuilder().put(settings).put("name", "node1")).node(); - //Node clientNode = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "client")).client(true).node(); + //Node clientNode = nodeBuilder().clusterName(clusterName).settings(settingsBuilder().put(settings).put("name", "client")).client(true).node(); Client client = node1.client(); diff --git a/src/test/java/org/elasticsearch/benchmark/search/facet/QueryFilterFacetSearchBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/facet/QueryFilterFacetSearchBenchmark.java index 579fe6dbb9e..b7d960028d1 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/facet/QueryFilterFacetSearchBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/facet/QueryFilterFacetSearchBenchmark.java @@ -61,7 +61,10 @@ public class QueryFilterFacetSearchBenchmark { .put(SETTING_NUMBER_OF_REPLICAS, 0) .build(); - Node node1 = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "node1")).node(); + String clusterName = QueryFilterFacetSearchBenchmark.class.getSimpleName(); + Node node1 = nodeBuilder() + .clusterName(clusterName) + .settings(settingsBuilder().put(settings).put("name", "node1")).node(); client = node1.client(); long[] lValues = new long[NUMBER_OF_TERMS]; diff --git a/src/test/java/org/elasticsearch/benchmark/search/facet/TermsFacetSearchBenchmark.java b/src/test/java/org/elasticsearch/benchmark/search/facet/TermsFacetSearchBenchmark.java index e2e70d5b1ca..dc8c4cea686 100644 --- a/src/test/java/org/elasticsearch/benchmark/search/facet/TermsFacetSearchBenchmark.java +++ b/src/test/java/org/elasticsearch/benchmark/search/facet/TermsFacetSearchBenchmark.java @@ -74,12 +74,17 @@ public class TermsFacetSearchBenchmark { .put(SETTING_NUMBER_OF_REPLICAS, 0) .build(); + String clusterName = TermsFacetSearchBenchmark.class.getSimpleName(); Node[] nodes = new Node[1]; for (int i = 0; i < nodes.length; i++) { - nodes[i] = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "node" + i)).node(); + nodes[i] = nodeBuilder().clusterName(clusterName) + .settings(settingsBuilder().put(settings).put("name", "node" + i)) + .node(); } - Node clientNode = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "client")).client(true).node(); + Node clientNode = nodeBuilder() + .clusterName(clusterName) + .settings(settingsBuilder().put(settings).put("name", "client")).client(true).node(); client = clientNode.client();