add count at the end of the stress test

This commit is contained in:
kimchy 2010-09-15 23:51:25 +02:00
parent 5b9dc45b7f
commit 0a6600818a
2 changed files with 13 additions and 1 deletions

View File

@ -36,6 +36,7 @@ import static org.elasticsearch.client.Requests.*;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*; import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
import static org.elasticsearch.common.settings.ImmutableSettings.*; import static org.elasticsearch.common.settings.ImmutableSettings.*;
import static org.elasticsearch.common.xcontent.XContentFactory.*; import static org.elasticsearch.common.xcontent.XContentFactory.*;
import static org.elasticsearch.index.query.xcontent.QueryBuilders.*;
import static org.elasticsearch.node.NodeBuilder.*; import static org.elasticsearch.node.NodeBuilder.*;
/** /**
@ -49,6 +50,7 @@ public class SingleThreadBulkStress {
Settings settings = settingsBuilder() Settings settings = settingsBuilder()
.put("cluster.routing.schedule", 200, TimeUnit.MILLISECONDS) .put("cluster.routing.schedule", 200, TimeUnit.MILLISECONDS)
.put("index.engine.robin.refreshInterval", "-1") .put("index.engine.robin.refreshInterval", "-1")
.put("gateway.type", "none")
.put(SETTING_NUMBER_OF_SHARDS, 2) .put(SETTING_NUMBER_OF_SHARDS, 2)
.put(SETTING_NUMBER_OF_REPLICAS, 1) .put(SETTING_NUMBER_OF_REPLICAS, 1)
.build(); .build();
@ -70,10 +72,12 @@ public class SingleThreadBulkStress {
System.out.println("Indexing [" + COUNT + "] ..."); System.out.println("Indexing [" + COUNT + "] ...");
int ITERS = COUNT / BATCH; int ITERS = COUNT / BATCH;
int i = 1; int i = 1;
int counter = 0;
for (; i <= ITERS; i++) { for (; i <= ITERS; i++) {
BulkRequestBuilder request = client1.prepareBulk(); BulkRequestBuilder request = client1.prepareBulk();
for (int j = 0; j < BATCH; j++) { for (int j = 0; j < BATCH; j++) {
request.add(Requests.indexRequest("test").type("type1").id(Integer.toString(i)).source(source(Integer.toString(i), "test" + i))); counter++;
request.add(Requests.indexRequest("test").type("type1").id(Integer.toString(counter)).source(source(Integer.toString(counter), "test" + counter)));
} }
BulkResponse response = request.execute().actionGet(); BulkResponse response = request.execute().actionGet();
if (response.hasFailures()) { if (response.hasFailures()) {
@ -86,6 +90,9 @@ public class SingleThreadBulkStress {
} }
System.out.println("Indexing took " + stopWatch.totalTime() + ", TPS " + (((double) COUNT) / stopWatch.totalTime().secondsFrac())); System.out.println("Indexing took " + stopWatch.totalTime() + ", TPS " + (((double) COUNT) / stopWatch.totalTime().secondsFrac()));
client.client().admin().indices().prepareRefresh().execute().actionGet();
System.out.println("Count: " + client.client().prepareCount().setQuery(matchAllQuery()).execute().actionGet().count());
client.close(); client.close();
node1.close(); node1.close();

View File

@ -33,6 +33,7 @@ import static org.elasticsearch.client.Requests.*;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*; import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
import static org.elasticsearch.common.settings.ImmutableSettings.*; import static org.elasticsearch.common.settings.ImmutableSettings.*;
import static org.elasticsearch.common.xcontent.XContentFactory.*; import static org.elasticsearch.common.xcontent.XContentFactory.*;
import static org.elasticsearch.index.query.xcontent.QueryBuilders.*;
import static org.elasticsearch.node.NodeBuilder.*; import static org.elasticsearch.node.NodeBuilder.*;
/** /**
@ -46,6 +47,7 @@ public class SingleThreadIndexingStress {
Settings settings = settingsBuilder() Settings settings = settingsBuilder()
.put("cluster.routing.schedule", 200, TimeUnit.MILLISECONDS) .put("cluster.routing.schedule", 200, TimeUnit.MILLISECONDS)
.put("index.engine.robin.refreshInterval", "-1") .put("index.engine.robin.refreshInterval", "-1")
.put("gateway.type", "none")
.put(SETTING_NUMBER_OF_SHARDS, 2) .put(SETTING_NUMBER_OF_SHARDS, 2)
.put(SETTING_NUMBER_OF_REPLICAS, 1) .put(SETTING_NUMBER_OF_REPLICAS, 1)
.build(); .build();
@ -75,6 +77,9 @@ public class SingleThreadIndexingStress {
} }
System.out.println("Indexing took " + stopWatch.totalTime() + ", TPS " + (((double) COUNT) / stopWatch.totalTime().secondsFrac())); System.out.println("Indexing took " + stopWatch.totalTime() + ", TPS " + (((double) COUNT) / stopWatch.totalTime().secondsFrac()));
client.client().admin().indices().prepareRefresh().execute().actionGet();
System.out.println("Count: " + client.client().prepareCount().setQuery(matchAllQuery()).execute().actionGet().count());
client.close(); client.close();
node1.close(); node1.close();