Use simple class name as cluster name

This commit is contained in:
Martijn van Groningen 2013-10-02 10:36:37 +02:00
parent b923c138b8
commit 23c035da35
6 changed files with 53 additions and 16 deletions

View File

@ -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;
}
}
}

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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];

View File

@ -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();