From 93ea25fb4634f91147b4c49b5df2c2ad48177e00 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 8 Dec 2014 16:08:05 +0100 Subject: Improve stability of sonar-server-benchmarks Optimize Lucene FS so it does not evolve when estimating size --- .../src/main/java/org/sonar/server/es/BulkIndexer.java | 6 +----- .../sonar-server/src/main/java/org/sonar/server/es/EsClient.java | 9 +++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'server/sonar-server') diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java index b08af55a94e..a1af20bc681 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java @@ -149,11 +149,7 @@ public class BulkIndexer implements Startable { // optimize lucene segments and revert index settings // Optimization must be done before re-applying replicas: // http://www.elasticsearch.org/blog/performance-considerations-elasticsearch-indexing/ - // TODO do not use nativeClient, else request is not profiled - client.nativeClient().admin().indices().prepareOptimize(indexName) - .setMaxNumSegments(1) - .setWaitForMerge(true) - .get(); + client.prepareOptimize(indexName).get(); updateSettings(largeInitialSettings); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/EsClient.java b/server/sonar-server/src/main/java/org/sonar/server/es/EsClient.java index 2e737b8c4be..eb658126ed8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/EsClient.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/EsClient.java @@ -29,6 +29,7 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; import org.elasticsearch.action.admin.indices.flush.FlushRequestBuilder; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder; +import org.elasticsearch.action.admin.indices.optimize.OptimizeRequestBuilder; import org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder; import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequestBuilder; import org.elasticsearch.action.bulk.BulkRequestBuilder; @@ -185,6 +186,14 @@ public class EsClient implements Startable { return new ProxyIndexRequestBuilder(client, profiling).setIndex(index).setType(type); } + public OptimizeRequestBuilder prepareOptimize(String indexName) { + // TODO add proxy for profiling + return nativeClient().admin().indices().prepareOptimize(indexName) + .setMaxNumSegments(1) + .setWaitForMerge(true); + } + + public long getLastUpdatedAt(String indexName, String typeName) { SearchRequestBuilder request = prepareSearch(indexName) .setTypes(typeName) -- cgit v1.2.3