diff --git a/plugin/build.gradle b/plugin/build.gradle index 0077cd1d8a1..ab3c4bc81f9 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -33,7 +33,7 @@ dependencyLicenses { mapping from: /elasticsearch-rest-client.*/, to: 'elasticsearch' mapping from: /server.*/, to: 'elasticsearch' mapping from: /jdbc-proto.*/, to: 'elasticsearch' - mapping from: /cli-proto.*/, to: 'elasticsearch' + mapping from: /rest-proto.*/, to: 'elasticsearch' mapping from: /shared-proto.*/, to: 'elasticsearch' mapping from: /aggs-matrix-stats.*/, to: 'elasticsearch' //pulled in by sql:server mapping from: /http.*/, to: 'httpclient' // pulled in by rest client @@ -43,7 +43,7 @@ dependencyLicenses { ignoreSha 'tribe' ignoreSha 'server' ignoreSha 'jdbc-proto' - ignoreSha 'cli-proto' + ignoreSha 'rest-proto' ignoreSha 'shared-proto' ignoreSha 'elasticsearch-rest-client-sniffer' ignoreSha 'aggs-matrix-stats' diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java b/plugin/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java index 6c88dfc318a..998500fd795 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java @@ -64,9 +64,9 @@ import org.elasticsearch.xpack.security.user.SystemUser; import org.elasticsearch.xpack.security.user.User; import org.elasticsearch.xpack.security.user.XPackSecurityUser; import org.elasticsearch.xpack.security.user.XPackUser; +import org.elasticsearch.xpack.sql.plugin.SqlAction; import org.elasticsearch.xpack.sql.plugin.SqlClearCursorAction; import org.elasticsearch.xpack.sql.plugin.SqlTranslateAction; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlAction; import java.util.Arrays; import java.util.Collections; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java index 0c362dc2a56..5b5e217e454 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java @@ -120,8 +120,8 @@ import org.elasticsearch.xpack.security.user.ElasticUser; import org.elasticsearch.xpack.security.user.SystemUser; import org.elasticsearch.xpack.security.user.User; import org.elasticsearch.xpack.security.user.XPackUser; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlAction; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlRequest; +import org.elasticsearch.xpack.sql.plugin.SqlAction; +import org.elasticsearch.xpack.sql.plugin.SqlRequest; import org.junit.Before; import org.mockito.Mockito; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlActionIT.java b/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlActionIT.java index 20abdd66df6..8a7ead6ef5e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlActionIT.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlActionIT.java @@ -7,9 +7,9 @@ package org.elasticsearch.xpack.sql; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.WriteRequest; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlAction; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlResponse; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlResponse.ColumnInfo; +import org.elasticsearch.xpack.sql.plugin.SqlAction; +import org.elasticsearch.xpack.sql.plugin.SqlResponse; +import org.elasticsearch.xpack.sql.plugin.SqlResponse.ColumnInfo; import java.sql.JDBCType; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlClearCursorActionIT.java b/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlClearCursorActionIT.java index 3964bb0cc4a..b7c7fa958b0 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlClearCursorActionIT.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlClearCursorActionIT.java @@ -9,9 +9,9 @@ import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.xpack.sql.plugin.SqlClearCursorAction; -import org.elasticsearch.xpack.sql.plugin.SqlClearCursorAction.Response; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlAction; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlResponse; +import org.elasticsearch.xpack.sql.plugin.SqlClearCursorResponse; +import org.elasticsearch.xpack.sql.plugin.SqlAction; +import org.elasticsearch.xpack.sql.plugin.SqlResponse; import org.elasticsearch.xpack.sql.session.Cursor; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; @@ -44,7 +44,8 @@ public class SqlClearCursorActionIT extends AbstractSqlIntegTestCase { assertThat(sqlResponse.cursor(), notNullValue()); assertThat(sqlResponse.cursor(), not(equalTo(Cursor.EMPTY))); - Response cleanCursorResponse = client().prepareExecute(SqlClearCursorAction.INSTANCE).cursor(sqlResponse.cursor()).get(); + SqlClearCursorResponse cleanCursorResponse = client().prepareExecute(SqlClearCursorAction.INSTANCE) + .cursor(sqlResponse.cursor()).get(); assertTrue(cleanCursorResponse.isSucceeded()); assertEquals(0, getNumberOfSearchContexts()); @@ -76,10 +77,11 @@ public class SqlClearCursorActionIT extends AbstractSqlIntegTestCase { do { sqlResponse = client().prepareExecute(SqlAction.INSTANCE).cursor(sqlResponse.cursor()).get(); fetched += sqlResponse.size(); - } while (sqlResponse.cursor().equals(Cursor.EMPTY) == false); + } while (sqlResponse.cursor().equals("") == false); assertEquals(indexSize, fetched); - Response cleanCursorResponse = client().prepareExecute(SqlClearCursorAction.INSTANCE).cursor(sqlResponse.cursor()).get(); + SqlClearCursorResponse cleanCursorResponse = client().prepareExecute(SqlClearCursorAction.INSTANCE) + .cursor(sqlResponse.cursor()).get(); assertFalse(cleanCursorResponse.isSucceeded()); assertEquals(0, getNumberOfSearchContexts()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlDisabledIT.java b/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlDisabledIT.java index 6b9b1f346a9..d23df82716d 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlDisabledIT.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlDisabledIT.java @@ -7,7 +7,7 @@ package org.elasticsearch.xpack.sql; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.xpack.XPackSettings; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlAction; +import org.elasticsearch.xpack.sql.plugin.SqlAction; import static org.hamcrest.CoreMatchers.either; import static org.hamcrest.CoreMatchers.startsWith; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlLicenseIT.java b/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlLicenseIT.java index f1822b0cb81..b402d6c8fc8 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlLicenseIT.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlLicenseIT.java @@ -27,8 +27,8 @@ import org.elasticsearch.transport.Netty4Plugin; import org.elasticsearch.xpack.sql.jdbc.net.protocol.MetaTableRequest; import org.elasticsearch.xpack.sql.jdbc.net.protocol.MetaTableResponse; import org.elasticsearch.xpack.sql.jdbc.net.protocol.Proto; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlAction; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlResponse; +import org.elasticsearch.xpack.sql.plugin.SqlAction; +import org.elasticsearch.xpack.sql.plugin.SqlResponse; import org.elasticsearch.xpack.sql.plugin.SqlTranslateAction; import org.elasticsearch.xpack.sql.protocol.shared.Request; import org.elasticsearch.xpack.sql.protocol.shared.Response; diff --git a/qa/sql/build.gradle b/qa/sql/build.gradle index 5619df3e65c..fd759a565e8 100644 --- a/qa/sql/build.gradle +++ b/qa/sql/build.gradle @@ -32,7 +32,7 @@ dependencies { compile(project(':x-pack-elasticsearch:sql:server')) { transitive = false } - compile(project(':x-pack-elasticsearch:sql:cli-proto')) { + compile(project(':x-pack-elasticsearch:sql:rest-proto')) { transitive = false } compile "org.elasticsearch.client:transport:${version}" diff --git a/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/cli/CliIntegrationTestCase.java b/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/cli/CliIntegrationTestCase.java index d890b5ac76d..09077d63859 100644 --- a/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/cli/CliIntegrationTestCase.java +++ b/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/cli/CliIntegrationTestCase.java @@ -8,48 +8,20 @@ package org.elasticsearch.xpack.qa.sql.cli; import org.apache.http.HttpEntity; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; -import org.elasticsearch.client.Client; -import org.elasticsearch.common.Booleans; import org.elasticsearch.common.CheckedConsumer; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.test.rest.ESRestTestCase; -import org.elasticsearch.transport.client.PreBuiltTransportClient; import org.elasticsearch.xpack.qa.sql.cli.RemoteCli.SecurityConfig; -import org.elasticsearch.xpack.qa.sql.embed.CliHttpServer; -import org.elasticsearch.xpack.qa.sql.rest.RestSqlTestCase; import org.junit.After; import org.junit.Before; -import org.junit.ClassRule; -import org.junit.rules.ExternalResource; import java.io.IOException; -import java.net.InetAddress; -import java.security.AccessControlException; -import java.util.function.Supplier; import static java.util.Collections.singletonMap; import static org.elasticsearch.xpack.qa.sql.rest.RestSqlTestCase.assertNoSearchContexts; public abstract class CliIntegrationTestCase extends ESRestTestCase { - /** - * Should the HTTP server that serves SQL be embedded in the test - * process (true) or should the JDBC driver connect to Elasticsearch - * running at {@code tests.rest.cluster}. Note that to use embedded - * HTTP you have to have Elasticsearch's transport protocol open on - * port 9300 but the Elasticsearch running there does not need to have - * the SQL plugin installed. Note also that embedded HTTP is faster - * but is not canonical because it runs against a different HTTP server - * then JDBC will use in production. Gradle always uses non-embedded. - */ - private static final boolean EMBED_SQL = Booleans.parseBoolean(System.getProperty("tests.embed.sql", "false")); - - @ClassRule - public static final EmbeddedCliServer EMBEDDED = EMBED_SQL ? new EmbeddedCliServer() : null; - public static final Supplier ES = EMBED_SQL ? EMBEDDED::address : CliIntegrationTestCase::elasticsearchAddress; - /** * Read an address for Elasticsearch suitable for the CLI from the system properties. */ @@ -66,7 +38,7 @@ public abstract class CliIntegrationTestCase extends ESRestTestCase { */ @Before public void startCli() throws IOException { - cli = new RemoteCli(ES.get(), true, securityConfig()); + cli = new RemoteCli(CliIntegrationTestCase.elasticsearchAddress(), true, securityConfig()); } @After @@ -102,45 +74,4 @@ public abstract class CliIntegrationTestCase extends ESRestTestCase { return cli.readLine(); } - /** - * Embedded CLI server that runs against a running Elasticsearch - * server using the transport protocol. - */ - private static class EmbeddedCliServer extends ExternalResource { - private Client client; - private CliHttpServer server; - - @Override - @SuppressWarnings("resource") - protected void before() throws Throwable { - try { - Settings settings = Settings.builder() - .put("client.transport.ignore_cluster_name", true) - .build(); - client = new PreBuiltTransportClient(settings) - .addTransportAddress(new TransportAddress(InetAddress.getLoopbackAddress(), 9300)); - } catch (ExceptionInInitializerError e) { - if (e.getCause() instanceof AccessControlException) { - throw new RuntimeException(getClass().getSimpleName() + " is not available with the security manager", e); - } else { - throw e; - } - } - server = new CliHttpServer(client); - - server.start(0); - } - - @Override - protected void after() { - client.close(); - client = null; - server.stop(); - server = null; - } - - private String address() { - return server.address().getAddress().getHostAddress() + ":" + server.address().getPort(); - } - } } diff --git a/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/embed/CliHttpServer.java b/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/embed/CliHttpServer.java deleted file mode 100644 index 073325a8258..00000000000 --- a/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/embed/CliHttpServer.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.qa.sql.embed; - -import org.elasticsearch.client.Client; - -/** - * Internal server used for testing without starting a new Elasticsearch instance. - */ -public class CliHttpServer extends ProtoHttpServer { - public CliHttpServer(Client client) { - super(client, new CliProtoHandler(client), "/_xpack/sql/cli"); - } - - @Override - public String url() { - return "http://" + super.url(); - } -} \ No newline at end of file diff --git a/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/embed/CliProtoHandler.java b/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/embed/CliProtoHandler.java deleted file mode 100644 index a4f0883c116..00000000000 --- a/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/embed/CliProtoHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.qa.sql.embed; - -import com.sun.net.httpserver.HttpExchange; - -import org.elasticsearch.client.Client; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.test.rest.FakeRestChannel; -import org.elasticsearch.test.rest.FakeRestRequest; -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto; -import org.elasticsearch.xpack.sql.plugin.RestSqlCliAction; - -import java.io.DataInput; -import java.io.IOException; - -import static org.mockito.Mockito.mock; - -class CliProtoHandler extends ProtoHandler { - private final RestSqlCliAction action; - - CliProtoHandler(Client client) { - super(client); - action = new RestSqlCliAction(Settings.EMPTY, mock(RestController.class)); - } - - @Override - protected void handle(HttpExchange http, DataInput in) throws IOException { - FakeRestChannel channel = new FakeRestChannel(new FakeRestRequest(), true, 1); - try { - action.operation(Proto.INSTANCE.readRequest(in), client).accept(channel); - while (false == channel.await()) {} - sendHttpResponse(http, channel.capturedResponse().content()); - } catch (Exception e) { - fail(http, e); - } - } -} \ No newline at end of file diff --git a/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/embed/EmbeddedModeFilterClient.java b/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/embed/EmbeddedModeFilterClient.java index c63643e68f2..0a43e4f24ab 100644 --- a/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/embed/EmbeddedModeFilterClient.java +++ b/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/embed/EmbeddedModeFilterClient.java @@ -13,10 +13,10 @@ import org.elasticsearch.action.ActionResponse; import org.elasticsearch.client.Client; import org.elasticsearch.client.FilterClient; import org.elasticsearch.xpack.sql.execution.PlanExecutor; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlAction; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlRequest; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlResponse; -import org.elasticsearch.xpack.sql.plugin.sql.action.TransportSqlAction; +import org.elasticsearch.xpack.sql.plugin.SqlAction; +import org.elasticsearch.xpack.sql.plugin.SqlRequest; +import org.elasticsearch.xpack.sql.plugin.SqlResponse; +import org.elasticsearch.xpack.sql.plugin.TransportSqlAction; import java.util.Objects; diff --git a/sql/cli-proto/build.gradle b/sql/cli-proto/build.gradle deleted file mode 100644 index 98ab91a53d5..00000000000 --- a/sql/cli-proto/build.gradle +++ /dev/null @@ -1,17 +0,0 @@ -description = 'Request and response objects shared by the cli and ' + - 'its backend in :sql:server' - -dependencies { - compile project(':x-pack-elasticsearch:sql:shared-proto') - testCompile project(':x-pack-elasticsearch:sql:test-utils') -} - -forbiddenApisMain { - // does not depend on core, so only jdk and http signatures should be checked - signaturesURLs = [this.class.getResource('/forbidden/jdk-signatures.txt')] -} - -dependencyLicenses { - mapping from: /shared-proto.*/, to: 'elasticsearch' - ignoreSha 'shared-proto' -} diff --git a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoRequest.java b/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoRequest.java deleted file mode 100644 index 0716de49a15..00000000000 --- a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoRequest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto.RequestType; -import org.elasticsearch.xpack.sql.protocol.shared.AbstractInfoRequest; -import org.elasticsearch.xpack.sql.protocol.shared.SqlDataInput; - -import java.io.IOException; - -/** - * Request general information about the server. - */ -public class InfoRequest extends AbstractInfoRequest { - /** - * Build the info request containing information about the current JVM. - */ - public InfoRequest() { - super(); - } - - public InfoRequest(String jvmVersion, String jvmVendor, String jvmClassPath, String osName, String osVersion) { - super(jvmVersion, jvmVendor, jvmClassPath, osName, osVersion); - } - - InfoRequest(SqlDataInput in) throws IOException { - super(in); - } - - @Override - public RequestType requestType() { - return RequestType.INFO; - } -} diff --git a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoResponse.java b/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoResponse.java deleted file mode 100644 index 52de73d97e3..00000000000 --- a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto.RequestType; -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto.ResponseType; -import org.elasticsearch.xpack.sql.protocol.shared.AbstractInfoResponse; -import org.elasticsearch.xpack.sql.protocol.shared.Request; - -import java.io.DataInput; -import java.io.IOException; - -/** - * General information about the server. - */ -public class InfoResponse extends AbstractInfoResponse { - public InfoResponse(String nodeName, String clusterName, byte versionMajor, byte versionMinor, String version, - String versionHash, String versionDate) { - super(nodeName, clusterName, versionMajor, versionMinor, version, versionHash, versionDate); - } - - InfoResponse(Request request, DataInput in) throws IOException { - super(request, in); - } - - @Override - public RequestType requestType() { - return RequestType.INFO; - } - - @Override - public ResponseType responseType() { - return ResponseType.INFO; - } -} \ No newline at end of file diff --git a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/Proto.java b/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/Proto.java deleted file mode 100644 index d99404b4e11..00000000000 --- a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/Proto.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.xpack.sql.protocol.shared.AbstractProto; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -/** - * Binary protocol for the CLI. All backwards compatibility is done using the - * version number sent in the header. - */ -public final class Proto extends AbstractProto { - public static final Proto INSTANCE = new Proto(); - - private Proto() {} - - @Override - protected RequestType readRequestType(DataInput in) throws IOException { - return RequestType.readFrom(in); - } - - @Override - protected ResponseType readResponseType(DataInput in) throws IOException { - return ResponseType.readFrom(in); - } - - public enum RequestType implements AbstractProto.RequestType { - INFO(InfoRequest::new), - QUERY_INIT(QueryInitRequest::new), - QUERY_PAGE(QueryPageRequest::new), - QUERY_CLOSE(QueryCloseRequest::new); - - private final RequestReader reader; - - RequestType(RequestReader reader) { - this.reader = reader; - } - - static RequestType readFrom(DataInput in) throws IOException { - byte b = in.readByte(); - try { - return values()[b]; - } catch (ArrayIndexOutOfBoundsException e) { - throw new IllegalArgumentException("Unknown request type [" + b + "]", e); - } - } - - @Override - public void writeTo(DataOutput out) throws IOException { - out.writeByte(ordinal()); - } - - @Override - public RequestReader reader() { - return reader; - } - } - - public enum ResponseType implements AbstractProto.ResponseType { - INFO(InfoResponse::new), - QUERY_INIT(QueryInitResponse::new), - QUERY_PAGE(QueryPageResponse::new), - QUERY_CLOSE(QueryCloseResponse::new); - - private final ResponseReader reader; - - ResponseType(ResponseReader reader) { - this.reader = reader; - } - - static ResponseType readFrom(DataInput in) throws IOException { - byte b = in.readByte(); - try { - return values()[b]; - } catch (ArrayIndexOutOfBoundsException e) { - throw new IllegalArgumentException("Unknown response type [" + b + "]", e); - } - } - - @Override - public void writeTo(DataOutput out) throws IOException { - out.writeByte(ordinal()); - } - - @Override - public ResponseReader reader() { - return reader; - } - } -} diff --git a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryCloseRequest.java b/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryCloseRequest.java deleted file mode 100644 index 5d372092825..00000000000 --- a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryCloseRequest.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.xpack.sql.protocol.shared.AbstractQueryCloseRequest; -import org.elasticsearch.xpack.sql.protocol.shared.SqlDataInput; - -import java.io.IOException; - -public class QueryCloseRequest extends AbstractQueryCloseRequest { - public QueryCloseRequest(String cursor) { - super(cursor); - } - - QueryCloseRequest(SqlDataInput in) throws IOException { - super(in); - } - - @Override - public Proto.RequestType requestType() { - return Proto.RequestType.QUERY_CLOSE; - } -} diff --git a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryCloseResponse.java b/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryCloseResponse.java deleted file mode 100644 index dbb9d4e85e5..00000000000 --- a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryCloseResponse.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto.RequestType; -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto.ResponseType; -import org.elasticsearch.xpack.sql.protocol.shared.AbstractQueryCloseResponse; -import org.elasticsearch.xpack.sql.protocol.shared.Request; - -import java.io.DataInput; -import java.io.IOException; - -public class QueryCloseResponse extends AbstractQueryCloseResponse { - public QueryCloseResponse(boolean succeeded) { - super(succeeded); - } - - QueryCloseResponse(Request request, DataInput in) throws IOException { - super(request, in); - } - - @Override - public RequestType requestType() { - return RequestType.QUERY_CLOSE; - } - - @Override - public ResponseType responseType() { - return ResponseType.QUERY_CLOSE; - } -} diff --git a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryInitRequest.java b/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryInitRequest.java deleted file mode 100644 index becd3fc551b..00000000000 --- a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryInitRequest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto.RequestType; -import org.elasticsearch.xpack.sql.protocol.shared.AbstractQueryInitRequest; -import org.elasticsearch.xpack.sql.protocol.shared.TimeoutInfo; -import org.elasticsearch.xpack.sql.protocol.shared.SqlDataInput; - -import java.io.IOException; -import java.util.TimeZone; - -/** - * Request to start a query. - */ -public class QueryInitRequest extends AbstractQueryInitRequest { - public QueryInitRequest(String query, int fetchSize, TimeZone timeZone, TimeoutInfo timeout) { - super(query, fetchSize, timeZone, timeout); - } - - QueryInitRequest(SqlDataInput in) throws IOException { - super(in); - } - - @Override - public RequestType requestType() { - return RequestType.QUERY_INIT; - } -} diff --git a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryInitResponse.java b/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryInitResponse.java deleted file mode 100644 index 18cde69a15a..00000000000 --- a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryInitResponse.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto.RequestType; -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto.ResponseType; -import org.elasticsearch.xpack.sql.protocol.shared.Request; - -import java.io.DataInput; -import java.io.IOException; - -public class QueryInitResponse extends QueryResponse { - public QueryInitResponse(long tookNanos, String cursor, String data) { - super(tookNanos, cursor, data); - } - - QueryInitResponse(Request request, DataInput in) throws IOException { - super(request, in); - } - - @Override - public RequestType requestType() { - return RequestType.QUERY_INIT; - } - - @Override - public ResponseType responseType() { - return ResponseType.QUERY_INIT; - } -} diff --git a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryPageRequest.java b/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryPageRequest.java deleted file mode 100644 index e30417bc58e..00000000000 --- a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryPageRequest.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto.RequestType; -import org.elasticsearch.xpack.sql.protocol.shared.AbstractQueryPageRequest; -import org.elasticsearch.xpack.sql.protocol.shared.TimeoutInfo; -import org.elasticsearch.xpack.sql.protocol.shared.SqlDataInput; - -import java.io.IOException; - -public class QueryPageRequest extends AbstractQueryPageRequest { - public QueryPageRequest(String cursor, TimeoutInfo timeout) { - super(cursor, timeout); - } - - QueryPageRequest(SqlDataInput in) throws IOException { - super(in); - } - - @Override - public RequestType requestType() { - return RequestType.QUERY_PAGE; - } -} diff --git a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryPageResponse.java b/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryPageResponse.java deleted file mode 100644 index 5bce5284460..00000000000 --- a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryPageResponse.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto.RequestType; -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto.ResponseType; -import org.elasticsearch.xpack.sql.protocol.shared.Request; - -import java.io.DataInput; -import java.io.IOException; - -public class QueryPageResponse extends QueryResponse { - public QueryPageResponse(long tookNanos, String cursor, String data) { - super(tookNanos, cursor, data); - } - - QueryPageResponse(Request request, DataInput in) throws IOException { - super(request, in); - } - - @Override - public RequestType requestType() { - return RequestType.QUERY_PAGE; - } - - @Override - public ResponseType responseType() { - return ResponseType.QUERY_PAGE; - } -} diff --git a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryResponse.java b/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryResponse.java deleted file mode 100644 index 1cd48f212d0..00000000000 --- a/sql/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryResponse.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.xpack.sql.protocol.shared.AbstractQueryResponse; -import org.elasticsearch.xpack.sql.protocol.shared.Request; -import org.elasticsearch.xpack.sql.protocol.shared.SqlDataOutput; - -import java.io.DataInput; -import java.io.IOException; -import java.util.Objects; - -public abstract class QueryResponse extends AbstractQueryResponse { - public final String data; - - protected QueryResponse(long tookNanos, String cursor, String data) { - super(tookNanos, cursor); - if (data == null) { - throw new IllegalArgumentException("data cannot be null"); - } - this.data = data; - } - - protected QueryResponse(Request request, DataInput in) throws IOException { - super(request, in); - data = in.readUTF(); - } - - @Override - protected void writeTo(SqlDataOutput out) throws IOException { - super.writeTo(out); - out.writeUTF(data); - } - - @Override - protected String toStringBody() { - return super.toStringBody() + " data=[" + data + "]"; - } - - @Override - public boolean equals(Object obj) { - if (false == super.equals(obj)) { - return false; - } - QueryResponse other = (QueryResponse) obj; - return data.equals(other.data); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), data); - } -} diff --git a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/CliRoundTripTestUtils.java b/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/CliRoundTripTestUtils.java deleted file mode 100644 index 7093f5ab129..00000000000 --- a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/CliRoundTripTestUtils.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.xpack.sql.protocol.shared.Request; -import org.elasticsearch.xpack.sql.protocol.shared.Response; -import org.elasticsearch.xpack.sql.protocol.shared.TimeoutInfo; -import org.elasticsearch.xpack.sql.test.RoundTripTestUtils; - -import java.io.IOException; - -import static org.elasticsearch.test.ESTestCase.randomNonNegativeLong; - -public final class CliRoundTripTestUtils { - private CliRoundTripTestUtils() { - // Just static utilities - } - - static void assertRoundTripCurrentVersion(Request request) throws IOException { - RoundTripTestUtils.assertRoundTrip(request, Proto.INSTANCE::writeRequest, Proto.INSTANCE::readRequest); - } - - static void assertRoundTripCurrentVersion(Request request, Response response) throws IOException { - RoundTripTestUtils.assertRoundTrip(response, - (r, out) -> Proto.INSTANCE.writeResponse(r, Proto.CURRENT_VERSION, out), - in -> Proto.INSTANCE.readResponse(request, in)); - } - - static TimeoutInfo randomTimeoutInfo() { - return new TimeoutInfo(randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong()); - } -} diff --git a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoRequestTests.java b/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoRequestTests.java deleted file mode 100644 index d0b035b1ccf..00000000000 --- a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoRequestTests.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.test.ESTestCase; - -import java.io.IOException; - -import static org.elasticsearch.xpack.sql.cli.net.protocol.CliRoundTripTestUtils.assertRoundTripCurrentVersion; - -public class InfoRequestTests extends ESTestCase { - static InfoRequest randomInfoRequest() { - return new InfoRequest(randomAlphaOfLength(5), randomAlphaOfLength(5), randomAlphaOfLength(5), - randomAlphaOfLength(5), randomAlphaOfLength(5)); - } - - public void testRoundTrip() throws IOException { - assertRoundTripCurrentVersion(randomInfoRequest()); - } - - public void testToString() { - assertEquals("InfoRequest", - new InfoRequest("1.8.0_131", "testvendor", "testcp", "Mac OS X", "10.12.5").toString()); - } -} diff --git a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoResponseTests.java b/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoResponseTests.java deleted file mode 100644 index 5f3b08480ef..00000000000 --- a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoResponseTests.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.test.ESTestCase; - -import java.io.IOException; - -import static org.elasticsearch.xpack.sql.cli.net.protocol.CliRoundTripTestUtils.assertRoundTripCurrentVersion; -import static org.elasticsearch.xpack.sql.cli.net.protocol.InfoRequestTests.randomInfoRequest; - -public class InfoResponseTests extends ESTestCase { - static InfoResponse randomInfoResponse() { - return new InfoResponse(randomAlphaOfLength(5), randomAlphaOfLength(5), randomByte(), randomByte(), - randomAlphaOfLength(5), randomAlphaOfLength(5), randomAlphaOfLength(5)); - } - - public void testRoundTrip() throws IOException { - assertRoundTripCurrentVersion(randomInfoRequest(), randomInfoResponse()); - } - - public void testToString() { - assertEquals("InfoResponse", - new InfoResponse("adsf", "test_cluster", (byte) 6, (byte) 0, "6.0.0", "feed", "date").toString()); - } -} diff --git a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryCloseRequestTests.java b/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryCloseRequestTests.java deleted file mode 100644 index 2c9bec200d0..00000000000 --- a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryCloseRequestTests.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.sql.protocol.shared.TimeoutInfo; - -import java.io.IOException; - -import static org.elasticsearch.xpack.sql.cli.net.protocol.CliRoundTripTestUtils.assertRoundTripCurrentVersion; - -public class QueryCloseRequestTests extends ESTestCase { - static QueryCloseRequest randomQueryCloseRequest() { - String cursor = randomAlphaOfLength(10); - return new QueryCloseRequest(cursor); - } - - public void testRoundTrip() throws IOException { - assertRoundTripCurrentVersion(randomQueryCloseRequest()); - } - - public void testToString() { - assertEquals("QueryCloseRequest<0320>", new QueryCloseRequest("0320").toString()); - } -} diff --git a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryCloseResponseTests.java b/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryCloseResponseTests.java deleted file mode 100644 index e888b78dba3..00000000000 --- a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryCloseResponseTests.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.test.ESTestCase; - -import java.io.IOException; - -import static org.elasticsearch.xpack.sql.cli.net.protocol.CliRoundTripTestUtils.assertRoundTripCurrentVersion; -import static org.elasticsearch.xpack.sql.cli.net.protocol.QueryCloseRequestTests.randomQueryCloseRequest; - -public class QueryCloseResponseTests extends ESTestCase { - static QueryCloseResponse randomQueryCloseResponse() { - return new QueryCloseResponse(randomBoolean()); - } - - public void testRoundTrip() throws IOException { - assertRoundTripCurrentVersion(randomQueryCloseRequest(), randomQueryCloseResponse()); - } - - public void testToString() { - assertEquals("QueryCloseResponse", - new QueryCloseResponse(true).toString()); - } -} diff --git a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryInitRequestTests.java b/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryInitRequestTests.java deleted file mode 100644 index c27eb3f04b8..00000000000 --- a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryInitRequestTests.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.sql.protocol.shared.TimeoutInfo; - -import java.io.IOException; -import java.util.TimeZone; - -import static org.elasticsearch.xpack.sql.cli.net.protocol.CliRoundTripTestUtils.assertRoundTripCurrentVersion; -import static org.elasticsearch.xpack.sql.cli.net.protocol.CliRoundTripTestUtils.randomTimeoutInfo; - -public class QueryInitRequestTests extends ESTestCase { - static QueryInitRequest randomQueryInitRequest() { - return new QueryInitRequest(randomAlphaOfLength(5), between(0, Integer.MAX_VALUE), randomTimeZone(random()), randomTimeoutInfo()); - } - - public void testRoundTrip() throws IOException { - assertRoundTripCurrentVersion(randomQueryInitRequest()); - } - - public void testToString() { - assertEquals("QueryInitRequest", - new QueryInitRequest("SELECT * FROM test.doc", 10, TimeZone.getTimeZone("UTC"), new TimeoutInfo(1, 1, 1)).toString()); - assertEquals("QueryInitRequest", - new QueryInitRequest("SELECT * FROM test.doc", 10, TimeZone.getTimeZone("GMT-5"), new TimeoutInfo(1, 1, 1)).toString()); - } -} diff --git a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryInitResponseTests.java b/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryInitResponseTests.java deleted file mode 100644 index 8facca8b723..00000000000 --- a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryInitResponseTests.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.test.ESTestCase; - -import java.io.IOException; - -import static org.elasticsearch.xpack.sql.cli.net.protocol.CliRoundTripTestUtils.assertRoundTripCurrentVersion; -import static org.elasticsearch.xpack.sql.cli.net.protocol.QueryInitRequestTests.randomQueryInitRequest; - -public class QueryInitResponseTests extends ESTestCase { - static QueryInitResponse randomQueryInitResponse() { - String cursor = randomAlphaOfLength(10); - return new QueryInitResponse(randomNonNegativeLong(), cursor, randomAlphaOfLength(5)); - } - - public void testRoundTrip() throws IOException { - assertRoundTripCurrentVersion(randomQueryInitRequest(), randomQueryInitResponse()); - } - - public void testToString() { - assertEquals("QueryInitResponse", - new QueryInitResponse(123, "0103", "test").toString()); - } -} diff --git a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryPageRequestTests.java b/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryPageRequestTests.java deleted file mode 100644 index 8680b848046..00000000000 --- a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryPageRequestTests.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.sql.protocol.shared.TimeoutInfo; - -import java.io.IOException; - -import static org.elasticsearch.xpack.sql.cli.net.protocol.CliRoundTripTestUtils.assertRoundTripCurrentVersion; -import static org.elasticsearch.xpack.sql.cli.net.protocol.CliRoundTripTestUtils.randomTimeoutInfo; - -public class QueryPageRequestTests extends ESTestCase { - static QueryPageRequest randomQueryPageRequest() { - String cursor = randomAlphaOfLength(10); - return new QueryPageRequest(cursor, randomTimeoutInfo()); - } - - public void testRoundTrip() throws IOException { - assertRoundTripCurrentVersion(randomQueryPageRequest()); - } - - public void testToString() { - assertEquals("QueryPageRequest<0320>", new QueryPageRequest("0320", new TimeoutInfo(1, 1, 1)).toString()); - } -} diff --git a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryPageResponseTests.java b/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryPageResponseTests.java deleted file mode 100644 index bd7413b6eda..00000000000 --- a/sql/cli-proto/src/test/java/org/elasticsearch/xpack/sql/cli/net/protocol/QueryPageResponseTests.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.cli.net.protocol; - -import org.elasticsearch.test.ESTestCase; - -import java.io.IOException; - -import static org.elasticsearch.xpack.sql.cli.net.protocol.CliRoundTripTestUtils.assertRoundTripCurrentVersion; -import static org.elasticsearch.xpack.sql.cli.net.protocol.QueryPageRequestTests.randomQueryPageRequest; - -public class QueryPageResponseTests extends ESTestCase { - static QueryPageResponse randomQueryPageResponse() { - String cursor = randomAlphaOfLength(10); - return new QueryPageResponse(randomNonNegativeLong(), cursor, randomAlphaOfLength(5)); - } - - public void testRoundTrip() throws IOException { - assertRoundTripCurrentVersion(randomQueryPageRequest(), randomQueryPageResponse()); - } - - public void testToString() { - assertEquals("QueryPageResponse", - new QueryPageResponse(123, "0103", "test").toString()); - } -} diff --git a/sql/cli/build.gradle b/sql/cli/build.gradle index e1146ece4b5..2291277bf02 100644 --- a/sql/cli/build.gradle +++ b/sql/cli/build.gradle @@ -7,30 +7,26 @@ description = 'Command line interface to Elasticsearch that speaks SQL' dependencies { compile "org.jline:jline:3.3.1" compile project(':x-pack-elasticsearch:sql:shared-client') - compile project(':x-pack-elasticsearch:sql:cli-proto') + compile project(':x-pack-elasticsearch:sql:rest-proto') compile project(':x-pack-elasticsearch:sql:shared-proto') compile project(':core:cli') runtime "org.fusesource.jansi:jansi:1.16" runtime "org.elasticsearch:jna:4.4.0-1" - runtime "com.fasterxml.jackson.core:jackson-core:${versions.jackson}" } dependencyLicenses { - mapping from: /cli-proto.*/, to: 'elasticsearch' + mapping from: /rest-proto.*/, to: 'elasticsearch' mapping from: /shared-client.*/, to: 'elasticsearch' mapping from: /shared-proto.*/, to: 'elasticsearch' mapping from: /elasticsearch-cli.*/, to: 'elasticsearch' mapping from: /jackson-.*/, to: 'jackson' - ignoreSha 'cli-proto' + mapping from: /lucene-.*/, to: 'lucene' + ignoreSha 'rest-proto' ignoreSha 'shared-client' ignoreSha 'shared-proto' ignoreSha 'elasticsearch-cli' -} - -forbiddenApisMain { - // does not depend on core, so only jdk and http signatures should be checked - signaturesURLs = [this.class.getResource('/forbidden/jdk-signatures.txt')] + ignoreSha 'elasticsearch' } jar { diff --git a/sql/cli/licenses/joda-time-2.9.5.jar.sha1 b/sql/cli/licenses/joda-time-2.9.5.jar.sha1 new file mode 100644 index 00000000000..ecf1c781556 --- /dev/null +++ b/sql/cli/licenses/joda-time-2.9.5.jar.sha1 @@ -0,0 +1 @@ +5f01da7306363fad2028b916f3eab926262de928 \ No newline at end of file diff --git a/sql/cli/licenses/joda-time-LICENSE.txt b/sql/cli/licenses/joda-time-LICENSE.txt new file mode 100644 index 00000000000..75b52484ea4 --- /dev/null +++ b/sql/cli/licenses/joda-time-LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License 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. diff --git a/sql/cli/licenses/joda-time-NOTICE.txt b/sql/cli/licenses/joda-time-NOTICE.txt new file mode 100644 index 00000000000..dffbcf31cac --- /dev/null +++ b/sql/cli/licenses/joda-time-NOTICE.txt @@ -0,0 +1,5 @@ +============================================================================= += NOTICE file corresponding to section 4d of the Apache License Version 2.0 = +============================================================================= +This product includes software developed by +Joda.org (http://www.joda.org/). diff --git a/sql/cli/licenses/log4j-api-2.9.1.jar.sha1 b/sql/cli/licenses/log4j-api-2.9.1.jar.sha1 new file mode 100644 index 00000000000..e1a89fadfed --- /dev/null +++ b/sql/cli/licenses/log4j-api-2.9.1.jar.sha1 @@ -0,0 +1 @@ +7a2999229464e7a324aa503c0a52ec0f05efe7bd \ No newline at end of file diff --git a/sql/cli/licenses/log4j-api-LICENSE.txt b/sql/cli/licenses/log4j-api-LICENSE.txt new file mode 100644 index 00000000000..6279e5206de --- /dev/null +++ b/sql/cli/licenses/log4j-api-LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 1999-2005 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License 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. diff --git a/sql/cli/licenses/log4j-api-NOTICE.txt b/sql/cli/licenses/log4j-api-NOTICE.txt new file mode 100644 index 00000000000..03757323600 --- /dev/null +++ b/sql/cli/licenses/log4j-api-NOTICE.txt @@ -0,0 +1,5 @@ +Apache log4j +Copyright 2007 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/sql/cli/licenses/log4j-core-2.9.1.jar.sha1 b/sql/cli/licenses/log4j-core-2.9.1.jar.sha1 new file mode 100644 index 00000000000..990ea322a76 --- /dev/null +++ b/sql/cli/licenses/log4j-core-2.9.1.jar.sha1 @@ -0,0 +1 @@ +c041978c686866ee8534f538c6220238db3bb6be \ No newline at end of file diff --git a/sql/cli/licenses/log4j-core-LICENSE.txt b/sql/cli/licenses/log4j-core-LICENSE.txt new file mode 100644 index 00000000000..6279e5206de --- /dev/null +++ b/sql/cli/licenses/log4j-core-LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 1999-2005 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License 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. diff --git a/sql/cli/licenses/log4j-core-NOTICE.txt b/sql/cli/licenses/log4j-core-NOTICE.txt new file mode 100644 index 00000000000..03757323600 --- /dev/null +++ b/sql/cli/licenses/log4j-core-NOTICE.txt @@ -0,0 +1,5 @@ +Apache log4j +Copyright 2007 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/sql/cli/licenses/lucene-LICENSE.txt b/sql/cli/licenses/lucene-LICENSE.txt new file mode 100644 index 00000000000..28b134f5f8e --- /dev/null +++ b/sql/cli/licenses/lucene-LICENSE.txt @@ -0,0 +1,475 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License 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. + + + +Some code in core/src/java/org/apache/lucene/util/UnicodeUtil.java was +derived from unicode conversion examples available at +http://www.unicode.org/Public/PROGRAMS/CVTUTF. Here is the copyright +from those sources: + +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + + +Some code in core/src/java/org/apache/lucene/util/ArrayUtil.java was +derived from Python 2.4.2 sources available at +http://www.python.org. Full license is here: + + http://www.python.org/download/releases/2.4.2/license/ + +Some code in core/src/java/org/apache/lucene/util/UnicodeUtil.java was +derived from Python 3.1.2 sources available at +http://www.python.org. Full license is here: + + http://www.python.org/download/releases/3.1.2/license/ + +Some code in core/src/java/org/apache/lucene/util/automaton was +derived from Brics automaton sources available at +www.brics.dk/automaton/. Here is the copyright from those sources: + +/* + * Copyright (c) 2001-2009 Anders Moeller + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +The levenshtein automata tables in core/src/java/org/apache/lucene/util/automaton +were automatically generated with the moman/finenight FSA package. +Here is the copyright for those sources: + +# Copyright (c) 2010, Jean-Philippe Barrette-LaPierre, +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, +# copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following +# conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +Some code in core/src/java/org/apache/lucene/util/UnicodeUtil.java was +derived from ICU (http://www.icu-project.org) +The full license is available here: + http://source.icu-project.org/repos/icu/icu/trunk/license.html + +/* + * Copyright (C) 1999-2010, International Business Machines + * Corporation and others. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * provided that the above copyright notice(s) and this permission notice appear + * in all copies of the Software and that both the above copyright notice(s) and + * this permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE + * LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization of the + * copyright holder. + */ + +The following license applies to the Snowball stemmers: + +Copyright (c) 2001, Dr Martin Porter +Copyright (c) 2002, Richard Boulton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the copyright holders nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The following license applies to the KStemmer: + +Copyright © 2003, +Center for Intelligent Information Retrieval, +University of Massachusetts, Amherst. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. The names "Center for Intelligent Information Retrieval" and +"University of Massachusetts" must not be used to endorse or promote products +derived from this software without prior written permission. To obtain +permission, contact info@ciir.cs.umass.edu. + +THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF MASSACHUSETTS AND OTHER CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +The following license applies to the Morfologik project: + +Copyright (c) 2006 Dawid Weiss +Copyright (c) 2007-2011 Dawid Weiss, Marcin Miłkowski +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of Morfologik nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--- + +The dictionary comes from Morfologik project. Morfologik uses data from +Polish ispell/myspell dictionary hosted at http://www.sjp.pl/slownik/en/ and +is licenced on the terms of (inter alia) LGPL and Creative Commons +ShareAlike. The part-of-speech tags were added in Morfologik project and +are not found in the data from sjp.pl. The tagset is similar to IPI PAN +tagset. + +--- + +The following license applies to the Morfeusz project, +used by org.apache.lucene.analysis.morfologik. + +BSD-licensed dictionary of Polish (SGJP) +http://sgjp.pl/morfeusz/ + +Copyright © 2011 Zygmunt Saloni, Włodzimierz Gruszczyński, + Marcin Woliński, Robert Wołosz + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDERS “AS IS” AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sql/cli/licenses/lucene-NOTICE.txt b/sql/cli/licenses/lucene-NOTICE.txt new file mode 100644 index 00000000000..1a1d5157243 --- /dev/null +++ b/sql/cli/licenses/lucene-NOTICE.txt @@ -0,0 +1,192 @@ +Apache Lucene +Copyright 2014 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +Includes software from other Apache Software Foundation projects, +including, but not limited to: + - Apache Ant + - Apache Jakarta Regexp + - Apache Commons + - Apache Xerces + +ICU4J, (under analysis/icu) is licensed under an MIT styles license +and Copyright (c) 1995-2008 International Business Machines Corporation and others + +Some data files (under analysis/icu/src/data) are derived from Unicode data such +as the Unicode Character Database. See http://unicode.org/copyright.html for more +details. + +Brics Automaton (under core/src/java/org/apache/lucene/util/automaton) is +BSD-licensed, created by Anders Møller. See http://www.brics.dk/automaton/ + +The levenshtein automata tables (under core/src/java/org/apache/lucene/util/automaton) were +automatically generated with the moman/finenight FSA library, created by +Jean-Philippe Barrette-LaPierre. This library is available under an MIT license, +see http://sites.google.com/site/rrettesite/moman and +http://bitbucket.org/jpbarrette/moman/overview/ + +The class org.apache.lucene.util.WeakIdentityMap was derived from +the Apache CXF project and is Apache License 2.0. + +The Google Code Prettify is Apache License 2.0. +See http://code.google.com/p/google-code-prettify/ + +JUnit (junit-4.10) is licensed under the Common Public License v. 1.0 +See http://junit.sourceforge.net/cpl-v10.html + +This product includes code (JaspellTernarySearchTrie) from Java Spelling Checkin +g Package (jaspell): http://jaspell.sourceforge.net/ +License: The BSD License (http://www.opensource.org/licenses/bsd-license.php) + +The snowball stemmers in + analysis/common/src/java/net/sf/snowball +were developed by Martin Porter and Richard Boulton. +The snowball stopword lists in + analysis/common/src/resources/org/apache/lucene/analysis/snowball +were developed by Martin Porter and Richard Boulton. +The full snowball package is available from + http://snowball.tartarus.org/ + +The KStem stemmer in + analysis/common/src/org/apache/lucene/analysis/en +was developed by Bob Krovetz and Sergio Guzman-Lara (CIIR-UMass Amherst) +under the BSD-license. + +The Arabic,Persian,Romanian,Bulgarian, Hindi and Bengali analyzers (common) come with a default +stopword list that is BSD-licensed created by Jacques Savoy. These files reside in: +analysis/common/src/resources/org/apache/lucene/analysis/ar/stopwords.txt, +analysis/common/src/resources/org/apache/lucene/analysis/fa/stopwords.txt, +analysis/common/src/resources/org/apache/lucene/analysis/ro/stopwords.txt, +analysis/common/src/resources/org/apache/lucene/analysis/bg/stopwords.txt, +analysis/common/src/resources/org/apache/lucene/analysis/hi/stopwords.txt, +analysis/common/src/resources/org/apache/lucene/analysis/bn/stopwords.txt +See http://members.unine.ch/jacques.savoy/clef/index.html. + +The German,Spanish,Finnish,French,Hungarian,Italian,Portuguese,Russian and Swedish light stemmers +(common) are based on BSD-licensed reference implementations created by Jacques Savoy and +Ljiljana Dolamic. These files reside in: +analysis/common/src/java/org/apache/lucene/analysis/de/GermanLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/de/GermanMinimalStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/es/SpanishLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/fi/FinnishLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchMinimalStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/hu/HungarianLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/it/ItalianLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/pt/PortugueseLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/ru/RussianLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/sv/SwedishLightStemmer.java + +The Stempel analyzer (stempel) includes BSD-licensed software developed +by the Egothor project http://egothor.sf.net/, created by Leo Galambos, Martin Kvapil, +and Edmond Nolan. + +The Polish analyzer (stempel) comes with a default +stopword list that is BSD-licensed created by the Carrot2 project. The file resides +in stempel/src/resources/org/apache/lucene/analysis/pl/stopwords.txt. +See http://project.carrot2.org/license.html. + +The SmartChineseAnalyzer source code (smartcn) was +provided by Xiaoping Gao and copyright 2009 by www.imdict.net. + +WordBreakTestUnicode_*.java (under modules/analysis/common/src/test/) +is derived from Unicode data such as the Unicode Character Database. +See http://unicode.org/copyright.html for more details. + +The Morfologik analyzer (morfologik) includes BSD-licensed software +developed by Dawid Weiss and Marcin Miłkowski (http://morfologik.blogspot.com/). + +Morfologik uses data from Polish ispell/myspell dictionary +(http://www.sjp.pl/slownik/en/) licenced on the terms of (inter alia) +LGPL and Creative Commons ShareAlike. + +Morfologic includes data from BSD-licensed dictionary of Polish (SGJP) +(http://sgjp.pl/morfeusz/) + +Servlet-api.jar and javax.servlet-*.jar are under the CDDL license, the original +source code for this can be found at http://www.eclipse.org/jetty/downloads.php + +=========================================================================== +Kuromoji Japanese Morphological Analyzer - Apache Lucene Integration +=========================================================================== + +This software includes a binary and/or source version of data from + + mecab-ipadic-2.7.0-20070801 + +which can be obtained from + + http://atilika.com/releases/mecab-ipadic/mecab-ipadic-2.7.0-20070801.tar.gz + +or + + http://jaist.dl.sourceforge.net/project/mecab/mecab-ipadic/2.7.0-20070801/mecab-ipadic-2.7.0-20070801.tar.gz + +=========================================================================== +mecab-ipadic-2.7.0-20070801 Notice +=========================================================================== + +Nara Institute of Science and Technology (NAIST), +the copyright holders, disclaims all warranties with regard to this +software, including all implied warranties of merchantability and +fitness, in no event shall NAIST be liable for +any special, indirect or consequential damages or any damages +whatsoever resulting from loss of use, data or profits, whether in an +action of contract, negligence or other tortuous action, arising out +of or in connection with the use or performance of this software. + +A large portion of the dictionary entries +originate from ICOT Free Software. The following conditions for ICOT +Free Software applies to the current dictionary as well. + +Each User may also freely distribute the Program, whether in its +original form or modified, to any third party or parties, PROVIDED +that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear +on, or be attached to, the Program, which is distributed substantially +in the same form as set out herein and that such intended +distribution, if actually made, will neither violate or otherwise +contravene any of the laws and regulations of the countries having +jurisdiction over the User or the intended distribution itself. + +NO WARRANTY + +The program was produced on an experimental basis in the course of the +research and development conducted during the project and is provided +to users as so produced on an experimental basis. Accordingly, the +program is provided without any warranty whatsoever, whether express, +implied, statutory or otherwise. The term "warranty" used herein +includes, but is not limited to, any warranty of the quality, +performance, merchantability and fitness for a particular purpose of +the program and the nonexistence of any infringement or violation of +any right of any third party. + +Each user of the program will agree and understand, and be deemed to +have agreed and understood, that there is no warranty whatsoever for +the program and, accordingly, the entire risk arising from or +otherwise connected with the program is assumed by the user. + +Therefore, neither ICOT, the copyright holder, or any other +organization that participated in or was otherwise related to the +development of the program and their respective officials, directors, +officers and other employees shall be held liable for any and all +damages, including, without limitation, general, special, incidental +and consequential damages, arising out of or otherwise in connection +with the use or inability to use the program or any product, material +or result produced or otherwise obtained by using the program, +regardless of whether they have been advised of, or otherwise had +knowledge of, the possibility of such damages at any time during the +project or thereafter. Each user will be deemed to have agreed to the +foregoing by his or her commencement of use of the program. The term +"use" as used herein includes, but is not limited to, the use, +modification, copying and distribution of the program and the +production of secondary products from the program. + +In the case where the program, whether in its original form or +modified, was distributed or delivered to or received by a user from +any person, organization or entity other than ICOT, unless it makes or +grants independently of ICOT any specific warranty to the user in +writing, such person, organization or entity, will also be exempted +from and not be held liable to the user for any such damages as noted +above as far as the program is concerned. diff --git a/sql/cli/licenses/lucene-core-7.2.0.jar.sha1 b/sql/cli/licenses/lucene-core-7.2.0.jar.sha1 new file mode 100644 index 00000000000..41e1103ca25 --- /dev/null +++ b/sql/cli/licenses/lucene-core-7.2.0.jar.sha1 @@ -0,0 +1 @@ +f88107aa577ce8edc0a5cee036b485943107a552 \ No newline at end of file diff --git a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java index a6199981e98..20854fecb51 100644 --- a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java +++ b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java @@ -7,8 +7,8 @@ package org.elasticsearch.xpack.sql.cli; import joptsimple.OptionSet; import joptsimple.OptionSpec; -import org.elasticsearch.cli.Command; import org.elasticsearch.cli.ExitCodes; +import org.elasticsearch.cli.LoggingAwareCommand; import org.elasticsearch.cli.Terminal; import org.elasticsearch.cli.UserException; import org.elasticsearch.xpack.sql.cli.command.ClearScreenCliCommand; @@ -30,14 +30,14 @@ import java.util.Arrays; import java.util.List; import java.util.logging.LogManager; -public class Cli extends Command { +public class Cli extends LoggingAwareCommand { private final OptionSpec debugOption; private final OptionSpec keystoreLocation; private final OptionSpec checkOption; private final OptionSpec connectionString; private Cli() { - super("Elasticsearch SQL CLI", Cli::configureLogging); + super("Elasticsearch SQL CLI"); this.debugOption = parser.acceptsAll(Arrays.asList("d", "debug"), "Enable debug logging") .withRequiredArg().ofType(Boolean.class) @@ -65,13 +65,14 @@ public class Cli extends Command { */ public static void main(String[] args) throws Exception { final Cli cli = new Cli(); + configureJLineLogging(); int status = cli.main(args, Terminal.DEFAULT); if (status != ExitCodes.OK) { exit(status); } } - private static void configureLogging() { + private static void configureJLineLogging() { try { /* Initialize the logger from the a properties file we bundle. This makes sure * we get useful error messages from jLine. */ @@ -134,7 +135,7 @@ public class Cli extends Command { throw new UserException(ExitCodes.IO_ERROR, "Cannot connect to the server " + con.connectionString() + " - " + ex.getCause().getMessage()); } else { - // Most likely we connected to an old version of Elasticsearch or not Elasticsearch at all + // Most likely we connected to something other than Elasticsearch throw new UserException(ExitCodes.DATA_ERROR, "Cannot communicate with the server " + con.connectionString() + ". This version of CLI only works with Elasticsearch version " + Version.CURRENT.toString()); diff --git a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/CliHttpClient.java b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/CliHttpClient.java index e32a013de02..c040b03ab5b 100644 --- a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/CliHttpClient.java +++ b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/CliHttpClient.java @@ -5,70 +5,140 @@ */ package org.elasticsearch.xpack.sql.cli; -import org.elasticsearch.xpack.sql.cli.net.protocol.InfoRequest; -import org.elasticsearch.xpack.sql.cli.net.protocol.InfoResponse; -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto; -import org.elasticsearch.xpack.sql.cli.net.protocol.QueryCloseRequest; -import org.elasticsearch.xpack.sql.cli.net.protocol.QueryCloseResponse; -import org.elasticsearch.xpack.sql.cli.net.protocol.QueryInitRequest; -import org.elasticsearch.xpack.sql.cli.net.protocol.QueryPageRequest; -import org.elasticsearch.xpack.sql.cli.net.protocol.QueryResponse; +import org.apache.lucene.util.BytesRef; +import org.elasticsearch.action.main.MainResponse; +import org.elasticsearch.common.CheckedFunction; +import org.elasticsearch.common.io.Streams; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.xcontent.NamedXContentRegistry; +import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.XContentHelper; +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.xpack.sql.client.shared.ClientException; import org.elasticsearch.xpack.sql.client.shared.ConnectionConfiguration; import org.elasticsearch.xpack.sql.client.shared.JreHttpUrlConnection; -import org.elasticsearch.xpack.sql.client.shared.JreHttpUrlConnection.ResponseOrException; -import org.elasticsearch.xpack.sql.protocol.shared.Request; -import org.elasticsearch.xpack.sql.protocol.shared.Response; -import org.elasticsearch.xpack.sql.protocol.shared.TimeoutInfo; +import org.elasticsearch.xpack.sql.plugin.SqlAction; +import org.elasticsearch.xpack.sql.plugin.SqlClearCursorAction; +import org.elasticsearch.xpack.sql.plugin.SqlClearCursorRequest; +import org.elasticsearch.xpack.sql.plugin.SqlClearCursorResponse; +import org.elasticsearch.xpack.sql.plugin.SqlRequest; +import org.joda.time.DateTimeZone; -import java.security.AccessController; -import java.security.PrivilegedAction; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.sql.SQLException; -import java.time.Instant; -import java.util.Collections; -import java.util.Map; -import java.util.TimeZone; +import java.util.function.Function; public class CliHttpClient { + private static final XContentType REQUEST_BODY_CONTENT_TYPE = XContentType.JSON; + private final ConnectionConfiguration cfg; public CliHttpClient(ConnectionConfiguration cfg) { this.cfg = cfg; } - public InfoResponse serverInfo() throws SQLException { - InfoRequest request = new InfoRequest(); - return (InfoResponse) post(request); + private NamedXContentRegistry registry = NamedXContentRegistry.EMPTY; + + public MainResponse serverInfo() throws SQLException { + return get("/", MainResponse::fromXContent); } - public QueryResponse queryInit(String query, int fetchSize) throws SQLException { + public PlainResponse queryInit(String query, int fetchSize) throws SQLException { // TODO allow customizing the time zone - this is what session set/reset/get should be about - QueryInitRequest request = new QueryInitRequest(query, fetchSize, TimeZone.getTimeZone("UTC"), timeout()); - return (QueryResponse) post(request); + SqlRequest sqlRequest = new SqlRequest(query, null, DateTimeZone.UTC, fetchSize, TimeValue.timeValueMillis(cfg.queryTimeout()), + TimeValue.timeValueMillis(cfg.pageTimeout()), ""); + return postPlain(SqlAction.REST_ENDPOINT, sqlRequest); } - public QueryResponse nextPage(String cursor) throws SQLException { - QueryPageRequest request = new QueryPageRequest(cursor, timeout()); - return (QueryResponse) post(request); + public PlainResponse nextPage(String cursor) throws SQLException { + SqlRequest sqlRequest = new SqlRequest(); + sqlRequest.cursor(cursor); + return postPlain(SqlAction.REST_ENDPOINT, sqlRequest); } - public QueryCloseResponse queryClose(String cursor) throws SQLException { - QueryCloseRequest request = new QueryCloseRequest(cursor); - return (QueryCloseResponse) post(request); + public boolean queryClose(String cursor) throws SQLException { + SqlClearCursorResponse response = post(SqlClearCursorAction.REST_ENDPOINT, + new SqlClearCursorRequest(cursor), + SqlClearCursorResponse::fromXContent); + return response.isSucceeded(); } - private TimeoutInfo timeout() { - long clientTime = Instant.now().toEpochMilli(); - return new TimeoutInfo(clientTime, cfg.queryTimeout(), cfg.pageTimeout()); - } - - private Response post(Request request) throws SQLException { - return AccessController.doPrivileged((PrivilegedAction>) () -> - JreHttpUrlConnection.http("_xpack/sql/cli", "error_trace", cfg, con -> - con.post( - out -> Proto.INSTANCE.writeRequest(request, out), - in -> Proto.INSTANCE.readResponse(request, in) + private Response post(String path, Request request, + CheckedFunction responseParser) + throws SQLException { + return JreHttpUrlConnection.http(path, "error_trace", cfg, con -> + con.request( + outputStream -> writeTo(request, outputStream), + (in, headers) -> readFrom(in, headers, responseParser), + "POST" ) - ) ).getResponseOrThrowException(); } + + private Response get(String path, CheckedFunction responseParser) + throws SQLException { + return JreHttpUrlConnection.http(path, "error_trace", cfg, con -> + con.request( + null, + (in, headers) -> readFrom(in, headers, responseParser), + "GET" + ) + ).getResponseOrThrowException(); + } + + private PlainResponse postPlain(String path, Request request) throws SQLException { + return JreHttpUrlConnection.http(path, "error_trace", cfg, con -> + con.request( + outputStream -> { + writeTo(request, outputStream); + }, + (in, headers) -> { + String cursor = headers.apply("Cursor"); + long tookNanos; + try { + tookNanos = Long.parseLong(headers.apply("Took-nanos")); + } catch (NumberFormatException ex) { + throw new ClientException("Cannot parse Took-nanos header [" + headers.apply("Took-nanos") + "]"); + } + return new PlainResponse(tookNanos, cursor == null ? "" : cursor, readData(in)); + }, + "POST" + ) + ).getResponseOrThrowException(); + } + + private static void writeTo(Request xContent, OutputStream outputStream) { + try { + BytesRef source = XContentHelper.toXContent(xContent, REQUEST_BODY_CONTENT_TYPE, false).toBytesRef(); + outputStream.write(source.bytes, source.offset, source.length); + } catch (IOException ex) { + throw new ClientException("Cannot serialize request", ex); + } + + } + + private Response readFrom(InputStream inputStream, Function headers, + CheckedFunction responseParser) { + String contentType = headers.apply("Content-Type"); + XContentType xContentType = XContentType.fromMediaTypeOrFormat(contentType); + if (xContentType == null) { + throw new IllegalStateException("Unsupported Content-Type: " + contentType); + } + try (XContentParser parser = xContentType.xContent().createParser(registry, inputStream)) { + return responseParser.apply(parser); + } catch (IOException ex) { + throw new ClientException("Cannot parse response", ex); + } + } + + private static String readData(InputStream in) throws IOException { + return Streams.copyToString(new InputStreamReader(new BufferedInputStream(in), StandardCharsets.UTF_8)); + } + } diff --git a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/ConnectionBuilder.java b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/ConnectionBuilder.java index 8f209e6d98a..d3f878e6849 100644 --- a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/ConnectionBuilder.java +++ b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/ConnectionBuilder.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.sql.cli; import org.elasticsearch.cli.ExitCodes; import org.elasticsearch.cli.UserException; +import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.xpack.sql.client.shared.ConnectionConfiguration; import java.net.URI; @@ -33,9 +34,11 @@ public class ConnectionBuilder { /** * Build the connection. + * * @param connectionStringArg the connection string to connect to - * @param keystoreLocation the location of the keystore to configure. If null then use the system keystore. + * @param keystoreLocation the location of the keystore to configure. If null then use the system keystore. */ + @SuppressForbidden(reason = "cli application") public ConnectionConfiguration buildConnection(String connectionStringArg, String keystoreLocation) throws UserException { final URI uri; final String connectionString; diff --git a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/PlainResponse.java b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/PlainResponse.java new file mode 100644 index 00000000000..18185692a19 --- /dev/null +++ b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/PlainResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.xpack.sql.cli; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringWriter; +import java.nio.charset.StandardCharsets; + +/** + * Plain text tabular SQL response + */ +public class PlainResponse { + public final long tookNanos; + public final String data; + public final String cursor; + + public PlainResponse(long tookNanos, String cursor, String data) { + this.data = data; + this.tookNanos = tookNanos; + this.cursor = cursor; + } +} + diff --git a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/AbstractServerCliCommand.java b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/AbstractServerCliCommand.java index bee868bdac2..346592df5d8 100644 --- a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/AbstractServerCliCommand.java +++ b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/AbstractServerCliCommand.java @@ -29,7 +29,8 @@ public abstract class AbstractServerCliCommand implements CliCommand { * into a method so that tests can bubble the failure. */ protected void handleExceptionWhileCommunicatingWithServer(CliTerminal terminal, CliSession cliSession, RuntimeException e) { - terminal.line().error("Communication error [").param(e.getMessage()).error("]").ln(); + terminal.line().error("Communication error [").param(e.getMessage() == null ? e.getClass().getName() : e.getMessage()).error("]") + .ln(); if (cliSession.isDebug()) { terminal.printStackTrace(e); } diff --git a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/CliSession.java b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/CliSession.java index cf1ac8f9083..b5dc4e75c19 100644 --- a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/CliSession.java +++ b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/CliSession.java @@ -5,8 +5,8 @@ */ package org.elasticsearch.xpack.sql.cli.command; +import org.elasticsearch.action.main.MainResponse; import org.elasticsearch.xpack.sql.cli.CliHttpClient; -import org.elasticsearch.xpack.sql.cli.net.protocol.InfoResponse; import org.elasticsearch.xpack.sql.client.shared.ClientException; import org.elasticsearch.xpack.sql.client.shared.Version; import org.elasticsearch.xpack.sql.protocol.shared.AbstractQueryInitRequest; @@ -58,14 +58,14 @@ public class CliSession { } public void checkConnection() throws ClientException { - InfoResponse response; + MainResponse response; try { response = cliHttpClient.serverInfo(); } catch (SQLException ex) { throw new ClientException(ex); } // TODO: We can relax compatibility requirement later when we have a better idea about protocol compatibility guarantees - if (response.majorVersion != Version.CURRENT.major || response.minorVersion != Version.CURRENT.minor) { + if (response.getVersion().major != Version.CURRENT.major || response.getVersion().minor != Version.CURRENT.minor) { throw new ClientException("This alpha version of CLI is only compatible with Elasticsearch version " + Version.CURRENT.toString()); } diff --git a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/ServerInfoCliCommand.java b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/ServerInfoCliCommand.java index cc4830a40fd..635c041da7a 100644 --- a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/ServerInfoCliCommand.java +++ b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/ServerInfoCliCommand.java @@ -5,8 +5,8 @@ */ package org.elasticsearch.xpack.sql.cli.command; +import org.elasticsearch.action.main.MainResponse; import org.elasticsearch.xpack.sql.cli.CliTerminal; -import org.elasticsearch.xpack.sql.cli.net.protocol.InfoResponse; import java.sql.SQLException; import java.util.Locale; @@ -21,7 +21,7 @@ public class ServerInfoCliCommand extends AbstractServerCliCommand { if (false == "info".equals(line.toLowerCase(Locale.ROOT))) { return false; } - InfoResponse info; + MainResponse info; try { info = cliSession.getClient().serverInfo(); } catch (SQLException e) { @@ -29,9 +29,9 @@ public class ServerInfoCliCommand extends AbstractServerCliCommand { return true; } terminal.line() - .text("Node:").em(info.node) - .text(" Cluster:").em(info.cluster) - .text(" Version:").em(info.versionString) + .text("Node:").em(info.getNodeName()) + .text(" Cluster:").em(info.getClusterName().value()) + .text(" Version:").em(info.getVersion().toString()) .ln(); return true; } diff --git a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/ServerQueryCliCommand.java b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/ServerQueryCliCommand.java index c75a3784101..633ce18de1a 100644 --- a/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/ServerQueryCliCommand.java +++ b/sql/cli/src/main/java/org/elasticsearch/xpack/sql/cli/command/ServerQueryCliCommand.java @@ -5,9 +5,10 @@ */ package org.elasticsearch.xpack.sql.cli.command; +import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.xpack.sql.cli.CliHttpClient; import org.elasticsearch.xpack.sql.cli.CliTerminal; -import org.elasticsearch.xpack.sql.cli.net.protocol.QueryResponse; +import org.elasticsearch.xpack.sql.cli.PlainResponse; import org.elasticsearch.xpack.sql.client.shared.JreHttpUrlConnection; import java.io.IOException; @@ -21,7 +22,7 @@ public class ServerQueryCliCommand extends AbstractServerCliCommand { @Override protected boolean doHandle(CliTerminal terminal, CliSession cliSession, String line) { - QueryResponse response = null; + PlainResponse response = null; CliHttpClient cliClient = cliSession.getClient(); try { response = cliClient.queryInit(line, cliSession.getFetchSize()); @@ -31,7 +32,7 @@ public class ServerQueryCliCommand extends AbstractServerCliCommand { } while (true) { handleText(terminal, response.data); - if (response.cursor().isEmpty()) { + if (response.cursor.isEmpty()) { // Successfully finished the entire query! terminal.flush(); return true; @@ -39,7 +40,7 @@ public class ServerQueryCliCommand extends AbstractServerCliCommand { if (false == cliSession.getFetchSeparator().equals("")) { terminal.println(cliSession.getFetchSeparator()); } - response = cliSession.getClient().nextPage(response.cursor()); + response = cliSession.getClient().nextPage(response.cursor); } } catch (SQLException e) { if (JreHttpUrlConnection.SQL_STATE_BAD_SERVER.equals(e.getSQLState())) { @@ -47,9 +48,9 @@ public class ServerQueryCliCommand extends AbstractServerCliCommand { } else { terminal.error("Bad request", e.getMessage()); } - if (response != null && response.cursor().isEmpty() == false) { + if (response != null) { try { - cliClient.queryClose(response.cursor()); + cliClient.queryClose(response.cursor); } catch (SQLException ex) { terminal.error("Could not close cursor", ex.getMessage()); } @@ -62,6 +63,7 @@ public class ServerQueryCliCommand extends AbstractServerCliCommand { terminal.print(str); } + @SuppressForbidden(reason = "cli application") private void handleGraphviz(CliTerminal terminal, String str) { try { // save the content to a temp file diff --git a/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/CliSessionTests.java b/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/CliSessionTests.java index 2c4a48d5918..9fbee63c2d9 100644 --- a/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/CliSessionTests.java +++ b/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/CliSessionTests.java @@ -5,11 +5,14 @@ */ package org.elasticsearch.xpack.sql.cli; -import org.elasticsearch.Version; +import org.elasticsearch.Build; +import org.elasticsearch.action.main.MainResponse; +import org.elasticsearch.cluster.ClusterName; +import org.elasticsearch.common.UUIDs; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.sql.cli.command.CliSession; -import org.elasticsearch.xpack.sql.cli.net.protocol.InfoResponse; import org.elasticsearch.xpack.sql.client.shared.ClientException; +import org.elasticsearch.xpack.sql.client.shared.Version; import java.sql.SQLException; @@ -23,9 +26,8 @@ public class CliSessionTests extends ESTestCase { public void testProperConnection() throws Exception { CliHttpClient cliHttpClient = mock(CliHttpClient.class); - when(cliHttpClient.serverInfo()).thenReturn(new InfoResponse(randomAlphaOfLength(5), randomAlphaOfLength(5), - Version.CURRENT.major, Version.CURRENT.minor, - randomAlphaOfLength(5), randomAlphaOfLength(5), randomAlphaOfLength(5))); + when(cliHttpClient.serverInfo()).thenReturn(new MainResponse(randomAlphaOfLength(5), org.elasticsearch.Version.CURRENT, + ClusterName.DEFAULT, UUIDs.randomBase64UUID(), Build.CURRENT, randomBoolean())); CliSession cliSession = new CliSession(cliHttpClient); cliSession.checkConnection(); verify(cliHttpClient, times(1)).serverInfo(); @@ -53,8 +55,9 @@ public class CliSessionTests extends ESTestCase { major = Version.CURRENT.major; } - when(cliHttpClient.serverInfo()).thenReturn(new InfoResponse(randomAlphaOfLength(5), randomAlphaOfLength(5), - minor, major, randomAlphaOfLength(5), randomAlphaOfLength(5), randomAlphaOfLength(5))); + when(cliHttpClient.serverInfo()).thenReturn(new MainResponse(randomAlphaOfLength(5), + org.elasticsearch.Version.fromString(major + "." + minor + ".23"), + ClusterName.DEFAULT, UUIDs.randomBase64UUID(), Build.CURRENT, randomBoolean())); CliSession cliSession = new CliSession(cliHttpClient); expectThrows(ClientException.class, cliSession::checkConnection); verify(cliHttpClient, times(1)).serverInfo(); diff --git a/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/command/ServerInfoCliCommandTests.java b/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/command/ServerInfoCliCommandTests.java index 18f281e0368..bc3f61e5109 100644 --- a/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/command/ServerInfoCliCommandTests.java +++ b/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/command/ServerInfoCliCommandTests.java @@ -5,10 +5,13 @@ */ package org.elasticsearch.xpack.sql.cli.command; +import org.elasticsearch.Build; +import org.elasticsearch.action.main.MainResponse; +import org.elasticsearch.cluster.ClusterName; +import org.elasticsearch.common.UUIDs; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.sql.cli.CliHttpClient; import org.elasticsearch.xpack.sql.cli.TestTerminal; -import org.elasticsearch.xpack.sql.cli.net.protocol.InfoResponse; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -32,10 +35,11 @@ public class ServerInfoCliCommandTests extends ESTestCase { TestTerminal testTerminal = new TestTerminal(); CliHttpClient client = mock(CliHttpClient.class); CliSession cliSession = new CliSession(client); - when(client.serverInfo()).thenReturn(new InfoResponse("my_node", "my_cluster", (byte) 1, (byte) 2, "v1.2", "1234", "Sep 1, 2017")); + when(client.serverInfo()).thenReturn(new MainResponse("my_node", org.elasticsearch.Version.fromString("1.2.3"), + new ClusterName("my_cluster"), UUIDs.randomBase64UUID(), Build.CURRENT, randomBoolean())); ServerInfoCliCommand cliCommand = new ServerInfoCliCommand(); assertTrue(cliCommand.handle(testTerminal, cliSession, "info")); - assertEquals(testTerminal.toString(), "Node:my_node Cluster:my_cluster Version:v1.2\n"); + assertEquals(testTerminal.toString(), "Node:my_node Cluster:my_cluster Version:1.2.3\n"); verify(client, times(1)).serverInfo(); verifyNoMoreInteractions(client); } diff --git a/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/command/ServerQueryCliCommandTests.java b/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/command/ServerQueryCliCommandTests.java index f4b7c1b039f..ed06d22e89a 100644 --- a/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/command/ServerQueryCliCommandTests.java +++ b/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/command/ServerQueryCliCommandTests.java @@ -8,9 +8,7 @@ package org.elasticsearch.xpack.sql.cli.command; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.sql.cli.CliHttpClient; import org.elasticsearch.xpack.sql.cli.TestTerminal; -import org.elasticsearch.xpack.sql.cli.net.protocol.QueryCloseResponse; -import org.elasticsearch.xpack.sql.cli.net.protocol.QueryInitResponse; -import org.elasticsearch.xpack.sql.cli.net.protocol.QueryPageResponse; +import org.elasticsearch.xpack.sql.cli.PlainResponse; import java.sql.SQLException; @@ -41,7 +39,7 @@ public class ServerQueryCliCommandTests extends ESTestCase { CliHttpClient client = mock(CliHttpClient.class); CliSession cliSession = new CliSession(client); cliSession.setFetchSize(10); - when(client.queryInit("test query", 10)).thenReturn(new QueryInitResponse(123, "", "some command response")); + when(client.queryInit("test query", 10)).thenReturn(new PlainResponse(123, "", "some command response")); ServerQueryCliCommand cliCommand = new ServerQueryCliCommand(); assertTrue(cliCommand.handle(testTerminal, cliSession, "test query")); assertEquals("some command response", testTerminal.toString()); @@ -54,9 +52,9 @@ public class ServerQueryCliCommandTests extends ESTestCase { CliHttpClient client = mock(CliHttpClient.class); CliSession cliSession = new CliSession(client); cliSession.setFetchSize(10); - when(client.queryInit("test query", 10)).thenReturn(new QueryInitResponse(123, "my_cursor1", "first")); - when(client.nextPage("my_cursor1")).thenReturn(new QueryPageResponse(345, "my_cursor2", "second")); - when(client.nextPage("my_cursor2")).thenReturn(new QueryPageResponse(678, "", "third")); + when(client.queryInit("test query", 10)).thenReturn(new PlainResponse(123, "my_cursor1", "first")); + when(client.nextPage("my_cursor1")).thenReturn(new PlainResponse(345, "my_cursor2", "second")); + when(client.nextPage("my_cursor2")).thenReturn(new PlainResponse(678, "", "third")); ServerQueryCliCommand cliCommand = new ServerQueryCliCommand(); assertTrue(cliCommand.handle(testTerminal, cliSession, "test query")); assertEquals("firstsecondthird", testTerminal.toString()); @@ -72,8 +70,8 @@ public class ServerQueryCliCommandTests extends ESTestCase { cliSession.setFetchSize(15); // Set a separator cliSession.setFetchSeparator("-----"); - when(client.queryInit("test query", 15)).thenReturn(new QueryInitResponse(123, "my_cursor1", "first")); - when(client.nextPage("my_cursor1")).thenReturn(new QueryPageResponse(345, "", "second")); + when(client.queryInit("test query", 15)).thenReturn(new PlainResponse(123, "my_cursor1", "first")); + when(client.nextPage("my_cursor1")).thenReturn(new PlainResponse(345, "", "second")); ServerQueryCliCommand cliCommand = new ServerQueryCliCommand(); assertTrue(cliCommand.handle(testTerminal, cliSession, "test query")); assertEquals("first-----\nsecond", testTerminal.toString()); @@ -87,9 +85,9 @@ public class ServerQueryCliCommandTests extends ESTestCase { CliHttpClient client = mock(CliHttpClient.class); CliSession cliSession = new CliSession(client); cliSession.setFetchSize(15); - when(client.queryInit("test query", 15)).thenReturn(new QueryInitResponse(123, "my_cursor1", "first")); + when(client.queryInit("test query", 15)).thenReturn(new PlainResponse(123, "my_cursor1", "first")); when(client.nextPage("my_cursor1")).thenThrow(new SQLException("test exception")); - when(client.queryClose("my_cursor1")).thenReturn(new QueryCloseResponse(true)); + when(client.queryClose("my_cursor1")).thenReturn(true); ServerQueryCliCommand cliCommand = new ServerQueryCliCommand(); assertTrue(cliCommand.handle(testTerminal, cliSession, "test query")); assertEquals("firstBad request [test exception]\n", testTerminal.toString()); diff --git a/sql/rest-proto/build.gradle b/sql/rest-proto/build.gradle new file mode 100644 index 00000000000..f7548656579 --- /dev/null +++ b/sql/rest-proto/build.gradle @@ -0,0 +1,134 @@ +description = 'Request and response objects shared by the cli and ' + + 'its backend in :sql:server' + +dependencies { + compile project(':x-pack-elasticsearch:sql:shared-proto') + compile (project(':core')) { + transitive = false + } + compile "org.apache.lucene:lucene-core:${versions.lucene}" + compile 'joda-time:joda-time:2.9.5' + runtime "com.fasterxml.jackson.core:jackson-core:${versions.jackson}" + runtime "org.apache.logging.log4j:log4j-api:${versions.log4j}" + runtime "org.apache.logging.log4j:log4j-core:${versions.log4j}" + + testCompile project(':x-pack-elasticsearch:sql:test-utils') +} + +dependencyLicenses { + mapping from: /shared-proto.*/, to: 'elasticsearch' + ignoreSha 'shared-proto' +} + +dependencyLicenses { + mapping from: /jackson-.*/, to: 'jackson' + mapping from: /lucene-.*/, to: 'lucene' + ignoreSha 'elasticsearch' +} + +thirdPartyAudit.excludes = [ + + 'com.fasterxml.jackson.dataformat.yaml.YAMLFactory', + 'com.fasterxml.jackson.dataformat.yaml.YAMLMapper', + + // from com.fasterxml.jackson.dataformat.yaml.YAMLMapper (jackson-dataformat-yaml) + 'com.fasterxml.jackson.databind.ObjectMapper', + 'org.fusesource.jansi.Ansi', + 'org.fusesource.jansi.AnsiRenderer$Code', + + // from log4j + 'com.conversantmedia.util.concurrent.DisruptorBlockingQueue', + 'com.conversantmedia.util.concurrent.SpinPolicy', + 'com.fasterxml.jackson.annotation.JsonInclude$Include', + 'com.fasterxml.jackson.databind.DeserializationContext', + 'com.fasterxml.jackson.databind.DeserializationFeature', + 'com.fasterxml.jackson.databind.JsonMappingException', + 'com.fasterxml.jackson.databind.JsonNode', + 'com.fasterxml.jackson.databind.Module$SetupContext', + 'com.fasterxml.jackson.databind.ObjectReader', + 'com.fasterxml.jackson.databind.ObjectWriter', + 'com.fasterxml.jackson.databind.SerializerProvider', + 'com.fasterxml.jackson.databind.deser.std.StdDeserializer', + 'com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer', + 'com.fasterxml.jackson.databind.module.SimpleModule', + 'com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter', + 'com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider', + 'com.fasterxml.jackson.databind.ser.std.StdScalarSerializer', + 'com.fasterxml.jackson.databind.ser.std.StdSerializer', + 'com.fasterxml.jackson.dataformat.xml.JacksonXmlModule', + 'com.fasterxml.jackson.dataformat.xml.XmlMapper', + 'com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter', + 'com.fasterxml.jackson.databind.node.JsonNodeFactory', + 'com.fasterxml.jackson.databind.node.ObjectNode', + 'com.lmax.disruptor.BlockingWaitStrategy', + 'com.lmax.disruptor.BusySpinWaitStrategy', + 'com.lmax.disruptor.EventFactory', + 'com.lmax.disruptor.EventTranslator', + 'com.lmax.disruptor.EventTranslatorTwoArg', + 'com.lmax.disruptor.EventTranslatorVararg', + 'com.lmax.disruptor.ExceptionHandler', + 'com.lmax.disruptor.LifecycleAware', + 'com.lmax.disruptor.RingBuffer', + 'com.lmax.disruptor.Sequence', + 'com.lmax.disruptor.SequenceReportingEventHandler', + 'com.lmax.disruptor.SleepingWaitStrategy', + 'com.lmax.disruptor.TimeoutBlockingWaitStrategy', + 'com.lmax.disruptor.WaitStrategy', + 'com.lmax.disruptor.YieldingWaitStrategy', + 'com.lmax.disruptor.dsl.Disruptor', + 'com.lmax.disruptor.dsl.ProducerType', + 'javax.jms.Connection', + 'javax.jms.ConnectionFactory', + 'javax.jms.Destination', + 'javax.jms.JMSException', + 'javax.jms.MapMessage', + 'javax.jms.Message', + 'javax.jms.MessageConsumer', + 'javax.jms.MessageProducer', + 'javax.jms.Session', + 'javax.mail.Authenticator', + 'javax.mail.Message$RecipientType', + 'javax.mail.PasswordAuthentication', + 'javax.mail.Session', + 'javax.mail.Transport', + 'javax.mail.internet.InternetAddress', + 'javax.mail.internet.InternetHeaders', + 'javax.mail.internet.MimeBodyPart', + 'javax.mail.internet.MimeMessage', + 'javax.mail.internet.MimeMultipart', + 'javax.mail.internet.MimeUtility', + 'javax.mail.util.ByteArrayDataSource', + 'javax.persistence.AttributeConverter', + 'javax.persistence.EntityManager', + 'javax.persistence.EntityManagerFactory', + 'javax.persistence.EntityTransaction', + 'javax.persistence.Persistence', + 'javax.persistence.PersistenceException', + 'org.apache.commons.compress.compressors.CompressorStreamFactory', + 'org.apache.commons.compress.utils.IOUtils', + 'org.apache.commons.csv.CSVFormat', + 'org.apache.commons.csv.QuoteMode', + 'org.apache.kafka.clients.producer.Callback', + 'org.apache.kafka.clients.producer.KafkaProducer', + 'org.apache.kafka.clients.producer.Producer', + 'org.apache.kafka.clients.producer.ProducerRecord', + 'org.apache.kafka.clients.producer.RecordMetadata', + 'org.codehaus.stax2.XMLStreamWriter2', + 'org.jctools.queues.MessagePassingQueue$Consumer', + 'org.jctools.queues.MpscArrayQueue', + 'org.osgi.framework.AdaptPermission', + 'org.osgi.framework.AdminPermission', + 'org.osgi.framework.Bundle', + 'org.osgi.framework.BundleActivator', + 'org.osgi.framework.BundleContext', + 'org.osgi.framework.BundleEvent', + 'org.osgi.framework.BundleReference', + 'org.osgi.framework.FrameworkUtil', + 'org.osgi.framework.ServiceRegistration', + 'org.osgi.framework.SynchronousBundleListener', + 'org.osgi.framework.wiring.BundleWire', + 'org.osgi.framework.wiring.BundleWiring', + 'org.zeromq.ZMQ$Context', + 'org.zeromq.ZMQ$Socket', + 'org.zeromq.ZMQ' +] diff --git a/sql/cli-proto/licenses/elasticsearch-LICENSE.txt b/sql/rest-proto/licenses/elasticsearch-LICENSE.txt similarity index 100% rename from sql/cli-proto/licenses/elasticsearch-LICENSE.txt rename to sql/rest-proto/licenses/elasticsearch-LICENSE.txt diff --git a/sql/cli-proto/licenses/elasticsearch-NOTICE.txt b/sql/rest-proto/licenses/elasticsearch-NOTICE.txt similarity index 100% rename from sql/cli-proto/licenses/elasticsearch-NOTICE.txt rename to sql/rest-proto/licenses/elasticsearch-NOTICE.txt diff --git a/sql/rest-proto/licenses/jackson-LICENSE b/sql/rest-proto/licenses/jackson-LICENSE new file mode 100644 index 00000000000..f5f45d26a49 --- /dev/null +++ b/sql/rest-proto/licenses/jackson-LICENSE @@ -0,0 +1,8 @@ +This copy of Jackson JSON processor streaming parser/generator is licensed under the +Apache (Software) License, version 2.0 ("the License"). +See the License for details about distribution rights, and the +specific rights regarding derivate works. + +You may obtain a copy of the License at: + +http://www.apache.org/licenses/LICENSE-2.0 diff --git a/sql/rest-proto/licenses/jackson-NOTICE b/sql/rest-proto/licenses/jackson-NOTICE new file mode 100644 index 00000000000..4c976b7b4cc --- /dev/null +++ b/sql/rest-proto/licenses/jackson-NOTICE @@ -0,0 +1,20 @@ +# Jackson JSON processor + +Jackson is a high-performance, Free/Open Source JSON processing library. +It was originally written by Tatu Saloranta (tatu.saloranta@iki.fi), and has +been in development since 2007. +It is currently developed by a community of developers, as well as supported +commercially by FasterXML.com. + +## Licensing + +Jackson core and extension components may licensed under different licenses. +To find the details that apply to this artifact see the accompanying LICENSE file. +For more information, including possible other licensing options, contact +FasterXML.com (http://fasterxml.com). + +## Credits + +A list of contributors may be found from CREDITS file, which is included +in some artifacts (usually source distributions); but is always available +from the source code management (SCM) system project uses. diff --git a/sql/rest-proto/licenses/jackson-core-2.8.10.jar.sha1 b/sql/rest-proto/licenses/jackson-core-2.8.10.jar.sha1 new file mode 100644 index 00000000000..a322d371e26 --- /dev/null +++ b/sql/rest-proto/licenses/jackson-core-2.8.10.jar.sha1 @@ -0,0 +1 @@ +eb21a035c66ad307e66ec8fce37f5d50fd62d039 \ No newline at end of file diff --git a/sql/rest-proto/licenses/joda-time-2.9.5.jar.sha1 b/sql/rest-proto/licenses/joda-time-2.9.5.jar.sha1 new file mode 100644 index 00000000000..ecf1c781556 --- /dev/null +++ b/sql/rest-proto/licenses/joda-time-2.9.5.jar.sha1 @@ -0,0 +1 @@ +5f01da7306363fad2028b916f3eab926262de928 \ No newline at end of file diff --git a/sql/rest-proto/licenses/joda-time-LICENSE.txt b/sql/rest-proto/licenses/joda-time-LICENSE.txt new file mode 100644 index 00000000000..75b52484ea4 --- /dev/null +++ b/sql/rest-proto/licenses/joda-time-LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License 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. diff --git a/sql/rest-proto/licenses/joda-time-NOTICE.txt b/sql/rest-proto/licenses/joda-time-NOTICE.txt new file mode 100644 index 00000000000..dffbcf31cac --- /dev/null +++ b/sql/rest-proto/licenses/joda-time-NOTICE.txt @@ -0,0 +1,5 @@ +============================================================================= += NOTICE file corresponding to section 4d of the Apache License Version 2.0 = +============================================================================= +This product includes software developed by +Joda.org (http://www.joda.org/). diff --git a/sql/rest-proto/licenses/log4j-api-2.9.1.jar.sha1 b/sql/rest-proto/licenses/log4j-api-2.9.1.jar.sha1 new file mode 100644 index 00000000000..e1a89fadfed --- /dev/null +++ b/sql/rest-proto/licenses/log4j-api-2.9.1.jar.sha1 @@ -0,0 +1 @@ +7a2999229464e7a324aa503c0a52ec0f05efe7bd \ No newline at end of file diff --git a/sql/rest-proto/licenses/log4j-api-LICENSE.txt b/sql/rest-proto/licenses/log4j-api-LICENSE.txt new file mode 100644 index 00000000000..6279e5206de --- /dev/null +++ b/sql/rest-proto/licenses/log4j-api-LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 1999-2005 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License 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. diff --git a/sql/rest-proto/licenses/log4j-api-NOTICE.txt b/sql/rest-proto/licenses/log4j-api-NOTICE.txt new file mode 100644 index 00000000000..03757323600 --- /dev/null +++ b/sql/rest-proto/licenses/log4j-api-NOTICE.txt @@ -0,0 +1,5 @@ +Apache log4j +Copyright 2007 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/sql/rest-proto/licenses/log4j-core-2.9.1.jar.sha1 b/sql/rest-proto/licenses/log4j-core-2.9.1.jar.sha1 new file mode 100644 index 00000000000..990ea322a76 --- /dev/null +++ b/sql/rest-proto/licenses/log4j-core-2.9.1.jar.sha1 @@ -0,0 +1 @@ +c041978c686866ee8534f538c6220238db3bb6be \ No newline at end of file diff --git a/sql/rest-proto/licenses/log4j-core-LICENSE.txt b/sql/rest-proto/licenses/log4j-core-LICENSE.txt new file mode 100644 index 00000000000..6279e5206de --- /dev/null +++ b/sql/rest-proto/licenses/log4j-core-LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 1999-2005 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License 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. diff --git a/sql/rest-proto/licenses/log4j-core-NOTICE.txt b/sql/rest-proto/licenses/log4j-core-NOTICE.txt new file mode 100644 index 00000000000..03757323600 --- /dev/null +++ b/sql/rest-proto/licenses/log4j-core-NOTICE.txt @@ -0,0 +1,5 @@ +Apache log4j +Copyright 2007 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/sql/rest-proto/licenses/lucene-LICENSE.txt b/sql/rest-proto/licenses/lucene-LICENSE.txt new file mode 100644 index 00000000000..28b134f5f8e --- /dev/null +++ b/sql/rest-proto/licenses/lucene-LICENSE.txt @@ -0,0 +1,475 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License 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. + + + +Some code in core/src/java/org/apache/lucene/util/UnicodeUtil.java was +derived from unicode conversion examples available at +http://www.unicode.org/Public/PROGRAMS/CVTUTF. Here is the copyright +from those sources: + +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + + +Some code in core/src/java/org/apache/lucene/util/ArrayUtil.java was +derived from Python 2.4.2 sources available at +http://www.python.org. Full license is here: + + http://www.python.org/download/releases/2.4.2/license/ + +Some code in core/src/java/org/apache/lucene/util/UnicodeUtil.java was +derived from Python 3.1.2 sources available at +http://www.python.org. Full license is here: + + http://www.python.org/download/releases/3.1.2/license/ + +Some code in core/src/java/org/apache/lucene/util/automaton was +derived from Brics automaton sources available at +www.brics.dk/automaton/. Here is the copyright from those sources: + +/* + * Copyright (c) 2001-2009 Anders Moeller + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +The levenshtein automata tables in core/src/java/org/apache/lucene/util/automaton +were automatically generated with the moman/finenight FSA package. +Here is the copyright for those sources: + +# Copyright (c) 2010, Jean-Philippe Barrette-LaPierre, +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, +# copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following +# conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +Some code in core/src/java/org/apache/lucene/util/UnicodeUtil.java was +derived from ICU (http://www.icu-project.org) +The full license is available here: + http://source.icu-project.org/repos/icu/icu/trunk/license.html + +/* + * Copyright (C) 1999-2010, International Business Machines + * Corporation and others. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * provided that the above copyright notice(s) and this permission notice appear + * in all copies of the Software and that both the above copyright notice(s) and + * this permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE + * LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization of the + * copyright holder. + */ + +The following license applies to the Snowball stemmers: + +Copyright (c) 2001, Dr Martin Porter +Copyright (c) 2002, Richard Boulton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the copyright holders nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The following license applies to the KStemmer: + +Copyright © 2003, +Center for Intelligent Information Retrieval, +University of Massachusetts, Amherst. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. The names "Center for Intelligent Information Retrieval" and +"University of Massachusetts" must not be used to endorse or promote products +derived from this software without prior written permission. To obtain +permission, contact info@ciir.cs.umass.edu. + +THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF MASSACHUSETTS AND OTHER CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +The following license applies to the Morfologik project: + +Copyright (c) 2006 Dawid Weiss +Copyright (c) 2007-2011 Dawid Weiss, Marcin Miłkowski +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of Morfologik nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--- + +The dictionary comes from Morfologik project. Morfologik uses data from +Polish ispell/myspell dictionary hosted at http://www.sjp.pl/slownik/en/ and +is licenced on the terms of (inter alia) LGPL and Creative Commons +ShareAlike. The part-of-speech tags were added in Morfologik project and +are not found in the data from sjp.pl. The tagset is similar to IPI PAN +tagset. + +--- + +The following license applies to the Morfeusz project, +used by org.apache.lucene.analysis.morfologik. + +BSD-licensed dictionary of Polish (SGJP) +http://sgjp.pl/morfeusz/ + +Copyright © 2011 Zygmunt Saloni, Włodzimierz Gruszczyński, + Marcin Woliński, Robert Wołosz + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDERS “AS IS” AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sql/rest-proto/licenses/lucene-NOTICE.txt b/sql/rest-proto/licenses/lucene-NOTICE.txt new file mode 100644 index 00000000000..1a1d5157243 --- /dev/null +++ b/sql/rest-proto/licenses/lucene-NOTICE.txt @@ -0,0 +1,192 @@ +Apache Lucene +Copyright 2014 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +Includes software from other Apache Software Foundation projects, +including, but not limited to: + - Apache Ant + - Apache Jakarta Regexp + - Apache Commons + - Apache Xerces + +ICU4J, (under analysis/icu) is licensed under an MIT styles license +and Copyright (c) 1995-2008 International Business Machines Corporation and others + +Some data files (under analysis/icu/src/data) are derived from Unicode data such +as the Unicode Character Database. See http://unicode.org/copyright.html for more +details. + +Brics Automaton (under core/src/java/org/apache/lucene/util/automaton) is +BSD-licensed, created by Anders Møller. See http://www.brics.dk/automaton/ + +The levenshtein automata tables (under core/src/java/org/apache/lucene/util/automaton) were +automatically generated with the moman/finenight FSA library, created by +Jean-Philippe Barrette-LaPierre. This library is available under an MIT license, +see http://sites.google.com/site/rrettesite/moman and +http://bitbucket.org/jpbarrette/moman/overview/ + +The class org.apache.lucene.util.WeakIdentityMap was derived from +the Apache CXF project and is Apache License 2.0. + +The Google Code Prettify is Apache License 2.0. +See http://code.google.com/p/google-code-prettify/ + +JUnit (junit-4.10) is licensed under the Common Public License v. 1.0 +See http://junit.sourceforge.net/cpl-v10.html + +This product includes code (JaspellTernarySearchTrie) from Java Spelling Checkin +g Package (jaspell): http://jaspell.sourceforge.net/ +License: The BSD License (http://www.opensource.org/licenses/bsd-license.php) + +The snowball stemmers in + analysis/common/src/java/net/sf/snowball +were developed by Martin Porter and Richard Boulton. +The snowball stopword lists in + analysis/common/src/resources/org/apache/lucene/analysis/snowball +were developed by Martin Porter and Richard Boulton. +The full snowball package is available from + http://snowball.tartarus.org/ + +The KStem stemmer in + analysis/common/src/org/apache/lucene/analysis/en +was developed by Bob Krovetz and Sergio Guzman-Lara (CIIR-UMass Amherst) +under the BSD-license. + +The Arabic,Persian,Romanian,Bulgarian, Hindi and Bengali analyzers (common) come with a default +stopword list that is BSD-licensed created by Jacques Savoy. These files reside in: +analysis/common/src/resources/org/apache/lucene/analysis/ar/stopwords.txt, +analysis/common/src/resources/org/apache/lucene/analysis/fa/stopwords.txt, +analysis/common/src/resources/org/apache/lucene/analysis/ro/stopwords.txt, +analysis/common/src/resources/org/apache/lucene/analysis/bg/stopwords.txt, +analysis/common/src/resources/org/apache/lucene/analysis/hi/stopwords.txt, +analysis/common/src/resources/org/apache/lucene/analysis/bn/stopwords.txt +See http://members.unine.ch/jacques.savoy/clef/index.html. + +The German,Spanish,Finnish,French,Hungarian,Italian,Portuguese,Russian and Swedish light stemmers +(common) are based on BSD-licensed reference implementations created by Jacques Savoy and +Ljiljana Dolamic. These files reside in: +analysis/common/src/java/org/apache/lucene/analysis/de/GermanLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/de/GermanMinimalStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/es/SpanishLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/fi/FinnishLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchMinimalStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/hu/HungarianLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/it/ItalianLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/pt/PortugueseLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/ru/RussianLightStemmer.java +analysis/common/src/java/org/apache/lucene/analysis/sv/SwedishLightStemmer.java + +The Stempel analyzer (stempel) includes BSD-licensed software developed +by the Egothor project http://egothor.sf.net/, created by Leo Galambos, Martin Kvapil, +and Edmond Nolan. + +The Polish analyzer (stempel) comes with a default +stopword list that is BSD-licensed created by the Carrot2 project. The file resides +in stempel/src/resources/org/apache/lucene/analysis/pl/stopwords.txt. +See http://project.carrot2.org/license.html. + +The SmartChineseAnalyzer source code (smartcn) was +provided by Xiaoping Gao and copyright 2009 by www.imdict.net. + +WordBreakTestUnicode_*.java (under modules/analysis/common/src/test/) +is derived from Unicode data such as the Unicode Character Database. +See http://unicode.org/copyright.html for more details. + +The Morfologik analyzer (morfologik) includes BSD-licensed software +developed by Dawid Weiss and Marcin Miłkowski (http://morfologik.blogspot.com/). + +Morfologik uses data from Polish ispell/myspell dictionary +(http://www.sjp.pl/slownik/en/) licenced on the terms of (inter alia) +LGPL and Creative Commons ShareAlike. + +Morfologic includes data from BSD-licensed dictionary of Polish (SGJP) +(http://sgjp.pl/morfeusz/) + +Servlet-api.jar and javax.servlet-*.jar are under the CDDL license, the original +source code for this can be found at http://www.eclipse.org/jetty/downloads.php + +=========================================================================== +Kuromoji Japanese Morphological Analyzer - Apache Lucene Integration +=========================================================================== + +This software includes a binary and/or source version of data from + + mecab-ipadic-2.7.0-20070801 + +which can be obtained from + + http://atilika.com/releases/mecab-ipadic/mecab-ipadic-2.7.0-20070801.tar.gz + +or + + http://jaist.dl.sourceforge.net/project/mecab/mecab-ipadic/2.7.0-20070801/mecab-ipadic-2.7.0-20070801.tar.gz + +=========================================================================== +mecab-ipadic-2.7.0-20070801 Notice +=========================================================================== + +Nara Institute of Science and Technology (NAIST), +the copyright holders, disclaims all warranties with regard to this +software, including all implied warranties of merchantability and +fitness, in no event shall NAIST be liable for +any special, indirect or consequential damages or any damages +whatsoever resulting from loss of use, data or profits, whether in an +action of contract, negligence or other tortuous action, arising out +of or in connection with the use or performance of this software. + +A large portion of the dictionary entries +originate from ICOT Free Software. The following conditions for ICOT +Free Software applies to the current dictionary as well. + +Each User may also freely distribute the Program, whether in its +original form or modified, to any third party or parties, PROVIDED +that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear +on, or be attached to, the Program, which is distributed substantially +in the same form as set out herein and that such intended +distribution, if actually made, will neither violate or otherwise +contravene any of the laws and regulations of the countries having +jurisdiction over the User or the intended distribution itself. + +NO WARRANTY + +The program was produced on an experimental basis in the course of the +research and development conducted during the project and is provided +to users as so produced on an experimental basis. Accordingly, the +program is provided without any warranty whatsoever, whether express, +implied, statutory or otherwise. The term "warranty" used herein +includes, but is not limited to, any warranty of the quality, +performance, merchantability and fitness for a particular purpose of +the program and the nonexistence of any infringement or violation of +any right of any third party. + +Each user of the program will agree and understand, and be deemed to +have agreed and understood, that there is no warranty whatsoever for +the program and, accordingly, the entire risk arising from or +otherwise connected with the program is assumed by the user. + +Therefore, neither ICOT, the copyright holder, or any other +organization that participated in or was otherwise related to the +development of the program and their respective officials, directors, +officers and other employees shall be held liable for any and all +damages, including, without limitation, general, special, incidental +and consequential damages, arising out of or otherwise in connection +with the use or inability to use the program or any product, material +or result produced or otherwise obtained by using the program, +regardless of whether they have been advised of, or otherwise had +knowledge of, the possibility of such damages at any time during the +project or thereafter. Each user will be deemed to have agreed to the +foregoing by his or her commencement of use of the program. The term +"use" as used herein includes, but is not limited to, the use, +modification, copying and distribution of the program and the +production of secondary products from the program. + +In the case where the program, whether in its original form or +modified, was distributed or delivered to or received by a user from +any person, organization or entity other than ICOT, unless it makes or +grants independently of ICOT any specific warranty to the user in +writing, such person, organization or entity, will also be exempted +from and not be held liable to the user for any such damages as noted +above as far as the program is concerned. diff --git a/sql/rest-proto/licenses/lucene-core-7.2.0.jar.sha1 b/sql/rest-proto/licenses/lucene-core-7.2.0.jar.sha1 new file mode 100644 index 00000000000..41e1103ca25 --- /dev/null +++ b/sql/rest-proto/licenses/lucene-core-7.2.0.jar.sha1 @@ -0,0 +1 @@ +f88107aa577ce8edc0a5cee036b485943107a552 \ No newline at end of file diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/AbstractSqlRequest.java b/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/AbstractSqlRequest.java similarity index 85% rename from sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/AbstractSqlRequest.java rename to sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/AbstractSqlRequest.java index d7e638e39df..6dd9c898aaf 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/AbstractSqlRequest.java +++ b/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/AbstractSqlRequest.java @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.xpack.sql.plugin.sql.action; +package org.elasticsearch.xpack.sql.plugin; @@ -15,6 +15,8 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.ObjectParser; +import org.elasticsearch.common.xcontent.ToXContentFragment; +import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.query.AbstractQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.xpack.sql.protocol.shared.AbstractQueryInitRequest; @@ -25,7 +27,7 @@ import java.io.IOException; import java.util.Objects; import java.util.function.Supplier; -public abstract class AbstractSqlRequest extends ActionRequest implements CompositeIndicesRequest { +public abstract class AbstractSqlRequest extends ActionRequest implements CompositeIndicesRequest, ToXContentFragment { public static final DateTimeZone DEFAULT_TIME_ZONE = DateTimeZone.UTC; public static final int DEFAULT_FETCH_SIZE = AbstractQueryInitRequest.DEFAULT_FETCH_SIZE; @@ -44,12 +46,14 @@ public abstract class AbstractSqlRequest extends ActionRequest implements Compos super(); } - public AbstractSqlRequest(String query, QueryBuilder filter, DateTimeZone timeZone, int fetchSize, TimeValue requestTimeout, TimeValue pageTimeout) { + public AbstractSqlRequest(String query, QueryBuilder filter, DateTimeZone timeZone, int fetchSize, TimeValue requestTimeout, + TimeValue pageTimeout) { this.query = query; this.timeZone = timeZone; this.fetchSize = fetchSize; this.requestTimeout = requestTimeout; this.pageTimeout = pageTimeout; + this.filter = filter; } public static ObjectParser objectParser(Supplier supplier) { @@ -192,4 +196,29 @@ public abstract class AbstractSqlRequest extends ActionRequest implements Compos && Objects.equals(pageTimeout, other.pageTimeout) && Objects.equals(filter, other.filter); } + + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + if(query!=null) { + builder.field("query", query); + } + if (timeZone != null) { + builder.field("time_zone", timeZone.getID()); + } + if (fetchSize != DEFAULT_FETCH_SIZE) { + builder.field("fetch_size", fetchSize); + } + if (requestTimeout != DEFAULT_REQUEST_TIMEOUT) { + builder.field("request_timeout", requestTimeout.getStringRep()); + } + if (pageTimeout != DEFAULT_PAGE_TIMEOUT) { + builder.field("page_timeout", pageTimeout.getStringRep()); + } + if (filter != null) { + builder.startObject("filter"); + filter.toXContent(builder, params); + builder.endObject(); + } + return builder; + } } \ No newline at end of file diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlAction.java b/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlAction.java similarity index 88% rename from sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlAction.java rename to sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlAction.java index 3b3b747ea88..9a98b74c4be 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlAction.java +++ b/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlAction.java @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.xpack.sql.plugin.sql.action; +package org.elasticsearch.xpack.sql.plugin; import org.elasticsearch.action.Action; import org.elasticsearch.client.ElasticsearchClient; @@ -12,6 +12,7 @@ public class SqlAction extends Action { + + public static final SqlClearCursorAction INSTANCE = new SqlClearCursorAction(); + public static final String NAME = "indices:data/read/sql/close_cursor"; + public static final String REST_ENDPOINT = "/_xpack/sql/close"; + + private SqlClearCursorAction() { + super(NAME); + } + + @Override + public SqlClearCursorRequestBuilder newRequestBuilder(ElasticsearchClient client) { + return new SqlClearCursorRequestBuilder(client, this); + } + + @Override + public SqlClearCursorResponse newResponse() { + return new SqlClearCursorResponse(); + } +} diff --git a/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorRequest.java b/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorRequest.java new file mode 100644 index 00000000000..2bf42255fb8 --- /dev/null +++ b/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorRequest.java @@ -0,0 +1,101 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.xpack.sql.plugin; + +import org.elasticsearch.action.ActionRequest; +import org.elasticsearch.action.ActionRequestValidationException; +import org.elasticsearch.common.ParseField; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.xcontent.ObjectParser; +import org.elasticsearch.common.xcontent.ToXContentObject; +import org.elasticsearch.common.xcontent.XContentBuilder; + +import java.io.IOException; +import java.util.Objects; + +import static org.elasticsearch.action.ValidateActions.addValidationError; + +/** + * Request to clean all SQL resources associated with the cursor + */ +public class SqlClearCursorRequest extends ActionRequest implements ToXContentObject { + + public static final ObjectParser PARSER = + new ObjectParser<>(SqlClearCursorAction.NAME, SqlClearCursorRequest::new); + + public static final ParseField CURSOR = new ParseField("cursor"); + + static { + PARSER.declareString(SqlClearCursorRequest::setCursor, CURSOR); + } + + private String cursor; + + public SqlClearCursorRequest() { + + } + + public SqlClearCursorRequest(String cursor) { + this.cursor = cursor; + } + + @Override + public ActionRequestValidationException validate() { + ActionRequestValidationException validationException = null; + if (getCursor() == null) { + validationException = addValidationError("cursor is required", validationException); + } + return validationException; + } + + public String getCursor() { + return cursor; + } + + public SqlClearCursorRequest setCursor(String cursor) { + this.cursor = cursor; + return this; + } + + @Override + public String getDescription() { + return "SQL Clean cursor [" + getCursor() + "]"; + } + + @Override + public void readFrom(StreamInput in) throws IOException { + super.readFrom(in); + cursor = in.readString(); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + super.writeTo(out); + out.writeString(cursor); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SqlClearCursorRequest request = (SqlClearCursorRequest) o; + return Objects.equals(cursor, request.cursor); + } + + @Override + public int hashCode() { + return Objects.hash(cursor); + } + + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + builder.startObject(); + builder.field("cursor", cursor); + builder.endObject(); + return builder; + } +} \ No newline at end of file diff --git a/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorRequestBuilder.java b/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorRequestBuilder.java new file mode 100644 index 00000000000..3c63ca8b83c --- /dev/null +++ b/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorRequestBuilder.java @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.xpack.sql.plugin; + +import org.elasticsearch.action.ActionRequestBuilder; +import org.elasticsearch.client.ElasticsearchClient; + +public class SqlClearCursorRequestBuilder extends + ActionRequestBuilder { + + public SqlClearCursorRequestBuilder(ElasticsearchClient client, SqlClearCursorAction action, String cursor) { + super(client, action, new SqlClearCursorRequest(cursor)); + } + + public SqlClearCursorRequestBuilder(ElasticsearchClient client, SqlClearCursorAction action) { + super(client, action, new SqlClearCursorRequest()); + } + + public SqlClearCursorRequestBuilder cursor(String cursor) { + request.setCursor(cursor); + return this; + } +} diff --git a/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorResponse.java b/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorResponse.java new file mode 100644 index 00000000000..b157d65dfff --- /dev/null +++ b/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorResponse.java @@ -0,0 +1,101 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.xpack.sql.plugin; + +import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.common.ParseField; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.xcontent.ObjectParser; +import org.elasticsearch.common.xcontent.StatusToXContentObject; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.rest.RestStatus; + +import java.io.IOException; +import java.util.Objects; + +import static org.elasticsearch.rest.RestStatus.NOT_FOUND; +import static org.elasticsearch.rest.RestStatus.OK; + +/** + * Response to the request to clean all SQL resources associated with the cursor + */ +public class SqlClearCursorResponse extends ActionResponse implements StatusToXContentObject { + + private static final ParseField SUCCEEDED = new ParseField("succeeded"); + public static final ObjectParser PARSER = + new ObjectParser<>(SqlClearCursorAction.NAME, true, SqlClearCursorResponse::new); + static { + PARSER.declareBoolean(SqlClearCursorResponse::setSucceeded, SUCCEEDED); + } + + + private boolean succeeded; + + public SqlClearCursorResponse(boolean succeeded) { + this.succeeded = succeeded; + } + + SqlClearCursorResponse() { + } + + /** + * @return Whether the attempt to clear a cursor was successful. + */ + public boolean isSucceeded() { + return succeeded; + } + + public SqlClearCursorResponse setSucceeded(boolean succeeded) { + this.succeeded = succeeded; + return this; + } + + @Override + public RestStatus status() { + return succeeded ? NOT_FOUND : OK; + } + + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + builder.startObject(); + builder.field(SUCCEEDED.getPreferredName(), succeeded); + builder.endObject(); + return builder; + } + + @Override + public void readFrom(StreamInput in) throws IOException { + super.readFrom(in); + succeeded = in.readBoolean(); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + super.writeTo(out); + out.writeBoolean(succeeded); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SqlClearCursorResponse response = (SqlClearCursorResponse) o; + return succeeded == response.succeeded; + } + + @Override + public int hashCode() { + return Objects.hash(succeeded); + } + + public static SqlClearCursorResponse fromXContent(XContentParser parser) { + return PARSER.apply(parser, null); + } + + +} diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlRequest.java b/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlRequest.java similarity index 71% rename from sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlRequest.java rename to sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlRequest.java index 4698095fd3f..33957caeb5e 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlRequest.java +++ b/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlRequest.java @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.xpack.sql.plugin.sql.action; +package org.elasticsearch.xpack.sql.plugin; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.common.ParseField; @@ -12,9 +12,10 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.ObjectParser; +import org.elasticsearch.common.xcontent.ToXContentObject; +import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.query.AbstractQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; -import org.elasticsearch.xpack.sql.session.Cursor; import org.joda.time.DateTimeZone; import java.io.IOException; @@ -22,7 +23,10 @@ import java.util.Objects; import static org.elasticsearch.action.ValidateActions.addValidationError; -public class SqlRequest extends AbstractSqlRequest { +/** + * Request to perform an sql query + */ +public class SqlRequest extends AbstractSqlRequest implements ToXContentObject { public static final ObjectParser PARSER = objectParser(SqlRequest::new); @@ -30,17 +34,18 @@ public class SqlRequest extends AbstractSqlRequest { public static final ParseField FILTER = new ParseField("filter"); static { - PARSER.declareString((request, nextPage) -> request.cursor(Cursor.decodeFromString(nextPage)), CURSOR); + PARSER.declareString(SqlRequest::cursor, CURSOR); PARSER.declareObject(SqlRequest::filter, (p, c) -> AbstractQueryBuilder.parseInnerQueryBuilder(p), FILTER); } - private Cursor cursor = Cursor.EMPTY; + private String cursor = ""; - public SqlRequest() {} + public SqlRequest() { + } public SqlRequest(String query, QueryBuilder filter, DateTimeZone timeZone, int fetchSize, TimeValue requestTimeout, - TimeValue pageTimeout, Cursor cursor) { + TimeValue pageTimeout, String cursor) { super(query, filter, timeZone, fetchSize, requestTimeout, pageTimeout); this.cursor = cursor; } @@ -48,7 +53,7 @@ public class SqlRequest extends AbstractSqlRequest { @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; - if ((false == Strings.hasText(query())) && cursor == Cursor.EMPTY) { + if ((false == Strings.hasText(query())) && Strings.hasText(cursor) == false) { validationException = addValidationError("one of [query] or [cursor] is required", validationException); } return validationException; @@ -58,7 +63,7 @@ public class SqlRequest extends AbstractSqlRequest { * The key that must be sent back to SQL to access the next page of * results. */ - public Cursor cursor() { + public String cursor() { return cursor; } @@ -66,7 +71,7 @@ public class SqlRequest extends AbstractSqlRequest { * The key that must be sent back to SQL to access the next page of * results. */ - public SqlRequest cursor(Cursor cursor) { + public SqlRequest cursor(String cursor) { if (cursor == null) { throw new IllegalArgumentException("cursor may not be null."); } @@ -77,13 +82,13 @@ public class SqlRequest extends AbstractSqlRequest { @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - cursor = in.readNamedWriteable(Cursor.class); + cursor = in.readString(); } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeNamedWriteable(cursor); + out.writeString(cursor); } @Override @@ -100,4 +105,20 @@ public class SqlRequest extends AbstractSqlRequest { public String getDescription() { return "SQL [" + query() + "][" + filter() + "]"; } + + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + builder.startObject(); + super.toXContent(builder, params); + if (cursor != null) { + builder.field("cursor", cursor); + } + builder.endObject(); + return builder; + } + + @Override + public boolean isFragment() { + return false; + } } \ No newline at end of file diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlRequestBuilder.java b/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlRequestBuilder.java similarity index 73% rename from sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlRequestBuilder.java rename to sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlRequestBuilder.java index 44f1bc60f7f..6919e215f44 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlRequestBuilder.java +++ b/sql/rest-proto/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlRequestBuilder.java @@ -3,28 +3,27 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.xpack.sql.plugin.sql.action; +package org.elasticsearch.xpack.sql.plugin; import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.query.QueryBuilder; -import org.elasticsearch.xpack.sql.session.Cursor; import org.joda.time.DateTimeZone; -import static org.elasticsearch.xpack.sql.plugin.sql.action.AbstractSqlRequest.DEFAULT_FETCH_SIZE; -import static org.elasticsearch.xpack.sql.plugin.sql.action.AbstractSqlRequest.DEFAULT_PAGE_TIMEOUT; -import static org.elasticsearch.xpack.sql.plugin.sql.action.AbstractSqlRequest.DEFAULT_REQUEST_TIMEOUT; -import static org.elasticsearch.xpack.sql.plugin.sql.action.AbstractSqlRequest.DEFAULT_TIME_ZONE; +import static org.elasticsearch.xpack.sql.plugin.AbstractSqlRequest.DEFAULT_FETCH_SIZE; +import static org.elasticsearch.xpack.sql.plugin.AbstractSqlRequest.DEFAULT_PAGE_TIMEOUT; +import static org.elasticsearch.xpack.sql.plugin.AbstractSqlRequest.DEFAULT_REQUEST_TIMEOUT; +import static org.elasticsearch.xpack.sql.plugin.AbstractSqlRequest.DEFAULT_TIME_ZONE; public class SqlRequestBuilder extends ActionRequestBuilder { public SqlRequestBuilder(ElasticsearchClient client, SqlAction action) { - this(client, action, "", null, DEFAULT_TIME_ZONE, DEFAULT_FETCH_SIZE, DEFAULT_REQUEST_TIMEOUT, DEFAULT_PAGE_TIMEOUT, Cursor.EMPTY); + this(client, action, "", null, DEFAULT_TIME_ZONE, DEFAULT_FETCH_SIZE, DEFAULT_REQUEST_TIMEOUT, DEFAULT_PAGE_TIMEOUT, ""); } public SqlRequestBuilder(ElasticsearchClient client, SqlAction action, String query, QueryBuilder filter, DateTimeZone timeZone, - int fetchSize, TimeValue requestTimeout, TimeValue pageTimeout, Cursor nextPageInfo) { + int fetchSize, TimeValue requestTimeout, TimeValue pageTimeout, String nextPageInfo) { super(client, action, new SqlRequest(query, filter, timeZone, fetchSize, requestTimeout, pageTimeout, nextPageInfo)); } @@ -33,7 +32,7 @@ public class SqlRequestBuilder extends ActionRequestBuilder columns; @@ -35,7 +37,7 @@ public class SqlResponse extends ActionResponse implements ToXContentObject { public SqlResponse() { } - public SqlResponse(Cursor cursor, long size, int columnCount, @Nullable List columns, List> rows) { + public SqlResponse(String cursor, long size, int columnCount, @Nullable List columns, List> rows) { this.cursor = cursor; this.size = size; // Size isn't the total number of results like ES uses, it is the size of the current rows list. @@ -47,9 +49,9 @@ public class SqlResponse extends ActionResponse implements ToXContentObject { /** * The key that must be sent back to SQL to access the next page of - * results. If equal to {@link Cursor#EMPTY} then there is no next page. + * results. If equal to "" then there is no next page. */ - public Cursor cursor() { + public String cursor() { return cursor; } @@ -67,7 +69,7 @@ public class SqlResponse extends ActionResponse implements ToXContentObject { @Override public void readFrom(StreamInput in) throws IOException { - cursor = in.readNamedWriteable(Cursor.class); + cursor = in.readString(); size = in.readVLong(); columnCount = in.readVInt(); if (in.readBoolean()) { @@ -93,7 +95,7 @@ public class SqlResponse extends ActionResponse implements ToXContentObject { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeNamedWriteable(cursor); + out.writeString(cursor); out.writeVLong(size); out.writeVInt(columnCount); if (columns == null) { @@ -120,7 +122,8 @@ public class SqlResponse extends ActionResponse implements ToXContentObject { { builder.field("size", size()); if (columns != null) { - builder.startArray("columns"); { + builder.startArray("columns"); + { for (ColumnInfo column : columns) { column.toXContent(builder, params); } @@ -138,8 +141,8 @@ public class SqlResponse extends ActionResponse implements ToXContentObject { } builder.endArray(); - if (cursor != Cursor.EMPTY) { - builder.field(SqlRequest.CURSOR.getPreferredName(), Cursor.encodeToString(Version.CURRENT, cursor)); + if (cursor.equals("") == false) { + builder.field(SqlRequest.CURSOR.getPreferredName(), cursor); } } return builder.endObject(); diff --git a/sql/rest-proto/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorRequestTests.java b/sql/rest-proto/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorRequestTests.java new file mode 100644 index 00000000000..387f4aa2710 --- /dev/null +++ b/sql/rest-proto/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorRequestTests.java @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.xpack.sql.plugin; + +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.test.AbstractStreamableTestCase; +import org.elasticsearch.test.AbstractStreamableXContentTestCase; +import org.elasticsearch.test.EqualsHashCodeTestUtils.MutateFunction; + +public class SqlClearCursorRequestTests extends AbstractStreamableXContentTestCase { + + @Override + protected SqlClearCursorRequest createTestInstance() { + return new SqlClearCursorRequest(randomAlphaOfLength(100)); + } + + @Override + protected SqlClearCursorRequest createBlankInstance() { + return new SqlClearCursorRequest(); + } + + @Override + @SuppressWarnings("unchecked") + protected MutateFunction getMutateFunction() { + return request -> getCopyFunction().copy(request).setCursor(randomAlphaOfLength(100)); + } + + @Override + protected SqlClearCursorRequest doParseInstance(XContentParser parser) { + return SqlClearCursorRequest.PARSER.apply(parser, null); + } + + @Override + protected boolean supportsUnknownFields() { + return false; + } +} + diff --git a/sql/rest-proto/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorResponseTests.java b/sql/rest-proto/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorResponseTests.java new file mode 100644 index 00000000000..2aced144c9d --- /dev/null +++ b/sql/rest-proto/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorResponseTests.java @@ -0,0 +1,33 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.xpack.sql.plugin; + +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.test.AbstractStreamableXContentTestCase; +import org.elasticsearch.test.EqualsHashCodeTestUtils.MutateFunction; + +public class SqlClearCursorResponseTests extends AbstractStreamableXContentTestCase { + + @Override + protected SqlClearCursorResponse createTestInstance() { + return new SqlClearCursorResponse(randomBoolean()); + } + + @Override + protected SqlClearCursorResponse createBlankInstance() { + return new SqlClearCursorResponse(); + } + + @Override + protected MutateFunction getMutateFunction() { + return response -> getCopyFunction().copy(response).setSucceeded(response.isSucceeded() == false); + } + + @Override + protected SqlClearCursorResponse doParseInstance(XContentParser parser) { + return SqlClearCursorResponse.fromXContent(parser); + } +} diff --git a/sql/server/build.gradle b/sql/server/build.gradle index 64e2050b8d5..9ac44dc815f 100644 --- a/sql/server/build.gradle +++ b/sql/server/build.gradle @@ -2,7 +2,7 @@ description = 'The server components of SQL for Elasticsearch' dependencies { compile project(':x-pack-elasticsearch:sql:jdbc-proto') - compile project(':x-pack-elasticsearch:sql:cli-proto') + compile project(':x-pack-elasticsearch:sql:rest-proto') compile project(':x-pack-elasticsearch:sql:shared-proto') compile 'org.antlr:antlr4-runtime:4.5.3' provided "org.elasticsearch:elasticsearch:${project.versions.elasticsearch}" @@ -11,10 +11,10 @@ dependencies { dependencyLicenses { mapping from: /jdbc-proto.*/, to: 'elasticsearch' - mapping from: /cli-proto.*/, to: 'elasticsearch' + mapping from: /rest-proto.*/, to: 'elasticsearch' mapping from: /shared-proto.*/, to: 'elasticsearch' ignoreSha 'jdbc-proto' - ignoreSha 'cli-proto' + ignoreSha 'rest-proto' ignoreSha 'shared-proto' } diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/CliFormatter.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/CliFormatter.java index 377eea04c82..a0682b09890 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/CliFormatter.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/CliFormatter.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.sql.plugin; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlResponse; import java.io.IOException; import java.util.Arrays; @@ -107,7 +106,7 @@ public class CliFormatter implements Writeable { * without the header lines. */ public String formatWithoutHeader(SqlResponse response) { - return formatWithoutHeader(new StringBuilder(estimateSize(response.rows().size())), response).toString(); + return formatWithoutHeader(new StringBuilder(estimateSize(response.rows().size())), response); } private String formatWithoutHeader(StringBuilder sb, SqlResponse response) { diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/rest/RestSqlAction.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlAction.java similarity index 82% rename from sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/rest/RestSqlAction.java rename to sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlAction.java index 4e1855b9f88..cf51b106a91 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/rest/RestSqlAction.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlAction.java @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.xpack.sql.plugin.sql.rest; +package org.elasticsearch.xpack.sql.plugin; import org.elasticsearch.Version; import org.elasticsearch.client.node.NodeClient; @@ -18,11 +18,6 @@ import org.elasticsearch.rest.RestResponse; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.action.RestResponseListener; import org.elasticsearch.rest.action.RestToXContentListener; -import org.elasticsearch.xpack.sql.plugin.CliFormatter; -import org.elasticsearch.xpack.sql.plugin.CliFormatterCursor; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlAction; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlRequest; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlResponse; import org.elasticsearch.xpack.sql.session.Cursor; import java.io.IOException; @@ -34,8 +29,8 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestSqlAction extends BaseRestHandler { public RestSqlAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(GET, "/_xpack/sql", this); - controller.registerHandler(POST, "/_xpack/sql", this); + controller.registerHandler(GET, SqlAction.REST_ENDPOINT, this); + controller.registerHandler(POST, SqlAction.REST_ENDPOINT, this); } @Override @@ -58,15 +53,16 @@ public class RestSqlAction extends BaseRestHandler { public RestResponse buildResponse(SqlResponse response) throws Exception { final String data; final CliFormatter formatter; - if (sqlRequest.cursor() != Cursor.EMPTY) { - formatter = ((CliFormatterCursor) sqlRequest.cursor()).getCliFormatter(); + if (sqlRequest.cursor().equals("") == false) { + formatter = ((CliFormatterCursor) Cursor.decodeFromString(sqlRequest.cursor())).getCliFormatter(); data = formatter.formatWithoutHeader(response); } else { formatter = new CliFormatter(response); data = formatter.formatWithHeader(response); } - return buildTextResponse(CliFormatterCursor.wrap(response.cursor(), formatter), System.nanoTime() - startNanos, data); + return buildTextResponse(CliFormatterCursor.wrap(Cursor.decodeFromString(response.cursor()), formatter), + System.nanoTime() - startNanos, data); } }); } diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlClearCursorAction.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlClearCursorAction.java new file mode 100644 index 00000000000..5002a44a46d --- /dev/null +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlClearCursorAction.java @@ -0,0 +1,40 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.xpack.sql.plugin; + +import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.rest.BaseRestHandler; +import org.elasticsearch.rest.RestController; +import org.elasticsearch.rest.RestRequest; +import org.elasticsearch.rest.action.RestToXContentListener; + +import java.io.IOException; + +import static org.elasticsearch.rest.RestRequest.Method.POST; +import static org.elasticsearch.xpack.sql.plugin.SqlClearCursorAction.REST_ENDPOINT; + +public class RestSqlClearCursorAction extends BaseRestHandler { + public RestSqlClearCursorAction(Settings settings, RestController controller) { + super(settings); + controller.registerHandler(POST, REST_ENDPOINT, this); + } + + @Override + protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { + SqlClearCursorRequest sqlRequest; + try (XContentParser parser = request.contentOrSourceParamParser()) { + sqlRequest = SqlClearCursorRequest.PARSER.apply(parser, null); + } + return channel -> client.executeLocally(SqlClearCursorAction.INSTANCE, sqlRequest, new RestToXContentListener<>(channel)); + } + + @Override + public String getName() { + return "sql_translate_action"; + } +} \ No newline at end of file diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlCliAction.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlCliAction.java deleted file mode 100644 index f998f16850f..00000000000 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlCliAction.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.plugin; - -import org.elasticsearch.Version; -import org.elasticsearch.action.main.MainAction; -import org.elasticsearch.action.main.MainRequest; -import org.elasticsearch.client.Client; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.xpack.sql.cli.net.protocol.InfoResponse; -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto; -import org.elasticsearch.xpack.sql.cli.net.protocol.Proto.RequestType; -import org.elasticsearch.xpack.sql.cli.net.protocol.QueryCloseRequest; -import org.elasticsearch.xpack.sql.cli.net.protocol.QueryInitRequest; -import org.elasticsearch.xpack.sql.cli.net.protocol.QueryInitResponse; -import org.elasticsearch.xpack.sql.cli.net.protocol.QueryPageRequest; -import org.elasticsearch.xpack.sql.cli.net.protocol.QueryPageResponse; -import org.elasticsearch.xpack.sql.jdbc.net.protocol.QueryCloseResponse; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlAction; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlRequest; -import org.elasticsearch.xpack.sql.protocol.shared.Request; -import org.elasticsearch.xpack.sql.session.Cursor; -import org.joda.time.DateTimeZone; - -import java.io.IOException; -import java.util.function.Consumer; - -import static org.elasticsearch.rest.RestRequest.Method.POST; - -public class RestSqlCliAction extends AbstractSqlProtocolRestAction { - public RestSqlCliAction(Settings settings, RestController controller) { - super(settings, Proto.INSTANCE); - controller.registerHandler(POST, "/_xpack/sql/cli", this); - } - - @Override - public String getName() { - return "xpack_sql_cli_action"; - } - - @Override - protected RestChannelConsumer innerPrepareRequest(Request request, Client client) throws IOException { - Consumer consumer = operation(request, client); - return consumer::accept; - } - - /** - * Actual implementation of the operation - */ - public Consumer operation(Request request, Client client) - throws IOException { - RequestType requestType = (RequestType) request.requestType(); - switch (requestType) { - case INFO: - return channel -> client.execute(MainAction.INSTANCE, new MainRequest(), toActionListener(channel, response -> - new InfoResponse(response.getNodeName(), response.getClusterName().value(), - response.getVersion().major, response.getVersion().minor, response.getVersion().toString(), - response.getBuild().shortHash(), response.getBuild().date()))); - case QUERY_INIT: - return queryInit(client, (QueryInitRequest) request); - case QUERY_PAGE: - return queryPage(client, (QueryPageRequest) request); - case QUERY_CLOSE: - return queryClose(client, (QueryCloseRequest) request); - default: - throw new IllegalArgumentException("Unsupported action [" + requestType + "]"); - } - } - - private Consumer queryInit(Client client, QueryInitRequest request) { - // TODO time zone support for CLI - SqlRequest sqlRequest = new SqlRequest(request.query, null, DateTimeZone.forTimeZone(request.timeZone), request.fetchSize, - TimeValue.timeValueMillis(request.timeout.requestTimeout), - TimeValue.timeValueMillis(request.timeout.pageTimeout), - Cursor.EMPTY); - long start = System.nanoTime(); - return channel -> client.execute(SqlAction.INSTANCE, sqlRequest, toActionListener(channel, response -> { - CliFormatter formatter = new CliFormatter(response); - String data = formatter.formatWithHeader(response); - return new QueryInitResponse(System.nanoTime() - start, - Cursor.encodeToString(Version.CURRENT, CliFormatterCursor.wrap(response.cursor(), formatter)), data); - })); - } - - private Consumer queryPage(Client client, QueryPageRequest request) { - Cursor cursor = Cursor.decodeFromString(request.cursor); - if (cursor instanceof CliFormatterCursor == false) { - throw new IllegalArgumentException("Unexpected cursor type: [" + cursor + "]"); - } - CliFormatter formatter = ((CliFormatterCursor)cursor).getCliFormatter(); - SqlRequest sqlRequest = new SqlRequest("", null, SqlRequest.DEFAULT_TIME_ZONE, 0, - TimeValue.timeValueMillis(request.timeout.requestTimeout), - TimeValue.timeValueMillis(request.timeout.pageTimeout), - cursor); - - long start = System.nanoTime(); - return channel -> client.execute(SqlAction.INSTANCE, sqlRequest, toActionListener(channel, response -> { - String data = formatter.formatWithoutHeader(response); - return new QueryPageResponse(System.nanoTime() - start, - Cursor.encodeToString(Version.CURRENT, CliFormatterCursor.wrap(response.cursor(), formatter)), data); - })); - } - - private Consumer queryClose(Client client, QueryCloseRequest request) { - Cursor cursor = Cursor.decodeFromString(request.cursor); - SqlClearCursorAction.Request sqlRequest = new SqlClearCursorAction.Request(cursor); - return channel -> client.execute(SqlClearCursorAction.INSTANCE, sqlRequest, toActionListener(channel, - response -> new QueryCloseResponse(response.isSucceeded()))); - } -} diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlJdbcAction.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlJdbcAction.java index f3fb969a3f6..11cda6bd0ef 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlJdbcAction.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlJdbcAction.java @@ -31,9 +31,6 @@ import org.elasticsearch.xpack.sql.jdbc.net.protocol.QueryInitRequest; import org.elasticsearch.xpack.sql.jdbc.net.protocol.QueryInitResponse; import org.elasticsearch.xpack.sql.jdbc.net.protocol.QueryPageRequest; import org.elasticsearch.xpack.sql.jdbc.net.protocol.QueryPageResponse; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlAction; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlRequest; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlResponse; import org.elasticsearch.xpack.sql.protocol.shared.Request; import org.elasticsearch.xpack.sql.session.Cursor; import org.elasticsearch.xpack.sql.type.DataType; @@ -137,7 +134,7 @@ public class RestSqlJdbcAction extends AbstractSqlProtocolRestAction { SqlRequest sqlRequest = new SqlRequest(request.query, null, DateTimeZone.forTimeZone(request.timeZone), request.fetchSize, TimeValue.timeValueMillis(request.timeout.requestTimeout), TimeValue.timeValueMillis(request.timeout.pageTimeout), - Cursor.EMPTY); + ""); long start = System.nanoTime(); return channel -> client.execute(SqlAction.INSTANCE, sqlRequest, toActionListener(channel, response -> { List types = new ArrayList<>(response.columns().size()); @@ -146,8 +143,9 @@ public class RestSqlJdbcAction extends AbstractSqlProtocolRestAction { types.add(info.jdbcType()); columns.add(new ColumnInfo(info.name(), info.jdbcType(), EMPTY, EMPTY, EMPTY, EMPTY, info.displaySize())); } + Cursor cursor = Cursor.decodeFromString(response.cursor()); return new QueryInitResponse(System.nanoTime() - start, - Cursor.encodeToString(Version.CURRENT, JdbcCursor.wrap(response.cursor(), types)), columns, + Cursor.encodeToString(Version.CURRENT, JdbcCursor.wrap(cursor, types)), columns, new SqlResponsePayload(types, response.rows())); })); } @@ -162,17 +160,16 @@ public class RestSqlJdbcAction extends AbstractSqlProtocolRestAction { SqlRequest sqlRequest = new SqlRequest(EMPTY, null, SqlRequest.DEFAULT_TIME_ZONE, 0, TimeValue.timeValueMillis(request.timeout.requestTimeout), TimeValue.timeValueMillis(request.timeout.pageTimeout), - cursor); + request.cursor); long start = System.nanoTime(); return channel -> client.execute(SqlAction.INSTANCE, sqlRequest, toActionListener(channel, response -> new QueryPageResponse(System.nanoTime() - start, - Cursor.encodeToString(Version.CURRENT, JdbcCursor.wrap(response.cursor(), types)), + Cursor.encodeToString(Version.CURRENT, JdbcCursor.wrap(Cursor.decodeFromString(response.cursor()), types)), new SqlResponsePayload(types, response.rows())))); } private Consumer queryClose(Client client, QueryCloseRequest request) { - Cursor cursor = Cursor.decodeFromString(request.cursor); - SqlClearCursorAction.Request sqlRequest = new SqlClearCursorAction.Request(cursor); + SqlClearCursorRequest sqlRequest = new SqlClearCursorRequest(request.cursor); return channel -> client.execute(SqlClearCursorAction.INSTANCE, sqlRequest, toActionListener(channel, response -> new QueryCloseResponse(response.isSucceeded()))); } diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorAction.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorAction.java deleted file mode 100644 index 1abca32187f..00000000000 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorAction.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.plugin; - -import org.elasticsearch.action.Action; -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.ActionRequest; -import org.elasticsearch.action.ActionRequestBuilder; -import org.elasticsearch.action.ActionRequestValidationException; -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.HandledTransportAction; -import org.elasticsearch.client.ElasticsearchClient; -import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; -import org.elasticsearch.common.ParseField; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.ObjectParser; -import org.elasticsearch.common.xcontent.StatusToXContentObject; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.action.RestToXContentListener; -import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.TransportService; -import org.elasticsearch.xpack.sql.execution.PlanExecutor; -import org.elasticsearch.xpack.sql.session.Configuration; -import org.elasticsearch.xpack.sql.session.Cursor; - -import java.io.IOException; -import java.util.Objects; - -import static org.elasticsearch.action.ValidateActions.addValidationError; -import static org.elasticsearch.rest.RestRequest.Method.POST; -import static org.elasticsearch.rest.RestStatus.NOT_FOUND; -import static org.elasticsearch.rest.RestStatus.OK; - -public class SqlClearCursorAction - extends Action { - - public static final SqlClearCursorAction INSTANCE = new SqlClearCursorAction(); - public static final String NAME = "indices:data/read/sql/close_cursor"; - - private SqlClearCursorAction() { - super(NAME); - } - - @Override - public RequestBuilder newRequestBuilder(ElasticsearchClient client) { - return new RequestBuilder(client, this); - } - - @Override - public Response newResponse() { - return new Response(); - } - - public static class Request extends ActionRequest { - - public static final ObjectParser PARSER = new ObjectParser<>(NAME, Request::new); - - public static final ParseField CURSOR = new ParseField("cursor"); - - static { - PARSER.declareString((request, nextPage) -> request.setCursor(Cursor.decodeFromString(nextPage)), CURSOR); - } - - private Cursor cursor; - - public Request() { - - } - - public Request(Cursor cursor) { - this.cursor = cursor; - } - - @Override - public ActionRequestValidationException validate() { - ActionRequestValidationException validationException = null; - if (getCursor() == null) { - validationException = addValidationError("cursor is required", validationException); - } - return validationException; - } - - public Cursor getCursor() { - return cursor; - } - - public Request setCursor(Cursor cursor) { - this.cursor = cursor; - return this; - } - - @Override - public String getDescription() { - return "SQL Clean cursor [" + getCursor() + "]"; - } - - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - cursor = in.readNamedWriteable(Cursor.class); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeNamedWriteable(cursor); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Request request = (Request) o; - return Objects.equals(cursor, request.cursor); - } - - @Override - public int hashCode() { - return Objects.hash(cursor); - } - } - - public static class RequestBuilder extends ActionRequestBuilder { - public RequestBuilder(ElasticsearchClient client, SqlClearCursorAction action, Cursor cursor) { - super(client, action, new Request(cursor)); - } - - public RequestBuilder(ElasticsearchClient client, SqlClearCursorAction action) { - super(client, action, new Request()); - } - - public RequestBuilder cursor(Cursor cursor) { - request.setCursor(cursor); - return this; - } - } - - public static class Response extends ActionResponse implements StatusToXContentObject { - - private static final ParseField SUCCEEDED = new ParseField("succeeded"); - - private boolean succeeded; - - public Response(boolean succeeded) { - this.succeeded = succeeded; - } - - Response() { - } - - /** - * @return Whether the attempt to clear a cursor was successful. - */ - public boolean isSucceeded() { - return succeeded; - } - - public Response setSucceeded(boolean succeeded) { - this.succeeded = succeeded; - return this; - } - - @Override - public RestStatus status() { - return succeeded ? NOT_FOUND : OK; - } - - @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject(); - builder.field(SUCCEEDED.getPreferredName(), succeeded); - builder.endObject(); - return builder; - } - - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - succeeded = in.readBoolean(); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeBoolean(succeeded); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Response response = (Response) o; - return succeeded == response.succeeded; - } - - @Override - public int hashCode() { - return Objects.hash(succeeded); - } - } - - - public static class TransportAction extends HandledTransportAction { - private final PlanExecutor planExecutor; - private final SqlLicenseChecker sqlLicenseChecker; - - @Inject - public TransportAction(Settings settings, ThreadPool threadPool, - TransportService transportService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver, - PlanExecutor planExecutor, - SqlLicenseChecker sqlLicenseChecker) { - super(settings, NAME, threadPool, transportService, actionFilters, - indexNameExpressionResolver, Request::new); - this.planExecutor = planExecutor; - this.sqlLicenseChecker = sqlLicenseChecker; - } - - @Override - protected void doExecute(Request request, ActionListener listener) { - sqlLicenseChecker.checkIfSqlAllowed(); - Cursor cursor = request.getCursor(); - planExecutor.cleanCursor(Configuration.DEFAULT, cursor, ActionListener.wrap( - success -> listener.onResponse(new Response(success)), listener::onFailure)); - } - } - - public static class RestAction extends BaseRestHandler { - public RestAction(Settings settings, RestController controller) { - super(settings); - controller.registerHandler(POST, "/_xpack/sql/close", this); - } - - @Override - protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { - Request sqlRequest; - try (XContentParser parser = request.contentOrSourceParamParser()) { - sqlRequest = Request.PARSER.apply(parser, null); - } - return channel -> client.executeLocally(SqlClearCursorAction.INSTANCE, sqlRequest, new RestToXContentListener<>(channel)); - } - - @Override - public String getName() { - return "sql_translate_action"; - } - } -} diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java index e8ef6b26b97..9e0c29df768 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java @@ -20,9 +20,6 @@ import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; import org.elasticsearch.xpack.sql.analysis.index.IndexResolver; import org.elasticsearch.xpack.sql.execution.PlanExecutor; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlAction; -import org.elasticsearch.xpack.sql.plugin.sql.action.TransportSqlAction; -import org.elasticsearch.xpack.sql.plugin.sql.rest.RestSqlAction; import org.elasticsearch.xpack.sql.session.Cursor; import java.util.Arrays; @@ -69,9 +66,8 @@ public class SqlPlugin implements ActionPlugin { return Arrays.asList(new RestSqlAction(settings, restController), new SqlTranslateAction.RestAction(settings, restController), - new RestSqlCliAction(settings, restController), new RestSqlJdbcAction(settings, restController, sqlLicenseChecker, indexResolver), - new SqlClearCursorAction.RestAction(settings, restController)); + new RestSqlClearCursorAction(settings, restController)); } @Override @@ -82,6 +78,6 @@ public class SqlPlugin implements ActionPlugin { return Arrays.asList(new ActionHandler<>(SqlAction.INSTANCE, TransportSqlAction.class), new ActionHandler<>(SqlTranslateAction.INSTANCE, SqlTranslateAction.TransportAction.class), - new ActionHandler<>(SqlClearCursorAction.INSTANCE, SqlClearCursorAction.TransportAction.class)); + new ActionHandler<>(SqlClearCursorAction.INSTANCE, TransportSqlClearCursorAction.class)); } } diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlResponsePayload.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlResponsePayload.java index 3dfdeab4eb3..8bfc0a3e275 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlResponsePayload.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlResponsePayload.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.sql.plugin; import org.elasticsearch.xpack.sql.jdbc.net.protocol.Payload; import org.elasticsearch.xpack.sql.jdbc.net.protocol.ProtoUtils; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlResponse; import org.elasticsearch.xpack.sql.protocol.shared.SqlDataInput; import org.elasticsearch.xpack.sql.protocol.shared.SqlDataOutput; diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlTranslateAction.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlTranslateAction.java index 498157f6bcd..fe77f5a4985 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlTranslateAction.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlTranslateAction.java @@ -34,7 +34,6 @@ import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.sql.execution.PlanExecutor; -import org.elasticsearch.xpack.sql.plugin.sql.action.AbstractSqlRequest; import org.elasticsearch.xpack.sql.session.Configuration; import org.joda.time.DateTimeZone; @@ -44,10 +43,10 @@ import java.util.Objects; import static org.elasticsearch.action.ValidateActions.addValidationError; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; -import static org.elasticsearch.xpack.sql.plugin.sql.action.AbstractSqlRequest.DEFAULT_FETCH_SIZE; -import static org.elasticsearch.xpack.sql.plugin.sql.action.AbstractSqlRequest.DEFAULT_PAGE_TIMEOUT; -import static org.elasticsearch.xpack.sql.plugin.sql.action.AbstractSqlRequest.DEFAULT_REQUEST_TIMEOUT; -import static org.elasticsearch.xpack.sql.plugin.sql.action.AbstractSqlRequest.DEFAULT_TIME_ZONE; +import static org.elasticsearch.xpack.sql.plugin.AbstractSqlRequest.DEFAULT_FETCH_SIZE; +import static org.elasticsearch.xpack.sql.plugin.AbstractSqlRequest.DEFAULT_PAGE_TIMEOUT; +import static org.elasticsearch.xpack.sql.plugin.AbstractSqlRequest.DEFAULT_REQUEST_TIMEOUT; +import static org.elasticsearch.xpack.sql.plugin.AbstractSqlRequest.DEFAULT_TIME_ZONE; public class SqlTranslateAction extends Action { diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/TransportSqlAction.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/TransportSqlAction.java similarity index 90% rename from sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/TransportSqlAction.java rename to sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/TransportSqlAction.java index 40ffb772744..5b79f69008f 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/sql/action/TransportSqlAction.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/TransportSqlAction.java @@ -3,19 +3,20 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.xpack.sql.plugin.sql.action; +package org.elasticsearch.xpack.sql.plugin; +import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.sql.execution.PlanExecutor; -import org.elasticsearch.xpack.sql.plugin.SqlLicenseChecker; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlResponse.ColumnInfo; +import org.elasticsearch.xpack.sql.plugin.SqlResponse.ColumnInfo; import org.elasticsearch.xpack.sql.session.Configuration; import org.elasticsearch.xpack.sql.session.Cursor; import org.elasticsearch.xpack.sql.session.RowSet; @@ -58,11 +59,11 @@ public class TransportSqlAction extends HandledTransportAction listener.onResponse(createResponse(rowSet)), listener::onFailure)); } else { - planExecutor.nextPage(cfg, request.cursor(), + planExecutor.nextPage(cfg, Cursor.decodeFromString(request.cursor()), ActionListener.wrap(rowSet -> listener.onResponse(createResponse(rowSet, null)), listener::onFailure)); } } @@ -85,7 +86,7 @@ public class TransportSqlAction extends HandledTransportAction { + private final PlanExecutor planExecutor; + private final SqlLicenseChecker sqlLicenseChecker; + + @Inject + public TransportSqlClearCursorAction(Settings settings, ThreadPool threadPool, + TransportService transportService, ActionFilters actionFilters, + IndexNameExpressionResolver indexNameExpressionResolver, + PlanExecutor planExecutor, + SqlLicenseChecker sqlLicenseChecker) { + super(settings, NAME, threadPool, transportService, actionFilters, + indexNameExpressionResolver, SqlClearCursorRequest::new); + this.planExecutor = planExecutor; + this.sqlLicenseChecker = sqlLicenseChecker; + } + + @Override + protected void doExecute(SqlClearCursorRequest request, ActionListener listener) { + sqlLicenseChecker.checkIfSqlAllowed(); + Cursor cursor = Cursor.decodeFromString(request.getCursor()); + planExecutor.cleanCursor(Configuration.DEFAULT, cursor, ActionListener.wrap( + success -> listener.onResponse(new SqlClearCursorResponse(success)), listener::onFailure)); + } +} + diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/session/Configuration.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/session/Configuration.java index 773b67ce84c..8748841b86d 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/session/Configuration.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/session/Configuration.java @@ -7,7 +7,7 @@ package org.elasticsearch.xpack.sql.session; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.query.QueryBuilder; -import org.elasticsearch.xpack.sql.plugin.sql.action.AbstractSqlRequest; +import org.elasticsearch.xpack.sql.plugin.AbstractSqlRequest; import org.elasticsearch.xpack.sql.protocol.shared.AbstractQueryInitRequest; import org.elasticsearch.xpack.sql.protocol.shared.Nullable; import org.joda.time.DateTimeZone; diff --git a/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/CliFormatterTests.java b/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/CliFormatterTests.java index f51c93bc4f9..52440394bb2 100644 --- a/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/CliFormatterTests.java +++ b/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/CliFormatterTests.java @@ -6,9 +6,7 @@ package org.elasticsearch.xpack.sql.plugin; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlResponse; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlResponse.ColumnInfo; -import org.elasticsearch.xpack.sql.session.Cursor; +import org.elasticsearch.xpack.sql.plugin.SqlResponse.ColumnInfo; import java.sql.JDBCType; import java.util.Arrays; @@ -16,7 +14,7 @@ import java.util.Arrays; import static org.hamcrest.Matchers.arrayWithSize; public class CliFormatterTests extends ESTestCase { - private final SqlResponse firstResponse = new SqlResponse(Cursor.EMPTY, 10, 5, + private final SqlResponse firstResponse = new SqlResponse("", 10, 5, Arrays.asList( new ColumnInfo("foo", "string", JDBCType.VARCHAR, 0), new ColumnInfo("bar", "long", JDBCType.BIGINT, 15), @@ -49,7 +47,7 @@ public class CliFormatterTests extends ESTestCase { * truncation of long columns. */ public void testFormatWithoutHeader() { - String[] result = formatter.formatWithoutHeader(new SqlResponse(Cursor.EMPTY, 10, 5, null, + String[] result = formatter.formatWithoutHeader(new SqlResponse("", 10, 5, null, Arrays.asList( Arrays.asList("ohnotruncateddata", 4, 1, 77, "wombat"), Arrays.asList("dog", 2, 123124.888, 9912, "goat")))).split("\n"); diff --git a/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorRequestTests.java b/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorRequestTests.java deleted file mode 100644 index 5193a797018..00000000000 --- a/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorRequestTests.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.plugin; - -import org.elasticsearch.common.io.stream.NamedWriteableRegistry; -import org.elasticsearch.test.AbstractStreamableTestCase; -import org.elasticsearch.test.EqualsHashCodeTestUtils.MutateFunction; -import org.elasticsearch.xpack.sql.session.Cursor; - -import static org.elasticsearch.xpack.sql.execution.search.ScrollCursorTests.randomScrollCursor; - -public class SqlClearCursorRequestTests extends AbstractStreamableTestCase { - - @Override - protected SqlClearCursorAction.Request createTestInstance() { - return new SqlClearCursorAction.Request(randomScrollCursor()); - } - - @Override - protected SqlClearCursorAction.Request createBlankInstance() { - return new SqlClearCursorAction.Request(); - } - - @Override - @SuppressWarnings("unchecked") - protected MutateFunction getMutateFunction() { - return request -> getCopyFunction().copy(request).setCursor(randomScrollCursor()); - } - - @Override - protected NamedWriteableRegistry getNamedWriteableRegistry() { - return new NamedWriteableRegistry(Cursor.getNamedWriteables()); - } - -} diff --git a/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorResponseTests.java b/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorResponseTests.java deleted file mode 100644 index a72b0901426..00000000000 --- a/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/SqlClearCursorResponseTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.sql.plugin; - -import org.elasticsearch.test.AbstractStreamableTestCase; -import org.elasticsearch.test.EqualsHashCodeTestUtils.MutateFunction; - -public class SqlClearCursorResponseTests extends AbstractStreamableTestCase { - - @Override - protected SqlClearCursorAction.Response createTestInstance() { - return new SqlClearCursorAction.Response(randomBoolean()); - } - - @Override - protected SqlClearCursorAction.Response createBlankInstance() { - return new SqlClearCursorAction.Response(); - } - - @Override - protected MutateFunction getMutateFunction() { - return response -> getCopyFunction().copy(response).setSucceeded(response.isSucceeded() == false); - } -} diff --git a/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlRequestTests.java b/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlRequestTests.java index 9667b94b8db..8717afcb480 100644 --- a/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlRequestTests.java +++ b/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlRequestTests.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.xpack.sql.plugin.sql.action; +import org.elasticsearch.Version; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; @@ -13,6 +14,8 @@ import org.elasticsearch.test.AbstractStreamableTestCase; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.EqualsHashCodeTestUtils.MutateFunction; import org.elasticsearch.xpack.sql.plugin.SqlPlugin; +import org.elasticsearch.xpack.sql.plugin.SqlRequest; +import org.elasticsearch.xpack.sql.session.Cursor; import java.util.ArrayList; import java.util.Collections; @@ -35,7 +38,7 @@ public class SqlRequestTests extends AbstractStreamableTestCase { @Override protected SqlRequest createTestInstance() { return new SqlRequest(randomAlphaOfLength(10), randomFilterOrNull(random()), randomDateTimeZone(), - between(1, Integer.MAX_VALUE), randomTV(), randomTV(), randomCursor()); + between(1, Integer.MAX_VALUE), randomTV(), randomTV(), Cursor.encodeToString(Version.CURRENT, randomCursor())); } private TimeValue randomTV() { @@ -52,7 +55,7 @@ public class SqlRequestTests extends AbstractStreamableTestCase { protected MutateFunction getMutateFunction() { return randomFrom( request -> getCopyFunction().copy(request) - .cursor(randomValueOtherThan(request.cursor(), SqlResponseTests::randomCursor)), + .cursor(randomValueOtherThan(request.cursor(), SqlResponseTests::randomStringCursor)), request -> (SqlRequest) getCopyFunction().copy(request) .query(randomValueOtherThan(request.query(), () -> randomAlphaOfLength(5))), request -> (SqlRequest) getCopyFunction().copy(request) diff --git a/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlResponseTests.java b/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlResponseTests.java index bb51f5d5df0..5e91866c225 100644 --- a/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlResponseTests.java +++ b/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlResponseTests.java @@ -17,7 +17,9 @@ import org.elasticsearch.xpack.sql.plugin.CliFormatter; import org.elasticsearch.xpack.sql.plugin.CliFormatterCursor; import org.elasticsearch.xpack.sql.plugin.JdbcCursor; import org.elasticsearch.xpack.sql.plugin.SqlPlugin; -import org.elasticsearch.xpack.sql.plugin.sql.action.SqlResponse.ColumnInfo; +import org.elasticsearch.xpack.sql.plugin.SqlRequest; +import org.elasticsearch.xpack.sql.plugin.SqlResponse; +import org.elasticsearch.xpack.sql.plugin.SqlResponse.ColumnInfo; import org.elasticsearch.xpack.sql.session.Cursor; import java.io.IOException; @@ -30,6 +32,10 @@ import java.util.Map; import static org.hamcrest.Matchers.hasSize; public class SqlResponseTests extends AbstractStreamableTestCase { + static String randomStringCursor() { + return Cursor.encodeToString(Version.CURRENT, randomCursor()); + } + static Cursor randomCursor() { return randomBoolean() ? Cursor.EMPTY : randomNonEmptyCursor(); } @@ -46,7 +52,7 @@ public class SqlResponseTests extends AbstractStreamableTestCase { } return JdbcCursor.wrap(ScrollCursorTests.randomScrollCursor(), types); case 2: - SqlResponse response = createRandomInstance(Cursor.EMPTY); + SqlResponse response = createRandomInstance(""); if (response.columns() != null && response.rows() != null) { return CliFormatterCursor.wrap(ScrollCursorTests.randomScrollCursor(), new CliFormatter(response)); } else { @@ -64,10 +70,10 @@ public class SqlResponseTests extends AbstractStreamableTestCase { @Override protected SqlResponse createTestInstance() { - return createRandomInstance(randomCursor()); + return createRandomInstance(randomStringCursor()); } - private static SqlResponse createRandomInstance(Cursor cursor) { + private static SqlResponse createRandomInstance(String cursor) { int columnCount = between(1, 10); List columns = null; @@ -130,8 +136,8 @@ public class SqlResponseTests extends AbstractStreamableTestCase { assertEquals(row, testInstance.rows().get(i)); } - if (testInstance.cursor() != Cursor.EMPTY) { - assertEquals(rootMap.get(SqlRequest.CURSOR.getPreferredName()), Cursor.encodeToString(Version.CURRENT, testInstance.cursor())); + if (testInstance.cursor().equals("") == false) { + assertEquals(rootMap.get(SqlRequest.CURSOR.getPreferredName()), testInstance.cursor()); } } diff --git a/sql/shared-client/src/main/java/org/elasticsearch/xpack/sql/client/shared/CheckedBiFunction.java b/sql/shared-client/src/main/java/org/elasticsearch/xpack/sql/client/shared/CheckedBiFunction.java new file mode 100644 index 00000000000..ba16da3bfd3 --- /dev/null +++ b/sql/shared-client/src/main/java/org/elasticsearch/xpack/sql/client/shared/CheckedBiFunction.java @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.xpack.sql.client.shared; + +import java.util.function.BiFunction; + +/** + * A {@link BiFunction}-like interface which allows throwing checked exceptions. + * Elasticsearch has one of these but we don't depend on Elasticsearch. + */ +@FunctionalInterface +public interface CheckedBiFunction { + R apply(T t, U u) throws E; +} diff --git a/sql/shared-client/src/main/java/org/elasticsearch/xpack/sql/client/shared/JreHttpUrlConnection.java b/sql/shared-client/src/main/java/org/elasticsearch/xpack/sql/client/shared/JreHttpUrlConnection.java index 3bbd6fa9db5..491e489cbe9 100644 --- a/sql/shared-client/src/main/java/org/elasticsearch/xpack/sql/client/shared/JreHttpUrlConnection.java +++ b/sql/shared-client/src/main/java/org/elasticsearch/xpack/sql/client/shared/JreHttpUrlConnection.java @@ -5,6 +5,9 @@ */ package org.elasticsearch.xpack.sql.client.shared; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLSocketFactory; +import javax.sql.rowset.serial.SerialException; import java.io.Closeable; import java.io.DataInput; import java.io.DataInputStream; @@ -30,16 +33,13 @@ import java.sql.SQLRecoverableException; import java.sql.SQLSyntaxErrorException; import java.sql.SQLTimeoutException; import java.util.Base64; +import java.util.List; +import java.util.Map; import java.util.function.Function; import java.util.zip.GZIPInputStream; -import javax.sql.rowset.serial.SerialException; - import static java.util.Collections.emptyMap; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLSocketFactory; - public class JreHttpUrlConnection implements Closeable { /** * State added to {@link SQLException}s when the server encounters an @@ -142,37 +142,67 @@ public class JreHttpUrlConnection implements Closeable { try (OutputStream out = con.getOutputStream()) { doc.accept(new DataOutputStream(out)); } - if (con.getResponseCode() < 300) { + if (shouldParseBody(con.getResponseCode())) { try (InputStream stream = getStream(con, con.getInputStream())) { return new ResponseOrException<>(parser.apply(new DataInputStream(stream))); } } - RemoteFailure failure; - try (InputStream stream = getStream(con, con.getErrorStream())) { - failure = RemoteFailure.parseFromResponse(stream); - } - if (con.getResponseCode() >= 500) { - /* - * Borrowing a page from the HTTP spec, we throw a "transient" - * exception if the server responded with a 500, not because - * we think that the application should retry, but because we - * think that the failure is not the fault of the application. - */ - return new ResponseOrException<>(new SQLException("Server encountered an error [" - + failure.reason() + "]. [" + failure.remoteTrace() + "]", SQL_STATE_BAD_SERVER)); - } - SqlExceptionType type = SqlExceptionType.fromRemoteFailureType(failure.type()); - if (type == null) { - return new ResponseOrException<>(new SQLException("Server sent bad type [" - + failure.type() + "]. Original type was [" + failure.reason() + "]. [" - + failure.remoteTrace() + "]", SQL_STATE_BAD_SERVER)); - } - return new ResponseOrException<>(type.asException(failure.reason())); + return parserError(); } catch (IOException ex) { throw new ClientException(ex, "Cannot POST address %s (%s)", url, ex.getMessage()); } } + public ResponseOrException request( + CheckedConsumer doc, + CheckedBiFunction, R, IOException> parser, + String requestMethod + ) throws ClientException { + try { + con.setRequestMethod(requestMethod); + con.setDoOutput(true); + con.setRequestProperty("Content-Type", "application/json"); + if (doc != null) { + try (OutputStream out = con.getOutputStream()) { + doc.accept(new DataOutputStream(out)); + } + } + if (shouldParseBody(con.getResponseCode())) { + try (InputStream stream = getStream(con, con.getInputStream())) { + return new ResponseOrException<>(parser.apply( + new DataInputStream(stream), + con::getHeaderField + )); + } + } + return parserError(); + } catch (IOException ex) { + throw new ClientException(ex, "Cannot POST address %s (%s)", url, ex.getMessage()); + } + } + + private boolean shouldParseBody(int responseCode) { + return responseCode == 200 || responseCode == 201 || responseCode == 202; + } + + private ResponseOrException parserError() throws IOException { + RemoteFailure failure; + try (InputStream stream = getStream(con, con.getErrorStream())) { + failure = RemoteFailure.parseFromResponse(stream); + } + if (con.getResponseCode() >= 500) { + return new ResponseOrException<>(new SQLException("Server encountered an error [" + + failure.reason() + "]. [" + failure.remoteTrace() + "]", SQL_STATE_BAD_SERVER)); + } + SqlExceptionType type = SqlExceptionType.fromRemoteFailureType(failure.type()); + if (type == null) { + return new ResponseOrException<>(new SQLException("Server sent bad type [" + + failure.type() + "]. Original type was [" + failure.reason() + "]. [" + + failure.remoteTrace() + "]", SQL_STATE_BAD_SERVER)); + } + return new ResponseOrException<>(type.asException(failure.reason())); + } + public static class ResponseOrException { private final R response; private final SQLException exception; @@ -296,4 +326,4 @@ public class JreHttpUrlConnection implements Closeable { return toException.apply(message); } } -} +} \ No newline at end of file