diff --git a/build.gradle b/build.gradle index 412268fb..733fd58c 100644 --- a/build.gradle +++ b/build.gradle @@ -6,12 +6,12 @@ buildscript { } dependencies { - classpath "org.elasticsearch.gradle:build-tools:7.2.0" + classpath "org.elasticsearch.gradle:build-tools:7.3.1" } } group = 'com.o19s' -version = '1.1.1-es7.2.0' +version = '1.1.2-es7.3.1' apply plugin: 'java' apply plugin: 'idea' @@ -27,7 +27,7 @@ noticeFile = rootProject.file('NOTICE.txt') esplugin { name 'ltr' - description 'Learing to Rank Query w/ RankLib Models' + description 'Learning to Rank Query w/ RankLib Models' classname 'com.o19s.es.ltr.LtrQueryParserPlugin' // license of this project licenseFile = rootProject.file('LICENSE.txt') @@ -46,15 +46,15 @@ repositories { } dependencies { - compile "org.apache.lucene:lucene-expressions:8.0.0" + compile "org.apache.lucene:lucene-expressions:8.1.0" compile 'org.antlr:antlr4-runtime:4.5.1-1' compile 'org.ow2.asm:asm:5.0.4' compile 'org.ow2.asm:asm-commons:5.0.4' compile 'org.ow2.asm:asm-tree:5.0.4' - compile 'org.elasticsearch:elasticsearch:7.2.0' + compile 'org.elasticsearch:elasticsearch:7.3.1' compile 'com.o19s:RankyMcRankFace:0.1.1' compile "com.github.spullara.mustache.java:compiler:0.9.3" - testCompile 'org.elasticsearch.test:framework:7.2.0' + testCompile 'org.elasticsearch.test:framework:7.3.1' } @@ -65,6 +65,14 @@ dependencyLicenses { mapping from: /compiler-.*/, to: 'lucene' } + +// https://github.com/elastic/elasticsearch/issues/45891#issuecomment-525399411 +configurations.restSpec.withDependencies { dependencies -> + dependencies.clear() + dependencies.add(project.dependencies.create("org.elasticsearch:rest-api-spec:7.3.1")) +} + + // Set to false to not use elasticsearch checkstyle rules checkstyleMain.enabled = true checkstyleTest.enabled = true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b0acbdcd..4b7e1f3d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew.bat b/gradlew.bat index 9618d8d9..24467a14 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,100 +1,100 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle index 72890a9f..8def085c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,2 @@ rootProject.name = 'ltr' +include ':rest-api-spec' diff --git a/src/main/java/com/o19s/es/ltr/action/AddFeaturesToSetAction.java b/src/main/java/com/o19s/es/ltr/action/AddFeaturesToSetAction.java index 9ab6e7ef..71292c13 100644 --- a/src/main/java/com/o19s/es/ltr/action/AddFeaturesToSetAction.java +++ b/src/main/java/com/o19s/es/ltr/action/AddFeaturesToSetAction.java @@ -16,17 +16,19 @@ package com.o19s.es.ltr.action; +import com.o19s.es.ltr.action.AddFeaturesToSetAction.AddFeaturesToSetResponse; import com.o19s.es.ltr.feature.store.StoredFeature; import com.o19s.es.ltr.feature.FeatureValidation; -import org.elasticsearch.action.Action; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.io.stream.Writeable.Reader; import org.elasticsearch.common.xcontent.StatusToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.rest.RestStatus; @@ -36,7 +38,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError; -public class AddFeaturesToSetAction extends Action { +public class AddFeaturesToSetAction extends ActionType { public static final AddFeaturesToSetAction INSTANCE = new AddFeaturesToSetAction(); public static final String NAME = "cluster:admin/ltr/store/add-features-to-set"; @@ -45,8 +47,8 @@ protected AddFeaturesToSetAction() { } @Override - public AddFeaturesToSetResponse newResponse() { - return new AddFeaturesToSetResponse(); + public Reader getResponseReader() { + return AddFeaturesToSetResponse::new; } public static class AddFeaturesToSetRequestBuilder extends ActionRequestBuilder { @@ -169,20 +171,16 @@ public void setValidation(FeatureValidation validation) { public static class AddFeaturesToSetResponse extends ActionResponse implements StatusToXContentObject { private IndexResponse response; - public AddFeaturesToSetResponse() { + public AddFeaturesToSetResponse(StreamInput in) throws IOException { + super(in); + response = new IndexResponse(); + response.readFrom(in); } public AddFeaturesToSetResponse(IndexResponse response) { this.response = response; } - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - response = new IndexResponse(); - response.readFrom(in); - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); diff --git a/src/main/java/com/o19s/es/ltr/action/CachesStatsAction.java b/src/main/java/com/o19s/es/ltr/action/CachesStatsAction.java index 432a1069..d69b4a32 100644 --- a/src/main/java/com/o19s/es/ltr/action/CachesStatsAction.java +++ b/src/main/java/com/o19s/es/ltr/action/CachesStatsAction.java @@ -16,9 +16,10 @@ package com.o19s.es.ltr.action; +import com.o19s.es.ltr.action.CachesStatsAction.CachesStatsNodesResponse; import com.o19s.es.ltr.feature.store.index.Caches; -import org.elasticsearch.action.Action; import org.elasticsearch.action.ActionRequestBuilder; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.nodes.BaseNodeResponse; import org.elasticsearch.action.support.nodes.BaseNodesRequest; @@ -29,6 +30,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.io.stream.Writeable.Reader; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -37,7 +39,7 @@ import java.util.List; import java.util.Map; -public class CachesStatsAction extends Action { +public class CachesStatsAction extends ActionType { public static final String NAME = "cluster:admin/ltr/caches/stats"; public static final CachesStatsAction INSTANCE = new CachesStatsAction(); @@ -46,18 +48,22 @@ protected CachesStatsAction() { } @Override - public CachesStatsNodesResponse newResponse() { - return new CachesStatsNodesResponse(); + public Reader getResponseReader() { + return CachesStatsNodesResponse::new; } - public static class CachesStatsNodesRequest extends BaseNodesRequest { } public static class CachesStatsNodesResponse extends BaseNodesResponse implements ToXContent { private StatDetails allStores; private Map byStore; - public CachesStatsNodesResponse() {} + + public CachesStatsNodesResponse(StreamInput in) throws IOException { + super.readFrom(in); + allStores = new StatDetails(in); + byStore = in.readMap(StreamInput::readString, StatDetails::new); + } public CachesStatsNodesResponse(ClusterName clusterName, List nodes, List failures) { super(clusterName, nodes, failures); @@ -79,13 +85,6 @@ protected void writeNodesTo(StreamOutput out, List node out.writeStreamableList(nodes); } - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - allStores = new StatDetails(in); - byStore = in.readMap(StreamInput::readString, StatDetails::new); - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); diff --git a/src/main/java/com/o19s/es/ltr/action/ClearCachesAction.java b/src/main/java/com/o19s/es/ltr/action/ClearCachesAction.java index b197317c..b18e8aa9 100644 --- a/src/main/java/com/o19s/es/ltr/action/ClearCachesAction.java +++ b/src/main/java/com/o19s/es/ltr/action/ClearCachesAction.java @@ -16,9 +16,10 @@ package com.o19s.es.ltr.action; -import org.elasticsearch.action.Action; +import com.o19s.es.ltr.action.ClearCachesAction.ClearCachesNodesResponse; import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.ActionRequestValidationException; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.nodes.BaseNodeResponse; import org.elasticsearch.action.support.nodes.BaseNodesRequest; @@ -32,10 +33,11 @@ import java.io.IOException; import java.util.List; import java.util.Objects; +import org.elasticsearch.common.io.stream.Writeable.Reader; import static org.elasticsearch.action.ValidateActions.addValidationError; -public class ClearCachesAction extends Action { +public class ClearCachesAction extends ActionType { public static final String NAME = "cluster:admin/ltr/caches"; public static final ClearCachesAction INSTANCE = new ClearCachesAction(); @@ -44,8 +46,8 @@ private ClearCachesAction() { } @Override - public ClearCachesNodesResponse newResponse() { - return new ClearCachesNodesResponse(); + public Reader getResponseReader() { + return ClearCachesNodesResponse::new; } public static class RequestBuilder extends ActionRequestBuilder { @@ -136,7 +138,9 @@ public String getName() { } public static class ClearCachesNodesResponse extends BaseNodesResponse { - public ClearCachesNodesResponse() {} + public ClearCachesNodesResponse(StreamInput in) throws IOException { + super.readFrom(in); + } public ClearCachesNodesResponse(ClusterName clusterName, List responses, List failures) { diff --git a/src/main/java/com/o19s/es/ltr/action/CreateModelFromSetAction.java b/src/main/java/com/o19s/es/ltr/action/CreateModelFromSetAction.java index a0ba7f56..7db8a6a3 100644 --- a/src/main/java/com/o19s/es/ltr/action/CreateModelFromSetAction.java +++ b/src/main/java/com/o19s/es/ltr/action/CreateModelFromSetAction.java @@ -16,17 +16,19 @@ package com.o19s.es.ltr.action; +import com.o19s.es.ltr.action.CreateModelFromSetAction.CreateModelFromSetResponse; import com.o19s.es.ltr.feature.FeatureValidation; import com.o19s.es.ltr.feature.store.StoredLtrModel; -import org.elasticsearch.action.Action; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.io.stream.Writeable.Reader; import org.elasticsearch.common.xcontent.StatusToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.rest.RestStatus; @@ -35,7 +37,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError; -public class CreateModelFromSetAction extends Action { +public class CreateModelFromSetAction extends ActionType { public static final String NAME = "cluster:admin/ltr/store/create-model-from-set"; public static final CreateModelFromSetAction INSTANCE = new CreateModelFromSetAction(); @@ -47,8 +49,8 @@ protected CreateModelFromSetAction() { * Creates a new response instance. */ @Override - public CreateModelFromSetResponse newResponse() { - return new CreateModelFromSetResponse(); + public Reader getResponseReader() { + return CreateModelFromSetResponse::new; } public static class CreateModelFromSetRequestBuilder extends ActionRequestBuilder { +public class FeatureStoreAction extends ActionType { public static final String NAME = "cluster:admin/ltr/featurestore/data"; public static final FeatureStoreAction INSTANCE = new FeatureStoreAction(); @@ -46,8 +48,8 @@ protected FeatureStoreAction() { } @Override - public FeatureStoreResponse newResponse() { - return new FeatureStoreResponse(); + public Reader getResponseReader() { + return FeatureStoreResponse::new; } public static class FeatureStoreRequestBuilder @@ -180,13 +182,16 @@ public enum Action { public static class FeatureStoreResponse extends ActionResponse implements StatusToXContentObject { private IndexResponse response; - public FeatureStoreResponse() {} + public FeatureStoreResponse(StreamInput in) throws IOException { + super(in); + response = new IndexResponse(); + response.readFrom(in); + } public FeatureStoreResponse(IndexResponse response) { this.response = response; } - public IndexResponse getResponse() { return response; } @@ -195,13 +200,6 @@ public void setResponse(IndexResponse response) { this.response = response; } - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - response = new IndexResponse(); - response.readFrom(in); - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); diff --git a/src/main/java/com/o19s/es/ltr/action/ListStoresAction.java b/src/main/java/com/o19s/es/ltr/action/ListStoresAction.java index fbeb4a5b..6784aff2 100644 --- a/src/main/java/com/o19s/es/ltr/action/ListStoresAction.java +++ b/src/main/java/com/o19s/es/ltr/action/ListStoresAction.java @@ -16,16 +16,18 @@ package com.o19s.es.ltr.action; +import com.o19s.es.ltr.action.ListStoresAction.ListStoresActionResponse; import com.o19s.es.ltr.feature.store.index.IndexFeatureStore; -import org.elasticsearch.action.Action; import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.support.master.MasterNodeReadRequest; import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.io.stream.Writeable.Reader; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -36,7 +38,7 @@ import java.util.Objects; import java.util.stream.Collectors; -public class ListStoresAction extends Action { +public class ListStoresAction extends ActionType { public static final String NAME = "cluster:admin/ltr/featurestore/list"; public static final ListStoresAction INSTANCE = new ListStoresAction(); @@ -45,8 +47,8 @@ private ListStoresAction() { } @Override - public ListStoresActionResponse newResponse() { - return new ListStoresActionResponse(); + public Reader getResponseReader() { + return ListStoresActionResponse::new; } public static class ListStoresActionRequest extends MasterNodeReadRequest { @@ -61,6 +63,11 @@ public static class ListStoresActionResponse extends ActionResponse implements T ListStoresActionResponse() {} + ListStoresActionResponse(StreamInput in) throws IOException { + super(in); + stores = in.readMap(StreamInput::readString, IndexStoreInfo::new); + } + public ListStoresActionResponse(List info) { stores = info.stream().collect(Collectors.toMap((i) -> i.storeName, (i) -> i)); } @@ -72,12 +79,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws .endObject(); } - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - stores = in.readMap(StreamInput::readString, IndexStoreInfo::new); - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); diff --git a/src/main/java/com/o19s/es/ltr/action/TransportCacheStatsAction.java b/src/main/java/com/o19s/es/ltr/action/TransportCacheStatsAction.java index 3291e149..f58e9956 100644 --- a/src/main/java/com/o19s/es/ltr/action/TransportCacheStatsAction.java +++ b/src/main/java/com/o19s/es/ltr/action/TransportCacheStatsAction.java @@ -55,8 +55,8 @@ protected CachesStatsNodesResponse newResponse(CachesStatsNodesRequest request, } @Override - protected CachesStatsNodeRequest newNodeRequest(String nodeId, CachesStatsNodesRequest request) { - return new CachesStatsNodeRequest(nodeId); + protected CachesStatsNodeRequest newNodeRequest(CachesStatsNodesRequest request) { + return new CachesStatsNodeRequest(); } @Override @@ -70,11 +70,6 @@ protected CachesStatsNodeResponse nodeOperation(CachesStatsNodeRequest request) } public static class CachesStatsNodeRequest extends BaseNodeRequest { - public CachesStatsNodeRequest() { - } - - public CachesStatsNodeRequest(String nodeId) { - super(nodeId); - } + public CachesStatsNodeRequest() {} } } diff --git a/src/main/java/com/o19s/es/ltr/action/TransportClearCachesAction.java b/src/main/java/com/o19s/es/ltr/action/TransportClearCachesAction.java index 8d722059..6e15fcdd 100644 --- a/src/main/java/com/o19s/es/ltr/action/TransportClearCachesAction.java +++ b/src/main/java/com/o19s/es/ltr/action/TransportClearCachesAction.java @@ -57,8 +57,8 @@ protected ClearCachesNodesResponse newResponse(ClearCachesNodesRequest request, } @Override - protected ClearCachesNodeRequest newNodeRequest(String nodeId, ClearCachesNodesRequest request) { - return new ClearCachesNodeRequest(nodeId, request); + protected ClearCachesNodeRequest newNodeRequest(ClearCachesNodesRequest request) { + return new ClearCachesNodeRequest(request); } @Override @@ -93,8 +93,7 @@ public static class ClearCachesNodeRequest extends BaseNodeRequest { public ClearCachesNodeRequest() {} - public ClearCachesNodeRequest(String nodeId, ClearCachesNodesRequest req) { - super(nodeId); + public ClearCachesNodeRequest(ClearCachesNodesRequest req) { this.request = req; } diff --git a/src/test/java/com/o19s/es/ltr/query/LtrQueryBuilderTests.java b/src/test/java/com/o19s/es/ltr/query/LtrQueryBuilderTests.java index 2c1ab21b..519c2b16 100644 --- a/src/test/java/com/o19s/es/ltr/query/LtrQueryBuilderTests.java +++ b/src/test/java/com/o19s/es/ltr/query/LtrQueryBuilderTests.java @@ -160,15 +160,19 @@ public void testUnnamedFeatures() throws IOException { } - @Override protected boolean builderGeneratesCacheableQueries() { return false; } @Override - protected boolean isCacheable(LtrQueryBuilder queryBuilder) { - return false; + public void testCacheability() throws IOException { + LtrQueryBuilder queryBuilder = createTestQueryBuilder(); + QueryShardContext context = createShardContext(); + assert context.isCacheable(); + QueryBuilder rewritten = rewriteQuery(queryBuilder, new QueryShardContext(context)); + assertNotNull(rewritten.toQuery(context)); + assertFalse("query should not be cacheable: " + queryBuilder.toString(), context.isCacheable()); } @Override diff --git a/src/test/java/com/o19s/es/ltr/query/StoredLtrQueryBuilderTests.java b/src/test/java/com/o19s/es/ltr/query/StoredLtrQueryBuilderTests.java index ea856dea..0969f767 100644 --- a/src/test/java/com/o19s/es/ltr/query/StoredLtrQueryBuilderTests.java +++ b/src/test/java/com/o19s/es/ltr/query/StoredLtrQueryBuilderTests.java @@ -218,10 +218,13 @@ protected void doAssertLuceneQuery(StoredLtrQueryBuilder queryBuilder, } @Override - protected boolean isCacheable(StoredLtrQueryBuilder queryBuilder) { - // This query is not cachable as it needs a ScriptService - // see QueryShardContext#failIfFrozen() - return false; + public void testCacheability() throws IOException { + StoredLtrQueryBuilder queryBuilder = createTestQueryBuilder(); + QueryShardContext context = createShardContext(); + assert context.isCacheable(); + QueryBuilder rewritten = rewriteQuery(queryBuilder, new QueryShardContext(context)); + assertNotNull(rewritten.toQuery(context)); + assertFalse("query should not be cacheable: " + queryBuilder.toString(), context.isCacheable()); } // Hack to inject our MemStore