Merge remote-tracking branch 'es/7.x' into enrich-7.x

This commit is contained in:
Martijn van Groningen 2019-09-23 09:46:05 +02:00
commit 0cfddca61d
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
1510 changed files with 24531 additions and 12944 deletions

View File

@ -43,4 +43,5 @@ BWC_VERSION:
- "7.3.0"
- "7.3.1"
- "7.3.2"
- "7.3.3"
- "7.4.0"

View File

@ -86,6 +86,10 @@ if (buildCacheUrl) {
.getData();
gradle.settingsEvaluated { settings ->
settings.buildCache {
local {
// Disable the local build cache in CI since we use ephemeral workers and it incurs an IO penalty
enabled = false
}
remote(HttpBuildCache) {
url = buildCacheUrl
push = buildCachePush

View File

@ -105,6 +105,7 @@ dependencies {
compile localGroovy()
compile 'commons-codec:commons-codec:1.12'
compile 'org.apache.commons:commons-compress:1.19'
compile 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
compile 'com.netflix.nebula:nebula-publishing-plugin:4.4.4'

View File

@ -1 +1,2 @@
include 'reaper'
include 'symbolic-link-preserving-tar'

View File

@ -21,19 +21,21 @@ package org.elasticsearch.gradle.doc
import org.elasticsearch.gradle.OS
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.test.RestTestPlugin
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
/**
* Sets up tests for documentation.
*/
public class DocsTestPlugin extends RestTestPlugin {
class DocsTestPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
void apply(Project project) {
project.pluginManager.apply('elasticsearch.testclusters')
project.pluginManager.apply('elasticsearch.standalone-rest-test')
super.apply(project)
project.pluginManager.apply('elasticsearch.rest-test')
String distribution = System.getProperty('tests.distribution', 'default')
// The distribution can be configured with -Dtests.distribution on the command line
project.testClusters.integTest.testDistribution = distribution.toUpperCase()

View File

@ -687,9 +687,7 @@ class ClusterFormationTasks {
static Task configureExecTask(String name, Project project, Task setup, NodeInfo node, Object[] execArgs) {
return project.tasks.create(name: name, type: LoggedExec, dependsOn: setup) { Exec exec ->
exec.workingDir node.cwd
if ((project.isRuntimeJavaHomeSet && node.isBwcNode == false) // runtime Java might not be compatible with old nodes
|| node.nodeVersion.before(Version.fromString("7.0.0"))
|| node.config.distribution == 'integ-test-zip') {
if (useRuntimeJava(project, node)) {
exec.environment.put('JAVA_HOME', project.runtimeJavaHome)
} else {
// force JAVA_HOME to *not* be set
@ -707,6 +705,12 @@ class ClusterFormationTasks {
}
}
public static boolean useRuntimeJava(Project project, NodeInfo node) {
return (project.isRuntimeJavaHomeSet ||
(node.isBwcNode == false && node.nodeVersion.before(Version.fromString("7.0.0"))) ||
node.config.distribution == 'integ-test-zip')
}
/** Adds a task to start an elasticsearch node with the given configuration */
static Task configureStartTask(String name, Project project, Task setup, NodeInfo node) {
// this closure is converted into ant nodes by groovy's AntBuilder
@ -714,9 +718,7 @@ class ClusterFormationTasks {
ant.exec(executable: node.executable, spawn: node.config.daemonize, newenvironment: true,
dir: node.cwd, taskname: 'elasticsearch') {
node.env.each { key, value -> env(key: key, value: value) }
if ((project.isRuntimeJavaHomeSet && node.isBwcNode == false) // runtime Java might not be compatible with old nodes
|| node.nodeVersion.before(Version.fromString("7.0.0"))
|| node.config.distribution == 'integ-test-zip') {
if (useRuntimeJava(project, node)) {
env(key: 'JAVA_HOME', value: project.runtimeJavaHome)
}
node.args.each { arg(value: it) }

View File

@ -66,6 +66,7 @@ import static org.elasticsearch.gradle.vagrant.VagrantMachine.convertWindowsPath
public class DistroTestPlugin implements Plugin<Project> {
private static final String GRADLE_JDK_VERSION = "12.0.1+12@69cfe15208a647278a19ef0990eea691";
private static final String GRADLE_JDK_VENDOR = "openjdk";
// all distributions used by distro tests. this is temporary until tests are per distribution
private static final String DISTRIBUTIONS_CONFIGURATION = "distributions";
@ -138,8 +139,10 @@ public class DistroTestPlugin implements Plugin<Project> {
});
}
private static Jdk createJdk(NamedDomainObjectContainer<Jdk> jdksContainer, String name, String version, String platform) {
private static Jdk createJdk(
NamedDomainObjectContainer<Jdk> jdksContainer, String name, String vendor, String version, String platform) {
Jdk jdk = jdksContainer.create(name);
jdk.setVendor(vendor);
jdk.setVersion(version);
jdk.setPlatform(platform);
return jdk;
@ -174,7 +177,7 @@ public class DistroTestPlugin implements Plugin<Project> {
NamedDomainObjectContainer<Jdk> jdksContainer = JdkDownloadPlugin.getContainer(project);
String platform = box.contains("windows") ? "windows" : "linux";
Jdk gradleJdk = createJdk(jdksContainer, "gradle", GRADLE_JDK_VERSION, platform);
Jdk gradleJdk = createJdk(jdksContainer, "gradle", GRADLE_JDK_VENDOR, GRADLE_JDK_VERSION, platform);
// setup VM used by these tests
VagrantExtension vagrant = project.getExtensions().getByType(VagrantExtension.class);

View File

@ -22,10 +22,12 @@ import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
import org.elasticsearch.gradle.tool.Boilerplate
import org.elasticsearch.gradle.tool.ClasspathUtils
import org.gradle.api.DefaultTask
import org.gradle.api.Task
import org.gradle.api.execution.TaskExecutionAdapter
import org.gradle.api.file.FileCopyDetails
import org.gradle.api.logging.Logger
import org.gradle.api.logging.Logging
import org.gradle.api.tasks.Copy
@ -39,6 +41,7 @@ import org.gradle.process.CommandLineArgumentProvider
import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.util.stream.Stream
/**
* A wrapper task around setting up a cluster and running rest tests.
*/
@ -121,9 +124,9 @@ class RestIntegTestTask extends DefaultTask {
runner.systemProperty('test.cluster', System.getProperty("tests.cluster"))
}
// copy the rest spec/tests into the test resources
Task copyRestSpec = createCopyRestSpecTask()
runner.dependsOn(copyRestSpec)
// copy the rest spec/tests onto the test classpath
Copy copyRestSpec = createCopyRestSpecTask()
project.sourceSets.test.output.builtBy(copyRestSpec)
// this must run after all projects have been configured, so we know any project
// references can be accessed as a fully configured
@ -222,40 +225,28 @@ class RestIntegTestTask extends DefaultTask {
}
/**
* Creates a task (if necessary) to copy the rest spec files.
*
* @param project The project to add the copy task to
* @param includePackagedTests true if the packaged tests should be copied, false otherwise
*/
Task createCopyRestSpecTask() {
project.configurations {
restSpec
}
project.dependencies {
restSpec ClasspathUtils.isElasticsearchProject() ? project.project(':rest-api-spec') :
Copy createCopyRestSpecTask() {
Boilerplate.maybeCreate(project.configurations, 'restSpec') {
project.dependencies.add(
'restSpec',
ClasspathUtils.isElasticsearchProject() ? project.project(':rest-api-spec') :
"org.elasticsearch:rest-api-spec:${VersionProperties.elasticsearch}"
)
}
Task copyRestSpec = project.tasks.findByName('copyRestSpec')
if (copyRestSpec != null) {
return copyRestSpec
}
Map copyRestSpecProps = [
name : 'copyRestSpec',
type : Copy,
dependsOn: [project.configurations.restSpec, 'processTestResources']
]
copyRestSpec = project.tasks.create(copyRestSpecProps) {
into project.sourceSets.test.output.resourcesDir
}
project.afterEvaluate {
copyRestSpec.from({ project.zipTree(project.configurations.restSpec.singleFile) }) {
include 'rest-api-spec/api/**'
if (includePackaged) {
include 'rest-api-spec/test/**'
return Boilerplate.maybeCreate(project.tasks, 'copyRestSpec', Copy) { Copy copy ->
copy.dependsOn project.configurations.restSpec
copy.into(project.sourceSets.test.output.resourcesDir)
copy.from({ project.zipTree(project.configurations.restSpec.singleFile) }) {
includeEmptyDirs = false
include 'rest-api-spec/**'
filesMatching('rest-api-spec/test/**') { FileCopyDetails details ->
if (includePackaged == false) {
details.exclude()
}
}
}
if (project.plugins.hasPlugin(IdeaPlugin)) {
project.idea {
module {
@ -265,7 +256,6 @@ class RestIntegTestTask extends DefaultTask {
}
}
}
return copyRestSpec
}
}
}

View File

@ -25,7 +25,7 @@ import javax.inject.Inject;
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.TaskAction;
import org.gradle.internal.nativeintegration.filesystem.Chmod;
import org.gradle.internal.file.Chmod;
/**
* Creates an empty directory.

View File

@ -34,19 +34,22 @@ import java.util.regex.Pattern;
public class Jdk implements Buildable, Iterable<File> {
static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+)(\\.\\d+\\.\\d+)?\\+(\\d+)(@([a-f0-9]{32}))?");
private static final List<String> ALLOWED_PLATFORMS = Collections.unmodifiableList(Arrays.asList("linux", "windows", "darwin"));
private static final List<String> ALLOWED_VENDORS = Collections.unmodifiableList(Arrays.asList("adoptopenjdk", "openjdk"));
static final Pattern VERSION_PATTERN =
Pattern.compile("(\\d+)(\\.\\d+\\.\\d+)?\\+(\\d+(?:\\.\\d+)?)(@([a-f0-9]{32}))?");
private static final List<String> ALLOWED_PLATFORMS = Collections.unmodifiableList(Arrays.asList("darwin", "linux", "windows"));
private final String name;
private final Configuration configuration;
private final Property<String> vendor;
private final Property<String> version;
private final Property<String> platform;
Jdk(String name, Project project) {
this.name = name;
this.configuration = project.getConfigurations().create("jdk_" + name);
this.vendor = project.getObjects().property(String.class);
this.version = project.getObjects().property(String.class);
this.platform = project.getObjects().property(String.class);
}
@ -55,6 +58,17 @@ public class Jdk implements Buildable, Iterable<File> {
return name;
}
public String getVendor() {
return vendor.get();
}
public void setVendor(final String vendor) {
if (ALLOWED_VENDORS.contains(vendor) == false) {
throw new IllegalArgumentException("unknown vendor [" + vendor + "] for jdk [" + name + "], must be one of " + ALLOWED_VENDORS);
}
this.vendor.set(vendor);
}
public String getVersion() {
return version.get();
}
@ -105,12 +119,17 @@ public class Jdk implements Buildable, Iterable<File> {
if (platform.isPresent() == false) {
throw new IllegalArgumentException("platform not specified for jdk [" + name + "]");
}
if (vendor.isPresent() == false) {
throw new IllegalArgumentException("vendor not specified for jdk [" + name + "]");
}
version.finalizeValue();
platform.finalizeValue();
vendor.finalizeValue();;
}
@Override
public Iterator<File> iterator() {
return configuration.iterator();
}
}

View File

@ -19,6 +19,7 @@
package org.elasticsearch.gradle;
import org.elasticsearch.gradle.tar.SymbolicLinkPreservingUntarTask;
import org.gradle.api.Action;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.Plugin;
@ -31,12 +32,15 @@ import org.gradle.api.artifacts.dsl.DependencyHandler;
import org.gradle.api.artifacts.dsl.RepositoryHandler;
import org.gradle.api.artifacts.repositories.IvyArtifactRepository;
import org.gradle.api.file.CopySpec;
import org.gradle.api.file.Directory;
import org.gradle.api.file.FileTree;
import org.gradle.api.file.RelativePath;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.Copy;
import org.gradle.api.tasks.TaskProvider;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
@ -60,6 +64,7 @@ public class JdkDownloadPlugin implements Plugin<Project> {
project.afterEvaluate(p -> {
for (Jdk jdk : jdksContainer) {
jdk.finalizeValues();
String vendor = jdk.getVendor();
String version = jdk.getVersion();
String platform = jdk.getPlatform();
@ -67,18 +72,21 @@ public class JdkDownloadPlugin implements Plugin<Project> {
DependencyHandler dependencies = project.getDependencies();
Map<String, Object> depConfig = new HashMap<>();
depConfig.put("path", ":"); // root project
depConfig.put("configuration", configName("extracted_jdk", version, platform));
depConfig.put("configuration", configName("extracted_jdk", vendor, version, platform));
dependencies.add(jdk.getConfiguration().getName(), dependencies.project(depConfig));
// ensure a root level jdk download task exists
setupRootJdkDownload(project.getRootProject(), platform, version);
setupRootJdkDownload(project.getRootProject(), platform, vendor, version);
}
});
// all other repos should ignore the special jdk artifacts
project.getRootProject().getRepositories().all(repo -> {
if (repo.getName().startsWith(REPO_NAME_PREFIX) == false) {
repo.content(content -> content.excludeGroup("jdk"));
repo.content(content -> {
content.excludeGroup("adoptopenjdk");
content.excludeGroup("openjdk");
});
}
});
}
@ -88,8 +96,8 @@ public class JdkDownloadPlugin implements Plugin<Project> {
return (NamedDomainObjectContainer<Jdk>) project.getExtensions().getByName(CONTAINER_NAME);
}
private static void setupRootJdkDownload(Project rootProject, String platform, String version) {
String extractTaskName = "extract" + capitalize(platform) + "Jdk" + version;
private static void setupRootJdkDownload(Project rootProject, String platform, String vendor, String version) {
String extractTaskName = "extract" + capitalize(platform) + "Jdk-" + vendor + "-" + version;
// NOTE: this is *horrendous*, but seems to be the only way to check for the existence of a registered task
try {
rootProject.getTasks().named(extractTaskName);
@ -111,9 +119,27 @@ public class JdkDownloadPlugin implements Plugin<Project> {
String hash = jdkVersionMatcher.group(5);
// add fake ivy repo for jdk url
String repoName = REPO_NAME_PREFIX + version;
String repoName = REPO_NAME_PREFIX + vendor + "_" + version;
RepositoryHandler repositories = rootProject.getRepositories();
if (rootProject.getRepositories().findByName(repoName) == null) {
if (vendor.equals("adoptopenjdk")) {
if (hash != null) {
throw new IllegalArgumentException("adoptopenjdk versions do not have hashes but was [" + version + "]");
}
repositories.ivy(ivyRepo -> {
ivyRepo.setName(repoName);
ivyRepo.setUrl("https://artifactory.elstc.co/artifactory/oss-jdk-local/");
ivyRepo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
final String pattern = String.format(
Locale.ROOT,
"adoptopenjdk/OpenJDK%sU-jdk_x64_[module]_hotspot_[revision]_%s.[ext]",
jdkMajor,
jdkBuild);
ivyRepo.patternLayout(layout -> layout.artifact(pattern));
ivyRepo.content(content -> content.includeGroup("adoptopenjdk"));
});
} else {
assert vendor.equals("openjdk") : vendor;
if (hash != null) {
// current pattern since 12.0.1
repositories.ivy(ivyRepo -> {
@ -122,7 +148,7 @@ public class JdkDownloadPlugin implements Plugin<Project> {
ivyRepo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
ivyRepo.patternLayout(layout -> layout.artifact(
"java/GA/jdk" + jdkVersion + "/" + hash + "/" + jdkBuild + "/GPL/openjdk-[revision]_[module]-x64_bin.[ext]"));
ivyRepo.content(content -> content.includeGroup("jdk"));
ivyRepo.content(content -> content.includeGroup("openjdk"));
});
} else {
// simpler legacy pattern from JDK 9 to JDK 12 that we are advocating to Oracle to bring back
@ -132,62 +158,123 @@ public class JdkDownloadPlugin implements Plugin<Project> {
ivyRepo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
ivyRepo.patternLayout(layout ->
layout.artifact("java/GA/jdk" + jdkMajor + "/" + jdkBuild + "/GPL/openjdk-[revision]_[module]-x64_bin.[ext]"));
ivyRepo.content(content -> content.includeGroup("jdk"));
ivyRepo.content(content -> content.includeGroup("openjdk"));
});
}
}
}
// add the jdk as a "dependency"
final ConfigurationContainer configurations = rootProject.getConfigurations();
String remoteConfigName = configName("openjdk", version, platform);
String localConfigName = configName("extracted_jdk", version, platform);
String remoteConfigName = configName(vendor, version, platform);
String localConfigName = configName("extracted_jdk", vendor, version, platform);
Configuration jdkConfig = configurations.findByName(remoteConfigName);
if (jdkConfig == null) {
jdkConfig = configurations.create(remoteConfigName);
configurations.create(localConfigName);
}
String platformDep = platform.equals("darwin") ? (vendor.equals("adoptopenjdk") ? "mac" : "osx") : platform;
String extension = platform.equals("windows") ? "zip" : "tar.gz";
String jdkDep = "jdk:" + (platform.equals("darwin") ? "osx" : platform) + ":" + jdkVersion + "@" + extension;
rootProject.getDependencies().add(configName("openjdk", version, platform), jdkDep);
String jdkDep = vendor + ":" + platformDep + ":" + jdkVersion + "@" + extension;
rootProject.getDependencies().add(configName(vendor, version, platform), jdkDep);
// add task for extraction
final Provider<Directory> extractPath =
rootProject.getLayout().getBuildDirectory().dir("jdks/" + vendor + "-" + jdkVersion + "_" + platform);
// delay resolving jdkConfig until runtime
Supplier<File> jdkArchiveGetter = jdkConfig::getSingleFile;
final Object extractTask;
if (extension.equals("zip")) {
final Callable<FileTree> fileGetter = () -> rootProject.zipTree(jdkArchiveGetter.get());
// TODO: look into doing this as an artifact transform, which are cacheable starting in gradle 5.3
int rootNdx = platform.equals("darwin") ? 2 : 1;
Action<CopySpec> removeRootDir = copy -> {
// remove extra unnecessary directory levels
copy.eachFile(details -> {
/*
* We want to remove up to the and including the jdk-.* relative paths. That is a JDK archive is structured as:
* jdk-12.0.1/
* jdk-12.0.1/Contents
* ...
*
* and we want to remove the leading jdk-12.0.1. Note however that there could also be a leading ./ as in
* ./
* ./jdk-12.0.1/
* ./jdk-12.0.1/Contents
*
* so we account for this and search the path components until we find the jdk-12.0.1, and strip the leading components.
*/
String[] pathSegments = details.getRelativePath().getSegments();
String[] newPathSegments = Arrays.copyOfRange(pathSegments, rootNdx, pathSegments.length);
int index = 0;
for (; index < pathSegments.length; index++) {
if (pathSegments[index].matches("jdk-.*")) break;
}
assert index + 1 <= pathSegments.length;
String[] newPathSegments = Arrays.copyOfRange(pathSegments, index + 1, pathSegments.length);
details.setRelativePath(new RelativePath(true, newPathSegments));
});
copy.setIncludeEmptyDirs(false);
};
// delay resolving jdkConfig until runtime
Supplier<File> jdkArchiveGetter = jdkConfig::getSingleFile;
final Callable<FileTree> fileGetter;
if (extension.equals("zip")) {
fileGetter = () -> rootProject.zipTree(jdkArchiveGetter.get());
} else {
fileGetter = () -> rootProject.tarTree(rootProject.getResources().gzip(jdkArchiveGetter.get()));
}
String extractDir = rootProject.getBuildDir().toPath().resolve("jdks/openjdk-" + jdkVersion + "_" + platform).toString();
TaskProvider<Copy> extractTask = rootProject.getTasks().register(extractTaskName, Copy.class, copyTask -> {
extractTask = rootProject.getTasks().register(extractTaskName, Copy.class, copyTask -> {
copyTask.doFirst(new Action<Task>() {
@Override
public void execute(Task t) {
rootProject.delete(extractDir);
rootProject.delete(extractPath);
}
});
copyTask.into(extractDir);
copyTask.into(extractPath);
copyTask.from(fileGetter, removeRootDir);
});
} else {
/*
* Gradle TarFileTree does not resolve symlinks, so we have to manually extract and preserve the symlinks.
* cf. https://github.com/gradle/gradle/issues/3982 and https://discuss.gradle.org/t/tar-and-untar-losing-symbolic-links/2039
*/
final Configuration jdkConfiguration = jdkConfig;
extractTask = rootProject.getTasks().register(extractTaskName, SymbolicLinkPreservingUntarTask.class, task -> {
task.getTarFile().set(jdkConfiguration.getSingleFile());
task.getExtractPath().set(extractPath);
task.setTransform(
name -> {
/*
* We want to remove up to the and including the jdk-.* relative paths. That is a JDK archive is structured as:
* jdk-12.0.1/
* jdk-12.0.1/Contents
* ...
*
* and we want to remove the leading jdk-12.0.1. Note however that there could also be a leading ./ as in
* ./
* ./jdk-12.0.1/
* ./jdk-12.0.1/Contents
*
* so we account for this and search the path components until we find the jdk-12.0.1, and strip the leading
* components.
*/
final Path entryName = Paths.get(name);
int index = 0;
for (; index < entryName.getNameCount(); index++) {
if (entryName.getName(index).toString().matches("jdk-.*")) break;
}
if (index + 1 >= entryName.getNameCount()) {
// this happens on the top-level directories in the archive, which we are removing
return null;
}
// finally remove the top-level directories from the output path
return entryName.subpath(index + 1, entryName.getNameCount());
});
});
}
rootProject.getArtifacts().add(localConfigName,
rootProject.getLayout().getProjectDirectory().dir(extractDir),
extractPath,
artifact -> artifact.builtBy(extractTask));
}
private static String configName(String prefix, String version, String platform) {
return prefix + "_" + version + "_" + platform;
private static String configName(String vendor, String version, String platform) {
return vendor + "_" + version + "_" + platform;
}
private static String configName(String prefix, String vendor, String version, String platform) {
return prefix + "_" + vendor + "_" + version + "_" + platform;
}
private static String capitalize(String s) {

View File

@ -120,9 +120,9 @@ public class GenerateGlobalBuildInfoTask extends DefaultTask {
@TaskAction
public void generate() {
String javaVendor = System.getProperty("java.vendor");
String javaVendorVersion = System.getProperty("java.vendor.version", System.getProperty("java.vendor"));
String gradleJavaVersion = System.getProperty("java.version");
String gradleJavaVersionDetails = javaVendor + " " + gradleJavaVersion + " [" + System.getProperty("java.vm.name")
String gradleJavaVersionDetails = javaVendorVersion + " " + gradleJavaVersion + " [" + System.getProperty("java.vm.name")
+ " " + System.getProperty("java.vm.version") + "]";
String compilerJavaVersionDetails = gradleJavaVersionDetails;
@ -231,8 +231,10 @@ public class GenerateGlobalBuildInfoTask extends DefaultTask {
*/
private String findJavaVersionDetails(File javaHome) {
String versionInfoScript = "print(" +
"java.lang.System.getProperty(\"java.vendor\") + \" \" + java.lang.System.getProperty(\"java.version\") + " +
"\" [\" + java.lang.System.getProperty(\"java.vm.name\") + \" \" + java.lang.System.getProperty(\"java.vm.version\") + \"]\");";
"java.lang.System.getProperty(\"java.vendor.version\", java.lang.System.getProperty(\"java.vendor\")) + \" \" + " +
"java.lang.System.getProperty(\"java.version\") + \" [\" + " +
"java.lang.System.getProperty(\"java.vm.name\") + \" \" + " +
"java.lang.System.getProperty(\"java.vm.version\") + \"]\");";
return runJavaAsScript(javaHome, versionInfoScript).trim();
}

View File

@ -95,6 +95,7 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
ext.set("gradleJavaVersion", Jvm.current().getJavaVersion());
ext.set("gitRevision", gitRevision(project.getRootProject().getRootDir()));
ext.set("buildDate", ZonedDateTime.now(ZoneOffset.UTC));
ext.set("isCi", System.getenv("JENKINS_URL") != null);
});
}

View File

@ -0,0 +1,211 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you 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.
*/
package org.elasticsearch.gradle.tar;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.archivers.tar.TarConstants;
import org.apache.commons.compress.archivers.zip.UnixStat;
import org.gradle.api.GradleException;
import org.gradle.api.file.FileCopyDetails;
import org.gradle.api.file.RegularFile;
import org.gradle.api.internal.file.CopyActionProcessingStreamAction;
import org.gradle.api.internal.file.archive.compression.ArchiveOutputStreamFactory;
import org.gradle.api.internal.file.archive.compression.Bzip2Archiver;
import org.gradle.api.internal.file.archive.compression.GzipArchiver;
import org.gradle.api.internal.file.archive.compression.SimpleCompressor;
import org.gradle.api.internal.file.copy.CopyAction;
import org.gradle.api.internal.file.copy.CopyActionProcessingStream;
import org.gradle.api.internal.file.copy.FileCopyDetailsInternal;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.WorkResult;
import org.gradle.api.tasks.WorkResults;
import org.gradle.api.tasks.bundling.Tar;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.HashSet;
import java.util.Set;
/**
* A custom archive task that assembles a tar archive that preserves symbolic links.
*
* This task is necessary because the built-in task {@link org.gradle.api.tasks.bundling.Tar} does not preserve symbolic links.
*/
public class SymbolicLinkPreservingTar extends Tar {
@Override
protected CopyAction createCopyAction() {
final ArchiveOutputStreamFactory compressor;
switch (getCompression()) {
case BZIP2:
compressor = Bzip2Archiver.getCompressor();
break;
case GZIP:
compressor = GzipArchiver.getCompressor();
break;
default:
compressor = new SimpleCompressor();
break;
}
return new SymbolicLinkPreservingTarCopyAction(getArchiveFile(), compressor, isPreserveFileTimestamps());
}
private static class SymbolicLinkPreservingTarCopyAction implements CopyAction {
private final Provider<RegularFile> tarFile;
private final ArchiveOutputStreamFactory compressor;
private final boolean isPreserveFileTimestamps;
SymbolicLinkPreservingTarCopyAction(
final Provider<RegularFile> tarFile,
final ArchiveOutputStreamFactory compressor,
final boolean isPreserveFileTimestamps) {
this.tarFile = tarFile;
this.compressor = compressor;
this.isPreserveFileTimestamps = isPreserveFileTimestamps;
}
@Override
public WorkResult execute(final CopyActionProcessingStream stream) {
try (OutputStream out = compressor.createArchiveOutputStream(tarFile.get().getAsFile());
TarArchiveOutputStream tar = new TarArchiveOutputStream(out)) {
tar.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
stream.process(new SymbolicLinkPreservingTarStreamAction(tar));
} catch (final IOException e) {
throw new GradleException("failed writing tar file [" + tarFile + "]", e);
}
return WorkResults.didWork(true);
}
private class SymbolicLinkPreservingTarStreamAction implements CopyActionProcessingStreamAction {
private final TarArchiveOutputStream tar;
/*
* When Gradle walks the file tree, it will follow symbolic links. This means that if there is a symbolic link to a directory
* in the source file tree, we could otherwise end up duplicating the entries below that directory in the resulting tar archive.
* To avoid this, we track which symbolic links we have visited, and skip files that are children of symbolic links that we have
* already visited.
*/
private final Set<File> visitedSymbolicLinks = new HashSet<>();
SymbolicLinkPreservingTarStreamAction(final TarArchiveOutputStream tar) {
this.tar = tar;
}
@Override
public void processFile(final FileCopyDetailsInternal details) {
if (isChildOfVisitedSymbolicLink(details) == false) {
if (isSymbolicLink(details)) {
visitSymbolicLink(details);
} else if (details.isDirectory()) {
visitDirectory(details);
} else {
visitFile(details);
}
}
}
private boolean isChildOfVisitedSymbolicLink(final FileCopyDetailsInternal details) {
final File file;
try {
file = details.getFile();
} catch (final UnsupportedOperationException e) {
// we get invoked with stubbed details, there is no way to introspect this other than catching this exception
return false;
}
for (final File symbolicLink : visitedSymbolicLinks) {
if (isChildOf(symbolicLink, file)) return true;
}
return false;
}
private boolean isChildOf(final File directory, final File file) {
return file.toPath().startsWith(directory.toPath());
}
private boolean isSymbolicLink(final FileCopyDetailsInternal details) {
final File file;
try {
file = details.getFile();
} catch (final UnsupportedOperationException e) {
// we get invoked with stubbed details, there is no way to introspect this other than catching this exception
return false;
}
return Files.isSymbolicLink(file.toPath());
}
private void visitSymbolicLink(final FileCopyDetailsInternal details) {
visitedSymbolicLinks.add(details.getFile());
final TarArchiveEntry entry = new TarArchiveEntry(details.getRelativePath().getPathString(), TarConstants.LF_SYMLINK);
entry.setModTime(getModTime(details));
entry.setMode(UnixStat.LINK_FLAG | details.getMode());
try {
entry.setLinkName(Files.readSymbolicLink(details.getFile().toPath()).toString());
tar.putArchiveEntry(entry);
tar.closeArchiveEntry();
} catch (final IOException e) {
handleProcessingException(details, e);
}
}
private void visitDirectory(final FileCopyDetailsInternal details) {
final TarArchiveEntry entry = new TarArchiveEntry(details.getRelativePath().getPathString() + "/");
entry.setModTime(getModTime(details));
entry.setMode(UnixStat.DIR_FLAG | details.getMode());
try {
tar.putArchiveEntry(entry);
tar.closeArchiveEntry();
} catch (final IOException e) {
handleProcessingException(details, e);
}
}
private void visitFile(final FileCopyDetailsInternal details) {
final TarArchiveEntry entry = new TarArchiveEntry(details.getRelativePath().getPathString());
entry.setModTime(getModTime(details));
entry.setMode(UnixStat.FILE_FLAG | details.getMode());
entry.setSize(details.getSize());
try {
tar.putArchiveEntry(entry);
details.copyTo(tar);
tar.closeArchiveEntry();
} catch (final IOException e) {
handleProcessingException(details, e);
}
}
private void handleProcessingException(final FileCopyDetailsInternal details, final IOException e) {
throw new GradleException("could not add [" + details + "] to tar file [" + tarFile + "]", e);
}
}
private long getModTime(final FileCopyDetails details) {
return isPreserveFileTimestamps ? details.getLastModified() : 0;
}
}
}

View File

@ -0,0 +1,162 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you 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.
*/
package org.elasticsearch.gradle.tar;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.TaskAction;
import javax.inject.Inject;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.Set;
import java.util.function.Function;
/**
* A custom task that explodes a tar archive that preserves symbolic links.
*
* This task is necessary because the built-in task {@link org.gradle.api.internal.file.archive.TarFileTree} does not preserve symbolic
* links.
*/
public class SymbolicLinkPreservingUntarTask extends DefaultTask {
private final RegularFileProperty tarFile;
@InputFile
public RegularFileProperty getTarFile() {
return tarFile;
}
private final DirectoryProperty extractPath;
@OutputDirectory
public DirectoryProperty getExtractPath() {
return extractPath;
}
private Function<String, Path> transform;
/**
* A transform to apply to the tar entry, to derive the relative path from the entry name. If the return value is null, the entry is
* dropped from the exploded tar archive.
*
* @param transform the transform
*/
@Input
public void setTransform(Function<String, Path> transform) {
this.transform = transform;
}
@Inject
public SymbolicLinkPreservingUntarTask(final ObjectFactory objectFactory) {
this.tarFile = objectFactory.fileProperty();
this.extractPath = objectFactory.directoryProperty();
this.transform = name -> Paths.get(name);
}
@TaskAction
final void execute() {
// ensure the target extraction path is empty
getProject().delete(extractPath);
try (TarArchiveInputStream tar =
new TarArchiveInputStream(new GzipCompressorInputStream(new FileInputStream(tarFile.getAsFile().get())))) {
final Path destinationPath = extractPath.get().getAsFile().toPath();
TarArchiveEntry entry = tar.getNextTarEntry();
while (entry != null) {
final Path relativePath = transform.apply(entry.getName());
if (relativePath == null) {
entry = tar.getNextTarEntry();
continue;
}
final Path destination = destinationPath.resolve(relativePath);
final Path parent = destination.getParent();
if (Files.exists(parent) == false) {
Files.createDirectories(parent);
}
if (entry.isDirectory()) {
Files.createDirectory(destination);
} else if (entry.isSymbolicLink()) {
Files.createSymbolicLink(destination, Paths.get(entry.getLinkName()));
} else {
// copy the file from the archive using a small buffer to avoid heaping
Files.createFile(destination);
try (FileOutputStream fos = new FileOutputStream(destination.toFile())) {
tar.transferTo(fos);
}
}
if (entry.isSymbolicLink() == false) {
// check if the underlying file system supports POSIX permissions
final PosixFileAttributeView view = Files.getFileAttributeView(destination, PosixFileAttributeView.class);
if (view != null) {
final Set<PosixFilePermission> permissions = PosixFilePermissions.fromString(
permissions((entry.getMode() >> 6) & 07) +
permissions((entry.getMode() >> 3) & 07) +
permissions((entry.getMode() >> 0) & 07));
Files.setPosixFilePermissions(destination, permissions);
}
}
entry = tar.getNextTarEntry();
}
} catch (final IOException e) {
throw new GradleException("unable to extract tar [" + tarFile.getAsFile().get().toPath() + "]", e);
}
}
private String permissions(final int permissions) {
if (permissions < 0 || permissions > 7) {
throw new IllegalArgumentException("permissions [" + permissions + "] out of range");
}
final StringBuilder sb = new StringBuilder(3);
if ((permissions & 4) == 4) {
sb.append('r');
} else {
sb.append('-');
}
if ((permissions & 2) == 2) {
sb.append('w');
} else {
sb.append('-');
}
if ((permissions & 1) == 1) {
sb.append('x');
} else {
sb.append('-');
}
return sb.toString();
}
}

View File

@ -0,0 +1,32 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you 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.
*/
package org.elasticsearch.gradle.tar;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
public class SymoblicLinkPreservingTarPlugin implements Plugin<Project> {
@Override
public void apply(final Project target) {
}
}

View File

@ -599,8 +599,11 @@ public class ElasticsearchNode implements TestClusterConfiguration {
})
.collect(Collectors.joining(" "));
}
defaultEnv.put("ES_JAVA_OPTS", "-Xms512m -Xmx512m -ea -esa" +
systemPropertiesString + jvmArgsString
defaultEnv.put("ES_JAVA_OPTS", "-Xms512m -Xmx512m -ea -esa " +
systemPropertiesString + " " +
jvmArgsString + " " +
// Support passing in additional JVM arguments
System.getProperty("tests.jvm.argline", "")
);
defaultEnv.put("ES_TMPDIR", tmpDir.toString());
// Windows requires this as it defaults to `c:\windows` despite ES_TMPDIR

View File

@ -20,6 +20,7 @@ package org.elasticsearch.gradle.tool;
import org.gradle.api.Action;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.PolymorphicDomainObjectContainer;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.UnknownTaskException;
@ -52,6 +53,16 @@ public abstract class Boilerplate {
}
public static <T> T maybeCreate(PolymorphicDomainObjectContainer<T> collection, String name, Class<T> type, Action<T> action) {
return Optional.ofNullable(collection.findByName(name))
.orElseGet(() -> {
T result = collection.create(name, type);
action.execute(result);
return result;
});
}
public static <T extends Task> TaskProvider<T> maybeRegister(TaskContainer tasks, String name, Class<T> clazz, Action<T> action) {
try {
return tasks.named(name, clazz);

View File

@ -0,0 +1 @@
implementation-class=org.elasticsearch.gradle.tar.SymoblicLinkPreservingTarPlugin

View File

@ -1 +1 @@
5.5
5.6.2

View File

@ -23,6 +23,10 @@ public class VersionProperties {
return bundledJdk;
}
public static String getBundledJdkVendor() {
return bundledJdkVendor;
}
public static Map<String, String> getVersions() {
return versions;
}
@ -30,12 +34,14 @@ public class VersionProperties {
private static final String elasticsearch;
private static final String lucene;
private static final String bundledJdk;
private static final String bundledJdkVendor;
private static final Map<String, String> versions = new HashMap<String, String>();
static {
Properties props = getVersionProperties();
elasticsearch = props.getProperty("elasticsearch");
lucene = props.getProperty("lucene");
bundledJdkVendor = props.getProperty("bundled_jdk_vendor");
bundledJdk = props.getProperty("bundled_jdk");
for (String property : props.stringPropertyNames()) {

View File

@ -0,0 +1,59 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you 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.
*/
package org.elasticsearch.gradle;
import java.io.IOException;
import java.io.InputStream;
public class AdoptOpenJdkDownloadPluginIT extends JdkDownloadPluginIT {
@Override
public String oldJdkVersion() {
return "1+99";
}
@Override
public String jdkVersion() {
return "12.0.2+10";
}
@Override
public String jdkVendor() {
return "adoptopenjdk";
}
@Override
protected String urlPath(final boolean isOld, final String platform, final String extension) {
final String module = platform.equals("osx") ? "mac" : platform;
if (isOld) {
return "/adoptopenjdk/OpenJDK1U-jdk_x64_" + module + "_hotspot_1_99." + extension;
} else {
return "/adoptopenjdk/OpenJDK12U-jdk_x64_" + module + "_hotspot_12.0.2_10." + extension;
}
}
@Override
protected byte[] filebytes(final String platform, final String extension) throws IOException {
try (InputStream stream = JdkDownloadPluginIT.class.getResourceAsStream("fake_adoptopenjdk_" + platform + "." + extension)) {
return stream.readAllBytes();
}
}
}

View File

@ -25,7 +25,6 @@ import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.GradleRunner;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@ -39,74 +38,79 @@ import static com.github.tomakehurst.wiremock.client.WireMock.head;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.hamcrest.CoreMatchers.equalTo;
public class JdkDownloadPluginIT extends GradleIntegrationTestCase {
public abstract class JdkDownloadPluginIT extends GradleIntegrationTestCase {
private static final String OLD_JDK_VERSION = "1+99";
private static final String JDK_VERSION = "12.0.1+99@123456789123456789123456789abcde";
private static final Pattern JDK_HOME_LOGLINE = Pattern.compile("JDK HOME: (.*)");
private static final Pattern NUM_CONFIGS_LOGLINE = Pattern.compile("NUM CONFIGS: (.*)");
public void testLinuxExtraction() throws IOException {
assertExtraction("getLinuxJdk", "linux", "bin/java", JDK_VERSION);
protected abstract String oldJdkVersion();
protected abstract String jdkVersion();
protected abstract String jdkVendor();
public final void testLinuxExtraction() throws IOException {
assertExtraction("getLinuxJdk", "linux", "bin/java", jdkVendor(), jdkVersion());
}
public void testDarwinExtraction() throws IOException {
assertExtraction("getDarwinJdk", "osx", "Contents/Home/bin/java", JDK_VERSION);
public final void testDarwinExtraction() throws IOException {
assertExtraction("getDarwinJdk", "osx", "Contents/Home/bin/java", jdkVendor(), jdkVersion());
}
public void testWindowsExtraction() throws IOException {
assertExtraction("getWindowsJdk", "windows", "bin/java", JDK_VERSION);
public final void testWindowsExtraction() throws IOException {
assertExtraction("getWindowsJdk", "windows", "bin/java", jdkVendor(), jdkVersion());
}
public void testLinuxExtractionOldVersion() throws IOException {
assertExtraction("getLinuxJdk", "linux", "bin/java", OLD_JDK_VERSION);
public final void testLinuxExtractionOldVersion() throws IOException {
assertExtraction("getLinuxJdk", "linux", "bin/java", jdkVendor(), oldJdkVersion());
}
public void testDarwinExtractionOldVersion() throws IOException {
assertExtraction("getDarwinJdk", "osx", "Contents/Home/bin/java", OLD_JDK_VERSION);
public final void testDarwinExtractionOldVersion() throws IOException {
assertExtraction("getDarwinJdk", "osx", "Contents/Home/bin/java", jdkVendor(), oldJdkVersion());
}
public void testWindowsExtractionOldVersion() throws IOException {
assertExtraction("getWindowsJdk", "windows", "bin/java", OLD_JDK_VERSION);
public final void testWindowsExtractionOldVersion() throws IOException {
assertExtraction("getWindowsJdk", "windows", "bin/java", jdkVendor(), oldJdkVersion());
}
public void testCrossProjectReuse() throws IOException {
public final void testCrossProjectReuse() throws IOException {
runBuild("numConfigurations", "linux", result -> {
Matcher matcher = NUM_CONFIGS_LOGLINE.matcher(result.getOutput());
assertTrue("could not find num configs in output: " + result.getOutput(), matcher.find());
assertThat(Integer.parseInt(matcher.group(1)), equalTo(6)); // 3 import configs, 3 export configs
}, JDK_VERSION);
}, jdkVendor(), jdkVersion());
}
public void assertExtraction(String taskname, String platform, String javaBin, String version) throws IOException {
private void assertExtraction(String taskname, String platform, String javaBin, String vendor, String version) throws IOException {
runBuild(taskname, platform, result -> {
Matcher matcher = JDK_HOME_LOGLINE.matcher(result.getOutput());
assertTrue("could not find jdk home in output: " + result.getOutput(), matcher.find());
String jdkHome = matcher.group(1);
Path javaPath = Paths.get(jdkHome, javaBin);
assertTrue(javaPath.toString(), Files.exists(javaPath));
}, version);
}, vendor, version);
}
private void runBuild(String taskname, String platform, Consumer<BuildResult> assertions, String version) throws IOException {
protected abstract String urlPath(boolean isOld, String platform, String extension);
protected abstract byte[] filebytes(String platform, String extension) throws IOException;
private void runBuild(
String taskname, String platform, Consumer<BuildResult> assertions, String vendor, String version) throws IOException {
WireMockServer wireMock = new WireMockServer(0);
try {
String extension = platform.equals("windows") ? "zip" : "tar.gz";
boolean isOld = version.equals(OLD_JDK_VERSION);
String filename = "openjdk-" + (isOld ? "1" : "12.0.1") + "_" + platform + "-x64_bin." + extension;
final byte[] filebytes;
try (InputStream stream = JdkDownloadPluginIT.class.getResourceAsStream("fake_openjdk_" + platform + "." + extension)) {
filebytes = stream.readAllBytes();
}
String versionPath = isOld ? "jdk1/99" : "jdk12.0.1/123456789123456789123456789abcde/99";
String urlPath = "/java/GA/" + versionPath + "/GPL/" + filename;
wireMock.stubFor(head(urlEqualTo(urlPath)).willReturn(aResponse().withStatus(200)));
wireMock.stubFor(get(urlEqualTo(urlPath)).willReturn(aResponse().withStatus(200).withBody(filebytes)));
boolean isOld = version.equals(oldJdkVersion());
wireMock.stubFor(head(urlEqualTo(urlPath(isOld, platform, extension))).willReturn(aResponse().withStatus(200)));
wireMock.stubFor(get(urlEqualTo(urlPath(isOld, platform, extension)))
.willReturn(aResponse().withStatus(200).withBody(filebytes(platform, extension))));
wireMock.start();
GradleRunner runner = GradleRunner.create().withProjectDir(getProjectDir("jdk-download"))
.withArguments(taskname,
"-Dlocal.repo.path=" + getLocalTestRepoPath(),
"-Dtests.jdk_vendor=" + vendor,
"-Dtests.jdk_version=" + version,
"-Dtests.jdk_repo=" + wireMock.baseUrl(),
"-i")

View File

@ -35,32 +35,50 @@ public class JdkDownloadPluginTests extends GradleUnitTestCase {
rootProject = ProjectBuilder.builder().build();
}
public void testMissingVendor() {
assertJdkError(createProject(), "testjdk", null, "11.0.2+33", "linux", "vendor not specified for jdk [testjdk]");
}
public void testUnknownVendor() {
assertJdkError(
createProject(),
"testjdk",
"unknown",
"11.0.2+33",
"linux",
"unknown vendor [unknown] for jdk [testjdk], must be one of [adoptopenjdk, openjdk]");
}
public void testMissingVersion() {
assertJdkError(createProject(), "testjdk", null, "linux", "version not specified for jdk [testjdk]");
}
public void testMissingPlatform() {
assertJdkError(createProject(), "testjdk", "11.0.2+33", null, "platform not specified for jdk [testjdk]");
}
public void testUnknownPlatform() {
assertJdkError(createProject(), "testjdk", "11.0.2+33", "unknown",
"unknown platform [unknown] for jdk [testjdk], must be one of [linux, windows, darwin]");
assertJdkError(createProject(), "testjdk", "openjdk", null, "linux", "version not specified for jdk [testjdk]");
}
public void testBadVersionFormat() {
assertJdkError(createProject(), "testjdk", "badversion", "linux", "malformed version [badversion] for jdk [testjdk]");
assertJdkError(createProject(), "testjdk", "openjdk", "badversion", "linux", "malformed version [badversion] for jdk [testjdk]");
}
private void assertJdkError(Project project, String name, String version, String platform, String message) {
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> createJdk(project, name, version, platform));
public void testMissingPlatform() {
assertJdkError(createProject(), "testjdk", "openjdk", "11.0.2+33", null, "platform not specified for jdk [testjdk]");
}
public void testUnknownPlatform() {
assertJdkError(createProject(), "testjdk", "openjdk", "11.0.2+33", "unknown",
"unknown platform [unknown] for jdk [testjdk], must be one of [darwin, linux, windows]");
}
private void assertJdkError(Project project, String name, String vendor, String version, String platform, String message) {
IllegalArgumentException e =
expectThrows(IllegalArgumentException.class, () -> createJdk(project, name, vendor, version, platform));
assertThat(e.getMessage(), equalTo(message));
}
private void createJdk(Project project, String name, String version, String platform) {
private void createJdk(Project project, String name, String vendor, String version, String platform) {
@SuppressWarnings("unchecked")
NamedDomainObjectContainer<Jdk> jdks = (NamedDomainObjectContainer<Jdk>) project.getExtensions().getByName("jdks");
jdks.create(name, jdk -> {
if (vendor != null) {
jdk.setVendor(vendor);
}
if (version != null) {
jdk.setVersion(version);
}

View File

@ -0,0 +1,56 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you 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.
*/
package org.elasticsearch.gradle;
import java.io.IOException;
import java.io.InputStream;
public class OpenJdkDownloadPluginIT extends JdkDownloadPluginIT {
@Override
public String oldJdkVersion() {
return "1+99";
}
@Override
public String jdkVersion() {
return "12.0.1+99@123456789123456789123456789abcde";
}
@Override
protected String jdkVendor() {
return "openjdk";
}
@Override
protected String urlPath(final boolean isOld, final String platform, final String extension) {
final String versionPath = isOld ? "jdk1/99" : "jdk12.0.1/123456789123456789123456789abcde/99";
final String filename = "openjdk-" + (isOld ? "1" : "12.0.1") + "_" + platform + "-x64_bin." + extension;
return "/java/GA/" + versionPath + "/GPL/" + filename;
}
@Override
protected byte[] filebytes(final String platform, final String extension) throws IOException {
try (InputStream stream = JdkDownloadPluginIT.class.getResourceAsStream("fake_openjdk_" + platform + "." + extension)) {
return stream.readAllBytes();
}
}
}

View File

@ -0,0 +1,157 @@
package org.elasticsearch.gradle.tar;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.elasticsearch.gradle.test.GradleIntegrationTestCase;
import org.gradle.api.GradleException;
import org.gradle.testkit.runner.GradleRunner;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.equalTo;
public class SymbolicLinkPreservingTarIT extends GradleIntegrationTestCase {
@Rule
public final TemporaryFolder temporaryFolder = new TemporaryFolder();
@Before
public void before() throws IOException {
final Path realFolder = temporaryFolder.getRoot().toPath().resolve("real-folder");
Files.createDirectory(realFolder);
Files.createFile(realFolder.resolve("file"));
Files.createSymbolicLink(realFolder.resolve("link-to-file"), Paths.get("./file"));
final Path linkInFolder = temporaryFolder.getRoot().toPath().resolve("link-in-folder");
Files.createDirectory(linkInFolder);
Files.createSymbolicLink(linkInFolder.resolve("link-to-file"), Paths.get("../real-folder/file"));
final Path linkToRealFolder = temporaryFolder.getRoot().toPath().resolve("link-to-real-folder");
Files.createSymbolicLink(linkToRealFolder, Paths.get("./real-folder"));
}
public void testBZip2Tar() throws IOException {
runBuild("buildBZip2Tar", true);
assertTar(".bz2", BZip2CompressorInputStream::new, true);
}
public void testBZip2TarDoNotPreserveFileTimestamps() throws IOException {
runBuild("buildBZip2Tar", false);
assertTar(".bz2", BZip2CompressorInputStream::new, false);
}
public void testGZipTar() throws IOException {
runBuild("buildGZipTar", true);
assertTar(".gz", GzipCompressorInputStream::new, true);
}
public void testGZipTarDoNotPreserveFileTimestamps() throws IOException {
runBuild("buildGZipTar", false);
assertTar(".gz", GzipCompressorInputStream::new, false);
}
public void testTar() throws IOException {
runBuild("buildTar", true);
assertTar("", fis -> fis, true);
}
public void testTarDoNotPreserveFileTimestamps() throws IOException {
runBuild("buildTar", false);
assertTar("", fis -> fis, false);
}
interface FileInputStreamWrapper {
InputStream apply(FileInputStream fis) throws IOException;
}
private void assertTar(
final String extension, final FileInputStreamWrapper wrapper, boolean preserveFileTimestamps) throws IOException {
try (TarArchiveInputStream tar = new TarArchiveInputStream(wrapper.apply(new FileInputStream(getOutputFile(extension))))) {
TarArchiveEntry entry = tar.getNextTarEntry();
boolean realFolderEntry = false;
boolean fileEntry = false;
boolean linkToFileEntry = false;
boolean linkInFolderEntry = false;
boolean linkInFolderLinkToFileEntry = false;
boolean linkToRealFolderEntry = false;
while (entry != null) {
if (entry.getName().equals("real-folder/")) {
assertTrue(entry.isDirectory());
realFolderEntry = true;
} else if (entry.getName().equals("real-folder/file")) {
assertTrue(entry.isFile());
fileEntry = true;
} else if (entry.getName().equals("real-folder/link-to-file")) {
assertTrue(entry.isSymbolicLink());
assertThat(
entry.getLinkName(),
anyOf(equalTo("./file"), equalTo(".\\file"))
);
linkToFileEntry = true;
} else if (entry.getName().equals("link-in-folder/")) {
assertTrue(entry.isDirectory());
linkInFolderEntry = true;
} else if (entry.getName().equals("link-in-folder/link-to-file")) {
assertTrue(entry.isSymbolicLink());
assertThat(
entry.getLinkName(),
anyOf(equalTo("../real-folder/file"), equalTo("..\\real-folder\\file"))
);
linkInFolderLinkToFileEntry = true;
} else if (entry.getName().equals("link-to-real-folder")) {
assertTrue(entry.isSymbolicLink());
assertThat(
entry.getLinkName(),
anyOf(equalTo("./real-folder"), equalTo(".\\real-folder"))
);
linkToRealFolderEntry = true;
} else {
throw new GradleException("unexpected entry [" + entry.getName() + "]");
}
if (preserveFileTimestamps) {
assertTrue(entry.getModTime().getTime() > 0);
} else {
assertThat(entry.getModTime().getTime(), equalTo(0L));
}
entry = tar.getNextTarEntry();
}
assertTrue(realFolderEntry);
assertTrue(fileEntry);
assertTrue(linkToFileEntry);
assertTrue(linkInFolderEntry);
assertTrue(linkInFolderLinkToFileEntry);
assertTrue(linkToRealFolderEntry);
}
}
private void runBuild(final String task, final boolean preserveFileTimestamps) {
final GradleRunner runner = GradleRunner.create().withProjectDir(getProjectDir())
.withArguments(
task,
"-Dtests.symbolic_link_preserving_tar_source=" + temporaryFolder.getRoot().toString(),
"-Dtests.symbolic_link_preserving_tar_preserve_file_timestamps=" + preserveFileTimestamps,
"-i")
.withPluginClasspath();
runner.build();
}
private File getProjectDir() {
return getProjectDir("symbolic-link-preserving-tar");
}
private File getOutputFile(final String extension) {
return getProjectDir().toPath().resolve("build/distributions/symbolic-link-preserving-tar.tar" + extension).toFile();
}
}

View File

@ -2,9 +2,11 @@
project.gradle.projectsEvaluated {
// wire the jdk repo to wiremock
String fakeJdkRepo = Objects.requireNonNull(System.getProperty('tests.jdk_repo'))
String fakeJdkVendor = Objects.requireNonNull(System.getProperty('tests.jdk_vendor'))
String fakeJdkVersion = Objects.requireNonNull(System.getProperty('tests.jdk_version'))
println rootProject.repositories.asMap.keySet()
IvyArtifactRepository repository = (IvyArtifactRepository) rootProject.repositories.getByName("jdk_repo_${fakeJdkVersion}")
IvyArtifactRepository repository =
(IvyArtifactRepository) rootProject.repositories.getByName("jdk_repo_${fakeJdkVendor}_${fakeJdkVersion}")
repository.setUrl(fakeJdkRepo)
}

View File

@ -1,8 +1,10 @@
evaluationDependsOn ':subproj'
String fakeJdkVendor = Objects.requireNonNull(System.getProperty('tests.jdk_vendor'))
String fakeJdkVersion = Objects.requireNonNull(System.getProperty('tests.jdk_version'))
jdks {
linux_jdk {
vendor = fakeJdkVendor
version = fakeJdkVersion
platform = "linux"
}

View File

@ -3,17 +3,21 @@ plugins {
}
String fakeJdkVendor = Objects.requireNonNull(System.getProperty('tests.jdk_vendor'))
String fakeJdkVersion = Objects.requireNonNull(System.getProperty('tests.jdk_version'))
jdks {
linux {
vendor = fakeJdkVendor
version = fakeJdkVersion
platform = "linux"
}
darwin {
vendor = fakeJdkVendor
version = fakeJdkVersion
platform = "darwin"
}
windows {
vendor = fakeJdkVendor
version = fakeJdkVersion
platform = "windows"
}

View File

@ -0,0 +1,53 @@
import org.elasticsearch.gradle.tar.SymbolicLinkPreservingTar
plugins {
id 'base'
id 'distribution'
id 'elasticsearch.symbolic-link-preserving-tar'
}
final String source = Objects.requireNonNull(System.getProperty('tests.symbolic_link_preserving_tar_source'))
boolean preserveFileTimestamps;
final String testPreserveFileTimestamps =
Objects.requireNonNull(System.getProperty('tests.symbolic_link_preserving_tar_preserve_file_timestamps'))
switch (testPreserveFileTimestamps) {
case "true":
preserveFileTimestamps = true
break
case "false":
preserveFileTimestamps = false
break
default:
throw new IllegalArgumentException(
"tests.symbolic_link_preserving_tar_preserve_file_timestamps must be [true] or [false] but was ["
+ testPreserveFileTimestamps + "]")
}
task buildBZip2Tar(type: SymbolicLinkPreservingTar) { SymbolicLinkPreservingTar tar ->
tar.archiveExtension = 'tar.bz2'
tar.compression = Compression.BZIP2
tar.preserveFileTimestamps = preserveFileTimestamps
from fileTree(source)
doLast {
println archiveFile.get().asFile.path
}
}
task buildGZipTar(type: SymbolicLinkPreservingTar) { SymbolicLinkPreservingTar tar ->
tar.archiveExtension = 'tar.gz'
tar.compression = Compression.GZIP
tar.preserveFileTimestamps = preserveFileTimestamps
from fileTree(source)
doLast{
println archiveFile.get().asFile.path
}
}
task buildTar(type: SymbolicLinkPreservingTar) { SymbolicLinkPreservingTar tar ->
tar.archiveExtension = 'tar'
tar.preserveFileTimestamps = preserveFileTimestamps
from fileTree(source)
doLast{
println archiveFile.get().asFile.path
}
}

View File

@ -1,7 +1,8 @@
elasticsearch = 7.5.0
lucene = 8.2.0
bundled_jdk = 12.0.2+10@e482c34c86bd4bf8b56c0b35558996b9
bundled_jdk_vendor = adoptopenjdk
bundled_jdk = 13+33
# optional dependencies
spatial4j = 0.7
@ -32,8 +33,8 @@ bouncycastle = 1.61
# test dependencies
randomizedrunner = 2.7.1
junit = 4.12
httpclient = 4.5.8
httpcore = 4.4.11
httpclient = 4.5.10
httpcore = 4.4.12
httpasyncclient = 4.1.4
commonslogging = 1.1.3
commonscodec = 1.11

View File

@ -85,15 +85,15 @@ public final class CcrClient {
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html">
* the docs</a> for more.
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putFollowAsync(PutFollowRequest request,
public Cancellable putFollowAsync(PutFollowRequest request,
RequestOptions options,
ActionListener<PutFollowResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
CcrRequestConverters::putFollow,
options,
@ -129,15 +129,15 @@ public final class CcrClient {
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-follow.html">
* the docs</a> for more.
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void pauseFollowAsync(PauseFollowRequest request,
public Cancellable pauseFollowAsync(PauseFollowRequest request,
RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
CcrRequestConverters::pauseFollow,
options,
@ -172,15 +172,15 @@ public final class CcrClient {
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-resume-follow.html">
* the docs</a> for more.
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void resumeFollowAsync(ResumeFollowRequest request,
public Cancellable resumeFollowAsync(ResumeFollowRequest request,
RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
CcrRequestConverters::resumeFollow,
options,
@ -217,15 +217,15 @@ public final class CcrClient {
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-unfollow.html">
* the docs</a> for more.
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void unfollowAsync(UnfollowRequest request,
public Cancellable unfollowAsync(UnfollowRequest request,
RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
CcrRequestConverters::unfollow,
options,
@ -260,15 +260,15 @@ public final class CcrClient {
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-forget-follower.html">the docs</a> for more details
* on the intended usage of this API.
*
* @param request the request
* @param options the request options (e.g., headers), use {@link RequestOptions#DEFAULT} if the defaults are acceptable.
* @return cancellable that may be used to cancel the request
*/
public void forgetFollowerAsync(
public Cancellable forgetFollowerAsync(
final ForgetFollowerRequest request,
final RequestOptions options,
final ActionListener<BroadcastResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
CcrRequestConverters::forgetFollower,
options,
@ -303,15 +303,15 @@ public final class CcrClient {
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html">
* the docs</a> for more.
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putAutoFollowPatternAsync(PutAutoFollowPatternRequest request,
public Cancellable putAutoFollowPatternAsync(PutAutoFollowPatternRequest request,
RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
CcrRequestConverters::putAutoFollowPattern,
options,
@ -347,15 +347,15 @@ public final class CcrClient {
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html">
* the docs</a> for more.
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteAutoFollowPatternAsync(DeleteAutoFollowPatternRequest request,
public Cancellable deleteAutoFollowPatternAsync(DeleteAutoFollowPatternRequest request,
RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
CcrRequestConverters::deleteAutoFollowPattern,
options,
@ -392,15 +392,15 @@ public final class CcrClient {
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html">
* the docs</a> for more.
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getAutoFollowPatternAsync(GetAutoFollowPatternRequest request,
public Cancellable getAutoFollowPatternAsync(GetAutoFollowPatternRequest request,
RequestOptions options,
ActionListener<GetAutoFollowPatternResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
CcrRequestConverters::getAutoFollowPattern,
options,
@ -437,14 +437,14 @@ public final class CcrClient {
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html">
* the docs</a> for more.
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return cancellable that may be used to cancel the request
*/
public void getCcrStatsAsync(CcrStatsRequest request,
public Cancellable getCcrStatsAsync(CcrStatsRequest request,
RequestOptions options,
ActionListener<CcrStatsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
CcrRequestConverters::getCcrStats,
options,
@ -481,14 +481,14 @@ public final class CcrClient {
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html">
* the docs</a> for more.
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return cancellable that may be used to cancel the request
*/
public void getFollowStatsAsync(FollowStatsRequest request,
public Cancellable getFollowStatsAsync(FollowStatsRequest request,
RequestOptions options,
ActionListener<FollowStatsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
CcrRequestConverters::getFollowStats,
options,
@ -524,14 +524,14 @@ public final class CcrClient {
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html">
* the docs</a> for more.
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return cancellable that may be used to cancel the request
*/
public void getFollowInfoAsync(FollowInfoRequest request,
public Cancellable getFollowInfoAsync(FollowInfoRequest request,
RequestOptions options,
ActionListener<FollowInfoResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
CcrRequestConverters::getFollowInfo,
options,

View File

@ -67,10 +67,12 @@ public final class ClusterClient {
* @param clusterUpdateSettingsRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putSettingsAsync(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, RequestOptions options,
public Cancellable putSettingsAsync(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, RequestOptions options,
ActionListener<ClusterUpdateSettingsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(clusterUpdateSettingsRequest, ClusterRequestConverters::clusterPutSettings,
return restHighLevelClient.performRequestAsyncAndParseEntity(clusterUpdateSettingsRequest,
ClusterRequestConverters::clusterPutSettings,
options, ClusterUpdateSettingsResponse::fromXContent, listener, emptySet());
}
@ -96,10 +98,12 @@ public final class ClusterClient {
* @param clusterGetSettingsRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getSettingsAsync(ClusterGetSettingsRequest clusterGetSettingsRequest, RequestOptions options,
public Cancellable getSettingsAsync(ClusterGetSettingsRequest clusterGetSettingsRequest, RequestOptions options,
ActionListener<ClusterGetSettingsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(clusterGetSettingsRequest, ClusterRequestConverters::clusterGetSettings,
return restHighLevelClient.performRequestAsyncAndParseEntity(
clusterGetSettingsRequest, ClusterRequestConverters::clusterGetSettings,
options, ClusterGetSettingsResponse::fromXContent, listener, emptySet());
}
@ -127,9 +131,11 @@ public final class ClusterClient {
* @param healthRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void healthAsync(ClusterHealthRequest healthRequest, RequestOptions options, ActionListener<ClusterHealthResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(healthRequest, ClusterRequestConverters::clusterHealth, options,
public Cancellable healthAsync(ClusterHealthRequest healthRequest, RequestOptions options,
ActionListener<ClusterHealthResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(healthRequest, ClusterRequestConverters::clusterHealth, options,
ClusterHealthResponse::fromXContent, listener, singleton(RestStatus.REQUEST_TIMEOUT.getStatus()));
}
}

View File

@ -21,20 +21,20 @@ package org.elasticsearch.client;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.client.core.AcknowledgedResponse;
import org.elasticsearch.client.dataframe.DeleteDataFrameTransformRequest;
import org.elasticsearch.client.dataframe.GetDataFrameTransformRequest;
import org.elasticsearch.client.dataframe.GetDataFrameTransformResponse;
import org.elasticsearch.client.dataframe.GetDataFrameTransformStatsRequest;
import org.elasticsearch.client.dataframe.GetDataFrameTransformStatsResponse;
import org.elasticsearch.client.dataframe.PreviewDataFrameTransformRequest;
import org.elasticsearch.client.dataframe.PreviewDataFrameTransformResponse;
import org.elasticsearch.client.dataframe.PutDataFrameTransformRequest;
import org.elasticsearch.client.dataframe.StartDataFrameTransformRequest;
import org.elasticsearch.client.dataframe.StartDataFrameTransformResponse;
import org.elasticsearch.client.dataframe.StopDataFrameTransformRequest;
import org.elasticsearch.client.dataframe.StopDataFrameTransformResponse;
import org.elasticsearch.client.dataframe.UpdateDataFrameTransformRequest;
import org.elasticsearch.client.dataframe.UpdateDataFrameTransformResponse;
import org.elasticsearch.client.transform.DeleteDataFrameTransformRequest;
import org.elasticsearch.client.transform.GetDataFrameTransformRequest;
import org.elasticsearch.client.transform.GetDataFrameTransformResponse;
import org.elasticsearch.client.transform.GetDataFrameTransformStatsRequest;
import org.elasticsearch.client.transform.GetDataFrameTransformStatsResponse;
import org.elasticsearch.client.transform.PreviewDataFrameTransformRequest;
import org.elasticsearch.client.transform.PreviewDataFrameTransformResponse;
import org.elasticsearch.client.transform.PutDataFrameTransformRequest;
import org.elasticsearch.client.transform.StartDataFrameTransformRequest;
import org.elasticsearch.client.transform.StartDataFrameTransformResponse;
import org.elasticsearch.client.transform.StopDataFrameTransformRequest;
import org.elasticsearch.client.transform.StopDataFrameTransformResponse;
import org.elasticsearch.client.transform.UpdateDataFrameTransformRequest;
import org.elasticsearch.client.transform.UpdateDataFrameTransformResponse;
import java.io.IOException;
import java.util.Collections;
@ -48,14 +48,14 @@ public final class DataFrameClient {
}
/**
* Creates a new Data Frame Transform
* Creates a new transform
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/put-data-frame-transform.html">
* Create data frame transform documentation</a>
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/put-transform.html">
* Create transform documentation</a>
*
* @param request The PutDataFrameTransformRequest containing the
* {@link org.elasticsearch.client.dataframe.transforms.DataFrameTransformConfig}.
* {@link org.elasticsearch.client.transform.transforms.DataFrameTransformConfig}.
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return An AcknowledgedResponse object indicating request success
* @throws IOException when there is a serialization issue sending the request or receiving the response
@ -69,20 +69,20 @@ public final class DataFrameClient {
}
/**
* Creates a new Data Frame Transform asynchronously and notifies listener on completion
* Creates a new transform asynchronously and notifies listener on completion
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/put-data-frame-transform.html">
* Create data frame transform documentation</a>
*
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/put-transform.html">
* Create transform documentation</a>
* @param request The PutDataFrameTransformRequest containing the
* {@link org.elasticsearch.client.dataframe.transforms.DataFrameTransformConfig}.
* {@link org.elasticsearch.client.transform.transforms.DataFrameTransformConfig}.
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putDataFrameTransformAsync(PutDataFrameTransformRequest request, RequestOptions options,
public Cancellable putDataFrameTransformAsync(PutDataFrameTransformRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
DataFrameRequestConverters::putDataFrameTransform,
options,
AcknowledgedResponse::fromXContent,
@ -91,14 +91,14 @@ public final class DataFrameClient {
}
/**
* Updates an existing Data Frame Transform
* Updates an existing transform
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/update-data-frame-transform.html">
* Create data frame transform documentation</a>
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/update-transform.html">
* Create transform documentation</a>
*
* @param request The UpdateDataFrameTransformRequest containing the
* {@link org.elasticsearch.client.dataframe.transforms.DataFrameTransformConfigUpdate}.
* {@link org.elasticsearch.client.transform.transforms.DataFrameTransformConfigUpdate}.
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return An UpdateDataFrameTransformResponse object containing the updated configuration
* @throws IOException when there is a serialization issue sending the request or receiving the response
@ -113,21 +113,21 @@ public final class DataFrameClient {
}
/**
* Updates an existing Data Frame Transform asynchronously and notifies listener on completion
* Updates an existing transform asynchronously and notifies listener on completion
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/update-data-frame-transform.html">
* Create data frame transform documentation</a>
*
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/update-transform.html">
* Create transform documentation</a>
* @param request The UpdateDataFrameTransformRequest containing the
* {@link org.elasticsearch.client.dataframe.transforms.DataFrameTransformConfigUpdate}.
* {@link org.elasticsearch.client.transform.transforms.DataFrameTransformConfigUpdate}.
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void updateDataFrameTransformAsync(UpdateDataFrameTransformRequest request,
public Cancellable updateDataFrameTransformAsync(UpdateDataFrameTransformRequest request,
RequestOptions options,
ActionListener<UpdateDataFrameTransformResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
DataFrameRequestConverters::updateDataFrameTransform,
options,
UpdateDataFrameTransformResponse::fromXContent,
@ -136,15 +136,15 @@ public final class DataFrameClient {
}
/**
* Get the running statistics of a Data Frame Transform
* Get the running statistics of a transform
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-data-frame-transform-stats.html">
* Get data frame transform stats documentation</a>
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-stats.html">
* Get transform stats documentation</a>
*
* @param request Specifies the which transforms to get the stats for
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return The Data Frame Transform stats
* @return The transform stats
* @throws IOException when there is a serialization issue sending the request or receiving the response
*/
public GetDataFrameTransformStatsResponse getDataFrameTransformStats(GetDataFrameTransformStatsRequest request, RequestOptions options)
@ -157,19 +157,19 @@ public final class DataFrameClient {
}
/**
* Get the running statistics of a Data Frame Transform asynchronously and notifies listener on completion
* Get the running statistics of a transform asynchronously and notifies listener on completion
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-data-frame-transform-stats.html">
* Get data frame transform stats documentation</a>
*
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-stats.html">
* Get transform stats documentation</a>
* @param request Specifies the which transforms to get the stats for
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getDataFrameTransformStatsAsync(GetDataFrameTransformStatsRequest request, RequestOptions options,
public Cancellable getDataFrameTransformStatsAsync(GetDataFrameTransformStatsRequest request, RequestOptions options,
ActionListener<GetDataFrameTransformStatsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
DataFrameRequestConverters::getDataFrameTransformStats,
options,
GetDataFrameTransformStatsResponse::fromXContent,
@ -178,13 +178,13 @@ public final class DataFrameClient {
}
/**
* Delete a data frame transform
* Delete a transform
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-data-frame-transform.html">
* Delete data frame transform documentation</a>
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-transform.html">
* Delete transform documentation</a>
*
* @param request The delete data frame transform request
* @param request The delete transform request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return An AcknowledgedResponse object indicating request success
* @throws IOException when there is a serialization issue sending the request or receiving the response
@ -199,19 +199,19 @@ public final class DataFrameClient {
}
/**
* Delete a data frame transform asynchronously and notifies listener on completion
* Delete a transform asynchronously and notifies listener on completion
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-data-frame-transform.html">
* Delete data frame transform documentation</a>
*
* @param request The delete data frame transform request
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-transform.html">
* Delete transform documentation</a>
* @param request The delete transform request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteDataFrameTransformAsync(DeleteDataFrameTransformRequest request, RequestOptions options,
public Cancellable deleteDataFrameTransformAsync(DeleteDataFrameTransformRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
DataFrameRequestConverters::deleteDataFrameTransform,
options,
AcknowledgedResponse::fromXContent,
@ -220,13 +220,13 @@ public final class DataFrameClient {
}
/**
* Preview the result of a data frame transform
* Preview the result of a transform
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-data-frame-transform.html">
* Preview data frame transform documentation</a>
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-transform.html">
* Preview transform documentation</a>
*
* @param request The preview data frame transform request
* @param request The preview transform request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return A response containing the results of the applied transform
* @throws IOException when there is a serialization issue sending the request or receiving the response
@ -241,18 +241,18 @@ public final class DataFrameClient {
}
/**
* Preview the result of a data frame transform asynchronously and notifies listener on completion
* Preview the result of a transform asynchronously and notifies listener on completion
* <p>
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-data-frame-transform.html">
* Preview data frame transform documentation</a>
*
* @param request The preview data frame transform request
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-transform.html">
* Preview transform documentation</a>
* @param request The preview transform request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void previewDataFrameTransformAsync(PreviewDataFrameTransformRequest request, RequestOptions options,
public Cancellable previewDataFrameTransformAsync(PreviewDataFrameTransformRequest request, RequestOptions options,
ActionListener<PreviewDataFrameTransformResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
DataFrameRequestConverters::previewDataFrameTransform,
options,
PreviewDataFrameTransformResponse::fromXContent,
@ -261,13 +261,13 @@ public final class DataFrameClient {
}
/**
* Start a data frame transform
* Start a transform
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/start-data-frame-transform.html">
* Start data frame transform documentation</a>
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/start-transform.html">
* Start transform documentation</a>
*
* @param request The start data frame transform request
* @param request The start transform request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return A response object indicating request success
* @throws IOException when there is a serialization issue sending the request or receiving the response
@ -282,19 +282,19 @@ public final class DataFrameClient {
}
/**
* Start a data frame transform asynchronously and notifies listener on completion
* Start a transform asynchronously and notifies listener on completion
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/start-data-frame-transform.html">
* Start data frame transform documentation</a>
*
* @param request The start data frame transform request
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/start-transform.html">
* Start transform documentation</a>
* @param request The start transform request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void startDataFrameTransformAsync(StartDataFrameTransformRequest request, RequestOptions options,
public Cancellable startDataFrameTransformAsync(StartDataFrameTransformRequest request, RequestOptions options,
ActionListener<StartDataFrameTransformResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
DataFrameRequestConverters::startDataFrameTransform,
options,
StartDataFrameTransformResponse::fromXContent,
@ -303,13 +303,13 @@ public final class DataFrameClient {
}
/**
* Stop a data frame transform
* Stop a transform
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-data-frame-transform.html">
* Stop data frame transform documentation</a>
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-transform.html">
* Stop transform documentation</a>
*
* @param request The stop data frame transform request
* @param request The stop transform request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return A response object indicating request success
* @throws IOException when there is a serialization issue sending the request or receiving the response
@ -324,19 +324,19 @@ public final class DataFrameClient {
}
/**
* Stop a data frame transform asynchronously and notifies listener on completion
* Stop a transform asynchronously and notifies listener on completion
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-data-frame-transform.html">
* Stop data frame transform documentation</a>
*
* @param request The stop data frame transform request
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-transform.html">
* Stop transform documentation</a>
* @param request The stop transform request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void stopDataFrameTransformAsync(StopDataFrameTransformRequest request, RequestOptions options,
public Cancellable stopDataFrameTransformAsync(StopDataFrameTransformRequest request, RequestOptions options,
ActionListener<StopDataFrameTransformResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
DataFrameRequestConverters::stopDataFrameTransform,
options,
StopDataFrameTransformResponse::fromXContent,
@ -345,13 +345,13 @@ public final class DataFrameClient {
}
/**
* Get one or more data frame transform configurations
* Get one or more transform configurations
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-data-frame-transform.html">
* Get data frame transform documentation</a>
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform.html">
* Get transform documentation</a>
*
* @param request The get data frame transform request
* @param request The get transform request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return An GetDataFrameTransformResponse containing the requested transforms
* @throws IOException when there is a serialization issue sending the request or receiving the response
@ -366,19 +366,19 @@ public final class DataFrameClient {
}
/**
* Get one or more data frame transform configurations asynchronously and notifies listener on completion
* Get one or more transform configurations asynchronously and notifies listener on completion
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-data-frame-transform.html">
* Get data frame transform documentation</a>
*
* @param request The get data frame transform request
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform.html">
* Get data transform documentation</a>
* @param request The get transform request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getDataFrameTransformAsync(GetDataFrameTransformRequest request, RequestOptions options,
public Cancellable getDataFrameTransformAsync(GetDataFrameTransformRequest request, RequestOptions options,
ActionListener<GetDataFrameTransformResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
DataFrameRequestConverters::getDataFrameTransform,
options,
GetDataFrameTransformResponse::fromXContent,

View File

@ -24,23 +24,23 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.elasticsearch.client.core.PageParams;
import org.elasticsearch.client.dataframe.DeleteDataFrameTransformRequest;
import org.elasticsearch.client.dataframe.GetDataFrameTransformRequest;
import org.elasticsearch.client.dataframe.GetDataFrameTransformStatsRequest;
import org.elasticsearch.client.dataframe.PreviewDataFrameTransformRequest;
import org.elasticsearch.client.dataframe.PutDataFrameTransformRequest;
import org.elasticsearch.client.dataframe.StartDataFrameTransformRequest;
import org.elasticsearch.client.dataframe.StopDataFrameTransformRequest;
import org.elasticsearch.client.dataframe.UpdateDataFrameTransformRequest;
import org.elasticsearch.client.transform.DeleteDataFrameTransformRequest;
import org.elasticsearch.client.transform.GetDataFrameTransformRequest;
import org.elasticsearch.client.transform.GetDataFrameTransformStatsRequest;
import org.elasticsearch.client.transform.PreviewDataFrameTransformRequest;
import org.elasticsearch.client.transform.PutDataFrameTransformRequest;
import org.elasticsearch.client.transform.StartDataFrameTransformRequest;
import org.elasticsearch.client.transform.StopDataFrameTransformRequest;
import org.elasticsearch.client.transform.UpdateDataFrameTransformRequest;
import org.elasticsearch.common.Strings;
import java.io.IOException;
import static org.elasticsearch.client.RequestConverters.REQUEST_BODY_CONTENT_TYPE;
import static org.elasticsearch.client.RequestConverters.createEntity;
import static org.elasticsearch.client.dataframe.DeleteDataFrameTransformRequest.FORCE;
import static org.elasticsearch.client.dataframe.GetDataFrameTransformRequest.ALLOW_NO_MATCH;
import static org.elasticsearch.client.dataframe.PutDataFrameTransformRequest.DEFER_VALIDATION;
import static org.elasticsearch.client.transform.DeleteDataFrameTransformRequest.FORCE;
import static org.elasticsearch.client.transform.GetDataFrameTransformRequest.ALLOW_NO_MATCH;
import static org.elasticsearch.client.transform.PutDataFrameTransformRequest.DEFER_VALIDATION;
final class DataFrameRequestConverters {

View File

@ -52,11 +52,12 @@ public class GraphClient {
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html">Graph API
* on elastic.co</a>.
* @return cancellable that may be used to cancel the request
*/
public final void exploreAsync(GraphExploreRequest graphExploreRequest,
public final Cancellable exploreAsync(GraphExploreRequest graphExploreRequest,
RequestOptions options,
ActionListener<GraphExploreResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(graphExploreRequest, GraphRequestConverters::explore,
return restHighLevelClient.performRequestAsyncAndParseEntity(graphExploreRequest, GraphRequestConverters::explore,
options, GraphExploreResponse::fromXContent, listener, emptySet());
}

View File

@ -39,6 +39,8 @@ import org.elasticsearch.client.slm.ExecuteSnapshotLifecyclePolicyRequest;
import org.elasticsearch.client.slm.ExecuteSnapshotLifecyclePolicyResponse;
import org.elasticsearch.client.slm.GetSnapshotLifecyclePolicyRequest;
import org.elasticsearch.client.slm.GetSnapshotLifecyclePolicyResponse;
import org.elasticsearch.client.slm.GetSnapshotLifecycleStatsRequest;
import org.elasticsearch.client.slm.GetSnapshotLifecycleStatsResponse;
import org.elasticsearch.client.slm.PutSnapshotLifecyclePolicyRequest;
import java.io.IOException;
@ -74,10 +76,11 @@ public class IndexLifecycleClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getLifecyclePolicyAsync(GetLifecyclePolicyRequest request, RequestOptions options,
public Cancellable getLifecyclePolicyAsync(GetLifecyclePolicyRequest request, RequestOptions options,
ActionListener<GetLifecyclePolicyResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::getLifecyclePolicy, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::getLifecyclePolicy, options,
GetLifecyclePolicyResponse::fromXContent, listener, emptySet());
}
@ -103,10 +106,11 @@ public class IndexLifecycleClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putLifecyclePolicyAsync(PutLifecyclePolicyRequest request, RequestOptions options,
public Cancellable putLifecyclePolicyAsync(PutLifecyclePolicyRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::putLifecyclePolicy, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::putLifecyclePolicy, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -132,10 +136,12 @@ public class IndexLifecycleClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteLifecyclePolicyAsync(DeleteLifecyclePolicyRequest request, RequestOptions options,
public Cancellable deleteLifecyclePolicyAsync(DeleteLifecyclePolicyRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::deleteLifecyclePolicy, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(
request, IndexLifecycleRequestConverters::deleteLifecyclePolicy, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -161,10 +167,12 @@ public class IndexLifecycleClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void removeIndexLifecyclePolicyAsync(RemoveIndexLifecyclePolicyRequest request, RequestOptions options,
public Cancellable removeIndexLifecyclePolicyAsync(RemoveIndexLifecyclePolicyRequest request, RequestOptions options,
ActionListener<RemoveIndexLifecyclePolicyResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::removeIndexLifecyclePolicy, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(
request, IndexLifecycleRequestConverters::removeIndexLifecyclePolicy, options,
RemoveIndexLifecyclePolicyResponse::fromXContent, listener, emptySet());
}
@ -189,9 +197,10 @@ public class IndexLifecycleClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void startILMAsync(StartILMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::startILM, options,
public Cancellable startILMAsync(StartILMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::startILM, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -227,14 +236,15 @@ public class IndexLifecycleClient {
* Asynchronously get the status of index lifecycle management
* See <a href="https://fix-me-when-we-have-docs.com">
* the docs</a> for more.
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void lifecycleManagementStatusAsync(LifecycleManagementStatusRequest request, RequestOptions options,
public Cancellable lifecycleManagementStatusAsync(LifecycleManagementStatusRequest request, RequestOptions options,
ActionListener<LifecycleManagementStatusResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::lifecycleManagementStatus, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(
request, IndexLifecycleRequestConverters::lifecycleManagementStatus, options,
LifecycleManagementStatusResponse::fromXContent, listener, emptySet());
}
@ -245,9 +255,10 @@ public class IndexLifecycleClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void stopILMAsync(StopILMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::stopILM, options,
public Cancellable stopILMAsync(StopILMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::stopILM, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -272,10 +283,11 @@ public class IndexLifecycleClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void explainLifecycleAsync(ExplainLifecycleRequest request, RequestOptions options,
public Cancellable explainLifecycleAsync(ExplainLifecycleRequest request, RequestOptions options,
ActionListener<ExplainLifecycleResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::explainLifecycle, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::explainLifecycle, options,
ExplainLifecycleResponse::fromXContent, listener, emptySet());
}
@ -300,10 +312,11 @@ public class IndexLifecycleClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void retryLifecyclePolicyAsync(RetryLifecyclePolicyRequest request, RequestOptions options,
public Cancellable retryLifecyclePolicyAsync(RetryLifecyclePolicyRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::retryLifecycle, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::retryLifecycle, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -335,10 +348,11 @@ public class IndexLifecycleClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getSnapshotLifecyclePolicyAsync(GetSnapshotLifecyclePolicyRequest request, RequestOptions options,
public Cancellable getSnapshotLifecyclePolicyAsync(GetSnapshotLifecyclePolicyRequest request, RequestOptions options,
ActionListener<GetSnapshotLifecyclePolicyResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::getSnapshotLifecyclePolicy,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::getSnapshotLifecyclePolicy,
options, GetSnapshotLifecyclePolicyResponse::fromXContent, listener, emptySet());
}
@ -370,10 +384,11 @@ public class IndexLifecycleClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putSnapshotLifecyclePolicyAsync(PutSnapshotLifecyclePolicyRequest request, RequestOptions options,
public Cancellable putSnapshotLifecyclePolicyAsync(PutSnapshotLifecyclePolicyRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::putSnapshotLifecyclePolicy,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::putSnapshotLifecyclePolicy,
options, AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -405,10 +420,12 @@ public class IndexLifecycleClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteSnapshotLifecyclePolicyAsync(DeleteSnapshotLifecyclePolicyRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::deleteSnapshotLifecyclePolicy,
public Cancellable deleteSnapshotLifecyclePolicyAsync(DeleteSnapshotLifecyclePolicyRequest request,
RequestOptions options,ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(
request, IndexLifecycleRequestConverters::deleteSnapshotLifecyclePolicy,
options, AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -440,10 +457,48 @@ public class IndexLifecycleClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void executeSnapshotLifecyclePolicyAsync(ExecuteSnapshotLifecyclePolicyRequest request, RequestOptions options,
public Cancellable executeSnapshotLifecyclePolicyAsync(
ExecuteSnapshotLifecyclePolicyRequest request, RequestOptions options,
ActionListener<ExecuteSnapshotLifecyclePolicyResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::executeSnapshotLifecyclePolicy,
return restHighLevelClient.performRequestAsyncAndParseEntity(
request, IndexLifecycleRequestConverters::executeSnapshotLifecyclePolicy,
options, ExecuteSnapshotLifecyclePolicyResponse::fromXContent, listener, emptySet());
}
/**
* Retrieve snapshot lifecycle statistics.
* See <pre>
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
* java-rest-high-ilm-slm-get-snapshot-lifecycle-stats.html
* </pre>
* for more.
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public GetSnapshotLifecycleStatsResponse getSnapshotLifecycleStats(GetSnapshotLifecycleStatsRequest request,
RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::getSnapshotLifecycleStats,
options, GetSnapshotLifecycleStatsResponse::fromXContent, emptySet());
}
/**
* Asynchronously retrieve snapshot lifecycle statistics.
* See <pre>
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
* java-rest-high-ilm-slm-get-snapshot-lifecycle-stats.html
* </pre>
* for more.
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
*/
public Cancellable getSnapshotLifecycleStatsAsync(GetSnapshotLifecycleStatsRequest request, RequestOptions options,
ActionListener<GetSnapshotLifecycleStatsResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::getSnapshotLifecycleStats,
options, GetSnapshotLifecycleStatsResponse::fromXContent, listener, emptySet());
}
}

View File

@ -35,6 +35,7 @@ import org.elasticsearch.client.indexlifecycle.StopILMRequest;
import org.elasticsearch.client.slm.DeleteSnapshotLifecyclePolicyRequest;
import org.elasticsearch.client.slm.ExecuteSnapshotLifecyclePolicyRequest;
import org.elasticsearch.client.slm.GetSnapshotLifecyclePolicyRequest;
import org.elasticsearch.client.slm.GetSnapshotLifecycleStatsRequest;
import org.elasticsearch.client.slm.PutSnapshotLifecyclePolicyRequest;
import org.elasticsearch.common.Strings;
@ -215,4 +216,14 @@ final class IndexLifecycleRequestConverters {
request.addParameters(params.asMap());
return request;
}
static Request getSnapshotLifecycleStats(GetSnapshotLifecycleStatsRequest getSnapshotLifecycleStatsRequest) {
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_slm/stats").build();
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
RequestConverters.Params params = new RequestConverters.Params();
params.withMasterTimeout(getSnapshotLifecycleStatsRequest.masterNodeTimeout());
params.withTimeout(getSnapshotLifecycleStatsRequest.timeout());
request.addParameters(params.asMap());
return request;
}
}

View File

@ -108,9 +108,12 @@ public final class IndicesClient {
* @param deleteIndexRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteAsync(DeleteIndexRequest deleteIndexRequest, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(deleteIndexRequest, IndicesRequestConverters::deleteIndex, options,
public Cancellable deleteAsync(DeleteIndexRequest deleteIndexRequest, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(deleteIndexRequest,
IndicesRequestConverters::deleteIndex, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -136,11 +139,12 @@ public final class IndicesClient {
* @param createIndexRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void createAsync(CreateIndexRequest createIndexRequest,
public Cancellable createAsync(CreateIndexRequest createIndexRequest,
RequestOptions options,
ActionListener<CreateIndexResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(createIndexRequest, IndicesRequestConverters::createIndex, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(createIndexRequest, IndicesRequestConverters::createIndex, options,
CreateIndexResponse::fromXContent, listener, emptySet());
}
@ -177,12 +181,13 @@ public final class IndicesClient {
* @deprecated This method uses an old request object which still refers to types, a deprecated feature. The
* method {@link #createAsync(CreateIndexRequest, RequestOptions, ActionListener)} should be used instead,
* which accepts a new request object.
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public void createAsync(org.elasticsearch.action.admin.indices.create.CreateIndexRequest createIndexRequest,
public Cancellable createAsync(org.elasticsearch.action.admin.indices.create.CreateIndexRequest createIndexRequest,
RequestOptions options,
ActionListener<org.elasticsearch.action.admin.indices.create.CreateIndexResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(createIndexRequest,
return restHighLevelClient.performRequestAsyncAndParseEntity(createIndexRequest,
IndicesRequestConverters::createIndex, options,
org.elasticsearch.action.admin.indices.create.CreateIndexResponse::fromXContent, listener, emptySet());
}
@ -208,10 +213,11 @@ public final class IndicesClient {
* @param putMappingRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putMappingAsync(PutMappingRequest putMappingRequest, RequestOptions options,
public Cancellable putMappingAsync(PutMappingRequest putMappingRequest, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(putMappingRequest, IndicesRequestConverters::putMapping, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(putMappingRequest, IndicesRequestConverters::putMapping, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -245,12 +251,13 @@ public final class IndicesClient {
* @deprecated This method uses an old request object which still refers to types, a deprecated feature. The
* method {@link #putMappingAsync(PutMappingRequest, RequestOptions, ActionListener)} should be used instead,
* which accepts a new request object.
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public void putMappingAsync(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest,
public Cancellable putMappingAsync(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest,
RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(putMappingRequest, IndicesRequestConverters::putMapping, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(putMappingRequest, IndicesRequestConverters::putMapping, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -278,10 +285,11 @@ public final class IndicesClient {
* @param getMappingsRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getMappingAsync(GetMappingsRequest getMappingsRequest, RequestOptions options,
public Cancellable getMappingAsync(GetMappingsRequest getMappingsRequest, RequestOptions options,
ActionListener<GetMappingsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(getMappingsRequest,
return restHighLevelClient.performRequestAsyncAndParseEntity(getMappingsRequest,
IndicesRequestConverters::getMappings,
options,
GetMappingsResponse::fromXContent,
@ -324,12 +332,13 @@ public final class IndicesClient {
* @deprecated This method uses old request and response objects which still refer to types, a deprecated feature.
* The method {@link #getMapping(GetMappingsRequest, RequestOptions)} should be used instead, which accepts a new
* request object.
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public void getMappingAsync(org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest getMappingsRequest,
public Cancellable getMappingAsync(org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest getMappingsRequest,
RequestOptions options,
ActionListener<org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(getMappingsRequest,
return restHighLevelClient.performRequestAsyncAndParseEntity(getMappingsRequest,
IndicesRequestConverters::getMappings,
options,
org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse::fromXContent,
@ -369,13 +378,17 @@ public final class IndicesClient {
* @deprecated This method uses old request and response objects which still refer to types, a deprecated feature.
* The method {@link #getFieldMappingAsync(GetFieldMappingsRequest, RequestOptions, ActionListener)} should be
* used instead, which accepts a new request object.
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public void getFieldMappingAsync(org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest getFieldMappingsRequest,
public Cancellable getFieldMappingAsync(
org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest getFieldMappingsRequest,
RequestOptions options,
ActionListener<org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(getFieldMappingsRequest, IndicesRequestConverters::getFieldMapping, options,
org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse::fromXContent, listener, emptySet());
return restHighLevelClient.performRequestAsyncAndParseEntity(getFieldMappingsRequest,
IndicesRequestConverters::getFieldMapping, options,
org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse::fromXContent,
listener, emptySet());
}
/**
@ -401,10 +414,12 @@ public final class IndicesClient {
* @param getFieldMappingsRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getFieldMappingAsync(GetFieldMappingsRequest getFieldMappingsRequest,
public Cancellable getFieldMappingAsync(GetFieldMappingsRequest getFieldMappingsRequest,
RequestOptions options, ActionListener<GetFieldMappingsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(getFieldMappingsRequest, IndicesRequestConverters::getFieldMapping, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(
getFieldMappingsRequest, IndicesRequestConverters::getFieldMapping, options,
GetFieldMappingsResponse::fromXContent, listener, emptySet());
}
@ -429,10 +444,12 @@ public final class IndicesClient {
* @param indicesAliasesRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void updateAliasesAsync(IndicesAliasesRequest indicesAliasesRequest, RequestOptions options,
public Cancellable updateAliasesAsync(IndicesAliasesRequest indicesAliasesRequest, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(indicesAliasesRequest, IndicesRequestConverters::updateAliases, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(indicesAliasesRequest,
IndicesRequestConverters::updateAliases, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -457,9 +474,10 @@ public final class IndicesClient {
* @param openIndexRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void openAsync(OpenIndexRequest openIndexRequest, RequestOptions options, ActionListener<OpenIndexResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(openIndexRequest, IndicesRequestConverters::openIndex, options,
public Cancellable openAsync(OpenIndexRequest openIndexRequest, RequestOptions options, ActionListener<OpenIndexResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(openIndexRequest, IndicesRequestConverters::openIndex, options,
OpenIndexResponse::fromXContent, listener, emptySet());
}
@ -484,9 +502,12 @@ public final class IndicesClient {
* @param closeIndexRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void closeAsync(CloseIndexRequest closeIndexRequest, RequestOptions options, ActionListener<CloseIndexResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(closeIndexRequest, IndicesRequestConverters::closeIndex, options,
public Cancellable closeAsync(CloseIndexRequest closeIndexRequest, RequestOptions options,
ActionListener<CloseIndexResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(closeIndexRequest,
IndicesRequestConverters::closeIndex, options,
CloseIndexResponse::fromXContent, listener, emptySet());
}
@ -512,9 +533,10 @@ public final class IndicesClient {
* @param getAliasesRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void existsAliasAsync(GetAliasesRequest getAliasesRequest, RequestOptions options, ActionListener<Boolean> listener) {
restHighLevelClient.performRequestAsync(getAliasesRequest, IndicesRequestConverters::existsAlias, options,
public Cancellable existsAliasAsync(GetAliasesRequest getAliasesRequest, RequestOptions options, ActionListener<Boolean> listener) {
return restHighLevelClient.performRequestAsync(getAliasesRequest, IndicesRequestConverters::existsAlias, options,
RestHighLevelClient::convertExistsResponse, listener, emptySet());
}
@ -537,9 +559,10 @@ public final class IndicesClient {
* @param refreshRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void refreshAsync(RefreshRequest refreshRequest, RequestOptions options, ActionListener<RefreshResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(refreshRequest, IndicesRequestConverters::refresh, options,
public Cancellable refreshAsync(RefreshRequest refreshRequest, RequestOptions options, ActionListener<RefreshResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(refreshRequest, IndicesRequestConverters::refresh, options,
RefreshResponse::fromXContent, listener, emptySet());
}
@ -562,15 +585,16 @@ public final class IndicesClient {
* @param flushRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void flushAsync(FlushRequest flushRequest, RequestOptions options, ActionListener<FlushResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(flushRequest, IndicesRequestConverters::flush, options,
public Cancellable flushAsync(FlushRequest flushRequest, RequestOptions options, ActionListener<FlushResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(flushRequest, IndicesRequestConverters::flush, options,
FlushResponse::fromXContent, listener, emptySet());
}
/**
* Initiate a synced flush manually using the synced flush API.
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html#synced-flush-api">
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush-api.html">
* Synced flush API on elastic.co</a>
* @param syncedFlushRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
@ -584,15 +608,16 @@ public final class IndicesClient {
/**
* Asynchronously initiate a synced flush manually using the synced flush API.
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html#synced-flush-api">
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush-api.html">
* Synced flush API on elastic.co</a>
* @param syncedFlushRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void flushSyncedAsync(SyncedFlushRequest syncedFlushRequest, RequestOptions options,
public Cancellable flushSyncedAsync(SyncedFlushRequest syncedFlushRequest, RequestOptions options,
ActionListener<SyncedFlushResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(syncedFlushRequest, IndicesRequestConverters::flushSynced, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(syncedFlushRequest, IndicesRequestConverters::flushSynced, options,
SyncedFlushResponse::fromXContent, listener, emptySet());
}
@ -617,10 +642,11 @@ public final class IndicesClient {
* @param getSettingsRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getSettingsAsync(GetSettingsRequest getSettingsRequest, RequestOptions options,
public Cancellable getSettingsAsync(GetSettingsRequest getSettingsRequest, RequestOptions options,
ActionListener<GetSettingsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(getSettingsRequest, IndicesRequestConverters::getSettings, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(getSettingsRequest, IndicesRequestConverters::getSettings, options,
GetSettingsResponse::fromXContent, listener, emptySet());
}
@ -645,10 +671,11 @@ public final class IndicesClient {
* @param getIndexRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getAsync(GetIndexRequest getIndexRequest, RequestOptions options,
public Cancellable getAsync(GetIndexRequest getIndexRequest, RequestOptions options,
ActionListener<GetIndexResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(getIndexRequest, IndicesRequestConverters::getIndex, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(getIndexRequest, IndicesRequestConverters::getIndex, options,
GetIndexResponse::fromXContent, listener, emptySet());
}
@ -679,11 +706,12 @@ public final class IndicesClient {
* @param listener the listener to be notified upon request completion
* @deprecated This method uses an old request object which still refers to types, a deprecated feature. The method
* {@link #getAsync(GetIndexRequest, RequestOptions, ActionListener)} should be used instead, which accepts a new request object.
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public void getAsync(org.elasticsearch.action.admin.indices.get.GetIndexRequest getIndexRequest, RequestOptions options,
public Cancellable getAsync(org.elasticsearch.action.admin.indices.get.GetIndexRequest getIndexRequest, RequestOptions options,
ActionListener<org.elasticsearch.action.admin.indices.get.GetIndexResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(getIndexRequest, IndicesRequestConverters::getIndex, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(getIndexRequest, IndicesRequestConverters::getIndex, options,
org.elasticsearch.action.admin.indices.get.GetIndexResponse::fromXContent, listener, emptySet());
}
@ -724,10 +752,12 @@ public final class IndicesClient {
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @deprecated use {@link #forcemergeAsync(ForceMergeRequest, RequestOptions, ActionListener)} instead
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public void forceMergeAsync(ForceMergeRequest forceMergeRequest, RequestOptions options, ActionListener<ForceMergeResponse> listener) {
forcemergeAsync(forceMergeRequest, options, listener);
public Cancellable forceMergeAsync(ForceMergeRequest forceMergeRequest, RequestOptions options,
ActionListener<ForceMergeResponse> listener) {
return forcemergeAsync(forceMergeRequest, options, listener);
}
/**
@ -737,9 +767,12 @@ public final class IndicesClient {
* @param forceMergeRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void forcemergeAsync(ForceMergeRequest forceMergeRequest, RequestOptions options, ActionListener<ForceMergeResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(forceMergeRequest, IndicesRequestConverters::forceMerge, options,
public Cancellable forcemergeAsync(ForceMergeRequest forceMergeRequest, RequestOptions options,
ActionListener<ForceMergeResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(forceMergeRequest,
IndicesRequestConverters::forceMerge, options,
ForceMergeResponse::fromXContent, listener, emptySet());
}
@ -765,10 +798,12 @@ public final class IndicesClient {
* @param clearIndicesCacheRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void clearCacheAsync(ClearIndicesCacheRequest clearIndicesCacheRequest, RequestOptions options,
public Cancellable clearCacheAsync(ClearIndicesCacheRequest clearIndicesCacheRequest, RequestOptions options,
ActionListener<ClearIndicesCacheResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(clearIndicesCacheRequest, IndicesRequestConverters::clearCache, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(clearIndicesCacheRequest,
IndicesRequestConverters::clearCache, options,
ClearIndicesCacheResponse::fromXContent, listener, emptySet());
}
@ -798,9 +833,10 @@ public final class IndicesClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void existsAsync(GetIndexRequest request, RequestOptions options, ActionListener<Boolean> listener) {
restHighLevelClient.performRequestAsync(
public Cancellable existsAsync(GetIndexRequest request, RequestOptions options, ActionListener<Boolean> listener) {
return restHighLevelClient.performRequestAsync(
request,
IndicesRequestConverters::indicesExist,
options,
@ -841,11 +877,12 @@ public final class IndicesClient {
* @param listener the listener to be notified upon request completion
* @deprecated This method uses an old request object which still refers to types, a deprecated feature. The method
* {@link #existsAsync(GetIndexRequest, RequestOptions, ActionListener)} should be used instead, which accepts a new request object.
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public void existsAsync(org.elasticsearch.action.admin.indices.get.GetIndexRequest request, RequestOptions options,
public Cancellable existsAsync(org.elasticsearch.action.admin.indices.get.GetIndexRequest request, RequestOptions options,
ActionListener<Boolean> listener) {
restHighLevelClient.performRequestAsync(
return restHighLevelClient.performRequestAsync(
request,
IndicesRequestConverters::indicesExist,
options,
@ -876,9 +913,10 @@ public final class IndicesClient {
* @param resizeRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void shrinkAsync(ResizeRequest resizeRequest, RequestOptions options, ActionListener<ResizeResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, IndicesRequestConverters::shrink, options,
public Cancellable shrinkAsync(ResizeRequest resizeRequest, RequestOptions options, ActionListener<ResizeResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, IndicesRequestConverters::shrink, options,
ResizeResponse::fromXContent, listener, emptySet());
}
@ -903,9 +941,10 @@ public final class IndicesClient {
* @param resizeRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void splitAsync(ResizeRequest resizeRequest, RequestOptions options, ActionListener<ResizeResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, IndicesRequestConverters::split, options,
public Cancellable splitAsync(ResizeRequest resizeRequest, RequestOptions options, ActionListener<ResizeResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, IndicesRequestConverters::split, options,
ResizeResponse::fromXContent, listener, emptySet());
}
@ -930,9 +969,10 @@ public final class IndicesClient {
* @param resizeRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void cloneAsync(ResizeRequest resizeRequest, RequestOptions options, ActionListener<ResizeResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, IndicesRequestConverters::clone, options,
public Cancellable cloneAsync(ResizeRequest resizeRequest, RequestOptions options, ActionListener<ResizeResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(resizeRequest, IndicesRequestConverters::clone, options,
ResizeResponse::fromXContent, listener, emptySet());
}
@ -957,9 +997,10 @@ public final class IndicesClient {
* @param rolloverRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void rolloverAsync(RolloverRequest rolloverRequest, RequestOptions options, ActionListener<RolloverResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(rolloverRequest, IndicesRequestConverters::rollover, options,
public Cancellable rolloverAsync(RolloverRequest rolloverRequest, RequestOptions options, ActionListener<RolloverResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(rolloverRequest, IndicesRequestConverters::rollover, options,
RolloverResponse::fromXContent, listener, emptySet());
}
@ -995,11 +1036,13 @@ public final class IndicesClient {
* @deprecated This method uses deprecated request and response objects.
* The method {@link #rolloverAsync(RolloverRequest, RequestOptions, ActionListener)} should be used instead, which
* accepts a new request object.
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public void rolloverAsync(org.elasticsearch.action.admin.indices.rollover.RolloverRequest rolloverRequest,
RequestOptions options, ActionListener<org.elasticsearch.action.admin.indices.rollover.RolloverResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(rolloverRequest, IndicesRequestConverters::rollover, options,
public Cancellable rolloverAsync(org.elasticsearch.action.admin.indices.rollover.RolloverRequest rolloverRequest,
RequestOptions options,
ActionListener<org.elasticsearch.action.admin.indices.rollover.RolloverResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(rolloverRequest, IndicesRequestConverters::rollover, options,
org.elasticsearch.action.admin.indices.rollover.RolloverResponse::fromXContent, listener, emptySet());
}
@ -1024,9 +1067,12 @@ public final class IndicesClient {
* @param getAliasesRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getAliasAsync(GetAliasesRequest getAliasesRequest, RequestOptions options, ActionListener<GetAliasesResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(getAliasesRequest, IndicesRequestConverters::getAlias, options,
public Cancellable getAliasAsync(GetAliasesRequest getAliasesRequest, RequestOptions options,
ActionListener<GetAliasesResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(getAliasesRequest,
IndicesRequestConverters::getAlias, options,
GetAliasesResponse::fromXContent, listener, singleton(RestStatus.NOT_FOUND.getStatus()));
}
@ -1051,10 +1097,12 @@ public final class IndicesClient {
* @param updateSettingsRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, RequestOptions options,
public Cancellable putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(updateSettingsRequest, IndicesRequestConverters::indexPutSettings, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(updateSettingsRequest,
IndicesRequestConverters::indexPutSettings, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -1088,11 +1136,14 @@ public final class IndicesClient {
* @deprecated This old form of request allows types in mappings.
* Use {@link #putTemplateAsync(PutIndexTemplateRequest, RequestOptions, ActionListener)}
* instead which introduces a new request object without types.
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public void putTemplateAsync(org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest putIndexTemplateRequest,
public Cancellable putTemplateAsync(
org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest putIndexTemplateRequest,
RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(putIndexTemplateRequest, IndicesRequestConverters::putTemplate, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(putIndexTemplateRequest,
IndicesRequestConverters::putTemplate, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -1120,10 +1171,12 @@ public final class IndicesClient {
* @param putIndexTemplateRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putTemplateAsync(PutIndexTemplateRequest putIndexTemplateRequest,
public Cancellable putTemplateAsync(PutIndexTemplateRequest putIndexTemplateRequest,
RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(putIndexTemplateRequest, IndicesRequestConverters::putTemplate, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(putIndexTemplateRequest,
IndicesRequestConverters::putTemplate, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -1137,8 +1190,10 @@ public final class IndicesClient {
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public ValidateQueryResponse validateQuery(ValidateQueryRequest validateQueryRequest, RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(validateQueryRequest, IndicesRequestConverters::validateQuery, options,
public ValidateQueryResponse validateQuery(ValidateQueryRequest validateQueryRequest,
RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(validateQueryRequest,
IndicesRequestConverters::validateQuery, options,
ValidateQueryResponse::fromXContent, emptySet());
}
@ -1150,10 +1205,12 @@ public final class IndicesClient {
* @param validateQueryRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void validateQueryAsync(ValidateQueryRequest validateQueryRequest, RequestOptions options,
public Cancellable validateQueryAsync(ValidateQueryRequest validateQueryRequest, RequestOptions options,
ActionListener<ValidateQueryResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(validateQueryRequest, IndicesRequestConverters::validateQuery, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(validateQueryRequest,
IndicesRequestConverters::validateQuery, options,
ValidateQueryResponse::fromXContent, listener, emptySet());
}
@ -1174,7 +1231,8 @@ public final class IndicesClient {
GetIndexTemplatesRequest getIndexTemplatesRequest, RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(getIndexTemplatesRequest,
IndicesRequestConverters::getTemplatesWithDocumentTypes,
options, org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse::fromXContent, emptySet());
options,
org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse::fromXContent, emptySet());
}
/**
@ -1186,8 +1244,8 @@ public final class IndicesClient {
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public GetIndexTemplatesResponse getIndexTemplate(GetIndexTemplatesRequest getIndexTemplatesRequest, RequestOptions options)
throws IOException {
public GetIndexTemplatesResponse getIndexTemplate(GetIndexTemplatesRequest getIndexTemplatesRequest,
RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(getIndexTemplatesRequest,
IndicesRequestConverters::getTemplates,
options, GetIndexTemplatesResponse::fromXContent, emptySet());
@ -1203,13 +1261,16 @@ public final class IndicesClient {
* @param listener the listener to be notified upon request completion
* @deprecated This method uses an old response object which still refers to types, a deprecated feature. Use
* {@link #getIndexTemplateAsync(GetIndexTemplatesRequest, RequestOptions, ActionListener)} instead which returns a new response object
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public void getTemplateAsync(GetIndexTemplatesRequest getIndexTemplatesRequest, RequestOptions options,
public Cancellable getTemplateAsync(GetIndexTemplatesRequest getIndexTemplatesRequest, RequestOptions options,
ActionListener<org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(getIndexTemplatesRequest,
return restHighLevelClient.performRequestAsyncAndParseEntity(getIndexTemplatesRequest,
IndicesRequestConverters::getTemplatesWithDocumentTypes,
options, org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse::fromXContent, listener, emptySet());
options,
org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse::fromXContent,
listener, emptySet());
}
/**
@ -1219,10 +1280,11 @@ public final class IndicesClient {
* @param getIndexTemplatesRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getIndexTemplateAsync(GetIndexTemplatesRequest getIndexTemplatesRequest, RequestOptions options,
public Cancellable getIndexTemplateAsync(GetIndexTemplatesRequest getIndexTemplatesRequest, RequestOptions options,
ActionListener<GetIndexTemplatesResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(getIndexTemplatesRequest,
return restHighLevelClient.performRequestAsyncAndParseEntity(getIndexTemplatesRequest,
IndicesRequestConverters::getTemplates,
options, GetIndexTemplatesResponse::fromXContent, listener, emptySet());
}
@ -1235,24 +1297,26 @@ public final class IndicesClient {
* @return true if any index templates in the request exist, false otherwise
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public boolean existsTemplate(IndexTemplatesExistRequest indexTemplatesRequest, RequestOptions options) throws IOException {
return restHighLevelClient.performRequest(indexTemplatesRequest, IndicesRequestConverters::templatesExist, options,
public boolean existsTemplate(IndexTemplatesExistRequest indexTemplatesRequest,
RequestOptions options) throws IOException {
return restHighLevelClient.performRequest(indexTemplatesRequest,
IndicesRequestConverters::templatesExist, options,
RestHighLevelClient::convertExistsResponse, emptySet());
}
/**
* Uses the Index Templates API to determine if index templates exist
*
* @param indexTemplatesExistRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion. The listener will be called with the value {@code true}
* if any index templates in the request exist, false otherwise
* @return cancellable that may be used to cancel the request
*/
public void existsTemplateAsync(IndexTemplatesExistRequest indexTemplatesExistRequest,
public Cancellable existsTemplateAsync(IndexTemplatesExistRequest indexTemplatesExistRequest,
RequestOptions options,
ActionListener<Boolean> listener) {
restHighLevelClient.performRequestAsync(indexTemplatesExistRequest, IndicesRequestConverters::templatesExist, options,
return restHighLevelClient.performRequestAsync(indexTemplatesExistRequest,
IndicesRequestConverters::templatesExist, options,
RestHighLevelClient::convertExistsResponse, listener, emptySet());
}
@ -1273,14 +1337,14 @@ public final class IndicesClient {
* Asynchronously calls the analyze API
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html">Analyze API on elastic.co</a>
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void analyzeAsync(AnalyzeRequest request, RequestOptions options,
public Cancellable analyzeAsync(AnalyzeRequest request, RequestOptions options,
ActionListener<AnalyzeResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::analyze, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::analyze, options,
AnalyzeResponse::fromXContent, listener, emptySet());
}
@ -1297,13 +1361,14 @@ public final class IndicesClient {
/**
* Asynchronously calls the _freeze API
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void freezeAsync(FreezeIndexRequest request, RequestOptions options, ActionListener<ShardsAcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::freezeIndex, options,
public Cancellable freezeAsync(FreezeIndexRequest request, RequestOptions options,
ActionListener<ShardsAcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::freezeIndex, options,
ShardsAcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -1320,13 +1385,15 @@ public final class IndicesClient {
/**
* Asynchronously calls the _unfreeze API
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void unfreezeAsync(UnfreezeIndexRequest request, RequestOptions options, ActionListener<ShardsAcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::unfreezeIndex, options,
public Cancellable unfreezeAsync(UnfreezeIndexRequest request, RequestOptions options,
ActionListener<ShardsAcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
IndicesRequestConverters::unfreezeIndex, options,
ShardsAcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -1348,14 +1415,14 @@ public final class IndicesClient {
* Asynchronously delete an index template using the Index Templates API
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html"> Index Templates API
* on elastic.co</a>
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteTemplateAsync(DeleteIndexTemplateRequest request, RequestOptions options,
public Cancellable deleteTemplateAsync(DeleteIndexTemplateRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::deleteTemplate,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::deleteTemplate,
options, AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -1372,14 +1439,14 @@ public final class IndicesClient {
/**
* Asynchronously calls the _reload_search_analyzers API
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void reloadAnalyzersAsync(ReloadAnalyzersRequest request, RequestOptions options,
public Cancellable reloadAnalyzersAsync(ReloadAnalyzersRequest request, RequestOptions options,
ActionListener<ReloadAnalyzersResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::reloadAnalyzers, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::reloadAnalyzers, options,
ReloadAnalyzersResponse::fromXContent, listener, emptySet());
}
}

View File

@ -67,9 +67,10 @@ public final class IngestClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putPipelineAsync(PutPipelineRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity( request, IngestRequestConverters::putPipeline, options,
public Cancellable putPipelineAsync(PutPipelineRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity( request, IngestRequestConverters::putPipeline, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -94,9 +95,10 @@ public final class IngestClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getPipelineAsync(GetPipelineRequest request, RequestOptions options, ActionListener<GetPipelineResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity( request, IngestRequestConverters::getPipeline, options,
public Cancellable getPipelineAsync(GetPipelineRequest request, RequestOptions options, ActionListener<GetPipelineResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity( request, IngestRequestConverters::getPipeline, options,
GetPipelineResponse::fromXContent, listener, Collections.singleton(404));
}
@ -123,9 +125,12 @@ public final class IngestClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deletePipelineAsync(DeletePipelineRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity( request, IngestRequestConverters::deletePipeline, options,
public Cancellable deletePipelineAsync(DeletePipelineRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity( request,
IngestRequestConverters::deletePipeline, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -154,11 +159,12 @@ public final class IngestClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void simulateAsync(SimulatePipelineRequest request,
public Cancellable simulateAsync(SimulatePipelineRequest request,
RequestOptions options,
ActionListener<SimulatePipelineResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity( request, IngestRequestConverters::simulatePipeline, options,
return restHighLevelClient.performRequestAsyncAndParseEntity( request, IngestRequestConverters::simulatePipeline, options,
SimulatePipelineResponse::fromXContent, listener, emptySet());
}
}

View File

@ -80,9 +80,10 @@ public final class LicenseClient {
* Asynchronously updates license for the cluster.
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putLicenseAsync(PutLicenseRequest request, RequestOptions options, ActionListener<PutLicenseResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, LicenseRequestConverters::putLicense, options,
public Cancellable putLicenseAsync(PutLicenseRequest request, RequestOptions options, ActionListener<PutLicenseResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, LicenseRequestConverters::putLicense, options,
PutLicenseResponse::fromXContent, listener, emptySet());
}
@ -101,9 +102,10 @@ public final class LicenseClient {
* Asynchronously returns the current license for the cluster cluster.
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getLicenseAsync(GetLicenseRequest request, RequestOptions options, ActionListener<GetLicenseResponse> listener) {
restHighLevelClient.performRequestAsync(request, LicenseRequestConverters::getLicense, options,
public Cancellable getLicenseAsync(GetLicenseRequest request, RequestOptions options, ActionListener<GetLicenseResponse> listener) {
return restHighLevelClient.performRequestAsync(request, LicenseRequestConverters::getLicense, options,
response -> new GetLicenseResponse(convertResponseToJson(response)), listener, emptySet());
}
@ -122,9 +124,12 @@ public final class LicenseClient {
* Asynchronously deletes license from the cluster.
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteLicenseAsync(DeleteLicenseRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, LicenseRequestConverters::deleteLicense, options,
public Cancellable deleteLicenseAsync(DeleteLicenseRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
LicenseRequestConverters::deleteLicense, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -143,12 +148,13 @@ public final class LicenseClient {
* Asynchronously starts a trial license on the cluster.
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void startTrialAsync(StartTrialRequest request,
public Cancellable startTrialAsync(StartTrialRequest request,
RequestOptions options,
ActionListener<StartTrialResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, LicenseRequestConverters::startTrial, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, LicenseRequestConverters::startTrial, options,
StartTrialResponse::fromXContent, listener, singleton(403));
}
@ -167,10 +173,11 @@ public final class LicenseClient {
* Asynchronously initiates an indefinite basic license.
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void startBasicAsync(StartBasicRequest request, RequestOptions options,
public Cancellable startBasicAsync(StartBasicRequest request, RequestOptions options,
ActionListener<StartBasicResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, LicenseRequestConverters::startBasic, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, LicenseRequestConverters::startBasic, options,
StartBasicResponse::fromXContent, listener, emptySet());
}

View File

@ -153,13 +153,13 @@ public final class MachineLearningClient {
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html">ML PUT job documentation</a>
*
* @param request The request containing the {@link org.elasticsearch.client.ml.job.config.Job} settings
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putJobAsync(PutJobRequest request, RequestOptions options, ActionListener<PutJobResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable putJobAsync(PutJobRequest request, RequestOptions options, ActionListener<PutJobResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::putJob,
options,
PutJobResponse::fromXContent,
@ -192,13 +192,13 @@ public final class MachineLearningClient {
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html">ML GET job documentation</a>
*
* @param request {@link GetJobRequest} Request containing a list of jobId(s) and additional options
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified with {@link GetJobResponse} upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getJobAsync(GetJobRequest request, RequestOptions options, ActionListener<GetJobResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable getJobAsync(GetJobRequest request, RequestOptions options, ActionListener<GetJobResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getJob,
options,
GetJobResponse::fromXContent,
@ -231,13 +231,13 @@ public final class MachineLearningClient {
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html">Get job stats docs</a>
*
* @param request {@link GetJobStatsRequest} Request containing a list of jobId(s) and additional options
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified with {@link GetJobStatsResponse} upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getJobStatsAsync(GetJobStatsRequest request, RequestOptions options, ActionListener<GetJobStatsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable getJobStatsAsync(GetJobStatsRequest request, RequestOptions options, ActionListener<GetJobStatsResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getJobStats,
options,
GetJobStatsResponse::fromXContent,
@ -272,14 +272,14 @@ public final class MachineLearningClient {
* For additional info
* see <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-expired-data.html">ML Delete Expired Data
* documentation</a>
*
* @param request The request to delete expired ML data
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteExpiredDataAsync(DeleteExpiredDataRequest request, RequestOptions options,
public Cancellable deleteExpiredDataAsync(DeleteExpiredDataRequest request, RequestOptions options,
ActionListener<DeleteExpiredDataResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::deleteExpiredData,
options,
DeleteExpiredDataResponse::fromXContent,
@ -316,9 +316,10 @@ public final class MachineLearningClient {
* @param request The request to delete the job
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteJobAsync(DeleteJobRequest request, RequestOptions options, ActionListener<DeleteJobResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable deleteJobAsync(DeleteJobRequest request, RequestOptions options, ActionListener<DeleteJobResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::deleteJob,
options,
DeleteJobResponse::fromXContent,
@ -360,9 +361,10 @@ public final class MachineLearningClient {
* @param request Request containing job_id and additional optional options
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void openJobAsync(OpenJobRequest request, RequestOptions options, ActionListener<OpenJobResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable openJobAsync(OpenJobRequest request, RequestOptions options, ActionListener<OpenJobResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::openJob,
options,
OpenJobResponse::fromXContent,
@ -400,9 +402,10 @@ public final class MachineLearningClient {
* @param request Request containing job_ids and additional options. See {@link CloseJobRequest}
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void closeJobAsync(CloseJobRequest request, RequestOptions options, ActionListener<CloseJobResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable closeJobAsync(CloseJobRequest request, RequestOptions options, ActionListener<CloseJobResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::closeJob,
options,
CloseJobResponse::fromXContent,
@ -449,9 +452,10 @@ public final class MachineLearningClient {
* @param request The {@link FlushJobRequest} object enclosing the `jobId` and additional request options
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void flushJobAsync(FlushJobRequest request, RequestOptions options, ActionListener<FlushJobResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable flushJobAsync(FlushJobRequest request, RequestOptions options, ActionListener<FlushJobResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::flushJob,
options,
FlushJobResponse::fromXContent,
@ -489,9 +493,10 @@ public final class MachineLearningClient {
* @param request ForecastJobRequest with forecasting options
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void forecastJobAsync(ForecastJobRequest request, RequestOptions options, ActionListener<ForecastJobResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable forecastJobAsync(ForecastJobRequest request, RequestOptions options, ActionListener<ForecastJobResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::forecastJob,
options,
ForecastJobResponse::fromXContent,
@ -529,9 +534,11 @@ public final class MachineLearningClient {
* @param request the {@link DeleteForecastRequest} object enclosing the desired jobId, forecastIDs, and other options
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteForecastAsync(DeleteForecastRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable deleteForecastAsync(DeleteForecastRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::deleteForecast,
options,
AcknowledgedResponse::fromXContent,
@ -569,10 +576,11 @@ public final class MachineLearningClient {
* @param request The request to delete the model snapshot
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteModelSnapshotAsync(DeleteModelSnapshotRequest request, RequestOptions options,
public Cancellable deleteModelSnapshotAsync(DeleteModelSnapshotRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::deleteModelSnapshot,
options,
AcknowledgedResponse::fromXContent,
@ -610,10 +618,11 @@ public final class MachineLearningClient {
* @param request The request to revert to a previous model snapshot
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void revertModelSnapshotAsync(RevertModelSnapshotRequest request, RequestOptions options,
public Cancellable revertModelSnapshotAsync(RevertModelSnapshotRequest request, RequestOptions options,
ActionListener<RevertModelSnapshotResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::revertModelSnapshot,
options,
RevertModelSnapshotResponse::fromXContent,
@ -649,9 +658,10 @@ public final class MachineLearningClient {
* @param request The request containing the {@link org.elasticsearch.client.ml.datafeed.DatafeedConfig} settings
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putDatafeedAsync(PutDatafeedRequest request, RequestOptions options, ActionListener<PutDatafeedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable putDatafeedAsync(PutDatafeedRequest request, RequestOptions options, ActionListener<PutDatafeedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::putDatafeed,
options,
PutDatafeedResponse::fromXContent,
@ -689,9 +699,11 @@ public final class MachineLearningClient {
* @param request The request containing the {@link org.elasticsearch.client.ml.datafeed.DatafeedUpdate} settings
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void updateDatafeedAsync(UpdateDatafeedRequest request, RequestOptions options, ActionListener<PutDatafeedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable updateDatafeedAsync(UpdateDatafeedRequest request, RequestOptions options,
ActionListener<PutDatafeedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::updateDatafeed,
options,
PutDatafeedResponse::fromXContent,
@ -730,9 +742,11 @@ public final class MachineLearningClient {
* @param request {@link GetDatafeedRequest} Request containing a list of datafeedId(s) and additional options
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified with {@link GetDatafeedResponse} upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getDatafeedAsync(GetDatafeedRequest request, RequestOptions options, ActionListener<GetDatafeedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable getDatafeedAsync(GetDatafeedRequest request, RequestOptions options,
ActionListener<GetDatafeedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getDatafeed,
options,
GetDatafeedResponse::fromXContent,
@ -770,9 +784,11 @@ public final class MachineLearningClient {
* @param request The request to delete the datafeed
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteDatafeedAsync(DeleteDatafeedRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable deleteDatafeedAsync(DeleteDatafeedRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::deleteDatafeed,
options,
AcknowledgedResponse::fromXContent,
@ -810,9 +826,11 @@ public final class MachineLearningClient {
* @param request The request to start the datafeed
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void startDatafeedAsync(StartDatafeedRequest request, RequestOptions options, ActionListener<StartDatafeedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable startDatafeedAsync(StartDatafeedRequest request, RequestOptions options,
ActionListener<StartDatafeedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::startDatafeed,
options,
StartDatafeedResponse::fromXContent,
@ -850,9 +868,11 @@ public final class MachineLearningClient {
* @param request The request to stop the datafeed
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void stopDatafeedAsync(StopDatafeedRequest request, RequestOptions options, ActionListener<StopDatafeedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable stopDatafeedAsync(StopDatafeedRequest request, RequestOptions options,
ActionListener<StopDatafeedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::stopDatafeed,
options,
StopDatafeedResponse::fromXContent,
@ -910,11 +930,12 @@ public final class MachineLearningClient {
* @param request {@link GetDatafeedStatsRequest} Request containing a list of datafeedId(s) and additional options
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified with {@link GetDatafeedStatsResponse} upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getDatafeedStatsAsync(GetDatafeedStatsRequest request,
public Cancellable getDatafeedStatsAsync(GetDatafeedStatsRequest request,
RequestOptions options,
ActionListener<GetDatafeedStatsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getDatafeedStats,
options,
GetDatafeedStatsResponse::fromXContent,
@ -932,11 +953,12 @@ public final class MachineLearningClient {
* @param request The request to preview the datafeed
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void previewDatafeedAsync(PreviewDatafeedRequest request,
public Cancellable previewDatafeedAsync(PreviewDatafeedRequest request,
RequestOptions options,
ActionListener<PreviewDatafeedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::previewDatafeed,
options,
PreviewDatafeedResponse::fromXContent,
@ -972,9 +994,10 @@ public final class MachineLearningClient {
* @param request the {@link UpdateJobRequest} object enclosing the desired updates
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void updateJobAsync(UpdateJobRequest request, RequestOptions options, ActionListener<PutJobResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable updateJobAsync(UpdateJobRequest request, RequestOptions options, ActionListener<PutJobResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::updateJob,
options,
PutJobResponse::fromXContent,
@ -1008,9 +1031,10 @@ public final class MachineLearningClient {
* @param request The request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getBucketsAsync(GetBucketsRequest request, RequestOptions options, ActionListener<GetBucketsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable getBucketsAsync(GetBucketsRequest request, RequestOptions options, ActionListener<GetBucketsResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getBuckets,
options,
GetBucketsResponse::fromXContent,
@ -1047,9 +1071,11 @@ public final class MachineLearningClient {
* @param request The request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getCategoriesAsync(GetCategoriesRequest request, RequestOptions options, ActionListener<GetCategoriesResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable getCategoriesAsync(GetCategoriesRequest request, RequestOptions options,
ActionListener<GetCategoriesResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getCategories,
options,
GetCategoriesResponse::fromXContent,
@ -1086,10 +1112,11 @@ public final class MachineLearningClient {
* @param request The request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getModelSnapshotsAsync(GetModelSnapshotsRequest request, RequestOptions options,
public Cancellable getModelSnapshotsAsync(GetModelSnapshotsRequest request, RequestOptions options,
ActionListener<GetModelSnapshotsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getModelSnapshots,
options,
GetModelSnapshotsResponse::fromXContent,
@ -1127,10 +1154,11 @@ public final class MachineLearningClient {
* @param request The request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void updateModelSnapshotAsync(UpdateModelSnapshotRequest request, RequestOptions options,
public Cancellable updateModelSnapshotAsync(UpdateModelSnapshotRequest request, RequestOptions options,
ActionListener<UpdateModelSnapshotResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::updateModelSnapshot,
options,
UpdateModelSnapshotResponse::fromXContent,
@ -1166,10 +1194,11 @@ public final class MachineLearningClient {
* @param request The request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getOverallBucketsAsync(GetOverallBucketsRequest request, RequestOptions options,
public Cancellable getOverallBucketsAsync(GetOverallBucketsRequest request, RequestOptions options,
ActionListener<GetOverallBucketsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getOverallBuckets,
options,
GetOverallBucketsResponse::fromXContent,
@ -1203,9 +1232,10 @@ public final class MachineLearningClient {
* @param request the request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getRecordsAsync(GetRecordsRequest request, RequestOptions options, ActionListener<GetRecordsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable getRecordsAsync(GetRecordsRequest request, RequestOptions options, ActionListener<GetRecordsResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getRecords,
options,
GetRecordsResponse::fromXContent,
@ -1245,9 +1275,10 @@ public final class MachineLearningClient {
* @param request PostDataRequest containing the data to post and some additional options
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void postDataAsync(PostDataRequest request, RequestOptions options, ActionListener<PostDataResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable postDataAsync(PostDataRequest request, RequestOptions options, ActionListener<PostDataResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::postData,
options,
PostDataResponse::fromXContent,
@ -1283,9 +1314,11 @@ public final class MachineLearningClient {
* @param request The calendars request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getCalendarsAsync(GetCalendarsRequest request, RequestOptions options, ActionListener<GetCalendarsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable getCalendarsAsync(GetCalendarsRequest request, RequestOptions options,
ActionListener<GetCalendarsResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getCalendars,
options,
GetCalendarsResponse::fromXContent,
@ -1321,10 +1354,11 @@ public final class MachineLearningClient {
* @param request the request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getInfluencersAsync(GetInfluencersRequest request, RequestOptions options,
public Cancellable getInfluencersAsync(GetInfluencersRequest request, RequestOptions options,
ActionListener<GetInfluencersResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getInfluencers,
options,
GetInfluencersResponse::fromXContent,
@ -1362,9 +1396,10 @@ public final class MachineLearningClient {
* @param request The request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putCalendarAsync(PutCalendarRequest request, RequestOptions options, ActionListener<PutCalendarResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable putCalendarAsync(PutCalendarRequest request, RequestOptions options, ActionListener<PutCalendarResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::putCalendar,
options,
PutCalendarResponse::fromXContent,
@ -1402,9 +1437,11 @@ public final class MachineLearningClient {
* @param request The request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putCalendarJobAsync(PutCalendarJobRequest request, RequestOptions options, ActionListener<PutCalendarResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable putCalendarJobAsync(PutCalendarJobRequest request, RequestOptions options,
ActionListener<PutCalendarResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::putCalendarJob,
options,
PutCalendarResponse::fromXContent,
@ -1442,11 +1479,12 @@ public final class MachineLearningClient {
* @param request The request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteCalendarJobAsync(DeleteCalendarJobRequest request,
public Cancellable deleteCalendarJobAsync(DeleteCalendarJobRequest request,
RequestOptions options,
ActionListener<PutCalendarResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::deleteCalendarJob,
options,
PutCalendarResponse::fromXContent,
@ -1484,9 +1522,11 @@ public final class MachineLearningClient {
* @param request The request to delete the calendar
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteCalendarAsync(DeleteCalendarRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable deleteCalendarAsync(DeleteCalendarRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::deleteCalendar,
options,
AcknowledgedResponse::fromXContent,
@ -1524,10 +1564,11 @@ public final class MachineLearningClient {
* @param request The request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getCalendarEventsAsync(GetCalendarEventsRequest request, RequestOptions options,
public Cancellable getCalendarEventsAsync(GetCalendarEventsRequest request, RequestOptions options,
ActionListener<GetCalendarEventsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getCalendarEvents,
options,
GetCalendarEventsResponse::fromXContent,
@ -1565,10 +1606,11 @@ public final class MachineLearningClient {
* @param request The request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void postCalendarEventAsync(PostCalendarEventRequest request, RequestOptions options,
public Cancellable postCalendarEventAsync(PostCalendarEventRequest request, RequestOptions options,
ActionListener<PostCalendarEventResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::postCalendarEvents,
options,
PostCalendarEventResponse::fromXContent,
@ -1606,11 +1648,12 @@ public final class MachineLearningClient {
* @param request The request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteCalendarEventAsync(DeleteCalendarEventRequest request,
public Cancellable deleteCalendarEventAsync(DeleteCalendarEventRequest request,
RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::deleteCalendarEvent,
options,
AcknowledgedResponse::fromXContent,
@ -1646,9 +1689,10 @@ public final class MachineLearningClient {
* @param request The request containing the {@link org.elasticsearch.client.ml.job.config.MlFilter} settings
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putFilterAsync(PutFilterRequest request, RequestOptions options, ActionListener<PutFilterResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable putFilterAsync(PutFilterRequest request, RequestOptions options, ActionListener<PutFilterResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::putFilter,
options,
PutFilterResponse::fromXContent,
@ -1684,9 +1728,10 @@ public final class MachineLearningClient {
* @param request The request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getFilterAsync(GetFiltersRequest request, RequestOptions options, ActionListener<GetFiltersResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable getFilterAsync(GetFiltersRequest request, RequestOptions options, ActionListener<GetFiltersResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getFilter,
options,
GetFiltersResponse::fromXContent,
@ -1724,9 +1769,10 @@ public final class MachineLearningClient {
* @param request The request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void updateFilterAsync(UpdateFilterRequest request, RequestOptions options, ActionListener<PutFilterResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable updateFilterAsync(UpdateFilterRequest request, RequestOptions options, ActionListener<PutFilterResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::updateFilter,
options,
PutFilterResponse::fromXContent,
@ -1764,9 +1810,11 @@ public final class MachineLearningClient {
* @param request The request to delete the filter
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteFilterAsync(DeleteFilterRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable deleteFilterAsync(DeleteFilterRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::deleteFilter,
options,
AcknowledgedResponse::fromXContent,
@ -1802,9 +1850,10 @@ public final class MachineLearningClient {
* @param request The request of Machine Learning info
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getMlInfoAsync(MlInfoRequest request, RequestOptions options, ActionListener<MlInfoResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable getMlInfoAsync(MlInfoRequest request, RequestOptions options, ActionListener<MlInfoResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::mlInfo,
options,
MlInfoResponse::fromXContent,
@ -1842,10 +1891,11 @@ public final class MachineLearningClient {
* @param request The find file structure request
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void findFileStructureAsync(FindFileStructureRequest request, RequestOptions options,
public Cancellable findFileStructureAsync(FindFileStructureRequest request, RequestOptions options,
ActionListener<FindFileStructureResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::findFileStructure,
options,
FindFileStructureResponse::fromXContent,
@ -1881,9 +1931,11 @@ public final class MachineLearningClient {
* @param request The request of Machine Learning info
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void setUpgradeModeAsync(SetUpgradeModeRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable setUpgradeModeAsync(SetUpgradeModeRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::setUpgradeMode,
options,
AcknowledgedResponse::fromXContent,
@ -1925,10 +1977,11 @@ public final class MachineLearningClient {
* {@link org.elasticsearch.client.ml.dataframe.DataFrameAnalyticsConfig}
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putDataFrameAnalyticsAsync(PutDataFrameAnalyticsRequest request, RequestOptions options,
public Cancellable putDataFrameAnalyticsAsync(PutDataFrameAnalyticsRequest request, RequestOptions options,
ActionListener<PutDataFrameAnalyticsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::putDataFrameAnalytics,
options,
PutDataFrameAnalyticsResponse::fromXContent,
@ -1967,10 +2020,11 @@ public final class MachineLearningClient {
* @param request The {@link GetDataFrameAnalyticsRequest}
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getDataFrameAnalyticsAsync(GetDataFrameAnalyticsRequest request, RequestOptions options,
public Cancellable getDataFrameAnalyticsAsync(GetDataFrameAnalyticsRequest request, RequestOptions options,
ActionListener<GetDataFrameAnalyticsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getDataFrameAnalytics,
options,
GetDataFrameAnalyticsResponse::fromXContent,
@ -2008,10 +2062,11 @@ public final class MachineLearningClient {
* @param request The {@link GetDataFrameAnalyticsStatsRequest}
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getDataFrameAnalyticsStatsAsync(GetDataFrameAnalyticsStatsRequest request, RequestOptions options,
public Cancellable getDataFrameAnalyticsStatsAsync(GetDataFrameAnalyticsStatsRequest request, RequestOptions options,
ActionListener<GetDataFrameAnalyticsStatsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::getDataFrameAnalyticsStats,
options,
GetDataFrameAnalyticsStatsResponse::fromXContent,
@ -2050,10 +2105,11 @@ public final class MachineLearningClient {
* @param request The {@link StartDataFrameAnalyticsRequest}
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void startDataFrameAnalyticsAsync(StartDataFrameAnalyticsRequest request, RequestOptions options,
public Cancellable startDataFrameAnalyticsAsync(StartDataFrameAnalyticsRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::startDataFrameAnalytics,
options,
AcknowledgedResponse::fromXContent,
@ -2092,10 +2148,11 @@ public final class MachineLearningClient {
* @param request The {@link StopDataFrameAnalyticsRequest}
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void stopDataFrameAnalyticsAsync(StopDataFrameAnalyticsRequest request, RequestOptions options,
public Cancellable stopDataFrameAnalyticsAsync(StopDataFrameAnalyticsRequest request, RequestOptions options,
ActionListener<StopDataFrameAnalyticsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::stopDataFrameAnalytics,
options,
StopDataFrameAnalyticsResponse::fromXContent,
@ -2134,10 +2191,11 @@ public final class MachineLearningClient {
* @param request The {@link DeleteDataFrameAnalyticsRequest}
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteDataFrameAnalyticsAsync(DeleteDataFrameAnalyticsRequest request, RequestOptions options,
public Cancellable deleteDataFrameAnalyticsAsync(DeleteDataFrameAnalyticsRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::deleteDataFrameAnalytics,
options,
AcknowledgedResponse::fromXContent,
@ -2176,10 +2234,11 @@ public final class MachineLearningClient {
* @param request The {@link EvaluateDataFrameRequest}
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void evaluateDataFrameAsync(EvaluateDataFrameRequest request, RequestOptions options,
public Cancellable evaluateDataFrameAsync(EvaluateDataFrameRequest request, RequestOptions options,
ActionListener<EvaluateDataFrameResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
MLRequestConverters::evaluateDataFrame,
options,
EvaluateDataFrameResponse::fromXContent,
@ -2219,10 +2278,11 @@ public final class MachineLearningClient {
* @param request The {@link PutDataFrameAnalyticsRequest}
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener Listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void estimateMemoryUsageAsync(PutDataFrameAnalyticsRequest request, RequestOptions options,
public Cancellable estimateMemoryUsageAsync(PutDataFrameAnalyticsRequest request, RequestOptions options,
ActionListener<EstimateMemoryUsageResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
MLRequestConverters::estimateMemoryUsage,
options,

View File

@ -58,10 +58,11 @@ public final class MigrationClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getDeprecationInfoAsync(DeprecationInfoRequest request, RequestOptions options,
public Cancellable getDeprecationInfoAsync(DeprecationInfoRequest request, RequestOptions options,
ActionListener<DeprecationInfoResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, MigrationRequestConverters::getDeprecationInfo, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, MigrationRequestConverters::getDeprecationInfo, options,
DeprecationInfoResponse::fromXContent, listener, Collections.emptySet());
}
}

View File

@ -484,6 +484,7 @@ final class RequestConverters {
if (multiSearchTemplateRequest.maxConcurrentSearchRequests() != MultiSearchRequest.MAX_CONCURRENT_SEARCH_REQUESTS_DEFAULT) {
params.putParam("max_concurrent_searches", Integer.toString(multiSearchTemplateRequest.maxConcurrentSearchRequests()));
}
request.addParameters(params.asMap());
XContent xContent = REQUEST_BODY_CONTENT_TYPE.xContent();
byte[] source = MultiSearchTemplateRequest.writeMultiLineFormat(multiSearchTemplateRequest, xContent);
@ -497,8 +498,14 @@ final class RequestConverters {
params.withRouting(countRequest.routing());
params.withPreference(countRequest.preference());
params.withIndicesOptions(countRequest.indicesOptions());
if (countRequest.terminateAfter() != 0){
params.withTerminateAfter(countRequest.terminateAfter());
}
if (countRequest.minScore() != null){
params.putParam("min_score", String.valueOf(countRequest.minScore()));
}
request.addParameters(params.asMap());
request.setEntity(createEntity(countRequest.source(), REQUEST_BODY_CONTENT_TYPE));
request.setEntity(createEntity(countRequest, REQUEST_BODY_CONTENT_TYPE));
return request;
}
@ -907,6 +914,10 @@ final class RequestConverters {
return this;
}
Params withTerminateAfter(int terminateAfter){
return putParam("terminate_after", String.valueOf(terminateAfter));
}
Params withTimeout(TimeValue timeout) {
return putParam("timeout", timeout);
}

View File

@ -473,8 +473,8 @@ public class RestHighLevelClient implements Closeable {
* are shipped with the Elastic Stack distribution of Elasticsearch. All of
* these APIs will 404 if run against the OSS distribution of Elasticsearch.
* <p>
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/data-frame-apis.html">
* Data Frame APIs on elastic.co</a> for more information.
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/transform-apis.html">
* Transform APIs on elastic.co</a> for more information.
*
* @return the client wrapper for making Data Frame API calls
*/
@ -503,9 +503,11 @@ public class RestHighLevelClient implements Closeable {
* @param bulkRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void bulkAsync(BulkRequest bulkRequest, RequestOptions options, ActionListener<BulkResponse> listener) {
performRequestAsyncAndParseEntity(bulkRequest, RequestConverters::bulk, options, BulkResponse::fromXContent, listener, emptySet());
public final Cancellable bulkAsync(BulkRequest bulkRequest, RequestOptions options, ActionListener<BulkResponse> listener) {
return performRequestAsyncAndParseEntity(bulkRequest, RequestConverters::bulk, options,
BulkResponse::fromXContent, listener, emptySet());
}
/**
@ -540,9 +542,11 @@ public class RestHighLevelClient implements Closeable {
* @param reindexRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void reindexAsync(ReindexRequest reindexRequest, RequestOptions options, ActionListener<BulkByScrollResponse> listener) {
performRequestAsyncAndParseEntity(
public final Cancellable reindexAsync(ReindexRequest reindexRequest, RequestOptions options,
ActionListener<BulkByScrollResponse> listener) {
return performRequestAsyncAndParseEntity(
reindexRequest, RequestConverters::reindex, options, BulkByScrollResponse::fromXContent, listener, singleton(409)
);
}
@ -568,10 +572,11 @@ public class RestHighLevelClient implements Closeable {
* @param updateByQueryRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void updateByQueryAsync(UpdateByQueryRequest updateByQueryRequest, RequestOptions options,
public final Cancellable updateByQueryAsync(UpdateByQueryRequest updateByQueryRequest, RequestOptions options,
ActionListener<BulkByScrollResponse> listener) {
performRequestAsyncAndParseEntity(
return performRequestAsyncAndParseEntity(
updateByQueryRequest, RequestConverters::updateByQuery, options, BulkByScrollResponse::fromXContent, listener, singleton(409)
);
}
@ -597,10 +602,11 @@ public class RestHighLevelClient implements Closeable {
* @param deleteByQueryRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void deleteByQueryAsync(DeleteByQueryRequest deleteByQueryRequest, RequestOptions options,
public final Cancellable deleteByQueryAsync(DeleteByQueryRequest deleteByQueryRequest, RequestOptions options,
ActionListener<BulkByScrollResponse> listener) {
performRequestAsyncAndParseEntity(
return performRequestAsyncAndParseEntity(
deleteByQueryRequest, RequestConverters::deleteByQuery, options, BulkByScrollResponse::fromXContent, listener, singleton(409)
);
}
@ -625,10 +631,11 @@ public class RestHighLevelClient implements Closeable {
* @param rethrottleRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void deleteByQueryRethrottleAsync(RethrottleRequest rethrottleRequest, RequestOptions options,
public final Cancellable deleteByQueryRethrottleAsync(RethrottleRequest rethrottleRequest, RequestOptions options,
ActionListener<ListTasksResponse> listener) {
performRequestAsyncAndParseEntity(rethrottleRequest, RequestConverters::rethrottleDeleteByQuery, options,
return performRequestAsyncAndParseEntity(rethrottleRequest, RequestConverters::rethrottleDeleteByQuery, options,
ListTasksResponse::fromXContent, listener, emptySet());
}
@ -652,10 +659,11 @@ public class RestHighLevelClient implements Closeable {
* @param rethrottleRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void updateByQueryRethrottleAsync(RethrottleRequest rethrottleRequest, RequestOptions options,
public final Cancellable updateByQueryRethrottleAsync(RethrottleRequest rethrottleRequest, RequestOptions options,
ActionListener<ListTasksResponse> listener) {
performRequestAsyncAndParseEntity(rethrottleRequest, RequestConverters::rethrottleUpdateByQuery, options,
return performRequestAsyncAndParseEntity(rethrottleRequest, RequestConverters::rethrottleUpdateByQuery, options,
ListTasksResponse::fromXContent, listener, emptySet());
}
@ -677,15 +685,15 @@ public class RestHighLevelClient implements Closeable {
* Executes a reindex rethrottling request.
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-rethrottle">
* Reindex rethrottling API on elastic.co</a>
*
* @param rethrottleRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void reindexRethrottleAsync(RethrottleRequest rethrottleRequest, RequestOptions options,
public final Cancellable reindexRethrottleAsync(RethrottleRequest rethrottleRequest, RequestOptions options,
ActionListener<ListTasksResponse> listener) {
performRequestAsyncAndParseEntity(rethrottleRequest, RequestConverters::rethrottleReindex, options, ListTasksResponse::fromXContent,
listener, emptySet());
return performRequestAsyncAndParseEntity(rethrottleRequest,
RequestConverters::rethrottleReindex, options, ListTasksResponse::fromXContent, listener, emptySet());
}
/**
@ -725,9 +733,10 @@ public class RestHighLevelClient implements Closeable {
* @param getRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void getAsync(GetRequest getRequest, RequestOptions options, ActionListener<GetResponse> listener) {
performRequestAsyncAndParseEntity(getRequest, RequestConverters::get, options, GetResponse::fromXContent, listener,
public final Cancellable getAsync(GetRequest getRequest, RequestOptions options, ActionListener<GetResponse> listener) {
return performRequestAsyncAndParseEntity(getRequest, RequestConverters::get, options, GetResponse::fromXContent, listener,
singleton(404));
}
@ -764,10 +773,12 @@ public class RestHighLevelClient implements Closeable {
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @deprecated use {@link #mgetAsync(MultiGetRequest, RequestOptions, ActionListener)} instead
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public final void multiGetAsync(MultiGetRequest multiGetRequest, RequestOptions options, ActionListener<MultiGetResponse> listener) {
mgetAsync(multiGetRequest, options, listener);
public final Cancellable multiGetAsync(MultiGetRequest multiGetRequest, RequestOptions options,
ActionListener<MultiGetResponse> listener) {
return mgetAsync(multiGetRequest, options, listener);
}
/**
@ -776,10 +787,12 @@ public class RestHighLevelClient implements Closeable {
* @param multiGetRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void mgetAsync(MultiGetRequest multiGetRequest, RequestOptions options, ActionListener<MultiGetResponse> listener) {
performRequestAsyncAndParseEntity(multiGetRequest, RequestConverters::multiGet, options, MultiGetResponse::fromXContent, listener,
singleton(404));
public final Cancellable mgetAsync(MultiGetRequest multiGetRequest, RequestOptions options,
ActionListener<MultiGetResponse> listener) {
return performRequestAsyncAndParseEntity(multiGetRequest, RequestConverters::multiGet, options,
MultiGetResponse::fromXContent, listener, singleton(404));
}
/**
@ -799,9 +812,10 @@ public class RestHighLevelClient implements Closeable {
* @param getRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void existsAsync(GetRequest getRequest, RequestOptions options, ActionListener<Boolean> listener) {
performRequestAsync(getRequest, RequestConverters::exists, options, RestHighLevelClient::convertExistsResponse, listener,
public final Cancellable existsAsync(GetRequest getRequest, RequestOptions options, ActionListener<Boolean> listener) {
return performRequestAsync(getRequest, RequestConverters::exists, options, RestHighLevelClient::convertExistsResponse, listener,
emptySet());
}
@ -824,10 +838,11 @@ public class RestHighLevelClient implements Closeable {
* @param getRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void existsSourceAsync(GetRequest getRequest, RequestOptions options, ActionListener<Boolean> listener) {
performRequestAsync(getRequest, RequestConverters::sourceExists, options, RestHighLevelClient::convertExistsResponse, listener,
emptySet());
public final Cancellable existsSourceAsync(GetRequest getRequest, RequestOptions options, ActionListener<Boolean> listener) {
return performRequestAsync(getRequest, RequestConverters::sourceExists, options,
RestHighLevelClient::convertExistsResponse, listener, emptySet());
}
/**
@ -838,7 +853,8 @@ public class RestHighLevelClient implements Closeable {
* @return the response
*/
public final IndexResponse index(IndexRequest indexRequest, RequestOptions options) throws IOException {
return performRequestAndParseEntity(indexRequest, RequestConverters::index, options, IndexResponse::fromXContent, emptySet());
return performRequestAndParseEntity(indexRequest, RequestConverters::index, options,
IndexResponse::fromXContent, emptySet());
}
/**
@ -847,9 +863,10 @@ public class RestHighLevelClient implements Closeable {
* @param indexRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void indexAsync(IndexRequest indexRequest, RequestOptions options, ActionListener<IndexResponse> listener) {
performRequestAsyncAndParseEntity(indexRequest, RequestConverters::index, options, IndexResponse::fromXContent, listener,
public final Cancellable indexAsync(IndexRequest indexRequest, RequestOptions options, ActionListener<IndexResponse> listener) {
return performRequestAsyncAndParseEntity(indexRequest, RequestConverters::index, options, IndexResponse::fromXContent, listener,
emptySet());
}
@ -871,9 +888,10 @@ public class RestHighLevelClient implements Closeable {
* @param countRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void countAsync(CountRequest countRequest, RequestOptions options, ActionListener<CountResponse> listener) {
performRequestAsyncAndParseEntity(countRequest, RequestConverters::count, options,CountResponse::fromXContent,
public final Cancellable countAsync(CountRequest countRequest, RequestOptions options, ActionListener<CountResponse> listener) {
return performRequestAsyncAndParseEntity(countRequest, RequestConverters::count, options,CountResponse::fromXContent,
listener, emptySet());
}
@ -894,9 +912,10 @@ public class RestHighLevelClient implements Closeable {
* @param updateRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void updateAsync(UpdateRequest updateRequest, RequestOptions options, ActionListener<UpdateResponse> listener) {
performRequestAsyncAndParseEntity(updateRequest, RequestConverters::update, options, UpdateResponse::fromXContent, listener,
public final Cancellable updateAsync(UpdateRequest updateRequest, RequestOptions options, ActionListener<UpdateResponse> listener) {
return performRequestAsyncAndParseEntity(updateRequest, RequestConverters::update, options, UpdateResponse::fromXContent, listener,
emptySet());
}
@ -918,9 +937,10 @@ public class RestHighLevelClient implements Closeable {
* @param deleteRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void deleteAsync(DeleteRequest deleteRequest, RequestOptions options, ActionListener<DeleteResponse> listener) {
performRequestAsyncAndParseEntity(deleteRequest, RequestConverters::delete, options, DeleteResponse::fromXContent, listener,
public final Cancellable deleteAsync(DeleteRequest deleteRequest, RequestOptions options, ActionListener<DeleteResponse> listener) {
return performRequestAsyncAndParseEntity(deleteRequest, RequestConverters::delete, options, DeleteResponse::fromXContent, listener,
Collections.singleton(404));
}
@ -946,9 +966,10 @@ public class RestHighLevelClient implements Closeable {
* @param searchRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void searchAsync(SearchRequest searchRequest, RequestOptions options, ActionListener<SearchResponse> listener) {
performRequestAsyncAndParseEntity(
public final Cancellable searchAsync(SearchRequest searchRequest, RequestOptions options, ActionListener<SearchResponse> listener) {
return performRequestAsyncAndParseEntity(
searchRequest,
r -> RequestConverters.search(r, "_search"),
options,
@ -992,11 +1013,12 @@ public class RestHighLevelClient implements Closeable {
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @deprecated use {@link #msearchAsync(MultiSearchRequest, RequestOptions, ActionListener)} instead
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public final void multiSearchAsync(MultiSearchRequest searchRequest, RequestOptions options,
public final Cancellable multiSearchAsync(MultiSearchRequest searchRequest, RequestOptions options,
ActionListener<MultiSearchResponse> listener) {
msearchAsync(searchRequest, options, listener);
return msearchAsync(searchRequest, options, listener);
}
/**
@ -1006,10 +1028,11 @@ public class RestHighLevelClient implements Closeable {
* @param searchRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void msearchAsync(MultiSearchRequest searchRequest, RequestOptions options,
public final Cancellable msearchAsync(MultiSearchRequest searchRequest, RequestOptions options,
ActionListener<MultiSearchResponse> listener) {
performRequestAsyncAndParseEntity(searchRequest, RequestConverters::multiSearch, options, MultiSearchResponse::fromXContext,
return performRequestAsyncAndParseEntity(searchRequest, RequestConverters::multiSearch, options, MultiSearchResponse::fromXContext,
listener, emptySet());
}
@ -1051,11 +1074,12 @@ public class RestHighLevelClient implements Closeable {
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @deprecated use {@link #scrollAsync(SearchScrollRequest, RequestOptions, ActionListener)} instead
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public final void searchScrollAsync(SearchScrollRequest searchScrollRequest, RequestOptions options,
public final Cancellable searchScrollAsync(SearchScrollRequest searchScrollRequest, RequestOptions options,
ActionListener<SearchResponse> listener) {
scrollAsync(searchScrollRequest, options, listener);
return scrollAsync(searchScrollRequest, options, listener);
}
/**
@ -1066,11 +1090,12 @@ public class RestHighLevelClient implements Closeable {
* @param searchScrollRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void scrollAsync(SearchScrollRequest searchScrollRequest, RequestOptions options,
public final Cancellable scrollAsync(SearchScrollRequest searchScrollRequest, RequestOptions options,
ActionListener<SearchResponse> listener) {
performRequestAsyncAndParseEntity(searchScrollRequest, RequestConverters::searchScroll, options, SearchResponse::fromXContent,
listener, emptySet());
return performRequestAsyncAndParseEntity(searchScrollRequest, RequestConverters::searchScroll,
options, SearchResponse::fromXContent, listener, emptySet());
}
/**
@ -1095,11 +1120,12 @@ public class RestHighLevelClient implements Closeable {
* @param clearScrollRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void clearScrollAsync(ClearScrollRequest clearScrollRequest, RequestOptions options,
public final Cancellable clearScrollAsync(ClearScrollRequest clearScrollRequest, RequestOptions options,
ActionListener<ClearScrollResponse> listener) {
performRequestAsyncAndParseEntity(clearScrollRequest, RequestConverters::clearScroll, options, ClearScrollResponse::fromXContent,
listener, emptySet());
return performRequestAsyncAndParseEntity(clearScrollRequest, RequestConverters::clearScroll,
options, ClearScrollResponse::fromXContent, listener, emptySet());
}
/**
@ -1121,10 +1147,11 @@ public class RestHighLevelClient implements Closeable {
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html">Search Template API
* on elastic.co</a>.
* @return cancellable that may be used to cancel the request
*/
public final void searchTemplateAsync(SearchTemplateRequest searchTemplateRequest, RequestOptions options,
public final Cancellable searchTemplateAsync(SearchTemplateRequest searchTemplateRequest, RequestOptions options,
ActionListener<SearchTemplateResponse> listener) {
performRequestAsyncAndParseEntity(searchTemplateRequest, RequestConverters::searchTemplate, options,
return performRequestAsyncAndParseEntity(searchTemplateRequest, RequestConverters::searchTemplate, options,
SearchTemplateResponse::fromXContent, listener, emptySet());
}
@ -1152,9 +1179,10 @@ public class RestHighLevelClient implements Closeable {
* @param explainRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void explainAsync(ExplainRequest explainRequest, RequestOptions options, ActionListener<ExplainResponse> listener) {
performRequestAsync(explainRequest, RequestConverters::explain, options,
public final Cancellable explainAsync(ExplainRequest explainRequest, RequestOptions options, ActionListener<ExplainResponse> listener) {
return performRequestAsync(explainRequest, RequestConverters::explain, options,
response -> {
CheckedFunction<XContentParser, ExplainResponse, IOException> entityParser =
parser -> ExplainResponse.fromXContent(parser, convertExistsResponse(response));
@ -1186,9 +1214,12 @@ public class RestHighLevelClient implements Closeable {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void termvectorsAsync(TermVectorsRequest request, RequestOptions options, ActionListener<TermVectorsResponse> listener) {
performRequestAsyncAndParseEntity(request, RequestConverters::termVectors, options, TermVectorsResponse::fromXContent, listener,
public final Cancellable termvectorsAsync(TermVectorsRequest request, RequestOptions options,
ActionListener<TermVectorsResponse> listener) {
return performRequestAsyncAndParseEntity(request, RequestConverters::termVectors, options,
TermVectorsResponse::fromXContent, listener,
emptySet());
}
@ -1216,10 +1247,11 @@ public class RestHighLevelClient implements Closeable {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void mtermvectorsAsync(MultiTermVectorsRequest request, RequestOptions options,
public final Cancellable mtermvectorsAsync(MultiTermVectorsRequest request, RequestOptions options,
ActionListener<MultiTermVectorsResponse> listener) {
performRequestAsyncAndParseEntity(
return performRequestAsyncAndParseEntity(
request, RequestConverters::mtermVectors, options, MultiTermVectorsResponse::fromXContent, listener, emptySet());
}
@ -1255,11 +1287,12 @@ public class RestHighLevelClient implements Closeable {
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-search-template.html">Multi Search Template API
* on elastic.co</a>.
* @return cancellable that may be used to cancel the request
*/
public final void msearchTemplateAsync(MultiSearchTemplateRequest multiSearchTemplateRequest,
public final Cancellable msearchTemplateAsync(MultiSearchTemplateRequest multiSearchTemplateRequest,
RequestOptions options,
ActionListener<MultiSearchTemplateResponse> listener) {
performRequestAsyncAndParseEntity(multiSearchTemplateRequest, RequestConverters::multiSearchTemplate,
return performRequestAsyncAndParseEntity(multiSearchTemplateRequest, RequestConverters::multiSearchTemplate,
options, MultiSearchTemplateResponse::fromXContext, listener, emptySet());
}
@ -1270,9 +1303,12 @@ public class RestHighLevelClient implements Closeable {
* @param rankEvalRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void rankEvalAsync(RankEvalRequest rankEvalRequest, RequestOptions options, ActionListener<RankEvalResponse> listener) {
performRequestAsyncAndParseEntity(rankEvalRequest, RequestConverters::rankEval, options, RankEvalResponse::fromXContent, listener,
public final Cancellable rankEvalAsync(RankEvalRequest rankEvalRequest, RequestOptions options,
ActionListener<RankEvalResponse> listener) {
return performRequestAsyncAndParseEntity(rankEvalRequest, RequestConverters::rankEval, options,
RankEvalResponse::fromXContent, listener,
emptySet());
}
@ -1310,10 +1346,11 @@ public class RestHighLevelClient implements Closeable {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getScriptAsync(GetStoredScriptRequest request, RequestOptions options,
public Cancellable getScriptAsync(GetStoredScriptRequest request, RequestOptions options,
ActionListener<GetStoredScriptResponse> listener) {
performRequestAsyncAndParseEntity(request, RequestConverters::getScript, options,
return performRequestAsyncAndParseEntity(request, RequestConverters::getScript, options,
GetStoredScriptResponse::fromXContent, listener, emptySet());
}
@ -1337,10 +1374,11 @@ public class RestHighLevelClient implements Closeable {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteScriptAsync(DeleteStoredScriptRequest request, RequestOptions options,
public Cancellable deleteScriptAsync(DeleteStoredScriptRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
performRequestAsyncAndParseEntity(request, RequestConverters::deleteScript, options,
return performRequestAsyncAndParseEntity(request, RequestConverters::deleteScript, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -1365,10 +1403,11 @@ public class RestHighLevelClient implements Closeable {
* @param putStoredScriptRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putScriptAsync(PutStoredScriptRequest putStoredScriptRequest, RequestOptions options,
public Cancellable putScriptAsync(PutStoredScriptRequest putStoredScriptRequest, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
performRequestAsyncAndParseEntity(putStoredScriptRequest, RequestConverters::putScript, options,
return performRequestAsyncAndParseEntity(putStoredScriptRequest, RequestConverters::putScript, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -1379,10 +1418,11 @@ public class RestHighLevelClient implements Closeable {
* @param fieldCapabilitiesRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public final void fieldCapsAsync(FieldCapabilitiesRequest fieldCapabilitiesRequest, RequestOptions options,
public final Cancellable fieldCapsAsync(FieldCapabilitiesRequest fieldCapabilitiesRequest, RequestOptions options,
ActionListener<FieldCapabilitiesResponse> listener) {
performRequestAsyncAndParseEntity(fieldCapabilitiesRequest, RequestConverters::fieldCaps, options,
return performRequestAsyncAndParseEntity(fieldCapabilitiesRequest, RequestConverters::fieldCaps, options,
FieldCapabilitiesResponse::fromXContent, listener, emptySet());
}
@ -1514,26 +1554,28 @@ public class RestHighLevelClient implements Closeable {
/**
* @deprecated If creating a new HLRC ReST API call, consider creating new actions instead of reusing server actions. The Validation
* layer has been added to the ReST client, and requests should extend {@link Validatable} instead of {@link ActionRequest}.
* @return Cancellable instance that may be used to cancel the request
*/
@Deprecated
protected final <Req extends ActionRequest, Resp> void performRequestAsyncAndParseEntity(Req request,
protected final <Req extends ActionRequest, Resp> Cancellable performRequestAsyncAndParseEntity(Req request,
CheckedFunction<Req, Request, IOException> requestConverter,
RequestOptions options,
CheckedFunction<XContentParser, Resp, IOException> entityParser,
ActionListener<Resp> listener, Set<Integer> ignores) {
performRequestAsync(request, requestConverter, options,
return performRequestAsync(request, requestConverter, options,
response -> parseEntity(response.getEntity(), entityParser), listener, ignores);
}
/**
* Defines a helper method for asynchronously performing a request.
* @return Cancellable instance that may be used to cancel the request
*/
protected final <Req extends Validatable, Resp> void performRequestAsyncAndParseEntity(Req request,
protected final <Req extends Validatable, Resp> Cancellable performRequestAsyncAndParseEntity(Req request,
CheckedFunction<Req, Request, IOException> requestConverter,
RequestOptions options,
CheckedFunction<XContentParser, Resp, IOException> entityParser,
ActionListener<Resp> listener, Set<Integer> ignores) {
performRequestAsync(request, requestConverter, options,
return performRequestAsync(request, requestConverter, options,
response -> parseEntity(response.getEntity(), entityParser), listener, ignores);
}
@ -1541,9 +1583,10 @@ public class RestHighLevelClient implements Closeable {
/**
* @deprecated If creating a new HLRC ReST API call, consider creating new actions instead of reusing server actions. The Validation
* layer has been added to the ReST client, and requests should extend {@link Validatable} instead of {@link ActionRequest}.
* @return Cancellable instance that may be used to cancel the request
*/
@Deprecated
protected final <Req extends ActionRequest, Resp> void performRequestAsync(Req request,
protected final <Req extends ActionRequest, Resp> Cancellable performRequestAsync(Req request,
CheckedFunction<Req, Request, IOException> requestConverter,
RequestOptions options,
CheckedFunction<Response, Resp, IOException> responseConverter,
@ -1551,15 +1594,16 @@ public class RestHighLevelClient implements Closeable {
ActionRequestValidationException validationException = request.validate();
if (validationException != null && validationException.validationErrors().isEmpty() == false) {
listener.onFailure(validationException);
return;
return Cancellable.NO_OP;
}
internalPerformRequestAsync(request, requestConverter, options, responseConverter, listener, ignores);
return internalPerformRequestAsync(request, requestConverter, options, responseConverter, listener, ignores);
}
/**
* Defines a helper method for asynchronously performing a request.
* @return Cancellable instance that may be used to cancel the request
*/
protected final <Req extends Validatable, Resp> void performRequestAsync(Req request,
protected final <Req extends Validatable, Resp> Cancellable performRequestAsync(Req request,
CheckedFunction<Req, Request, IOException> requestConverter,
RequestOptions options,
CheckedFunction<Response, Resp, IOException> responseConverter,
@ -1567,15 +1611,16 @@ public class RestHighLevelClient implements Closeable {
Optional<ValidationException> validationException = request.validate();
if (validationException != null && validationException.isPresent()) {
listener.onFailure(validationException.get());
return;
return Cancellable.NO_OP;
}
internalPerformRequestAsync(request, requestConverter, options, responseConverter, listener, ignores);
return internalPerformRequestAsync(request, requestConverter, options, responseConverter, listener, ignores);
}
/**
* Provides common functionality for asynchronously performing a request.
* @return Cancellable instance that may be used to cancel the request
*/
private <Req, Resp> void internalPerformRequestAsync(Req request,
private <Req, Resp> Cancellable internalPerformRequestAsync(Req request,
CheckedFunction<Req, Request, IOException> requestConverter,
RequestOptions options,
CheckedFunction<Response, Resp, IOException> responseConverter,
@ -1585,12 +1630,12 @@ public class RestHighLevelClient implements Closeable {
req = requestConverter.apply(request);
} catch (Exception e) {
listener.onFailure(e);
return;
return Cancellable.NO_OP;
}
req.setOptions(options);
ResponseListener responseListener = wrapResponseListener(responseConverter, listener, ignores);
client.performRequestAsync(req, responseListener);
return client.performRequestAsync(req, responseListener);
}
@ -1634,8 +1679,9 @@ public class RestHighLevelClient implements Closeable {
/**
* Asynchronous request which returns empty {@link Optional}s in the case of 404s or parses entity into an Optional
* @return Cancellable instance that may be used to cancel the request
*/
protected final <Req extends Validatable, Resp> void performRequestAsyncAndParseOptionalEntity(Req request,
protected final <Req extends Validatable, Resp> Cancellable performRequestAsyncAndParseOptionalEntity(Req request,
CheckedFunction<Req, Request, IOException> requestConverter,
RequestOptions options,
CheckedFunction<XContentParser, Resp, IOException> entityParser,
@ -1643,19 +1689,19 @@ public class RestHighLevelClient implements Closeable {
Optional<ValidationException> validationException = request.validate();
if (validationException != null && validationException.isPresent()) {
listener.onFailure(validationException.get());
return;
return Cancellable.NO_OP;
}
Request req;
try {
req = requestConverter.apply(request);
} catch (Exception e) {
listener.onFailure(e);
return;
return Cancellable.NO_OP;
}
req.setOptions(options);
ResponseListener responseListener = wrapResponseListener404sOptional(response -> parseEntity(response.getEntity(),
entityParser), listener);
client.performRequestAsync(req, responseListener);
return client.performRequestAsync(req, responseListener);
}
final <Resp> ResponseListener wrapResponseListener404sOptional(CheckedFunction<Response, Resp, IOException> responseConverter,

View File

@ -30,8 +30,6 @@ import org.elasticsearch.client.rollup.GetRollupJobRequest;
import org.elasticsearch.client.rollup.GetRollupJobResponse;
import org.elasticsearch.client.rollup.GetRollupCapsRequest;
import org.elasticsearch.client.rollup.GetRollupCapsResponse;
import org.elasticsearch.client.rollup.GetRollupJobRequest;
import org.elasticsearch.client.rollup.GetRollupJobResponse;
import org.elasticsearch.client.rollup.PutRollupJobRequest;
import org.elasticsearch.client.rollup.StartRollupJobRequest;
import org.elasticsearch.client.rollup.StartRollupJobResponse;
@ -80,9 +78,11 @@ public class RollupClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putRollupJobAsync(PutRollupJobRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable putRollupJobAsync(PutRollupJobRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
RollupRequestConverters::putJob,
options,
AcknowledgedResponse::fromXContent,
@ -113,10 +113,11 @@ public class RollupClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void startRollupJobAsync(StartRollupJobRequest request, RequestOptions options,
public Cancellable startRollupJobAsync(StartRollupJobRequest request, RequestOptions options,
ActionListener<StartRollupJobResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
RollupRequestConverters::startJob,
options,
StartRollupJobResponse::fromXContent,
@ -147,10 +148,11 @@ public class RollupClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void stopRollupJobAsync(StopRollupJobRequest request, RequestOptions options,
public Cancellable stopRollupJobAsync(StopRollupJobRequest request, RequestOptions options,
ActionListener<StopRollupJobResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
RollupRequestConverters::stopJob,
options,
StopRollupJobResponse::fromXContent,
@ -180,11 +182,12 @@ public class RollupClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteRollupJobAsync(DeleteRollupJobRequest request,
public Cancellable deleteRollupJobAsync(DeleteRollupJobRequest request,
RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
RollupRequestConverters::deleteJob,
options,
AcknowledgedResponse::fromXContent,
@ -215,11 +218,11 @@ public class RollupClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getRollupJobAsync(GetRollupJobRequest request, RequestOptions options, ActionListener<GetRollupJobResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
public Cancellable getRollupJobAsync(GetRollupJobRequest request, RequestOptions options,
ActionListener<GetRollupJobResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
RollupRequestConverters::getJob,
options,
GetRollupJobResponse::fromXContent,
@ -251,9 +254,10 @@ public class RollupClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void searchAsync(SearchRequest request, RequestOptions options, ActionListener<SearchResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
public Cancellable searchAsync(SearchRequest request, RequestOptions options, ActionListener<SearchResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
RollupRequestConverters::search,
options,
@ -286,10 +290,11 @@ public class RollupClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getRollupCapabilitiesAsync(GetRollupCapsRequest request, RequestOptions options,
public Cancellable getRollupCapabilitiesAsync(GetRollupCapsRequest request, RequestOptions options,
ActionListener<GetRollupCapsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
RollupRequestConverters::getRollupCaps,
options,
GetRollupCapsResponse::fromXContent,
@ -322,10 +327,11 @@ public class RollupClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getRollupIndexCapabilitiesAsync(GetRollupIndexCapsRequest request, RequestOptions options,
public Cancellable getRollupIndexCapabilitiesAsync(GetRollupIndexCapsRequest request, RequestOptions options,
ActionListener<GetRollupIndexCapsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
RollupRequestConverters::getRollupIndexCaps,
options,
GetRollupIndexCapsResponse::fromXContent,

View File

@ -113,9 +113,10 @@ public final class SecurityClient {
* @param request the request with the user's name
* @param options the request options (e.g., headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getUsersAsync(GetUsersRequest request, RequestOptions options, ActionListener<GetUsersResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::getUsers, options,
public Cancellable getUsersAsync(GetUsersRequest request, RequestOptions options, ActionListener<GetUsersResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::getUsers, options,
GetUsersResponse::fromXContent, listener, emptySet());
}
@ -142,9 +143,10 @@ public final class SecurityClient {
* @param request the request with the user's information
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putUserAsync(PutUserRequest request, RequestOptions options, ActionListener<PutUserResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::putUser, options,
public Cancellable putUserAsync(PutUserRequest request, RequestOptions options, ActionListener<PutUserResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::putUser, options,
PutUserResponse::fromXContent, listener, emptySet());
}
@ -169,9 +171,10 @@ public final class SecurityClient {
* @param request the request with the user to delete
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteUserAsync(DeleteUserRequest request, RequestOptions options, ActionListener<DeleteUserResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::deleteUser, options,
public Cancellable deleteUserAsync(DeleteUserRequest request, RequestOptions options, ActionListener<DeleteUserResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::deleteUser, options,
DeleteUserResponse::fromXContent, listener, singleton(404));
}
@ -196,10 +199,11 @@ public final class SecurityClient {
* @param request the request with the role mapping information
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putRoleMappingAsync(final PutRoleMappingRequest request, final RequestOptions options,
public Cancellable putRoleMappingAsync(final PutRoleMappingRequest request, final RequestOptions options,
final ActionListener<PutRoleMappingResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::putRoleMapping, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::putRoleMapping, options,
PutRoleMappingResponse::fromXContent, listener, emptySet());
}
@ -216,7 +220,8 @@ public final class SecurityClient {
* @throws IOException in case there is a problem sending the request or
* parsing back the response
*/
public GetRoleMappingsResponse getRoleMappings(final GetRoleMappingsRequest request, final RequestOptions options) throws IOException {
public GetRoleMappingsResponse getRoleMappings(final GetRoleMappingsRequest request,
final RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(request, SecurityRequestConverters::getRoleMappings,
options, GetRoleMappingsResponse::fromXContent, emptySet());
}
@ -230,10 +235,11 @@ public final class SecurityClient {
* If no role mapping name is provided then retrieves all role mappings.
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getRoleMappingsAsync(final GetRoleMappingsRequest request, final RequestOptions options,
public Cancellable getRoleMappingsAsync(final GetRoleMappingsRequest request, final RequestOptions options,
final ActionListener<GetRoleMappingsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::getRoleMappings,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::getRoleMappings,
options, GetRoleMappingsResponse::fromXContent, listener, emptySet());
}
@ -276,10 +282,11 @@ public final class SecurityClient {
* @param request the request with the user to enable
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void enableUserAsync(EnableUserRequest request, RequestOptions options,
public Cancellable enableUserAsync(EnableUserRequest request, RequestOptions options,
ActionListener<Boolean> listener) {
restHighLevelClient.performRequestAsync(request, SecurityRequestConverters::enableUser, options,
return restHighLevelClient.performRequestAsync(request, SecurityRequestConverters::enableUser, options,
RestHighLevelClient::convertExistsResponse, listener, emptySet());
}
@ -292,11 +299,12 @@ public final class SecurityClient {
* @param request the request with the user to enable
* @param listener the listener to be notified upon request completion
* @deprecated use {@link #enableUserAsync(EnableUserRequest, RequestOptions, ActionListener)} instead
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public void enableUserAsync(RequestOptions options, EnableUserRequest request,
public Cancellable enableUserAsync(RequestOptions options, EnableUserRequest request,
ActionListener<Boolean> listener) {
enableUserAsync(request, options, listener);
return enableUserAsync(request, options, listener);
}
/**
@ -338,10 +346,11 @@ public final class SecurityClient {
* @param request the request with the user to disable
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void disableUserAsync(DisableUserRequest request, RequestOptions options,
public Cancellable disableUserAsync(DisableUserRequest request, RequestOptions options,
ActionListener<Boolean> listener) {
restHighLevelClient.performRequestAsync(request, SecurityRequestConverters::disableUser, options,
return restHighLevelClient.performRequestAsync(request, SecurityRequestConverters::disableUser, options,
RestHighLevelClient::convertExistsResponse, listener, emptySet());
}
@ -354,11 +363,12 @@ public final class SecurityClient {
* @param request the request with the user to disable
* @param listener the listener to be notified upon request completion
* @deprecated use {@link #disableUserAsync(DisableUserRequest, RequestOptions, ActionListener)} instead
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public void disableUserAsync(RequestOptions options, DisableUserRequest request,
public Cancellable disableUserAsync(RequestOptions options, DisableUserRequest request,
ActionListener<Boolean> listener) {
disableUserAsync(request, options, listener);
return disableUserAsync(request, options, listener);
}
/**
@ -381,9 +391,10 @@ public final class SecurityClient {
*
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void authenticateAsync(RequestOptions options, ActionListener<AuthenticateResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(AuthenticateRequest.INSTANCE, AuthenticateRequest::getRequest, options,
public Cancellable authenticateAsync(RequestOptions options, ActionListener<AuthenticateResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(AuthenticateRequest.INSTANCE, AuthenticateRequest::getRequest, options,
AuthenticateResponse::fromXContent, listener, emptySet());
}
@ -405,13 +416,14 @@ public final class SecurityClient {
* Asynchronously determine whether the current user has a specified list of privileges
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html">
* the docs</a> for more.
*
* @param request the request with the privileges to check
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void hasPrivilegesAsync(HasPrivilegesRequest request, RequestOptions options, ActionListener<HasPrivilegesResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::hasPrivileges, options,
public Cancellable hasPrivilegesAsync(HasPrivilegesRequest request, RequestOptions options,
ActionListener<HasPrivilegesResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::hasPrivileges, options,
HasPrivilegesResponse::fromXContent, listener, emptySet());
}
@ -428,9 +440,11 @@ public final class SecurityClient {
* Asynchronously retrieve the set of effective privileges held by the current user.
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getUserPrivilegesAsync(RequestOptions options, ActionListener<GetUserPrivilegesResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(GetUserPrivilegesRequest.INSTANCE, GetUserPrivilegesRequest::getRequest,
public Cancellable getUserPrivilegesAsync(RequestOptions options, ActionListener<GetUserPrivilegesResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(
GetUserPrivilegesRequest.INSTANCE, GetUserPrivilegesRequest::getRequest,
options, GetUserPrivilegesResponse::fromXContent, listener, emptySet());
}
@ -457,10 +471,11 @@ public final class SecurityClient {
* @param request the request with the realm names and usernames to clear the cache for
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void clearRealmCacheAsync(ClearRealmCacheRequest request, RequestOptions options,
public Cancellable clearRealmCacheAsync(ClearRealmCacheRequest request, RequestOptions options,
ActionListener<ClearRealmCacheResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::clearRealmCache, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::clearRealmCache, options,
ClearRealmCacheResponse::fromXContent, listener, emptySet());
}
@ -487,10 +502,11 @@ public final class SecurityClient {
* @param request the request with the roles for which the cache should be cleared.
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void clearRolesCacheAsync(ClearRolesCacheRequest request, RequestOptions options,
public Cancellable clearRolesCacheAsync(ClearRolesCacheRequest request, RequestOptions options,
ActionListener<ClearRolesCacheResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::clearRolesCache, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::clearRolesCache, options,
ClearRolesCacheResponse::fromXContent, listener, emptySet());
}
@ -515,9 +531,11 @@ public final class SecurityClient {
*
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getSslCertificatesAsync(RequestOptions options, ActionListener<GetSslCertificatesResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(GetSslCertificatesRequest.INSTANCE, GetSslCertificatesRequest::getRequest,
public Cancellable getSslCertificatesAsync(RequestOptions options, ActionListener<GetSslCertificatesResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(
GetSslCertificatesRequest.INSTANCE, GetSslCertificatesRequest::getRequest,
options, GetSslCertificatesResponse::fromXContent, listener, emptySet());
}
@ -560,10 +578,11 @@ public final class SecurityClient {
* @param request the request with the user's new password
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void changePasswordAsync(ChangePasswordRequest request, RequestOptions options,
public Cancellable changePasswordAsync(ChangePasswordRequest request, RequestOptions options,
ActionListener<Boolean> listener) {
restHighLevelClient.performRequestAsync(request, SecurityRequestConverters::changePassword, options,
return restHighLevelClient.performRequestAsync(request, SecurityRequestConverters::changePassword, options,
RestHighLevelClient::convertExistsResponse, listener, emptySet());
}
@ -576,11 +595,12 @@ public final class SecurityClient {
* @param request the request with the user's new password
* @param listener the listener to be notified upon request completion
* @deprecated use {@link #changePasswordAsync(ChangePasswordRequest, RequestOptions, ActionListener)} instead
* @return cancellable that may be used to cancel the request
*/
@Deprecated
public void changePasswordAsync(RequestOptions options, ChangePasswordRequest request,
public Cancellable changePasswordAsync(RequestOptions options, ChangePasswordRequest request,
ActionListener<Boolean> listener) {
changePasswordAsync(request, options, listener);
return changePasswordAsync(request, options, listener);
}
/**
@ -605,9 +625,10 @@ public final class SecurityClient {
* @param request the request with the roles to get
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getRolesAsync(GetRolesRequest request, RequestOptions options, ActionListener<GetRolesResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::getRoles, options,
public Cancellable getRolesAsync(GetRolesRequest request, RequestOptions options, ActionListener<GetRolesResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::getRoles, options,
GetRolesResponse::fromXContent, listener, emptySet());
}
@ -634,9 +655,10 @@ public final class SecurityClient {
* @param request the request containing the role to create or update
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putRoleAsync(PutRoleRequest request, RequestOptions options, ActionListener<PutRoleResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::putRole, options,
public Cancellable putRoleAsync(PutRoleRequest request, RequestOptions options, ActionListener<PutRoleResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::putRole, options,
PutRoleResponse::fromXContent, listener, emptySet());
}
@ -662,10 +684,12 @@ public final class SecurityClient {
* @param request the request with the role mapping name to be deleted.
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteRoleMappingAsync(DeleteRoleMappingRequest request, RequestOptions options,
public Cancellable deleteRoleMappingAsync(DeleteRoleMappingRequest request, RequestOptions options,
ActionListener<DeleteRoleMappingResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::deleteRoleMapping, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
SecurityRequestConverters::deleteRoleMapping, options,
DeleteRoleMappingResponse::fromXContent, listener, emptySet());
}
@ -690,9 +714,11 @@ public final class SecurityClient {
* @param request the request with the role to delete
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteRoleAsync(DeleteRoleRequest request, RequestOptions options, ActionListener<DeleteRoleResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::deleteRole, options,
public Cancellable deleteRoleAsync(DeleteRoleRequest request, RequestOptions options,
ActionListener<DeleteRoleResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::deleteRole, options,
DeleteRoleResponse::fromXContent, listener, singleton(404));
}
@ -719,9 +745,11 @@ public final class SecurityClient {
* @param request the request for the token
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void createTokenAsync(CreateTokenRequest request, RequestOptions options, ActionListener<CreateTokenResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::createToken, options,
public Cancellable createTokenAsync(CreateTokenRequest request, RequestOptions options,
ActionListener<CreateTokenResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::createToken, options,
CreateTokenResponse::fromXContent, listener, emptySet());
}
@ -744,14 +772,14 @@ public final class SecurityClient {
* Asynchronously invalidates an OAuth2 token.
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html">
* the docs</a> for more.
*
* @param request the request to invalidate the token
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void invalidateTokenAsync(InvalidateTokenRequest request, RequestOptions options,
public Cancellable invalidateTokenAsync(InvalidateTokenRequest request, RequestOptions options,
ActionListener<InvalidateTokenResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::invalidateToken, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::invalidateToken, options,
InvalidateTokenResponse::fromXContent, listener, emptySet());
}
@ -777,10 +805,13 @@ public final class SecurityClient {
*
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getBuiltinPrivilegesAsync(final RequestOptions options, final ActionListener<GetBuiltinPrivilegesResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(GetBuiltinPrivilegesRequest.INSTANCE,
GetBuiltinPrivilegesRequest::getRequest, options, GetBuiltinPrivilegesResponse::fromXContent, listener, emptySet());
public Cancellable getBuiltinPrivilegesAsync(final RequestOptions options,
final ActionListener<GetBuiltinPrivilegesResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(GetBuiltinPrivilegesRequest.INSTANCE,
GetBuiltinPrivilegesRequest::getRequest, options, GetBuiltinPrivilegesResponse::fromXContent,
listener, emptySet());
}
/**
@ -806,16 +837,16 @@ public final class SecurityClient {
* Asynchronously get application privilege(s).
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-privileges.html">
* the docs</a> for more.
*
* @param request {@link GetPrivilegesRequest} with the application name and the privilege name.
* If no application name is provided, information about all privileges for all applications is retrieved.
* If no privilege name is provided, information about all privileges of the specified application is retrieved.
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getPrivilegesAsync(final GetPrivilegesRequest request, final RequestOptions options,
public Cancellable getPrivilegesAsync(final GetPrivilegesRequest request, final RequestOptions options,
final ActionListener<GetPrivilegesResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::getPrivileges,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::getPrivileges,
options, GetPrivilegesResponse::fromXContent, listener, emptySet());
}
@ -844,10 +875,11 @@ public final class SecurityClient {
* @param options the request options (e.g. headers), use
* {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putPrivilegesAsync(final PutPrivilegesRequest request, final RequestOptions options,
public Cancellable putPrivilegesAsync(final PutPrivilegesRequest request, final RequestOptions options,
final ActionListener<PutPrivilegesResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::putPrivileges, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::putPrivileges, options,
PutPrivilegesResponse::fromXContent, listener, emptySet());
}
@ -874,10 +906,11 @@ public final class SecurityClient {
* @param request the request with the application privilege to delete
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deletePrivilegesAsync(DeletePrivilegesRequest request, RequestOptions options,
public Cancellable deletePrivilegesAsync(DeletePrivilegesRequest request, RequestOptions options,
ActionListener<DeletePrivilegesResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::deletePrivileges, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::deletePrivileges, options,
DeletePrivilegesResponse::fromXContent, listener, singleton(404));
}
@ -904,10 +937,11 @@ public final class SecurityClient {
* @param request the request to create a API key
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void createApiKeyAsync(final CreateApiKeyRequest request, final RequestOptions options,
public Cancellable createApiKeyAsync(final CreateApiKeyRequest request, final RequestOptions options,
final ActionListener<CreateApiKeyResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::createApiKey, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::createApiKey, options,
CreateApiKeyResponse::fromXContent, listener, emptySet());
}
@ -934,10 +968,11 @@ public final class SecurityClient {
* @param request the request to retrieve API key(s)
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getApiKeyAsync(final GetApiKeyRequest request, final RequestOptions options,
public Cancellable getApiKeyAsync(final GetApiKeyRequest request, final RequestOptions options,
final ActionListener<GetApiKeyResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::getApiKey, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::getApiKey, options,
GetApiKeyResponse::fromXContent, listener, emptySet());
}
@ -965,10 +1000,11 @@ public final class SecurityClient {
* @param request the request to invalidate API key(s)
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void invalidateApiKeyAsync(final InvalidateApiKeyRequest request, final RequestOptions options,
public Cancellable invalidateApiKeyAsync(final InvalidateApiKeyRequest request, final RequestOptions options,
final ActionListener<InvalidateApiKeyResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::invalidateApiKey, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::invalidateApiKey, options,
InvalidateApiKeyResponse::fromXContent, listener, emptySet());
}
@ -1000,9 +1036,9 @@ public final class SecurityClient {
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
*/
public void delegatePkiAuthenticationAsync(DelegatePkiAuthenticationRequest request, RequestOptions options,
public Cancellable delegatePkiAuthenticationAsync(DelegatePkiAuthenticationRequest request, RequestOptions options,
ActionListener<DelegatePkiAuthenticationResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::delegatePkiAuthentication, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::delegatePkiAuthentication, options,
DelegatePkiAuthenticationResponse::fromXContent, listener, emptySet());
}
}

View File

@ -79,10 +79,12 @@ public final class SnapshotClient {
* @param getRepositoriesRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getRepositoryAsync(GetRepositoriesRequest getRepositoriesRequest, RequestOptions options,
public Cancellable getRepositoryAsync(GetRepositoriesRequest getRepositoriesRequest, RequestOptions options,
ActionListener<GetRepositoriesResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(getRepositoriesRequest, SnapshotRequestConverters::getRepositories, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(getRepositoriesRequest,
SnapshotRequestConverters::getRepositories, options,
GetRepositoriesResponse::fromXContent, listener, emptySet());
}
@ -107,10 +109,12 @@ public final class SnapshotClient {
* @param putRepositoryRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void createRepositoryAsync(PutRepositoryRequest putRepositoryRequest, RequestOptions options,
public Cancellable createRepositoryAsync(PutRepositoryRequest putRepositoryRequest, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(putRepositoryRequest, SnapshotRequestConverters::createRepository, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(putRepositoryRequest,
SnapshotRequestConverters::createRepository, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -136,10 +140,12 @@ public final class SnapshotClient {
* @param deleteRepositoryRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteRepositoryAsync(DeleteRepositoryRequest deleteRepositoryRequest, RequestOptions options,
public Cancellable deleteRepositoryAsync(DeleteRepositoryRequest deleteRepositoryRequest, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(deleteRepositoryRequest, SnapshotRequestConverters::deleteRepository, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(deleteRepositoryRequest,
SnapshotRequestConverters::deleteRepository, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -165,10 +171,12 @@ public final class SnapshotClient {
* @param verifyRepositoryRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void verifyRepositoryAsync(VerifyRepositoryRequest verifyRepositoryRequest, RequestOptions options,
public Cancellable verifyRepositoryAsync(VerifyRepositoryRequest verifyRepositoryRequest, RequestOptions options,
ActionListener<VerifyRepositoryResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(verifyRepositoryRequest, SnapshotRequestConverters::verifyRepository, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(verifyRepositoryRequest,
SnapshotRequestConverters::verifyRepository, options,
VerifyRepositoryResponse::fromXContent, listener, emptySet());
}
@ -194,10 +202,11 @@ public final class SnapshotClient {
* @param cleanupRepositoryRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void cleanupRepositoryAsync(CleanupRepositoryRequest cleanupRepositoryRequest, RequestOptions options,
public Cancellable cleanupRepositoryAsync(CleanupRepositoryRequest cleanupRepositoryRequest, RequestOptions options,
ActionListener<CleanupRepositoryResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(cleanupRepositoryRequest, SnapshotRequestConverters::cleanupRepository,
return restHighLevelClient.performRequestAsyncAndParseEntity(cleanupRepositoryRequest, SnapshotRequestConverters::cleanupRepository,
options, CleanupRepositoryResponse::fromXContent, listener, emptySet());
}
@ -218,10 +227,12 @@ public final class SnapshotClient {
* <p>
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html"> Snapshot and Restore
* API on elastic.co</a>
* @return cancellable that may be used to cancel the request
*/
public void createAsync(CreateSnapshotRequest createSnapshotRequest, RequestOptions options,
public Cancellable createAsync(CreateSnapshotRequest createSnapshotRequest, RequestOptions options,
ActionListener<CreateSnapshotResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(createSnapshotRequest, SnapshotRequestConverters::createSnapshot, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(createSnapshotRequest,
SnapshotRequestConverters::createSnapshot, options,
CreateSnapshotResponse::fromXContent, listener, emptySet());
}
@ -244,13 +255,15 @@ public final class SnapshotClient {
* Asynchronously get snapshots.
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html"> Snapshot and Restore
* API on elastic.co</a>
*
* @param getSnapshotsRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getAsync(GetSnapshotsRequest getSnapshotsRequest, RequestOptions options, ActionListener<GetSnapshotsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(getSnapshotsRequest, SnapshotRequestConverters::getSnapshots, options,
public Cancellable getAsync(GetSnapshotsRequest getSnapshotsRequest, RequestOptions options,
ActionListener<GetSnapshotsResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(getSnapshotsRequest,
SnapshotRequestConverters::getSnapshots, options,
GetSnapshotsResponse::fromXContent, listener, emptySet());
}
@ -276,10 +289,12 @@ public final class SnapshotClient {
* @param snapshotsStatusRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void statusAsync(SnapshotsStatusRequest snapshotsStatusRequest, RequestOptions options,
public Cancellable statusAsync(SnapshotsStatusRequest snapshotsStatusRequest, RequestOptions options,
ActionListener<SnapshotsStatusResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(snapshotsStatusRequest, SnapshotRequestConverters::snapshotsStatus, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(snapshotsStatusRequest,
SnapshotRequestConverters::snapshotsStatus, options,
SnapshotsStatusResponse::fromXContent, listener, emptySet());
}
@ -306,10 +321,12 @@ public final class SnapshotClient {
* @param restoreSnapshotRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void restoreAsync(RestoreSnapshotRequest restoreSnapshotRequest, RequestOptions options,
public Cancellable restoreAsync(RestoreSnapshotRequest restoreSnapshotRequest, RequestOptions options,
ActionListener<RestoreSnapshotResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(restoreSnapshotRequest, SnapshotRequestConverters::restoreSnapshot, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(restoreSnapshotRequest,
SnapshotRequestConverters::restoreSnapshot, options,
RestoreSnapshotResponse::fromXContent, listener, emptySet());
}
@ -324,7 +341,8 @@ public final class SnapshotClient {
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public AcknowledgedResponse delete(DeleteSnapshotRequest deleteSnapshotRequest, RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(deleteSnapshotRequest, SnapshotRequestConverters::deleteSnapshot, options,
return restHighLevelClient.performRequestAndParseEntity(deleteSnapshotRequest,
SnapshotRequestConverters::deleteSnapshot, options,
AcknowledgedResponse::fromXContent, emptySet());
}
@ -336,10 +354,12 @@ public final class SnapshotClient {
* @param deleteSnapshotRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteAsync(DeleteSnapshotRequest deleteSnapshotRequest, RequestOptions options,
public Cancellable deleteAsync(DeleteSnapshotRequest deleteSnapshotRequest, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(deleteSnapshotRequest, SnapshotRequestConverters::deleteSnapshot, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(deleteSnapshotRequest,
SnapshotRequestConverters::deleteSnapshot, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}
}

View File

@ -65,9 +65,10 @@ public final class TasksClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void listAsync(ListTasksRequest request, RequestOptions options, ActionListener<ListTasksResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, TasksRequestConverters::listTasks, options,
public Cancellable listAsync(ListTasksRequest request, RequestOptions options, ActionListener<ListTasksResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, TasksRequestConverters::listTasks, options,
ListTasksResponse::fromXContent, listener, emptySet());
}
@ -92,10 +93,12 @@ public final class TasksClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener an actionlistener that takes an optional response (404s are returned as an empty Optional)
* @return cancellable that may be used to cancel the request
*/
public void getAsync(GetTaskRequest request, RequestOptions options, ActionListener<Optional<GetTaskResponse>> listener) {
public Cancellable getAsync(GetTaskRequest request, RequestOptions options,
ActionListener<Optional<GetTaskResponse>> listener) {
restHighLevelClient.performRequestAsyncAndParseOptionalEntity(request, TasksRequestConverters::getTask, options,
return restHighLevelClient.performRequestAsyncAndParseOptionalEntity(request, TasksRequestConverters::getTask, options,
GetTaskResponse::fromXContent, listener);
}
@ -128,9 +131,11 @@ public final class TasksClient {
* @param cancelTasksRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void cancelAsync(CancelTasksRequest cancelTasksRequest, RequestOptions options, ActionListener<CancelTasksResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
public Cancellable cancelAsync(CancelTasksRequest cancelTasksRequest, RequestOptions options,
ActionListener<CancelTasksResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(
cancelTasksRequest,
TasksRequestConverters::cancelTasks,
options,

View File

@ -71,10 +71,11 @@ public final class WatcherClient {
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html">
* the docs</a> for more.
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return cancellable that may be used to cancel the request
*/
public void startWatchServiceAsync(StartWatchServiceRequest request, RequestOptions options,
public Cancellable startWatchServiceAsync(StartWatchServiceRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
return restHighLevelClient.performRequestAsyncAndParseEntity(
request, WatcherRequestConverters::startWatchService, options, AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -98,10 +99,11 @@ public final class WatcherClient {
* the docs</a> for more.
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return cancellable that may be used to cancel the request
*/
public void stopWatchServiceAsync(StopWatchServiceRequest request, RequestOptions options,
public Cancellable stopWatchServiceAsync(StopWatchServiceRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
return restHighLevelClient.performRequestAsyncAndParseEntity(
request, WatcherRequestConverters::stopWatchService, options, AcknowledgedResponse::fromXContent, listener, emptySet());
}
@ -126,10 +128,11 @@ public final class WatcherClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void putWatchAsync(PutWatchRequest request, RequestOptions options,
public Cancellable putWatchAsync(PutWatchRequest request, RequestOptions options,
ActionListener<PutWatchResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::putWatch, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::putWatch, options,
PutWatchResponse::fromXContent, listener, emptySet());
}
@ -154,10 +157,11 @@ public final class WatcherClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void getWatchAsync(GetWatchRequest request, RequestOptions options,
public Cancellable getWatchAsync(GetWatchRequest request, RequestOptions options,
ActionListener<GetWatchResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::getWatch, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::getWatch, options,
GetWatchResponse::fromXContent, listener, emptySet());
}
@ -183,10 +187,11 @@ public final class WatcherClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deactivateWatchAsync(DeactivateWatchRequest request, RequestOptions options,
public Cancellable deactivateWatchAsync(DeactivateWatchRequest request, RequestOptions options,
ActionListener<DeactivateWatchResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::deactivateWatch, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::deactivateWatch, options,
DeactivateWatchResponse::fromXContent, listener, emptySet());
}
@ -211,9 +216,10 @@ public final class WatcherClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void deleteWatchAsync(DeleteWatchRequest request, RequestOptions options, ActionListener<DeleteWatchResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::deleteWatch, options,
public Cancellable deleteWatchAsync(DeleteWatchRequest request, RequestOptions options, ActionListener<DeleteWatchResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::deleteWatch, options,
DeleteWatchResponse::fromXContent, listener, singleton(404));
}
@ -238,9 +244,10 @@ public final class WatcherClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon completion of the request
* @return cancellable that may be used to cancel the request
*/
public void ackWatchAsync(AckWatchRequest request, RequestOptions options, ActionListener<AckWatchResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::ackWatch, options,
public Cancellable ackWatchAsync(AckWatchRequest request, RequestOptions options, ActionListener<AckWatchResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::ackWatch, options,
AckWatchResponse::fromXContent, listener, emptySet());
}
@ -265,9 +272,11 @@ public final class WatcherClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void activateWatchAsync(ActivateWatchRequest request, RequestOptions options, ActionListener<ActivateWatchResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::activateWatch, options,
public Cancellable activateWatchAsync(ActivateWatchRequest request, RequestOptions options,
ActionListener<ActivateWatchResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::activateWatch, options,
ActivateWatchResponse::fromXContent, listener, singleton(404));
}
@ -292,9 +301,11 @@ public final class WatcherClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notifed upon request completion
* @return cancellable that may be used to cancel the request
*/
public void executeWatchAsync(ExecuteWatchRequest request, RequestOptions options, ActionListener<ExecuteWatchResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::executeWatch, options,
public Cancellable executeWatchAsync(ExecuteWatchRequest request, RequestOptions options,
ActionListener<ExecuteWatchResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::executeWatch, options,
ExecuteWatchResponse::fromXContent, listener, emptySet());
}
@ -319,9 +330,11 @@ public final class WatcherClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void watcherStatsAsync(WatcherStatsRequest request, RequestOptions options, ActionListener<WatcherStatsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::watcherStats, options,
public Cancellable watcherStatsAsync(WatcherStatsRequest request, RequestOptions options,
ActionListener<WatcherStatsResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::watcherStats, options,
WatcherStatsResponse::fromXContent, listener, emptySet());
}

View File

@ -67,10 +67,11 @@ public final class XPackClient {
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void infoAsync(XPackInfoRequest request, RequestOptions options,
public Cancellable infoAsync(XPackInfoRequest request, RequestOptions options,
ActionListener<XPackInfoResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, XPackRequestConverters::info, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, XPackRequestConverters::info, options,
XPackInfoResponse::fromXContent, listener, emptySet());
}
@ -89,9 +90,10 @@ public final class XPackClient {
* Asynchronously fetch usage information about X-Pack features from the cluster.
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public void usageAsync(XPackUsageRequest request, RequestOptions options, ActionListener<XPackUsageResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, XPackRequestConverters::usage, options,
public Cancellable usageAsync(XPackUsageRequest request, RequestOptions options, ActionListener<XPackUsageResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(request, XPackRequestConverters::usage, options,
XPackUsageResponse::fromXContent, listener, emptySet());
}
}

View File

@ -24,8 +24,13 @@ import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.internal.SearchContext;
import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;
@ -34,32 +39,43 @@ import static org.elasticsearch.action.search.SearchRequest.DEFAULT_INDICES_OPTI
/**
* Encapsulates a request to _count API against one, several or all indices.
*/
public final class CountRequest extends ActionRequest implements IndicesRequest.Replaceable {
public final class CountRequest extends ActionRequest implements IndicesRequest.Replaceable, ToXContentObject {
private String[] indices = Strings.EMPTY_ARRAY;
private String[] types = Strings.EMPTY_ARRAY;
private String routing;
private String preference;
private SearchSourceBuilder searchSourceBuilder;
private QueryBuilder query;
private IndicesOptions indicesOptions = DEFAULT_INDICES_OPTIONS;
private int terminateAfter = SearchContext.DEFAULT_TERMINATE_AFTER;
private Float minScore;
public CountRequest() {
this.searchSourceBuilder = new SearchSourceBuilder();
}
public CountRequest() {}
/**
* Constructs a new count request against the indices. No indices provided here means that count will execute on all indices.
*/
public CountRequest(String... indices) {
this(indices, new SearchSourceBuilder());
indices(indices);
}
/**
* Constructs a new search request against the provided indices with the given search source.
*
* @deprecated The count api only supports a query. Use {@link #CountRequest(String[], QueryBuilder)} instead.
*/
@Deprecated
public CountRequest(String[] indices, SearchSourceBuilder searchSourceBuilder) {
indices(indices);
this.searchSourceBuilder = searchSourceBuilder;
this.query = Objects.requireNonNull(searchSourceBuilder, "source must not be null").query();
}
/**
* Constructs a new search request against the provided indices with the given query.
*/
public CountRequest(String[] indices, QueryBuilder query) {
indices(indices);
this.query = Objects.requireNonNull(query, "query must not be null");;
}
@Override
@ -81,9 +97,20 @@ public final class CountRequest extends ActionRequest implements IndicesRequest.
/**
* The source of the count request.
*
* @deprecated The count api only supports a query. Use {@link #query(QueryBuilder)} instead.
*/
@Deprecated
public CountRequest source(SearchSourceBuilder searchSourceBuilder) {
this.searchSourceBuilder = Objects.requireNonNull(searchSourceBuilder, "source must not be null");
this.query = Objects.requireNonNull(searchSourceBuilder, "source must not be null").query();
return this;
}
/**
* Sets the query to execute for this count request.
*/
public CountRequest query(QueryBuilder query) {
this.query = Objects.requireNonNull(query, "query must not be null");
return this;
}
@ -156,20 +183,23 @@ public final class CountRequest extends ActionRequest implements IndicesRequest.
}
public Float minScore() {
return this.searchSourceBuilder.minScore();
return minScore;
}
public CountRequest minScore(Float minScore) {
this.searchSourceBuilder.minScore(minScore);
this.minScore = minScore;
return this;
}
public int terminateAfter() {
return this.searchSourceBuilder.terminateAfter();
return this.terminateAfter;
}
public CountRequest terminateAfter(int terminateAfter) {
this.searchSourceBuilder.terminateAfter(terminateAfter);
if (terminateAfter < 0) {
throw new IllegalArgumentException("terminateAfter must be > 0");
}
this.terminateAfter = terminateAfter;
return this;
}
@ -182,8 +212,31 @@ public final class CountRequest extends ActionRequest implements IndicesRequest.
return Arrays.copyOf(this.types, this.types.length);
}
/**
* @return the source builder
* @deprecated The count api only supports a query. Use {@link #query()} instead.
*/
@Deprecated
public SearchSourceBuilder source() {
return this.searchSourceBuilder;
return new SearchSourceBuilder().query(query);
}
/**
* @return The provided query to execute with the count request or
* <code>null</code> if no query was provided.
*/
public QueryBuilder query() {
return query;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
if (query != null) {
builder.field("query", query);
}
builder.endObject();
return builder;
}
@Override
@ -199,12 +252,15 @@ public final class CountRequest extends ActionRequest implements IndicesRequest.
Arrays.equals(indices, that.indices) &&
Arrays.equals(types, that.types) &&
Objects.equals(routing, that.routing) &&
Objects.equals(preference, that.preference);
Objects.equals(preference, that.preference) &&
Objects.equals(terminateAfter, that.terminateAfter) &&
Objects.equals(minScore, that.minScore) &&
Objects.equals(query, that.query);
}
@Override
public int hashCode() {
int result = Objects.hash(indicesOptions, routing, preference);
int result = Objects.hash(indicesOptions, routing, preference, terminateAfter, minScore, query);
result = 31 * result + Arrays.hashCode(indices);
result = 31 * result + Arrays.hashCode(types);
return result;

View File

@ -21,8 +21,8 @@ package org.elasticsearch.client.ml;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.TaskOperationFailure;
import org.elasticsearch.client.dataframe.AcknowledgedTasksResponse;
import org.elasticsearch.client.ml.dataframe.DataFrameAnalyticsStats;
import org.elasticsearch.client.transform.AcknowledgedTasksResponse;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;

View File

@ -20,7 +20,7 @@
package org.elasticsearch.client.ml.dataframe;
import org.elasticsearch.Version;
import org.elasticsearch.client.dataframe.transforms.util.TimeUtil;
import org.elasticsearch.client.transform.transforms.util.TimeUtil;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;

View File

@ -0,0 +1,30 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you 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.
*/
package org.elasticsearch.client.slm;
import org.elasticsearch.client.TimedRequest;
public class GetSnapshotLifecycleStatsRequest extends TimedRequest {
public GetSnapshotLifecycleStatsRequest() {
super();
}
}

View File

@ -0,0 +1,68 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you 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.
*/
package org.elasticsearch.client.slm;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
import java.util.Objects;
public class GetSnapshotLifecycleStatsResponse implements ToXContentObject {
private final SnapshotLifecycleStats stats;
public GetSnapshotLifecycleStatsResponse(SnapshotLifecycleStats stats) {
this.stats = stats;
}
public SnapshotLifecycleStats getStats() {
return this.stats;
}
public static GetSnapshotLifecycleStatsResponse fromXContent(XContentParser parser) throws IOException {
return new GetSnapshotLifecycleStatsResponse(SnapshotLifecycleStats.parse(parser));
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
return stats.toXContent(builder, params);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GetSnapshotLifecycleStatsResponse other = (GetSnapshotLifecycleStatsResponse) o;
return Objects.equals(this.stats, other.stats);
}
@Override
public int hashCode() {
return Objects.hash(this.stats);
}
}

View File

@ -38,11 +38,13 @@ public class SnapshotLifecyclePolicy implements ToXContentObject {
private final String schedule;
private final String repository;
private final Map<String, Object> configuration;
private final SnapshotRetentionConfiguration retentionPolicy;
private static final ParseField NAME = new ParseField("name");
private static final ParseField SCHEDULE = new ParseField("schedule");
private static final ParseField REPOSITORY = new ParseField("repository");
private static final ParseField CONFIG = new ParseField("config");
private static final ParseField RETENTION = new ParseField("retention");
@SuppressWarnings("unchecked")
private static final ConstructingObjectParser<SnapshotLifecyclePolicy, String> PARSER =
@ -52,7 +54,8 @@ public class SnapshotLifecyclePolicy implements ToXContentObject {
String schedule = (String) a[1];
String repo = (String) a[2];
Map<String, Object> config = (Map<String, Object>) a[3];
return new SnapshotLifecyclePolicy(id, name, schedule, repo, config);
SnapshotRetentionConfiguration retention = (SnapshotRetentionConfiguration) a[4];
return new SnapshotLifecyclePolicy(id, name, schedule, repo, config, retention);
});
static {
@ -60,15 +63,18 @@ public class SnapshotLifecyclePolicy implements ToXContentObject {
PARSER.declareString(ConstructingObjectParser.constructorArg(), SCHEDULE);
PARSER.declareString(ConstructingObjectParser.constructorArg(), REPOSITORY);
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), (p, c) -> p.map(), CONFIG);
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), SnapshotRetentionConfiguration::parse, RETENTION);
}
public SnapshotLifecyclePolicy(final String id, final String name, final String schedule,
final String repository, @Nullable Map<String, Object> configuration) {
this.id = Objects.requireNonNull(id);
this.name = name;
this.schedule = schedule;
this.repository = repository;
final String repository, @Nullable final Map<String, Object> configuration,
@Nullable final SnapshotRetentionConfiguration retentionPolicy) {
this.id = Objects.requireNonNull(id, "policy id is required");
this.name = Objects.requireNonNull(name, "policy snapshot name is required");
this.schedule = Objects.requireNonNull(schedule, "policy schedule is required");
this.repository = Objects.requireNonNull(repository, "policy snapshot repository is required");
this.configuration = configuration;
this.retentionPolicy = retentionPolicy;
}
public String getId() {
@ -92,6 +98,11 @@ public class SnapshotLifecyclePolicy implements ToXContentObject {
return this.configuration;
}
@Nullable
public SnapshotRetentionConfiguration getRetentionPolicy() {
return this.retentionPolicy;
}
public static SnapshotLifecyclePolicy parse(XContentParser parser, String id) {
return PARSER.apply(parser, id);
}
@ -105,13 +116,16 @@ public class SnapshotLifecyclePolicy implements ToXContentObject {
if (this.configuration != null) {
builder.field(CONFIG.getPreferredName(), this.configuration);
}
if (this.retentionPolicy != null) {
builder.field(RETENTION.getPreferredName(), this.retentionPolicy);
}
builder.endObject();
return builder;
}
@Override
public int hashCode() {
return Objects.hash(id, name, schedule, repository, configuration);
return Objects.hash(id, name, schedule, repository, configuration, retentionPolicy);
}
@Override
@ -128,7 +142,8 @@ public class SnapshotLifecyclePolicy implements ToXContentObject {
Objects.equals(name, other.name) &&
Objects.equals(schedule, other.schedule) &&
Objects.equals(repository, other.repository) &&
Objects.equals(configuration, other.configuration);
Objects.equals(configuration, other.configuration) &&
Objects.equals(retentionPolicy, other.retentionPolicy);
}
@Override

View File

@ -42,6 +42,7 @@ public class SnapshotLifecyclePolicyMetadata implements ToXContentObject {
static final ParseField NEXT_EXECUTION_MILLIS = new ParseField("next_execution_millis");
static final ParseField NEXT_EXECUTION = new ParseField("next_execution");
static final ParseField SNAPSHOT_IN_PROGRESS = new ParseField("in_progress");
static final ParseField POLICY_STATS = new ParseField("stats");
private final SnapshotLifecyclePolicy policy;
private final long version;
@ -53,6 +54,7 @@ public class SnapshotLifecyclePolicyMetadata implements ToXContentObject {
private final SnapshotInvocationRecord lastFailure;
@Nullable
private final SnapshotInProgress snapshotInProgress;
private final SnapshotLifecycleStats.SnapshotPolicyStats policyStats;
@SuppressWarnings("unchecked")
public static final ConstructingObjectParser<SnapshotLifecyclePolicyMetadata, String> PARSER =
@ -65,8 +67,9 @@ public class SnapshotLifecyclePolicyMetadata implements ToXContentObject {
SnapshotInvocationRecord lastFailure = (SnapshotInvocationRecord) a[4];
long nextExecution = (long) a[5];
SnapshotInProgress sip = (SnapshotInProgress) a[6];
return new SnapshotLifecyclePolicyMetadata(policy, version, modifiedDate, lastSuccess, lastFailure, nextExecution, sip);
SnapshotLifecycleStats.SnapshotPolicyStats stats = (SnapshotLifecycleStats.SnapshotPolicyStats) a[7];
return new SnapshotLifecyclePolicyMetadata(policy, version, modifiedDate, lastSuccess,
lastFailure, nextExecution, sip, stats);
});
static {
@ -77,6 +80,9 @@ public class SnapshotLifecyclePolicyMetadata implements ToXContentObject {
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), SnapshotInvocationRecord::parse, LAST_FAILURE);
PARSER.declareLong(ConstructingObjectParser.constructorArg(), NEXT_EXECUTION_MILLIS);
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), SnapshotInProgress::parse, SNAPSHOT_IN_PROGRESS);
PARSER.declareObject(ConstructingObjectParser.constructorArg(),
(p, c) -> SnapshotLifecycleStats.SnapshotPolicyStats.parse(p, "policy"), POLICY_STATS);
}
public static SnapshotLifecyclePolicyMetadata parse(XContentParser parser, String id) {
@ -86,7 +92,8 @@ public class SnapshotLifecyclePolicyMetadata implements ToXContentObject {
public SnapshotLifecyclePolicyMetadata(SnapshotLifecyclePolicy policy, long version, long modifiedDate,
SnapshotInvocationRecord lastSuccess, SnapshotInvocationRecord lastFailure,
long nextExecution,
@Nullable SnapshotInProgress snapshotInProgress) {
@Nullable SnapshotInProgress snapshotInProgress,
SnapshotLifecycleStats.SnapshotPolicyStats policyStats) {
this.policy = policy;
this.version = version;
this.modifiedDate = modifiedDate;
@ -94,6 +101,7 @@ public class SnapshotLifecyclePolicyMetadata implements ToXContentObject {
this.lastFailure = lastFailure;
this.nextExecution = nextExecution;
this.snapshotInProgress = snapshotInProgress;
this.policyStats = policyStats;
}
public SnapshotLifecyclePolicy getPolicy() {
@ -124,6 +132,10 @@ public class SnapshotLifecyclePolicyMetadata implements ToXContentObject {
return this.nextExecution;
}
public SnapshotLifecycleStats.SnapshotPolicyStats getPolicyStats() {
return this.policyStats;
}
@Nullable
public SnapshotInProgress getSnapshotInProgress() {
return this.snapshotInProgress;
@ -145,13 +157,16 @@ public class SnapshotLifecyclePolicyMetadata implements ToXContentObject {
if (snapshotInProgress != null) {
builder.field(SNAPSHOT_IN_PROGRESS.getPreferredName(), snapshotInProgress);
}
builder.startObject(POLICY_STATS.getPreferredName());
this.policyStats.toXContent(builder, params);
builder.endObject();
builder.endObject();
return builder;
}
@Override
public int hashCode() {
return Objects.hash(policy, version, modifiedDate, lastSuccess, lastFailure, nextExecution);
return Objects.hash(policy, version, modifiedDate, lastSuccess, lastFailure, nextExecution, policyStats);
}
@Override
@ -168,7 +183,8 @@ public class SnapshotLifecyclePolicyMetadata implements ToXContentObject {
Objects.equals(modifiedDate, other.modifiedDate) &&
Objects.equals(lastSuccess, other.lastSuccess) &&
Objects.equals(lastFailure, other.lastFailure) &&
Objects.equals(nextExecution, other.nextExecution);
Objects.equals(nextExecution, other.nextExecution) &&
Objects.equals(policyStats, other.policyStats);
}
public static class SnapshotInProgress implements ToXContentObject {

View File

@ -0,0 +1,261 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you 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.
*/
package org.elasticsearch.client.slm;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
public class SnapshotLifecycleStats implements ToXContentObject {
private final long retentionRunCount;
private final long retentionFailedCount;
private final long retentionTimedOut;
private final long retentionTimeMs;
private final Map<String, SnapshotPolicyStats> policyStats;
public static final ParseField RETENTION_RUNS = new ParseField("retention_runs");
public static final ParseField RETENTION_FAILED = new ParseField("retention_failed");
public static final ParseField RETENTION_TIMED_OUT = new ParseField("retention_timed_out");
public static final ParseField RETENTION_TIME = new ParseField("retention_deletion_time");
public static final ParseField RETENTION_TIME_MILLIS = new ParseField("retention_deletion_time_millis");
public static final ParseField POLICY_STATS = new ParseField("policy_stats");
public static final ParseField TOTAL_TAKEN = new ParseField("total_snapshots_taken");
public static final ParseField TOTAL_FAILED = new ParseField("total_snapshots_failed");
public static final ParseField TOTAL_DELETIONS = new ParseField("total_snapshots_deleted");
public static final ParseField TOTAL_DELETION_FAILURES = new ParseField("total_snapshot_deletion_failures");
@SuppressWarnings("unchecked")
private static final ConstructingObjectParser<SnapshotLifecycleStats, Void> PARSER =
new ConstructingObjectParser<>("snapshot_policy_stats", true,
a -> {
long runs = (long) a[0];
long failed = (long) a[1];
long timedOut = (long) a[2];
long timeMs = (long) a[3];
Map<String, SnapshotPolicyStats> policyStatsMap = ((List<SnapshotPolicyStats>) a[4]).stream()
.collect(Collectors.toMap(m -> m.policyId, Function.identity()));
return new SnapshotLifecycleStats(runs, failed, timedOut, timeMs, policyStatsMap);
});
static {
PARSER.declareLong(ConstructingObjectParser.constructorArg(), RETENTION_RUNS);
PARSER.declareLong(ConstructingObjectParser.constructorArg(), RETENTION_FAILED);
PARSER.declareLong(ConstructingObjectParser.constructorArg(), RETENTION_TIMED_OUT);
PARSER.declareLong(ConstructingObjectParser.constructorArg(), RETENTION_TIME_MILLIS);
PARSER.declareNamedObjects(ConstructingObjectParser.constructorArg(), (p, c, n) -> SnapshotPolicyStats.parse(p, n), POLICY_STATS);
}
// Package visible for testing
private SnapshotLifecycleStats(long retentionRuns, long retentionFailed, long retentionTimedOut, long retentionTimeMs,
Map<String, SnapshotPolicyStats> policyStats) {
this.retentionRunCount = retentionRuns;
this.retentionFailedCount = retentionFailed;
this.retentionTimedOut = retentionTimedOut;
this.retentionTimeMs = retentionTimeMs;
this.policyStats = policyStats;
}
public static SnapshotLifecycleStats parse(XContentParser parser) {
return PARSER.apply(parser, null);
}
public long getRetentionRunCount() {
return retentionRunCount;
}
public long getRetentionFailedCount() {
return retentionFailedCount;
}
public long getRetentionTimedOut() {
return retentionTimedOut;
}
public long getRetentionTimeMillis() {
return retentionTimeMs;
}
/**
* @return a map of per-policy stats for each SLM policy
*/
public Map<String, SnapshotPolicyStats> getMetrics() {
return Collections.unmodifiableMap(this.policyStats);
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field(RETENTION_RUNS.getPreferredName(), this.retentionRunCount);
builder.field(RETENTION_FAILED.getPreferredName(), this.retentionFailedCount);
builder.field(RETENTION_TIMED_OUT.getPreferredName(), this.retentionTimedOut);
TimeValue retentionTime = TimeValue.timeValueMillis(this.retentionTimeMs);
builder.field(RETENTION_TIME.getPreferredName(), retentionTime);
builder.field(RETENTION_TIME_MILLIS.getPreferredName(), retentionTime.millis());
Map<String, SnapshotPolicyStats> metrics = getMetrics();
long totalTaken = metrics.values().stream().mapToLong(s -> s.snapshotsTaken).sum();
long totalFailed = metrics.values().stream().mapToLong(s -> s.snapshotsFailed).sum();
long totalDeleted = metrics.values().stream().mapToLong(s -> s.snapshotsDeleted).sum();
long totalDeleteFailures = metrics.values().stream().mapToLong(s -> s.snapshotDeleteFailures).sum();
builder.field(TOTAL_TAKEN.getPreferredName(), totalTaken);
builder.field(TOTAL_FAILED.getPreferredName(), totalFailed);
builder.field(TOTAL_DELETIONS.getPreferredName(), totalDeleted);
builder.field(TOTAL_DELETION_FAILURES.getPreferredName(), totalDeleteFailures);
builder.startObject(POLICY_STATS.getPreferredName());
for (Map.Entry<String, SnapshotPolicyStats> policy : metrics.entrySet()) {
SnapshotPolicyStats perPolicyMetrics = policy.getValue();
builder.startObject(perPolicyMetrics.policyId);
perPolicyMetrics.toXContent(builder, params);
builder.endObject();
}
builder.endObject();
builder.endObject();
return builder;
}
@Override
public int hashCode() {
return Objects.hash(retentionRunCount, retentionFailedCount, retentionTimedOut, retentionTimeMs, policyStats);
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj.getClass() != getClass()) {
return false;
}
SnapshotLifecycleStats other = (SnapshotLifecycleStats) obj;
return retentionRunCount == other.retentionRunCount &&
retentionFailedCount == other.retentionFailedCount &&
retentionTimedOut == other.retentionTimedOut &&
retentionTimeMs == other.retentionTimeMs &&
Objects.equals(policyStats, other.policyStats);
}
@Override
public String toString() {
return Strings.toString(this);
}
public static class SnapshotPolicyStats implements ToXContentFragment {
private final String policyId;
private final long snapshotsTaken;
private final long snapshotsFailed;
private final long snapshotsDeleted;
private final long snapshotDeleteFailures;
static final ParseField SNAPSHOTS_TAKEN = new ParseField("snapshots_taken");
static final ParseField SNAPSHOTS_FAILED = new ParseField("snapshots_failed");
static final ParseField SNAPSHOTS_DELETED = new ParseField("snapshots_deleted");
static final ParseField SNAPSHOT_DELETION_FAILURES = new ParseField("snapshot_deletion_failures");
private static final ConstructingObjectParser<SnapshotPolicyStats, String> PARSER =
new ConstructingObjectParser<>("snapshot_policy_stats", true,
(a, id) -> {
long taken = (long) a[0];
long failed = (long) a[1];
long deleted = (long) a[2];
long deleteFailed = (long) a[3];
return new SnapshotPolicyStats(id, taken, failed, deleted, deleteFailed);
});
static {
PARSER.declareLong(ConstructingObjectParser.constructorArg(), SNAPSHOTS_TAKEN);
PARSER.declareLong(ConstructingObjectParser.constructorArg(), SNAPSHOTS_FAILED);
PARSER.declareLong(ConstructingObjectParser.constructorArg(), SNAPSHOTS_DELETED);
PARSER.declareLong(ConstructingObjectParser.constructorArg(), SNAPSHOT_DELETION_FAILURES);
}
public SnapshotPolicyStats(String policyId, long snapshotsTaken, long snapshotsFailed, long deleted, long failedDeletes) {
this.policyId = policyId;
this.snapshotsTaken = snapshotsTaken;
this.snapshotsFailed = snapshotsFailed;
this.snapshotsDeleted = deleted;
this.snapshotDeleteFailures = failedDeletes;
}
public static SnapshotPolicyStats parse(XContentParser parser, String policyId) {
return PARSER.apply(parser, policyId);
}
public long getSnapshotsTaken() {
return snapshotsTaken;
}
public long getSnapshotsFailed() {
return snapshotsFailed;
}
public long getSnapshotsDeleted() {
return snapshotsDeleted;
}
public long getSnapshotDeleteFailures() {
return snapshotDeleteFailures;
}
@Override
public int hashCode() {
return Objects.hash(policyId, snapshotsTaken, snapshotsFailed, snapshotsDeleted, snapshotDeleteFailures);
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj.getClass() != getClass()) {
return false;
}
SnapshotPolicyStats other = (SnapshotPolicyStats) obj;
return Objects.equals(policyId, other.policyId) &&
snapshotsTaken == other.snapshotsTaken &&
snapshotsFailed == other.snapshotsFailed &&
snapshotsDeleted == other.snapshotsDeleted &&
snapshotDeleteFailures == other.snapshotDeleteFailures;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(SnapshotPolicyStats.SNAPSHOTS_TAKEN.getPreferredName(), snapshotsTaken);
builder.field(SnapshotPolicyStats.SNAPSHOTS_FAILED.getPreferredName(), snapshotsFailed);
builder.field(SnapshotPolicyStats.SNAPSHOTS_DELETED.getPreferredName(), snapshotsDeleted);
builder.field(SnapshotPolicyStats.SNAPSHOT_DELETION_FAILURES.getPreferredName(), snapshotDeleteFailures);
return builder;
}
}
}

View File

@ -0,0 +1,133 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you 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.
*/
package org.elasticsearch.client.slm;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
import java.util.Objects;
public class SnapshotRetentionConfiguration implements ToXContentObject {
public static final SnapshotRetentionConfiguration EMPTY = new SnapshotRetentionConfiguration(null, null, null);
private static final ParseField EXPIRE_AFTER = new ParseField("expire_after");
private static final ParseField MINIMUM_SNAPSHOT_COUNT = new ParseField("min_count");
private static final ParseField MAXIMUM_SNAPSHOT_COUNT = new ParseField("max_count");
private static final ConstructingObjectParser<SnapshotRetentionConfiguration, Void> PARSER =
new ConstructingObjectParser<>("snapshot_retention", true, a -> {
TimeValue expireAfter = a[0] == null ? null : TimeValue.parseTimeValue((String) a[0], EXPIRE_AFTER.getPreferredName());
Integer minCount = (Integer) a[1];
Integer maxCount = (Integer) a[2];
return new SnapshotRetentionConfiguration(expireAfter, minCount, maxCount);
});
static {
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), EXPIRE_AFTER);
PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), MINIMUM_SNAPSHOT_COUNT);
PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), MAXIMUM_SNAPSHOT_COUNT);
}
private final TimeValue expireAfter;
private final Integer minimumSnapshotCount;
private final Integer maximumSnapshotCount;
public SnapshotRetentionConfiguration(@Nullable TimeValue expireAfter,
@Nullable Integer minimumSnapshotCount,
@Nullable Integer maximumSnapshotCount) {
this.expireAfter = expireAfter;
this.minimumSnapshotCount = minimumSnapshotCount;
this.maximumSnapshotCount = maximumSnapshotCount;
if (this.minimumSnapshotCount != null && this.minimumSnapshotCount < 1) {
throw new IllegalArgumentException("minimum snapshot count must be at least 1, but was: " + this.minimumSnapshotCount);
}
if (this.maximumSnapshotCount != null && this.maximumSnapshotCount < 1) {
throw new IllegalArgumentException("maximum snapshot count must be at least 1, but was: " + this.maximumSnapshotCount);
}
if ((maximumSnapshotCount != null && minimumSnapshotCount != null) && this.minimumSnapshotCount > this.maximumSnapshotCount) {
throw new IllegalArgumentException("minimum snapshot count " + this.minimumSnapshotCount +
" cannot be larger than maximum snapshot count " + this.maximumSnapshotCount);
}
}
public static SnapshotRetentionConfiguration parse(XContentParser parser, String name) {
return PARSER.apply(parser, null);
}
public TimeValue getExpireAfter() {
return this.expireAfter;
}
public Integer getMinimumSnapshotCount() {
return this.minimumSnapshotCount;
}
public Integer getMaximumSnapshotCount() {
return this.maximumSnapshotCount;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
if (expireAfter != null) {
builder.field(EXPIRE_AFTER.getPreferredName(), expireAfter.getStringRep());
}
if (minimumSnapshotCount != null) {
builder.field(MINIMUM_SNAPSHOT_COUNT.getPreferredName(), minimumSnapshotCount);
}
if (maximumSnapshotCount != null) {
builder.field(MAXIMUM_SNAPSHOT_COUNT.getPreferredName(), maximumSnapshotCount);
}
builder.endObject();
return builder;
}
@Override
public int hashCode() {
return Objects.hash(expireAfter, minimumSnapshotCount, maximumSnapshotCount);
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj.getClass() != getClass()) {
return false;
}
SnapshotRetentionConfiguration other = (SnapshotRetentionConfiguration) obj;
return Objects.equals(this.expireAfter, other.expireAfter) &&
Objects.equals(minimumSnapshotCount, other.minimumSnapshotCount) &&
Objects.equals(maximumSnapshotCount, other.maximumSnapshotCount);
}
@Override
public String toString() {
return Strings.toString(this);
}
}

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.TaskOperationFailure;

View File

@ -17,10 +17,10 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.client.dataframe.transforms.SyncConfig;
import org.elasticsearch.client.dataframe.transforms.TimeSyncConfig;
import org.elasticsearch.client.transform.transforms.SyncConfig;
import org.elasticsearch.client.transform.transforms.TimeSyncConfig;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.plugins.spi.NamedXContentProvider;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.client.Validatable;
import org.elasticsearch.client.ValidationException;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.client.Validatable;
import org.elasticsearch.client.ValidationException;

View File

@ -17,9 +17,9 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.client.dataframe.transforms.DataFrameTransformConfig;
import org.elasticsearch.client.transform.transforms.DataFrameTransformConfig;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.client.Validatable;
import org.elasticsearch.client.ValidationException;

View File

@ -17,11 +17,11 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.TaskOperationFailure;
import org.elasticsearch.client.dataframe.transforms.DataFrameTransformStats;
import org.elasticsearch.client.transform.transforms.DataFrameTransformStats;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;

View File

@ -17,11 +17,11 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.client.Validatable;
import org.elasticsearch.client.ValidationException;
import org.elasticsearch.client.dataframe.transforms.DataFrameTransformConfig;
import org.elasticsearch.client.transform.transforms.DataFrameTransformConfig;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.common.xcontent.XContentParser;

View File

@ -17,11 +17,11 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.client.Validatable;
import org.elasticsearch.client.ValidationException;
import org.elasticsearch.client.dataframe.transforms.DataFrameTransformConfig;
import org.elasticsearch.client.transform.transforms.DataFrameTransformConfig;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.client.Validatable;
import org.elasticsearch.client.ValidationException;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.TaskOperationFailure;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.client.Validatable;
import org.elasticsearch.client.ValidationException;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.TaskOperationFailure;

View File

@ -17,11 +17,11 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.client.Validatable;
import org.elasticsearch.client.ValidationException;
import org.elasticsearch.client.dataframe.transforms.DataFrameTransformConfigUpdate;
import org.elasticsearch.client.transform.transforms.DataFrameTransformConfigUpdate;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;

View File

@ -17,9 +17,9 @@
* under the License.
*/
package org.elasticsearch.client.dataframe;
package org.elasticsearch.client.transform;
import org.elasticsearch.client.dataframe.transforms.DataFrameTransformConfig;
import org.elasticsearch.client.transform.transforms.DataFrameTransformConfig;
import org.elasticsearch.common.xcontent.XContentParser;
import java.util.Objects;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms;
package org.elasticsearch.client.transform.transforms;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms;
package org.elasticsearch.client.transform.transforms;
import org.elasticsearch.client.core.IndexerJobStats;
import org.elasticsearch.common.ParseField;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms;
package org.elasticsearch.client.transform.transforms;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;

View File

@ -17,9 +17,9 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms;
package org.elasticsearch.client.transform.transforms;
import org.elasticsearch.client.dataframe.transforms.util.TimeUtil;
import org.elasticsearch.client.transform.transforms.util.TimeUtil;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;

View File

@ -17,11 +17,11 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms;
package org.elasticsearch.client.transform.transforms;
import org.elasticsearch.Version;
import org.elasticsearch.client.dataframe.transforms.pivot.PivotConfig;
import org.elasticsearch.client.dataframe.transforms.util.TimeUtil;
import org.elasticsearch.client.transform.transforms.pivot.PivotConfig;
import org.elasticsearch.client.transform.transforms.util.TimeUtil;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms;
package org.elasticsearch.client.transform.transforms;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms;
package org.elasticsearch.client.transform.transforms;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms;
package org.elasticsearch.client.transform.transforms;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms;
package org.elasticsearch.client.transform.transforms;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms;
package org.elasticsearch.client.transform.transforms;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms;
package org.elasticsearch.client.transform.transforms;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms;
package org.elasticsearch.client.transform.transforms;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms;
package org.elasticsearch.client.transform.transforms;
import org.elasticsearch.common.xcontent.ToXContentObject;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms;
package org.elasticsearch.client.transform.transforms;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.unit.TimeValue;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms.pivot;
package org.elasticsearch.client.transform.transforms.pivot;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms.pivot;
package org.elasticsearch.client.transform.transforms.pivot;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms.pivot;
package org.elasticsearch.client.transform.transforms.pivot;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.Strings;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms.pivot;
package org.elasticsearch.client.transform.transforms.pivot;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms.pivot;
package org.elasticsearch.client.transform.transforms.pivot;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.client.dataframe.transforms.pivot;
package org.elasticsearch.client.transform.transforms.pivot;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.ToXContentObject;

Some files were not shown because too many files have changed in this diff Show More