]> source.dussan.org Git - sonarqube.git/commitdiff
Refactor ES proxy requests
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Sat, 13 Dec 2014 10:29:39 +0000 (11:29 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Sat, 13 Dec 2014 10:29:49 +0000 (11:29 +0100)
86 files changed:
server/sonar-server/src/main/java/org/sonar/server/es/EsClient.java
server/sonar-server/src/main/java/org/sonar/server/es/IndexCreator.java
server/sonar-server/src/main/java/org/sonar/server/es/IndexDefinitionHash.java
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyBulkRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyClusterHealthRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyClusterStateRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyClusterStatsRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyCountRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyCreateIndexRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyDeleteByQueryRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyDeleteRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyFlushRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyGetRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyIndexRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyIndicesExistsRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyIndicesStatsRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyMultiGetRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyNodesStatsRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyPutMappingRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyRefreshRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxySearchRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/ProxySearchScrollRequestBuilder.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/request/package-info.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java
server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyBulkRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyClusterHealthRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyClusterStateRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyClusterStatsRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyCountRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyCreateIndexRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyDeleteByQueryRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyDeleteRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyFlushRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyGetRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyIndexRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyIndicesExistsRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyIndicesStatsRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyNodesStatsRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyPutMappingRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyRefreshRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxySearchRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilder.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/request/package-info.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/es/EsClientTest.java
server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java
server/sonar-server/src/test/java/org/sonar/server/es/FakeIndexDefinition.java
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyBulkRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyClusterHealthRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyClusterStateRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyClusterStatsRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyCountRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyCreateIndexRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyDeleteByQueryRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyDeleteRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyFlushRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyGetRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyIndexRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyIndicesExistsRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyIndicesStatsRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyMultiGetRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyNodesStatsRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyPutMappingRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyRefreshRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxySearchRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxySearchScrollRequestBuilderTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyBulkRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterHealthRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStateRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStatsRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCountRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCreateIndexRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyDeleteByQueryRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyDeleteRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyFlushRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyGetRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndexRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesExistsRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesStatsRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyNodesStatsRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyPutMappingRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyRefreshRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchRequestBuilderTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilderTest.java [deleted file]

index eb658126ed88e7729e197a107d4e6cd9a591face..1af8a7b0f3767da8a57e5a48d326a7dc7b349469 100644 (file)
@@ -50,25 +50,25 @@ import org.picocontainer.Startable;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.server.search.ClusterHealth;
 import org.sonar.server.search.SearchClient;
-import org.sonar.server.search.request.ProxyBulkRequestBuilder;
-import org.sonar.server.search.request.ProxyClusterHealthRequestBuilder;
-import org.sonar.server.search.request.ProxyClusterStateRequestBuilder;
-import org.sonar.server.search.request.ProxyClusterStatsRequestBuilder;
-import org.sonar.server.search.request.ProxyCountRequestBuilder;
-import org.sonar.server.search.request.ProxyCreateIndexRequestBuilder;
-import org.sonar.server.search.request.ProxyDeleteByQueryRequestBuilder;
-import org.sonar.server.search.request.ProxyDeleteRequestBuilder;
-import org.sonar.server.search.request.ProxyFlushRequestBuilder;
-import org.sonar.server.search.request.ProxyGetRequestBuilder;
-import org.sonar.server.search.request.ProxyIndexRequestBuilder;
-import org.sonar.server.search.request.ProxyIndicesExistsRequestBuilder;
-import org.sonar.server.search.request.ProxyIndicesStatsRequestBuilder;
-import org.sonar.server.search.request.ProxyMultiGetRequestBuilder;
-import org.sonar.server.search.request.ProxyNodesStatsRequestBuilder;
-import org.sonar.server.search.request.ProxyPutMappingRequestBuilder;
-import org.sonar.server.search.request.ProxyRefreshRequestBuilder;
-import org.sonar.server.search.request.ProxySearchRequestBuilder;
-import org.sonar.server.search.request.ProxySearchScrollRequestBuilder;
+import org.sonar.server.es.request.ProxyBulkRequestBuilder;
+import org.sonar.server.es.request.ProxyClusterHealthRequestBuilder;
+import org.sonar.server.es.request.ProxyClusterStateRequestBuilder;
+import org.sonar.server.es.request.ProxyClusterStatsRequestBuilder;
+import org.sonar.server.es.request.ProxyCountRequestBuilder;
+import org.sonar.server.es.request.ProxyCreateIndexRequestBuilder;
+import org.sonar.server.es.request.ProxyDeleteByQueryRequestBuilder;
+import org.sonar.server.es.request.ProxyDeleteRequestBuilder;
+import org.sonar.server.es.request.ProxyFlushRequestBuilder;
+import org.sonar.server.es.request.ProxyGetRequestBuilder;
+import org.sonar.server.es.request.ProxyIndexRequestBuilder;
+import org.sonar.server.es.request.ProxyIndicesExistsRequestBuilder;
+import org.sonar.server.es.request.ProxyIndicesStatsRequestBuilder;
+import org.sonar.server.es.request.ProxyMultiGetRequestBuilder;
+import org.sonar.server.es.request.ProxyNodesStatsRequestBuilder;
+import org.sonar.server.es.request.ProxyPutMappingRequestBuilder;
+import org.sonar.server.es.request.ProxyRefreshRequestBuilder;
+import org.sonar.server.es.request.ProxySearchRequestBuilder;
+import org.sonar.server.es.request.ProxySearchScrollRequestBuilder;
 
 /**
  * Facade to connect to Elasticsearch node. Handles correctly errors (logging + exceptions
@@ -134,7 +134,7 @@ public class EsClient implements Startable {
     prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForStatus(status).get();
   }
 
-  public IndicesExistsRequestBuilder prepareExists(String... indices) {
+  public IndicesExistsRequestBuilder prepareIndicesExist(String... indices) {
     return new ProxyIndicesExistsRequestBuilder(client, profiling, indices);
   }
 
@@ -178,6 +178,7 @@ public class EsClient implements Startable {
     return new ProxyDeleteRequestBuilder(profiling, client, index).setType(type).setId(id);
   }
 
+
   public DeleteByQueryRequestBuilder prepareDeleteByQuery(String... indices) {
     return new ProxyDeleteByQueryRequestBuilder(client, profiling).setIndices(indices);
   }
index 6648cc5794590faeb82e5529631b4d66799dea47..581d0c1fa07cb60571bc96ede5471ad1c03f6edf 100644 (file)
@@ -56,7 +56,7 @@ public class IndexCreator implements ServerComponent, Startable {
   public void start() {
     // create indices that do not exist or that have a new definition (different mapping, cluster enabled, ...)
     for (IndexRegistry.Index index : registry.getIndices().values()) {
-      boolean exists = client.prepareExists(index.getName()).get().isExists();
+      boolean exists = client.prepareIndicesExist(index.getName()).get().isExists();
       if (exists && needsToDeleteIndex(index)) {
         LOGGER.info(String.format("Delete index %s (settings changed)", index.getName()));
         deleteIndex(index.getName());
index 8551839914f357271181e5ecf011358e107be36a..6df309abaa2c4bfbb7c8f8436326c8a7d08d39ec 100644 (file)
@@ -28,6 +28,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.SortedMap;
 
+/**
+ * Hash of index definition is stored in the index itself in order to detect changes of mappings
+ * between SonarQube versions. In this case, contrary to database tables, indices are dropped
+ * and re-populated from scratch. There's no attempt to migrate existing data.
+ */
 class IndexDefinitionHash {
 
   private static final char DELIMITER = ',';
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyBulkRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyBulkRequestBuilder.java
new file mode 100644 (file)
index 0000000..480e2b7
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.ActionRequest;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.bulk.BulkRequestBuilder;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.elasticsearch.action.delete.DeleteRequest;
+import org.elasticsearch.action.index.IndexRequest;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyBulkRequestBuilder extends BulkRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyBulkRequestBuilder(Client client, Profiling profiling) {
+    super(client);
+    this.profiling = profiling;
+  }
+
+  @Override
+  public BulkResponse get() {
+    StopWatch fullProfile = profiling.start("bulk", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public BulkResponse get(TimeValue timeout) {
+    throw unsupported();
+  }
+
+  @Override
+  public BulkResponse get(String timeout) {
+    // easy to implement if needed (copy get())
+    throw unsupported();
+  }
+
+  @Override
+  public ListenableActionFuture<BulkResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  private UnsupportedOperationException unsupported() {
+    throw new UnsupportedOperationException("See " + ProxyBulkRequestBuilder.class.getName());
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message.append("Bulk[");
+    for (int i=0 ; i<request.requests().size() ; i++) {
+      ActionRequest item = request.requests().get(i);
+      if (item instanceof IndexRequest) {
+        IndexRequest request = (IndexRequest) item;
+        message.append(String.format("index id '%s' in %s/%s", request.id(), request.index(), request.type()));
+      } else if (item instanceof UpdateRequest) {
+        UpdateRequest request = (UpdateRequest) item;
+        message.append(String.format("update id '%s' in %s/%s", request.id(), request.index(), request.type()));
+      } else if (item instanceof DeleteRequest) {
+        DeleteRequest request = (DeleteRequest) item;
+        message.append(String.format("delete id '%s' from %s/%s", request.id(), request.index(), request.type()));
+      }
+      if (i < request.requests().size()-1) {
+        message.append(", ");
+      }
+    }
+    message.append("]");
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyClusterHealthRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyClusterHealthRequestBuilder.java
new file mode 100644 (file)
index 0000000..e141bc9
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.apache.commons.lang.StringUtils;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder;
+import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyClusterHealthRequestBuilder extends ClusterHealthRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyClusterHealthRequestBuilder(Client client, Profiling profiling) {
+    super(client.admin().cluster());
+    this.profiling = profiling;
+  }
+
+  @Override
+  public ClusterHealthResponse get() {
+    StopWatch fullProfile = profiling.start("cluster health", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public ClusterHealthResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ClusterHealthResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<ClusterHealthResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message.append("ES cluster health request");
+    if (request.indices().length > 0) {
+      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
+    }
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyClusterStateRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyClusterStateRequestBuilder.java
new file mode 100644 (file)
index 0000000..c425e58
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.apache.commons.lang.StringUtils;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.admin.cluster.state.ClusterStateRequestBuilder;
+import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyClusterStateRequestBuilder extends ClusterStateRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyClusterStateRequestBuilder(Client client, Profiling profiling) {
+    super(client.admin().cluster());
+    this.profiling = profiling;
+  }
+
+  @Override
+  public ClusterStateResponse get() {
+    StopWatch fullProfile = profiling.start("cluster state", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public ClusterStateResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ClusterStateResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<ClusterStateResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message.append("ES cluster state request");
+    if (request.indices().length > 0) {
+      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
+    }
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyClusterStatsRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyClusterStatsRequestBuilder.java
new file mode 100644 (file)
index 0000000..15f15c9
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.apache.commons.lang.StringUtils;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequestBuilder;
+import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyClusterStatsRequestBuilder extends ClusterStatsRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyClusterStatsRequestBuilder(Client client, Profiling profiling) {
+    super(client.admin().cluster());
+    this.profiling = profiling;
+  }
+
+  @Override
+  public ClusterStatsResponse get() {
+    StopWatch fullProfile = profiling.start("cluster stats", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public ClusterStatsResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ClusterStatsResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<ClusterStatsResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message.append("ES cluster stats request");
+    if (request.nodesIds().length > 0) {
+      message.append(String.format(" on nodes '%s'", StringUtils.join(request.nodesIds(), ",")));
+    }
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyCountRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyCountRequestBuilder.java
new file mode 100644 (file)
index 0000000..0c80878
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.apache.commons.lang.StringUtils;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.count.CountRequestBuilder;
+import org.elasticsearch.action.count.CountResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyCountRequestBuilder extends CountRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyCountRequestBuilder(Client client, Profiling profiling) {
+    super(client);
+    this.profiling = profiling;
+  }
+
+  @Override
+  public CountResponse get() {
+    StopWatch fullProfile = profiling.start("count", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public CountResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public CountResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<CountResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message.append("ES count request");
+    if (request.indices().length > 0) {
+      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
+    }
+    if (request.types().length > 0) {
+      message.append(String.format(" on types '%s'", StringUtils.join(request.types(), ",")));
+    }
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyCreateIndexRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyCreateIndexRequestBuilder.java
new file mode 100644 (file)
index 0000000..c99462b
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
+import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyCreateIndexRequestBuilder extends CreateIndexRequestBuilder {
+
+  private final Profiling profiling;
+  private final String index;
+
+  public ProxyCreateIndexRequestBuilder(Client client, Profiling profiling, String index) {
+    super(client.admin().indices(), index);
+    this.profiling = profiling;
+    this.index = index;
+  }
+
+  @Override
+  public CreateIndexResponse get() {
+    StopWatch fullProfile = profiling.start("create index", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public CreateIndexResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public CreateIndexResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<CreateIndexResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    return String.format("ES create index '%s'", index);
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyDeleteByQueryRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyDeleteByQueryRequestBuilder.java
new file mode 100644 (file)
index 0000000..f473fc3
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.apache.commons.lang.StringUtils;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.deletebyquery.DeleteByQueryRequestBuilder;
+import org.elasticsearch.action.deletebyquery.DeleteByQueryResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyDeleteByQueryRequestBuilder extends DeleteByQueryRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyDeleteByQueryRequestBuilder(Client client, Profiling profiling) {
+    super(client);
+    this.profiling = profiling;
+  }
+
+  @Override
+  public DeleteByQueryResponse get() {
+    StopWatch fullProfile = profiling.start("delete by query", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public DeleteByQueryResponse get(TimeValue timeout) {
+    throw new UnsupportedOperationException("Not yet implemented");
+  }
+
+  @Override
+  public DeleteByQueryResponse get(String timeout) {
+    throw new UnsupportedOperationException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<DeleteByQueryResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message.append("ES delete by query request");
+    if (request.indices().length > 0) {
+      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
+    }
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyDeleteRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyDeleteRequestBuilder.java
new file mode 100644 (file)
index 0000000..88e9d32
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.delete.DeleteRequestBuilder;
+import org.elasticsearch.action.delete.DeleteResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyDeleteRequestBuilder extends DeleteRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyDeleteRequestBuilder(Profiling profiling, Client client, String index) {
+    super(client, index);
+    this.profiling = profiling;
+  }
+
+  @Override
+  public DeleteResponse get() {
+    StopWatch fullProfile = profiling.start("delete", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public DeleteResponse get(TimeValue timeout) {
+    throw new UnsupportedOperationException("Not yet implemented");
+  }
+
+  @Override
+  public DeleteResponse get(String timeout) {
+    throw new UnsupportedOperationException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<DeleteResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message
+      .append("ES delete request of doc ")
+      .append(request.id())
+      .append(" in index ")
+      .append(request.index())
+      .append("/")
+      .append(request.type());
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyFlushRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyFlushRequestBuilder.java
new file mode 100644 (file)
index 0000000..65eed7a
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.apache.commons.lang.StringUtils;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.admin.indices.flush.FlushRequestBuilder;
+import org.elasticsearch.action.admin.indices.flush.FlushResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyFlushRequestBuilder extends FlushRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyFlushRequestBuilder(Client client, Profiling profiling) {
+    super(client.admin().indices());
+    this.profiling = profiling;
+  }
+
+  @Override
+  public FlushResponse get() {
+    StopWatch fullProfile = profiling.start("flush", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public FlushResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public FlushResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<FlushResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message.append("ES flush request");
+    if (request.indices().length > 0) {
+      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
+    }
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyGetRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyGetRequestBuilder.java
new file mode 100644 (file)
index 0000000..7aa2388
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.get.GetRequestBuilder;
+import org.elasticsearch.action.get.GetResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyGetRequestBuilder extends GetRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyGetRequestBuilder(Client client, Profiling profiling) {
+    super(client);
+    this.profiling = profiling;
+  }
+
+  @Override
+  public GetResponse get() {
+    StopWatch fullProfile = profiling.start("get", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public GetResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public GetResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<GetResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder().append("ES get request");
+    message.append(String.format(" for key '%s'", request.id()));
+    message.append(String.format(" on index '%s'", request.index()));
+    message.append(String.format(" on type '%s'", request.type()));
+    return message.toString();
+  }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyIndexRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyIndexRequestBuilder.java
new file mode 100644 (file)
index 0000000..e9987f6
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.index.IndexRequestBuilder;
+import org.elasticsearch.action.index.IndexResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyIndexRequestBuilder extends IndexRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyIndexRequestBuilder(Client client, Profiling profiling) {
+    super(client);
+    this.profiling = profiling;
+  }
+
+  @Override
+  public IndexResponse get() {
+    StopWatch fullProfile = profiling.start("index", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.FULL)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public IndexResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public IndexResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<IndexResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder().append("ES index request");
+    message.append(String.format(" for key '%s'", request.id()));
+    message.append(String.format(" on index '%s'", request.index()));
+    message.append(String.format(" on type '%s'", request.type()));
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyIndicesExistsRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyIndicesExistsRequestBuilder.java
new file mode 100644 (file)
index 0000000..49f8443
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.apache.commons.lang.StringUtils;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder;
+import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyIndicesExistsRequestBuilder extends IndicesExistsRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyIndicesExistsRequestBuilder(Client client, Profiling profiling, String... indices) {
+    super(client.admin().indices(), indices);
+    this.profiling = profiling;
+  }
+
+  @Override
+  public IndicesExistsResponse get() {
+    StopWatch fullProfile = profiling.start("indices exists", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public IndicesExistsResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public IndicesExistsResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<IndicesExistsResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message.append("ES indices exists request");
+    if (request.indices().length > 0) {
+      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
+    }
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyIndicesStatsRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyIndicesStatsRequestBuilder.java
new file mode 100644 (file)
index 0000000..3bf1994
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.apache.commons.lang.StringUtils;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequestBuilder;
+import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyIndicesStatsRequestBuilder extends IndicesStatsRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyIndicesStatsRequestBuilder(Client client, Profiling profiling) {
+    super(client.admin().indices());
+    this.profiling = profiling;
+  }
+
+  @Override
+  public IndicesStatsResponse get() {
+    StopWatch fullProfile = profiling.start("indices stats", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public IndicesStatsResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public IndicesStatsResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<IndicesStatsResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message.append("ES indices stats request");
+    if (request.indices().length > 0) {
+      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
+    }
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyMultiGetRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyMultiGetRequestBuilder.java
new file mode 100644 (file)
index 0000000..d30e2aa
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.get.MultiGetRequest;
+import org.elasticsearch.action.get.MultiGetRequestBuilder;
+import org.elasticsearch.action.get.MultiGetResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyMultiGetRequestBuilder extends MultiGetRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyMultiGetRequestBuilder(Client client, Profiling profiling) {
+    super(client);
+    this.profiling = profiling;
+  }
+
+  @Override
+  public MultiGetResponse get() {
+    StopWatch fullProfile = profiling.start("get", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public MultiGetResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public MultiGetResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<MultiGetResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message.append("ES multi get request");
+    for (MultiGetRequest.Item item : request) {
+      message.append(String.format(" [key '%s'", item.id()));
+      message.append(String.format(", index '%s'", item.index()));
+      String type = item.type();
+      if (type != null) {
+        message.append(String.format(", type '%s'", type));
+      }
+      message.append("],");
+    }
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyNodesStatsRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyNodesStatsRequestBuilder.java
new file mode 100644 (file)
index 0000000..dfa01b7
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.apache.commons.lang.StringUtils;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequestBuilder;
+import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyNodesStatsRequestBuilder extends NodesStatsRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyNodesStatsRequestBuilder(Client client, Profiling profiling) {
+    super(client.admin().cluster());
+    this.profiling = profiling;
+  }
+
+  @Override
+  public NodesStatsResponse get() {
+    StopWatch fullProfile = profiling.start("nodes stats", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public NodesStatsResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public NodesStatsResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<NodesStatsResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message.append("ES nodes stats request");
+    if (request.nodesIds().length > 0) {
+      message.append(String.format(" on nodes '%s'", StringUtils.join(request.nodesIds(), ",")));
+    }
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyPutMappingRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyPutMappingRequestBuilder.java
new file mode 100644 (file)
index 0000000..8a9699a
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.apache.commons.lang.StringUtils;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder;
+import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyPutMappingRequestBuilder extends PutMappingRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyPutMappingRequestBuilder(Client client, Profiling profiling) {
+    super(client.admin().indices());
+    this.profiling = profiling;
+  }
+
+  @Override
+  public PutMappingResponse get() {
+    StopWatch fullProfile = profiling.start("put mapping", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public PutMappingResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public PutMappingResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<PutMappingResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message.append("ES put mapping request");
+    if (request.indices().length > 0) {
+      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
+    }
+    String type = request.type();
+    if (type != null) {
+      message.append(String.format(" on type '%s'", type));
+    }
+    String source = request.source();
+    if (source != null) {
+      message.append(String.format(" with source '%s'", source));
+    }
+
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyRefreshRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyRefreshRequestBuilder.java
new file mode 100644 (file)
index 0000000..da888cb
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.apache.commons.lang.StringUtils;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder;
+import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxyRefreshRequestBuilder extends RefreshRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxyRefreshRequestBuilder(Client client, Profiling profiling) {
+    super(client.admin().indices());
+    this.profiling = profiling;
+  }
+
+  @Override
+  public RefreshResponse get() {
+    StopWatch fullProfile = profiling.start("refresh", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public RefreshResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public RefreshResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<RefreshResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message.append("ES refresh request");
+    if (request.indices().length > 0) {
+      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
+    }
+    return message.toString();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxySearchRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxySearchRequestBuilder.java
new file mode 100644 (file)
index 0000000..3676494
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.search.SearchRequestBuilder;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.common.xcontent.ToXContent;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+public class ProxySearchRequestBuilder extends SearchRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxySearchRequestBuilder(Client client, Profiling profiling) {
+    super(client);
+    this.profiling = profiling;
+  }
+
+  @Override
+  public SearchResponse get() {
+    StopWatch fullProfile = profiling.start("search", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public SearchResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public SearchResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<SearchResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder message = new StringBuilder();
+    message.append(String.format("ES search request '%s'", xContentToString(super.internalBuilder())));
+    if (request.indices().length > 0) {
+      message.append(String.format(" on indices '%s'", Arrays.toString(request.indices())));
+    }
+    if (request.types().length > 0) {
+      message.append(String.format(" on types '%s'", Arrays.toString(request.types())));
+    }
+    return message.toString();
+  }
+
+  private String xContentToString(ToXContent toXContent) {
+    try {
+      XContentBuilder builder = XContentFactory.jsonBuilder();
+      toXContent.toXContent(builder, ToXContent.EMPTY_PARAMS);
+      return builder.string();
+    } catch (IOException e) {
+      throw new IllegalStateException("Fail to convert request to string", e);
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxySearchScrollRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxySearchScrollRequestBuilder.java
new file mode 100644 (file)
index 0000000..dbaa4aa
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.action.search.SearchScrollRequestBuilder;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.unit.TimeValue;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.core.profiling.StopWatch;
+
+public class ProxySearchScrollRequestBuilder extends SearchScrollRequestBuilder {
+
+  private final Profiling profiling;
+
+  public ProxySearchScrollRequestBuilder(String scrollId, Client client, Profiling profiling) {
+    super(client, scrollId);
+    this.profiling = profiling;
+  }
+
+  @Override
+  public SearchResponse get() {
+    StopWatch fullProfile = profiling.start("search scroll", Profiling.Level.FULL);
+    try {
+      return super.execute().actionGet();
+    } catch (Exception e) {
+      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
+    } finally {
+      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+        fullProfile.stop("%s", toString());
+      }
+    }
+  }
+
+  @Override
+  public SearchResponse get(TimeValue timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public SearchResponse get(String timeout) {
+    throw new IllegalStateException("Not yet implemented");
+  }
+
+  @Override
+  public ListenableActionFuture<SearchResponse> execute() {
+    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
+  }
+
+  @Override
+  public String toString() {
+    return String.format("ES search scroll request for scroll id '%s'", super.request().scroll());
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/package-info.java
new file mode 100644 (file)
index 0000000..d473934
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+@ParametersAreNonnullByDefault
+package org.sonar.server.es.request;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index 9294371e22d9d80f5671ac797b974d6b45001172..bc7821588c4a245b47c2696090f1599f29bbf138 100644 (file)
@@ -148,7 +148,7 @@ public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serial
   protected void initializeIndex() {
     String index = this.getIndexName();
 
-    IndicesExistsResponse indexExistsResponse = client.prepareExists(index).get();
+    IndicesExistsResponse indexExistsResponse = client.prepareIndicesExist(index).get();
     try {
 
       if (!indexExistsResponse.isExists()) {
index d18997686021a1ba2c8c6a2a6482f12a9fe35f7e..2e1c3511c1815e667690f106aea0deb59c1931f6 100644 (file)
 
 package org.sonar.server.search;
 
-import org.sonar.server.search.request.ProxyIndexRequestBuilder;
-
 import com.google.common.annotations.VisibleForTesting;
 import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder;
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
 import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequestBuilder;
 import org.elasticsearch.action.admin.cluster.state.ClusterStateRequestBuilder;
@@ -66,24 +63,23 @@ import org.sonar.api.config.Settings;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.process.LoopbackAddress;
 import org.sonar.process.ProcessConstants;
-import org.sonar.server.search.request.ProxyBulkRequestBuilder;
-import org.sonar.server.search.request.ProxyClusterHealthRequestBuilder;
-import org.sonar.server.search.request.ProxyClusterStateRequestBuilder;
-import org.sonar.server.search.request.ProxyClusterStatsRequestBuilder;
-import org.sonar.server.search.request.ProxyCountRequestBuilder;
-import org.sonar.server.search.request.ProxyCreateIndexRequestBuilder;
-import org.sonar.server.search.request.ProxyDeleteByQueryRequestBuilder;
-import org.sonar.server.search.request.ProxyDeleteRequestBuilder;
-import org.sonar.server.search.request.ProxyFlushRequestBuilder;
-import org.sonar.server.search.request.ProxyGetRequestBuilder;
-import org.sonar.server.search.request.ProxyIndicesExistsRequestBuilder;
-import org.sonar.server.search.request.ProxyIndicesStatsRequestBuilder;
-import org.sonar.server.search.request.ProxyMultiGetRequestBuilder;
-import org.sonar.server.search.request.ProxyNodesStatsRequestBuilder;
-import org.sonar.server.search.request.ProxyPutMappingRequestBuilder;
-import org.sonar.server.search.request.ProxyRefreshRequestBuilder;
-import org.sonar.server.search.request.ProxySearchRequestBuilder;
-import org.sonar.server.search.request.ProxySearchScrollRequestBuilder;
+import org.sonar.server.es.request.ProxyBulkRequestBuilder;
+import org.sonar.server.es.request.ProxyClusterStateRequestBuilder;
+import org.sonar.server.es.request.ProxyClusterStatsRequestBuilder;
+import org.sonar.server.es.request.ProxyCountRequestBuilder;
+import org.sonar.server.es.request.ProxyCreateIndexRequestBuilder;
+import org.sonar.server.es.request.ProxyDeleteByQueryRequestBuilder;
+import org.sonar.server.es.request.ProxyDeleteRequestBuilder;
+import org.sonar.server.es.request.ProxyFlushRequestBuilder;
+import org.sonar.server.es.request.ProxyGetRequestBuilder;
+import org.sonar.server.es.request.ProxyIndicesExistsRequestBuilder;
+import org.sonar.server.es.request.ProxyIndicesStatsRequestBuilder;
+import org.sonar.server.es.request.ProxyMultiGetRequestBuilder;
+import org.sonar.server.es.request.ProxyNodesStatsRequestBuilder;
+import org.sonar.server.es.request.ProxyPutMappingRequestBuilder;
+import org.sonar.server.es.request.ProxyRefreshRequestBuilder;
+import org.sonar.server.es.request.ProxySearchRequestBuilder;
+import org.sonar.server.es.request.ProxySearchScrollRequestBuilder;
 
 /**
  * ElasticSearch Node used to connect to index.
@@ -155,11 +151,7 @@ public class SearchClient extends TransportClient implements Startable {
     return new ProxyClusterStateRequestBuilder(this, profiling);
   }
 
-  public ClusterHealthRequestBuilder prepareHealth(String... indices) {
-    return new ProxyClusterHealthRequestBuilder(this, profiling).setIndices(indices);
-  }
-
-  public IndicesExistsRequestBuilder prepareExists(String... indices) {
+  public IndicesExistsRequestBuilder prepareIndicesExist(String... indices) {
     return new ProxyIndicesExistsRequestBuilder(this, profiling, indices);
   }
 
@@ -186,11 +178,6 @@ public class SearchClient extends TransportClient implements Startable {
     return new ProxyGetRequestBuilder(this, profiling);
   }
 
-  @Override
-  public GetRequestBuilder prepareGet(String index, String type, String id) {
-    return new ProxyGetRequestBuilder(this, profiling).setIndex(index).setType(type).setId(id);
-  }
-
   @Override
   public MultiGetRequestBuilder prepareMultiGet() {
     return new ProxyMultiGetRequestBuilder(this, profiling);
@@ -211,25 +198,30 @@ public class SearchClient extends TransportClient implements Startable {
     return new ProxyDeleteByQueryRequestBuilder(this, profiling).setIndices(indices);
   }
 
+  // ****************************************************************************************************************
+  // Not yet implemented methods
+  // ****************************************************************************************************************
+
+  @Override
+  public GetRequestBuilder prepareGet(String index, String type, String id) {
+    throw throwNotYetImplemented();
+  }
+
   @Override
   public IndexRequestBuilder prepareIndex() {
-    return new ProxyIndexRequestBuilder(this, profiling);
+    throw throwNotYetImplemented();
   }
 
   @Override
   public IndexRequestBuilder prepareIndex(String index, String type) {
-    return new ProxyIndexRequestBuilder(this, profiling).setIndex(index).setType(type);
+    throw throwNotYetImplemented();
   }
 
   @Override
   public IndexRequestBuilder prepareIndex(String index, String type, @Nullable String id) {
-    return new ProxyIndexRequestBuilder(this, profiling).setIndex(index).setType(type).setId(id);
+    throw throwNotYetImplemented();
   }
 
-  // ****************************************************************************************************************
-  // Not yet implemented methods
-  // ****************************************************************************************************************
-
   @Override
   public MultiSearchRequestBuilder prepareMultiSearch() {
     throw throwNotYetImplemented();
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyBulkRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyBulkRequestBuilder.java
deleted file mode 100644 (file)
index bb75fdb..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.ActionRequest;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.bulk.BulkRequestBuilder;
-import org.elasticsearch.action.bulk.BulkResponse;
-import org.elasticsearch.action.delete.DeleteRequest;
-import org.elasticsearch.action.index.IndexRequest;
-import org.elasticsearch.action.update.UpdateRequest;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyBulkRequestBuilder extends BulkRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyBulkRequestBuilder(Client client, Profiling profiling) {
-    super(client);
-    this.profiling = profiling;
-  }
-
-  @Override
-  public BulkResponse get() {
-    StopWatch fullProfile = profiling.start("bulk", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public BulkResponse get(TimeValue timeout) {
-    throw unsupported();
-  }
-
-  @Override
-  public BulkResponse get(String timeout) {
-    // easy to implement if needed (copy get())
-    throw unsupported();
-  }
-
-  @Override
-  public ListenableActionFuture<BulkResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  private UnsupportedOperationException unsupported() {
-    throw new UnsupportedOperationException("See " + ProxyBulkRequestBuilder.class.getName());
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message.append("ES bulk request for ");
-    for (ActionRequest item : request.requests()) {
-      message.append(String.format("[Action '%s' ", item.getClass().getSimpleName()));
-      if (item instanceof IndexRequest) {
-        IndexRequest request = (IndexRequest) item;
-        message.append(String.format("for key '%s'", request.id()));
-        message.append(String.format(" on index '%s'", request.index()));
-        message.append(String.format(" on type '%s'", request.type()));
-      } else if (item instanceof UpdateRequest) {
-        UpdateRequest request = (UpdateRequest) item;
-        message.append(String.format("for key '%s'", request.id()));
-        message.append(String.format(" on index '%s'", request.index()));
-        message.append(String.format(" on type '%s'", request.type()));
-      } else if (item instanceof DeleteRequest) {
-        DeleteRequest request = (DeleteRequest) item;
-        message.append(String.format("for key '%s'", request.id()));
-        message.append(String.format(" on index '%s'", request.index()));
-        message.append(String.format(" on type '%s'", request.type()));
-      }
-      message.append("],");
-    }
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyClusterHealthRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyClusterHealthRequestBuilder.java
deleted file mode 100644 (file)
index 8cc46b0..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder;
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyClusterHealthRequestBuilder extends ClusterHealthRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyClusterHealthRequestBuilder(Client client, Profiling profiling) {
-    super(client.admin().cluster());
-    this.profiling = profiling;
-  }
-
-  @Override
-  public ClusterHealthResponse get() {
-    StopWatch fullProfile = profiling.start("cluster health", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public ClusterHealthResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ClusterHealthResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<ClusterHealthResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message.append("ES cluster health request");
-    if (request.indices().length > 0) {
-      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
-    }
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyClusterStateRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyClusterStateRequestBuilder.java
deleted file mode 100644 (file)
index 178eec9..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.admin.cluster.state.ClusterStateRequestBuilder;
-import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyClusterStateRequestBuilder extends ClusterStateRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyClusterStateRequestBuilder(Client client, Profiling profiling) {
-    super(client.admin().cluster());
-    this.profiling = profiling;
-  }
-
-  @Override
-  public ClusterStateResponse get() {
-    StopWatch fullProfile = profiling.start("cluster state", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public ClusterStateResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ClusterStateResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<ClusterStateResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message.append("ES cluster state request");
-    if (request.indices().length > 0) {
-      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
-    }
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyClusterStatsRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyClusterStatsRequestBuilder.java
deleted file mode 100644 (file)
index 3a2ba51..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequestBuilder;
-import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyClusterStatsRequestBuilder extends ClusterStatsRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyClusterStatsRequestBuilder(Client client, Profiling profiling) {
-    super(client.admin().cluster());
-    this.profiling = profiling;
-  }
-
-  @Override
-  public ClusterStatsResponse get() {
-    StopWatch fullProfile = profiling.start("cluster stats", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public ClusterStatsResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ClusterStatsResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<ClusterStatsResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message.append("ES cluster stats request");
-    if (request.nodesIds().length > 0) {
-      message.append(String.format(" on nodes '%s'", StringUtils.join(request.nodesIds(), ",")));
-    }
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyCountRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyCountRequestBuilder.java
deleted file mode 100644 (file)
index fbd5f92..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.count.CountRequestBuilder;
-import org.elasticsearch.action.count.CountResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyCountRequestBuilder extends CountRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyCountRequestBuilder(Client client, Profiling profiling) {
-    super(client);
-    this.profiling = profiling;
-  }
-
-  @Override
-  public CountResponse get() {
-    StopWatch fullProfile = profiling.start("count", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public CountResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public CountResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<CountResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message.append("ES count request");
-    if (request.indices().length > 0) {
-      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
-    }
-    if (request.types().length > 0) {
-      message.append(String.format(" on types '%s'", StringUtils.join(request.types(), ",")));
-    }
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyCreateIndexRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyCreateIndexRequestBuilder.java
deleted file mode 100644 (file)
index e867930..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
-import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyCreateIndexRequestBuilder extends CreateIndexRequestBuilder {
-
-  private final Profiling profiling;
-  private final String index;
-
-  public ProxyCreateIndexRequestBuilder(Client client, Profiling profiling, String index) {
-    super(client.admin().indices(), index);
-    this.profiling = profiling;
-    this.index = index;
-  }
-
-  @Override
-  public CreateIndexResponse get() {
-    StopWatch fullProfile = profiling.start("create index", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public CreateIndexResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public CreateIndexResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<CreateIndexResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    return String.format("ES create index '%s'", index);
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyDeleteByQueryRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyDeleteByQueryRequestBuilder.java
deleted file mode 100644 (file)
index ee93ec7..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.deletebyquery.DeleteByQueryRequestBuilder;
-import org.elasticsearch.action.deletebyquery.DeleteByQueryResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyDeleteByQueryRequestBuilder extends DeleteByQueryRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyDeleteByQueryRequestBuilder(Client client, Profiling profiling) {
-    super(client);
-    this.profiling = profiling;
-  }
-
-  @Override
-  public DeleteByQueryResponse get() {
-    StopWatch fullProfile = profiling.start("delete by query", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public DeleteByQueryResponse get(TimeValue timeout) {
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  @Override
-  public DeleteByQueryResponse get(String timeout) {
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<DeleteByQueryResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message.append("ES delete by query request");
-    if (request.indices().length > 0) {
-      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
-    }
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyDeleteRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyDeleteRequestBuilder.java
deleted file mode 100644 (file)
index 993eb01..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.delete.DeleteRequestBuilder;
-import org.elasticsearch.action.delete.DeleteResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyDeleteRequestBuilder extends DeleteRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyDeleteRequestBuilder(Profiling profiling, Client client, String index) {
-    super(client, index);
-    this.profiling = profiling;
-  }
-
-  @Override
-  public DeleteResponse get() {
-    StopWatch fullProfile = profiling.start("delete", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public DeleteResponse get(TimeValue timeout) {
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  @Override
-  public DeleteResponse get(String timeout) {
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<DeleteResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message
-      .append("ES delete request of doc ")
-      .append(request.id())
-      .append(" in index ")
-      .append(request.index())
-      .append("/")
-      .append(request.type());
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyFlushRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyFlushRequestBuilder.java
deleted file mode 100644 (file)
index c758784..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.admin.indices.flush.FlushRequestBuilder;
-import org.elasticsearch.action.admin.indices.flush.FlushResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyFlushRequestBuilder extends FlushRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyFlushRequestBuilder(Client client, Profiling profiling) {
-    super(client.admin().indices());
-    this.profiling = profiling;
-  }
-
-  @Override
-  public FlushResponse get() {
-    StopWatch fullProfile = profiling.start("flush", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public FlushResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public FlushResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<FlushResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message.append("ES flush request");
-    if (request.indices().length > 0) {
-      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
-    }
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyGetRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyGetRequestBuilder.java
deleted file mode 100644 (file)
index 604c26a..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.get.GetRequestBuilder;
-import org.elasticsearch.action.get.GetResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyGetRequestBuilder extends GetRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyGetRequestBuilder(Client client, Profiling profiling) {
-    super(client);
-    this.profiling = profiling;
-  }
-
-  @Override
-  public GetResponse get() {
-    StopWatch fullProfile = profiling.start("get", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public GetResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public GetResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<GetResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder().append("ES get request");
-    message.append(String.format(" for key '%s'", request.id()));
-    message.append(String.format(" on index '%s'", request.index()));
-    message.append(String.format(" on type '%s'", request.type()));
-    return message.toString();
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyIndexRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyIndexRequestBuilder.java
deleted file mode 100644 (file)
index 26751f0..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.index.IndexRequestBuilder;
-import org.elasticsearch.action.index.IndexResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyIndexRequestBuilder extends IndexRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyIndexRequestBuilder(Client client, Profiling profiling) {
-    super(client);
-    this.profiling = profiling;
-  }
-
-  @Override
-  public IndexResponse get() {
-    StopWatch fullProfile = profiling.start("index", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.FULL)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public IndexResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public IndexResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<IndexResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder().append("ES index request");
-    message.append(String.format(" for key '%s'", request.id()));
-    message.append(String.format(" on index '%s'", request.index()));
-    message.append(String.format(" on type '%s'", request.type()));
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyIndicesExistsRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyIndicesExistsRequestBuilder.java
deleted file mode 100644 (file)
index 7403cef..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder;
-import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyIndicesExistsRequestBuilder extends IndicesExistsRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyIndicesExistsRequestBuilder(Client client, Profiling profiling, String... indices) {
-    super(client.admin().indices(), indices);
-    this.profiling = profiling;
-  }
-
-  @Override
-  public IndicesExistsResponse get() {
-    StopWatch fullProfile = profiling.start("indices exists", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public IndicesExistsResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public IndicesExistsResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<IndicesExistsResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message.append("ES indices exists request");
-    if (request.indices().length > 0) {
-      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
-    }
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyIndicesStatsRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyIndicesStatsRequestBuilder.java
deleted file mode 100644 (file)
index 689387c..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequestBuilder;
-import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyIndicesStatsRequestBuilder extends IndicesStatsRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyIndicesStatsRequestBuilder(Client client, Profiling profiling) {
-    super(client.admin().indices());
-    this.profiling = profiling;
-  }
-
-  @Override
-  public IndicesStatsResponse get() {
-    StopWatch fullProfile = profiling.start("indices stats", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public IndicesStatsResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public IndicesStatsResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<IndicesStatsResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message.append("ES indices stats request");
-    if (request.indices().length > 0) {
-      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
-    }
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilder.java
deleted file mode 100644 (file)
index 6567240..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.get.MultiGetRequest;
-import org.elasticsearch.action.get.MultiGetRequestBuilder;
-import org.elasticsearch.action.get.MultiGetResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyMultiGetRequestBuilder extends MultiGetRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyMultiGetRequestBuilder(Client client, Profiling profiling) {
-    super(client);
-    this.profiling = profiling;
-  }
-
-  @Override
-  public MultiGetResponse get() {
-    StopWatch fullProfile = profiling.start("get", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public MultiGetResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public MultiGetResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<MultiGetResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message.append("ES multi get request");
-    for (MultiGetRequest.Item item : request) {
-      message.append(String.format(" [key '%s'", item.id()));
-      message.append(String.format(", index '%s'", item.index()));
-      String type = item.type();
-      if (type != null) {
-        message.append(String.format(", type '%s'", type));
-      }
-      message.append("],");
-    }
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyNodesStatsRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyNodesStatsRequestBuilder.java
deleted file mode 100644 (file)
index ff43b6c..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequestBuilder;
-import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyNodesStatsRequestBuilder extends NodesStatsRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyNodesStatsRequestBuilder(Client client, Profiling profiling) {
-    super(client.admin().cluster());
-    this.profiling = profiling;
-  }
-
-  @Override
-  public NodesStatsResponse get() {
-    StopWatch fullProfile = profiling.start("nodes stats", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public NodesStatsResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public NodesStatsResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<NodesStatsResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message.append("ES nodes stats request");
-    if (request.nodesIds().length > 0) {
-      message.append(String.format(" on nodes '%s'", StringUtils.join(request.nodesIds(), ",")));
-    }
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyPutMappingRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyPutMappingRequestBuilder.java
deleted file mode 100644 (file)
index ca3cc2c..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder;
-import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyPutMappingRequestBuilder extends PutMappingRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyPutMappingRequestBuilder(Client client, Profiling profiling) {
-    super(client.admin().indices());
-    this.profiling = profiling;
-  }
-
-  @Override
-  public PutMappingResponse get() {
-    StopWatch fullProfile = profiling.start("put mapping", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public PutMappingResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public PutMappingResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<PutMappingResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message.append("ES put mapping request");
-    if (request.indices().length > 0) {
-      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
-    }
-    String type = request.type();
-    if (type != null) {
-      message.append(String.format(" on type '%s'", type));
-    }
-    String source = request.source();
-    if (source != null) {
-      message.append(String.format(" with source '%s'", source));
-    }
-
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyRefreshRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyRefreshRequestBuilder.java
deleted file mode 100644 (file)
index 0cb33ea..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.apache.commons.lang.StringUtils;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder;
-import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxyRefreshRequestBuilder extends RefreshRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxyRefreshRequestBuilder(Client client, Profiling profiling) {
-    super(client.admin().indices());
-    this.profiling = profiling;
-  }
-
-  @Override
-  public RefreshResponse get() {
-    StopWatch fullProfile = profiling.start("refresh", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public RefreshResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public RefreshResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<RefreshResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message.append("ES refresh request");
-    if (request.indices().length > 0) {
-      message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ",")));
-    }
-    return message.toString();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxySearchRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxySearchRequestBuilder.java
deleted file mode 100644 (file)
index e859246..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.search.SearchRequestBuilder;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.common.xcontent.ToXContent;
-import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.common.xcontent.XContentFactory;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-public class ProxySearchRequestBuilder extends SearchRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxySearchRequestBuilder(Client client, Profiling profiling) {
-    super(client);
-    this.profiling = profiling;
-  }
-
-  @Override
-  public SearchResponse get() {
-    StopWatch fullProfile = profiling.start("search", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public SearchResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public SearchResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<SearchResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder message = new StringBuilder();
-    message.append(String.format("ES search request '%s'", xContentToString(super.internalBuilder())));
-    if (request.indices().length > 0) {
-      message.append(String.format(" on indices '%s'", Arrays.toString(request.indices())));
-    }
-    if (request.types().length > 0) {
-      message.append(String.format(" on types '%s'", Arrays.toString(request.types())));
-    }
-    return message.toString();
-  }
-
-  private String xContentToString(ToXContent toXContent) {
-    try {
-      XContentBuilder builder = XContentFactory.jsonBuilder();
-      toXContent.toXContent(builder, ToXContent.EMPTY_PARAMS);
-      return builder.string();
-    } catch (IOException e) {
-      throw new IllegalStateException("Fail to convert request to string", e);
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilder.java
deleted file mode 100644 (file)
index 8c5706d..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.action.search.SearchScrollRequestBuilder;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.core.profiling.StopWatch;
-
-public class ProxySearchScrollRequestBuilder extends SearchScrollRequestBuilder {
-
-  private final Profiling profiling;
-
-  public ProxySearchScrollRequestBuilder(String scrollId, Client client, Profiling profiling) {
-    super(client, scrollId);
-    this.profiling = profiling;
-  }
-
-  @Override
-  public SearchResponse get() {
-    StopWatch fullProfile = profiling.start("search scroll", Profiling.Level.FULL);
-    try {
-      return super.execute().actionGet();
-    } catch (Exception e) {
-      throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
-    } finally {
-      if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
-        fullProfile.stop("%s", toString());
-      }
-    }
-  }
-
-  @Override
-  public SearchResponse get(TimeValue timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public SearchResponse get(String timeout) {
-    throw new IllegalStateException("Not yet implemented");
-  }
-
-  @Override
-  public ListenableActionFuture<SearchResponse> execute() {
-    throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous");
-  }
-
-  @Override
-  public String toString() {
-    return String.format("ES search scroll request for scroll id '%s'", super.request().scroll());
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/package-info.java
deleted file mode 100644 (file)
index 50f8a08..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-@ParametersAreNonnullByDefault
-package org.sonar.server.search.request;
-
-import javax.annotation.ParametersAreNonnullByDefault;
index 66b91c01ede77b6a211d92f9612ec77899b13c80..6549a6f08a772eb0b1a2c70ad817a4c046032328 100644 (file)
@@ -21,24 +21,24 @@ package org.sonar.server.es;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.server.search.request.ProxyBulkRequestBuilder;
-import org.sonar.server.search.request.ProxyClusterHealthRequestBuilder;
-import org.sonar.server.search.request.ProxyClusterStateRequestBuilder;
-import org.sonar.server.search.request.ProxyClusterStatsRequestBuilder;
-import org.sonar.server.search.request.ProxyCountRequestBuilder;
-import org.sonar.server.search.request.ProxyCreateIndexRequestBuilder;
-import org.sonar.server.search.request.ProxyDeleteByQueryRequestBuilder;
-import org.sonar.server.search.request.ProxyDeleteRequestBuilder;
-import org.sonar.server.search.request.ProxyFlushRequestBuilder;
-import org.sonar.server.search.request.ProxyGetRequestBuilder;
-import org.sonar.server.search.request.ProxyIndicesExistsRequestBuilder;
-import org.sonar.server.search.request.ProxyIndicesStatsRequestBuilder;
-import org.sonar.server.search.request.ProxyMultiGetRequestBuilder;
-import org.sonar.server.search.request.ProxyNodesStatsRequestBuilder;
-import org.sonar.server.search.request.ProxyPutMappingRequestBuilder;
-import org.sonar.server.search.request.ProxyRefreshRequestBuilder;
-import org.sonar.server.search.request.ProxySearchRequestBuilder;
-import org.sonar.server.search.request.ProxySearchScrollRequestBuilder;
+import org.sonar.server.es.request.ProxyBulkRequestBuilder;
+import org.sonar.server.es.request.ProxyClusterHealthRequestBuilder;
+import org.sonar.server.es.request.ProxyClusterStateRequestBuilder;
+import org.sonar.server.es.request.ProxyClusterStatsRequestBuilder;
+import org.sonar.server.es.request.ProxyCountRequestBuilder;
+import org.sonar.server.es.request.ProxyCreateIndexRequestBuilder;
+import org.sonar.server.es.request.ProxyDeleteByQueryRequestBuilder;
+import org.sonar.server.es.request.ProxyDeleteRequestBuilder;
+import org.sonar.server.es.request.ProxyFlushRequestBuilder;
+import org.sonar.server.es.request.ProxyGetRequestBuilder;
+import org.sonar.server.es.request.ProxyIndicesExistsRequestBuilder;
+import org.sonar.server.es.request.ProxyIndicesStatsRequestBuilder;
+import org.sonar.server.es.request.ProxyMultiGetRequestBuilder;
+import org.sonar.server.es.request.ProxyNodesStatsRequestBuilder;
+import org.sonar.server.es.request.ProxyPutMappingRequestBuilder;
+import org.sonar.server.es.request.ProxyRefreshRequestBuilder;
+import org.sonar.server.es.request.ProxySearchRequestBuilder;
+import org.sonar.server.es.request.ProxySearchScrollRequestBuilder;
 
 import static org.fest.assertions.Assertions.assertThat;
 
@@ -59,7 +59,7 @@ public class EsClientTest {
     assertThat(client.prepareCreate("fakes")).isInstanceOf(ProxyCreateIndexRequestBuilder.class);
     assertThat(client.prepareDeleteByQuery()).isInstanceOf(ProxyDeleteByQueryRequestBuilder.class);
     assertThat(client.prepareDelete("fakes", "fake", "my_id")).isInstanceOf(ProxyDeleteRequestBuilder.class);
-    assertThat(client.prepareExists()).isInstanceOf(ProxyIndicesExistsRequestBuilder.class);
+    assertThat(client.prepareIndicesExist()).isInstanceOf(ProxyIndicesExistsRequestBuilder.class);
     assertThat(client.prepareFlush()).isInstanceOf(ProxyFlushRequestBuilder.class);
     assertThat(client.prepareGet()).isInstanceOf(ProxyGetRequestBuilder.class);
     assertThat(client.prepareGet("fakes", "fake", "1")).isInstanceOf(ProxyGetRequestBuilder.class);
index ad08d619827cc6ea80dacb32c70aa54b8d81ce3f..417f93f7c960e6536ee18b0619c15eed39ff1521 100644 (file)
@@ -60,6 +60,7 @@ public class EsTester extends ExternalResource {
   private Node node;
   private EsClient client;
   private final List<IndexDefinition> definitions = Lists.newArrayList();
+  private Settings settings = new Settings();
 
   public EsTester addDefinitions(IndexDefinition... defs) {
     Collections.addAll(definitions, defs);
@@ -96,7 +97,7 @@ public class EsTester extends ExternalResource {
     DeleteIndexResponse response = node.client().admin().indices().prepareDelete("_all").get();
     assertThat(response.isAcknowledged()).isTrue();
 
-    client = new EsClient(new Profiling(new Settings()), node.client());
+    client = new EsClient(new Profiling(settings), node.client());
     client.start();
 
     if (!definitions.isEmpty()) {
@@ -118,6 +119,15 @@ public class EsTester extends ExternalResource {
       node.stop();
       node.close();
     }
+    settings = null;
+  }
+
+  /**
+   * Default level is NONE.
+   */
+  public EsTester setProfilingLevel(Profiling.Level level) {
+    settings.setProperty(Profiling.CONFIG_PROFILING_LEVEL, level.name());
+    return this;
   }
 
   public void truncateIndices() {
index d0e9e56dfd5df84d279f644dfe5ccfbab186f363..3b033f6646b0d018190a47ff92853b658b7c865e 100644 (file)
  */
 package org.sonar.server.es;
 
+import com.google.common.collect.ImmutableMap;
 import org.elasticsearch.cluster.metadata.IndexMetaData;
 
+import java.util.Map;
+
 public class FakeIndexDefinition implements IndexDefinition {
 
   public static final String INDEX = "fakes";
@@ -41,4 +44,8 @@ public class FakeIndexDefinition implements IndexDefinition {
     NewIndex.NewIndexType type = index.createType(TYPE);
     type.createIntegerField(INT_FIELD);
   }
+
+  public static Map<String,Object> newDoc(int value) {
+    return ImmutableMap.<String,Object>of(INT_FIELD, value);
+  }
 }
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyBulkRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyBulkRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..eee35ee
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.bulk.BulkRequestBuilder;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.elasticsearch.action.delete.DeleteRequest;
+import org.elasticsearch.action.index.IndexRequest;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.es.EsTester;
+import org.sonar.server.es.FakeIndexDefinition;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class ProxyBulkRequestBuilderTest {
+
+  @Rule
+  public EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition());
+
+  @Test
+  public void bulk() {
+    testBulk(Profiling.Level.NONE);
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    testBulk(Profiling.Level.BASIC);
+    // TODO assert profiling
+  }
+
+  private void testBulk(Profiling.Level profilingLevel) {
+    esTester.setProfilingLevel(profilingLevel);
+
+    BulkRequestBuilder req = esTester.client().prepareBulk();
+    req.add(new UpdateRequest(FakeIndexDefinition.INDEX, FakeIndexDefinition.TYPE, "key1")
+      .doc(FakeIndexDefinition.newDoc(1)));
+    req.add(new DeleteRequest(FakeIndexDefinition.INDEX, FakeIndexDefinition.TYPE, "key2"));
+    req.add(new IndexRequest(FakeIndexDefinition.INDEX, FakeIndexDefinition.TYPE, "key3")
+      .source(FakeIndexDefinition.newDoc(3)));
+
+    BulkResponse response = req.get();
+    assertThat(response.getItems()).hasSize(3);
+  }
+
+  @Test(expected = UnsupportedOperationException.class)
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    esTester.client().prepareBulk().get("1");
+  }
+
+  @Test(expected = UnsupportedOperationException.class)
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    esTester.client().prepareBulk().get(TimeValue.timeValueMinutes(1));
+  }
+
+  @Test(expected = UnsupportedOperationException.class)
+  public void execute_is_not_yet_implemented() throws Exception {
+    esTester.client().prepareBulk().execute();
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyClusterHealthRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyClusterHealthRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..3efdab6
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder;
+import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
+import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.es.EsTester;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyClusterHealthRequestBuilderTest {
+
+  @Rule
+  public EsTester esTester = new EsTester();
+
+  @Test
+  public void state() {
+    ClusterHealthRequestBuilder requestBuilder = esTester.client().prepareHealth();
+    ClusterHealthResponse state = requestBuilder.get();
+    assertThat(state.getStatus()).isEqualTo(ClusterHealthStatus.GREEN);
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(esTester.client().prepareHealth("rules").toString()).isEqualTo("ES cluster health request on indices 'rules'");
+    assertThat(esTester.client().prepareHealth().toString()).isEqualTo("ES cluster health request");
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    esTester.setProfilingLevel(Profiling.Level.BASIC);
+
+    ClusterHealthRequestBuilder requestBuilder = esTester.client().prepareHealth();
+    ClusterHealthResponse state = requestBuilder.get();
+    assertThat(state.getStatus()).isEqualTo(ClusterHealthStatus.GREEN);
+
+    // TODO assert profiling
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      esTester.client().prepareHealth().get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      esTester.client().prepareHealth().get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      esTester.client().prepareHealth().execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyClusterStateRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyClusterStateRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..58b11dd
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.admin.cluster.state.ClusterStateRequestBuilder;
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyClusterStateRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void state() {
+    try {
+      ClusterStateRequestBuilder requestBuilder = searchClient.prepareState();
+      requestBuilder.get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES cluster state request");
+    }
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(searchClient.prepareState().setIndices("rules").toString()).isEqualTo("ES cluster state request on indices 'rules'");
+    assertThat(searchClient.prepareState().toString()).isEqualTo("ES cluster state request");
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+    try {
+
+      ClusterStateRequestBuilder requestBuilder = searchClient.prepareState();
+      requestBuilder.get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES cluster state request");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareState().get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareState().get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareState().execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyClusterStatsRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyClusterStatsRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..b63fedb
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequestBuilder;
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyClusterStatsRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void stats() {
+    try {
+      ClusterStatsRequestBuilder requestBuilder = searchClient.prepareClusterStats();
+      requestBuilder.get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES cluster stats request");
+    }
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(searchClient.prepareClusterStats().setNodesIds("node1").toString()).isEqualTo("ES cluster stats request on nodes 'node1'");
+    assertThat(searchClient.prepareClusterStats().toString()).isEqualTo("ES cluster stats request");
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+    try {
+      ClusterStatsRequestBuilder requestBuilder = searchClient.prepareClusterStats();
+      requestBuilder.get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES cluster stats request");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareClusterStats().get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareClusterStats().get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareClusterStats().execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyCountRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyCountRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..206fb33
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.IndexDefinition;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyCountRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void count() {
+    try {
+      searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES count request on indices 'rules'");
+    }
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).setTypes("rule").toString()).isEqualTo("ES count request on indices 'rules' on types 'rule'");
+    assertThat(searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).toString()).isEqualTo("ES count request on indices 'rules'");
+    assertThat(searchClient.prepareCount().toString()).isEqualTo("ES count request");
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+    try {
+      searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES count request on indices 'rules'");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void fail_to_count_bad_query() throws Exception {
+    try {
+      searchClient.prepareCount("unknown_index1, unknown_index2").setTypes("unknown_type").get();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES count request on indices 'unknown_index1, unknown_index2' on types 'unknown_type'");
+    }
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyCreateIndexRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyCreateIndexRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..17e3e36
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyCreateIndexRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void create_index() {
+    try {
+      CreateIndexRequestBuilder requestBuilder = searchClient.prepareCreate("new");
+      requestBuilder.get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES create index 'new'");
+    }
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(searchClient.prepareCreate("new").toString()).isEqualTo("ES create index 'new'");
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+    try {
+      CreateIndexRequestBuilder requestBuilder = searchClient.prepareCreate("new");
+      requestBuilder.get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES create index 'new'");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareCreate("new").get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareCreate("new").get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareCreate("new").execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyDeleteByQueryRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyDeleteByQueryRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..bbb130f
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.IndexDefinition;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyDeleteByQueryRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void expect_failure() {
+    try {
+      searchClient.prepareDeleteByQuery(IndexDefinition.RULE.getIndexName()).setQuery(QueryBuilders.matchAllQuery()).get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES delete by query request on indices 'rules'");
+    }
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(searchClient.prepareDeleteByQuery(IndexDefinition.RULE.getIndexName()).toString()).isEqualTo("ES delete by query request on indices 'rules'");
+    assertThat(searchClient.prepareDeleteByQuery().toString()).isEqualTo("ES delete by query request");
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+    try {
+      searchClient.prepareDeleteByQuery(IndexDefinition.RULE.getIndexName()).setQuery(QueryBuilders.matchAllQuery()).get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES delete by query request on indices 'rules'");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareDeleteByQuery().get("1");
+      fail();
+    } catch (UnsupportedOperationException e) {
+      assertThat(e).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareDeleteByQuery().get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (UnsupportedOperationException e) {
+      assertThat(e).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareDeleteByQuery().execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyDeleteRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyDeleteRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..fe04a3d
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.es.request;
+
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyDeleteRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void expect_failure() {
+    try {
+      searchClient.prepareDelete("fakes", "fake", "the_id").get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES delete request of doc the_id in index fakes/fake");
+    }
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(searchClient.prepareDelete("fakes", "fake", "the_id").toString()).isEqualTo("ES delete request of doc the_id in index fakes/fake");
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+    try {
+      searchClient.prepareDelete("fakes", "fake", "the_id").get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES delete request of doc the_id in index fakes/fake");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareDelete("fakes", "fake", "the_id").get("1");
+      fail();
+    } catch (UnsupportedOperationException e) {
+      assertThat(e).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareDelete("fakes", "fake", "the_id").get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (UnsupportedOperationException e) {
+      assertThat(e).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareDelete("fakes", "fake", "the_id").execute();
+      fail();
+    } catch (UnsupportedOperationException e) {
+      assertThat(e).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyFlushRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyFlushRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..823e5c9
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.IndexDefinition;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyFlushRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void flush() {
+    try {
+      searchClient.prepareFlush(IndexDefinition.RULE.getIndexName()).get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES flush request on indices 'rules'");
+    }
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(searchClient.prepareFlush(IndexDefinition.RULE.getIndexName()).toString()).isEqualTo("ES flush request on indices 'rules'");
+    assertThat(searchClient.prepareFlush().toString()).isEqualTo("ES flush request");
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+    try {
+      searchClient.prepareFlush(IndexDefinition.RULE.getIndexName()).get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES flush request on indices 'rules'");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void fail_to_refresh() throws Exception {
+    try {
+      searchClient.prepareFlush("unknown").get();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES flush request on indices 'unknown'");
+    }
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareFlush(IndexDefinition.RULE.getIndexName()).get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareFlush(IndexDefinition.RULE.getIndexName()).get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareFlush(IndexDefinition.RULE.getIndexName()).execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyGetRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyGetRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..318d890
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.get.GetRequestBuilder;
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.IndexDefinition;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyGetRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void get() {
+    try {
+      searchClient.prepareGet()
+        .setIndex(IndexDefinition.RULE.getIndexName())
+        .setType(IndexDefinition.RULE.getIndexType())
+        .setId("ruleKey")
+        .get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES get request for key 'ruleKey' on index 'rules' on type 'rule'");
+    }
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+    try {
+      searchClient.prepareGet()
+        .setIndex(IndexDefinition.RULE.getIndexName())
+        .setType(IndexDefinition.RULE.getIndexType())
+        .setId("ruleKey")
+        .get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES get request for key 'ruleKey' on index 'rules' on type 'rule'");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void fail_to_get_bad_query() throws Exception {
+    GetRequestBuilder requestBuilder = searchClient.prepareGet()
+      .setIndex("unknown")
+      .setType("test")
+      .setId("rule1");
+    try {
+      requestBuilder.get();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES get request for key 'rule1' on index 'unknown' on type 'test'");
+    }
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareGet().get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareGet().get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareGet().execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyIndexRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyIndexRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..be8854a
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.index.IndexRequestBuilder;
+import org.elasticsearch.action.index.IndexResponse;
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.es.EsTester;
+import org.sonar.server.es.FakeIndexDefinition;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyIndexRequestBuilderTest {
+
+  @Rule
+  public EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition());
+
+  @Test
+  public void index_with_index_type_and_id() {
+    IndexResponse response = esTester.client().prepareIndex(FakeIndexDefinition.INDEX, FakeIndexDefinition.TYPE)
+      .setSource(FakeIndexDefinition.newDoc(42))
+      .get();
+    assertThat(response.isCreated()).isTrue();
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    esTester.setProfilingLevel(Profiling.Level.BASIC);
+    IndexResponse response = esTester.client().prepareIndex(FakeIndexDefinition.INDEX, FakeIndexDefinition.TYPE)
+      .setSource(FakeIndexDefinition.newDoc(42))
+      .get();
+    assertThat(response.isCreated()).isTrue();
+    // TODO assert profiling
+  }
+
+  @Test
+  public void fail_if_bad_query() throws Exception {
+    IndexRequestBuilder requestBuilder = esTester.client().prepareIndex("unknownIndex", "unknownType");
+    try {
+      requestBuilder.get();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES index request for key 'null' on index 'unknownIndex' on type 'unknownType'");
+    }
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      esTester.client().prepareIndex(FakeIndexDefinition.INDEX, FakeIndexDefinition.TYPE).get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      esTester.client().prepareIndex(FakeIndexDefinition.INDEX, FakeIndexDefinition.TYPE).get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void do_not_support_execute_method() throws Exception {
+    try {
+      esTester.client().prepareIndex(FakeIndexDefinition.INDEX, FakeIndexDefinition.TYPE).execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyIndicesExistsRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyIndicesExistsRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..3fd4bc1
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.IndexDefinition;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyIndicesExistsRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void exists() {
+    try {
+      searchClient.prepareIndicesExist(IndexDefinition.RULE.getIndexName()).get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES indices exists request on indices 'rules'");
+    }
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+    try {
+      searchClient.prepareIndicesExist(IndexDefinition.RULE.getIndexName()).get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES indices exists request on indices 'rules'");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void fail_to_exists() throws Exception {
+    try {
+      searchClient.prepareIndicesExist().get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES indices exists request");
+    }
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(searchClient.prepareIndicesExist(IndexDefinition.RULE.getIndexName()).toString()).isEqualTo("ES indices exists request on indices 'rules'");
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareIndicesExist().get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareIndicesExist().get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareIndicesExist().execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyIndicesStatsRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyIndicesStatsRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..70509ad
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.IndexDefinition;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyIndicesStatsRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void stats() {
+    try {
+      searchClient.prepareStats(IndexDefinition.RULE.getIndexName()).get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES indices stats request on indices 'rules'");
+    }
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(searchClient.prepareStats(IndexDefinition.RULE.getIndexName()).setIndices("rules").toString()).isEqualTo("ES indices stats request on indices 'rules'");
+    assertThat(searchClient.prepareStats().toString()).isEqualTo("ES indices stats request");
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+    try {
+      searchClient.prepareStats(IndexDefinition.RULE.getIndexName()).get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (IllegalStateException e) {
+      assertThat(e.getMessage()).isEqualTo("Fail to execute ES indices stats request on indices 'rules'");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void fail_to_stats() throws Exception {
+    try {
+      searchClient.prepareStats("unknown").get();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES indices stats request on indices 'unknown'");
+    }
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareStats(IndexDefinition.RULE.getIndexName()).get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareStats(IndexDefinition.RULE.getIndexName()).get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareStats(IndexDefinition.RULE.getIndexName()).execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyMultiGetRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyMultiGetRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..3d78ed4
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.get.MultiGetRequest;
+import org.elasticsearch.action.get.MultiGetRequestBuilder;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.search.fetch.source.FetchSourceContext;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.IndexDefinition;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyMultiGetRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void multi_get() {
+    try {
+      MultiGetRequestBuilder request = searchClient.prepareMultiGet();
+      request.add(new MultiGetRequest.Item(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), "ruleKey")
+        .fetchSourceContext(FetchSourceContext.FETCH_SOURCE));
+      request.get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES multi get request");
+    }
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(searchClient.prepareMultiGet().toString()).isEqualTo("ES multi get request");
+    assertThat(searchClient.prepareMultiGet().add(new MultiGetRequest.Item(IndexDefinition.RULE.getIndexName(), null, "ruleKey")
+      .fetchSourceContext(FetchSourceContext.FETCH_SOURCE)).toString()).isEqualTo("ES multi get request [key 'ruleKey', index 'rules'],");
+    assertThat(searchClient.prepareMultiGet().add(new MultiGetRequest.Item(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), "ruleKey")
+      .fetchSourceContext(FetchSourceContext.FETCH_SOURCE)).toString()).isEqualTo("ES multi get request [key 'ruleKey', index 'rules', type 'rule'],");
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+    try {
+      MultiGetRequestBuilder request = searchClient.prepareMultiGet();
+      request.add(new MultiGetRequest.Item(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), "ruleKey")
+        .fetchSourceContext(FetchSourceContext.FETCH_SOURCE));
+      request.get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES multi get request");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareMultiGet().get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareMultiGet().get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareMultiGet().execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyNodesStatsRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyNodesStatsRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..765a91e
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.IndexDefinition;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyNodesStatsRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void stats() {
+    try {
+      searchClient.prepareNodesStats().get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES nodes stats request");
+    }
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(searchClient.prepareNodesStats().setNodesIds("node1").toString()).isEqualTo("ES nodes stats request on nodes 'node1'");
+    assertThat(searchClient.prepareNodesStats().toString()).isEqualTo("ES nodes stats request");
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+    try {
+      searchClient.prepareNodesStats().get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES nodes stats request");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareNodesStats(IndexDefinition.RULE.getIndexName()).get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareNodesStats(IndexDefinition.RULE.getIndexName()).get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareNodesStats(IndexDefinition.RULE.getIndexName()).execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyPutMappingRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyPutMappingRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..d3cb2bb
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import com.google.common.collect.ImmutableMap;
+import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder;
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.IndexDefinition;
+import org.sonar.server.search.SearchClient;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyPutMappingRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void put_mapping() {
+    try {
+      PutMappingRequestBuilder requestBuilder = searchClient.preparePutMapping(IndexDefinition.RULE.getIndexName())
+        .setType(IndexDefinition.RULE.getIndexType())
+        .setIgnoreConflicts(true)
+        .setSource(mapDomain());
+      requestBuilder.get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES put mapping request");
+    }
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(searchClient.preparePutMapping(IndexDefinition.RULE.getIndexName()).setSource(mapDomain()).toString())
+      .isEqualTo("ES put mapping request on indices 'rules' with source '{\"dynamic\":false,\"_all\":{\"enabled\":false}}'");
+    assertThat(searchClient.preparePutMapping(IndexDefinition.RULE.getIndexName()).setType(IndexDefinition.RULE.getIndexType()).setSource(mapDomain()).toString())
+      .isEqualTo("ES put mapping request on indices 'rules' on type 'rule' with source '{\"dynamic\":false,\"_all\":{\"enabled\":false}}'");
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+    try {
+      PutMappingRequestBuilder requestBuilder = searchClient.preparePutMapping(IndexDefinition.RULE.getIndexName())
+        .setType(IndexDefinition.RULE.getIndexType())
+        .setIgnoreConflicts(true)
+        .setSource(mapDomain());
+      requestBuilder.get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES put mapping request");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void fail_on_bad_query() throws Exception {
+    try {
+      searchClient.preparePutMapping().get();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES put mapping request");
+    }
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.preparePutMapping().get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.preparePutMapping().get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.preparePutMapping().execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+  protected static Map mapDomain() {
+    Map<String, Object> mapping = new HashMap<String, Object>();
+    mapping.put("dynamic", false);
+    mapping.put("_all", ImmutableMap.of("enabled", false));
+    return mapping;
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyRefreshRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyRefreshRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..b8be869
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder;
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.IndexDefinition;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxyRefreshRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void refresh() {
+    try {
+      RefreshRequestBuilder requestBuilder = searchClient.prepareRefresh(IndexDefinition.RULE.getIndexName());
+      requestBuilder.get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES refresh request on indices 'rules'");
+    }
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(searchClient.prepareRefresh(IndexDefinition.RULE.getIndexName()).toString()).isEqualTo("ES refresh request on indices 'rules'");
+    assertThat(searchClient.prepareRefresh().toString()).isEqualTo("ES refresh request");
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+    try {
+      RefreshRequestBuilder requestBuilder = searchClient.prepareRefresh(IndexDefinition.RULE.getIndexName());
+      requestBuilder.get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES refresh request on indices 'rules'");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void fail_to_refresh() throws Exception {
+    try {
+      searchClient.prepareRefresh("unknown").get();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES refresh request on indices 'unknown'");
+    }
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareRefresh(IndexDefinition.RULE.getIndexName()).get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareRefresh(IndexDefinition.RULE.getIndexName()).get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareRefresh(IndexDefinition.RULE.getIndexName()).execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxySearchRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxySearchRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..3d3ce02
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.IndexDefinition;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxySearchRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void search() {
+    try {
+      searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES search request '{").contains("}' on indices '[rules]'");
+    }
+  }
+
+  @Test
+  public void to_string() {
+    assertThat(searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).setTypes("rule").toString()).contains("ES search request '").contains(
+      "' on indices '[rules]' on types '[rule]'");
+    assertThat(searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).toString()).contains("ES search request '").contains("' on indices '[rules]'");
+    assertThat(searchClient.prepareSearch().toString()).contains("ES search request");
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+    try {
+      searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES search request '{").contains("}' on indices '[rules]'");
+    }
+
+    // TODO assert profiling
+    searchClient.stop();
+  }
+
+  @Test
+  public void fail_to_search_bad_query() throws Exception {
+    try {
+      searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).setQuery("bad query").get();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES search request '{").contains("}' on indices '[rules]'");
+    }
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxySearchScrollRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/request/ProxySearchScrollRequestBuilderTest.java
new file mode 100644 (file)
index 0000000..3192b2e
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.es.request;
+
+import org.elasticsearch.common.unit.TimeValue;
+import org.junit.After;
+import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.core.profiling.Profiling;
+import org.sonar.server.search.SearchClient;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
+
+public class ProxySearchScrollRequestBuilderTest {
+
+  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
+  SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+  @After
+  public void tearDown() throws Exception {
+    searchClient.stop();
+  }
+
+  @Test
+  public void search_scroll() {
+    try {
+      searchClient.prepareSearchScroll("scrollId").get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES search scroll request for scroll id 'null'");
+    }
+  }
+
+  @Test
+  public void with_profiling_basic() {
+    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+    SearchClient searchClient = new SearchClient(new Settings(), profiling);
+    try {
+      searchClient.prepareSearchScroll("scrollId").get();
+
+      // expected to fail because elasticsearch is not correctly configured, but that does not matter
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES search scroll request for scroll id 'null'");
+    }
+    searchClient.stop();
+  }
+
+  @Test
+  public void fail_to_search_bad_query() throws Exception {
+    try {
+      searchClient.prepareSearchScroll("unknown").get();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class);
+      assertThat(e.getMessage()).contains("Fail to execute ES search scroll request for scroll id 'null'");
+    }
+  }
+
+  @Test
+  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareSearchScroll("scrollId").get("1");
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
+    try {
+      searchClient.prepareSearchScroll("scrollId").get(TimeValue.timeValueMinutes(1));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
+    }
+  }
+
+  @Test
+  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
+    try {
+      searchClient.prepareSearchScroll("scrollId").execute();
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
+    }
+  }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyBulkRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyBulkRequestBuilderTest.java
deleted file mode 100644 (file)
index 929cff7..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.bulk.BulkRequestBuilder;
-import org.elasticsearch.action.delete.DeleteRequest;
-import org.elasticsearch.action.index.IndexRequest;
-import org.elasticsearch.action.update.UpdateRequest;
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.SearchClient;
-
-import java.util.Collections;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyBulkRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void bulk() {
-    BulkRequestBuilder bulkRequestBuilder = searchClient.prepareBulk();
-    bulkRequestBuilder.add(new UpdateRequest(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexName(), "rule1").doc(Collections.emptyMap()));
-    bulkRequestBuilder.add(new DeleteRequest(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexName(), "rule1"));
-    bulkRequestBuilder.add(new IndexRequest(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexName(), "rule1").source(Collections.emptyMap()));
-    try {
-      bulkRequestBuilder.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage())
-        .contains("Fail to execute ES bulk request for [Action 'UpdateRequest' for key 'rule1' on index 'rules' on type 'rules'],")
-        .contains("[Action 'DeleteRequest' for key 'rule1' on index 'rules' on type 'rules'],")
-        .contains("[Action 'IndexRequest' for key 'rule1' on index 'rules' on type 'rules'],");
-    }
-
-    // TODO assert profiling
-  }
-
-  @Test
-  public void to_string() {
-    BulkRequestBuilder bulkRequestBuilder = searchClient.prepareBulk();
-    bulkRequestBuilder.add(new UpdateRequest(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexName(), "rule1").doc(Collections.emptyMap()));
-    bulkRequestBuilder.add(new DeleteRequest(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexName(), "rule1"));
-    bulkRequestBuilder.add(new IndexRequest(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexName(), "rule1").source(Collections.emptyMap()));
-
-    assertThat(bulkRequestBuilder.toString()).contains("ES bulk request for [Action 'UpdateRequest' for key 'rule1' on index 'rules' on type 'rules'],")
-      .contains("[Action 'DeleteRequest' for key 'rule1' on index 'rules' on type 'rules'],")
-      .contains("[Action 'IndexRequest' for key 'rule1' on index 'rules' on type 'rules'],");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    BulkRequestBuilder bulkRequestBuilder = searchClient.prepareBulk();
-    bulkRequestBuilder.add(new UpdateRequest(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexName(), "rule1").doc(Collections.emptyMap()));
-    bulkRequestBuilder.add(new DeleteRequest(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexName(), "rule1"));
-    bulkRequestBuilder.add(new IndexRequest(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexName(), "rule1").source(Collections.emptyMap()));
-    try {
-      bulkRequestBuilder.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage())
-        .contains("Fail to execute ES bulk request for [Action 'UpdateRequest' for key 'rule1' on index 'rules' on type 'rules'],")
-        .contains("[Action 'DeleteRequest' for key 'rule1' on index 'rules' on type 'rules'],")
-        .contains("[Action 'IndexRequest' for key 'rule1' on index 'rules' on type 'rules'],");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    searchClient.prepareBulk().get("1");
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    searchClient.prepareBulk().get(TimeValue.timeValueMinutes(1));
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void execute_is_not_yet_implemented() throws Exception {
-    searchClient.prepareBulk().execute();
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterHealthRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterHealthRequestBuilderTest.java
deleted file mode 100644 (file)
index 94a6f75..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder;
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyClusterHealthRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void state() {
-    try {
-      ClusterHealthRequestBuilder requestBuilder = searchClient.prepareHealth();
-      requestBuilder.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES cluster health request");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.prepareHealth("rules").toString()).isEqualTo("ES cluster health request on indices 'rules'");
-    assertThat(searchClient.prepareHealth().toString()).isEqualTo("ES cluster health request");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      ClusterHealthRequestBuilder requestBuilder = searchClient.prepareHealth();
-      requestBuilder.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES cluster health request");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareHealth().get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareHealth().get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareHealth().execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStateRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStateRequestBuilderTest.java
deleted file mode 100644 (file)
index adb934c..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.admin.cluster.state.ClusterStateRequestBuilder;
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyClusterStateRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void state() {
-    try {
-      ClusterStateRequestBuilder requestBuilder = searchClient.prepareState();
-      requestBuilder.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES cluster state request");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.prepareState().setIndices("rules").toString()).isEqualTo("ES cluster state request on indices 'rules'");
-    assertThat(searchClient.prepareState().toString()).isEqualTo("ES cluster state request");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-    try {
-
-      ClusterStateRequestBuilder requestBuilder = searchClient.prepareState();
-      requestBuilder.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES cluster state request");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareState().get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareState().get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareState().execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStatsRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStatsRequestBuilderTest.java
deleted file mode 100644 (file)
index d7263de..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequestBuilder;
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyClusterStatsRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void stats() {
-    try {
-      ClusterStatsRequestBuilder requestBuilder = searchClient.prepareClusterStats();
-      requestBuilder.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES cluster stats request");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.prepareClusterStats().setNodesIds("node1").toString()).isEqualTo("ES cluster stats request on nodes 'node1'");
-    assertThat(searchClient.prepareClusterStats().toString()).isEqualTo("ES cluster stats request");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      ClusterStatsRequestBuilder requestBuilder = searchClient.prepareClusterStats();
-      requestBuilder.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES cluster stats request");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareClusterStats().get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareClusterStats().get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareClusterStats().execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCountRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCountRequestBuilderTest.java
deleted file mode 100644 (file)
index 8b37cb6..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyCountRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void count() {
-    try {
-      searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES count request on indices 'rules'");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).setTypes("rule").toString()).isEqualTo("ES count request on indices 'rules' on types 'rule'");
-    assertThat(searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).toString()).isEqualTo("ES count request on indices 'rules'");
-    assertThat(searchClient.prepareCount().toString()).isEqualTo("ES count request");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES count request on indices 'rules'");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void fail_to_count_bad_query() throws Exception {
-    try {
-      searchClient.prepareCount("unknown_index1, unknown_index2").setTypes("unknown_type").get();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES count request on indices 'unknown_index1, unknown_index2' on types 'unknown_type'");
-    }
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCreateIndexRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCreateIndexRequestBuilderTest.java
deleted file mode 100644 (file)
index a083c03..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyCreateIndexRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void create_index() {
-    try {
-      CreateIndexRequestBuilder requestBuilder = searchClient.prepareCreate("new");
-      requestBuilder.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES create index 'new'");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.prepareCreate("new").toString()).isEqualTo("ES create index 'new'");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      CreateIndexRequestBuilder requestBuilder = searchClient.prepareCreate("new");
-      requestBuilder.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES create index 'new'");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareCreate("new").get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareCreate("new").get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareCreate("new").execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyDeleteByQueryRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyDeleteByQueryRequestBuilderTest.java
deleted file mode 100644 (file)
index 48bad69..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.index.query.QueryBuilders;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyDeleteByQueryRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void expect_failure() {
-    try {
-      searchClient.prepareDeleteByQuery(IndexDefinition.RULE.getIndexName()).setQuery(QueryBuilders.matchAllQuery()).get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES delete by query request on indices 'rules'");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.prepareDeleteByQuery(IndexDefinition.RULE.getIndexName()).toString()).isEqualTo("ES delete by query request on indices 'rules'");
-    assertThat(searchClient.prepareDeleteByQuery().toString()).isEqualTo("ES delete by query request");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      searchClient.prepareDeleteByQuery(IndexDefinition.RULE.getIndexName()).setQuery(QueryBuilders.matchAllQuery()).get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES delete by query request on indices 'rules'");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareDeleteByQuery().get("1");
-      fail();
-    } catch (UnsupportedOperationException e) {
-      assertThat(e).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareDeleteByQuery().get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (UnsupportedOperationException e) {
-      assertThat(e).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareDeleteByQuery().execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyDeleteRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyDeleteRequestBuilderTest.java
deleted file mode 100644 (file)
index ec6897e..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.search.request;
-
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyDeleteRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void expect_failure() {
-    try {
-      searchClient.prepareDelete("fakes", "fake", "the_id").get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES delete request of doc the_id in index fakes/fake");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.prepareDelete("fakes", "fake", "the_id").toString()).isEqualTo("ES delete request of doc the_id in index fakes/fake");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      searchClient.prepareDelete("fakes", "fake", "the_id").get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES delete request of doc the_id in index fakes/fake");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareDelete("fakes", "fake", "the_id").get("1");
-      fail();
-    } catch (UnsupportedOperationException e) {
-      assertThat(e).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareDelete("fakes", "fake", "the_id").get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (UnsupportedOperationException e) {
-      assertThat(e).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareDelete("fakes", "fake", "the_id").execute();
-      fail();
-    } catch (UnsupportedOperationException e) {
-      assertThat(e).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyFlushRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyFlushRequestBuilderTest.java
deleted file mode 100644 (file)
index 7f4b3cb..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyFlushRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void flush() {
-    try {
-      searchClient.prepareFlush(IndexDefinition.RULE.getIndexName()).get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES flush request on indices 'rules'");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.prepareFlush(IndexDefinition.RULE.getIndexName()).toString()).isEqualTo("ES flush request on indices 'rules'");
-    assertThat(searchClient.prepareFlush().toString()).isEqualTo("ES flush request");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      searchClient.prepareFlush(IndexDefinition.RULE.getIndexName()).get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES flush request on indices 'rules'");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void fail_to_refresh() throws Exception {
-    try {
-      searchClient.prepareFlush("unknown").get();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES flush request on indices 'unknown'");
-    }
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareFlush(IndexDefinition.RULE.getIndexName()).get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareFlush(IndexDefinition.RULE.getIndexName()).get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareFlush(IndexDefinition.RULE.getIndexName()).execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyGetRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyGetRequestBuilderTest.java
deleted file mode 100644 (file)
index 07c5c75..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.get.GetRequestBuilder;
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyGetRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void get() {
-    try {
-      searchClient.prepareGet()
-        .setIndex(IndexDefinition.RULE.getIndexName())
-        .setType(IndexDefinition.RULE.getIndexType())
-        .setId("ruleKey")
-        .get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES get request for key 'ruleKey' on index 'rules' on type 'rule'");
-    }
-  }
-
-  @Test
-  public void get_with_index_type_and_id() {
-    try {
-      searchClient.prepareGet(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), "ruleKey").get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES get request for key 'ruleKey' on index 'rules' on type 'rule'");
-    }
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      searchClient.prepareGet()
-        .setIndex(IndexDefinition.RULE.getIndexName())
-        .setType(IndexDefinition.RULE.getIndexType())
-        .setId("ruleKey")
-        .get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES get request for key 'ruleKey' on index 'rules' on type 'rule'");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void fail_to_get_bad_query() throws Exception {
-    GetRequestBuilder requestBuilder = searchClient.prepareGet()
-      .setIndex("unknown")
-      .setType("test")
-      .setId("rule1");
-    try {
-      requestBuilder.get();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES get request for key 'rule1' on index 'unknown' on type 'test'");
-    }
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareGet().get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareGet().get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareGet().execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndexRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndexRequestBuilderTest.java
deleted file mode 100644 (file)
index 61625f9..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.index.IndexRequestBuilder;
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyIndexRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void index_with_index_type_and_id() {
-    try {
-      searchClient.prepareIndex(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), "ruleKey").get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES index request for key 'ruleKey' on index 'rules' on type 'rule'");
-    }
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      searchClient.prepareIndex()
-        .setIndex(IndexDefinition.RULE.getIndexName())
-        .setType(IndexDefinition.RULE.getIndexType())
-        .setId("ruleKey")
-        .get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES index request for key 'ruleKey' on index 'rules' on type 'rule'");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void fail_to_get_bad_query() throws Exception {
-    IndexRequestBuilder requestBuilder = searchClient.prepareIndex()
-      .setIndex("unknown")
-      .setType("test")
-      .setId("rule1");
-    try {
-      requestBuilder.get();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES index request for key 'rule1' on index 'unknown' on type 'test'");
-    }
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareIndex().get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareIndex().get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareIndex().execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesExistsRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesExistsRequestBuilderTest.java
deleted file mode 100644 (file)
index 175dc30..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyIndicesExistsRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void exists() {
-    try {
-      searchClient.prepareExists(IndexDefinition.RULE.getIndexName()).get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES indices exists request on indices 'rules'");
-    }
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      searchClient.prepareExists(IndexDefinition.RULE.getIndexName()).get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES indices exists request on indices 'rules'");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void fail_to_exists() throws Exception {
-    try {
-      searchClient.prepareExists().get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES indices exists request");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.prepareExists(IndexDefinition.RULE.getIndexName()).toString()).isEqualTo("ES indices exists request on indices 'rules'");
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareExists().get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareExists().get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareExists().execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesStatsRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesStatsRequestBuilderTest.java
deleted file mode 100644 (file)
index f7d1977..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyIndicesStatsRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void stats() {
-    try {
-      searchClient.prepareStats(IndexDefinition.RULE.getIndexName()).get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES indices stats request on indices 'rules'");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.prepareStats(IndexDefinition.RULE.getIndexName()).setIndices("rules").toString()).isEqualTo("ES indices stats request on indices 'rules'");
-    assertThat(searchClient.prepareStats().toString()).isEqualTo("ES indices stats request");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      searchClient.prepareStats(IndexDefinition.RULE.getIndexName()).get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Fail to execute ES indices stats request on indices 'rules'");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void fail_to_stats() throws Exception {
-    try {
-      searchClient.prepareStats("unknown").get();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES indices stats request on indices 'unknown'");
-    }
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareStats(IndexDefinition.RULE.getIndexName()).get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareStats(IndexDefinition.RULE.getIndexName()).get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareStats(IndexDefinition.RULE.getIndexName()).execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilderTest.java
deleted file mode 100644 (file)
index e581c86..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.get.MultiGetRequest;
-import org.elasticsearch.action.get.MultiGetRequestBuilder;
-import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.search.fetch.source.FetchSourceContext;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyMultiGetRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void multi_get() {
-    try {
-      MultiGetRequestBuilder request = searchClient.prepareMultiGet();
-      request.add(new MultiGetRequest.Item(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), "ruleKey")
-        .fetchSourceContext(FetchSourceContext.FETCH_SOURCE));
-      request.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES multi get request");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.prepareMultiGet().toString()).isEqualTo("ES multi get request");
-    assertThat(searchClient.prepareMultiGet().add(new MultiGetRequest.Item(IndexDefinition.RULE.getIndexName(), null, "ruleKey")
-      .fetchSourceContext(FetchSourceContext.FETCH_SOURCE)).toString()).isEqualTo("ES multi get request [key 'ruleKey', index 'rules'],");
-    assertThat(searchClient.prepareMultiGet().add(new MultiGetRequest.Item(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), "ruleKey")
-      .fetchSourceContext(FetchSourceContext.FETCH_SOURCE)).toString()).isEqualTo("ES multi get request [key 'ruleKey', index 'rules', type 'rule'],");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      MultiGetRequestBuilder request = searchClient.prepareMultiGet();
-      request.add(new MultiGetRequest.Item(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), "ruleKey")
-        .fetchSourceContext(FetchSourceContext.FETCH_SOURCE));
-      request.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES multi get request");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareMultiGet().get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareMultiGet().get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareMultiGet().execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyNodesStatsRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyNodesStatsRequestBuilderTest.java
deleted file mode 100644 (file)
index 27c8cd4..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyNodesStatsRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void stats() {
-    try {
-      searchClient.prepareNodesStats().get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES nodes stats request");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.prepareNodesStats().setNodesIds("node1").toString()).isEqualTo("ES nodes stats request on nodes 'node1'");
-    assertThat(searchClient.prepareNodesStats().toString()).isEqualTo("ES nodes stats request");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      searchClient.prepareNodesStats().get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES nodes stats request");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareNodesStats(IndexDefinition.RULE.getIndexName()).get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareNodesStats(IndexDefinition.RULE.getIndexName()).get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareNodesStats(IndexDefinition.RULE.getIndexName()).execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyPutMappingRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyPutMappingRequestBuilderTest.java
deleted file mode 100644 (file)
index 386c83e..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import com.google.common.collect.ImmutableMap;
-import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder;
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.SearchClient;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyPutMappingRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void put_mapping() {
-    try {
-      PutMappingRequestBuilder requestBuilder = searchClient.preparePutMapping(IndexDefinition.RULE.getIndexName())
-        .setType(IndexDefinition.RULE.getIndexType())
-        .setIgnoreConflicts(true)
-        .setSource(mapDomain());
-      requestBuilder.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES put mapping request");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.preparePutMapping(IndexDefinition.RULE.getIndexName()).setSource(mapDomain()).toString())
-      .isEqualTo("ES put mapping request on indices 'rules' with source '{\"dynamic\":false,\"_all\":{\"enabled\":false}}'");
-    assertThat(searchClient.preparePutMapping(IndexDefinition.RULE.getIndexName()).setType(IndexDefinition.RULE.getIndexType()).setSource(mapDomain()).toString())
-      .isEqualTo("ES put mapping request on indices 'rules' on type 'rule' with source '{\"dynamic\":false,\"_all\":{\"enabled\":false}}'");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      PutMappingRequestBuilder requestBuilder = searchClient.preparePutMapping(IndexDefinition.RULE.getIndexName())
-        .setType(IndexDefinition.RULE.getIndexType())
-        .setIgnoreConflicts(true)
-        .setSource(mapDomain());
-      requestBuilder.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES put mapping request");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void fail_on_bad_query() throws Exception {
-    try {
-      searchClient.preparePutMapping().get();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES put mapping request");
-    }
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.preparePutMapping().get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.preparePutMapping().get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.preparePutMapping().execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-  protected static Map mapDomain() {
-    Map<String, Object> mapping = new HashMap<String, Object>();
-    mapping.put("dynamic", false);
-    mapping.put("_all", ImmutableMap.of("enabled", false));
-    return mapping;
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyRefreshRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyRefreshRequestBuilderTest.java
deleted file mode 100644 (file)
index b68f596..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder;
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxyRefreshRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void refresh() {
-    try {
-      RefreshRequestBuilder requestBuilder = searchClient.prepareRefresh(IndexDefinition.RULE.getIndexName());
-      requestBuilder.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES refresh request on indices 'rules'");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.prepareRefresh(IndexDefinition.RULE.getIndexName()).toString()).isEqualTo("ES refresh request on indices 'rules'");
-    assertThat(searchClient.prepareRefresh().toString()).isEqualTo("ES refresh request");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      RefreshRequestBuilder requestBuilder = searchClient.prepareRefresh(IndexDefinition.RULE.getIndexName());
-      requestBuilder.get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES refresh request on indices 'rules'");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void fail_to_refresh() throws Exception {
-    try {
-      searchClient.prepareRefresh("unknown").get();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES refresh request on indices 'unknown'");
-    }
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareRefresh(IndexDefinition.RULE.getIndexName()).get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareRefresh(IndexDefinition.RULE.getIndexName()).get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareRefresh(IndexDefinition.RULE.getIndexName()).execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchRequestBuilderTest.java
deleted file mode 100644 (file)
index 011ed41..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.IndexDefinition;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxySearchRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void search() {
-    try {
-      searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES search request '{").contains("}' on indices '[rules]'");
-    }
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).setTypes("rule").toString()).contains("ES search request '").contains(
-      "' on indices '[rules]' on types '[rule]'");
-    assertThat(searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).toString()).contains("ES search request '").contains("' on indices '[rules]'");
-    assertThat(searchClient.prepareSearch().toString()).contains("ES search request");
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-    try {
-      searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES search request '{").contains("}' on indices '[rules]'");
-    }
-
-    // TODO assert profiling
-    searchClient.stop();
-  }
-
-  @Test
-  public void fail_to_search_bad_query() throws Exception {
-    try {
-      searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).setQuery("bad query").get();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES search request '{").contains("}' on indices '[rules]'");
-    }
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilderTest.java
deleted file mode 100644 (file)
index 773e324..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.server.search.request;
-
-import org.elasticsearch.common.unit.TimeValue;
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.core.profiling.Profiling;
-import org.sonar.server.search.SearchClient;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class ProxySearchScrollRequestBuilderTest {
-
-  Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.NONE.name()));
-  SearchClient searchClient = new SearchClient(new Settings(), profiling);
-
-  @After
-  public void tearDown() throws Exception {
-    searchClient.stop();
-  }
-
-  @Test
-  public void search_scroll() {
-    try {
-      searchClient.prepareSearchScroll("scrollId").get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES search scroll request for scroll id 'null'");
-    }
-  }
-
-  @Test
-  public void with_profiling_basic() {
-    Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
-    SearchClient searchClient = new SearchClient(new Settings(), profiling);
-    try {
-      searchClient.prepareSearchScroll("scrollId").get();
-
-      // expected to fail because elasticsearch is not correctly configured, but that does not matter
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES search scroll request for scroll id 'null'");
-    }
-    searchClient.stop();
-  }
-
-  @Test
-  public void fail_to_search_bad_query() throws Exception {
-    try {
-      searchClient.prepareSearchScroll("unknown").get();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class);
-      assertThat(e.getMessage()).contains("Fail to execute ES search scroll request for scroll id 'null'");
-    }
-  }
-
-  @Test
-  public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareSearchScroll("scrollId").get("1");
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void get_with_time_value_timeout_is_not_yet_implemented() throws Exception {
-    try {
-      searchClient.prepareSearchScroll("scrollId").get(TimeValue.timeValueMinutes(1));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("Not yet implemented");
-    }
-  }
-
-  @Test
-  public void execute_should_throw_an_unsupported_operation_exception() throws Exception {
-    try {
-      searchClient.prepareSearchScroll("scrollId").execute();
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
-    }
-  }
-}