mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 04:58:50 +00:00
This teaches SQL to parse Elasticsearch's standard error responses but doesn't change SQL to general Elasticsearch's standard error responses in all cases. That can come in a followup. We do this parsing with jackson-core, the same dependency Elasticsearch uses for parsing json. We shade jackson-core in the JDBC driver so that users don't have to worry about dependency clashes. We do not do so in the CLI because it is a standalone application. We get a few "bonus" changes along the way: 1. We save a copy operation. Before this change responses were spooled into memory and then parsed. After this change they are parsed directly from the response stream. 2. We had a few classes entirely to support the spooling operation that we no longer need: `BytesArray`, `FastByteArrayInputStream`, and `BasicByteArrayOutputStream`. 3. SQL's `Version` was incorrectly parsing the version from the jar manifest. We didn't notice because the test was rigged to return `UNKNOWN` because we *were* running the test from the compiled classes directory instead of the jar. As part of shading jackson we moved running the tests to running against the shaded jar. Now we can actually assert that we parse the version correctly. It turns out we weren't. So I fixed it. Original commit: elastic/x-pack-elasticsearch@2e8f397bf4
95 lines
3.4 KiB
Groovy
95 lines
3.4 KiB
Groovy
apply plugin: 'elasticsearch.build'
|
|
/* We don't use the 'application' plugin because it builds a zip and tgz which
|
|
* we don't want. */
|
|
|
|
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:shared-proto')
|
|
|
|
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: /shared-client.*/, to: 'elasticsearch'
|
|
mapping from: /shared-proto.*/, to: 'elasticsearch'
|
|
mapping from: /jackson-.*/, to: 'jackson'
|
|
ignoreSha 'cli-proto'
|
|
ignoreSha 'shared-client'
|
|
ignoreSha 'shared-proto'
|
|
}
|
|
|
|
forbiddenApisMain {
|
|
// does not depend on core, so only jdk and http signatures should be checked
|
|
signaturesURLs = [this.class.getResource('/forbidden/jdk-signatures.txt')]
|
|
}
|
|
|
|
jar {
|
|
// Bundle all dependencies into the jar.
|
|
from {
|
|
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
|
|
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
|
|
}
|
|
// Make the jar "executable" with `java -jar`
|
|
manifest {
|
|
attributes 'Main-Class': 'org.elasticsearch.xpack.sql.cli.Cli'
|
|
}
|
|
}
|
|
|
|
// Needed so we can launch graphviz if it is installed
|
|
project.compactProfile = 'full'
|
|
|
|
thirdPartyAudit.excludes = [
|
|
'org.apache.sshd.client.SshClient',
|
|
'org.apache.sshd.client.auth.keyboard.UserInteraction',
|
|
'org.apache.sshd.client.channel.ChannelShell',
|
|
'org.apache.sshd.client.channel.ClientChannel',
|
|
'org.apache.sshd.client.channel.ClientChannelEvent',
|
|
'org.apache.sshd.client.future.AuthFuture',
|
|
'org.apache.sshd.client.future.ConnectFuture',
|
|
'org.apache.sshd.client.future.OpenFuture',
|
|
'org.apache.sshd.client.session.ClientSession',
|
|
'org.apache.sshd.common.Factory',
|
|
'org.apache.sshd.common.channel.PtyMode',
|
|
'org.apache.sshd.common.config.keys.FilePasswordProvider',
|
|
'org.apache.sshd.common.util.io.NoCloseInputStream',
|
|
'org.apache.sshd.common.util.io.NoCloseOutputStream',
|
|
'org.apache.sshd.server.Command',
|
|
'org.apache.sshd.server.Environment',
|
|
'org.apache.sshd.server.ExitCallback',
|
|
'org.apache.sshd.server.SessionAware',
|
|
'org.apache.sshd.server.Signal',
|
|
'org.apache.sshd.server.SshServer',
|
|
'org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider',
|
|
'org.apache.sshd.server.scp.ScpCommandFactory$Builder',
|
|
'org.apache.sshd.server.session.ServerSession',
|
|
'org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory$Builder',
|
|
'org.mozilla.universalchardet.UniversalDetector'
|
|
]
|
|
|
|
task run {
|
|
description = 'Run the CLI and connect to elasticsearch running on 9200'
|
|
dependsOn 'assemble'
|
|
doLast {
|
|
List command = [new File(project.javaHome, 'bin/java').absolutePath]
|
|
if ('true'.equals(System.getProperty('debug', 'false'))) {
|
|
command += '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000'
|
|
}
|
|
command += ['-jar', jar.archivePath.absolutePath]
|
|
logger.info("running the cli with: ${command}")
|
|
|
|
new ProcessBuilder(command)
|
|
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
|
|
.redirectInput(ProcessBuilder.Redirect.INHERIT)
|
|
.redirectError(ProcessBuilder.Redirect.INHERIT)
|
|
.start()
|
|
.waitFor()
|
|
}
|
|
}
|