Skip to content

Commit

Permalink
SQL: Remove the last remaining server dependencies from jdbc (#30771)
Browse files Browse the repository at this point in the history
Removes the last remaining server dependencies from jdbc client. In order to do that it introduces the new project sql-shared-proto that contains only XContent-serializable classes. HTTP Client and JDBC now depend only on sql-shared-proto. I had to keep the original sql-proto project since it is used as a dependency by sql-cli and security integration tests.

Relates #29856
  • Loading branch information
imotov authored May 25, 2018
1 parent 81eb8ba commit dbb2e81
Show file tree
Hide file tree
Showing 32 changed files with 489 additions and 750 deletions.
14 changes: 4 additions & 10 deletions x-pack/plugin/sql/jdbc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,20 @@ dependencies {
compile (xpackProject('plugin:sql:sql-shared-client')) {
transitive = false
}
compile (xpackProject('plugin:sql:sql-proto')) {
compile (xpackProject('plugin:sql:sql-shared-proto')) {
transitive = false
}
} else {
bundled (xpackProject('plugin:sql:sql-shared-client')) {
transitive = false
}
bundled (xpackProject('plugin:sql:sql-proto')) {
bundled (xpackProject('plugin:sql:sql-shared-proto')) {
transitive = false
}
}
compile (project(':server')) {
transitive = false
}
compile (project(':libs:x-content')) {
transitive = false
}
compile "org.apache.lucene:lucene-core:${versions.lucene}"
compile 'joda-time:joda-time:2.9.9'
compile project(':libs:elasticsearch-core')
runtime "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
Expand All @@ -80,15 +76,13 @@ dependencies {
}

dependencyLicenses {
mapping from: /sql-proto.*/, to: 'elasticsearch'
mapping from: /sql-shared-proto.*/, to: 'elasticsearch'
mapping from: /sql-shared-client.*/, to: 'elasticsearch'
mapping from: /jackson-.*/, to: 'jackson'
mapping from: /lucene-.*/, to: 'lucene'
mapping from: /elasticsearch-core.*/, to: 'elasticsearch'
ignoreSha 'sql-proto'
ignoreSha 'sql-shared-proto'
ignoreSha 'sql-shared-client'
ignoreSha 'elasticsearch'
ignoreSha 'elasticsearch-core'
}

/*
Expand Down
475 changes: 0 additions & 475 deletions x-pack/plugin/sql/jdbc/licenses/lucene-LICENSE.txt

This file was deleted.

192 changes: 0 additions & 192 deletions x-pack/plugin/sql/jdbc/licenses/lucene-NOTICE.txt

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.sql.plugin.SqlQueryResponse;
import org.elasticsearch.xpack.sql.proto.Mode;
import org.joda.time.DateTime;
import org.joda.time.ReadableDateTime;

import java.sql.JDBCType;

Expand Down Expand Up @@ -51,7 +50,11 @@ private Object convertAsNative(Object value, JDBCType type) throws Exception {
XContentBuilder builder = JsonXContent.contentBuilder();
builder.startObject();
builder.field("value");
SqlQueryResponse.value(builder, Mode.JDBC, value);
if (value instanceof ReadableDateTime) {
builder.value(((ReadableDateTime) value).getMillis());
} else {
builder.value(value);
}
builder.endObject();
builder.close();
Object copy = XContentHelper.convertToMap(BytesReference.bytes(builder), false, builder.contentType()).v2().get("value");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.elasticsearch.xpack.sql.client.HttpClient;
import org.elasticsearch.xpack.sql.client.shared.ClientException;
import org.elasticsearch.xpack.sql.client.shared.Version;
import org.elasticsearch.xpack.sql.plugin.AbstractSqlQueryRequest;
import org.elasticsearch.xpack.sql.proto.MainResponse;
import org.elasticsearch.xpack.sql.proto.Protocol;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class CliSessionTests extends ESTestCase {
public void testProperConnection() throws Exception {
HttpClient httpClient = mock(HttpClient.class);
when(httpClient.serverInfo()).thenReturn(new MainResponse(randomAlphaOfLength(5), org.elasticsearch.Version.CURRENT.toString(),
ClusterName.DEFAULT.value(), UUIDs.randomBase64UUID(), Build.CURRENT));
ClusterName.DEFAULT.value(), UUIDs.randomBase64UUID()));
CliSession cliSession = new CliSession(httpClient);
cliSession.checkConnection();
verify(httpClient, times(1)).serverInfo();
Expand Down Expand Up @@ -58,7 +58,7 @@ public void testWrongServerVersion() throws Exception {
}
when(httpClient.serverInfo()).thenReturn(new MainResponse(randomAlphaOfLength(5),
org.elasticsearch.Version.fromString(major + "." + minor + ".23").toString(),
ClusterName.DEFAULT.value(), UUIDs.randomBase64UUID(), Build.CURRENT));
ClusterName.DEFAULT.value(), UUIDs.randomBase64UUID()));
CliSession cliSession = new CliSession(httpClient);
expectThrows(ClientException.class, cliSession::checkConnection);
verify(httpClient, times(1)).serverInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void testShowInfo() throws Exception {
HttpClient client = mock(HttpClient.class);
CliSession cliSession = new CliSession(client);
when(client.serverInfo()).thenReturn(new MainResponse("my_node", "1.2.3",
new ClusterName("my_cluster").value(), UUIDs.randomBase64UUID(), Build.CURRENT));
new ClusterName("my_cluster").value(), UUIDs.randomBase64UUID()));
ServerInfoCliCommand cliCommand = new ServerInfoCliCommand();
assertTrue(cliCommand.handle(testTerminal, cliSession, "info"));
assertEquals(testTerminal.toString(), "Node:<em>my_node</em> Cluster:<em>my_cluster</em> Version:<em>1.2.3</em>\n");
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugin/sql/sql-proto/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
compile (project(':libs:x-content')) {
transitive = false
}
compile xpackProject('plugin:sql:sql-shared-proto')
compile "org.apache.lucene:lucene-core:${versions.lucene}"
compile 'joda-time:joda-time:2.9.9'
runtime "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugin/sql/sql-shared-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ apply plugin: 'elasticsearch.build'
description = 'Code shared between jdbc and cli'

dependencies {
compile xpackProject('plugin:sql:sql-proto')
compile xpackProject('plugin:sql:sql-shared-proto')
compile "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
testCompile "org.elasticsearch.test:framework:${version}"
}

dependencyLicenses {
mapping from: /jackson-.*/, to: 'jackson'
mapping from: /sql-proto.*/, to: 'elasticsearch'
mapping from: /sql-shared-proto.*/, to: 'elasticsearch'
mapping from: /elasticsearch-cli.*/, to: 'elasticsearch'
mapping from: /elasticsearch-core.*/, to: 'elasticsearch'
mapping from: /lucene-.*/, to: 'lucene'
Expand Down
Loading

0 comments on commit dbb2e81

Please sign in to comment.