From 8856565b895dcdb1607447f955051f268b329380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Fri, 5 Aug 2016 13:48:46 +0200 Subject: [PATCH] Make RankEvalRequestTests work with transport client --- .../index/rankeval/RankEvalAction.java | 4 +-- .../index/rankeval/RankEvalResponse.java | 25 +++++++++++-------- .../index/rankeval/RankEvalSpec.java | 2 +- .../index/rankeval/RankEvalRequestTests.java | 3 +-- .../org/elasticsearch/test/TestCluster.java | 1 + 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalAction.java b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalAction.java index 0f506112d65..b095e948fa9 100644 --- a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalAction.java +++ b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalAction.java @@ -22,8 +22,8 @@ package org.elasticsearch.index.rankeval; import org.elasticsearch.action.Action; import org.elasticsearch.client.ElasticsearchClient; -/** - * Action used to start precision at qa evaluations. +/** + * Action used to start precision at qa evaluations. **/ public class RankEvalAction extends Action { diff --git a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalResponse.java b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalResponse.java index 140d60024cb..173357b9311 100644 --- a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalResponse.java +++ b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalResponse.java @@ -51,12 +51,8 @@ public class RankEvalResponse extends ActionResponse implements ToXContent { public RankEvalResponse() { } - @SuppressWarnings("unchecked") public RankEvalResponse(StreamInput in) throws IOException { - super.readFrom(in); - this.specId = in.readString(); - this.qualityLevel = in.readDouble(); - this.unknownDocs = (Map>) in.readGenericValue(); + this.readFrom(in); } public RankEvalResponse(String specId, double qualityLevel, Map> unknownDocs) { @@ -65,7 +61,8 @@ public class RankEvalResponse extends ActionResponse implements ToXContent { this.unknownDocs = unknownDocs; } - public String getSpecId() { + + public Object getSpecId() { return specId; } @@ -79,17 +76,26 @@ public class RankEvalResponse extends ActionResponse implements ToXContent { @Override public String toString() { - return "RankEvalResult, ID :[" + specId + "], quality: " + qualityLevel + ", unknown docs: " + unknownDocs; + return "RankEvalResponse, ID :[" + specId + "], quality: " + qualityLevel + ", unknown docs: " + unknownDocs; } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeString(specId); - out.writeDouble(qualityLevel); + out.writeOptionalString(specId); + out.writeOptionalDouble(qualityLevel); out.writeGenericValue(getUnknownDocs()); } + @Override + @SuppressWarnings("unchecked") + public void readFrom(StreamInput in) throws IOException { + super.readFrom(in); + this.specId = in.readOptionalString(); + this.qualityLevel = in.readOptionalDouble(); + this.unknownDocs = (Map>) in.readGenericValue(); + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("rank_eval"); @@ -105,5 +111,4 @@ public class RankEvalResponse extends ActionResponse implements ToXContent { builder.endObject(); return builder; } - } diff --git a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalSpec.java b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalSpec.java index 71f65c43882..8f3f27a792e 100644 --- a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalSpec.java +++ b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalSpec.java @@ -59,7 +59,7 @@ public class RankEvalSpec implements Writeable { for (int i = 0; i < specSize; i++) { specifications.add(new QuerySpec(in)); } - eval = in.readNamedWriteable(RankedListQualityMetric.class); // TODO add to registry + eval = in.readNamedWriteable(RankedListQualityMetric.class); taskId = in.readString(); } diff --git a/modules/rank-eval/src/test/java/org/elasticsearch/index/rankeval/RankEvalRequestTests.java b/modules/rank-eval/src/test/java/org/elasticsearch/index/rankeval/RankEvalRequestTests.java index 862ccea63f3..f2b4ee65c52 100644 --- a/modules/rank-eval/src/test/java/org/elasticsearch/index/rankeval/RankEvalRequestTests.java +++ b/modules/rank-eval/src/test/java/org/elasticsearch/index/rankeval/RankEvalRequestTests.java @@ -41,8 +41,7 @@ import java.util.List; import java.util.Map.Entry; import java.util.Set; -@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, transportClientRatio = 0.0) -// NORELEASE need to fix transport client use case +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE) public class RankEvalRequestTests extends ESIntegTestCase { @Override protected Collection> transportClientPlugins() { diff --git a/test/framework/src/main/java/org/elasticsearch/test/TestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/TestCluster.java index 2629f655c95..c668c2719b6 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/TestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/TestCluster.java @@ -20,6 +20,7 @@ package org.elasticsearch.test; import com.carrotsearch.hppc.ObjectArrayList; + import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; import org.elasticsearch.client.Client;