This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 186
[PPL] init basic codebase structure #409
Merged
penghuo
merged 1 commit into
opendistro-for-elasticsearch:feature/ppl
from
penghuo:feature/ppl-framework
Apr 6, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,16 +14,15 @@ | |
*/ | ||
|
||
buildscript { | ||
|
||
ext { | ||
// When upgrading to version after 7.3.0, must remove also | ||
// project substitution from configurations.all (line 39) | ||
es_version = System.getProperty("es.version", "7.6.1") | ||
es_version = "7.6.1" | ||
} | ||
// This isn't applying from repositories.gradle so repeating it here | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
maven { url "https://plugins.gradle.org/m2/" } | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
classpath "org.elasticsearch.gradle:build-tools:${es_version}" | ||
|
@@ -37,18 +36,6 @@ plugins { | |
id "io.freefair.lombok" version "5.0.0-rc4" | ||
} | ||
|
||
/* | ||
Temporary fix, must be removed after 7.3.0 See | ||
https://github.com/elastic/elasticsearch/issues/45073 | ||
|
||
Also must remove include ':rest-api-spec' from settings.gradle | ||
*/ | ||
configurations.all { | ||
resolutionStrategy.dependencySubstitution { | ||
substitute project(':rest-api-spec') with module ("org.elasticsearch:rest-api-spec:${es_version}") | ||
} | ||
} | ||
|
||
// Repository on root level is for dependencies that project code depends on. And this block must be placed after plugins{} | ||
repositories { | ||
mavenCentral() // For Elastic Libs that you can use to get started coding until open ES libs are available | ||
|
@@ -59,10 +46,24 @@ ext { | |
isSnapshot = "true" == System.getProperty("build.snapshot", "true") | ||
} | ||
|
||
version = "${opendistroVersion}.0" | ||
allprojects { | ||
version = "${opendistroVersion}.0" | ||
|
||
plugins.withId('java') { | ||
sourceCompatibility = targetCompatibility = "1.8" | ||
} | ||
} | ||
|
||
apply plugin: 'elasticsearch.esplugin' | ||
apply plugin: 'elasticsearch.testclusters' | ||
// Todo, removed after migrate SQL to subProject | ||
project('plugin') { | ||
apply plugin: 'elasticsearch.esplugin' | ||
} | ||
// Todo, removed after migrate SQL to subProject | ||
project('integ-test') { | ||
apply plugin: 'elasticsearch.testclusters' | ||
} | ||
apply plugin: 'jacoco' | ||
if (!System.properties.containsKey('tests.rest.cluster') && !System.properties.containsKey('tests.cluster')){ | ||
apply from: 'build-tools/sqlplugin-coverage.gradle' | ||
|
@@ -291,7 +292,7 @@ afterEvaluate { | |
maintainer 'OpenDistro for Elasticsearch Team <[email protected]>' | ||
url 'https://opendistro.github.io/elasticsearch/downloads' | ||
summary ''' | ||
SQL plugin for OpenDistro for Elasticsearch. | ||
SQL plugin for OpenDistro for Elasticsearch. | ||
Reference documentation can be found at https://opendistro.github.io/for-elasticsearch-docs/. | ||
'''.stripIndent().replace('\n', ' ').trim() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apply plugin: 'elasticsearch.build' | ||
apply plugin: 'elasticsearch.rest-test' | ||
apply plugin: 'java' | ||
|
||
ext { | ||
projectSubstitutions = [:] | ||
licenseFile = rootProject.file('LICENSE.TXT') | ||
noticeFile = rootProject.file('NOTICE') | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testCompile group: 'org.elasticsearch.test', name: 'framework', version: '7.6.1' | ||
testCompile group: 'org.elasticsearch.client', name: 'elasticsearch-rest-high-level-client', version: '7.6.1' | ||
testCompile group: 'junit', name: 'junit', version: '4.12' | ||
testCompile group: 'org.hamcrest', name: 'hamcrest', version: '2.1' | ||
testCompile group: 'org.apache.logging.log4j', name: 'log4j-core', version:'2.11.1' | ||
} | ||
|
||
dependencyLicenses.enabled = false | ||
testingConventions.enabled = false | ||
checkstyleTest.ignoreFailures = true | ||
|
||
tasks.integTest.dependsOn(':plugin:bundlePlugin') | ||
testClusters.integTest { | ||
testDistribution='oss' | ||
plugin file(tasks.getByPath(':plugin:bundlePlugin').archiveFile) | ||
} | ||
|
||
integTest.runner { | ||
systemProperty 'tests.security.manager', 'false' | ||
systemProperty('project.root', project.rootDir.absolutePath) | ||
|
||
if (System.getProperty("test.debug") != null) { | ||
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005' | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
integ-test/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/PPLPluginIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.sql.ppl; | ||
|
||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.Response; | ||
import org.elasticsearch.test.rest.ESRestTestCase; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
|
||
public class PPLPluginIT extends ESRestTestCase { | ||
|
||
public void testQueryEndpointShouldOK() throws IOException { | ||
Response response = client().performRequest(new Request("POST", "/_opendistro/_ppl")); | ||
assertThat(response.getStatusLine().getStatusCode(), is(200)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apply plugin: 'java' | ||
apply plugin: 'idea' | ||
|
||
ext { | ||
projectSubstitutions = [:] | ||
licenseFile = rootProject.file('LICENSE.TXT') | ||
noticeFile = rootProject.file('NOTICE') | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
esplugin { | ||
name 'opendistro_sql' | ||
description 'Open Distro for Elasticsearch SQL' | ||
classname 'com.amazon.opendistroforelasticsearch.sql.plugin.SQLPlugin' | ||
} | ||
|
||
test.enabled = false | ||
integTest.enabled = false | ||
dependencyLicenses.enabled = false | ||
|
||
dependencies { | ||
compile project(":ppl") | ||
} |
45 changes: 45 additions & 0 deletions
45
plugin/src/main/java/com/amazon/opendistroforelasticsearch/sql/plugin/SQLPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.sql.plugin; | ||
|
||
import com.amazon.opendistroforelasticsearch.sql.plugin.rest.RestPPLQueryAction; | ||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; | ||
import org.elasticsearch.cluster.node.DiscoveryNodes; | ||
import org.elasticsearch.common.settings.ClusterSettings; | ||
import org.elasticsearch.common.settings.IndexScopedSettings; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.settings.SettingsFilter; | ||
import org.elasticsearch.plugins.ActionPlugin; | ||
import org.elasticsearch.plugins.Plugin; | ||
import org.elasticsearch.rest.RestController; | ||
import org.elasticsearch.rest.RestHandler; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
public class SQLPlugin extends Plugin implements ActionPlugin { | ||
@Override | ||
public List<RestHandler> getRestHandlers(Settings settings, RestController restController, | ||
ClusterSettings clusterSettings, IndexScopedSettings indexScopedSettings, | ||
SettingsFilter settingsFilter, | ||
IndexNameExpressionResolver indexNameExpressionResolver, | ||
Supplier<DiscoveryNodes> nodesInCluster) { | ||
return Arrays.asList( | ||
new RestPPLQueryAction(restController) | ||
); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...c/main/java/com/amazon/opendistroforelasticsearch/sql/plugin/rest/RestPPLQueryAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.sql.plugin.rest; | ||
|
||
import com.amazon.opendistroforelasticsearch.sql.ppl.PPLService; | ||
import com.amazon.opendistroforelasticsearch.sql.ppl.ResponseListener; | ||
import com.amazon.opendistroforelasticsearch.sql.ppl.domain.PPLQueryRequest; | ||
import com.amazon.opendistroforelasticsearch.sql.ppl.domain.PPLQueryResponse; | ||
import org.elasticsearch.client.node.NodeClient; | ||
import org.elasticsearch.rest.BaseRestHandler; | ||
import org.elasticsearch.rest.BytesRestResponse; | ||
import org.elasticsearch.rest.RestController; | ||
import org.elasticsearch.rest.RestRequest; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.elasticsearch.rest.RestStatus.OK; | ||
|
||
public class RestPPLQueryAction extends BaseRestHandler { | ||
public static final String QUERY_API_ENDPOINT = "/_opendistro/_ppl"; | ||
|
||
public RestPPLQueryAction(RestController restController) { | ||
super(); | ||
restController.registerHandler(RestRequest.Method.POST, QUERY_API_ENDPOINT, this); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "ppl_query_action"; | ||
} | ||
|
||
@Override | ||
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { | ||
PPLService pplService = new PPLService(); | ||
return channel -> pplService.execute(new PPLQueryRequest(), new ResponseListener<PPLQueryResponse>() { | ||
@Override | ||
public void onResponse(PPLQueryResponse pplQueryResponse) { | ||
channel.sendResponse(new BytesRestResponse(OK, "application/json; charset=UTF-8", "ok")); | ||
} | ||
|
||
@Override | ||
public void onFailure(Exception e) { | ||
channel.sendResponse(new BytesRestResponse(OK, "application/json; charset=UTF-8", "error")); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
plugins { | ||
id 'java' | ||
id "io.freefair.lombok" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testCompile group: 'junit', name: 'junit', version: '4.12' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This file is generated by the 'io.freefair.lombok' Gradle plugin | ||
config.stopBubbling = true |
28 changes: 28 additions & 0 deletions
28
ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/PPLService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.sql.ppl; | ||
|
||
import com.amazon.opendistroforelasticsearch.sql.ppl.domain.PPLQueryRequest; | ||
import com.amazon.opendistroforelasticsearch.sql.ppl.domain.PPLQueryResponse; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public class PPLService { | ||
|
||
public void execute(PPLQueryRequest request, ResponseListener<PPLQueryResponse> listener) { | ||
listener.onResponse(new PPLQueryResponse()); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/ResponseListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.sql.ppl; | ||
|
||
public interface ResponseListener<Response> { | ||
|
||
void onResponse(Response response); | ||
|
||
void onFailure(Exception e); | ||
} |
19 changes: 19 additions & 0 deletions
19
ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/domain/PPLQueryRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.sql.ppl.domain; | ||
|
||
public class PPLQueryRequest { | ||
} |
19 changes: 19 additions & 0 deletions
19
ppl/src/main/java/com/amazon/opendistroforelasticsearch/sql/ppl/domain/PPLQueryResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.sql.ppl.domain; | ||
|
||
public class PPLQueryResponse { | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing about this PR, but I wonder if another PR is needed to remove these deprecated in master as well. I can run some tests and help with that.