while (p.nextToken() != XContentParser.Token.END_ARRAY) {
percentiles.add(p.doubleValue());
}
builder.setPercentiles(Doubles.toArray(percentiles));
} else {
throw new ElasticsearchParseException("Failed parsing array field [" + fieldName + "] field is not recognized");
}
break;
case START_OBJECT:
if ("clear_caches".equals(fieldName)) {
BenchmarkSettings.ClearCachesSettings clearCachesSettings = new BenchmarkSettings.ClearCachesSettings();
builder.setClearCachesSettings(clearCachesSettings);
parseClearCaches(p, clearCachesSettings);
} else {
throw new ElasticsearchParseException("Failed parsing object field [" + fieldName + "] field is not recognized");
}
break;
case FIELD_NAME:
fieldName = p.text();
break;
case VALUE_NUMBER:
if ("num_executor_nodes".equals(fieldName)) {
builder.setNumExecutorNodes(p.intValue());
} else if ("iterations".equals(fieldName)) {
builder.setIterations(p.intValue());
} else if ("concurrency".equals(fieldName)) {
builder.setConcurrency(p.intValue());
} else if ("multiplier".equals(fieldName)) {
builder.setMultiplier(p.intValue());
} else if ("num_slowest".equals(fieldName)) {
builder.setNumSlowest(p.intValue());
} else {
throw new ElasticsearchParseException("Failed parsing numeric field [" + fieldName + "] field is not recognized");
}
break;
case VALUE_BOOLEAN:
if ("warmup".equals(fieldName)) {
builder.setWarmup(p.booleanValue());
} else if ("clear_caches".equals(fieldName)) {
if (p.booleanValue()) {
throw new ElasticsearchParseException("Failed parsing field [" + fieldName + "] must specify which caches to clear");
} else {
builder.setAllowCacheClearing(false);
}
} else {
throw new ElasticsearchParseException("Failed parsing boolean field [" + fieldName + "] field is not recognized");
}
break;
case VALUE_STRING:
if ("name".equals(fieldName)) {
builder.setBenchmarkId(p.text());
} else {
throw new ElasticsearchParseException("Failed parsing string field [" + fieldName + "] field is not recognized");
}
break;
default:
throw new ElasticsearchParseException("Failed parsing " + token.name() + " field [" + fieldName + "] field is not recognized");
}
}
return builder.request();
}