enhance bulk stress test

This commit is contained in:
kimchy 2010-11-02 14:01:22 +02:00
parent 3fe2851dae
commit 8e2e85f460
2 changed files with 9 additions and 4 deletions

View File

@ -25,6 +25,7 @@ import org.elasticsearch.client.Requests;
import org.elasticsearch.client.action.bulk.BulkRequestBuilder; import org.elasticsearch.client.action.bulk.BulkRequestBuilder;
import org.elasticsearch.common.StopWatch; import org.elasticsearch.common.StopWatch;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.SizeValue;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
@ -50,7 +51,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("gateway.type", "local")
.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();
@ -67,11 +68,11 @@ public class SingleThreadBulkStress {
Thread.sleep(5000); Thread.sleep(5000);
StopWatch stopWatch = new StopWatch().start(); StopWatch stopWatch = new StopWatch().start();
int COUNT = 200000; long COUNT = SizeValue.parseSizeValue("5m").singles();
int BATCH = 100; int BATCH = 100;
System.out.println("Indexing [" + COUNT + "] ..."); System.out.println("Indexing [" + COUNT + "] ...");
int ITERS = COUNT / BATCH; long ITERS = COUNT / BATCH;
int i = 1; long i = 1;
int counter = 0; int counter = 0;
for (; i <= ITERS; i++) { for (; i <= ITERS; i++) {
BulkRequestBuilder request = client1.prepareBulk(); BulkRequestBuilder request = client1.prepareBulk();

View File

@ -123,6 +123,10 @@ public class SizeValue implements Serializable, Streamable {
return Strings.format1Decimals(value, suffix); return Strings.format1Decimals(value, suffix);
} }
public static SizeValue parseSizeValue(String sValue) throws ElasticSearchParseException {
return parseSizeValue(sValue, null);
}
public static SizeValue parseSizeValue(String sValue, SizeValue defaultValue) throws ElasticSearchParseException { public static SizeValue parseSizeValue(String sValue, SizeValue defaultValue) throws ElasticSearchParseException {
if (sValue == null) { if (sValue == null) {
return defaultValue; return defaultValue;