Skip to content

Commit

Permalink
Es 7 11 (#362)
Browse files Browse the repository at this point in the history
* wip for 7.11 deprecations

* Fix build errors for 7.11

* add public visibility to test templates

* keeping threadpool over executor for now

* remove all the checks except keep nebula disabled

* Restore override annotation in TransportAddFeatureToSet

* read() was removed

* Bring back checkstyle and fix some violations

* Clean up unused vars

* clean up comments in gradle build

Co-authored-by: Nathan Day <nathancday@gmail.com>
  • Loading branch information
worleydl and nathancday authored Apr 14, 2021
1 parent c000a39 commit 049d4fd
Show file tree
Hide file tree
Showing 33 changed files with 210 additions and 47 deletions.
27 changes: 6 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ allprojects {
}
}

apply plugin: 'checkstyle'
apply plugin: 'idea'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.java-rest-test'
Expand All @@ -40,6 +41,10 @@ noticeFile = rootProject.file('NOTICE.txt')
// disable uploadArchives task for now, no upload happening currently
uploadArchives.enabled = false

checkstyle {
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
}

esplugin {
name 'ltr'
description 'Learning to Rank Query w/ RankLib Models'
Expand All @@ -63,13 +68,6 @@ repositories {
}
}

dependencyLicenses {
mapping from: /lucene-.*/, to: 'lucene'
mapping from: /asm-.*/, to: 'asm'
mapping from: /Ranky-.*/, to: 'lucene'
mapping from: /compiler-.*/, to: 'lucene'
}

sourceSets {
javaRestTest {
compileClasspath += sourceSets["main"].output + sourceSets["test"].output + configurations["testRuntimeClasspath"]
Expand All @@ -86,18 +84,5 @@ java {
checkstyleMain.enabled = true
checkstyleTest.enabled = true

// FIXME dependency license check needs to be enabled
dependencyLicenses.enabled = false

// FIXME thirdparty audit needs to be enabled
thirdPartyAudit.enabled = false

// Uncomment this to skip license header checks
licenseHeaders.enabled = false

// No need to validate POM, as we do not upload to sonatype
// // No need to validate POM, as we do not upload to sonatype
validateNebulaPom.enabled = false

// Elastic tried to remove the logging requirement for plugins, but didn't get it quite right so this is a short term fix until 7.11
// https://github.com/elastic/elasticsearch/issues/65247
loggerUsageCheck.enabled = false
116 changes: 116 additions & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
<property name="charset" value="UTF-8" />

<module name="SuppressionFilter">
<property name="file" value="${config_loc}/suppressions.xml" />
</module>

<module name="SuppressWarningsFilter" />

<!-- Checks Java files and forbids empty Javadoc comments. -->
<!-- Although you can use the "JavadocStyle" rule for this, it considers Javadoc -->
<!-- that only contains a "@return" line to be empty. -->
<module name="RegexpMultiline">
<property name="id" value="EmptyJavadoc" />
<property name="format" value="\/\*[\s\*]*\*\/" />
<property name="fileExtensions" value="java" />
<property name="message" value="Empty javadoc comments are forbidden" />
</module>

<!-- Its our official line length! See checkstyle_suppressions.xml for the files that don't pass this. For now we
suppress the check there but enforce it everywhere else. This prevents the list from getting longer even if it is
unfair. -->
<module name="LineLength">
<property name="max" value="140" />
<property name="ignorePattern" value="^ *\* *https?://[^ ]+$" />
</module>

<module name="TreeWalker">
<!-- Make the @SuppressWarnings annotations available to Checkstyle -->
<module name="SuppressWarningsHolder" />

<module name="AvoidStarImport" />

<!-- Unused imports are forbidden -->
<module name="UnusedImports" />

<!-- Non-inner classes must be in files that match their names. -->
<module name="OuterTypeFilename" />

<!-- No line wraps inside of import and package statements. -->
<module name="NoLineWrap" />

<!-- only one statement per line should be allowed -->
<module name="OneStatementPerLine" />

<!-- Each java file has only one outer class -->
<module name="OneTopLevelClass" />

<!-- The suffix L is preferred, because the letter l (ell) is often
hard to distinguish from the digit 1 (one). -->
<module name="UpperEll" />

<module name="EqualsHashCode" />

<!-- Checks that the order of modifiers conforms to the suggestions in the
Java Language specification, sections 8.1.1, 8.3.1 and 8.4.3. It is not that
the standard is perfect, but having a consistent order makes the code more
readable and no other order is compellingly better than the standard.
The correct order is:
public
protected
private
abstract
static
final
transient
volatile
synchronized
native
strictfp
-->
<module name="ModifierOrder" />

<!-- Checks that we don't include modifier where they are implied. For
example, this does not allow interface methods to be declared public
because they are *always* public. -->
<module name="RedundantModifier" />
<!-- Checks that all java files have a package declaration and that it
lines up with the directory structure. -->
<module name="PackageDeclaration" />

<!-- We don't use Java's builtin serialization and we suppress all warning
about it. The flip side of that coin is that we shouldn't _try_ to use
it. We can't outright ban it with ForbiddenApis because it complain about
every we reference a class that implements Serializable like String or
Exception.
-->
<module name="RegexpSinglelineJava">
<property name="format" value="serialVersionUID" />
<property name="message" value="Do not declare serialVersionUID." />
<property name="ignoreComments" value="true" />
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="java\.io\.Serializable;" />
<property name="message" value="References java.io.Serializable." />
<property name="ignoreComments" value="true" />
</module>
<!-- end Orwellian suppression of Serializable -->

<!-- Forbid equality comparisons with `true` -->
<module name="DescendantToken">
<property name="id" value="EqualityWithTrue" />
<property name="tokens" value="EQUAL" />
<property name="limitedTokens" value="LITERAL_TRUE" />
<property name="maximumNumber" value="0" />
<property name="maximumDepth" value="1" />
<message key="descendant.token.max" value="Do not check for equality with 'true', since it is implied" />
</module>

</module>
</module>
52 changes: 52 additions & 0 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<suppressions>
<!-- On Windows, Checkstyle matches files using \ path separator -->

<!-- These files are generated by ANTLR so its silly to hold them to our rules. -->
<suppress files="modules[/\\]lang-painless[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]antlr[/\\]PainlessLexer\.java" checks="." />
<suppress files="modules[/\\]lang-painless[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]antlr[/\\]PainlessParser(|BaseVisitor|Visitor)\.java" checks="." />
<suppress files="modules[/\\]lang-painless[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]antlr[/\\]SuggestLexer\.java" checks="." />
<suppress files="plugin[/\\]sql[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]sql[/\\]parser[/\\]SqlBase(Base(Listener|Visitor)|Lexer|Listener|Parser|Visitor).java" checks="." />
<suppress files="plugin[/\\]eql[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]eql[/\\]parser[/\\]EqlBase(Base(Listener|Visitor)|Lexer|Listener|Parser|Visitor).java" checks="." />

<!-- JNA requires the no-argument constructor on JNAKernel32Library.SizeT to be public-->
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]bootstrap[/\\]JNAKernel32Library.java" checks="RedundantModifier" />

<!-- the constructors on some local classes in these tests must be public-->
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]plugins[/\\]PluginsServiceTests.java" checks="RedundantModifier" />

<!-- Intentionally doesn't have a package declaration to test logging
configuration of classes that aren't in packages. -->
<suppress files="test[/\\]framework[/\\]src[/\\]test[/\\]java[/\\]Dummy.java" checks="PackageDeclaration" />

<!-- Intentionally has long example curl commands to coincide with sibling Painless tests. -->
<suppress files="modules[/\\]lang-painless[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]ContextExampleTests.java" checks="LineLength" />

<!--
Truly temporary suppressions suppression of snippets included in
documentation that are so wide that they scroll.
-->
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]ClusterClientDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]GraphDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]IndicesClientDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]IngestClientDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]LicensingDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]MigrationDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]MigrationClientDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]MiscellaneousDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]MlClientDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]RollupDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]SearchDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]SecurityDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]SnapshotClientDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]StoredScriptsDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]TasksClientDocumentationIT.java" id="SnippetLength" />
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]WatcherDocumentationIT.java" id="SnippetLength" />

<!-- Gradle requires inputs to be seriablizable -->
<suppress files="buildSrc[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]gradle[/\\]internal[/\\]precommit[/\\]TestingConventionRule.java" checks="RegexpSinglelineJava" />
</suppressions>
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ltrVersion = 1.5.4
elasticsearchVersion = 7.10.2
elasticsearchVersion = 7.11.1
luceneVersion = 8.7.0
ow2Version = 8.0.1
antlrVersion=4.5.1-1
antlrVersion = 4.5.1-1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,13 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
Expand All @@ -61,23 +58,13 @@ public class TransportListStoresAction extends TransportMasterNodeReadAction<Lis
private final Client client;

@Inject
public TransportListStoresAction(Settings settings, TransportService transportService,ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters,
public TransportListStoresAction(TransportService transportService,
ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, Client client) {
super(ListStoresAction.NAME, transportService, clusterService, threadPool,
actionFilters, ListStoresActionRequest::new, indexNameExpressionResolver);
actionFilters, ListStoresActionRequest::new, indexNameExpressionResolver, ListStoresActionResponse::new, ThreadPool.Names.SAME);
this.client = client;
}

@Override
protected String executor() {
return ThreadPool.Names.SAME;
}

@Override
protected ListStoresActionResponse read(StreamInput in) throws IOException {
return new ListStoresActionResponse(in);
}

@Override
protected void masterOperation(ListStoresActionRequest request, ClusterState state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ public Query doToQuery(LtrQueryContext context, FeatureSet featureSet, Map<Strin
Analyzer analyzer = null;
for(String field : fields) {
if (analyzerName == null) {
final MappedFieldType fieldType = context.getQueryShardContext().getMapperService().fieldType(field);
analyzer = context.getQueryShardContext().getSearchAnalyzer(fieldType);
final MappedFieldType fieldType = context.getQueryShardContext().getFieldType(field);
analyzer = fieldType.getTextSearchInfo().getSearchAnalyzer();
} else {
analyzer = context.getQueryShardContext().getIndexAnalyzers().get(analyzerName);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/o19s/es/termstat/TermStatQueryBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ protected Query doToQuery(QueryShardContext context) throws IOException {
}

private Analyzer getAnalyzerForField(QueryShardContext context, String fieldName) {
MappedFieldType fieldType = context.getMapperService().fieldType(fieldName);
return context.getSearchAnalyzer(fieldType);
MappedFieldType fieldType = context.getFieldType(fieldName);
return fieldType.getTextSearchInfo().getSearchAnalyzer();
}

private Analyzer getAnalyzerByName(QueryShardContext context, String analyzerName) {
return context.getMapperService().getIndexAnalyzers().get(analyzerName);
return context.getIndexAnalyzers().get(analyzerName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.fetch.FetchSubPhase;
import org.elasticsearch.search.fetch.FetchSubPhaseProcessor;
import org.elasticsearch.search.lookup.SourceLookup;
import org.junit.AfterClass;
import org.junit.BeforeClass;

Expand Down Expand Up @@ -186,7 +185,7 @@ public void collect(int doc) throws IOException {
random().nextBoolean() ? new HashMap<>() : null,
null
);
processor.process(new FetchSubPhase.HitContext(hit, context, doc, new SourceLookup()));
processor.process(new FetchSubPhase.HitContext(hit, context, doc));
hits.add(hit);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"ltr.add_features_to_set": {
"stability": "stable",
"visibility": "public",
"url": {
"paths": [
{
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/rest-api-spec/api/ltr.cache_stats.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"ltr.cache_stats": {
"stability": "stable",
"visibility": "public",
"url": {
"paths": [
{
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/rest-api-spec/api/ltr.clear_cache.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"ltr.clear_cache": {
"stability": "stable",
"visibility": "public",
"url": {
"paths": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"ltr.create_feature": {
"stability": "stable",
"visibility": "public",
"url": {
"paths": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"ltr.create_featureset": {
"stability": "stable",
"visibility": "public",
"url": {
"paths": [
{
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/rest-api-spec/api/ltr.create_model.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"ltr.create_model": {
"stability": "stable",
"visibility": "public",
"url": {
"paths": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"ltr.create_model_from_set": {
"stability": "stable",
"visibility": "public",
"url": {
"paths": [
{
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/rest-api-spec/api/ltr.create_store.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"ltr.create_store": {
"stability": "stable",
"visibility": "public",
"url": {
"paths": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"ltr.delete_feature": {
"stability": "stable",
"visibility": "public",
"url": {
"paths": [
{
Expand Down
Loading

0 comments on commit 049d4fd

Please sign in to comment.