mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 23:27:25 -04:00
Reformat Elasticsearch source
This commit is contained in:
parent
4e09186b3d
commit
12ad399c48
10457 changed files with 436577 additions and 281860 deletions
|
@ -60,7 +60,7 @@ public class FormattingPrecommitPlugin implements Plugin<Project> {
|
|||
formatterConfigPath = "../" + formatterConfigPath;
|
||||
}
|
||||
|
||||
java.target(getTargets(project.getPath()));
|
||||
java.target("src/**/*.java");
|
||||
|
||||
// Use `@formatter:off` and `@formatter:on` to toggle formatting - ONLY IF STRICTLY NECESSARY
|
||||
java.toggleOffOn("@formatter:off", "@formatter:on");
|
||||
|
@ -83,259 +83,11 @@ public class FormattingPrecommitPlugin implements Plugin<Project> {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("CheckStyle")
|
||||
private Object[] getTargets(String projectPath) {
|
||||
if (projectPath.equals(":server")) {
|
||||
return new String[] {
|
||||
"src/*/java/org/elasticsearch/action/admin/cluster/repositories/**/*.java",
|
||||
"src/*/java/org/elasticsearch/action/admin/cluster/snapshots/**/*.java",
|
||||
"src/test/java/org/elasticsearch/common/xcontent/support/XContentMapValuesTests.java",
|
||||
"src/*/java/org/elasticsearch/index/IndexMode.java",
|
||||
"src/*/java/org/elasticsearch/index/IndexRouting.java",
|
||||
"src/*/java/org/elasticsearch/index/TimeSeriesModeTests.java",
|
||||
"src/*/java/org/elasticsearch/index/snapshots/**/*.java",
|
||||
"src/*/java/org/elasticsearch/repositories/**/*.java",
|
||||
"src/*/java/org/elasticsearch/search/aggregations/**/*.java",
|
||||
"src/*/java/org/elasticsearch/snapshots/**/*.java" };
|
||||
} else if (projectPath.equals(":test:framework")) {
|
||||
return new String[] {
|
||||
"src/test/java/org/elasticsearch/common/xcontent/support/AbstractFilteringTestCase.java",
|
||||
};
|
||||
} else {
|
||||
// Normally this isn"t necessary, but we have Java sources in
|
||||
// non-standard places
|
||||
return new String[] { "src/**/*.java" };
|
||||
}
|
||||
}
|
||||
|
||||
// Do not add new sub-projects here!
|
||||
private static final List<String> PROJECT_PATHS_TO_EXCLUDE = List.of(
|
||||
":client:benchmark",
|
||||
":client:client-benchmark-noop-api-plugin",
|
||||
":client:rest",
|
||||
":client:rest-high-level",
|
||||
":client:rest-high-level:qa:ssl-enabled",
|
||||
":client:sniffer",
|
||||
":client:test",
|
||||
":distribution:archives:integ-test-zip",
|
||||
":distribution:bwc:bugfix",
|
||||
":distribution:bwc:maintenance",
|
||||
":distribution:bwc:minor",
|
||||
":distribution:bwc:staged",
|
||||
":distribution:docker",
|
||||
":docs",
|
||||
":example-plugins:custom-settings",
|
||||
":example-plugins:custom-significance-heuristic",
|
||||
":example-plugins:custom-suggester",
|
||||
":example-plugins:painless-whitelist",
|
||||
":example-plugins:rescore",
|
||||
":example-plugins:rest-handler",
|
||||
":example-plugins:script-expert-scoring",
|
||||
":example-plugins:security-authorization-engine",
|
||||
":libs:elasticsearch-cli",
|
||||
":libs:elasticsearch-core",
|
||||
":libs:elasticsearch-dissect",
|
||||
":libs:elasticsearch-geo",
|
||||
":libs:elasticsearch-grok",
|
||||
":libs:elasticsearch-lz4",
|
||||
":libs:elasticsearch-nio",
|
||||
":libs:elasticsearch-plugin-classloader",
|
||||
":libs:elasticsearch-secure-sm",
|
||||
":libs:elasticsearch-ssl-config",
|
||||
":libs:elasticsearch-x-content",
|
||||
":modules:analysis-common",
|
||||
":modules:ingest-common",
|
||||
":modules:ingest-geoip",
|
||||
":modules:ingest-geoip:qa:file-based-update",
|
||||
":modules:ingest-user-agent",
|
||||
":modules:lang-expression",
|
||||
":modules:lang-mustache",
|
||||
":modules:lang-painless",
|
||||
":modules:lang-painless:spi",
|
||||
":modules:mapper-extras",
|
||||
":modules:parent-join",
|
||||
":modules:percolator",
|
||||
":modules:rank-eval",
|
||||
":modules:reindex",
|
||||
":modules:repository-url",
|
||||
":modules:systemd",
|
||||
":modules:tasks",
|
||||
":modules:transport-netty4",
|
||||
":plugins:analysis-icu",
|
||||
":plugins:analysis-kuromoji",
|
||||
":plugins:analysis-nori",
|
||||
":plugins:analysis-phonetic",
|
||||
":plugins:analysis-smartcn",
|
||||
":plugins:analysis-stempel",
|
||||
":plugins:analysis-ukrainian",
|
||||
":plugins:discovery-azure-classic",
|
||||
":plugins:discovery-ec2",
|
||||
":plugins:discovery-ec2:qa:amazon-ec2",
|
||||
":plugins:discovery-gce",
|
||||
":plugins:discovery-gce:qa:gce",
|
||||
":plugins:ingest-attachment",
|
||||
":plugins:mapper-annotated-text",
|
||||
":plugins:mapper-murmur3",
|
||||
":plugins:mapper-size",
|
||||
":plugins:repository-azure",
|
||||
":plugins:repository-gcs",
|
||||
":plugins:repository-hdfs",
|
||||
":plugins:repository-hdfs:hadoop-common",
|
||||
":plugins:repository-s3",
|
||||
":plugins:store-smb",
|
||||
":plugins:transport-nio",
|
||||
":qa:ccs-rolling-upgrade-remote-cluster",
|
||||
":qa:ccs-unavailable-clusters",
|
||||
":qa:die-with-dignity",
|
||||
":qa:evil-tests",
|
||||
":qa:full-cluster-restart",
|
||||
":qa:logging-config",
|
||||
":qa:mixed-cluster",
|
||||
":qa:multi-cluster-search",
|
||||
":qa:no-bootstrap-tests",
|
||||
":qa:remote-clusters",
|
||||
":qa:repository-multi-version",
|
||||
":qa:rolling-upgrade",
|
||||
":qa:smoke-test-http",
|
||||
":qa:smoke-test-ingest-with-all-dependencies",
|
||||
":qa:smoke-test-multinode",
|
||||
":qa:smoke-test-plugins",
|
||||
":qa:snapshot-based-recoveries",
|
||||
":qa:snapshot-based-recoveries:azure",
|
||||
":qa:snapshot-based-recoveries:fs",
|
||||
":qa:snapshot-based-recoveries:gcs",
|
||||
":qa:snapshot-based-recoveries:s3",
|
||||
":qa:verify-version-constants",
|
||||
":rest-api-spec",
|
||||
":test:fixtures:geoip-fixture",
|
||||
":test:fixtures:krb5kdc-fixture",
|
||||
":test:fixtures:old-elasticsearch",
|
||||
":test:logger-usage",
|
||||
":x-pack:docs",
|
||||
":x-pack:license-tools",
|
||||
":x-pack:plugin",
|
||||
":x-pack:plugin:async-search",
|
||||
":x-pack:plugin:async-search:qa",
|
||||
":x-pack:plugin:async-search:qa:security",
|
||||
":x-pack:plugin:autoscaling:qa:rest",
|
||||
":x-pack:plugin:ccr",
|
||||
":x-pack:plugin:ccr:qa",
|
||||
":x-pack:plugin:ccr:qa:downgrade-to-basic-license",
|
||||
":x-pack:plugin:ccr:qa:multi-cluster",
|
||||
":x-pack:plugin:ccr:qa:non-compliant-license",
|
||||
":x-pack:plugin:ccr:qa:rest",
|
||||
":x-pack:plugin:ccr:qa:restart",
|
||||
":x-pack:plugin:ccr:qa:security",
|
||||
":x-pack:plugin:core",
|
||||
":x-pack:plugin:data-streams:qa:multi-node",
|
||||
":x-pack:plugin:data-streams:qa:rest",
|
||||
":x-pack:plugin:deprecation",
|
||||
":x-pack:plugin:enrich:qa:common",
|
||||
":x-pack:plugin:enrich:qa:rest",
|
||||
":x-pack:plugin:enrich:qa:rest-with-advanced-security",
|
||||
":x-pack:plugin:enrich:qa:rest-with-security",
|
||||
":x-pack:plugin:eql",
|
||||
":x-pack:plugin:eql:qa",
|
||||
":x-pack:plugin:eql:qa:common",
|
||||
":x-pack:plugin:eql:qa:mixed-node",
|
||||
":x-pack:plugin:eql:qa:multi-cluster-with-security",
|
||||
":x-pack:plugin:eql:qa:rest",
|
||||
":x-pack:plugin:eql:qa:security",
|
||||
":x-pack:plugin:fleet:qa:rest",
|
||||
":x-pack:plugin:graph",
|
||||
":x-pack:plugin:graph:qa:with-security",
|
||||
":x-pack:plugin:identity-provider",
|
||||
":x-pack:plugin:identity-provider:qa:idp-rest-tests",
|
||||
":x-pack:plugin:ilm",
|
||||
":x-pack:plugin:ilm:qa:multi-cluster",
|
||||
":x-pack:plugin:ilm:qa:multi-node",
|
||||
":x-pack:plugin:ilm:qa:rest",
|
||||
":x-pack:plugin:ilm:qa:with-security",
|
||||
":x-pack:plugin:mapper-constant-keyword",
|
||||
":x-pack:plugin:mapper-flattened",
|
||||
":x-pack:plugin:ml",
|
||||
":x-pack:plugin:ml:qa:basic-multi-node",
|
||||
":x-pack:plugin:ml:qa:disabled",
|
||||
":x-pack:plugin:ml:qa:ml-with-security",
|
||||
":x-pack:plugin:ml:qa:native-multi-node-tests",
|
||||
":x-pack:plugin:ml:qa:no-bootstrap-tests",
|
||||
":x-pack:plugin:ml:qa:single-node-tests",
|
||||
":x-pack:plugin:monitoring",
|
||||
":x-pack:plugin:ql",
|
||||
":x-pack:plugin:repository-encrypted:qa:azure",
|
||||
":x-pack:plugin:repository-encrypted:qa:gcs",
|
||||
":x-pack:plugin:repository-encrypted:qa:s3",
|
||||
":x-pack:plugin:rollup:qa:rest",
|
||||
":x-pack:plugin:search-business-rules",
|
||||
":x-pack:plugin:searchable-snapshots:qa:rest",
|
||||
":x-pack:plugin:security",
|
||||
":x-pack:plugin:security:cli",
|
||||
":x-pack:plugin:security:qa:basic-enable-security",
|
||||
":x-pack:plugin:security:qa:security-basic",
|
||||
":x-pack:plugin:security:qa:security-disabled",
|
||||
":x-pack:plugin:security:qa:security-not-enabled",
|
||||
":x-pack:plugin:security:qa:security-trial",
|
||||
":x-pack:plugin:security:qa:service-account",
|
||||
":x-pack:plugin:security:qa:smoke-test-all-realms",
|
||||
":x-pack:plugin:security:qa:tls-basic",
|
||||
":x-pack:plugin:shutdown:qa:multi-node",
|
||||
":x-pack:plugin:snapshot-repo-test-kit:qa:rest",
|
||||
":x-pack:plugin:spatial",
|
||||
":x-pack:plugin:sql",
|
||||
":x-pack:plugin:sql:jdbc",
|
||||
":x-pack:plugin:sql:qa",
|
||||
":x-pack:plugin:sql:qa:jdbc",
|
||||
":x-pack:plugin:sql:qa:jdbc:security",
|
||||
":x-pack:plugin:sql:qa:mixed-node",
|
||||
":x-pack:plugin:sql:qa:security",
|
||||
":x-pack:plugin:sql:qa:server:multi-node",
|
||||
":x-pack:plugin:sql:qa:server:single-node",
|
||||
":x-pack:plugin:sql:sql-action",
|
||||
":x-pack:plugin:sql:sql-cli",
|
||||
":x-pack:plugin:sql:sql-client",
|
||||
":x-pack:plugin:sql:sql-proto",
|
||||
":x-pack:plugin:stack:qa:rest",
|
||||
":x-pack:plugin:text-structure:qa:text-structure-with-security",
|
||||
":x-pack:plugin:transform",
|
||||
":x-pack:plugin:transform:qa:multi-cluster-tests-with-security",
|
||||
":x-pack:plugin:transform:qa:multi-node-tests",
|
||||
":x-pack:plugin:transform:qa:single-node-tests",
|
||||
":x-pack:plugin:vector-tile:qa:multi-cluster",
|
||||
":x-pack:plugin:vectors",
|
||||
":x-pack:plugin:watcher",
|
||||
":x-pack:plugin:watcher:qa:rest",
|
||||
":x-pack:plugin:watcher:qa:with-monitoring",
|
||||
":x-pack:plugin:watcher:qa:with-security",
|
||||
":x-pack:plugin:wildcard",
|
||||
":x-pack:qa",
|
||||
":x-pack:qa:core-rest-tests-with-security",
|
||||
":x-pack:qa:evil-tests",
|
||||
":x-pack:qa:full-cluster-restart",
|
||||
":x-pack:qa:kerberos-tests",
|
||||
":x-pack:qa:mixed-tier-cluster",
|
||||
":x-pack:qa:multi-cluster-search-security",
|
||||
":x-pack:qa:multi-node",
|
||||
":x-pack:qa:oidc-op-tests",
|
||||
":x-pack:qa:openldap-tests",
|
||||
":x-pack:qa:password-protected-keystore",
|
||||
":x-pack:qa:reindex-tests-with-security",
|
||||
":x-pack:qa:rolling-upgrade",
|
||||
":x-pack:qa:rolling-upgrade-multi-cluster",
|
||||
":x-pack:qa:runtime-fields:core-with-mapped",
|
||||
":x-pack:qa:runtime-fields:core-with-search",
|
||||
":x-pack:qa:runtime-fields:with-security",
|
||||
":x-pack:qa:saml-idp-tests",
|
||||
":x-pack:qa:security-example-spi-extension",
|
||||
":x-pack:qa:security-setup-password-tests",
|
||||
":x-pack:qa:security-tools-tests",
|
||||
":x-pack:qa:smoke-test-plugins",
|
||||
":x-pack:qa:smoke-test-plugins-ssl",
|
||||
":x-pack:qa:smoke-test-security-with-mustache",
|
||||
":x-pack:qa:third-party:active-directory",
|
||||
":x-pack:qa:third-party:jira",
|
||||
":x-pack:qa:third-party:pagerduty",
|
||||
":x-pack:qa:third-party:slack",
|
||||
":x-pack:test:idp-fixture",
|
||||
":x-pack:test:smb-fixture"
|
||||
":distribution:bwc:staged"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -53,8 +53,7 @@ public abstract class AbstractBenchmark<T extends Closeable> {
|
|||
@SuppressForbidden(reason = "system out is ok for a command line tool")
|
||||
private void runBulkIndexBenchmark(String[] args) throws Exception {
|
||||
if (args.length != 7) {
|
||||
System.err.println(
|
||||
"usage: 'bulk' benchmarkTargetHostIp indexFilePath indexName typeName numberOfDocuments bulkSize");
|
||||
System.err.println("usage: 'bulk' benchmarkTargetHostIp indexFilePath indexName typeName numberOfDocuments bulkSize");
|
||||
System.exit(1);
|
||||
}
|
||||
String benchmarkTargetHost = args[1];
|
||||
|
@ -71,9 +70,11 @@ public abstract class AbstractBenchmark<T extends Closeable> {
|
|||
|
||||
T client = client(benchmarkTargetHost);
|
||||
|
||||
BenchmarkRunner benchmark = new BenchmarkRunner(warmupIterations, iterations,
|
||||
new BulkBenchmarkTask(
|
||||
bulkRequestExecutor(client, indexName, typeName), indexFilePath, warmupIterations, iterations, bulkSize));
|
||||
BenchmarkRunner benchmark = new BenchmarkRunner(
|
||||
warmupIterations,
|
||||
iterations,
|
||||
new BulkBenchmarkTask(bulkRequestExecutor(client, indexName, typeName), indexFilePath, warmupIterations, iterations, bulkSize)
|
||||
);
|
||||
|
||||
try {
|
||||
runTrials(() -> {
|
||||
|
@ -89,8 +90,7 @@ public abstract class AbstractBenchmark<T extends Closeable> {
|
|||
@SuppressForbidden(reason = "system out is ok for a command line tool")
|
||||
private void runSearchBenchmark(String[] args) throws Exception {
|
||||
if (args.length != 5) {
|
||||
System.err.println(
|
||||
"usage: 'search' benchmarkTargetHostIp indexName searchRequestBody throughputRates");
|
||||
System.err.println("usage: 'search' benchmarkTargetHostIp indexName searchRequestBody throughputRates");
|
||||
System.exit(1);
|
||||
}
|
||||
String benchmarkTargetHost = args[1];
|
||||
|
@ -105,10 +105,17 @@ public abstract class AbstractBenchmark<T extends Closeable> {
|
|||
for (int throughput : throughputRates) {
|
||||
// GC between trials to reduce the likelihood of a GC occurring in the middle of a trial.
|
||||
runGc();
|
||||
BenchmarkRunner benchmark = new BenchmarkRunner(SEARCH_BENCHMARK_ITERATIONS, SEARCH_BENCHMARK_ITERATIONS,
|
||||
BenchmarkRunner benchmark = new BenchmarkRunner(
|
||||
SEARCH_BENCHMARK_ITERATIONS,
|
||||
SEARCH_BENCHMARK_ITERATIONS,
|
||||
new SearchBenchmarkTask(
|
||||
searchRequestExecutor(client, indexName), searchBody, SEARCH_BENCHMARK_ITERATIONS,
|
||||
SEARCH_BENCHMARK_ITERATIONS, throughput));
|
||||
searchRequestExecutor(client, indexName),
|
||||
searchBody,
|
||||
SEARCH_BENCHMARK_ITERATIONS,
|
||||
SEARCH_BENCHMARK_ITERATIONS,
|
||||
throughput
|
||||
)
|
||||
);
|
||||
System.out.printf("Target throughput = %d ops / s%n", throughput);
|
||||
benchmark.run();
|
||||
}
|
||||
|
|
|
@ -31,8 +31,12 @@ public final class BenchmarkRunner {
|
|||
@SuppressForbidden(reason = "system out is ok for a command line tool")
|
||||
public void run() {
|
||||
SampleRecorder recorder = new SampleRecorder(iterations);
|
||||
System.out.printf("Running %s with %d warmup iterations and %d iterations.%n",
|
||||
task.getClass().getSimpleName(), warmupIterations, iterations);
|
||||
System.out.printf(
|
||||
"Running %s with %d warmup iterations and %d iterations.%n",
|
||||
task.getClass().getSimpleName(),
|
||||
warmupIterations,
|
||||
iterations
|
||||
);
|
||||
|
||||
try {
|
||||
task.setUp(recorder);
|
||||
|
@ -54,14 +58,26 @@ public final class BenchmarkRunner {
|
|||
|
||||
for (Metrics metrics : summaryMetrics) {
|
||||
String throughput = String.format(Locale.ROOT, "Throughput [ops/s]: %f", metrics.throughput);
|
||||
String serviceTimes = String.format(Locale.ROOT,
|
||||
String serviceTimes = String.format(
|
||||
Locale.ROOT,
|
||||
"Service time [ms]: p50 = %f, p90 = %f, p95 = %f, p99 = %f, p99.9 = %f, p99.99 = %f",
|
||||
metrics.serviceTimeP50, metrics.serviceTimeP90, metrics.serviceTimeP95,
|
||||
metrics.serviceTimeP99, metrics.serviceTimeP999, metrics.serviceTimeP9999);
|
||||
String latencies = String.format(Locale.ROOT,
|
||||
metrics.serviceTimeP50,
|
||||
metrics.serviceTimeP90,
|
||||
metrics.serviceTimeP95,
|
||||
metrics.serviceTimeP99,
|
||||
metrics.serviceTimeP999,
|
||||
metrics.serviceTimeP9999
|
||||
);
|
||||
String latencies = String.format(
|
||||
Locale.ROOT,
|
||||
"Latency [ms]: p50 = %f, p90 = %f, p95 = %f, p99 = %f, p99.9 = %f, p99.99 = %f",
|
||||
metrics.latencyP50, metrics.latencyP90, metrics.latencyP95,
|
||||
metrics.latencyP99, metrics.latencyP999, metrics.latencyP9999);
|
||||
metrics.latencyP50,
|
||||
metrics.latencyP90,
|
||||
metrics.latencyP95,
|
||||
metrics.latencyP99,
|
||||
metrics.latencyP999,
|
||||
metrics.latencyP9999
|
||||
);
|
||||
|
||||
int lineLength = Math.max(serviceTimes.length(), latencies.length());
|
||||
|
||||
|
|
|
@ -25,10 +25,24 @@ public final class Metrics {
|
|||
public final double latencyP999;
|
||||
public final double latencyP9999;
|
||||
|
||||
public Metrics(String operation, long successCount, long errorCount, double throughput,
|
||||
double serviceTimeP50, double serviceTimeP90, double serviceTimeP95, double serviceTimeP99,
|
||||
double serviceTimeP999, double serviceTimeP9999, double latencyP50, double latencyP90,
|
||||
double latencyP95, double latencyP99, double latencyP999, double latencyP9999) {
|
||||
public Metrics(
|
||||
String operation,
|
||||
long successCount,
|
||||
long errorCount,
|
||||
double throughput,
|
||||
double serviceTimeP50,
|
||||
double serviceTimeP90,
|
||||
double serviceTimeP95,
|
||||
double serviceTimeP99,
|
||||
double serviceTimeP999,
|
||||
double serviceTimeP9999,
|
||||
double latencyP50,
|
||||
double latencyP90,
|
||||
double latencyP95,
|
||||
double latencyP99,
|
||||
double latencyP999,
|
||||
double latencyP9999
|
||||
) {
|
||||
this.operation = operation;
|
||||
this.successCount = successCount;
|
||||
this.errorCount = errorCount;
|
||||
|
|
|
@ -51,7 +51,9 @@ public final class MetricsCalculator {
|
|||
it++;
|
||||
}
|
||||
|
||||
metrics.add(new Metrics(operationAndMetrics.getKey(),
|
||||
metrics.add(
|
||||
new Metrics(
|
||||
operationAndMetrics.getKey(),
|
||||
samples.stream().filter((r) -> r.isSuccess()).count(),
|
||||
samples.stream().filter((r) -> r.isSuccess() == false).count(),
|
||||
// throughput calculation is based on the total (Wall clock) time it took to generate all samples
|
||||
|
@ -68,7 +70,9 @@ public final class MetricsCalculator {
|
|||
StatUtils.percentile(latencies, 95.0d) / TimeUnit.MILLISECONDS.toNanos(1L),
|
||||
StatUtils.percentile(latencies, 99.0d) / TimeUnit.MILLISECONDS.toNanos(1L),
|
||||
StatUtils.percentile(latencies, 99.9d) / TimeUnit.MILLISECONDS.toNanos(1L),
|
||||
StatUtils.percentile(latencies, 99.99d) / TimeUnit.MILLISECONDS.toNanos(1L)));
|
||||
StatUtils.percentile(latencies, 99.99d) / TimeUnit.MILLISECONDS.toNanos(1L)
|
||||
)
|
||||
);
|
||||
}
|
||||
return metrics;
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
*/
|
||||
package org.elasticsearch.client.benchmark.ops.bulk;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.client.benchmark.BenchmarkTask;
|
||||
import org.elasticsearch.client.benchmark.metrics.Sample;
|
||||
import org.elasticsearch.client.benchmark.metrics.SampleRecorder;
|
||||
import org.elasticsearch.core.SuppressForbidden;
|
||||
import org.elasticsearch.core.PathUtils;
|
||||
import org.elasticsearch.core.SuppressForbidden;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
@ -38,8 +38,13 @@ public class BulkBenchmarkTask implements BenchmarkTask {
|
|||
private LoadGenerator generator;
|
||||
private ExecutorService executorService;
|
||||
|
||||
public BulkBenchmarkTask(BulkRequestExecutor requestExecutor, String indexFilePath, int warmupIterations, int measurementIterations,
|
||||
int bulkSize) {
|
||||
public BulkBenchmarkTask(
|
||||
BulkRequestExecutor requestExecutor,
|
||||
String indexFilePath,
|
||||
int warmupIterations,
|
||||
int measurementIterations,
|
||||
int bulkSize
|
||||
) {
|
||||
this.requestExecutor = requestExecutor;
|
||||
this.indexFilePath = indexFilePath;
|
||||
this.warmupIterations = warmupIterations;
|
||||
|
@ -122,7 +127,6 @@ public class BulkBenchmarkTask implements BenchmarkTask {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static final class BulkIndexer implements Runnable {
|
||||
private static final Logger logger = LogManager.getLogger(BulkIndexer.class);
|
||||
|
||||
|
@ -132,8 +136,13 @@ public class BulkBenchmarkTask implements BenchmarkTask {
|
|||
private final BulkRequestExecutor bulkRequestExecutor;
|
||||
private final SampleRecorder sampleRecorder;
|
||||
|
||||
BulkIndexer(BlockingQueue<List<String>> bulkData, int warmupIterations, int measurementIterations,
|
||||
SampleRecorder sampleRecorder, BulkRequestExecutor bulkRequestExecutor) {
|
||||
BulkIndexer(
|
||||
BlockingQueue<List<String>> bulkData,
|
||||
int warmupIterations,
|
||||
int measurementIterations,
|
||||
SampleRecorder sampleRecorder,
|
||||
BulkRequestExecutor bulkRequestExecutor
|
||||
) {
|
||||
this.bulkData = bulkData;
|
||||
this.warmupIterations = warmupIterations;
|
||||
this.measurementIterations = measurementIterations;
|
||||
|
|
|
@ -22,8 +22,13 @@ public class SearchBenchmarkTask implements BenchmarkTask {
|
|||
|
||||
private SampleRecorder sampleRecorder;
|
||||
|
||||
public SearchBenchmarkTask(SearchRequestExecutor searchRequestExecutor, String body, int warmupIterations,
|
||||
int measurementIterations, int targetThroughput) {
|
||||
public SearchBenchmarkTask(
|
||||
SearchRequestExecutor searchRequestExecutor,
|
||||
String body,
|
||||
int warmupIterations,
|
||||
int measurementIterations,
|
||||
int targetThroughput
|
||||
) {
|
||||
this.searchRequestExecutor = searchRequestExecutor;
|
||||
this.searchRequestBody = body;
|
||||
this.warmupIterations = warmupIterations;
|
||||
|
|
|
@ -32,10 +32,10 @@ public final class RestClientBenchmark extends AbstractBenchmark<RestClient> {
|
|||
|
||||
@Override
|
||||
protected RestClient client(String benchmarkTargetHost) {
|
||||
return RestClient
|
||||
.builder(new HttpHost(benchmarkTargetHost, 9200))
|
||||
.setHttpClientConfigCallback(b -> b.setDefaultHeaders(
|
||||
Collections.singleton(new BasicHeader(HttpHeaders.ACCEPT_ENCODING, "gzip"))))
|
||||
return RestClient.builder(new HttpHost(benchmarkTargetHost, 9200))
|
||||
.setHttpClientConfigCallback(
|
||||
b -> b.setDefaultHeaders(Collections.singleton(new BasicHeader(HttpHeaders.ACCEPT_ENCODING, "gzip")))
|
||||
)
|
||||
.setRequestConfigCallback(b -> b.setContentCompressionEnabled(true))
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
*/
|
||||
package org.elasticsearch.plugin.noop;
|
||||
|
||||
import org.elasticsearch.plugin.noop.action.bulk.NoopBulkAction;
|
||||
import org.elasticsearch.plugin.noop.action.bulk.RestNoopBulkAction;
|
||||
import org.elasticsearch.plugin.noop.action.bulk.TransportNoopBulkAction;
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
|
@ -18,6 +15,9 @@ import org.elasticsearch.common.settings.ClusterSettings;
|
|||
import org.elasticsearch.common.settings.IndexScopedSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
import org.elasticsearch.plugin.noop.action.bulk.NoopBulkAction;
|
||||
import org.elasticsearch.plugin.noop.action.bulk.RestNoopBulkAction;
|
||||
import org.elasticsearch.plugin.noop.action.bulk.TransportNoopBulkAction;
|
||||
import org.elasticsearch.plugin.noop.action.search.NoopSearchAction;
|
||||
import org.elasticsearch.plugin.noop.action.search.RestNoopSearchAction;
|
||||
import org.elasticsearch.plugin.noop.action.search.TransportNoopSearchAction;
|
||||
|
@ -40,11 +40,15 @@ public class NoopPlugin extends Plugin implements ActionPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<RestHandler> getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings,
|
||||
IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver,
|
||||
Supplier<DiscoveryNodes> nodesInCluster) {
|
||||
return Arrays.asList(
|
||||
new RestNoopBulkAction(),
|
||||
new RestNoopSearchAction());
|
||||
public List<RestHandler> getRestHandlers(
|
||||
Settings settings,
|
||||
RestController restController,
|
||||
ClusterSettings clusterSettings,
|
||||
IndexScopedSettings indexScopedSettings,
|
||||
SettingsFilter settingsFilter,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver,
|
||||
Supplier<DiscoveryNodes> nodesInCluster
|
||||
) {
|
||||
return Arrays.asList(new RestNoopBulkAction(), new RestNoopSearchAction());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.elasticsearch.action.support.ActiveShardCount;
|
|||
import org.elasticsearch.action.update.UpdateResponse;
|
||||
import org.elasticsearch.client.Requests;
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.BytesRestResponse;
|
||||
|
@ -24,6 +23,7 @@ import org.elasticsearch.rest.RestChannel;
|
|||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.RestResponse;
|
||||
import org.elasticsearch.rest.action.RestBuilderListener;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
@ -40,7 +40,8 @@ public class RestNoopBulkAction extends BaseRestHandler {
|
|||
new Route(POST, "/_noop_bulk"),
|
||||
new Route(PUT, "/_noop_bulk"),
|
||||
new Route(POST, "/{index}/_noop_bulk"),
|
||||
new Route(PUT, "/{index}/_noop_bulk"));
|
||||
new Route(PUT, "/{index}/_noop_bulk")
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,9 +63,17 @@ public class RestNoopBulkAction extends BaseRestHandler {
|
|||
}
|
||||
bulkRequest.timeout(request.paramAsTime("timeout", BulkShardRequest.DEFAULT_TIMEOUT));
|
||||
bulkRequest.setRefreshPolicy(request.param("refresh"));
|
||||
bulkRequest.add(request.requiredContent(), defaultIndex, defaultRouting,
|
||||
null, defaultPipeline, defaultRequireAlias, true, request.getXContentType(),
|
||||
request.getRestApiVersion());
|
||||
bulkRequest.add(
|
||||
request.requiredContent(),
|
||||
defaultIndex,
|
||||
defaultRouting,
|
||||
null,
|
||||
defaultPipeline,
|
||||
defaultRequireAlias,
|
||||
true,
|
||||
request.getXContentType(),
|
||||
request.getRestApiVersion()
|
||||
);
|
||||
|
||||
// short circuit the call to the transport layer
|
||||
return channel -> {
|
||||
|
@ -74,12 +83,14 @@ public class RestNoopBulkAction extends BaseRestHandler {
|
|||
}
|
||||
|
||||
private static class BulkRestBuilderListener extends RestBuilderListener<BulkRequest> {
|
||||
private final BulkItemResponse ITEM_RESPONSE = BulkItemResponse.success(1, DocWriteRequest.OpType.UPDATE,
|
||||
new UpdateResponse(new ShardId("mock", "", 1), "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED));
|
||||
private final BulkItemResponse ITEM_RESPONSE = BulkItemResponse.success(
|
||||
1,
|
||||
DocWriteRequest.OpType.UPDATE,
|
||||
new UpdateResponse(new ShardId("mock", "", 1), "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED)
|
||||
);
|
||||
|
||||
private final RestRequest request;
|
||||
|
||||
|
||||
BulkRestBuilderListener(RestChannel channel, RestRequest request) {
|
||||
super(channel);
|
||||
this.request = request;
|
||||
|
|
|
@ -22,8 +22,11 @@ import org.elasticsearch.tasks.Task;
|
|||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
public class TransportNoopBulkAction extends HandledTransportAction<BulkRequest, BulkResponse> {
|
||||
private static final BulkItemResponse ITEM_RESPONSE = BulkItemResponse.success(1, DocWriteRequest.OpType.UPDATE,
|
||||
new UpdateResponse(new ShardId("mock", "", 1), "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED));
|
||||
private static final BulkItemResponse ITEM_RESPONSE = BulkItemResponse.success(
|
||||
1,
|
||||
DocWriteRequest.OpType.UPDATE,
|
||||
new UpdateResponse(new ShardId("mock", "", 1), "1", 0L, 1L, 1L, DocWriteResponse.Result.CREATED)
|
||||
);
|
||||
|
||||
@Inject
|
||||
public TransportNoopBulkAction(TransportService transportService, ActionFilters actionFilters) {
|
||||
|
|
|
@ -26,7 +26,8 @@ public class RestNoopSearchAction extends BaseRestHandler {
|
|||
new Route(GET, "/_noop_search"),
|
||||
new Route(POST, "/_noop_search"),
|
||||
new Route(GET, "/{index}/_noop_search"),
|
||||
new Route(POST, "/{index}/_noop_search"));
|
||||
new Route(POST, "/{index}/_noop_search")
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,12 +35,25 @@ public class TransportNoopSearchAction extends HandledTransportAction<SearchRequ
|
|||
|
||||
@Override
|
||||
protected void doExecute(Task task, SearchRequest request, ActionListener<SearchResponse> listener) {
|
||||
listener.onResponse(new SearchResponse(new InternalSearchResponse(
|
||||
new SearchHits(
|
||||
new SearchHit[0], new TotalHits(0L, TotalHits.Relation.EQUAL_TO), 0.0f),
|
||||
listener.onResponse(
|
||||
new SearchResponse(
|
||||
new InternalSearchResponse(
|
||||
new SearchHits(new SearchHit[0], new TotalHits(0L, TotalHits.Relation.EQUAL_TO), 0.0f),
|
||||
InternalAggregations.EMPTY,
|
||||
new Suggest(Collections.emptyList()),
|
||||
new SearchProfileResults(Collections.emptyMap()), false, false, 1),
|
||||
"", 1, 1, 0, 0, ShardSearchFailure.EMPTY_ARRAY, SearchResponse.Clusters.EMPTY));
|
||||
new SearchProfileResults(Collections.emptyMap()),
|
||||
false,
|
||||
false,
|
||||
1
|
||||
),
|
||||
"",
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
ShardSearchFailure.EMPTY_ARRAY,
|
||||
SearchResponse.Clusters.EMPTY
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,8 +71,11 @@ public class EnrollmentIT extends ESRestHighLevelClientTestCase {
|
|||
}
|
||||
|
||||
public void testEnrollNode() throws Exception {
|
||||
final NodeEnrollmentResponse nodeEnrollmentResponse =
|
||||
execute(highLevelClient().security()::enrollNode, highLevelClient().security()::enrollNodeAsync, RequestOptions.DEFAULT);
|
||||
final NodeEnrollmentResponse nodeEnrollmentResponse = execute(
|
||||
highLevelClient().security()::enrollNode,
|
||||
highLevelClient().security()::enrollNodeAsync,
|
||||
RequestOptions.DEFAULT
|
||||
);
|
||||
assertThat(nodeEnrollmentResponse, notNullValue());
|
||||
assertThat(nodeEnrollmentResponse.getHttpCaKey(), endsWith("K2S3vidA="));
|
||||
assertThat(nodeEnrollmentResponse.getHttpCaCert(), endsWith("LfkRjirc="));
|
||||
|
@ -84,11 +87,16 @@ public class EnrollmentIT extends ESRestHighLevelClientTestCase {
|
|||
}
|
||||
|
||||
public void testEnrollKibana() throws Exception {
|
||||
KibanaEnrollmentResponse kibanaResponse =
|
||||
execute(highLevelClient().security()::enrollKibana, highLevelClient().security()::enrollKibanaAsync, RequestOptions.DEFAULT);
|
||||
KibanaEnrollmentResponse kibanaResponse = execute(
|
||||
highLevelClient().security()::enrollKibana,
|
||||
highLevelClient().security()::enrollKibanaAsync,
|
||||
RequestOptions.DEFAULT
|
||||
);
|
||||
assertThat(kibanaResponse, notNullValue());
|
||||
assertThat(kibanaResponse.getHttpCa()
|
||||
, endsWith("brcNC5xq6YE7C4/06nH7F6le4kE4Uo6c9fpkl4ehOxQxndNLn462tFF+8VBA8IftJ1PPWzqGxLsCTzM6p6w8sa+XhgNYglLfkRjirc="));
|
||||
assertThat(
|
||||
kibanaResponse.getHttpCa(),
|
||||
endsWith("brcNC5xq6YE7C4/06nH7F6le4kE4Uo6c9fpkl4ehOxQxndNLn462tFF+8VBA8IftJ1PPWzqGxLsCTzM6p6w8sa+XhgNYglLfkRjirc=")
|
||||
);
|
||||
assertNotNull(kibanaResponse.getTokenValue());
|
||||
assertNotNull(kibanaResponse.getTokenName(), startsWith("enroll-process-token-"));
|
||||
}
|
||||
|
|
|
@ -42,8 +42,13 @@ public class AsyncSearchClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AsyncSearchResponse submit(SubmitAsyncSearchRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, AsyncSearchRequestConverters::submitAsyncSearch, options,
|
||||
AsyncSearchResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
AsyncSearchRequestConverters::submitAsyncSearch,
|
||||
options,
|
||||
AsyncSearchResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,10 +61,15 @@ public class AsyncSearchClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable submitAsync(SubmitAsyncSearchRequest request, RequestOptions options,
|
||||
ActionListener<AsyncSearchResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, AsyncSearchRequestConverters::submitAsyncSearch, options,
|
||||
AsyncSearchResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable submitAsync(SubmitAsyncSearchRequest request, RequestOptions options, ActionListener<AsyncSearchResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
AsyncSearchRequestConverters::submitAsyncSearch,
|
||||
options,
|
||||
AsyncSearchResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,8 +78,13 @@ public class AsyncSearchClient {
|
|||
*
|
||||
*/
|
||||
public AsyncSearchResponse get(GetAsyncSearchRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, AsyncSearchRequestConverters::getAsyncSearch, options,
|
||||
AsyncSearchResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
AsyncSearchRequestConverters::getAsyncSearch,
|
||||
options,
|
||||
AsyncSearchResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,10 +95,15 @@ public class AsyncSearchClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getAsync(GetAsyncSearchRequest request, RequestOptions options,
|
||||
ActionListener<AsyncSearchResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, AsyncSearchRequestConverters::getAsyncSearch, options,
|
||||
AsyncSearchResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable getAsync(GetAsyncSearchRequest request, RequestOptions options, ActionListener<AsyncSearchResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
AsyncSearchRequestConverters::getAsyncSearch,
|
||||
options,
|
||||
AsyncSearchResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,8 +115,13 @@ public class AsyncSearchClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse delete(DeleteAsyncSearchRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, AsyncSearchRequestConverters::deleteAsyncSearch, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
AsyncSearchRequestConverters::deleteAsyncSearch,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,10 +132,19 @@ public class AsyncSearchClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deleteAsync(DeleteAsyncSearchRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, AsyncSearchRequestConverters::deleteAsyncSearch, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable deleteAsync(
|
||||
DeleteAsyncSearchRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
AsyncSearchRequestConverters::deleteAsyncSearch,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ import static org.elasticsearch.client.RequestConverters.REQUEST_BODY_CONTENT_TY
|
|||
final class AsyncSearchRequestConverters {
|
||||
|
||||
static Request submitAsyncSearch(SubmitAsyncSearchRequest asyncSearchRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addCommaSeparatedPathParts(
|
||||
asyncSearchRequest.getIndices())
|
||||
.addPathPartAsIs("_async_search").build();
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addCommaSeparatedPathParts(asyncSearchRequest.getIndices())
|
||||
.addPathPartAsIs("_async_search")
|
||||
.build();
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
Params params = new RequestConverters.Params();
|
||||
// add all typical search params and search request source as body
|
||||
|
@ -71,8 +71,7 @@ final class AsyncSearchRequestConverters {
|
|||
}
|
||||
|
||||
static Request getAsyncSearch(GetAsyncSearchRequest asyncSearchRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_async_search")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_async_search")
|
||||
.addPathPart(asyncSearchRequest.getId())
|
||||
.build();
|
||||
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
|
@ -89,8 +88,7 @@ final class AsyncSearchRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteAsyncSearch(DeleteAsyncSearchRequest deleteAsyncSearchRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_async_search")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_async_search")
|
||||
.addPathPart(deleteAsyncSearchRequest.getId())
|
||||
.build();
|
||||
return new Request(HttpDelete.METHOD_NAME, endpoint);
|
||||
|
|
|
@ -87,9 +87,7 @@ public final class CcrClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable putFollowAsync(PutFollowRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<PutFollowResponse> listener) {
|
||||
public Cancellable putFollowAsync(PutFollowRequest request, RequestOptions options, ActionListener<PutFollowResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::putFollow,
|
||||
|
@ -131,16 +129,15 @@ public final class CcrClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable pauseFollowAsync(PauseFollowRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
public Cancellable pauseFollowAsync(PauseFollowRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::pauseFollow,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,16 +171,19 @@ public final class CcrClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable resumeFollowAsync(ResumeFollowRequest request,
|
||||
public Cancellable resumeFollowAsync(
|
||||
ResumeFollowRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::resumeFollow,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -219,9 +219,7 @@ public final class CcrClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable unfollowAsync(UnfollowRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
public Cancellable unfollowAsync(UnfollowRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::unfollow,
|
||||
|
@ -249,7 +247,8 @@ public final class CcrClient {
|
|||
CcrRequestConverters::forgetFollower,
|
||||
options,
|
||||
BroadcastResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -264,14 +263,16 @@ public final class CcrClient {
|
|||
public Cancellable forgetFollowerAsync(
|
||||
final ForgetFollowerRequest request,
|
||||
final RequestOptions options,
|
||||
final ActionListener<BroadcastResponse> listener) {
|
||||
final ActionListener<BroadcastResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::forgetFollower,
|
||||
options,
|
||||
BroadcastResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -305,16 +306,19 @@ public final class CcrClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable putAutoFollowPatternAsync(PutAutoFollowPatternRequest request,
|
||||
public Cancellable putAutoFollowPatternAsync(
|
||||
PutAutoFollowPatternRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::putAutoFollowPattern,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -328,8 +332,7 @@ public final class CcrClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse deleteAutoFollowPattern(DeleteAutoFollowPatternRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
public AcknowledgedResponse deleteAutoFollowPattern(DeleteAutoFollowPatternRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::deleteAutoFollowPattern,
|
||||
|
@ -349,9 +352,11 @@ public final class CcrClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deleteAutoFollowPatternAsync(DeleteAutoFollowPatternRequest request,
|
||||
public Cancellable deleteAutoFollowPatternAsync(
|
||||
DeleteAutoFollowPatternRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::deleteAutoFollowPattern,
|
||||
|
@ -373,8 +378,8 @@ public final class CcrClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetAutoFollowPatternResponse getAutoFollowPattern(GetAutoFollowPatternRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
public GetAutoFollowPatternResponse getAutoFollowPattern(GetAutoFollowPatternRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::getAutoFollowPattern,
|
||||
|
@ -394,9 +399,11 @@ public final class CcrClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getAutoFollowPatternAsync(GetAutoFollowPatternRequest request,
|
||||
public Cancellable getAutoFollowPatternAsync(
|
||||
GetAutoFollowPatternRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<GetAutoFollowPatternResponse> listener) {
|
||||
ActionListener<GetAutoFollowPatternResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::getAutoFollowPattern,
|
||||
|
@ -438,16 +445,19 @@ public final class CcrClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable pauseAutoFollowPatternAsync(PauseAutoFollowPatternRequest request,
|
||||
public Cancellable pauseAutoFollowPatternAsync(
|
||||
PauseAutoFollowPatternRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::pauseAutoFollowPattern,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -481,16 +491,19 @@ public final class CcrClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable resumeAutoFollowPatternAsync(ResumeAutoFollowPatternRequest request,
|
||||
public Cancellable resumeAutoFollowPatternAsync(
|
||||
ResumeAutoFollowPatternRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::resumeAutoFollowPattern,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -504,8 +517,7 @@ public final class CcrClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public CcrStatsResponse getCcrStats(CcrStatsRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
public CcrStatsResponse getCcrStats(CcrStatsRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::getCcrStats,
|
||||
|
@ -524,9 +536,7 @@ public final class CcrClient {
|
|||
* @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 Cancellable getCcrStatsAsync(CcrStatsRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<CcrStatsResponse> listener) {
|
||||
public Cancellable getCcrStatsAsync(CcrStatsRequest request, RequestOptions options, ActionListener<CcrStatsResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::getCcrStats,
|
||||
|
@ -548,8 +558,7 @@ public final class CcrClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public FollowStatsResponse getFollowStats(FollowStatsRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
public FollowStatsResponse getFollowStats(FollowStatsRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::getFollowStats,
|
||||
|
@ -568,9 +577,11 @@ public final class CcrClient {
|
|||
* @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 Cancellable getFollowStatsAsync(FollowStatsRequest request,
|
||||
public Cancellable getFollowStatsAsync(
|
||||
FollowStatsRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<FollowStatsResponse> listener) {
|
||||
ActionListener<FollowStatsResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::getFollowStats,
|
||||
|
@ -611,9 +622,7 @@ public final class CcrClient {
|
|||
* @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 Cancellable getFollowInfoAsync(FollowInfoRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<FollowInfoResponse> listener) {
|
||||
public Cancellable getFollowInfoAsync(FollowInfoRequest request, RequestOptions options, ActionListener<FollowInfoResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
CcrRequestConverters::getFollowInfo,
|
||||
|
|
|
@ -34,8 +34,7 @@ import static org.elasticsearch.client.RequestConverters.createEntity;
|
|||
final class CcrRequestConverters {
|
||||
|
||||
static Request putFollow(PutFollowRequest putFollowRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPart(putFollowRequest.getFollowerIndex())
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPart(putFollowRequest.getFollowerIndex())
|
||||
.addPathPartAsIs("_ccr", "follow")
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
@ -47,16 +46,14 @@ final class CcrRequestConverters {
|
|||
}
|
||||
|
||||
static Request pauseFollow(PauseFollowRequest pauseFollowRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPart(pauseFollowRequest.getFollowerIndex())
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPart(pauseFollowRequest.getFollowerIndex())
|
||||
.addPathPartAsIs("_ccr", "pause_follow")
|
||||
.build();
|
||||
return new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request resumeFollow(ResumeFollowRequest resumeFollowRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPart(resumeFollowRequest.getFollowerIndex())
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPart(resumeFollowRequest.getFollowerIndex())
|
||||
.addPathPartAsIs("_ccr", "resume_follow")
|
||||
.build();
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
|
@ -65,16 +62,14 @@ final class CcrRequestConverters {
|
|||
}
|
||||
|
||||
static Request unfollow(UnfollowRequest unfollowRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPart(unfollowRequest.getFollowerIndex())
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPart(unfollowRequest.getFollowerIndex())
|
||||
.addPathPartAsIs("_ccr", "unfollow")
|
||||
.build();
|
||||
return new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request forgetFollower(final ForgetFollowerRequest forgetFollowerRequest) throws IOException {
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPart(forgetFollowerRequest.leaderIndex())
|
||||
final String endpoint = new RequestConverters.EndpointBuilder().addPathPart(forgetFollowerRequest.leaderIndex())
|
||||
.addPathPartAsIs("_ccr")
|
||||
.addPathPartAsIs("forget_follower")
|
||||
.build();
|
||||
|
@ -84,8 +79,7 @@ final class CcrRequestConverters {
|
|||
}
|
||||
|
||||
static Request putAutoFollowPattern(PutAutoFollowPatternRequest putAutoFollowPatternRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ccr", "auto_follow")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_ccr", "auto_follow")
|
||||
.addPathPart(putAutoFollowPatternRequest.getName())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
@ -94,24 +88,21 @@ final class CcrRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteAutoFollowPattern(DeleteAutoFollowPatternRequest deleteAutoFollowPatternRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ccr", "auto_follow")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_ccr", "auto_follow")
|
||||
.addPathPart(deleteAutoFollowPatternRequest.getName())
|
||||
.build();
|
||||
return new Request(HttpDelete.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request getAutoFollowPattern(GetAutoFollowPatternRequest getAutoFollowPatternRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ccr", "auto_follow")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_ccr", "auto_follow")
|
||||
.addPathPart(getAutoFollowPatternRequest.getName())
|
||||
.build();
|
||||
return new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request pauseAutoFollowPattern(PauseAutoFollowPatternRequest pauseAutoFollowPatternRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ccr", "auto_follow")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_ccr", "auto_follow")
|
||||
.addPathPart(pauseAutoFollowPatternRequest.getName())
|
||||
.addPathPartAsIs("pause")
|
||||
.build();
|
||||
|
@ -119,8 +110,7 @@ final class CcrRequestConverters {
|
|||
}
|
||||
|
||||
static Request resumeAutoFollowPattern(ResumeAutoFollowPatternRequest resumeAutoFollowPatternRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ccr", "auto_follow")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_ccr", "auto_follow")
|
||||
.addPathPart(resumeAutoFollowPatternRequest.getName())
|
||||
.addPathPartAsIs("resume")
|
||||
.build();
|
||||
|
@ -128,23 +118,19 @@ final class CcrRequestConverters {
|
|||
}
|
||||
|
||||
static Request getCcrStats(CcrStatsRequest ccrStatsRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ccr", "stats")
|
||||
.build();
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_ccr", "stats").build();
|
||||
return new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request getFollowStats(FollowStatsRequest followStatsRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPart(followStatsRequest.getFollowerIndex())
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPart(followStatsRequest.getFollowerIndex())
|
||||
.addPathPartAsIs("_ccr", "stats")
|
||||
.build();
|
||||
return new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request getFollowInfo(FollowInfoRequest followInfoRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPart(followInfoRequest.getFollowerIndex())
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPart(followInfoRequest.getFollowerIndex())
|
||||
.addPathPartAsIs("_ccr", "info")
|
||||
.build();
|
||||
return new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
|
|
|
@ -59,8 +59,13 @@ public final class ClusterClient {
|
|||
*/
|
||||
public ClusterUpdateSettingsResponse putSettings(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(clusterUpdateSettingsRequest, ClusterRequestConverters::clusterPutSettings,
|
||||
options, ClusterUpdateSettingsResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
clusterUpdateSettingsRequest,
|
||||
ClusterRequestConverters::clusterPutSettings,
|
||||
options,
|
||||
ClusterUpdateSettingsResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,11 +77,19 @@ public final class ClusterClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable putSettingsAsync(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, RequestOptions options,
|
||||
ActionListener<ClusterUpdateSettingsResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(clusterUpdateSettingsRequest,
|
||||
public Cancellable putSettingsAsync(
|
||||
ClusterUpdateSettingsRequest clusterUpdateSettingsRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<ClusterUpdateSettingsResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
clusterUpdateSettingsRequest,
|
||||
ClusterRequestConverters::clusterPutSettings,
|
||||
options, ClusterUpdateSettingsResponse::fromXContent, listener, emptySet());
|
||||
options,
|
||||
ClusterUpdateSettingsResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,8 +103,13 @@ public final class ClusterClient {
|
|||
*/
|
||||
public ClusterGetSettingsResponse getSettings(ClusterGetSettingsRequest clusterGetSettingsRequest, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(clusterGetSettingsRequest, ClusterRequestConverters::clusterGetSettings,
|
||||
options, ClusterGetSettingsResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
clusterGetSettingsRequest,
|
||||
ClusterRequestConverters::clusterGetSettings,
|
||||
options,
|
||||
ClusterGetSettingsResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,11 +121,19 @@ public final class ClusterClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getSettingsAsync(ClusterGetSettingsRequest clusterGetSettingsRequest, RequestOptions options,
|
||||
ActionListener<ClusterGetSettingsResponse> listener) {
|
||||
public Cancellable getSettingsAsync(
|
||||
ClusterGetSettingsRequest clusterGetSettingsRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<ClusterGetSettingsResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
clusterGetSettingsRequest, ClusterRequestConverters::clusterGetSettings,
|
||||
options, ClusterGetSettingsResponse::fromXContent, listener, emptySet());
|
||||
clusterGetSettingsRequest,
|
||||
ClusterRequestConverters::clusterGetSettings,
|
||||
options,
|
||||
ClusterGetSettingsResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,8 +148,13 @@ public final class ClusterClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public ClusterHealthResponse health(ClusterHealthRequest healthRequest, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(healthRequest, ClusterRequestConverters::clusterHealth, options,
|
||||
ClusterHealthResponse::fromXContent, singleton(RestStatus.REQUEST_TIMEOUT.getStatus()));
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
healthRequest,
|
||||
ClusterRequestConverters::clusterHealth,
|
||||
options,
|
||||
ClusterHealthResponse::fromXContent,
|
||||
singleton(RestStatus.REQUEST_TIMEOUT.getStatus())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,10 +167,19 @@ public final class ClusterClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
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()));
|
||||
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())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -152,8 +192,13 @@ public final class ClusterClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public RemoteInfoResponse remoteInfo(RemoteInfoRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, ClusterRequestConverters::remoteInfo, options,
|
||||
RemoteInfoResponse::fromXContent, singleton(RestStatus.REQUEST_TIMEOUT.getStatus()));
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
ClusterRequestConverters::remoteInfo,
|
||||
options,
|
||||
RemoteInfoResponse::fromXContent,
|
||||
singleton(RestStatus.REQUEST_TIMEOUT.getStatus())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,10 +210,15 @@ public final class ClusterClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable remoteInfoAsync(RemoteInfoRequest request, RequestOptions options,
|
||||
ActionListener<RemoteInfoResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, ClusterRequestConverters::remoteInfo, options,
|
||||
RemoteInfoResponse::fromXContent, listener, singleton(RestStatus.REQUEST_TIMEOUT.getStatus()));
|
||||
public Cancellable remoteInfoAsync(RemoteInfoRequest request, RequestOptions options, ActionListener<RemoteInfoResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
ClusterRequestConverters::remoteInfo,
|
||||
options,
|
||||
RemoteInfoResponse::fromXContent,
|
||||
listener,
|
||||
singleton(RestStatus.REQUEST_TIMEOUT.getStatus())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,8 +229,13 @@ public final class ClusterClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse deleteComponentTemplate(DeleteComponentTemplateRequest req, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(req, ClusterRequestConverters::deleteComponentTemplate,
|
||||
options, AcknowledgedResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
req,
|
||||
ClusterRequestConverters::deleteComponentTemplate,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -191,10 +246,19 @@ public final class ClusterClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deleteComponentTemplateAsync(DeleteComponentTemplateRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, ClusterRequestConverters::deleteComponentTemplate,
|
||||
options, AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable deleteComponentTemplateAsync(
|
||||
DeleteComponentTemplateRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
ClusterRequestConverters::deleteComponentTemplate,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -205,10 +269,15 @@ public final class ClusterClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse putComponentTemplate(PutComponentTemplateRequest putComponentTemplateRequest,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(putComponentTemplateRequest, ClusterRequestConverters::putComponentTemplate,
|
||||
options, AcknowledgedResponse::fromXContent, emptySet());
|
||||
public AcknowledgedResponse putComponentTemplate(PutComponentTemplateRequest putComponentTemplateRequest, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
putComponentTemplateRequest,
|
||||
ClusterRequestConverters::putComponentTemplate,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -219,10 +288,19 @@ public final class ClusterClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable putComponentTemplateAsync(PutComponentTemplateRequest putComponentTemplateRequest,
|
||||
RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(putComponentTemplateRequest,
|
||||
ClusterRequestConverters::putComponentTemplate, options, AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable putComponentTemplateAsync(
|
||||
PutComponentTemplateRequest putComponentTemplateRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
putComponentTemplateRequest,
|
||||
ClusterRequestConverters::putComponentTemplate,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -232,10 +310,17 @@ public final class ClusterClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetComponentTemplatesResponse getComponentTemplate(GetComponentTemplatesRequest getComponentTemplatesRequest,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(getComponentTemplatesRequest,
|
||||
ClusterRequestConverters::getComponentTemplates, options, GetComponentTemplatesResponse::fromXContent, emptySet());
|
||||
public GetComponentTemplatesResponse getComponentTemplate(
|
||||
GetComponentTemplatesRequest getComponentTemplatesRequest,
|
||||
RequestOptions options
|
||||
) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
getComponentTemplatesRequest,
|
||||
ClusterRequestConverters::getComponentTemplates,
|
||||
options,
|
||||
GetComponentTemplatesResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -245,10 +330,19 @@ public final class ClusterClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getComponentTemplateAsync(GetComponentTemplatesRequest getComponentTemplatesRequest, RequestOptions options,
|
||||
ActionListener<GetComponentTemplatesResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(getComponentTemplatesRequest,
|
||||
ClusterRequestConverters::getComponentTemplates, options, GetComponentTemplatesResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable getComponentTemplateAsync(
|
||||
GetComponentTemplatesRequest getComponentTemplatesRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<GetComponentTemplatesResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
getComponentTemplatesRequest,
|
||||
ClusterRequestConverters::getComponentTemplates,
|
||||
options,
|
||||
GetComponentTemplatesResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -259,10 +353,15 @@ public final class ClusterClient {
|
|||
* @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 existsComponentTemplate(ComponentTemplatesExistRequest componentTemplatesRequest,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequest(componentTemplatesRequest,
|
||||
ClusterRequestConverters::componentTemplatesExist, options, RestHighLevelClient::convertExistsResponse, emptySet());
|
||||
public boolean existsComponentTemplate(ComponentTemplatesExistRequest componentTemplatesRequest, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequest(
|
||||
componentTemplatesRequest,
|
||||
ClusterRequestConverters::componentTemplatesExist,
|
||||
options,
|
||||
RestHighLevelClient::convertExistsResponse,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -272,11 +371,19 @@ public final class ClusterClient {
|
|||
* @param listener the listener to be notified upon request completion. The listener will be called with the value {@code true}
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable existsComponentTemplateAsync(ComponentTemplatesExistRequest componentTemplatesRequest,
|
||||
public Cancellable existsComponentTemplateAsync(
|
||||
ComponentTemplatesExistRequest componentTemplatesRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<Boolean> listener) {
|
||||
ActionListener<Boolean> listener
|
||||
) {
|
||||
|
||||
return restHighLevelClient.performRequestAsync(componentTemplatesRequest,
|
||||
ClusterRequestConverters::componentTemplatesExist, options, RestHighLevelClient::convertExistsResponse, listener, emptySet());
|
||||
return restHighLevelClient.performRequestAsync(
|
||||
componentTemplatesRequest,
|
||||
ClusterRequestConverters::componentTemplatesExist,
|
||||
options,
|
||||
RestHighLevelClient::convertExistsResponse,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,14 +52,12 @@ final class ClusterRequestConverters {
|
|||
|
||||
static Request clusterHealth(ClusterHealthRequest healthRequest) {
|
||||
String[] indices = healthRequest.indices() == null ? Strings.EMPTY_ARRAY : healthRequest.indices();
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_cluster/health")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_cluster/health")
|
||||
.addCommaSeparatedPathParts(indices)
|
||||
.build();
|
||||
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
|
||||
RequestConverters.Params params = new RequestConverters.Params()
|
||||
.withWaitForStatus(healthRequest.waitForStatus())
|
||||
RequestConverters.Params params = new RequestConverters.Params().withWaitForStatus(healthRequest.waitForStatus())
|
||||
.withWaitForNoRelocatingShards(healthRequest.waitForNoRelocatingShards())
|
||||
.withWaitForNoInitializingShards(healthRequest.waitForNoInitializingShards())
|
||||
.withWaitForActiveShards(healthRequest.waitForActiveShards(), ActiveShardCount.NONE)
|
||||
|
@ -79,7 +77,8 @@ final class ClusterRequestConverters {
|
|||
|
||||
static Request putComponentTemplate(PutComponentTemplateRequest putComponentTemplateRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_component_template")
|
||||
.addPathPart(putComponentTemplateRequest.name()).build();
|
||||
.addPathPart(putComponentTemplateRequest.name())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(putComponentTemplateRequest.masterNodeTimeout());
|
||||
|
@ -95,8 +94,7 @@ final class ClusterRequestConverters {
|
|||
}
|
||||
|
||||
static Request getComponentTemplates(GetComponentTemplatesRequest getComponentTemplatesRequest) {
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_component_template")
|
||||
final String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_component_template")
|
||||
.addPathPart(getComponentTemplatesRequest.name())
|
||||
.build();
|
||||
final Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
|
@ -108,8 +106,7 @@ final class ClusterRequestConverters {
|
|||
}
|
||||
|
||||
static Request componentTemplatesExist(ComponentTemplatesExistRequest componentTemplatesRequest) {
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_component_template")
|
||||
final String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_component_template")
|
||||
.addPathPart(componentTemplatesRequest.name())
|
||||
.build();
|
||||
final Request request = new Request(HttpHead.METHOD_NAME, endpoint);
|
||||
|
|
|
@ -74,9 +74,7 @@ public final class EnrichClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable putPolicyAsync(PutPolicyRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
public Cancellable putPolicyAsync(PutPolicyRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
EnrichRequestConverters::putPolicy,
|
||||
|
@ -119,9 +117,11 @@ public final class EnrichClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deletePolicyAsync(DeletePolicyRequest request,
|
||||
public Cancellable deletePolicyAsync(
|
||||
DeletePolicyRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
EnrichRequestConverters::deletePolicy,
|
||||
|
@ -164,9 +164,7 @@ public final class EnrichClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getPolicyAsync(GetPolicyRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<GetPolicyResponse> listener) {
|
||||
public Cancellable getPolicyAsync(GetPolicyRequest request, RequestOptions options, ActionListener<GetPolicyResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
EnrichRequestConverters::getPolicy,
|
||||
|
@ -209,9 +207,7 @@ public final class EnrichClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable statsAsync(StatsRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<StatsResponse> listener) {
|
||||
public Cancellable statsAsync(StatsRequest request, RequestOptions options, ActionListener<StatsResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
EnrichRequestConverters::stats,
|
||||
|
@ -254,9 +250,11 @@ public final class EnrichClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable executePolicyAsync(ExecutePolicyRequest request,
|
||||
public Cancellable executePolicyAsync(
|
||||
ExecutePolicyRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<ExecutePolicyResponse> listener) {
|
||||
ActionListener<ExecutePolicyResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
EnrichRequestConverters::executePolicy,
|
||||
|
|
|
@ -25,8 +25,7 @@ import static org.elasticsearch.client.RequestConverters.createEntity;
|
|||
final class EnrichRequestConverters {
|
||||
|
||||
static Request putPolicy(PutPolicyRequest putPolicyRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_enrich", "policy")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_enrich", "policy")
|
||||
.addPathPart(putPolicyRequest.getName())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
@ -35,31 +34,26 @@ final class EnrichRequestConverters {
|
|||
}
|
||||
|
||||
static Request deletePolicy(DeletePolicyRequest deletePolicyRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_enrich", "policy")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_enrich", "policy")
|
||||
.addPathPart(deletePolicyRequest.getName())
|
||||
.build();
|
||||
return new Request(HttpDelete.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request getPolicy(GetPolicyRequest getPolicyRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_enrich", "policy")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_enrich", "policy")
|
||||
.addCommaSeparatedPathParts(getPolicyRequest.getNames())
|
||||
.build();
|
||||
return new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request stats(StatsRequest statsRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_enrich", "_stats")
|
||||
.build();
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_enrich", "_stats").build();
|
||||
return new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request executePolicy(ExecutePolicyRequest executePolicyRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_enrich", "policy")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_enrich", "policy")
|
||||
.addPathPart(executePolicyRequest.getName())
|
||||
.addPathPartAsIs("_execute")
|
||||
.build();
|
||||
|
|
|
@ -70,9 +70,7 @@ public final class EqlClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable searchAsync(EqlSearchRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<EqlSearchResponse> listener) {
|
||||
public Cancellable searchAsync(EqlSearchRequest request, RequestOptions options, ActionListener<EqlSearchResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
EqlRequestConverters::search,
|
||||
|
@ -112,7 +110,8 @@ public final class EqlClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable statsAsync(EqlStatsRequest request, RequestOptions options, ActionListener<EqlStatsResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
EqlRequestConverters::stats,
|
||||
options,
|
||||
EqlStatsResponse::fromXContent,
|
||||
|
|
|
@ -20,8 +20,7 @@ import static org.elasticsearch.client.RequestConverters.createEntity;
|
|||
final class EqlRequestConverters {
|
||||
|
||||
static Request search(EqlSearchRequest eqlSearchRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addCommaSeparatedPathParts(eqlSearchRequest.indices())
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addCommaSeparatedPathParts(eqlSearchRequest.indices())
|
||||
.addPathPartAsIs("_eql", "search")
|
||||
.build();
|
||||
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
|
@ -33,9 +32,7 @@ final class EqlRequestConverters {
|
|||
}
|
||||
|
||||
static Request stats(EqlStatsRequest eqlStatsRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_eql", "stats")
|
||||
.build();
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_eql", "stats").build();
|
||||
return new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,8 +46,7 @@ public class FeaturesClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetFeaturesResponse getFeatures(GetFeaturesRequest getFeaturesRequest, RequestOptions options)
|
||||
throws IOException {
|
||||
public GetFeaturesResponse getFeatures(GetFeaturesRequest getFeaturesRequest, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
getFeaturesRequest,
|
||||
FeaturesRequestConverters::getFeatures,
|
||||
|
@ -68,8 +67,10 @@ public class FeaturesClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getFeaturesAsync(
|
||||
GetFeaturesRequest getFeaturesRequest, RequestOptions options,
|
||||
ActionListener<GetFeaturesResponse> listener) {
|
||||
GetFeaturesRequest getFeaturesRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<GetFeaturesResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
getFeaturesRequest,
|
||||
FeaturesRequestConverters::getFeatures,
|
||||
|
@ -91,8 +92,7 @@ public class FeaturesClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public ResetFeaturesResponse resetFeatures(ResetFeaturesRequest resetFeaturesRequest, RequestOptions options)
|
||||
throws IOException {
|
||||
public ResetFeaturesResponse resetFeatures(ResetFeaturesRequest resetFeaturesRequest, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
resetFeaturesRequest,
|
||||
FeaturesRequestConverters::resetFeatures,
|
||||
|
@ -114,8 +114,10 @@ public class FeaturesClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable resetFeaturesAsync(
|
||||
ResetFeaturesRequest resetFeaturesRequest, RequestOptions options,
|
||||
ActionListener<ResetFeaturesResponse> listener) {
|
||||
ResetFeaturesRequest resetFeaturesRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<ResetFeaturesResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
resetFeaturesRequest,
|
||||
FeaturesRequestConverters::resetFeatures,
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
package org.elasticsearch.client;
|
||||
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.core.Tuple;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
|
@ -33,15 +33,23 @@ public class GeoIpStatsResponse implements ToXContentObject {
|
|||
Map<String, Object> stats = (Map<String, Object>) a[0];
|
||||
List<Tuple<String, NodeInfo>> nodes = (List<Tuple<String, NodeInfo>>) a[1];
|
||||
|
||||
return new GeoIpStatsResponse((int) stats.get("successful_downloads"), (int) stats.get("failed_downloads"),
|
||||
((Number) stats.get("total_download_time")).longValue(), (int) stats.get("databases_count"), (int) stats.get("skipped_updates"),
|
||||
nodes.stream().collect(Collectors.toMap(Tuple::v1, Tuple::v2)));
|
||||
return new GeoIpStatsResponse(
|
||||
(int) stats.get("successful_downloads"),
|
||||
(int) stats.get("failed_downloads"),
|
||||
((Number) stats.get("total_download_time")).longValue(),
|
||||
(int) stats.get("databases_count"),
|
||||
(int) stats.get("skipped_updates"),
|
||||
nodes.stream().collect(Collectors.toMap(Tuple::v1, Tuple::v2))
|
||||
);
|
||||
});
|
||||
|
||||
static {
|
||||
PARSER.declareObject(constructorArg(), (p, c) -> p.map(), new ParseField("stats"));
|
||||
PARSER.declareNamedObjects(constructorArg(), (p, c, name) -> Tuple.tuple(name, NodeInfo.PARSER.apply(p, c)),
|
||||
new ParseField("nodes"));
|
||||
PARSER.declareNamedObjects(
|
||||
constructorArg(),
|
||||
(p, c, name) -> Tuple.tuple(name, NodeInfo.PARSER.apply(p, c)),
|
||||
new ParseField("nodes")
|
||||
);
|
||||
}
|
||||
|
||||
private final int successfulDownloads;
|
||||
|
@ -51,8 +59,14 @@ public class GeoIpStatsResponse implements ToXContentObject {
|
|||
private final int skippedDownloads;
|
||||
private final Map<String, NodeInfo> nodes;
|
||||
|
||||
public GeoIpStatsResponse(int successfulDownloads, int failedDownloads, long totalDownloadTime, int databasesCount,
|
||||
int skippedDownloads, Map<String, NodeInfo> nodes) {
|
||||
public GeoIpStatsResponse(
|
||||
int successfulDownloads,
|
||||
int failedDownloads,
|
||||
long totalDownloadTime,
|
||||
int databasesCount,
|
||||
int skippedDownloads,
|
||||
Map<String, NodeInfo> nodes
|
||||
) {
|
||||
this.successfulDownloads = successfulDownloads;
|
||||
this.failedDownloads = failedDownloads;
|
||||
this.totalDownloadTime = totalDownloadTime;
|
||||
|
@ -128,8 +142,10 @@ public class GeoIpStatsResponse implements ToXContentObject {
|
|||
@SuppressWarnings("unchecked")
|
||||
private static final ConstructingObjectParser<NodeInfo, Void> PARSER = new ConstructingObjectParser<>("node_info", a -> {
|
||||
List<DatabaseInfo> databases = (List<DatabaseInfo>) a[1];
|
||||
return new NodeInfo((Collection<String>) a[0], databases.stream().collect(Collectors.toMap(DatabaseInfo::getName,
|
||||
Function.identity())));
|
||||
return new NodeInfo(
|
||||
(Collection<String>) a[0],
|
||||
databases.stream().collect(Collectors.toMap(DatabaseInfo::getName, Function.identity()))
|
||||
);
|
||||
});
|
||||
|
||||
static {
|
||||
|
@ -157,10 +173,10 @@ public class GeoIpStatsResponse implements ToXContentObject {
|
|||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject();
|
||||
builder.stringListField("files_in_temp", filesInTemp);
|
||||
builder.field("databases", databases.entrySet().stream()
|
||||
.sorted(Map.Entry.comparingByKey())
|
||||
.map(Map.Entry::getValue)
|
||||
.collect(Collectors.toList()));
|
||||
builder.field(
|
||||
"databases",
|
||||
databases.entrySet().stream().sorted(Map.Entry.comparingByKey()).map(Map.Entry::getValue).collect(Collectors.toList())
|
||||
);
|
||||
builder.endObject();
|
||||
return builder;
|
||||
}
|
||||
|
@ -181,8 +197,10 @@ public class GeoIpStatsResponse implements ToXContentObject {
|
|||
|
||||
public static final class DatabaseInfo implements ToXContentObject {
|
||||
|
||||
private static final ConstructingObjectParser<DatabaseInfo, Void> PARSER = new ConstructingObjectParser<>("database_info",
|
||||
a -> new DatabaseInfo((String) a[0]));
|
||||
private static final ConstructingObjectParser<DatabaseInfo, Void> PARSER = new ConstructingObjectParser<>(
|
||||
"database_info",
|
||||
a -> new DatabaseInfo((String) a[0])
|
||||
);
|
||||
|
||||
static {
|
||||
PARSER.declareString(constructorArg(), new ParseField("name"));
|
||||
|
|
|
@ -11,11 +11,11 @@ package org.elasticsearch.client;
|
|||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.cluster.metadata.AliasMetadata;
|
||||
import org.elasticsearch.common.xcontent.StatusToXContentObject;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.xcontent.ToXContent;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -36,10 +36,14 @@ 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>.
|
||||
*/
|
||||
public final GraphExploreResponse explore(GraphExploreRequest graphExploreRequest,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(graphExploreRequest, GraphRequestConverters::explore,
|
||||
options, GraphExploreResponse::fromXContent, emptySet());
|
||||
public final GraphExploreResponse explore(GraphExploreRequest graphExploreRequest, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
graphExploreRequest,
|
||||
GraphRequestConverters::explore,
|
||||
options,
|
||||
GraphExploreResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,11 +53,19 @@ public class GraphClient {
|
|||
* on elastic.co</a>.
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public final Cancellable exploreAsync(GraphExploreRequest graphExploreRequest,
|
||||
public final Cancellable exploreAsync(
|
||||
GraphExploreRequest graphExploreRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<GraphExploreResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(graphExploreRequest, GraphRequestConverters::explore,
|
||||
options, GraphExploreResponse::fromXContent, listener, emptySet());
|
||||
ActionListener<GraphExploreResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
graphExploreRequest,
|
||||
GraphRequestConverters::explore,
|
||||
options,
|
||||
GraphExploreResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,10 +63,14 @@ public class IndexLifecycleClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetLifecyclePolicyResponse getLifecyclePolicy(GetLifecyclePolicyRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::getLifecyclePolicy, options,
|
||||
GetLifecyclePolicyResponse::fromXContent, emptySet());
|
||||
public GetLifecyclePolicyResponse getLifecyclePolicy(GetLifecyclePolicyRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::getLifecyclePolicy,
|
||||
options,
|
||||
GetLifecyclePolicyResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,10 +82,19 @@ public class IndexLifecycleClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getLifecyclePolicyAsync(GetLifecyclePolicyRequest request, RequestOptions options,
|
||||
ActionListener<GetLifecyclePolicyResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::getLifecyclePolicy, options,
|
||||
GetLifecyclePolicyResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable getLifecyclePolicyAsync(
|
||||
GetLifecyclePolicyRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<GetLifecyclePolicyResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::getLifecyclePolicy,
|
||||
options,
|
||||
GetLifecyclePolicyResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,10 +106,14 @@ public class IndexLifecycleClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse putLifecyclePolicy(PutLifecyclePolicyRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::putLifecyclePolicy, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
public AcknowledgedResponse putLifecyclePolicy(PutLifecyclePolicyRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::putLifecyclePolicy,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,10 +125,19 @@ public class IndexLifecycleClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable putLifecyclePolicyAsync(PutLifecyclePolicyRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::putLifecyclePolicy, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable putLifecyclePolicyAsync(
|
||||
PutLifecyclePolicyRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::putLifecyclePolicy,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,10 +152,14 @@ public class IndexLifecycleClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse deleteLifecyclePolicy(DeleteLifecyclePolicyRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::deleteLifecyclePolicy, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
public AcknowledgedResponse deleteLifecyclePolicy(DeleteLifecyclePolicyRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::deleteLifecyclePolicy,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,11 +174,19 @@ public class IndexLifecycleClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deleteLifecyclePolicyAsync(DeleteLifecyclePolicyRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
public Cancellable deleteLifecyclePolicyAsync(
|
||||
DeleteLifecyclePolicyRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request, IndexLifecycleRequestConverters::deleteLifecyclePolicy, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
request,
|
||||
IndexLifecycleRequestConverters::deleteLifecyclePolicy,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,10 +201,15 @@ public class IndexLifecycleClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public RemoveIndexLifecyclePolicyResponse removeIndexLifecyclePolicy(RemoveIndexLifecyclePolicyRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::removeIndexLifecyclePolicy,
|
||||
options, RemoveIndexLifecyclePolicyResponse::fromXContent, emptySet());
|
||||
public RemoveIndexLifecyclePolicyResponse removeIndexLifecyclePolicy(RemoveIndexLifecyclePolicyRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::removeIndexLifecyclePolicy,
|
||||
options,
|
||||
RemoveIndexLifecyclePolicyResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,11 +224,19 @@ public class IndexLifecycleClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable removeIndexLifecyclePolicyAsync(RemoveIndexLifecyclePolicyRequest request, RequestOptions options,
|
||||
ActionListener<RemoveIndexLifecyclePolicyResponse> listener) {
|
||||
public Cancellable removeIndexLifecyclePolicyAsync(
|
||||
RemoveIndexLifecyclePolicyRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<RemoveIndexLifecyclePolicyResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request, IndexLifecycleRequestConverters::removeIndexLifecyclePolicy, options,
|
||||
RemoveIndexLifecyclePolicyResponse::fromXContent, listener, emptySet());
|
||||
request,
|
||||
IndexLifecycleRequestConverters::removeIndexLifecyclePolicy,
|
||||
options,
|
||||
RemoveIndexLifecyclePolicyResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,8 +252,13 @@ public class IndexLifecycleClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse startILM(StartILMRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::startILM, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::startILM,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -218,8 +274,14 @@ public class IndexLifecycleClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable startILMAsync(StartILMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::startILM, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::startILM,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -235,8 +297,13 @@ public class IndexLifecycleClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse stopILM(StopILMRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::stopILM, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::stopILM,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -252,8 +319,14 @@ public class IndexLifecycleClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable stopILMAsync(StopILMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::stopILM, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::stopILM,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -269,8 +342,13 @@ public class IndexLifecycleClient {
|
|||
*/
|
||||
public LifecycleManagementStatusResponse lifecycleManagementStatus(LifecycleManagementStatusRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::lifecycleManagementStatus,
|
||||
options, LifecycleManagementStatusResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::lifecycleManagementStatus,
|
||||
options,
|
||||
LifecycleManagementStatusResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -285,11 +363,19 @@ public class IndexLifecycleClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable lifecycleManagementStatusAsync(LifecycleManagementStatusRequest request, RequestOptions options,
|
||||
ActionListener<LifecycleManagementStatusResponse> listener) {
|
||||
public Cancellable lifecycleManagementStatusAsync(
|
||||
LifecycleManagementStatusRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<LifecycleManagementStatusResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request, IndexLifecycleRequestConverters::lifecycleManagementStatus, options,
|
||||
LifecycleManagementStatusResponse::fromXContent, listener, emptySet());
|
||||
request,
|
||||
IndexLifecycleRequestConverters::lifecycleManagementStatus,
|
||||
options,
|
||||
LifecycleManagementStatusResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -305,8 +391,13 @@ public class IndexLifecycleClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public ExplainLifecycleResponse explainLifecycle(ExplainLifecycleRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::explainLifecycle, options,
|
||||
ExplainLifecycleResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::explainLifecycle,
|
||||
options,
|
||||
ExplainLifecycleResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -321,10 +412,19 @@ public class IndexLifecycleClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable explainLifecycleAsync(ExplainLifecycleRequest request, RequestOptions options,
|
||||
ActionListener<ExplainLifecycleResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::explainLifecycle, options,
|
||||
ExplainLifecycleResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable explainLifecycleAsync(
|
||||
ExplainLifecycleRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<ExplainLifecycleResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::explainLifecycle,
|
||||
options,
|
||||
ExplainLifecycleResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -340,8 +440,13 @@ public class IndexLifecycleClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse retryLifecyclePolicy(RetryLifecyclePolicyRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::retryLifecycle, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::retryLifecycle,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -356,10 +461,19 @@ public class IndexLifecycleClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable retryLifecyclePolicyAsync(RetryLifecyclePolicyRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::retryLifecycle, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable retryLifecyclePolicyAsync(
|
||||
RetryLifecyclePolicyRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::retryLifecycle,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -374,10 +488,15 @@ public class IndexLifecycleClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetSnapshotLifecyclePolicyResponse getSnapshotLifecyclePolicy(GetSnapshotLifecyclePolicyRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::getSnapshotLifecyclePolicy,
|
||||
options, GetSnapshotLifecyclePolicyResponse::fromXContent, emptySet());
|
||||
public GetSnapshotLifecyclePolicyResponse getSnapshotLifecyclePolicy(GetSnapshotLifecyclePolicyRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::getSnapshotLifecyclePolicy,
|
||||
options,
|
||||
GetSnapshotLifecyclePolicyResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -392,10 +511,19 @@ public class IndexLifecycleClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getSnapshotLifecyclePolicyAsync(GetSnapshotLifecyclePolicyRequest request, RequestOptions options,
|
||||
ActionListener<GetSnapshotLifecyclePolicyResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::getSnapshotLifecyclePolicy,
|
||||
options, GetSnapshotLifecyclePolicyResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable getSnapshotLifecyclePolicyAsync(
|
||||
GetSnapshotLifecyclePolicyRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<GetSnapshotLifecyclePolicyResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::getSnapshotLifecyclePolicy,
|
||||
options,
|
||||
GetSnapshotLifecyclePolicyResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -410,10 +538,15 @@ public class IndexLifecycleClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse putSnapshotLifecyclePolicy(PutSnapshotLifecyclePolicyRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::putSnapshotLifecyclePolicy,
|
||||
options, AcknowledgedResponse::fromXContent, emptySet());
|
||||
public AcknowledgedResponse putSnapshotLifecyclePolicy(PutSnapshotLifecyclePolicyRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::putSnapshotLifecyclePolicy,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -428,10 +561,19 @@ public class IndexLifecycleClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable putSnapshotLifecyclePolicyAsync(PutSnapshotLifecyclePolicyRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::putSnapshotLifecyclePolicy,
|
||||
options, AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable putSnapshotLifecyclePolicyAsync(
|
||||
PutSnapshotLifecyclePolicyRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::putSnapshotLifecyclePolicy,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -446,10 +588,15 @@ public class IndexLifecycleClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse deleteSnapshotLifecyclePolicy(DeleteSnapshotLifecyclePolicyRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::deleteSnapshotLifecyclePolicy,
|
||||
options, AcknowledgedResponse::fromXContent, emptySet());
|
||||
public AcknowledgedResponse deleteSnapshotLifecyclePolicy(DeleteSnapshotLifecyclePolicyRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::deleteSnapshotLifecyclePolicy,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -464,11 +611,19 @@ public class IndexLifecycleClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deleteSnapshotLifecyclePolicyAsync(DeleteSnapshotLifecyclePolicyRequest request,
|
||||
RequestOptions options,ActionListener<AcknowledgedResponse> listener) {
|
||||
public Cancellable deleteSnapshotLifecyclePolicyAsync(
|
||||
DeleteSnapshotLifecyclePolicyRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request, IndexLifecycleRequestConverters::deleteSnapshotLifecyclePolicy,
|
||||
options, AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
request,
|
||||
IndexLifecycleRequestConverters::deleteSnapshotLifecyclePolicy,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -483,10 +638,17 @@ public class IndexLifecycleClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public ExecuteSnapshotLifecyclePolicyResponse executeSnapshotLifecyclePolicy(ExecuteSnapshotLifecyclePolicyRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::executeSnapshotLifecyclePolicy,
|
||||
options, ExecuteSnapshotLifecyclePolicyResponse::fromXContent, emptySet());
|
||||
public ExecuteSnapshotLifecyclePolicyResponse executeSnapshotLifecyclePolicy(
|
||||
ExecuteSnapshotLifecyclePolicyRequest request,
|
||||
RequestOptions options
|
||||
) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::executeSnapshotLifecyclePolicy,
|
||||
options,
|
||||
ExecuteSnapshotLifecyclePolicyResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -502,11 +664,18 @@ public class IndexLifecycleClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable executeSnapshotLifecyclePolicyAsync(
|
||||
ExecuteSnapshotLifecyclePolicyRequest request, RequestOptions options,
|
||||
ActionListener<ExecuteSnapshotLifecyclePolicyResponse> listener) {
|
||||
ExecuteSnapshotLifecyclePolicyRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<ExecuteSnapshotLifecyclePolicyResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request, IndexLifecycleRequestConverters::executeSnapshotLifecyclePolicy,
|
||||
options, ExecuteSnapshotLifecyclePolicyResponse::fromXContent, listener, emptySet());
|
||||
request,
|
||||
IndexLifecycleRequestConverters::executeSnapshotLifecyclePolicy,
|
||||
options,
|
||||
ExecuteSnapshotLifecyclePolicyResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -521,10 +690,15 @@ public class IndexLifecycleClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse executeSnapshotLifecycleRetention(ExecuteSnapshotLifecycleRetentionRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::executeSnapshotLifecycleRetention,
|
||||
options, AcknowledgedResponse::fromXContent, emptySet());
|
||||
public AcknowledgedResponse executeSnapshotLifecycleRetention(ExecuteSnapshotLifecycleRetentionRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::executeSnapshotLifecycleRetention,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -540,11 +714,18 @@ public class IndexLifecycleClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable executeSnapshotLifecycleRetentionAsync(
|
||||
ExecuteSnapshotLifecycleRetentionRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
ExecuteSnapshotLifecycleRetentionRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request, IndexLifecycleRequestConverters::executeSnapshotLifecycleRetention,
|
||||
options, AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
request,
|
||||
IndexLifecycleRequestConverters::executeSnapshotLifecycleRetention,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -559,10 +740,15 @@ public class IndexLifecycleClient {
|
|||
* @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());
|
||||
public GetSnapshotLifecycleStatsResponse getSnapshotLifecycleStats(GetSnapshotLifecycleStatsRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::getSnapshotLifecycleStats,
|
||||
options,
|
||||
GetSnapshotLifecycleStatsResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -577,10 +763,19 @@ public class IndexLifecycleClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getSnapshotLifecycleStatsAsync(GetSnapshotLifecycleStatsRequest request, RequestOptions options,
|
||||
ActionListener<GetSnapshotLifecycleStatsResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::getSnapshotLifecycleStats,
|
||||
options, GetSnapshotLifecycleStatsResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable getSnapshotLifecycleStatsAsync(
|
||||
GetSnapshotLifecycleStatsRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<GetSnapshotLifecycleStatsResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::getSnapshotLifecycleStats,
|
||||
options,
|
||||
GetSnapshotLifecycleStatsResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -595,8 +790,13 @@ public class IndexLifecycleClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse startSLM(StartSLMRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::startSLM, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::startSLM,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -610,8 +810,14 @@ public class IndexLifecycleClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable startSLMAsync(StartSLMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::startSLM, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::startSLM,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -626,8 +832,13 @@ public class IndexLifecycleClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse stopSLM(StopSLMRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::stopSLM, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::stopSLM,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -642,8 +853,14 @@ public class IndexLifecycleClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable stopSLMAsync(StopSLMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::stopSLM, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::stopSLM,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -657,10 +874,15 @@ public class IndexLifecycleClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public LifecycleManagementStatusResponse getSLMStatus(SnapshotLifecycleManagementStatusRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::snapshotLifecycleManagementStatus,
|
||||
options, LifecycleManagementStatusResponse::fromXContent, emptySet());
|
||||
public LifecycleManagementStatusResponse getSLMStatus(SnapshotLifecycleManagementStatusRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::snapshotLifecycleManagementStatus,
|
||||
options,
|
||||
LifecycleManagementStatusResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -674,10 +896,18 @@ public class IndexLifecycleClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getSLMStatusAsync(SnapshotLifecycleManagementStatusRequest request, RequestOptions options,
|
||||
ActionListener<LifecycleManagementStatusResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
IndexLifecycleRequestConverters::snapshotLifecycleManagementStatus, options, LifecycleManagementStatusResponse::fromXContent,
|
||||
listener, emptySet());
|
||||
public Cancellable getSLMStatusAsync(
|
||||
SnapshotLifecycleManagementStatusRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<LifecycleManagementStatusResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IndexLifecycleRequestConverters::snapshotLifecycleManagementStatus,
|
||||
options,
|
||||
LifecycleManagementStatusResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,8 @@ final class IndexLifecycleRequestConverters {
|
|||
|
||||
static Request getLifecyclePolicy(GetLifecyclePolicyRequest getLifecyclePolicyRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_ilm/policy")
|
||||
.addCommaSeparatedPathParts(getLifecyclePolicyRequest.getPolicyNames()).build();
|
||||
.addCommaSeparatedPathParts(getLifecyclePolicyRequest.getPolicyNames())
|
||||
.build();
|
||||
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(getLifecyclePolicyRequest.masterNodeTimeout());
|
||||
|
@ -50,8 +51,7 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request putLifecyclePolicy(PutLifecyclePolicyRequest putLifecycleRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ilm/policy")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_ilm/policy")
|
||||
.addPathPartAsIs(putLifecycleRequest.getName())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
@ -64,11 +64,12 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteLifecyclePolicy(DeleteLifecyclePolicyRequest deleteLifecyclePolicyRequest) {
|
||||
Request request = new Request(HttpDelete.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ilm/policy")
|
||||
Request request = new Request(
|
||||
HttpDelete.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder().addPathPartAsIs("_ilm/policy")
|
||||
.addPathPartAsIs(deleteLifecyclePolicyRequest.getLifecyclePolicy())
|
||||
.build());
|
||||
.build()
|
||||
);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(deleteLifecyclePolicyRequest.masterNodeTimeout());
|
||||
params.withTimeout(deleteLifecyclePolicyRequest.timeout());
|
||||
|
@ -77,13 +78,13 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request removeIndexLifecyclePolicy(RemoveIndexLifecyclePolicyRequest removePolicyRequest) {
|
||||
String[] indices = removePolicyRequest.indices() == null ?
|
||||
Strings.EMPTY_ARRAY : removePolicyRequest.indices().toArray(new String[] {});
|
||||
Request request = new Request(HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder()
|
||||
.addCommaSeparatedPathParts(indices)
|
||||
.addPathPartAsIs("_ilm", "remove")
|
||||
.build());
|
||||
String[] indices = removePolicyRequest.indices() == null
|
||||
? Strings.EMPTY_ARRAY
|
||||
: removePolicyRequest.indices().toArray(new String[] {});
|
||||
Request request = new Request(
|
||||
HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder().addCommaSeparatedPathParts(indices).addPathPartAsIs("_ilm", "remove").build()
|
||||
);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withIndicesOptions(removePolicyRequest.indicesOptions());
|
||||
params.withMasterTimeout(removePolicyRequest.masterNodeTimeout());
|
||||
|
@ -92,11 +93,10 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request startILM(StartILMRequest startILMRequest) {
|
||||
Request request = new Request(HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ilm")
|
||||
.addPathPartAsIs("start")
|
||||
.build());
|
||||
Request request = new Request(
|
||||
HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder().addPathPartAsIs("_ilm").addPathPartAsIs("start").build()
|
||||
);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(startILMRequest.masterNodeTimeout());
|
||||
params.withTimeout(startILMRequest.timeout());
|
||||
|
@ -105,11 +105,10 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request stopILM(StopILMRequest stopILMRequest) {
|
||||
Request request = new Request(HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ilm")
|
||||
.addPathPartAsIs("stop")
|
||||
.build());
|
||||
Request request = new Request(
|
||||
HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder().addPathPartAsIs("_ilm").addPathPartAsIs("stop").build()
|
||||
);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(stopILMRequest.masterNodeTimeout());
|
||||
params.withTimeout(stopILMRequest.timeout());
|
||||
|
@ -118,11 +117,10 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request lifecycleManagementStatus(LifecycleManagementStatusRequest lifecycleManagementStatusRequest) {
|
||||
Request request = new Request(HttpGet.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ilm")
|
||||
.addPathPartAsIs("status")
|
||||
.build());
|
||||
Request request = new Request(
|
||||
HttpGet.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder().addPathPartAsIs("_ilm").addPathPartAsIs("status").build()
|
||||
);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(lifecycleManagementStatusRequest.masterNodeTimeout());
|
||||
params.withTimeout(lifecycleManagementStatusRequest.timeout());
|
||||
|
@ -131,12 +129,13 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request explainLifecycle(ExplainLifecycleRequest explainLifecycleRequest) {
|
||||
Request request = new Request(HttpGet.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder()
|
||||
.addCommaSeparatedPathParts(explainLifecycleRequest.getIndices())
|
||||
Request request = new Request(
|
||||
HttpGet.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder().addCommaSeparatedPathParts(explainLifecycleRequest.getIndices())
|
||||
.addPathPartAsIs("_ilm")
|
||||
.addPathPartAsIs("explain")
|
||||
.build());
|
||||
.build()
|
||||
);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withIndicesOptions(explainLifecycleRequest.indicesOptions());
|
||||
params.withMasterTimeout(explainLifecycleRequest.masterNodeTimeout());
|
||||
|
@ -145,12 +144,13 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request retryLifecycle(RetryLifecyclePolicyRequest retryLifecyclePolicyRequest) {
|
||||
Request request = new Request(HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder()
|
||||
.addCommaSeparatedPathParts(retryLifecyclePolicyRequest.getIndices())
|
||||
Request request = new Request(
|
||||
HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder().addCommaSeparatedPathParts(retryLifecyclePolicyRequest.getIndices())
|
||||
.addPathPartAsIs("_ilm")
|
||||
.addPathPartAsIs("retry")
|
||||
.build());
|
||||
.build()
|
||||
);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(retryLifecyclePolicyRequest.masterNodeTimeout());
|
||||
params.withTimeout(retryLifecyclePolicyRequest.timeout());
|
||||
|
@ -160,7 +160,8 @@ final class IndexLifecycleRequestConverters {
|
|||
|
||||
static Request getSnapshotLifecyclePolicy(GetSnapshotLifecyclePolicyRequest getSnapshotLifecyclePolicyRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_slm/policy")
|
||||
.addCommaSeparatedPathParts(getSnapshotLifecyclePolicyRequest.getPolicyIds()).build();
|
||||
.addCommaSeparatedPathParts(getSnapshotLifecyclePolicyRequest.getPolicyIds())
|
||||
.build();
|
||||
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(getSnapshotLifecyclePolicyRequest.masterNodeTimeout());
|
||||
|
@ -170,8 +171,7 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request putSnapshotLifecyclePolicy(PutSnapshotLifecyclePolicyRequest putSnapshotLifecyclePolicyRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_slm/policy")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_slm/policy")
|
||||
.addPathPartAsIs(putSnapshotLifecyclePolicyRequest.getPolicy().getId())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
@ -184,11 +184,12 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteSnapshotLifecyclePolicy(DeleteSnapshotLifecyclePolicyRequest deleteSnapshotLifecyclePolicyRequest) {
|
||||
Request request = new Request(HttpDelete.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_slm/policy")
|
||||
Request request = new Request(
|
||||
HttpDelete.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder().addPathPartAsIs("_slm/policy")
|
||||
.addPathPartAsIs(deleteSnapshotLifecyclePolicyRequest.getPolicyId())
|
||||
.build());
|
||||
.build()
|
||||
);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(deleteSnapshotLifecyclePolicyRequest.masterNodeTimeout());
|
||||
params.withTimeout(deleteSnapshotLifecyclePolicyRequest.timeout());
|
||||
|
@ -197,12 +198,13 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request executeSnapshotLifecyclePolicy(ExecuteSnapshotLifecyclePolicyRequest executeSnapshotLifecyclePolicyRequest) {
|
||||
Request request = new Request(HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_slm/policy")
|
||||
Request request = new Request(
|
||||
HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder().addPathPartAsIs("_slm/policy")
|
||||
.addPathPartAsIs(executeSnapshotLifecyclePolicyRequest.getPolicyId())
|
||||
.addPathPartAsIs("_execute")
|
||||
.build());
|
||||
.build()
|
||||
);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(executeSnapshotLifecyclePolicyRequest.masterNodeTimeout());
|
||||
params.withTimeout(executeSnapshotLifecyclePolicyRequest.timeout());
|
||||
|
@ -211,10 +213,10 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request executeSnapshotLifecycleRetention(ExecuteSnapshotLifecycleRetentionRequest executeSnapshotLifecycleRetentionRequest) {
|
||||
Request request = new Request(HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_slm/_execute_retention")
|
||||
.build());
|
||||
Request request = new Request(
|
||||
HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder().addPathPartAsIs("_slm/_execute_retention").build()
|
||||
);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(executeSnapshotLifecycleRetentionRequest.masterNodeTimeout());
|
||||
params.withTimeout(executeSnapshotLifecycleRetentionRequest.timeout());
|
||||
|
@ -233,11 +235,10 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request snapshotLifecycleManagementStatus(SnapshotLifecycleManagementStatusRequest snapshotLifecycleManagementStatusRequest) {
|
||||
Request request = new Request(HttpGet.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_slm")
|
||||
.addPathPartAsIs("status")
|
||||
.build());
|
||||
Request request = new Request(
|
||||
HttpGet.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder().addPathPartAsIs("_slm").addPathPartAsIs("status").build()
|
||||
);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(snapshotLifecycleManagementStatusRequest.masterNodeTimeout());
|
||||
params.withTimeout(snapshotLifecycleManagementStatusRequest.timeout());
|
||||
|
@ -246,11 +247,10 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request startSLM(StartSLMRequest startSLMRequest) {
|
||||
Request request = new Request(HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_slm")
|
||||
.addPathPartAsIs("start")
|
||||
.build());
|
||||
Request request = new Request(
|
||||
HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder().addPathPartAsIs("_slm").addPathPartAsIs("start").build()
|
||||
);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(startSLMRequest.masterNodeTimeout());
|
||||
params.withTimeout(startSLMRequest.timeout());
|
||||
|
@ -259,11 +259,10 @@ final class IndexLifecycleRequestConverters {
|
|||
}
|
||||
|
||||
static Request stopSLM(StopSLMRequest stopSLMRequest) {
|
||||
Request request = new Request(HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_slm")
|
||||
.addPathPartAsIs("stop")
|
||||
.build());
|
||||
Request request = new Request(
|
||||
HttpPost.METHOD_NAME,
|
||||
new RequestConverters.EndpointBuilder().addPathPartAsIs("_slm").addPathPartAsIs("stop").build()
|
||||
);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(stopSLMRequest.masterNodeTimeout());
|
||||
params.withTimeout(stopSLMRequest.timeout());
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,23 +29,23 @@ import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryReques
|
|||
import org.elasticsearch.action.support.broadcast.BroadcastRequest;
|
||||
import org.elasticsearch.client.indices.AnalyzeRequest;
|
||||
import org.elasticsearch.client.indices.CloseIndexRequest;
|
||||
import org.elasticsearch.client.indices.ComposableIndexTemplateExistRequest;
|
||||
import org.elasticsearch.client.indices.CreateDataStreamRequest;
|
||||
import org.elasticsearch.client.indices.CreateIndexRequest;
|
||||
import org.elasticsearch.client.indices.DataStreamsStatsRequest;
|
||||
import org.elasticsearch.client.indices.GetDataStreamRequest;
|
||||
import org.elasticsearch.client.indices.DeleteAliasRequest;
|
||||
import org.elasticsearch.client.indices.DeleteComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.DeleteDataStreamRequest;
|
||||
import org.elasticsearch.client.indices.FreezeIndexRequest;
|
||||
import org.elasticsearch.client.indices.GetComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.GetDataStreamRequest;
|
||||
import org.elasticsearch.client.indices.GetFieldMappingsRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexRequest;
|
||||
import org.elasticsearch.client.indices.GetComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplatesRequest;
|
||||
import org.elasticsearch.client.indices.GetMappingsRequest;
|
||||
import org.elasticsearch.client.indices.ComposableIndexTemplateExistRequest;
|
||||
import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
|
||||
import org.elasticsearch.client.indices.PutIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutMappingRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersRequest;
|
||||
import org.elasticsearch.client.indices.ResizeRequest;
|
||||
|
@ -64,7 +64,8 @@ final class IndicesRequestConverters {
|
|||
|
||||
static Request putDataStream(CreateDataStreamRequest createDataStreamRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_data_stream")
|
||||
.addPathPart(createDataStreamRequest.getName()).build();
|
||||
.addPathPart(createDataStreamRequest.getName())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
return request;
|
||||
}
|
||||
|
@ -77,8 +78,7 @@ final class IndicesRequestConverters {
|
|||
}
|
||||
|
||||
static Request getDataStreams(GetDataStreamRequest dataStreamRequest) {
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_data_stream")
|
||||
final String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_data_stream")
|
||||
.addPathPart(dataStreamRequest.getName())
|
||||
.build();
|
||||
return new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
|
@ -86,8 +86,7 @@ final class IndicesRequestConverters {
|
|||
|
||||
static Request dataStreamsStats(DataStreamsStatsRequest dataStreamsStatsRequest) {
|
||||
String[] expressions = dataStreamsStatsRequest.indices() == null ? Strings.EMPTY_ARRAY : dataStreamsStatsRequest.indices();
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_data_stream")
|
||||
final String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_data_stream")
|
||||
.addCommaSeparatedPathParts(expressions)
|
||||
.addPathPartAsIs("_stats")
|
||||
.build();
|
||||
|
@ -139,8 +138,7 @@ final class IndicesRequestConverters {
|
|||
}
|
||||
|
||||
static Request createIndex(CreateIndexRequest createIndexRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPart(createIndexRequest.index()).build();
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPart(createIndexRequest.index()).build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
||||
RequestConverters.Params parameters = new RequestConverters.Params();
|
||||
|
@ -163,7 +161,6 @@ final class IndicesRequestConverters {
|
|||
return request;
|
||||
}
|
||||
|
||||
|
||||
static Request putMapping(PutMappingRequest putMappingRequest) throws IOException {
|
||||
Request request = new Request(HttpPut.METHOD_NAME, RequestConverters.endpoint(putMappingRequest.indices(), "_mapping"));
|
||||
|
||||
|
@ -195,8 +192,7 @@ final class IndicesRequestConverters {
|
|||
String[] indices = getFieldMappingsRequest.indices() == null ? Strings.EMPTY_ARRAY : getFieldMappingsRequest.indices();
|
||||
String[] fields = getFieldMappingsRequest.fields() == null ? Strings.EMPTY_ARRAY : getFieldMappingsRequest.fields();
|
||||
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addCommaSeparatedPathParts(indices)
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addCommaSeparatedPathParts(indices)
|
||||
.addPathPartAsIs("_mapping")
|
||||
.addPathPartAsIs("field")
|
||||
.addCommaSeparatedPathParts(fields)
|
||||
|
@ -269,8 +265,8 @@ final class IndicesRequestConverters {
|
|||
}
|
||||
|
||||
static Request existsAlias(GetAliasesRequest getAliasesRequest) {
|
||||
if ((getAliasesRequest.indices() == null || getAliasesRequest.indices().length == 0) &&
|
||||
(getAliasesRequest.aliases() == null || getAliasesRequest.aliases().length == 0)) {
|
||||
if ((getAliasesRequest.indices() == null || getAliasesRequest.indices().length == 0)
|
||||
&& (getAliasesRequest.aliases() == null || getAliasesRequest.aliases().length == 0)) {
|
||||
throw new IllegalArgumentException("existsAlias requires at least an alias or an index");
|
||||
}
|
||||
String[] indices = getAliasesRequest.indices() == null ? Strings.EMPTY_ARRAY : getAliasesRequest.indices();
|
||||
|
@ -329,7 +325,8 @@ final class IndicesRequestConverters {
|
|||
private static Request resize(ResizeRequest resizeRequest, ResizeType type) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPart(resizeRequest.getSourceIndex())
|
||||
.addPathPartAsIs("_" + type.name().toLowerCase(Locale.ROOT))
|
||||
.addPathPart(resizeRequest.getTargetIndex()).build();
|
||||
.addPathPart(resizeRequest.getTargetIndex())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
|
@ -345,7 +342,8 @@ final class IndicesRequestConverters {
|
|||
private static Request resize(org.elasticsearch.action.admin.indices.shrink.ResizeRequest resizeRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPart(resizeRequest.getSourceIndex())
|
||||
.addPathPartAsIs("_" + resizeRequest.getResizeType().name().toLowerCase(Locale.ROOT))
|
||||
.addPathPart(resizeRequest.getTargetIndexRequest().index()).build();
|
||||
.addPathPart(resizeRequest.getTargetIndexRequest().index())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
|
@ -358,8 +356,10 @@ final class IndicesRequestConverters {
|
|||
}
|
||||
|
||||
static Request rollover(RolloverRequest rolloverRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPart(rolloverRequest.getAlias()).addPathPartAsIs("_rollover")
|
||||
.addPathPart(rolloverRequest.getNewIndexName()).build();
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPart(rolloverRequest.getAlias())
|
||||
.addPathPartAsIs("_rollover")
|
||||
.addPathPart(rolloverRequest.getNewIndexName())
|
||||
.build();
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
|
@ -446,7 +446,8 @@ final class IndicesRequestConverters {
|
|||
|
||||
static Request putTemplate(PutIndexTemplateRequest putIndexTemplateRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_template")
|
||||
.addPathPart(putIndexTemplateRequest.name()).build();
|
||||
.addPathPart(putIndexTemplateRequest.name())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(putIndexTemplateRequest.masterNodeTimeout());
|
||||
|
@ -463,7 +464,8 @@ final class IndicesRequestConverters {
|
|||
|
||||
static Request putIndexTemplate(PutComposableIndexTemplateRequest putIndexTemplateRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_index_template")
|
||||
.addPathPart(putIndexTemplateRequest.name()).build();
|
||||
.addPathPart(putIndexTemplateRequest.name())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(putIndexTemplateRequest.masterNodeTimeout());
|
||||
|
@ -480,7 +482,8 @@ final class IndicesRequestConverters {
|
|||
|
||||
static Request simulateIndexTemplate(SimulateIndexTemplateRequest simulateIndexTemplateRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_index_template", "_simulate_index")
|
||||
.addPathPart(simulateIndexTemplateRequest.indexName()).build();
|
||||
.addPathPart(simulateIndexTemplateRequest.indexName())
|
||||
.build();
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(simulateIndexTemplateRequest.masterNodeTimeout());
|
||||
|
@ -492,8 +495,9 @@ final class IndicesRequestConverters {
|
|||
if (Strings.hasText(putComposableIndexTemplateRequest.cause())) {
|
||||
params.putParam("cause", putComposableIndexTemplateRequest.cause());
|
||||
}
|
||||
request.setEntity(RequestConverters.createEntity(putComposableIndexTemplateRequest,
|
||||
RequestConverters.REQUEST_BODY_CONTENT_TYPE));
|
||||
request.setEntity(
|
||||
RequestConverters.createEntity(putComposableIndexTemplateRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE)
|
||||
);
|
||||
}
|
||||
request.addParameters(params.asMap());
|
||||
return request;
|
||||
|
@ -530,8 +534,7 @@ final class IndicesRequestConverters {
|
|||
}
|
||||
|
||||
static Request getTemplates(GetIndexTemplatesRequest getIndexTemplatesRequest) {
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_template")
|
||||
final String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_template")
|
||||
.addCommaSeparatedPathParts(getIndexTemplatesRequest.names())
|
||||
.build();
|
||||
final Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
|
@ -543,8 +546,7 @@ final class IndicesRequestConverters {
|
|||
}
|
||||
|
||||
static Request getIndexTemplates(GetComposableIndexTemplateRequest getIndexTemplatesRequest) {
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_index_template")
|
||||
final String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_index_template")
|
||||
.addPathPart(getIndexTemplatesRequest.name())
|
||||
.build();
|
||||
final Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
|
@ -556,8 +558,7 @@ final class IndicesRequestConverters {
|
|||
}
|
||||
|
||||
static Request templatesExist(IndexTemplatesExistRequest indexTemplatesExistRequest) {
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_template")
|
||||
final String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_template")
|
||||
.addCommaSeparatedPathParts(indexTemplatesExistRequest.names())
|
||||
.build();
|
||||
final Request request = new Request(HttpHead.METHOD_NAME, endpoint);
|
||||
|
@ -569,8 +570,7 @@ final class IndicesRequestConverters {
|
|||
}
|
||||
|
||||
static Request templatesExist(ComposableIndexTemplateExistRequest indexTemplatesExistRequest) {
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_index_template")
|
||||
final String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_index_template")
|
||||
.addPathPart(indexTemplatesExistRequest.name())
|
||||
.build();
|
||||
final Request request = new Request(HttpHead.METHOD_NAME, endpoint);
|
||||
|
@ -649,10 +649,10 @@ final class IndicesRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteAlias(DeleteAliasRequest deleteAliasRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPart(deleteAliasRequest.getIndex())
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPart(deleteAliasRequest.getIndex())
|
||||
.addPathPartAsIs("_alias")
|
||||
.addPathPart(deleteAliasRequest.getAlias()).build();
|
||||
.addPathPart(deleteAliasRequest.getAlias())
|
||||
.build();
|
||||
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params parameters = new RequestConverters.Params();
|
||||
parameters.withTimeout(deleteAliasRequest.timeout());
|
||||
|
|
|
@ -53,8 +53,13 @@ public final class IngestClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse putPipeline(PutPipelineRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IngestRequestConverters::putPipeline, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IngestRequestConverters::putPipeline,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,8 +73,14 @@ public final class IngestClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable putPipelineAsync(PutPipelineRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IngestRequestConverters::putPipeline, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IngestRequestConverters::putPipeline,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,8 +94,13 @@ public final class IngestClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetPipelineResponse getPipeline(GetPipelineRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IngestRequestConverters::getPipeline, options,
|
||||
GetPipelineResponse::fromXContent, Collections.singleton(404));
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IngestRequestConverters::getPipeline,
|
||||
options,
|
||||
GetPipelineResponse::fromXContent,
|
||||
Collections.singleton(404)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,8 +114,14 @@ public final class IngestClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getPipelineAsync(GetPipelineRequest request, RequestOptions options, ActionListener<GetPipelineResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IngestRequestConverters::getPipeline, options,
|
||||
GetPipelineResponse::fromXContent, listener, Collections.singleton(404));
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IngestRequestConverters::getPipeline,
|
||||
options,
|
||||
GetPipelineResponse::fromXContent,
|
||||
listener,
|
||||
Collections.singleton(404)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,8 +136,13 @@ public final class IngestClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse deletePipeline(DeletePipelineRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IngestRequestConverters::deletePipeline, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IngestRequestConverters::deletePipeline,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,11 +156,19 @@ public final class IngestClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deletePipelineAsync(DeletePipelineRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
IngestRequestConverters::deletePipeline, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable deletePipelineAsync(
|
||||
DeletePipelineRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IngestRequestConverters::deletePipeline,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,8 +184,13 @@ public final class IngestClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public SimulatePipelineResponse simulate(SimulatePipelineRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IngestRequestConverters::simulatePipeline, options,
|
||||
SimulatePipelineResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
IngestRequestConverters::simulatePipeline,
|
||||
options,
|
||||
SimulatePipelineResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,20 +205,39 @@ public final class IngestClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable simulateAsync(SimulatePipelineRequest request,
|
||||
public Cancellable simulateAsync(
|
||||
SimulatePipelineRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<SimulatePipelineResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IngestRequestConverters::simulatePipeline, options,
|
||||
SimulatePipelineResponse::fromXContent, listener, emptySet());
|
||||
ActionListener<SimulatePipelineResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IngestRequestConverters::simulatePipeline,
|
||||
options,
|
||||
SimulatePipelineResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
public GeoIpStatsResponse geoIpStats(MainRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(new MainRequest(), IngestRequestConverters::geoIpStats, options,
|
||||
GeoIpStatsResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
new MainRequest(),
|
||||
IngestRequestConverters::geoIpStats,
|
||||
options,
|
||||
GeoIpStatsResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
public Cancellable geoIpStatsAsync(MainRequest request, RequestOptions options, ActionListener<GeoIpStatsResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IngestRequestConverters::geoIpStats, options,
|
||||
GeoIpStatsResponse::fromXContent, listener, emptySet());
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
IngestRequestConverters::geoIpStats,
|
||||
options,
|
||||
GeoIpStatsResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@ final class IngestRequestConverters {
|
|||
private IngestRequestConverters() {}
|
||||
|
||||
static Request getPipeline(GetPipelineRequest getPipelineRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ingest/pipeline")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_ingest/pipeline")
|
||||
.addCommaSeparatedPathParts(getPipelineRequest.getIds())
|
||||
.build();
|
||||
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
|
@ -38,8 +37,7 @@ final class IngestRequestConverters {
|
|||
}
|
||||
|
||||
static Request putPipeline(PutPipelineRequest putPipelineRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ingest/pipeline")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_ingest/pipeline")
|
||||
.addPathPart(putPipelineRequest.getId())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
@ -53,8 +51,7 @@ final class IngestRequestConverters {
|
|||
}
|
||||
|
||||
static Request deletePipeline(DeletePipelineRequest deletePipelineRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_ingest/pipeline")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_ingest/pipeline")
|
||||
.addPathPart(deletePipelineRequest.getId())
|
||||
.build();
|
||||
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
|
||||
|
|
|
@ -11,12 +11,17 @@ package org.elasticsearch.client;
|
|||
import org.apache.http.HttpEntity;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.client.license.StartTrialRequest;
|
||||
import org.elasticsearch.client.license.StartTrialResponse;
|
||||
import org.elasticsearch.client.license.DeleteLicenseRequest;
|
||||
import org.elasticsearch.client.license.GetBasicStatusResponse;
|
||||
import org.elasticsearch.client.license.GetLicenseRequest;
|
||||
import org.elasticsearch.client.license.GetLicenseResponse;
|
||||
import org.elasticsearch.client.license.GetTrialStatusResponse;
|
||||
import org.elasticsearch.client.license.PutLicenseRequest;
|
||||
import org.elasticsearch.client.license.PutLicenseResponse;
|
||||
import org.elasticsearch.client.license.StartBasicRequest;
|
||||
import org.elasticsearch.client.license.StartBasicResponse;
|
||||
import org.elasticsearch.client.license.GetBasicStatusResponse;
|
||||
import org.elasticsearch.client.license.GetTrialStatusResponse;
|
||||
import org.elasticsearch.client.license.StartTrialRequest;
|
||||
import org.elasticsearch.client.license.StartTrialResponse;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.io.Streams;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
|
@ -25,11 +30,6 @@ import org.elasticsearch.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.xcontent.XContentFactory;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
import org.elasticsearch.client.license.DeleteLicenseRequest;
|
||||
import org.elasticsearch.client.license.GetLicenseRequest;
|
||||
import org.elasticsearch.client.license.GetLicenseResponse;
|
||||
import org.elasticsearch.client.license.PutLicenseRequest;
|
||||
import org.elasticsearch.client.license.PutLicenseResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -67,8 +67,13 @@ public final class LicenseClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public PutLicenseResponse putLicense(PutLicenseRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, LicenseRequestConverters::putLicense, options,
|
||||
PutLicenseResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
LicenseRequestConverters::putLicense,
|
||||
options,
|
||||
PutLicenseResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,8 +83,14 @@ public final class LicenseClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable putLicenseAsync(PutLicenseRequest request, RequestOptions options, ActionListener<PutLicenseResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, LicenseRequestConverters::putLicense, options,
|
||||
PutLicenseResponse::fromXContent, listener, emptySet());
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
LicenseRequestConverters::putLicense,
|
||||
options,
|
||||
PutLicenseResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,8 +100,13 @@ public final class LicenseClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetLicenseResponse getLicense(GetLicenseRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequest(request, LicenseRequestConverters::getLicense, options,
|
||||
response -> new GetLicenseResponse(convertResponseToJson(response)), emptySet());
|
||||
return restHighLevelClient.performRequest(
|
||||
request,
|
||||
LicenseRequestConverters::getLicense,
|
||||
options,
|
||||
response -> new GetLicenseResponse(convertResponseToJson(response)),
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,8 +116,14 @@ public final class LicenseClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getLicenseAsync(GetLicenseRequest request, RequestOptions options, ActionListener<GetLicenseResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsync(request, LicenseRequestConverters::getLicense, options,
|
||||
response -> new GetLicenseResponse(convertResponseToJson(response)), listener, emptySet());
|
||||
return restHighLevelClient.performRequestAsync(
|
||||
request,
|
||||
LicenseRequestConverters::getLicense,
|
||||
options,
|
||||
response -> new GetLicenseResponse(convertResponseToJson(response)),
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,8 +133,13 @@ public final class LicenseClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse deleteLicense(DeleteLicenseRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, LicenseRequestConverters::deleteLicense, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
LicenseRequestConverters::deleteLicense,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,11 +148,19 @@ public final class LicenseClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deleteLicenseAsync(DeleteLicenseRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
LicenseRequestConverters::deleteLicense, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable deleteLicenseAsync(
|
||||
DeleteLicenseRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
LicenseRequestConverters::deleteLicense,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,8 +170,13 @@ public final class LicenseClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public StartTrialResponse startTrial(StartTrialRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, LicenseRequestConverters::startTrial, options,
|
||||
StartTrialResponse::fromXContent, singleton(403));
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
LicenseRequestConverters::startTrial,
|
||||
options,
|
||||
StartTrialResponse::fromXContent,
|
||||
singleton(403)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,12 +185,16 @@ public final class LicenseClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable startTrialAsync(StartTrialRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<StartTrialResponse> listener) {
|
||||
public Cancellable startTrialAsync(StartTrialRequest request, RequestOptions options, ActionListener<StartTrialResponse> listener) {
|
||||
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, LicenseRequestConverters::startTrial, options,
|
||||
StartTrialResponse::fromXContent, listener, singleton(403));
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
LicenseRequestConverters::startTrial,
|
||||
options,
|
||||
StartTrialResponse::fromXContent,
|
||||
listener,
|
||||
singleton(403)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,8 +204,13 @@ public final class LicenseClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public StartBasicResponse startBasic(StartBasicRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, LicenseRequestConverters::startBasic, options,
|
||||
StartBasicResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
LicenseRequestConverters::startBasic,
|
||||
options,
|
||||
StartBasicResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,10 +219,15 @@ public final class LicenseClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable startBasicAsync(StartBasicRequest request, RequestOptions options,
|
||||
ActionListener<StartBasicResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, LicenseRequestConverters::startBasic, options,
|
||||
StartBasicResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable startBasicAsync(StartBasicRequest request, RequestOptions options, ActionListener<StartBasicResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
LicenseRequestConverters::startBasic,
|
||||
options,
|
||||
StartBasicResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,8 +237,13 @@ public final class LicenseClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetTrialStatusResponse getTrialStatus(RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(Validatable.EMPTY,
|
||||
request -> LicenseRequestConverters.getLicenseTrialStatus(), options, GetTrialStatusResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
Validatable.EMPTY,
|
||||
request -> LicenseRequestConverters.getLicenseTrialStatus(),
|
||||
options,
|
||||
GetTrialStatusResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -194,8 +253,13 @@ public final class LicenseClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetBasicStatusResponse getBasicStatus(RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(Validatable.EMPTY,
|
||||
request -> LicenseRequestConverters.getLicenseBasicStatus(), options, GetBasicStatusResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
Validatable.EMPTY,
|
||||
request -> LicenseRequestConverters.getLicenseBasicStatus(),
|
||||
options,
|
||||
GetBasicStatusResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -221,9 +285,11 @@ public final class LicenseClient {
|
|||
return Streams.copyToString(new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8));
|
||||
} else {
|
||||
// Need to convert into JSON
|
||||
try (InputStream stream = response.getEntity().getContent();
|
||||
XContentParser parser = XContentFactory.xContent(xContentType).createParser(NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION, stream)) {
|
||||
try (
|
||||
InputStream stream = response.getEntity().getContent();
|
||||
XContentParser parser = XContentFactory.xContent(xContentType)
|
||||
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, stream)
|
||||
) {
|
||||
parser.nextToken();
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.copyCurrentStructure(parser);
|
||||
|
|
|
@ -12,11 +12,11 @@ import org.apache.http.client.methods.HttpDelete;
|
|||
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.license.StartTrialRequest;
|
||||
import org.elasticsearch.client.license.StartBasicRequest;
|
||||
import org.elasticsearch.client.license.DeleteLicenseRequest;
|
||||
import org.elasticsearch.client.license.GetLicenseRequest;
|
||||
import org.elasticsearch.client.license.PutLicenseRequest;
|
||||
import org.elasticsearch.client.license.StartBasicRequest;
|
||||
import org.elasticsearch.client.license.StartTrialRequest;
|
||||
|
||||
final class LicenseRequestConverters {
|
||||
|
||||
|
@ -69,9 +69,7 @@ final class LicenseRequestConverters {
|
|||
}
|
||||
|
||||
static Request startBasic(StartBasicRequest startBasicRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_license", "start_basic")
|
||||
.build();
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_license", "start_basic").build();
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params parameters = new RequestConverters.Params();
|
||||
parameters.withTimeout(startBasicRequest.timeout());
|
||||
|
|
|
@ -91,8 +91,7 @@ final class MLRequestConverters {
|
|||
private MLRequestConverters() {}
|
||||
|
||||
static Request putJob(PutJobRequest putJobRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(putJobRequest.getJob().getId())
|
||||
.build();
|
||||
|
@ -102,8 +101,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getJob(GetJobRequest getJobRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(Strings.collectionToCommaDelimitedString(getJobRequest.getJobIds()))
|
||||
.build();
|
||||
|
@ -121,8 +119,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getJobStats(GetJobStatsRequest getJobStatsRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(Strings.collectionToCommaDelimitedString(getJobStatsRequest.getJobIds()))
|
||||
.addPathPartAsIs("_stats")
|
||||
|
@ -138,8 +135,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request openJob(OpenJobRequest openJobRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(openJobRequest.getJobId())
|
||||
.addPathPartAsIs("_open")
|
||||
|
@ -150,8 +146,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request closeJob(CloseJobRequest closeJobRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(Strings.collectionToCommaDelimitedString(closeJobRequest.getJobIds()))
|
||||
.addPathPartAsIs("_close")
|
||||
|
@ -162,8 +157,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteExpiredData(DeleteExpiredDataRequest deleteExpiredDataRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("_delete_expired_data")
|
||||
.addPathPart(deleteExpiredDataRequest.getJobId())
|
||||
.build();
|
||||
|
@ -173,8 +167,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteJob(DeleteJobRequest deleteJobRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(deleteJobRequest.getJobId())
|
||||
.build();
|
||||
|
@ -192,8 +185,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request flushJob(FlushJobRequest flushJobRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(flushJobRequest.getJobId())
|
||||
.addPathPartAsIs("_flush")
|
||||
|
@ -204,8 +196,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request forecastJob(ForecastJobRequest forecastJobRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(forecastJobRequest.getJobId())
|
||||
.addPathPartAsIs("_forecast")
|
||||
|
@ -216,8 +207,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request updateJob(UpdateJobRequest updateJobRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(updateJobRequest.getJobUpdate().getJobId())
|
||||
.addPathPartAsIs("_update")
|
||||
|
@ -228,8 +218,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request putDatafeed(PutDatafeedRequest putDatafeedRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("datafeeds")
|
||||
.addPathPart(putDatafeedRequest.getDatafeed().getId())
|
||||
.build();
|
||||
|
@ -239,8 +228,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request updateDatafeed(UpdateDatafeedRequest updateDatafeedRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("datafeeds")
|
||||
.addPathPart(updateDatafeedRequest.getDatafeedUpdate().getId())
|
||||
.addPathPartAsIs("_update")
|
||||
|
@ -251,8 +239,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getDatafeed(GetDatafeedRequest getDatafeedRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("datafeeds")
|
||||
.addPathPart(Strings.collectionToCommaDelimitedString(getDatafeedRequest.getDatafeedIds()))
|
||||
.build();
|
||||
|
@ -260,8 +247,7 @@ final class MLRequestConverters {
|
|||
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
if (getDatafeedRequest.getAllowNoMatch() != null) {
|
||||
params.putParam(GetDatafeedRequest.ALLOW_NO_MATCH.getPreferredName(),
|
||||
Boolean.toString(getDatafeedRequest.getAllowNoMatch()));
|
||||
params.putParam(GetDatafeedRequest.ALLOW_NO_MATCH.getPreferredName(), Boolean.toString(getDatafeedRequest.getAllowNoMatch()));
|
||||
}
|
||||
if (getDatafeedRequest.getExcludeGenerated() != null) {
|
||||
params.putParam(GetDatafeedRequest.EXCLUDE_GENERATED, Boolean.toString(getDatafeedRequest.getExcludeGenerated()));
|
||||
|
@ -271,8 +257,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteDatafeed(DeleteDatafeedRequest deleteDatafeedRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("datafeeds")
|
||||
.addPathPart(deleteDatafeedRequest.getDatafeedId())
|
||||
.build();
|
||||
|
@ -286,8 +271,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request startDatafeed(StartDatafeedRequest startDatafeedRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("datafeeds")
|
||||
.addPathPart(startDatafeedRequest.getDatafeedId())
|
||||
.addPathPartAsIs("_start")
|
||||
|
@ -298,8 +282,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request stopDatafeed(StopDatafeedRequest stopDatafeedRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("datafeeds")
|
||||
.addPathPart(Strings.collectionToCommaDelimitedString(stopDatafeedRequest.getDatafeedIds()))
|
||||
.addPathPartAsIs("_stop")
|
||||
|
@ -310,8 +293,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getDatafeedStats(GetDatafeedStatsRequest getDatafeedStatsRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("datafeeds")
|
||||
.addPathPart(Strings.collectionToCommaDelimitedString(getDatafeedStatsRequest.getDatafeedIds()))
|
||||
.addPathPartAsIs("_stats")
|
||||
|
@ -327,12 +309,10 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request previewDatafeed(PreviewDatafeedRequest previewDatafeedRequest) throws IOException {
|
||||
EndpointBuilder builder = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("datafeeds");
|
||||
String endpoint = previewDatafeedRequest.getDatafeedId() != null ?
|
||||
builder.addPathPart(previewDatafeedRequest.getDatafeedId()).addPathPartAsIs("_preview").build() :
|
||||
builder.addPathPartAsIs("_preview").build();
|
||||
EndpointBuilder builder = new EndpointBuilder().addPathPartAsIs("_ml").addPathPartAsIs("datafeeds");
|
||||
String endpoint = previewDatafeedRequest.getDatafeedId() != null
|
||||
? builder.addPathPart(previewDatafeedRequest.getDatafeedId()).addPathPartAsIs("_preview").build()
|
||||
: builder.addPathPartAsIs("_preview").build();
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
if (previewDatafeedRequest.getDatafeedId() == null) {
|
||||
request.setEntity(createEntity(previewDatafeedRequest, REQUEST_BODY_CONTENT_TYPE));
|
||||
|
@ -341,8 +321,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteForecast(DeleteForecastRequest deleteForecastRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(deleteForecastRequest.getJobId())
|
||||
.addPathPartAsIs("_forecast")
|
||||
|
@ -361,8 +340,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteModelSnapshot(DeleteModelSnapshotRequest deleteModelSnapshotRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(deleteModelSnapshotRequest.getJobId())
|
||||
.addPathPartAsIs("model_snapshots")
|
||||
|
@ -372,8 +350,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getBuckets(GetBucketsRequest getBucketsRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(getBucketsRequest.getJobId())
|
||||
.addPathPartAsIs("results")
|
||||
|
@ -385,8 +362,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getCategories(GetCategoriesRequest getCategoriesRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(getCategoriesRequest.getJobId())
|
||||
.addPathPartAsIs("results")
|
||||
|
@ -398,8 +374,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getModelSnapshots(GetModelSnapshotsRequest getModelSnapshotsRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(getModelSnapshotsRequest.getJobId())
|
||||
.addPathPartAsIs("model_snapshots")
|
||||
|
@ -410,8 +385,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request updateModelSnapshot(UpdateModelSnapshotRequest updateModelSnapshotRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(updateModelSnapshotRequest.getJobId())
|
||||
.addPathPartAsIs("model_snapshots")
|
||||
|
@ -424,8 +398,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request upgradeJobSnapshot(UpgradeJobModelSnapshotRequest upgradeJobModelSnapshotRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(upgradeJobModelSnapshotRequest.getJobId())
|
||||
.addPathPartAsIs("model_snapshots")
|
||||
|
@ -435,20 +408,23 @@ final class MLRequestConverters {
|
|||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
if (upgradeJobModelSnapshotRequest.getTimeout() != null) {
|
||||
params.putParam(UpgradeJobModelSnapshotRequest.TIMEOUT.getPreferredName(),
|
||||
upgradeJobModelSnapshotRequest.getTimeout().getStringRep());
|
||||
params.putParam(
|
||||
UpgradeJobModelSnapshotRequest.TIMEOUT.getPreferredName(),
|
||||
upgradeJobModelSnapshotRequest.getTimeout().getStringRep()
|
||||
);
|
||||
}
|
||||
if (upgradeJobModelSnapshotRequest.getWaitForCompletion() != null) {
|
||||
params.putParam(UpgradeJobModelSnapshotRequest.WAIT_FOR_COMPLETION.getPreferredName(),
|
||||
upgradeJobModelSnapshotRequest.getWaitForCompletion().toString());
|
||||
params.putParam(
|
||||
UpgradeJobModelSnapshotRequest.WAIT_FOR_COMPLETION.getPreferredName(),
|
||||
upgradeJobModelSnapshotRequest.getWaitForCompletion().toString()
|
||||
);
|
||||
}
|
||||
request.addParameters(params.asMap());
|
||||
return request;
|
||||
}
|
||||
|
||||
static Request revertModelSnapshot(RevertModelSnapshotRequest revertModelSnapshotsRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(revertModelSnapshotsRequest.getJobId())
|
||||
.addPathPartAsIs("model_snapshots")
|
||||
|
@ -461,8 +437,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getOverallBuckets(GetOverallBucketsRequest getOverallBucketsRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(Strings.collectionToCommaDelimitedString(getOverallBucketsRequest.getJobIds()))
|
||||
.addPathPartAsIs("results")
|
||||
|
@ -474,8 +449,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getRecords(GetRecordsRequest getRecordsRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(getRecordsRequest.getJobId())
|
||||
.addPathPartAsIs("results")
|
||||
|
@ -487,8 +461,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request postData(PostDataRequest postDataRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(postDataRequest.getJobId())
|
||||
.addPathPartAsIs("_data")
|
||||
|
@ -506,18 +479,19 @@ final class MLRequestConverters {
|
|||
request.addParameters(params.asMap());
|
||||
if (content != null) {
|
||||
BytesRef source = postDataRequest.getContent().toBytesRef();
|
||||
HttpEntity byteEntity = new NByteArrayEntity(source.bytes,
|
||||
HttpEntity byteEntity = new NByteArrayEntity(
|
||||
source.bytes,
|
||||
source.offset,
|
||||
source.length,
|
||||
createContentType(postDataRequest.getXContentType()));
|
||||
createContentType(postDataRequest.getXContentType())
|
||||
);
|
||||
request.setEntity(byteEntity);
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
||||
static Request getInfluencers(GetInfluencersRequest getInfluencersRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPart(getInfluencersRequest.getJobId())
|
||||
.addPathPartAsIs("results")
|
||||
|
@ -529,8 +503,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request putCalendar(PutCalendarRequest putCalendarRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("calendars")
|
||||
.addPathPart(putCalendarRequest.getCalendar().getId())
|
||||
.build();
|
||||
|
@ -540,8 +513,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getCalendars(GetCalendarsRequest getCalendarsRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("calendars")
|
||||
.addPathPart(getCalendarsRequest.getCalendarId())
|
||||
.build();
|
||||
|
@ -551,8 +523,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request putCalendarJob(PutCalendarJobRequest putCalendarJobRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("calendars")
|
||||
.addPathPart(putCalendarJobRequest.getCalendarId())
|
||||
.addPathPartAsIs("jobs")
|
||||
|
@ -562,8 +533,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteCalendarJob(DeleteCalendarJobRequest deleteCalendarJobRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("calendars")
|
||||
.addPathPart(deleteCalendarJobRequest.getCalendarId())
|
||||
.addPathPartAsIs("jobs")
|
||||
|
@ -573,8 +543,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteCalendar(DeleteCalendarRequest deleteCalendarRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("calendars")
|
||||
.addPathPart(deleteCalendarRequest.getCalendarId())
|
||||
.build();
|
||||
|
@ -583,8 +552,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getCalendarEvents(GetCalendarEventsRequest getCalendarEventsRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("calendars")
|
||||
.addPathPart(getCalendarEventsRequest.getCalendarId())
|
||||
.addPathPartAsIs("events")
|
||||
|
@ -595,22 +563,20 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request postCalendarEvents(PostCalendarEventRequest postCalendarEventRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("calendars")
|
||||
.addPathPart(postCalendarEventRequest.getCalendarId())
|
||||
.addPathPartAsIs("events")
|
||||
.build();
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
request.setEntity(createEntity(postCalendarEventRequest,
|
||||
REQUEST_BODY_CONTENT_TYPE,
|
||||
PostCalendarEventRequest.EXCLUDE_CALENDAR_ID_PARAMS));
|
||||
request.setEntity(
|
||||
createEntity(postCalendarEventRequest, REQUEST_BODY_CONTENT_TYPE, PostCalendarEventRequest.EXCLUDE_CALENDAR_ID_PARAMS)
|
||||
);
|
||||
return request;
|
||||
}
|
||||
|
||||
static Request deleteCalendarEvent(DeleteCalendarEventRequest deleteCalendarEventRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("calendars")
|
||||
.addPathPart(deleteCalendarEventRequest.getCalendarId())
|
||||
.addPathPartAsIs("events")
|
||||
|
@ -620,8 +586,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request estimateModelMemory(EstimateModelMemoryRequest estimateModelMemoryRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("anomaly_detectors")
|
||||
.addPathPartAsIs("_estimate_model_memory")
|
||||
.build();
|
||||
|
@ -631,8 +596,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request putDataFrameAnalytics(PutDataFrameAnalyticsRequest putRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "data_frame", "analytics")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "data_frame", "analytics")
|
||||
.addPathPart(putRequest.getConfig().getId())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
@ -641,8 +605,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request updateDataFrameAnalytics(UpdateDataFrameAnalyticsRequest updateRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "data_frame", "analytics")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "data_frame", "analytics")
|
||||
.addPathPart(updateRequest.getUpdate().getId())
|
||||
.addPathPartAsIs("_update")
|
||||
.build();
|
||||
|
@ -652,8 +615,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getDataFrameAnalytics(GetDataFrameAnalyticsRequest getRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "data_frame", "analytics")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "data_frame", "analytics")
|
||||
.addPathPart(Strings.collectionToCommaDelimitedString(getRequest.getIds()))
|
||||
.build();
|
||||
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
|
@ -678,8 +640,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getDataFrameAnalyticsStats(GetDataFrameAnalyticsStatsRequest getStatsRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "data_frame", "analytics")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "data_frame", "analytics")
|
||||
.addPathPart(Strings.collectionToCommaDelimitedString(getStatsRequest.getIds()))
|
||||
.addPathPartAsIs("_stats")
|
||||
.build();
|
||||
|
@ -695,16 +656,17 @@ final class MLRequestConverters {
|
|||
}
|
||||
}
|
||||
if (getStatsRequest.getAllowNoMatch() != null) {
|
||||
params.putParam(GetDataFrameAnalyticsStatsRequest.ALLOW_NO_MATCH.getPreferredName(),
|
||||
Boolean.toString(getStatsRequest.getAllowNoMatch()));
|
||||
params.putParam(
|
||||
GetDataFrameAnalyticsStatsRequest.ALLOW_NO_MATCH.getPreferredName(),
|
||||
Boolean.toString(getStatsRequest.getAllowNoMatch())
|
||||
);
|
||||
}
|
||||
request.addParameters(params.asMap());
|
||||
return request;
|
||||
}
|
||||
|
||||
static Request startDataFrameAnalytics(StartDataFrameAnalyticsRequest startRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "data_frame", "analytics")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "data_frame", "analytics")
|
||||
.addPathPart(startRequest.getId())
|
||||
.addPathPartAsIs("_start")
|
||||
.build();
|
||||
|
@ -718,8 +680,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request stopDataFrameAnalytics(StopDataFrameAnalyticsRequest stopRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "data_frame", "analytics")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "data_frame", "analytics")
|
||||
.addPathPart(stopRequest.getId())
|
||||
.addPathPartAsIs("_stop")
|
||||
.build();
|
||||
|
@ -730,7 +691,9 @@ final class MLRequestConverters {
|
|||
}
|
||||
if (stopRequest.getAllowNoMatch() != null) {
|
||||
params.putParam(
|
||||
StopDataFrameAnalyticsRequest.ALLOW_NO_MATCH.getPreferredName(), Boolean.toString(stopRequest.getAllowNoMatch()));
|
||||
StopDataFrameAnalyticsRequest.ALLOW_NO_MATCH.getPreferredName(),
|
||||
Boolean.toString(stopRequest.getAllowNoMatch())
|
||||
);
|
||||
}
|
||||
if (stopRequest.getForce() != null) {
|
||||
params.putParam(StopDataFrameAnalyticsRequest.FORCE.getPreferredName(), Boolean.toString(stopRequest.getForce()));
|
||||
|
@ -740,8 +703,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteDataFrameAnalytics(DeleteDataFrameAnalyticsRequest deleteRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "data_frame", "analytics")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "data_frame", "analytics")
|
||||
.addPathPart(deleteRequest.getId())
|
||||
.build();
|
||||
|
||||
|
@ -760,9 +722,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request evaluateDataFrame(EvaluateDataFrameRequest evaluateRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "data_frame", "_evaluate")
|
||||
.build();
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "data_frame", "_evaluate").build();
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
request.setEntity(createEntity(evaluateRequest, REQUEST_BODY_CONTENT_TYPE));
|
||||
return request;
|
||||
|
@ -783,8 +743,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getTrainedModels(GetTrainedModelsRequest getTrainedModelsRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "trained_models")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "trained_models")
|
||||
.addPathPart(Strings.collectionToCommaDelimitedString(getTrainedModelsRequest.getIds()))
|
||||
.build();
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
|
@ -798,16 +757,19 @@ final class MLRequestConverters {
|
|||
}
|
||||
}
|
||||
if (getTrainedModelsRequest.getAllowNoMatch() != null) {
|
||||
params.putParam(GetTrainedModelsRequest.ALLOW_NO_MATCH,
|
||||
Boolean.toString(getTrainedModelsRequest.getAllowNoMatch()));
|
||||
params.putParam(GetTrainedModelsRequest.ALLOW_NO_MATCH, Boolean.toString(getTrainedModelsRequest.getAllowNoMatch()));
|
||||
}
|
||||
if (getTrainedModelsRequest.getDecompressDefinition() != null) {
|
||||
params.putParam(GetTrainedModelsRequest.DECOMPRESS_DEFINITION,
|
||||
Boolean.toString(getTrainedModelsRequest.getDecompressDefinition()));
|
||||
params.putParam(
|
||||
GetTrainedModelsRequest.DECOMPRESS_DEFINITION,
|
||||
Boolean.toString(getTrainedModelsRequest.getDecompressDefinition())
|
||||
);
|
||||
}
|
||||
if (getTrainedModelsRequest.getIncludes().isEmpty() == false) {
|
||||
params.putParam(GetTrainedModelsRequest.INCLUDE,
|
||||
Strings.collectionToCommaDelimitedString(getTrainedModelsRequest.getIncludes()));
|
||||
params.putParam(
|
||||
GetTrainedModelsRequest.INCLUDE,
|
||||
Strings.collectionToCommaDelimitedString(getTrainedModelsRequest.getIncludes())
|
||||
);
|
||||
}
|
||||
if (getTrainedModelsRequest.getTags() != null) {
|
||||
params.putParam(GetTrainedModelsRequest.TAGS, Strings.collectionToCommaDelimitedString(getTrainedModelsRequest.getTags()));
|
||||
|
@ -821,8 +783,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getTrainedModelsStats(GetTrainedModelsStatsRequest getTrainedModelsStatsRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "trained_models")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "trained_models")
|
||||
.addPathPart(Strings.collectionToCommaDelimitedString(getTrainedModelsStatsRequest.getIds()))
|
||||
.addPathPart("_stats")
|
||||
.build();
|
||||
|
@ -837,8 +798,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
}
|
||||
if (getTrainedModelsStatsRequest.getAllowNoMatch() != null) {
|
||||
params.putParam(GetTrainedModelsStatsRequest.ALLOW_NO_MATCH,
|
||||
Boolean.toString(getTrainedModelsStatsRequest.getAllowNoMatch()));
|
||||
params.putParam(GetTrainedModelsStatsRequest.ALLOW_NO_MATCH, Boolean.toString(getTrainedModelsStatsRequest.getAllowNoMatch()));
|
||||
}
|
||||
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
request.addParameters(params.asMap());
|
||||
|
@ -846,16 +806,12 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteTrainedModel(DeleteTrainedModelRequest deleteRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "trained_models")
|
||||
.addPathPart(deleteRequest.getId())
|
||||
.build();
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "trained_models").addPathPart(deleteRequest.getId()).build();
|
||||
return new Request(HttpDelete.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request putTrainedModel(PutTrainedModelRequest putTrainedModelRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "trained_models")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "trained_models")
|
||||
.addPathPart(putTrainedModelRequest.getTrainedModelConfig().getModelId())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
@ -864,8 +820,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request putTrainedModelAlias(PutTrainedModelAliasRequest putTrainedModelAliasRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "trained_models")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "trained_models")
|
||||
.addPathPart(putTrainedModelAliasRequest.getModelId())
|
||||
.addPathPartAsIs("model_aliases")
|
||||
.addPathPart(putTrainedModelAliasRequest.getModelAlias())
|
||||
|
@ -880,8 +835,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteTrainedModelAlias(DeleteTrainedModelAliasRequest deleteTrainedModelAliasRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "trained_models")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "trained_models")
|
||||
.addPathPart(deleteTrainedModelAliasRequest.getModelId())
|
||||
.addPathPartAsIs("model_aliases")
|
||||
.addPathPart(deleteTrainedModelAliasRequest.getModelAlias())
|
||||
|
@ -890,8 +844,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request putFilter(PutFilterRequest putFilterRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("filters")
|
||||
.addPathPart(putFilterRequest.getMlFilter().getId())
|
||||
.build();
|
||||
|
@ -901,8 +854,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request getFilter(GetFiltersRequest getFiltersRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("filters")
|
||||
.addPathPart(getFiltersRequest.getFilterId())
|
||||
.build();
|
||||
|
@ -919,8 +871,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request updateFilter(UpdateFilterRequest updateFilterRequest) throws IOException {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml")
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml")
|
||||
.addPathPartAsIs("filters")
|
||||
.addPathPart(updateFilterRequest.getFilterId())
|
||||
.addPathPartAsIs("_update")
|
||||
|
@ -931,10 +882,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteFilter(DeleteFilterRequest deleteFilterRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "filters")
|
||||
.addPathPart(deleteFilterRequest.getId())
|
||||
.build();
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "filters").addPathPart(deleteFilterRequest.getId()).build();
|
||||
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
|
||||
return request;
|
||||
}
|
||||
|
@ -952,9 +900,7 @@ final class MLRequestConverters {
|
|||
}
|
||||
|
||||
static Request mlInfo(MlInfoRequest infoRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_ml", "info")
|
||||
.build();
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_ml", "info").build();
|
||||
return new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -48,8 +48,13 @@ public final class MigrationClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public DeprecationInfoResponse getDeprecationInfo(DeprecationInfoRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, MigrationRequestConverters::getDeprecationInfo, options,
|
||||
DeprecationInfoResponse::fromXContent, Collections.emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
MigrationRequestConverters::getDeprecationInfo,
|
||||
options,
|
||||
DeprecationInfoResponse::fromXContent,
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,10 +64,19 @@ public final class MigrationClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getDeprecationInfoAsync(DeprecationInfoRequest request, RequestOptions options,
|
||||
ActionListener<DeprecationInfoResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, MigrationRequestConverters::getDeprecationInfo, options,
|
||||
DeprecationInfoResponse::fromXContent, listener, Collections.emptySet());
|
||||
public Cancellable getDeprecationInfoAsync(
|
||||
DeprecationInfoRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<DeprecationInfoResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
MigrationRequestConverters::getDeprecationInfo,
|
||||
options,
|
||||
DeprecationInfoResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,8 +86,8 @@ public final class MigrationClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetFeatureUpgradeStatusResponse getFeatureUpgradeStatus(
|
||||
GetFeatureUpgradeStatusRequest request, RequestOptions options) throws IOException {
|
||||
public GetFeatureUpgradeStatusResponse getFeatureUpgradeStatus(GetFeatureUpgradeStatusRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
MigrationRequestConverters::getFeatureUpgradeStatus,
|
||||
|
@ -90,8 +104,11 @@ public final class MigrationClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getFeatureUpgradeStatusAsync(GetFeatureUpgradeStatusRequest request,
|
||||
RequestOptions options, ActionListener<GetFeatureUpgradeStatusResponse> listener) {
|
||||
public Cancellable getFeatureUpgradeStatusAsync(
|
||||
GetFeatureUpgradeStatusRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<GetFeatureUpgradeStatusResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
MigrationRequestConverters::getFeatureUpgradeStatus,
|
||||
|
@ -109,8 +126,7 @@ public final class MigrationClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public PostFeatureUpgradeResponse postFeatureUpgrade(
|
||||
PostFeatureUpgradeRequest request, RequestOptions options) throws IOException {
|
||||
public PostFeatureUpgradeResponse postFeatureUpgrade(PostFeatureUpgradeRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
MigrationRequestConverters::postFeatureUpgrade,
|
||||
|
@ -128,8 +144,10 @@ public final class MigrationClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable postFeatureUpgradeAsync(
|
||||
PostFeatureUpgradeRequest request, RequestOptions options,
|
||||
ActionListener<PostFeatureUpgradeResponse> listener) throws IOException {
|
||||
PostFeatureUpgradeRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<PostFeatureUpgradeResponse> listener
|
||||
) throws IOException {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
MigrationRequestConverters::postFeatureUpgrade,
|
||||
|
|
|
@ -16,12 +16,10 @@ import org.elasticsearch.client.migration.PostFeatureUpgradeRequest;
|
|||
|
||||
final class MigrationRequestConverters {
|
||||
|
||||
private MigrationRequestConverters() {
|
||||
}
|
||||
private MigrationRequestConverters() {}
|
||||
|
||||
static Request getDeprecationInfo(DeprecationInfoRequest deprecationInfoRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addCommaSeparatedPathParts(deprecationInfoRequest.getIndices())
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addCommaSeparatedPathParts(deprecationInfoRequest.getIndices())
|
||||
.addPathPartAsIs("_migration", "deprecations")
|
||||
.build();
|
||||
|
||||
|
@ -34,9 +32,7 @@ final class MigrationRequestConverters {
|
|||
* @return a {@link Request} with the correct path and HTTP request type
|
||||
*/
|
||||
static Request getFeatureUpgradeStatus(GetFeatureUpgradeStatusRequest getFeatureUpgradeStatusRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_migration", "system_features")
|
||||
.build();
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_migration", "system_features").build();
|
||||
|
||||
return new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
@ -47,9 +43,7 @@ final class MigrationRequestConverters {
|
|||
* @return a {@link Request} with the correct path and HTTP request type
|
||||
*/
|
||||
static Request postFeatureUpgrade(PostFeatureUpgradeRequest postFeatureUpgradeRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_migration", "system_features")
|
||||
.build();
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_migration", "system_features").build();
|
||||
|
||||
return new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
package org.elasticsearch.client;
|
||||
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
|
||||
/**
|
||||
* Base class for responses that are node responses. These responses always contain the cluster
|
||||
|
|
|
@ -10,12 +10,12 @@ package org.elasticsearch.client;
|
|||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
|
||||
import org.elasticsearch.core.Nullable;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.rest.action.RestActions;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ToXContent;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.rest.action.RestActions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
@ -34,8 +34,9 @@ public final class NodesResponseHeader {
|
|||
public static final ParseField FAILURES = new ParseField("failures");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final ConstructingObjectParser<NodesResponseHeader, Void> PARSER =
|
||||
new ConstructingObjectParser<>("nodes_response_header", true,
|
||||
public static final ConstructingObjectParser<NodesResponseHeader, Void> PARSER = new ConstructingObjectParser<>(
|
||||
"nodes_response_header",
|
||||
true,
|
||||
(a) -> {
|
||||
int i = 0;
|
||||
int total = (Integer) a[i++];
|
||||
|
@ -43,14 +44,18 @@ public final class NodesResponseHeader {
|
|||
int failed = (Integer) a[i++];
|
||||
List<ElasticsearchException> failures = (List<ElasticsearchException>) a[i++];
|
||||
return new NodesResponseHeader(total, successful, failed, failures);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
static {
|
||||
PARSER.declareInt(ConstructingObjectParser.constructorArg(), TOTAL);
|
||||
PARSER.declareInt(ConstructingObjectParser.constructorArg(), SUCCESSFUL);
|
||||
PARSER.declareInt(ConstructingObjectParser.constructorArg(), FAILED);
|
||||
PARSER.declareObjectArray(ConstructingObjectParser.optionalConstructorArg(),
|
||||
(p, c) -> ElasticsearchException.fromXContent(p), FAILURES);
|
||||
PARSER.declareObjectArray(
|
||||
ConstructingObjectParser.optionalConstructorArg(),
|
||||
(p, c) -> ElasticsearchException.fromXContent(p),
|
||||
FAILURES
|
||||
);
|
||||
}
|
||||
|
||||
private final int total;
|
||||
|
@ -111,10 +116,7 @@ public final class NodesResponseHeader {
|
|||
return false;
|
||||
}
|
||||
NodesResponseHeader that = (NodesResponseHeader) o;
|
||||
return total == that.total &&
|
||||
successful == that.successful &&
|
||||
failed == that.failed &&
|
||||
Objects.equals(failures, that.failures);
|
||||
return total == that.total && successful == that.successful && failed == that.failed && Objects.equals(failures, that.failures);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -47,22 +47,15 @@ import org.elasticsearch.client.indices.AnalyzeRequest;
|
|||
import org.elasticsearch.client.security.RefreshPolicy;
|
||||
import org.elasticsearch.client.tasks.TaskId;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.core.Nullable;
|
||||
import org.elasticsearch.common.Priority;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.core.SuppressForbidden;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.lucene.uid.Versions;
|
||||
import org.elasticsearch.core.TimeValue;
|
||||
import org.elasticsearch.common.util.CollectionUtils;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.ToXContent;
|
||||
import org.elasticsearch.xcontent.XContent;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
import org.elasticsearch.core.Nullable;
|
||||
import org.elasticsearch.core.SuppressForbidden;
|
||||
import org.elasticsearch.core.TimeValue;
|
||||
import org.elasticsearch.index.VersionType;
|
||||
import org.elasticsearch.index.rankeval.RankEvalRequest;
|
||||
import org.elasticsearch.index.reindex.AbstractBulkByScrollRequest;
|
||||
|
@ -74,6 +67,13 @@ import org.elasticsearch.rest.action.search.RestSearchAction;
|
|||
import org.elasticsearch.script.mustache.MultiSearchTemplateRequest;
|
||||
import org.elasticsearch.script.mustache.SearchTemplateRequest;
|
||||
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
|
||||
import org.elasticsearch.xcontent.DeprecationHandler;
|
||||
import org.elasticsearch.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.xcontent.ToXContent;
|
||||
import org.elasticsearch.xcontent.XContent;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -216,14 +216,19 @@ final class RequestConverters {
|
|||
BytesReference indexSource = indexRequest.source();
|
||||
XContentType indexXContentType = indexRequest.getContentType();
|
||||
|
||||
try (XContentParser parser = XContentHelper.createParser(
|
||||
try (
|
||||
XContentParser parser = XContentHelper.createParser(
|
||||
/*
|
||||
* EMPTY and THROW are fine here because we just call
|
||||
* copyCurrentStructure which doesn't touch the
|
||||
* registry or deprecation.
|
||||
*/
|
||||
NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
indexSource, indexXContentType)) {
|
||||
NamedXContentRegistry.EMPTY,
|
||||
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
|
||||
indexSource,
|
||||
indexXContentType
|
||||
)
|
||||
) {
|
||||
try (XContentBuilder builder = XContentBuilder.builder(bulkContentType.xContent())) {
|
||||
builder.copyCurrentStructure(parser);
|
||||
source = BytesReference.bytes(builder).toBytesRef();
|
||||
|
@ -363,8 +368,14 @@ final class RequestConverters {
|
|||
if (updateRequest.upsertRequest() != null) {
|
||||
XContentType upsertContentType = updateRequest.upsertRequest().getContentType();
|
||||
if ((xContentType != null) && (xContentType != upsertContentType)) {
|
||||
throw new IllegalStateException("Update request cannot have different content types for doc [" + xContentType + "]" +
|
||||
" and upsert [" + upsertContentType + "] documents");
|
||||
throw new IllegalStateException(
|
||||
"Update request cannot have different content types for doc ["
|
||||
+ xContentType
|
||||
+ "]"
|
||||
+ " and upsert ["
|
||||
+ upsertContentType
|
||||
+ "] documents"
|
||||
);
|
||||
} else {
|
||||
xContentType = upsertContentType;
|
||||
}
|
||||
|
@ -593,8 +604,7 @@ final class RequestConverters {
|
|||
private static Request prepareReindexRequest(ReindexRequest reindexRequest, boolean waitForCompletion) throws IOException {
|
||||
String endpoint = new EndpointBuilder().addPathPart("_reindex").build();
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
Params params = new Params()
|
||||
.withWaitForCompletion(waitForCompletion)
|
||||
Params params = new Params().withWaitForCompletion(waitForCompletion)
|
||||
.withRefresh(reindexRequest.isRefresh())
|
||||
.withTimeout(reindexRequest.getTimeout())
|
||||
.withWaitForActiveShards(reindexRequest.getWaitForActiveShards())
|
||||
|
@ -611,12 +621,11 @@ final class RequestConverters {
|
|||
return request;
|
||||
}
|
||||
|
||||
private static Request prepareDeleteByQueryRequest(DeleteByQueryRequest deleteByQueryRequest,
|
||||
boolean waitForCompletion) throws IOException {
|
||||
private static Request prepareDeleteByQueryRequest(DeleteByQueryRequest deleteByQueryRequest, boolean waitForCompletion)
|
||||
throws IOException {
|
||||
String endpoint = endpoint(deleteByQueryRequest.indices(), "_delete_by_query");
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
Params params = new Params()
|
||||
.withRouting(deleteByQueryRequest.getRouting())
|
||||
Params params = new Params().withRouting(deleteByQueryRequest.getRouting())
|
||||
.withRefresh(deleteByQueryRequest.isRefresh())
|
||||
.withTimeout(deleteByQueryRequest.getTimeout())
|
||||
.withWaitForActiveShards(deleteByQueryRequest.getWaitForActiveShards())
|
||||
|
@ -645,12 +654,10 @@ final class RequestConverters {
|
|||
return request;
|
||||
}
|
||||
|
||||
static Request prepareUpdateByQueryRequest(UpdateByQueryRequest updateByQueryRequest,
|
||||
boolean waitForCompletion) throws IOException {
|
||||
static Request prepareUpdateByQueryRequest(UpdateByQueryRequest updateByQueryRequest, boolean waitForCompletion) throws IOException {
|
||||
String endpoint = endpoint(updateByQueryRequest.indices(), "_update_by_query");
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
Params params = new Params()
|
||||
.withRouting(updateByQueryRequest.getRouting())
|
||||
Params params = new Params().withRouting(updateByQueryRequest.getRouting())
|
||||
.withPipeline(updateByQueryRequest.getPipeline())
|
||||
.withRefresh(updateByQueryRequest.isRefresh())
|
||||
.withTimeout(updateByQueryRequest.getTimeout())
|
||||
|
@ -691,11 +698,12 @@ final class RequestConverters {
|
|||
}
|
||||
|
||||
private static Request rethrottle(RethrottleRequest rethrottleRequest, String firstPathPart) {
|
||||
String endpoint = new EndpointBuilder().addPathPart(firstPathPart).addPathPart(rethrottleRequest.getTaskId().toString())
|
||||
.addPathPart("_rethrottle").build();
|
||||
String endpoint = new EndpointBuilder().addPathPart(firstPathPart)
|
||||
.addPathPart(rethrottleRequest.getTaskId().toString())
|
||||
.addPathPart("_rethrottle")
|
||||
.build();
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
Params params = new Params()
|
||||
.withRequestsPerSecond(rethrottleRequest.getRequestsPerSecond());
|
||||
Params params = new Params().withRequestsPerSecond(rethrottleRequest.getRequestsPerSecond());
|
||||
// we set "group_by" to "none" because this is the response format we can parse back
|
||||
params.putParam("group_by", "none");
|
||||
request.addParameters(params.asMap());
|
||||
|
@ -811,13 +819,17 @@ final class RequestConverters {
|
|||
|
||||
@Deprecated
|
||||
static String endpoint(String[] indices, String[] types, String endpoint) {
|
||||
return new EndpointBuilder().addCommaSeparatedPathParts(indices).addCommaSeparatedPathParts(types)
|
||||
.addPathPartAsIs(endpoint).build();
|
||||
return new EndpointBuilder().addCommaSeparatedPathParts(indices)
|
||||
.addCommaSeparatedPathParts(types)
|
||||
.addPathPartAsIs(endpoint)
|
||||
.build();
|
||||
}
|
||||
|
||||
static String endpoint(String[] indices, String endpoint, String[] suffixes) {
|
||||
return new EndpointBuilder().addCommaSeparatedPathParts(indices).addPathPartAsIs(endpoint)
|
||||
.addCommaSeparatedPathParts(suffixes).build();
|
||||
return new EndpointBuilder().addCommaSeparatedPathParts(indices)
|
||||
.addPathPartAsIs(endpoint)
|
||||
.addCommaSeparatedPathParts(suffixes)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@ -843,8 +855,7 @@ final class RequestConverters {
|
|||
static class Params {
|
||||
private final Map<String, String> parameters = new HashMap<>();
|
||||
|
||||
Params() {
|
||||
}
|
||||
Params() {}
|
||||
|
||||
Params putParam(String name, String value) {
|
||||
if (Strings.hasLength(value)) {
|
||||
|
@ -1212,15 +1223,23 @@ final class RequestConverters {
|
|||
static XContentType enforceSameContentType(IndexRequest indexRequest, @Nullable XContentType xContentType) {
|
||||
XContentType requestContentType = indexRequest.getContentType();
|
||||
if (requestContentType.canonical() != XContentType.JSON && requestContentType.canonical() != XContentType.SMILE) {
|
||||
throw new IllegalArgumentException("Unsupported content-type found for request with content-type [" + requestContentType
|
||||
+ "], only JSON and SMILE are supported");
|
||||
throw new IllegalArgumentException(
|
||||
"Unsupported content-type found for request with content-type ["
|
||||
+ requestContentType
|
||||
+ "], only JSON and SMILE are supported"
|
||||
);
|
||||
}
|
||||
if (xContentType == null) {
|
||||
return requestContentType;
|
||||
}
|
||||
if (requestContentType.canonical() != xContentType.canonical()) {
|
||||
throw new IllegalArgumentException("Mismatching content-type found for request with content-type [" + requestContentType
|
||||
+ "], previous requests have content-type [" + xContentType + "]");
|
||||
throw new IllegalArgumentException(
|
||||
"Mismatching content-type found for request with content-type ["
|
||||
+ requestContentType
|
||||
+ "], previous requests have content-type ["
|
||||
+ xContentType
|
||||
+ "]"
|
||||
);
|
||||
}
|
||||
return xContentType;
|
||||
}
|
||||
|
@ -1280,4 +1299,3 @@ final class RequestConverters {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -13,12 +13,12 @@ import org.elasticsearch.action.search.SearchRequest;
|
|||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.client.core.AcknowledgedResponse;
|
||||
import org.elasticsearch.client.rollup.DeleteRollupJobRequest;
|
||||
import org.elasticsearch.client.rollup.GetRollupCapsRequest;
|
||||
import org.elasticsearch.client.rollup.GetRollupCapsResponse;
|
||||
import org.elasticsearch.client.rollup.GetRollupIndexCapsRequest;
|
||||
import org.elasticsearch.client.rollup.GetRollupIndexCapsResponse;
|
||||
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.PutRollupJobRequest;
|
||||
import org.elasticsearch.client.rollup.StartRollupJobRequest;
|
||||
import org.elasticsearch.client.rollup.StartRollupJobResponse;
|
||||
|
@ -59,11 +59,13 @@ public class RollupClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse putRollupJob(PutRollupJobRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
RollupRequestConverters::putJob,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,13 +77,19 @@ public class RollupClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable putRollupJobAsync(PutRollupJobRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
public Cancellable putRollupJobAsync(
|
||||
PutRollupJobRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
RollupRequestConverters::putJob,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener, Collections.emptySet());
|
||||
listener,
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,11 +102,13 @@ public class RollupClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public StartRollupJobResponse startRollupJob(StartRollupJobRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
RollupRequestConverters::startJob,
|
||||
options,
|
||||
StartRollupJobResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,13 +120,19 @@ public class RollupClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable startRollupJobAsync(StartRollupJobRequest request, RequestOptions options,
|
||||
ActionListener<StartRollupJobResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
public Cancellable startRollupJobAsync(
|
||||
StartRollupJobRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<StartRollupJobResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
RollupRequestConverters::startJob,
|
||||
options,
|
||||
StartRollupJobResponse::fromXContent,
|
||||
listener, Collections.emptySet());
|
||||
listener,
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,11 +145,13 @@ public class RollupClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public StopRollupJobResponse stopRollupJob(StopRollupJobRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
RollupRequestConverters::stopJob,
|
||||
options,
|
||||
StopRollupJobResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,13 +163,19 @@ public class RollupClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable stopRollupJobAsync(StopRollupJobRequest request, RequestOptions options,
|
||||
ActionListener<StopRollupJobResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
public Cancellable stopRollupJobAsync(
|
||||
StopRollupJobRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<StopRollupJobResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
RollupRequestConverters::stopJob,
|
||||
options,
|
||||
StopRollupJobResponse::fromXContent,
|
||||
listener, Collections.emptySet());
|
||||
listener,
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -164,12 +188,15 @@ public class RollupClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse deleteRollupJob(DeleteRollupJobRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
RollupRequestConverters::deleteJob,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously delete a rollup job from the cluster
|
||||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-delete-job.html">
|
||||
|
@ -179,14 +206,19 @@ public class RollupClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deleteRollupJobAsync(DeleteRollupJobRequest request,
|
||||
public Cancellable deleteRollupJobAsync(
|
||||
DeleteRollupJobRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
RollupRequestConverters::deleteJob,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener, Collections.emptySet());
|
||||
listener,
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -199,11 +231,13 @@ public class RollupClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetRollupJobResponse getRollupJob(GetRollupJobRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
RollupRequestConverters::getJob,
|
||||
options,
|
||||
GetRollupJobResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -215,13 +249,19 @@ public class RollupClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getRollupJobAsync(GetRollupJobRequest request, RequestOptions options,
|
||||
ActionListener<GetRollupJobResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
public Cancellable getRollupJobAsync(
|
||||
GetRollupJobRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<GetRollupJobResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
RollupRequestConverters::getJob,
|
||||
options,
|
||||
GetRollupJobResponse::fromXContent,
|
||||
listener, Collections.emptySet());
|
||||
listener,
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -239,7 +279,8 @@ public class RollupClient {
|
|||
RollupRequestConverters::search,
|
||||
options,
|
||||
SearchResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -258,7 +299,8 @@ public class RollupClient {
|
|||
options,
|
||||
SearchResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -271,11 +313,13 @@ public class RollupClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetRollupCapsResponse getRollupCapabilities(GetRollupCapsRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
RollupRequestConverters::getRollupCaps,
|
||||
options,
|
||||
GetRollupCapsResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,14 +331,19 @@ public class RollupClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getRollupCapabilitiesAsync(GetRollupCapsRequest request, RequestOptions options,
|
||||
ActionListener<GetRollupCapsResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
public Cancellable getRollupCapabilitiesAsync(
|
||||
GetRollupCapsRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<GetRollupCapsResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
RollupRequestConverters::getRollupCaps,
|
||||
options,
|
||||
GetRollupCapsResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -306,13 +355,15 @@ public class RollupClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetRollupIndexCapsResponse getRollupIndexCapabilities(GetRollupIndexCapsRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
public GetRollupIndexCapsResponse getRollupIndexCapabilities(GetRollupIndexCapsRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
RollupRequestConverters::getRollupIndexCaps,
|
||||
options,
|
||||
GetRollupIndexCapsResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -324,13 +375,18 @@ public class RollupClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getRollupIndexCapabilitiesAsync(GetRollupIndexCapsRequest request, RequestOptions options,
|
||||
ActionListener<GetRollupIndexCapsResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
public Cancellable getRollupIndexCapabilitiesAsync(
|
||||
GetRollupIndexCapsRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<GetRollupIndexCapsResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
RollupRequestConverters::getRollupIndexCaps,
|
||||
options,
|
||||
GetRollupIndexCapsResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,12 +27,10 @@ import static org.elasticsearch.client.RequestConverters.createEntity;
|
|||
|
||||
final class RollupRequestConverters {
|
||||
|
||||
private RollupRequestConverters() {
|
||||
}
|
||||
private RollupRequestConverters() {}
|
||||
|
||||
static Request putJob(final PutRollupJobRequest putRollupJobRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_rollup", "job")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_rollup", "job")
|
||||
.addPathPart(putRollupJobRequest.getConfig().getId())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
@ -41,8 +39,7 @@ final class RollupRequestConverters {
|
|||
}
|
||||
|
||||
static Request startJob(final StartRollupJobRequest startRollupJobRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_rollup", "job")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_rollup", "job")
|
||||
.addPathPart(startRollupJobRequest.getJobId())
|
||||
.addPathPartAsIs("_start")
|
||||
.build();
|
||||
|
@ -50,8 +47,7 @@ final class RollupRequestConverters {
|
|||
}
|
||||
|
||||
static Request stopJob(final StopRollupJobRequest stopRollupJobRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_rollup", "job")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_rollup", "job")
|
||||
.addPathPart(stopRollupJobRequest.getJobId())
|
||||
.addPathPartAsIs("_stop")
|
||||
.build();
|
||||
|
@ -67,16 +63,14 @@ final class RollupRequestConverters {
|
|||
}
|
||||
|
||||
static Request getJob(final GetRollupJobRequest getRollupJobRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_rollup", "job")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_rollup", "job")
|
||||
.addPathPart(getRollupJobRequest.getJobId())
|
||||
.build();
|
||||
return new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request deleteJob(final DeleteRollupJobRequest deleteRollupJobRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_rollup", "job")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_rollup", "job")
|
||||
.addPathPart(deleteRollupJobRequest.getId())
|
||||
.build();
|
||||
return new Request(HttpDelete.METHOD_NAME, endpoint);
|
||||
|
@ -87,16 +81,14 @@ final class RollupRequestConverters {
|
|||
}
|
||||
|
||||
static Request getRollupCaps(final GetRollupCapsRequest getRollupCapsRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_rollup", "data")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_rollup", "data")
|
||||
.addPathPart(getRollupCapsRequest.getIndexPattern())
|
||||
.build();
|
||||
return new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request getRollupIndexCaps(final GetRollupIndexCapsRequest getRollupIndexCapsRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addCommaSeparatedPathParts(getRollupIndexCapsRequest.indices())
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addCommaSeparatedPathParts(getRollupIndexCapsRequest.indices())
|
||||
.addPathPartAsIs("_rollup", "data")
|
||||
.build();
|
||||
return new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
|
|
|
@ -70,8 +70,8 @@ public class SearchableSnapshotsClient {
|
|||
public Cancellable mountSnapshotAsync(
|
||||
final MountSnapshotRequest request,
|
||||
final RequestOptions options,
|
||||
final ActionListener<RestoreSnapshotResponse> listener)
|
||||
{
|
||||
final ActionListener<RestoreSnapshotResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
SearchableSnapshotsRequestConverters::mountSnapshot,
|
||||
|
@ -114,8 +114,8 @@ public class SearchableSnapshotsClient {
|
|||
public Cancellable cacheStatsAsync(
|
||||
final CachesStatsRequest request,
|
||||
final RequestOptions options,
|
||||
final ActionListener<CachesStatsResponse> listener)
|
||||
{
|
||||
final ActionListener<CachesStatsResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
SearchableSnapshotsRequestConverters::cacheStats,
|
||||
|
|
|
@ -21,8 +21,7 @@ import static org.elasticsearch.client.RequestConverters.createEntity;
|
|||
final class SearchableSnapshotsRequestConverters {
|
||||
|
||||
static Request mountSnapshot(final MountSnapshotRequest mountSnapshotRequest) throws IOException {
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_snapshot")
|
||||
final String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_snapshot")
|
||||
.addPathPart(mountSnapshotRequest.getRepository())
|
||||
.addPathPart(mountSnapshotRequest.getSnapshot())
|
||||
.addPathPartAsIs("_mount")
|
||||
|
@ -44,8 +43,7 @@ final class SearchableSnapshotsRequestConverters {
|
|||
}
|
||||
|
||||
static Request cacheStats(final CachesStatsRequest cacheStatsRequest) {
|
||||
final RequestConverters.EndpointBuilder endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_searchable_snapshots");
|
||||
final RequestConverters.EndpointBuilder endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_searchable_snapshots");
|
||||
if (cacheStatsRequest.getNodesIds() != null) {
|
||||
endpoint.addCommaSeparatedPathParts(cacheStatsRequest.getNodesIds());
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -58,8 +58,7 @@ final class SecurityRequestConverters {
|
|||
private SecurityRequestConverters() {}
|
||||
|
||||
static Request changePassword(ChangePasswordRequest changePasswordRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/user")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/user")
|
||||
.addPathPart(changePasswordRequest.getUsername())
|
||||
.addPathPartAsIs("_password")
|
||||
.build();
|
||||
|
@ -72,8 +71,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request getUsers(GetUsersRequest getUsersRequest) {
|
||||
RequestConverters.EndpointBuilder builder = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/user");
|
||||
RequestConverters.EndpointBuilder builder = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/user");
|
||||
if (getUsersRequest.getUsernames().size() > 0) {
|
||||
builder.addPathPart(Strings.collectionToCommaDelimitedString(getUsersRequest.getUsernames()));
|
||||
}
|
||||
|
@ -81,8 +79,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request putUser(PutUserRequest putUserRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/user")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/user")
|
||||
.addPathPart(putUserRequest.getUser().getUsername())
|
||||
.build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
@ -94,8 +91,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteUser(DeleteUserRequest deleteUserRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security", "user")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security", "user")
|
||||
.addPathPart(deleteUserRequest.getName())
|
||||
.build();
|
||||
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
|
||||
|
@ -106,8 +102,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request putRoleMapping(final PutRoleMappingRequest putRoleMappingRequest) throws IOException {
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/role_mapping")
|
||||
final String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/role_mapping")
|
||||
.addPathPart(putRoleMappingRequest.getName())
|
||||
.build();
|
||||
final Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
@ -136,8 +131,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
private static Request setUserEnabled(SetUserEnabledRequest setUserEnabledRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/user")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/user")
|
||||
.addPathPart(setUserEnabledRequest.getUsername())
|
||||
.addPathPart(setUserEnabledRequest.isEnabled() ? "_enable" : "_disable")
|
||||
.build();
|
||||
|
@ -155,8 +149,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request clearRealmCache(ClearRealmCacheRequest clearRealmCacheRequest) {
|
||||
RequestConverters.EndpointBuilder builder = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/realm");
|
||||
RequestConverters.EndpointBuilder builder = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/realm");
|
||||
if (clearRealmCacheRequest.getRealms().isEmpty() == false) {
|
||||
builder.addCommaSeparatedPathParts(clearRealmCacheRequest.getRealms().toArray(Strings.EMPTY_ARRAY));
|
||||
} else {
|
||||
|
@ -173,8 +166,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request clearRolesCache(ClearRolesCacheRequest disableCacheRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/role")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/role")
|
||||
.addCommaSeparatedPathParts(disableCacheRequest.names())
|
||||
.addPathPart("_clear_cache")
|
||||
.build();
|
||||
|
@ -182,8 +174,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request clearPrivilegesCache(ClearPrivilegesCacheRequest clearPrivilegesCacheRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/privilege")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/privilege")
|
||||
.addCommaSeparatedPathParts(clearPrivilegesCacheRequest.applications())
|
||||
.addPathPart("_clear_cache")
|
||||
.build();
|
||||
|
@ -191,8 +182,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request clearApiKeyCache(ClearApiKeyCacheRequest clearApiKeyCacheRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/api_key")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/api_key")
|
||||
.addCommaSeparatedPathParts(clearApiKeyCacheRequest.ids())
|
||||
.addPathPart("_clear_cache")
|
||||
.build();
|
||||
|
@ -200,8 +190,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request clearServiceAccountTokenCache(ClearServiceAccountTokenCacheRequest clearServiceAccountTokenCacheRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/service")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/service")
|
||||
.addPathPart(clearServiceAccountTokenCacheRequest.getNamespace(), clearServiceAccountTokenCacheRequest.getServiceName())
|
||||
.addPathPartAsIs("credential/token")
|
||||
.addCommaSeparatedPathParts(clearServiceAccountTokenCacheRequest.getTokenNames())
|
||||
|
@ -211,8 +200,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteRoleMapping(DeleteRoleMappingRequest deleteRoleMappingRequest) {
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/role_mapping")
|
||||
final String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/role_mapping")
|
||||
.addPathPart(deleteRoleMappingRequest.getName())
|
||||
.build();
|
||||
final Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
|
||||
|
@ -223,8 +211,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteRole(DeleteRoleRequest deleteRoleRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/role")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/role")
|
||||
.addPathPart(deleteRoleRequest.getName())
|
||||
.build();
|
||||
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
|
||||
|
@ -262,8 +249,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request getPrivileges(GetPrivilegesRequest getPrivilegesRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/privilege")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/privilege")
|
||||
.addPathPart(getPrivilegesRequest.getApplicationName())
|
||||
.addCommaSeparatedPathParts(getPrivilegesRequest.getPrivilegeNames())
|
||||
.build();
|
||||
|
@ -280,8 +266,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request deletePrivileges(DeletePrivilegesRequest deletePrivilegeRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/privilege")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/privilege")
|
||||
.addPathPart(deletePrivilegeRequest.getApplication())
|
||||
.addCommaSeparatedPathParts(deletePrivilegeRequest.getPrivileges())
|
||||
.build();
|
||||
|
@ -293,8 +278,7 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request putRole(final PutRoleRequest putRoleRequest) throws IOException {
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/role")
|
||||
final String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_security/role")
|
||||
.addPathPart(putRoleRequest.getRole().getName())
|
||||
.build();
|
||||
final Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
|
@ -354,8 +338,9 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request getServiceAccounts(final GetServiceAccountsRequest getServiceAccountsRequest) {
|
||||
final RequestConverters.EndpointBuilder endpointBuilder = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/service");
|
||||
final RequestConverters.EndpointBuilder endpointBuilder = new RequestConverters.EndpointBuilder().addPathPartAsIs(
|
||||
"_security/service"
|
||||
);
|
||||
if (getServiceAccountsRequest.getNamespace() != null) {
|
||||
endpointBuilder.addPathPart(getServiceAccountsRequest.getNamespace());
|
||||
if (getServiceAccountsRequest.getServiceName() != null) {
|
||||
|
@ -366,8 +351,9 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request createServiceAccountToken(final CreateServiceAccountTokenRequest createServiceAccountTokenRequest) throws IOException {
|
||||
final RequestConverters.EndpointBuilder endpointBuilder = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/service")
|
||||
final RequestConverters.EndpointBuilder endpointBuilder = new RequestConverters.EndpointBuilder().addPathPartAsIs(
|
||||
"_security/service"
|
||||
)
|
||||
.addPathPart(createServiceAccountTokenRequest.getNamespace(), createServiceAccountTokenRequest.getServiceName())
|
||||
.addPathPartAsIs("credential/token");
|
||||
if (createServiceAccountTokenRequest.getTokenName() != null) {
|
||||
|
@ -383,8 +369,9 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteServiceAccountToken(final DeleteServiceAccountTokenRequest deleteServiceAccountTokenRequest) {
|
||||
final RequestConverters.EndpointBuilder endpointBuilder = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/service")
|
||||
final RequestConverters.EndpointBuilder endpointBuilder = new RequestConverters.EndpointBuilder().addPathPartAsIs(
|
||||
"_security/service"
|
||||
)
|
||||
.addPathPart(deleteServiceAccountTokenRequest.getNamespace(), deleteServiceAccountTokenRequest.getServiceName())
|
||||
.addPathPartAsIs("credential/token")
|
||||
.addPathPart(deleteServiceAccountTokenRequest.getTokenName());
|
||||
|
@ -399,8 +386,9 @@ final class SecurityRequestConverters {
|
|||
}
|
||||
|
||||
static Request getServiceAccountCredentials(final GetServiceAccountCredentialsRequest getServiceAccountCredentialsRequest) {
|
||||
final RequestConverters.EndpointBuilder endpointBuilder = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_security/service")
|
||||
final RequestConverters.EndpointBuilder endpointBuilder = new RequestConverters.EndpointBuilder().addPathPartAsIs(
|
||||
"_security/service"
|
||||
)
|
||||
.addPathPart(getServiceAccountCredentialsRequest.getNamespace(), getServiceAccountCredentialsRequest.getServiceName())
|
||||
.addPathPartAsIs("credential");
|
||||
|
||||
|
|
|
@ -61,10 +61,14 @@ public final class SnapshotClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetRepositoriesResponse getRepository(GetRepositoriesRequest getRepositoriesRequest, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(getRepositoriesRequest, SnapshotRequestConverters::getRepositories, options,
|
||||
GetRepositoriesResponse::fromXContent, emptySet());
|
||||
public GetRepositoriesResponse getRepository(GetRepositoriesRequest getRepositoriesRequest, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
getRepositoriesRequest,
|
||||
SnapshotRequestConverters::getRepositories,
|
||||
options,
|
||||
GetRepositoriesResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,11 +81,19 @@ public final class SnapshotClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getRepositoryAsync(GetRepositoriesRequest getRepositoriesRequest, RequestOptions options,
|
||||
ActionListener<GetRepositoriesResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(getRepositoriesRequest,
|
||||
SnapshotRequestConverters::getRepositories, options,
|
||||
GetRepositoriesResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable getRepositoryAsync(
|
||||
GetRepositoriesRequest getRepositoriesRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<GetRepositoriesResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
getRepositoriesRequest,
|
||||
SnapshotRequestConverters::getRepositories,
|
||||
options,
|
||||
GetRepositoriesResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,8 +106,13 @@ public final class SnapshotClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse createRepository(PutRepositoryRequest putRepositoryRequest, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(putRepositoryRequest, SnapshotRequestConverters::createRepository, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
putRepositoryRequest,
|
||||
SnapshotRequestConverters::createRepository,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,11 +124,19 @@ public final class SnapshotClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable createRepositoryAsync(PutRepositoryRequest putRepositoryRequest, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(putRepositoryRequest,
|
||||
SnapshotRequestConverters::createRepository, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable createRepositoryAsync(
|
||||
PutRepositoryRequest putRepositoryRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
putRepositoryRequest,
|
||||
SnapshotRequestConverters::createRepository,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,8 +150,13 @@ public final class SnapshotClient {
|
|||
*/
|
||||
public AcknowledgedResponse deleteRepository(DeleteRepositoryRequest deleteRepositoryRequest, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(deleteRepositoryRequest, SnapshotRequestConverters::deleteRepository,
|
||||
options, AcknowledgedResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
deleteRepositoryRequest,
|
||||
SnapshotRequestConverters::deleteRepository,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,11 +168,19 @@ public final class SnapshotClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deleteRepositoryAsync(DeleteRepositoryRequest deleteRepositoryRequest, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(deleteRepositoryRequest,
|
||||
SnapshotRequestConverters::deleteRepository, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable deleteRepositoryAsync(
|
||||
DeleteRepositoryRequest deleteRepositoryRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
deleteRepositoryRequest,
|
||||
SnapshotRequestConverters::deleteRepository,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -156,8 +194,13 @@ public final class SnapshotClient {
|
|||
*/
|
||||
public VerifyRepositoryResponse verifyRepository(VerifyRepositoryRequest verifyRepositoryRequest, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(verifyRepositoryRequest, SnapshotRequestConverters::verifyRepository,
|
||||
options, VerifyRepositoryResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
verifyRepositoryRequest,
|
||||
SnapshotRequestConverters::verifyRepository,
|
||||
options,
|
||||
VerifyRepositoryResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,11 +212,19 @@ public final class SnapshotClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable verifyRepositoryAsync(VerifyRepositoryRequest verifyRepositoryRequest, RequestOptions options,
|
||||
ActionListener<VerifyRepositoryResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(verifyRepositoryRequest,
|
||||
SnapshotRequestConverters::verifyRepository, options,
|
||||
VerifyRepositoryResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable verifyRepositoryAsync(
|
||||
VerifyRepositoryRequest verifyRepositoryRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<VerifyRepositoryResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
verifyRepositoryRequest,
|
||||
SnapshotRequestConverters::verifyRepository,
|
||||
options,
|
||||
VerifyRepositoryResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,8 +238,13 @@ public final class SnapshotClient {
|
|||
*/
|
||||
public CleanupRepositoryResponse cleanupRepository(CleanupRepositoryRequest cleanupRepositoryRequest, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(cleanupRepositoryRequest, SnapshotRequestConverters::cleanupRepository,
|
||||
options, CleanupRepositoryResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
cleanupRepositoryRequest,
|
||||
SnapshotRequestConverters::cleanupRepository,
|
||||
options,
|
||||
CleanupRepositoryResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,10 +256,19 @@ public final class SnapshotClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable cleanupRepositoryAsync(CleanupRepositoryRequest cleanupRepositoryRequest, RequestOptions options,
|
||||
ActionListener<CleanupRepositoryResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(cleanupRepositoryRequest, SnapshotRequestConverters::cleanupRepository,
|
||||
options, CleanupRepositoryResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable cleanupRepositoryAsync(
|
||||
CleanupRepositoryRequest cleanupRepositoryRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<CleanupRepositoryResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
cleanupRepositoryRequest,
|
||||
SnapshotRequestConverters::cleanupRepository,
|
||||
options,
|
||||
CleanupRepositoryResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,10 +277,14 @@ public final class SnapshotClient {
|
|||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html"> Snapshot and Restore
|
||||
* API on elastic.co</a>
|
||||
*/
|
||||
public CreateSnapshotResponse create(CreateSnapshotRequest createSnapshotRequest, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(createSnapshotRequest, SnapshotRequestConverters::createSnapshot, options,
|
||||
CreateSnapshotResponse::fromXContent, emptySet());
|
||||
public CreateSnapshotResponse create(CreateSnapshotRequest createSnapshotRequest, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
createSnapshotRequest,
|
||||
SnapshotRequestConverters::createSnapshot,
|
||||
options,
|
||||
CreateSnapshotResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -225,11 +294,19 @@ public final class SnapshotClient {
|
|||
* API on elastic.co</a>
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable createAsync(CreateSnapshotRequest createSnapshotRequest, RequestOptions options,
|
||||
ActionListener<CreateSnapshotResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(createSnapshotRequest,
|
||||
SnapshotRequestConverters::createSnapshot, options,
|
||||
CreateSnapshotResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable createAsync(
|
||||
CreateSnapshotRequest createSnapshotRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<CreateSnapshotResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
createSnapshotRequest,
|
||||
SnapshotRequestConverters::createSnapshot,
|
||||
options,
|
||||
CreateSnapshotResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -238,10 +315,14 @@ public final class SnapshotClient {
|
|||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html"> Snapshot and Restore
|
||||
* API on elastic.co</a>
|
||||
*/
|
||||
public AcknowledgedResponse clone(CloneSnapshotRequest cloneSnapshotRequest, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(cloneSnapshotRequest, SnapshotRequestConverters::cloneSnapshot, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
public AcknowledgedResponse clone(CloneSnapshotRequest cloneSnapshotRequest, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
cloneSnapshotRequest,
|
||||
SnapshotRequestConverters::cloneSnapshot,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -251,11 +332,19 @@ public final class SnapshotClient {
|
|||
* API on elastic.co</a>
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable cloneAsync(CloneSnapshotRequest cloneSnapshotRequest, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(cloneSnapshotRequest,
|
||||
SnapshotRequestConverters::cloneSnapshot, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable cloneAsync(
|
||||
CloneSnapshotRequest cloneSnapshotRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
cloneSnapshotRequest,
|
||||
SnapshotRequestConverters::cloneSnapshot,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -269,8 +358,13 @@ public final class SnapshotClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetSnapshotsResponse get(GetSnapshotsRequest getSnapshotsRequest, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(getSnapshotsRequest, SnapshotRequestConverters::getSnapshots, options,
|
||||
GetSnapshotsResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
getSnapshotsRequest,
|
||||
SnapshotRequestConverters::getSnapshots,
|
||||
options,
|
||||
GetSnapshotsResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -282,11 +376,19 @@ public final class SnapshotClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getAsync(GetSnapshotsRequest getSnapshotsRequest, RequestOptions options,
|
||||
ActionListener<GetSnapshotsResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(getSnapshotsRequest,
|
||||
SnapshotRequestConverters::getSnapshots, options,
|
||||
GetSnapshotsResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable getAsync(
|
||||
GetSnapshotsRequest getSnapshotsRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<GetSnapshotsResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
getSnapshotsRequest,
|
||||
SnapshotRequestConverters::getSnapshots,
|
||||
options,
|
||||
GetSnapshotsResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,10 +400,14 @@ public final class SnapshotClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public SnapshotsStatusResponse status(SnapshotsStatusRequest snapshotsStatusRequest, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(snapshotsStatusRequest, SnapshotRequestConverters::snapshotsStatus, options,
|
||||
SnapshotsStatusResponse::fromXContent, emptySet());
|
||||
public SnapshotsStatusResponse status(SnapshotsStatusRequest snapshotsStatusRequest, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
snapshotsStatusRequest,
|
||||
SnapshotRequestConverters::snapshotsStatus,
|
||||
options,
|
||||
SnapshotsStatusResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -313,11 +419,19 @@ public final class SnapshotClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable statusAsync(SnapshotsStatusRequest snapshotsStatusRequest, RequestOptions options,
|
||||
ActionListener<SnapshotsStatusResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(snapshotsStatusRequest,
|
||||
SnapshotRequestConverters::snapshotsStatus, options,
|
||||
SnapshotsStatusResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable statusAsync(
|
||||
SnapshotsStatusRequest snapshotsStatusRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<SnapshotsStatusResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
snapshotsStatusRequest,
|
||||
SnapshotRequestConverters::snapshotsStatus,
|
||||
options,
|
||||
SnapshotsStatusResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -331,8 +445,13 @@ public final class SnapshotClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public RestoreSnapshotResponse restore(RestoreSnapshotRequest restoreSnapshotRequest, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(restoreSnapshotRequest, SnapshotRequestConverters::restoreSnapshot, options,
|
||||
RestoreSnapshotResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
restoreSnapshotRequest,
|
||||
SnapshotRequestConverters::restoreSnapshot,
|
||||
options,
|
||||
RestoreSnapshotResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -345,11 +464,19 @@ public final class SnapshotClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable restoreAsync(RestoreSnapshotRequest restoreSnapshotRequest, RequestOptions options,
|
||||
ActionListener<RestoreSnapshotResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(restoreSnapshotRequest,
|
||||
SnapshotRequestConverters::restoreSnapshot, options,
|
||||
RestoreSnapshotResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable restoreAsync(
|
||||
RestoreSnapshotRequest restoreSnapshotRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<RestoreSnapshotResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
restoreSnapshotRequest,
|
||||
SnapshotRequestConverters::restoreSnapshot,
|
||||
options,
|
||||
RestoreSnapshotResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -363,9 +490,13 @@ 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,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
deleteSnapshotRequest,
|
||||
SnapshotRequestConverters::deleteSnapshot,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -378,10 +509,18 @@ public final class SnapshotClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deleteAsync(DeleteSnapshotRequest deleteSnapshotRequest, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(deleteSnapshotRequest,
|
||||
SnapshotRequestConverters::deleteSnapshot, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable deleteAsync(
|
||||
DeleteSnapshotRequest deleteSnapshotRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
deleteSnapshotRequest,
|
||||
SnapshotRequestConverters::deleteSnapshot,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@ final class SnapshotRequestConverters {
|
|||
|
||||
static Request getRepositories(GetRepositoriesRequest getRepositoriesRequest) {
|
||||
String[] repositories = getRepositoriesRequest.repositories() == null ? Strings.EMPTY_ARRAY : getRepositoriesRequest.repositories();
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_snapshot").addCommaSeparatedPathParts(repositories)
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_snapshot")
|
||||
.addCommaSeparatedPathParts(repositories)
|
||||
.build();
|
||||
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
|
||||
|
@ -60,7 +61,8 @@ final class SnapshotRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteRepository(DeleteRepositoryRequest deleteRepositoryRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_snapshot").addPathPart(deleteRepositoryRequest.name())
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_snapshot")
|
||||
.addPathPart(deleteRepositoryRequest.name())
|
||||
.build();
|
||||
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
|
||||
|
||||
|
|
|
@ -49,8 +49,13 @@ public final class TasksClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public ListTasksResponse list(ListTasksRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, TasksRequestConverters::listTasks, options,
|
||||
ListTasksResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
TasksRequestConverters::listTasks,
|
||||
options,
|
||||
ListTasksResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,8 +68,14 @@ public final class TasksClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable listAsync(ListTasksRequest request, RequestOptions options, ActionListener<ListTasksResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, TasksRequestConverters::listTasks, options,
|
||||
ListTasksResponse::fromXContent, listener, emptySet());
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
TasksRequestConverters::listTasks,
|
||||
options,
|
||||
ListTasksResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,8 +88,12 @@ public final class TasksClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public Optional<GetTaskResponse> get(GetTaskRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseOptionalEntity(request, TasksRequestConverters::getTask, options,
|
||||
GetTaskResponse::fromXContent);
|
||||
return restHighLevelClient.performRequestAndParseOptionalEntity(
|
||||
request,
|
||||
TasksRequestConverters::getTask,
|
||||
options,
|
||||
GetTaskResponse::fromXContent
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,11 +105,15 @@ public final class TasksClient {
|
|||
* @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 Cancellable getAsync(GetTaskRequest request, RequestOptions options,
|
||||
ActionListener<Optional<GetTaskResponse>> listener) {
|
||||
public Cancellable getAsync(GetTaskRequest request, RequestOptions options, ActionListener<Optional<GetTaskResponse>> listener) {
|
||||
|
||||
return restHighLevelClient.performRequestAsyncAndParseOptionalEntity(request, TasksRequestConverters::getTask, options,
|
||||
GetTaskResponse::fromXContent, listener);
|
||||
return restHighLevelClient.performRequestAsyncAndParseOptionalEntity(
|
||||
request,
|
||||
TasksRequestConverters::getTask,
|
||||
options,
|
||||
GetTaskResponse::fromXContent,
|
||||
listener
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,8 +147,11 @@ public final class TasksClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable cancelAsync(CancelTasksRequest cancelTasksRequest, RequestOptions options,
|
||||
ActionListener<CancelTasksResponse> listener) {
|
||||
public Cancellable cancelAsync(
|
||||
CancelTasksRequest cancelTasksRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<CancelTasksResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
cancelTasksRequest,
|
||||
TasksRequestConverters::cancelTasks,
|
||||
|
|
|
@ -25,9 +25,7 @@ final class TasksRequestConverters {
|
|||
req.getTimeout().ifPresent(params::withTimeout);
|
||||
req.getTaskId().ifPresent(params::withTaskId);
|
||||
req.getParentTaskId().ifPresent(params::withParentTaskId);
|
||||
params
|
||||
.withNodes(req.getNodes())
|
||||
.withActions(req.getActions());
|
||||
params.withNodes(req.getNodes()).withActions(req.getActions());
|
||||
if (req.getWaitForCompletion() != null) {
|
||||
params.withWaitForCompletion(req.getWaitForCompletion());
|
||||
}
|
||||
|
@ -58,8 +56,7 @@ final class TasksRequestConverters {
|
|||
.build();
|
||||
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withTimeout(getTaskRequest.getTimeout())
|
||||
.withWaitForCompletion(getTaskRequest.getWaitForCompletion());
|
||||
params.withTimeout(getTaskRequest.getTimeout()).withWaitForCompletion(getTaskRequest.getWaitForCompletion());
|
||||
request.addParameters(params.asMap());
|
||||
return request;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.elasticsearch.client.textstructure.FindStructureResponse;
|
|||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
/**
|
||||
* Text Structure API client wrapper for the {@link RestHighLevelClient}
|
||||
* <p>
|
||||
|
@ -48,11 +47,13 @@ public final class TextStructureClient {
|
|||
* @throws IOException when there is a serialization issue sending the request or receiving the response
|
||||
*/
|
||||
public FindStructureResponse findStructure(FindStructureRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
TextStructureRequestConverters::findFileStructure,
|
||||
options,
|
||||
FindStructureResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,14 +68,19 @@ public final class TextStructureClient {
|
|||
* @param listener Listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable findStructureAsync(FindStructureRequest request, RequestOptions options,
|
||||
ActionListener<FindStructureResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
public Cancellable findStructureAsync(
|
||||
FindStructureRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<FindStructureResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
TextStructureRequestConverters::findFileStructure,
|
||||
options,
|
||||
FindStructureResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
package org.elasticsearch.client;
|
||||
|
||||
import static org.elasticsearch.client.RequestConverters.createContentType;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.nio.entity.NByteArrayEntity;
|
||||
|
@ -20,21 +18,19 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import static org.elasticsearch.client.RequestConverters.createContentType;
|
||||
|
||||
final class TextStructureRequestConverters {
|
||||
|
||||
private TextStructureRequestConverters() {}
|
||||
|
||||
static Request findFileStructure(FindStructureRequest findStructureRequest) {
|
||||
String endpoint = new EndpointBuilder()
|
||||
.addPathPartAsIs("_text_structure")
|
||||
.addPathPartAsIs("find_structure")
|
||||
.build();
|
||||
String endpoint = new EndpointBuilder().addPathPartAsIs("_text_structure").addPathPartAsIs("find_structure").build();
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
if (findStructureRequest.getLinesToSample() != null) {
|
||||
params.putParam(FindStructureRequest.LINES_TO_SAMPLE.getPreferredName(),
|
||||
findStructureRequest.getLinesToSample().toString());
|
||||
params.putParam(FindStructureRequest.LINES_TO_SAMPLE.getPreferredName(), findStructureRequest.getLinesToSample().toString());
|
||||
}
|
||||
if (findStructureRequest.getTimeout() != null) {
|
||||
params.putParam(FindStructureRequest.TIMEOUT.getPreferredName(), findStructureRequest.getTimeout().toString());
|
||||
|
@ -46,23 +42,25 @@ final class TextStructureRequestConverters {
|
|||
params.putParam(FindStructureRequest.FORMAT.getPreferredName(), findStructureRequest.getFormat().toString());
|
||||
}
|
||||
if (findStructureRequest.getColumnNames() != null) {
|
||||
params.putParam(FindStructureRequest.COLUMN_NAMES.getPreferredName(),
|
||||
Strings.collectionToCommaDelimitedString(findStructureRequest.getColumnNames()));
|
||||
params.putParam(
|
||||
FindStructureRequest.COLUMN_NAMES.getPreferredName(),
|
||||
Strings.collectionToCommaDelimitedString(findStructureRequest.getColumnNames())
|
||||
);
|
||||
}
|
||||
if (findStructureRequest.getHasHeaderRow() != null) {
|
||||
params.putParam(FindStructureRequest.HAS_HEADER_ROW.getPreferredName(),
|
||||
findStructureRequest.getHasHeaderRow().toString());
|
||||
params.putParam(FindStructureRequest.HAS_HEADER_ROW.getPreferredName(), findStructureRequest.getHasHeaderRow().toString());
|
||||
}
|
||||
if (findStructureRequest.getDelimiter() != null) {
|
||||
params.putParam(FindStructureRequest.DELIMITER.getPreferredName(),
|
||||
findStructureRequest.getDelimiter().toString());
|
||||
params.putParam(FindStructureRequest.DELIMITER.getPreferredName(), findStructureRequest.getDelimiter().toString());
|
||||
}
|
||||
if (findStructureRequest.getQuote() != null) {
|
||||
params.putParam(FindStructureRequest.QUOTE.getPreferredName(), findStructureRequest.getQuote().toString());
|
||||
}
|
||||
if (findStructureRequest.getShouldTrimFields() != null) {
|
||||
params.putParam(FindStructureRequest.SHOULD_TRIM_FIELDS.getPreferredName(),
|
||||
findStructureRequest.getShouldTrimFields().toString());
|
||||
params.putParam(
|
||||
FindStructureRequest.SHOULD_TRIM_FIELDS.getPreferredName(),
|
||||
findStructureRequest.getShouldTrimFields().toString()
|
||||
);
|
||||
}
|
||||
if (findStructureRequest.getGrokPattern() != null) {
|
||||
params.putParam(FindStructureRequest.GROK_PATTERN.getPreferredName(), findStructureRequest.getGrokPattern());
|
||||
|
|
|
@ -57,11 +57,13 @@ public final class TransformClient {
|
|||
* @throws IOException when there is a serialization issue sending the request or receiving the response
|
||||
*/
|
||||
public AcknowledgedResponse putTransform(PutTransformRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::putTransform,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,14 +78,19 @@ public final class TransformClient {
|
|||
* @param listener Listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable putTransformAsync(PutTransformRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
public Cancellable putTransformAsync(
|
||||
PutTransformRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::putTransform,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,13 +106,14 @@ public final class TransformClient {
|
|||
* @return An UpdateTransformResponse object containing the updated configuration
|
||||
* @throws IOException when there is a serialization issue sending the request or receiving the response
|
||||
*/
|
||||
public UpdateTransformResponse updateTransform(UpdateTransformRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
public UpdateTransformResponse updateTransform(UpdateTransformRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::updateTransform,
|
||||
options,
|
||||
UpdateTransformResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -120,15 +128,19 @@ public final class TransformClient {
|
|||
* @param listener Listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable updateTransformAsync(UpdateTransformRequest request,
|
||||
public Cancellable updateTransformAsync(
|
||||
UpdateTransformRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<UpdateTransformResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
ActionListener<UpdateTransformResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::updateTransform,
|
||||
options,
|
||||
UpdateTransformResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,13 +155,14 @@ public final class TransformClient {
|
|||
* @return The transform stats
|
||||
* @throws IOException when there is a serialization issue sending the request or receiving the response
|
||||
*/
|
||||
public GetTransformStatsResponse getTransformStats(GetTransformStatsRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
public GetTransformStatsResponse getTransformStats(GetTransformStatsRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::getTransformStats,
|
||||
options,
|
||||
GetTransformStatsResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,14 +176,19 @@ public final class TransformClient {
|
|||
* @param listener Listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getTransformStatsAsync(GetTransformStatsRequest request, RequestOptions options,
|
||||
ActionListener<GetTransformStatsResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
public Cancellable getTransformStatsAsync(
|
||||
GetTransformStatsRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<GetTransformStatsResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::getTransformStats,
|
||||
options,
|
||||
GetTransformStatsResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,13 +203,14 @@ public final class TransformClient {
|
|||
* @return An AcknowledgedResponse object indicating request success
|
||||
* @throws IOException when there is a serialization issue sending the request or receiving the response
|
||||
*/
|
||||
public AcknowledgedResponse deleteTransform(DeleteTransformRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
public AcknowledgedResponse deleteTransform(DeleteTransformRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::deleteTransform,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -205,14 +224,19 @@ public final class TransformClient {
|
|||
* @param listener Listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deleteTransformAsync(DeleteTransformRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
public Cancellable deleteTransformAsync(
|
||||
DeleteTransformRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::deleteTransform,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,13 +251,14 @@ public final class TransformClient {
|
|||
* @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
|
||||
*/
|
||||
public PreviewTransformResponse previewTransform(PreviewTransformRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
public PreviewTransformResponse previewTransform(PreviewTransformRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::previewTransform,
|
||||
options,
|
||||
PreviewTransformResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -246,14 +271,19 @@ public final class TransformClient {
|
|||
* @param listener Listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable previewTransformAsync(PreviewTransformRequest request, RequestOptions options,
|
||||
ActionListener<PreviewTransformResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
public Cancellable previewTransformAsync(
|
||||
PreviewTransformRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<PreviewTransformResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::previewTransform,
|
||||
options,
|
||||
PreviewTransformResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -268,13 +298,14 @@ public final class TransformClient {
|
|||
* @return A response object indicating request success
|
||||
* @throws IOException when there is a serialization issue sending the request or receiving the response
|
||||
*/
|
||||
public StartTransformResponse startTransform(StartTransformRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
public StartTransformResponse startTransform(StartTransformRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::startTransform,
|
||||
options,
|
||||
StartTransformResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -288,14 +319,19 @@ public final class TransformClient {
|
|||
* @param listener Listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable startTransformAsync(StartTransformRequest request, RequestOptions options,
|
||||
ActionListener<StartTransformResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
public Cancellable startTransformAsync(
|
||||
StartTransformRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<StartTransformResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::startTransform,
|
||||
options,
|
||||
StartTransformResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -310,13 +346,14 @@ public final class TransformClient {
|
|||
* @return A response object indicating request success
|
||||
* @throws IOException when there is a serialization issue sending the request or receiving the response
|
||||
*/
|
||||
public StopTransformResponse stopTransform(StopTransformRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
public StopTransformResponse stopTransform(StopTransformRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::stopTransform,
|
||||
options,
|
||||
StopTransformResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -330,14 +367,19 @@ public final class TransformClient {
|
|||
* @param listener Listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable stopTransformAsync(StopTransformRequest request, RequestOptions options,
|
||||
ActionListener<StopTransformResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
public Cancellable stopTransformAsync(
|
||||
StopTransformRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<StopTransformResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::stopTransform,
|
||||
options,
|
||||
StopTransformResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -352,13 +394,14 @@ public final class TransformClient {
|
|||
* @return An GetTransformResponse containing the requested transforms
|
||||
* @throws IOException when there is a serialization issue sending the request or receiving the response
|
||||
*/
|
||||
public GetTransformResponse getTransform(GetTransformRequest request, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request,
|
||||
public GetTransformResponse getTransform(GetTransformRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::getTransform,
|
||||
options,
|
||||
GetTransformResponse::fromXContent,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -372,13 +415,18 @@ public final class TransformClient {
|
|||
* @param listener Listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getTransformAsync(GetTransformRequest request, RequestOptions options,
|
||||
ActionListener<GetTransformResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request,
|
||||
public Cancellable getTransformAsync(
|
||||
GetTransformRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<GetTransformResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
TransformRequestConverters::getTransform,
|
||||
options,
|
||||
GetTransformResponse::fromXContent,
|
||||
listener,
|
||||
Collections.emptySet());
|
||||
Collections.emptySet()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,8 @@ import java.util.Optional;
|
|||
*/
|
||||
public interface Validatable {
|
||||
|
||||
Validatable EMPTY = new Validatable() {};
|
||||
Validatable EMPTY = new Validatable() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Perform validation. This method does not have to be overridden in the event that no validation needs to be done,
|
||||
|
|
|
@ -8,23 +8,23 @@
|
|||
package org.elasticsearch.client;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.client.watcher.DeactivateWatchRequest;
|
||||
import org.elasticsearch.client.watcher.DeactivateWatchResponse;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.client.watcher.ActivateWatchRequest;
|
||||
import org.elasticsearch.client.watcher.ActivateWatchResponse;
|
||||
import org.elasticsearch.client.watcher.AckWatchRequest;
|
||||
import org.elasticsearch.client.watcher.AckWatchResponse;
|
||||
import org.elasticsearch.client.watcher.ActivateWatchRequest;
|
||||
import org.elasticsearch.client.watcher.ActivateWatchResponse;
|
||||
import org.elasticsearch.client.watcher.DeactivateWatchRequest;
|
||||
import org.elasticsearch.client.watcher.DeactivateWatchResponse;
|
||||
import org.elasticsearch.client.watcher.DeleteWatchRequest;
|
||||
import org.elasticsearch.client.watcher.DeleteWatchResponse;
|
||||
import org.elasticsearch.client.watcher.ExecuteWatchRequest;
|
||||
import org.elasticsearch.client.watcher.ExecuteWatchResponse;
|
||||
import org.elasticsearch.client.watcher.GetWatchRequest;
|
||||
import org.elasticsearch.client.watcher.GetWatchResponse;
|
||||
import org.elasticsearch.client.watcher.StartWatchServiceRequest;
|
||||
import org.elasticsearch.client.watcher.StopWatchServiceRequest;
|
||||
import org.elasticsearch.client.watcher.DeleteWatchRequest;
|
||||
import org.elasticsearch.client.watcher.DeleteWatchResponse;
|
||||
import org.elasticsearch.client.watcher.PutWatchRequest;
|
||||
import org.elasticsearch.client.watcher.PutWatchResponse;
|
||||
import org.elasticsearch.client.watcher.StartWatchServiceRequest;
|
||||
import org.elasticsearch.client.watcher.StopWatchServiceRequest;
|
||||
import org.elasticsearch.client.watcher.WatcherStatsRequest;
|
||||
import org.elasticsearch.client.watcher.WatcherStatsResponse;
|
||||
|
||||
|
@ -59,7 +59,12 @@ public final class WatcherClient {
|
|||
*/
|
||||
public AcknowledgedResponse startWatchService(StartWatchServiceRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request, WatcherRequestConverters::startWatchService, options, AcknowledgedResponse::fromXContent, emptySet());
|
||||
request,
|
||||
WatcherRequestConverters::startWatchService,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,10 +74,19 @@ public final class WatcherClient {
|
|||
* @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 Cancellable startWatchServiceAsync(StartWatchServiceRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
public Cancellable startWatchServiceAsync(
|
||||
StartWatchServiceRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request, WatcherRequestConverters::startWatchService, options, AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
request,
|
||||
WatcherRequestConverters::startWatchService,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,7 +100,12 @@ public final class WatcherClient {
|
|||
*/
|
||||
public AcknowledgedResponse stopWatchService(StopWatchServiceRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request, WatcherRequestConverters::stopWatchService, options, AcknowledgedResponse::fromXContent, emptySet());
|
||||
request,
|
||||
WatcherRequestConverters::stopWatchService,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,10 +116,19 @@ public final class WatcherClient {
|
|||
* @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 Cancellable stopWatchServiceAsync(StopWatchServiceRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
public Cancellable stopWatchServiceAsync(
|
||||
StopWatchServiceRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request, WatcherRequestConverters::stopWatchService, options, AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
request,
|
||||
WatcherRequestConverters::stopWatchService,
|
||||
options,
|
||||
AcknowledgedResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,8 +141,13 @@ public final class WatcherClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public PutWatchResponse putWatch(PutWatchRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, WatcherRequestConverters::putWatch, options,
|
||||
PutWatchResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::putWatch,
|
||||
options,
|
||||
PutWatchResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,10 +159,15 @@ public final class WatcherClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable putWatchAsync(PutWatchRequest request, RequestOptions options,
|
||||
ActionListener<PutWatchResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::putWatch, options,
|
||||
PutWatchResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable putWatchAsync(PutWatchRequest request, RequestOptions options, ActionListener<PutWatchResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::putWatch,
|
||||
options,
|
||||
PutWatchResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -142,8 +180,13 @@ public final class WatcherClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetWatchResponse getWatch(GetWatchRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, WatcherRequestConverters::getWatch, options,
|
||||
GetWatchResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::getWatch,
|
||||
options,
|
||||
GetWatchResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -155,10 +198,15 @@ public final class WatcherClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getWatchAsync(GetWatchRequest request, RequestOptions options,
|
||||
ActionListener<GetWatchResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::getWatch, options,
|
||||
GetWatchResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable getWatchAsync(GetWatchRequest request, RequestOptions options, ActionListener<GetWatchResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::getWatch,
|
||||
options,
|
||||
GetWatchResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,8 +219,13 @@ public final class WatcherClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public DeactivateWatchResponse deactivateWatch(DeactivateWatchRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, WatcherRequestConverters::deactivateWatch, options,
|
||||
DeactivateWatchResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::deactivateWatch,
|
||||
options,
|
||||
DeactivateWatchResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,10 +238,19 @@ public final class WatcherClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deactivateWatchAsync(DeactivateWatchRequest request, RequestOptions options,
|
||||
ActionListener<DeactivateWatchResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::deactivateWatch, options,
|
||||
DeactivateWatchResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable deactivateWatchAsync(
|
||||
DeactivateWatchRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<DeactivateWatchResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::deactivateWatch,
|
||||
options,
|
||||
DeactivateWatchResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,8 +263,13 @@ public final class WatcherClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public DeleteWatchResponse deleteWatch(DeleteWatchRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, WatcherRequestConverters::deleteWatch, options,
|
||||
DeleteWatchResponse::fromXContent, singleton(404));
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::deleteWatch,
|
||||
options,
|
||||
DeleteWatchResponse::fromXContent,
|
||||
singleton(404)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -215,8 +282,14 @@ public final class WatcherClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deleteWatchAsync(DeleteWatchRequest request, RequestOptions options, ActionListener<DeleteWatchResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::deleteWatch, options,
|
||||
DeleteWatchResponse::fromXContent, listener, singleton(404));
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::deleteWatch,
|
||||
options,
|
||||
DeleteWatchResponse::fromXContent,
|
||||
listener,
|
||||
singleton(404)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -229,8 +302,13 @@ public final class WatcherClient {
|
|||
* @throws IOException if there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AckWatchResponse ackWatch(AckWatchRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, WatcherRequestConverters::ackWatch, options,
|
||||
AckWatchResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::ackWatch,
|
||||
options,
|
||||
AckWatchResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -243,8 +321,14 @@ public final class WatcherClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable ackWatchAsync(AckWatchRequest request, RequestOptions options, ActionListener<AckWatchResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::ackWatch, options,
|
||||
AckWatchResponse::fromXContent, listener, emptySet());
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::ackWatch,
|
||||
options,
|
||||
AckWatchResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,8 +341,13 @@ public final class WatcherClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public ActivateWatchResponse activateWatch(ActivateWatchRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, WatcherRequestConverters::activateWatch, options,
|
||||
ActivateWatchResponse::fromXContent, singleton(404));
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::activateWatch,
|
||||
options,
|
||||
ActivateWatchResponse::fromXContent,
|
||||
singleton(404)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -270,10 +359,19 @@ public final class WatcherClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable activateWatchAsync(ActivateWatchRequest request, RequestOptions options,
|
||||
ActionListener<ActivateWatchResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::activateWatch, options,
|
||||
ActivateWatchResponse::fromXContent, listener, singleton(404));
|
||||
public Cancellable activateWatchAsync(
|
||||
ActivateWatchRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<ActivateWatchResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::activateWatch,
|
||||
options,
|
||||
ActivateWatchResponse::fromXContent,
|
||||
listener,
|
||||
singleton(404)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -286,8 +384,13 @@ public final class WatcherClient {
|
|||
* @throws IOException if there is a problem sending the request or parsing the response
|
||||
*/
|
||||
public ExecuteWatchResponse executeWatch(ExecuteWatchRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, WatcherRequestConverters::executeWatch, options,
|
||||
ExecuteWatchResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::executeWatch,
|
||||
options,
|
||||
ExecuteWatchResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -299,10 +402,19 @@ public final class WatcherClient {
|
|||
* @param listener the listener to be notifed upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable executeWatchAsync(ExecuteWatchRequest request, RequestOptions options,
|
||||
ActionListener<ExecuteWatchResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::executeWatch, options,
|
||||
ExecuteWatchResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable executeWatchAsync(
|
||||
ExecuteWatchRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<ExecuteWatchResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::executeWatch,
|
||||
options,
|
||||
ExecuteWatchResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -315,8 +427,13 @@ public final class WatcherClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public WatcherStatsResponse watcherStats(WatcherStatsRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, WatcherRequestConverters::watcherStats, options,
|
||||
WatcherStatsResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::watcherStats,
|
||||
options,
|
||||
WatcherStatsResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -328,10 +445,19 @@ public final class WatcherClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable watcherStatsAsync(WatcherStatsRequest request, RequestOptions options,
|
||||
ActionListener<WatcherStatsResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::watcherStats, options,
|
||||
WatcherStatsResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable watcherStatsAsync(
|
||||
WatcherStatsRequest request,
|
||||
RequestOptions options,
|
||||
ActionListener<WatcherStatsResponse> listener
|
||||
) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
WatcherRequestConverters::watcherStats,
|
||||
options,
|
||||
WatcherStatsResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,32 +34,24 @@ final class WatcherRequestConverters {
|
|||
private WatcherRequestConverters() {}
|
||||
|
||||
static Request startWatchService(StartWatchServiceRequest startWatchServiceRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_watcher")
|
||||
.addPathPartAsIs("_start")
|
||||
.build();
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_watcher").addPathPartAsIs("_start").build();
|
||||
|
||||
return new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request stopWatchService(StopWatchServiceRequest stopWatchServiceRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_watcher")
|
||||
.addPathPartAsIs("_stop")
|
||||
.build();
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_watcher").addPathPartAsIs("_stop").build();
|
||||
|
||||
return new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request putWatch(PutWatchRequest putWatchRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_watcher", "watch")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_watcher", "watch")
|
||||
.addPathPart(putWatchRequest.getId())
|
||||
.build();
|
||||
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params params = new RequestConverters.Params()
|
||||
.withIfSeqNo(putWatchRequest.ifSeqNo())
|
||||
RequestConverters.Params params = new RequestConverters.Params().withIfSeqNo(putWatchRequest.ifSeqNo())
|
||||
.withIfPrimaryTerm(putWatchRequest.ifPrimaryTerm());
|
||||
if (putWatchRequest.isActive() == false) {
|
||||
params.putParam("active", "false");
|
||||
|
@ -71,10 +63,8 @@ final class WatcherRequestConverters {
|
|||
return request;
|
||||
}
|
||||
|
||||
|
||||
static Request getWatch(GetWatchRequest getWatchRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_watcher", "watch")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_watcher", "watch")
|
||||
.addPathPart(getWatchRequest.getId())
|
||||
.build();
|
||||
|
||||
|
@ -82,8 +72,7 @@ final class WatcherRequestConverters {
|
|||
}
|
||||
|
||||
static Request deactivateWatch(DeactivateWatchRequest deactivateWatchRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_watcher")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_watcher")
|
||||
.addPathPartAsIs("watch")
|
||||
.addPathPart(deactivateWatchRequest.getWatchId())
|
||||
.addPathPartAsIs("_deactivate")
|
||||
|
@ -92,8 +81,7 @@ final class WatcherRequestConverters {
|
|||
}
|
||||
|
||||
static Request deleteWatch(DeleteWatchRequest deleteWatchRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_watcher", "watch")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_watcher", "watch")
|
||||
.addPathPart(deleteWatchRequest.getId())
|
||||
.build();
|
||||
|
||||
|
@ -102,10 +90,10 @@ final class WatcherRequestConverters {
|
|||
}
|
||||
|
||||
static Request executeWatch(ExecuteWatchRequest executeWatchRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_watcher", "watch")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_watcher", "watch")
|
||||
.addPathPart(executeWatchRequest.getId()) // will ignore if ID is null
|
||||
.addPathPartAsIs("_execute").build();
|
||||
.addPathPartAsIs("_execute")
|
||||
.build();
|
||||
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
|
@ -124,8 +112,7 @@ final class WatcherRequestConverters {
|
|||
}
|
||||
|
||||
public static Request ackWatch(AckWatchRequest ackWatchRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_watcher", "watch")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_watcher", "watch")
|
||||
.addPathPart(ackWatchRequest.getWatchId())
|
||||
.addPathPartAsIs("_ack")
|
||||
.addCommaSeparatedPathParts(ackWatchRequest.getActionIds())
|
||||
|
@ -135,8 +122,7 @@ final class WatcherRequestConverters {
|
|||
}
|
||||
|
||||
static Request activateWatch(ActivateWatchRequest activateWatchRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_watcher", "watch")
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_watcher", "watch")
|
||||
.addPathPart(activateWatchRequest.getWatchId())
|
||||
.addPathPartAsIs("_activate")
|
||||
.build();
|
||||
|
|
|
@ -51,8 +51,13 @@ public final class XPackClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public XPackInfoResponse info(XPackInfoRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, XPackRequestConverters::info, options,
|
||||
XPackInfoResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
XPackRequestConverters::info,
|
||||
options,
|
||||
XPackInfoResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,10 +69,15 @@ public final class XPackClient {
|
|||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable infoAsync(XPackInfoRequest request, RequestOptions options,
|
||||
ActionListener<XPackInfoResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, XPackRequestConverters::info, options,
|
||||
XPackInfoResponse::fromXContent, listener, emptySet());
|
||||
public Cancellable infoAsync(XPackInfoRequest request, RequestOptions options, ActionListener<XPackInfoResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
XPackRequestConverters::info,
|
||||
options,
|
||||
XPackInfoResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,8 +87,13 @@ public final class XPackClient {
|
|||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public XPackUsageResponse usage(XPackUsageRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, XPackRequestConverters::usage, options,
|
||||
XPackUsageResponse::fromXContent, emptySet());
|
||||
return restHighLevelClient.performRequestAndParseEntity(
|
||||
request,
|
||||
XPackRequestConverters::usage,
|
||||
options,
|
||||
XPackUsageResponse::fromXContent,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,7 +103,13 @@ public final class XPackClient {
|
|||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable usageAsync(XPackUsageRequest request, RequestOptions options, ActionListener<XPackUsageResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, XPackRequestConverters::usage, options,
|
||||
XPackUsageResponse::fromXContent, listener, emptySet());
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(
|
||||
request,
|
||||
XPackRequestConverters::usage,
|
||||
options,
|
||||
XPackUsageResponse::fromXContent,
|
||||
listener,
|
||||
emptySet()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,10 @@ final class XPackRequestConverters {
|
|||
request.addParameter("human", "false");
|
||||
}
|
||||
if (false == infoRequest.getCategories().equals(EnumSet.allOf(XPackInfoRequest.Category.class))) {
|
||||
request.addParameter("categories", infoRequest.getCategories().stream()
|
||||
.map(c -> c.toString().toLowerCase(Locale.ROOT))
|
||||
.collect(Collectors.joining(",")));
|
||||
request.addParameter(
|
||||
"categories",
|
||||
infoRequest.getCategories().stream().map(c -> c.toString().toLowerCase(Locale.ROOT)).collect(Collectors.joining(","))
|
||||
);
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
|
|
@ -9,15 +9,15 @@
|
|||
package org.elasticsearch.client.analytics;
|
||||
|
||||
import org.elasticsearch.client.ml.inference.trainedmodel.InferenceConfig;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.search.aggregations.PipelineAggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.AbstractPipelineAggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
@ -41,26 +41,28 @@ public class InferencePipelineAggregationBuilder extends AbstractPipelineAggrega
|
|||
public static final ParseField MODEL_ID = new ParseField("model_id");
|
||||
private static final ParseField INFERENCE_CONFIG = new ParseField("inference_config");
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final ConstructingObjectParser<InferencePipelineAggregationBuilder, String> PARSER = new ConstructingObjectParser<>(
|
||||
NAME, false,
|
||||
NAME,
|
||||
false,
|
||||
(args, name) -> new InferencePipelineAggregationBuilder(name, (String) args[0], (Map<String, String>) args[1])
|
||||
);
|
||||
|
||||
static {
|
||||
PARSER.declareString(constructorArg(), MODEL_ID);
|
||||
PARSER.declareObject(constructorArg(), (p, c) -> p.mapStrings(), BUCKETS_PATH_FIELD);
|
||||
PARSER.declareNamedObject(InferencePipelineAggregationBuilder::setInferenceConfig,
|
||||
(p, c, n) -> p.namedObject(InferenceConfig.class, n, c), INFERENCE_CONFIG);
|
||||
PARSER.declareNamedObject(
|
||||
InferencePipelineAggregationBuilder::setInferenceConfig,
|
||||
(p, c, n) -> p.namedObject(InferenceConfig.class, n, c),
|
||||
INFERENCE_CONFIG
|
||||
);
|
||||
}
|
||||
|
||||
private final Map<String, String> bucketPathMap;
|
||||
private final String modelId;
|
||||
private InferenceConfig inferenceConfig;
|
||||
|
||||
public static InferencePipelineAggregationBuilder parse(String pipelineAggregatorName,
|
||||
XContentParser parser) {
|
||||
public static InferencePipelineAggregationBuilder parse(String pipelineAggregatorName, XContentParser parser) {
|
||||
return PARSER.apply(parser, pipelineAggregatorName);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,13 +10,13 @@ package org.elasticsearch.client.analytics;
|
|||
|
||||
import org.elasticsearch.client.ml.inference.results.FeatureImportance;
|
||||
import org.elasticsearch.client.ml.inference.results.TopClassEntry;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.search.aggregations.ParsedAggregation;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParseException;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.search.aggregations.ParsedAggregation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
@ -34,10 +34,11 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstr
|
|||
public class ParsedInference extends ParsedAggregation {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final ConstructingObjectParser<ParsedInference, Void> PARSER =
|
||||
new ConstructingObjectParser<>(ParsedInference.class.getSimpleName(), true,
|
||||
args -> new ParsedInference(args[0], (List<FeatureImportance>) args[1],
|
||||
(List<TopClassEntry>) args[2], (String) args[3]));
|
||||
private static final ConstructingObjectParser<ParsedInference, Void> PARSER = new ConstructingObjectParser<>(
|
||||
ParsedInference.class.getSimpleName(),
|
||||
true,
|
||||
args -> new ParsedInference(args[0], (List<FeatureImportance>) args[1], (List<TopClassEntry>) args[2], (String) args[3])
|
||||
);
|
||||
|
||||
public static final ParseField FEATURE_IMPORTANCE = new ParseField("feature_importance");
|
||||
public static final ParseField WARNING = new ParseField("warning");
|
||||
|
@ -54,9 +55,17 @@ public class ParsedInference extends ParsedAggregation {
|
|||
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
||||
o = p.doubleValue();
|
||||
} else {
|
||||
throw new XContentParseException(p.getTokenLocation(),
|
||||
"[" + ParsedInference.class.getSimpleName() + "] failed to parse field [" + CommonFields.VALUE + "] "
|
||||
+ "value [" + token + "] is not a string, boolean or number");
|
||||
throw new XContentParseException(
|
||||
p.getTokenLocation(),
|
||||
"["
|
||||
+ ParsedInference.class.getSimpleName()
|
||||
+ "] failed to parse field ["
|
||||
+ CommonFields.VALUE
|
||||
+ "] "
|
||||
+ "value ["
|
||||
+ token
|
||||
+ "] is not a string, boolean or number"
|
||||
);
|
||||
}
|
||||
return o;
|
||||
}, CommonFields.VALUE, ObjectParser.ValueType.VALUE);
|
||||
|
@ -77,10 +86,7 @@ public class ParsedInference extends ParsedAggregation {
|
|||
private final List<TopClassEntry> topClasses;
|
||||
private final String warning;
|
||||
|
||||
ParsedInference(Object value,
|
||||
List<FeatureImportance> featureImportance,
|
||||
List<TopClassEntry> topClasses,
|
||||
String warning) {
|
||||
ParsedInference(Object value, List<FeatureImportance> featureImportance, List<TopClassEntry> topClasses, String warning) {
|
||||
this.value = value;
|
||||
this.warning = warning;
|
||||
this.featureImportance = featureImportance;
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
package org.elasticsearch.client.analytics;
|
||||
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.search.aggregations.ParsedAggregation;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.search.aggregations.ParsedAggregation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
@ -41,8 +41,16 @@ public class ParsedStringStats extends ParsedAggregation {
|
|||
private final boolean showDistribution;
|
||||
private final Map<String, Double> distribution;
|
||||
|
||||
private ParsedStringStats(String name, long count, int minLength, int maxLength, double avgLength, double entropy,
|
||||
boolean showDistribution, Map<String, Double> distribution) {
|
||||
private ParsedStringStats(
|
||||
String name,
|
||||
long count,
|
||||
int minLength,
|
||||
int maxLength,
|
||||
double avgLength,
|
||||
double entropy,
|
||||
boolean showDistribution,
|
||||
Map<String, Double> distribution
|
||||
) {
|
||||
setName(name);
|
||||
this.count = count;
|
||||
this.minLength = minLength;
|
||||
|
@ -108,7 +116,9 @@ public class ParsedStringStats extends ParsedAggregation {
|
|||
|
||||
private static final Object NULL_DISTRIBUTION_MARKER = new Object();
|
||||
public static final ConstructingObjectParser<ParsedStringStats, String> PARSER = new ConstructingObjectParser<>(
|
||||
StringStatsAggregationBuilder.NAME, true, (args, name) -> {
|
||||
StringStatsAggregationBuilder.NAME,
|
||||
true,
|
||||
(args, name) -> {
|
||||
long count = (long) args[0];
|
||||
boolean disributionWasExplicitNull = args[5] == NULL_DISTRIBUTION_MARKER;
|
||||
if (count == 0) {
|
||||
|
@ -119,23 +129,26 @@ public class ParsedStringStats extends ParsedAggregation {
|
|||
double averageLength = (double) args[3];
|
||||
double entropy = (double) args[4];
|
||||
if (disributionWasExplicitNull) {
|
||||
return new ParsedStringStats(name, count, minLength, maxLength, averageLength, entropy,
|
||||
disributionWasExplicitNull, null);
|
||||
return new ParsedStringStats(name, count, minLength, maxLength, averageLength, entropy, disributionWasExplicitNull, null);
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Double> distribution = (Map<String, Double>) args[5];
|
||||
return new ParsedStringStats(name, count, minLength, maxLength, averageLength, entropy,
|
||||
distribution != null, distribution);
|
||||
return new ParsedStringStats(name, count, minLength, maxLength, averageLength, entropy, distribution != null, distribution);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
static {
|
||||
PARSER.declareLong(constructorArg(), COUNT_FIELD);
|
||||
PARSER.declareIntOrNull(constructorArg(), 0, MIN_LENGTH_FIELD);
|
||||
PARSER.declareIntOrNull(constructorArg(), 0, MAX_LENGTH_FIELD);
|
||||
PARSER.declareDoubleOrNull(constructorArg(), 0, AVG_LENGTH_FIELD);
|
||||
PARSER.declareDoubleOrNull(constructorArg(), 0, ENTROPY_FIELD);
|
||||
PARSER.declareObjectOrNull(optionalConstructorArg(), (p, c) -> unmodifiableMap(p.map(HashMap::new, XContentParser::doubleValue)),
|
||||
NULL_DISTRIBUTION_MARKER, DISTRIBUTION_FIELD);
|
||||
PARSER.declareObjectOrNull(
|
||||
optionalConstructorArg(),
|
||||
(p, c) -> unmodifiableMap(p.map(HashMap::new, XContentParser::doubleValue)),
|
||||
NULL_DISTRIBUTION_MARKER,
|
||||
DISTRIBUTION_FIELD
|
||||
);
|
||||
ParsedAggregation.declareAggregationFields(PARSER);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
|
||||
package org.elasticsearch.client.analytics;
|
||||
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ObjectParser;
|
||||
import org.elasticsearch.xcontent.ToXContent;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParserUtils;
|
||||
import org.elasticsearch.search.aggregations.ParsedAggregation;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ToXContent;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
@ -57,11 +57,14 @@ public class ParsedTopMetrics extends ParsedAggregation {
|
|||
}
|
||||
|
||||
public static final ConstructingObjectParser<ParsedTopMetrics, String> PARSER = new ConstructingObjectParser<>(
|
||||
TopMetricsAggregationBuilder.NAME, true, (args, name) -> {
|
||||
TopMetricsAggregationBuilder.NAME,
|
||||
true,
|
||||
(args, name) -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<TopMetrics> topMetrics = (List<TopMetrics>) args[0];
|
||||
return new ParsedTopMetrics(name, topMetrics);
|
||||
});
|
||||
}
|
||||
);
|
||||
static {
|
||||
PARSER.declareObjectArray(constructorArg(), (p, c) -> TopMetrics.PARSER.parse(p, null), TOP_FIELD);
|
||||
ParsedAggregation.declareAggregationFields(PARSER);
|
||||
|
@ -96,17 +99,24 @@ public class ParsedTopMetrics extends ParsedAggregation {
|
|||
return metrics;
|
||||
}
|
||||
|
||||
private static final ConstructingObjectParser<TopMetrics, Void> PARSER = new ConstructingObjectParser<>("top", true,
|
||||
private static final ConstructingObjectParser<TopMetrics, Void> PARSER = new ConstructingObjectParser<>(
|
||||
"top",
|
||||
true,
|
||||
(args, name) -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> sort = (List<Object>) args[0];
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> metrics = (Map<String, Object>) args[1];
|
||||
return new TopMetrics(sort, metrics);
|
||||
});
|
||||
}
|
||||
);
|
||||
static {
|
||||
PARSER.declareFieldArray(constructorArg(), (p, c) -> XContentParserUtils.parseFieldsValue(p),
|
||||
SORT_FIELD, ObjectParser.ValueType.VALUE_ARRAY);
|
||||
PARSER.declareFieldArray(
|
||||
constructorArg(),
|
||||
(p, c) -> XContentParserUtils.parseFieldsValue(p),
|
||||
SORT_FIELD,
|
||||
ObjectParser.ValueType.VALUE_ARRAY
|
||||
);
|
||||
PARSER.declareObject(constructorArg(), (p, c) -> p.map(), METRICS_FIELD);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,10 +8,8 @@
|
|||
|
||||
package org.elasticsearch.client.analytics;
|
||||
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryRewriteContext;
|
||||
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
|
@ -25,6 +23,8 @@ import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
|||
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
@ -91,8 +91,12 @@ public class StringStatsAggregationBuilder extends ValuesSourceAggregationBuilde
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ValuesSourceAggregatorFactory innerBuild(AggregationContext context, ValuesSourceConfig config,
|
||||
AggregatorFactory parent, Builder subFactoriesBuilder) throws IOException {
|
||||
protected ValuesSourceAggregatorFactory innerBuild(
|
||||
AggregationContext context,
|
||||
ValuesSourceConfig config,
|
||||
AggregatorFactory parent,
|
||||
Builder subFactoriesBuilder
|
||||
) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ package org.elasticsearch.client.analytics;
|
|||
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryRewriteContext;
|
||||
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
|
@ -19,6 +18,7 @@ import org.elasticsearch.search.aggregations.AggregatorFactory;
|
|||
import org.elasticsearch.search.aggregations.support.AggregationContext;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.elasticsearch.search.sort.SortBuilder;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
|
|
@ -9,10 +9,10 @@ package org.elasticsearch.client.asyncsearch;
|
|||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.core.Nullable;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.core.Nullable;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
|
@ -20,9 +20,9 @@ import org.elasticsearch.xcontent.XContentParser.Token;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken;
|
||||
import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg;
|
||||
import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstructorArg;
|
||||
import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken;
|
||||
|
||||
/**
|
||||
* A response of an async search request.
|
||||
|
@ -43,13 +43,15 @@ public class AsyncSearchResponse implements ToXContentObject {
|
|||
/**
|
||||
* Creates an {@link AsyncSearchResponse} with the arguments that are always present in the server response
|
||||
*/
|
||||
AsyncSearchResponse(boolean isPartial,
|
||||
AsyncSearchResponse(
|
||||
boolean isPartial,
|
||||
boolean isRunning,
|
||||
long startTimeMillis,
|
||||
long expirationTimeMillis,
|
||||
@Nullable String id,
|
||||
@Nullable SearchResponse searchResponse,
|
||||
@Nullable ElasticsearchException error) {
|
||||
@Nullable ElasticsearchException error
|
||||
) {
|
||||
this.isPartial = isPartial;
|
||||
this.isRunning = isRunning;
|
||||
this.startTimeMillis = startTimeMillis;
|
||||
|
@ -151,7 +153,8 @@ public class AsyncSearchResponse implements ToXContentObject {
|
|||
public static final ParseField ERROR_FIELD = new ParseField("error");
|
||||
|
||||
public static final ConstructingObjectParser<AsyncSearchResponse, Void> PARSER = new ConstructingObjectParser<>(
|
||||
"submit_async_search_response", true,
|
||||
"submit_async_search_response",
|
||||
true,
|
||||
args -> new AsyncSearchResponse(
|
||||
(boolean) args[0],
|
||||
(boolean) args[1],
|
||||
|
@ -159,15 +162,16 @@ public class AsyncSearchResponse implements ToXContentObject {
|
|||
(long) args[3],
|
||||
(String) args[4],
|
||||
(SearchResponse) args[5],
|
||||
(ElasticsearchException) args[6]));
|
||||
(ElasticsearchException) args[6]
|
||||
)
|
||||
);
|
||||
static {
|
||||
PARSER.declareBoolean(constructorArg(), IS_PARTIAL_FIELD);
|
||||
PARSER.declareBoolean(constructorArg(), IS_RUNNING_FIELD);
|
||||
PARSER.declareLong(constructorArg(), START_TIME_FIELD);
|
||||
PARSER.declareLong(constructorArg(), EXPIRATION_FIELD);
|
||||
PARSER.declareString(optionalConstructorArg(), ID_FIELD);
|
||||
PARSER.declareObject(optionalConstructorArg(), (p, c) -> AsyncSearchResponse.parseSearchResponse(p),
|
||||
RESPONSE_FIELD);
|
||||
PARSER.declareObject(optionalConstructorArg(), (p, c) -> AsyncSearchResponse.parseSearchResponse(p), RESPONSE_FIELD);
|
||||
PARSER.declareObject(optionalConstructorArg(), (p, c) -> ElasticsearchException.fromXContent(p), ERROR_FIELD);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
|
||||
package org.elasticsearch.client.asyncsearch;
|
||||
|
||||
import org.elasticsearch.client.Validatable;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
|
||||
package org.elasticsearch.client.asyncsearch;
|
||||
|
||||
import org.elasticsearch.client.Validatable;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
|
||||
package org.elasticsearch.client.asyncsearch;
|
||||
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
|
@ -48,7 +47,6 @@ public class SubmitAsyncSearchRequest implements Validatable {
|
|||
return this.searchRequest.indices();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the minimum time that the request should wait before returning a partial result (defaults to 1 second).
|
||||
*/
|
||||
|
|
|
@ -10,9 +10,9 @@ package org.elasticsearch.client.ccr;
|
|||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.util.Maps;
|
||||
import org.elasticsearch.core.Tuple;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.core.Tuple;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.List;
|
||||
|
@ -23,8 +23,9 @@ public final class AutoFollowStats {
|
|||
|
||||
static final ParseField NUMBER_OF_SUCCESSFUL_INDICES_AUTO_FOLLOWED = new ParseField("number_of_successful_follow_indices");
|
||||
static final ParseField NUMBER_OF_FAILED_INDICES_AUTO_FOLLOWED = new ParseField("number_of_failed_follow_indices");
|
||||
static final ParseField NUMBER_OF_FAILED_REMOTE_CLUSTER_STATE_REQUESTS =
|
||||
new ParseField("number_of_failed_remote_cluster_state_requests");
|
||||
static final ParseField NUMBER_OF_FAILED_REMOTE_CLUSTER_STATE_REQUESTS = new ParseField(
|
||||
"number_of_failed_remote_cluster_state_requests"
|
||||
);
|
||||
static final ParseField RECENT_AUTO_FOLLOW_ERRORS = new ParseField("recent_auto_follow_errors");
|
||||
static final ParseField LEADER_INDEX = new ParseField("leader_index");
|
||||
static final ParseField TIMESTAMP = new ParseField("timestamp");
|
||||
|
@ -42,25 +43,26 @@ public final class AutoFollowStats {
|
|||
(Long) args[0],
|
||||
(Long) args[1],
|
||||
(Long) args[2],
|
||||
((List<Map.Entry<String, Tuple<Long, ElasticsearchException>>>) args[3])
|
||||
.stream()
|
||||
((List<Map.Entry<String, Tuple<Long, ElasticsearchException>>>) args[3]).stream()
|
||||
.collect(Maps.toUnmodifiableSortedMap(Map.Entry::getKey, Map.Entry::getValue)),
|
||||
((List<Map.Entry<String, AutoFollowedCluster>>) args[4])
|
||||
.stream()
|
||||
((List<Map.Entry<String, AutoFollowedCluster>>) args[4]).stream()
|
||||
.collect(Maps.toUnmodifiableSortedMap(Map.Entry::getKey, Map.Entry::getValue))
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
static final ConstructingObjectParser<Map.Entry<String, Tuple<Long, ElasticsearchException>>, Void> AUTO_FOLLOW_EXCEPTIONS_PARSER =
|
||||
new ConstructingObjectParser<>(
|
||||
"auto_follow_stats_errors",
|
||||
true,
|
||||
args -> new AbstractMap.SimpleEntry<>((String) args[0], Tuple.tuple((Long) args[1], (ElasticsearchException) args[2])));
|
||||
args -> new AbstractMap.SimpleEntry<>((String) args[0], Tuple.tuple((Long) args[1], (ElasticsearchException) args[2]))
|
||||
);
|
||||
|
||||
private static final ConstructingObjectParser<Map.Entry<String, AutoFollowedCluster>, Void> AUTO_FOLLOWED_CLUSTERS_PARSER =
|
||||
new ConstructingObjectParser<>(
|
||||
"auto_followed_clusters",
|
||||
true,
|
||||
args -> new AbstractMap.SimpleEntry<>((String) args[0], new AutoFollowedCluster((Long) args[1], (Long) args[2])));
|
||||
args -> new AbstractMap.SimpleEntry<>((String) args[0], new AutoFollowedCluster((Long) args[1], (Long) args[2]))
|
||||
);
|
||||
|
||||
static {
|
||||
AUTO_FOLLOW_EXCEPTIONS_PARSER.declareString(ConstructingObjectParser.constructorArg(), LEADER_INDEX);
|
||||
|
@ -68,7 +70,8 @@ public final class AutoFollowStats {
|
|||
AUTO_FOLLOW_EXCEPTIONS_PARSER.declareObject(
|
||||
ConstructingObjectParser.constructorArg(),
|
||||
(p, c) -> ElasticsearchException.fromXContent(p),
|
||||
AUTO_FOLLOW_EXCEPTION);
|
||||
AUTO_FOLLOW_EXCEPTION
|
||||
);
|
||||
|
||||
AUTO_FOLLOWED_CLUSTERS_PARSER.declareString(ConstructingObjectParser.constructorArg(), CLUSTER_NAME);
|
||||
AUTO_FOLLOWED_CLUSTERS_PARSER.declareLong(ConstructingObjectParser.constructorArg(), TIME_SINCE_LAST_CHECK_MILLIS);
|
||||
|
@ -77,10 +80,12 @@ public final class AutoFollowStats {
|
|||
STATS_PARSER.declareLong(ConstructingObjectParser.constructorArg(), NUMBER_OF_FAILED_INDICES_AUTO_FOLLOWED);
|
||||
STATS_PARSER.declareLong(ConstructingObjectParser.constructorArg(), NUMBER_OF_FAILED_REMOTE_CLUSTER_STATE_REQUESTS);
|
||||
STATS_PARSER.declareLong(ConstructingObjectParser.constructorArg(), NUMBER_OF_SUCCESSFUL_INDICES_AUTO_FOLLOWED);
|
||||
STATS_PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), AUTO_FOLLOW_EXCEPTIONS_PARSER,
|
||||
RECENT_AUTO_FOLLOW_ERRORS);
|
||||
STATS_PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), AUTO_FOLLOWED_CLUSTERS_PARSER,
|
||||
AUTO_FOLLOWED_CLUSTERS);
|
||||
STATS_PARSER.declareObjectArray(
|
||||
ConstructingObjectParser.constructorArg(),
|
||||
AUTO_FOLLOW_EXCEPTIONS_PARSER,
|
||||
RECENT_AUTO_FOLLOW_ERRORS
|
||||
);
|
||||
STATS_PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), AUTO_FOLLOWED_CLUSTERS_PARSER, AUTO_FOLLOWED_CLUSTERS);
|
||||
}
|
||||
|
||||
private final long numberOfFailedFollowIndices;
|
||||
|
@ -89,11 +94,13 @@ public final class AutoFollowStats {
|
|||
private final NavigableMap<String, Tuple<Long, ElasticsearchException>> recentAutoFollowErrors;
|
||||
private final NavigableMap<String, AutoFollowedCluster> autoFollowedClusters;
|
||||
|
||||
AutoFollowStats(long numberOfFailedFollowIndices,
|
||||
AutoFollowStats(
|
||||
long numberOfFailedFollowIndices,
|
||||
long numberOfFailedRemoteClusterStateRequests,
|
||||
long numberOfSuccessfulFollowIndices,
|
||||
NavigableMap<String, Tuple<Long, ElasticsearchException>> recentAutoFollowErrors,
|
||||
NavigableMap<String, AutoFollowedCluster> autoFollowedClusters) {
|
||||
NavigableMap<String, AutoFollowedCluster> autoFollowedClusters
|
||||
) {
|
||||
this.numberOfFailedFollowIndices = numberOfFailedFollowIndices;
|
||||
this.numberOfFailedRemoteClusterStateRequests = numberOfFailedRemoteClusterStateRequests;
|
||||
this.numberOfSuccessfulFollowIndices = numberOfSuccessfulFollowIndices;
|
||||
|
|
|
@ -10,5 +10,4 @@ package org.elasticsearch.client.ccr;
|
|||
|
||||
import org.elasticsearch.client.Validatable;
|
||||
|
||||
public final class CcrStatsRequest implements Validatable {
|
||||
}
|
||||
public final class CcrStatsRequest implements Validatable {}
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
package org.elasticsearch.client.ccr;
|
||||
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
|
||||
public final class CcrStatsResponse {
|
||||
|
@ -17,10 +17,7 @@ public final class CcrStatsResponse {
|
|||
static final ParseField AUTO_FOLLOW_STATS_FIELD = new ParseField("auto_follow_stats");
|
||||
static final ParseField FOLLOW_STATS_FIELD = new ParseField("follow_stats");
|
||||
|
||||
private static final ConstructingObjectParser<CcrStatsResponse, Void> PARSER = new ConstructingObjectParser<>(
|
||||
"indices",
|
||||
true,
|
||||
args -> {
|
||||
private static final ConstructingObjectParser<CcrStatsResponse, Void> PARSER = new ConstructingObjectParser<>("indices", true, args -> {
|
||||
AutoFollowStats autoFollowStats = (AutoFollowStats) args[0];
|
||||
IndicesFollowStats indicesFollowStats = (IndicesFollowStats) args[1];
|
||||
return new CcrStatsResponse(autoFollowStats, indicesFollowStats);
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
package org.elasticsearch.client.ccr;
|
||||
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.core.TimeValue;
|
||||
import org.elasticsearch.xcontent.ObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ToXContent;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
|
@ -34,10 +34,7 @@ public class FollowConfig {
|
|||
static final ParseField MAX_RETRY_DELAY_FIELD = new ParseField("max_retry_delay");
|
||||
static final ParseField READ_POLL_TIMEOUT = new ParseField("read_poll_timeout");
|
||||
|
||||
private static final ObjectParser<FollowConfig, Void> PARSER = new ObjectParser<>(
|
||||
"follow_config",
|
||||
true,
|
||||
FollowConfig::new);
|
||||
private static final ObjectParser<FollowConfig, Void> PARSER = new ObjectParser<>("follow_config", true, FollowConfig::new);
|
||||
|
||||
static {
|
||||
PARSER.declareObject(FollowConfig::setSettings, (p, c) -> Settings.fromXContent(p), SETTINGS);
|
||||
|
@ -47,26 +44,35 @@ public class FollowConfig {
|
|||
FollowConfig::setMaxReadRequestSize,
|
||||
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_READ_REQUEST_SIZE.getPreferredName()),
|
||||
MAX_READ_REQUEST_SIZE,
|
||||
ObjectParser.ValueType.STRING);
|
||||
ObjectParser.ValueType.STRING
|
||||
);
|
||||
PARSER.declareInt(FollowConfig::setMaxWriteRequestOperationCount, MAX_WRITE_REQUEST_OPERATION_COUNT);
|
||||
PARSER.declareField(
|
||||
FollowConfig::setMaxWriteRequestSize,
|
||||
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_WRITE_REQUEST_SIZE.getPreferredName()),
|
||||
MAX_WRITE_REQUEST_SIZE,
|
||||
ObjectParser.ValueType.STRING);
|
||||
ObjectParser.ValueType.STRING
|
||||
);
|
||||
PARSER.declareInt(FollowConfig::setMaxOutstandingWriteRequests, MAX_OUTSTANDING_WRITE_REQUESTS);
|
||||
PARSER.declareInt(FollowConfig::setMaxWriteBufferCount, MAX_WRITE_BUFFER_COUNT);
|
||||
PARSER.declareField(
|
||||
FollowConfig::setMaxWriteBufferSize,
|
||||
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_WRITE_BUFFER_SIZE.getPreferredName()),
|
||||
MAX_WRITE_BUFFER_SIZE,
|
||||
ObjectParser.ValueType.STRING);
|
||||
PARSER.declareField(FollowConfig::setMaxRetryDelay,
|
||||
ObjectParser.ValueType.STRING
|
||||
);
|
||||
PARSER.declareField(
|
||||
FollowConfig::setMaxRetryDelay,
|
||||
(p, c) -> TimeValue.parseTimeValue(p.text(), MAX_RETRY_DELAY_FIELD.getPreferredName()),
|
||||
MAX_RETRY_DELAY_FIELD, ObjectParser.ValueType.STRING);
|
||||
PARSER.declareField(FollowConfig::setReadPollTimeout,
|
||||
MAX_RETRY_DELAY_FIELD,
|
||||
ObjectParser.ValueType.STRING
|
||||
);
|
||||
PARSER.declareField(
|
||||
FollowConfig::setReadPollTimeout,
|
||||
(p, c) -> TimeValue.parseTimeValue(p.text(), READ_POLL_TIMEOUT.getPreferredName()),
|
||||
READ_POLL_TIMEOUT, ObjectParser.ValueType.STRING);
|
||||
READ_POLL_TIMEOUT,
|
||||
ObjectParser.ValueType.STRING
|
||||
);
|
||||
}
|
||||
|
||||
static FollowConfig fromXContent(XContentParser parser) {
|
||||
|
@ -85,8 +91,7 @@ public class FollowConfig {
|
|||
private TimeValue maxRetryDelay;
|
||||
private TimeValue readPollTimeout;
|
||||
|
||||
FollowConfig() {
|
||||
}
|
||||
FollowConfig() {}
|
||||
|
||||
public Settings getSettings() {
|
||||
return settings;
|
||||
|
@ -221,16 +226,16 @@ public class FollowConfig {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
FollowConfig that = (FollowConfig) o;
|
||||
return Objects.equals(maxReadRequestOperationCount, that.maxReadRequestOperationCount) &&
|
||||
Objects.equals(maxOutstandingReadRequests, that.maxOutstandingReadRequests) &&
|
||||
Objects.equals(maxReadRequestSize, that.maxReadRequestSize) &&
|
||||
Objects.equals(maxWriteRequestOperationCount, that.maxWriteRequestOperationCount) &&
|
||||
Objects.equals(maxWriteRequestSize, that.maxWriteRequestSize) &&
|
||||
Objects.equals(maxOutstandingWriteRequests, that.maxOutstandingWriteRequests) &&
|
||||
Objects.equals(maxWriteBufferCount, that.maxWriteBufferCount) &&
|
||||
Objects.equals(maxWriteBufferSize, that.maxWriteBufferSize) &&
|
||||
Objects.equals(maxRetryDelay, that.maxRetryDelay) &&
|
||||
Objects.equals(readPollTimeout, that.readPollTimeout);
|
||||
return Objects.equals(maxReadRequestOperationCount, that.maxReadRequestOperationCount)
|
||||
&& Objects.equals(maxOutstandingReadRequests, that.maxOutstandingReadRequests)
|
||||
&& Objects.equals(maxReadRequestSize, that.maxReadRequestSize)
|
||||
&& Objects.equals(maxWriteRequestOperationCount, that.maxWriteRequestOperationCount)
|
||||
&& Objects.equals(maxWriteRequestSize, that.maxWriteRequestSize)
|
||||
&& Objects.equals(maxOutstandingWriteRequests, that.maxOutstandingWriteRequests)
|
||||
&& Objects.equals(maxWriteBufferCount, that.maxWriteBufferCount)
|
||||
&& Objects.equals(maxWriteBufferSize, that.maxWriteBufferSize)
|
||||
&& Objects.equals(maxRetryDelay, that.maxRetryDelay)
|
||||
&& Objects.equals(readPollTimeout, that.readPollTimeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
package org.elasticsearch.client.ccr;
|
||||
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -26,7 +26,8 @@ public final class FollowInfoResponse {
|
|||
@SuppressWarnings("unchecked")
|
||||
List<FollowerInfo> infos = (List<FollowerInfo>) args[0];
|
||||
return new FollowInfoResponse(infos);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
static {
|
||||
PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), FollowerInfo.PARSER, FOLLOWER_INDICES_FIELD);
|
||||
|
@ -71,17 +72,26 @@ public final class FollowInfoResponse {
|
|||
"follower_info",
|
||||
true,
|
||||
args -> {
|
||||
return new FollowerInfo((String) args[0], (String) args[1], (String) args[2],
|
||||
Status.fromString((String) args[3]), (FollowConfig) args[4]);
|
||||
});
|
||||
return new FollowerInfo(
|
||||
(String) args[0],
|
||||
(String) args[1],
|
||||
(String) args[2],
|
||||
Status.fromString((String) args[3]),
|
||||
(FollowConfig) args[4]
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
static {
|
||||
PARSER.declareString(ConstructingObjectParser.constructorArg(), FOLLOWER_INDEX_FIELD);
|
||||
PARSER.declareString(ConstructingObjectParser.constructorArg(), REMOTE_CLUSTER_FIELD);
|
||||
PARSER.declareString(ConstructingObjectParser.constructorArg(), LEADER_INDEX_FIELD);
|
||||
PARSER.declareString(ConstructingObjectParser.constructorArg(), STATUS_FIELD);
|
||||
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(),
|
||||
(p, c) -> FollowConfig.fromXContent(p), PARAMETERS_FIELD);
|
||||
PARSER.declareObject(
|
||||
ConstructingObjectParser.optionalConstructorArg(),
|
||||
(p, c) -> FollowConfig.fromXContent(p),
|
||||
PARAMETERS_FIELD
|
||||
);
|
||||
}
|
||||
|
||||
private final String followerIndex;
|
||||
|
@ -90,8 +100,7 @@ public final class FollowInfoResponse {
|
|||
private final Status status;
|
||||
private final FollowConfig parameters;
|
||||
|
||||
FollowerInfo(String followerIndex, String remoteCluster, String leaderIndex, Status status,
|
||||
FollowConfig parameters) {
|
||||
FollowerInfo(String followerIndex, String remoteCluster, String leaderIndex, Status status, FollowConfig parameters) {
|
||||
this.followerIndex = followerIndex;
|
||||
this.remoteCluster = remoteCluster;
|
||||
this.leaderIndex = leaderIndex;
|
||||
|
@ -124,11 +133,11 @@ public final class FollowInfoResponse {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
FollowerInfo that = (FollowerInfo) o;
|
||||
return Objects.equals(followerIndex, that.followerIndex) &&
|
||||
Objects.equals(remoteCluster, that.remoteCluster) &&
|
||||
Objects.equals(leaderIndex, that.leaderIndex) &&
|
||||
status == that.status &&
|
||||
Objects.equals(parameters, that.parameters);
|
||||
return Objects.equals(followerIndex, that.followerIndex)
|
||||
&& Objects.equals(remoteCluster, that.remoteCluster)
|
||||
&& Objects.equals(leaderIndex, that.leaderIndex)
|
||||
&& status == that.status
|
||||
&& Objects.equals(parameters, that.parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -54,7 +54,8 @@ public final class ForgetFollowerRequest implements ToXContentObject, Validatabl
|
|||
final String followerIndex,
|
||||
final String followerIndexUUID,
|
||||
final String leaderRemoteCluster,
|
||||
final String leaderIndex) {
|
||||
final String leaderIndex
|
||||
) {
|
||||
this.followerCluster = Objects.requireNonNull(followerCluster);
|
||||
this.followerIndex = Objects.requireNonNull(followerIndex);
|
||||
this.followerIndexUUID = Objects.requireNonNull(followerIndexUUID);
|
||||
|
|
|
@ -11,11 +11,11 @@ package org.elasticsearch.client.ccr;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.util.Maps;
|
||||
import org.elasticsearch.core.TimeValue;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.core.TimeValue;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Collections;
|
||||
|
@ -31,7 +31,10 @@ public final class GetAutoFollowPatternResponse {
|
|||
static final ParseField PATTERN_FIELD = new ParseField("pattern");
|
||||
|
||||
private static final ConstructingObjectParser<Map.Entry<String, Pattern>, Void> ENTRY_PARSER = new ConstructingObjectParser<>(
|
||||
"get_auto_follow_pattern_response", true, args -> new AbstractMap.SimpleEntry<>((String) args[0], (Pattern) args[1]));
|
||||
"get_auto_follow_pattern_response",
|
||||
true,
|
||||
args -> new AbstractMap.SimpleEntry<>((String) args[0], (Pattern) args[1])
|
||||
);
|
||||
|
||||
static {
|
||||
ENTRY_PARSER.declareString(ConstructingObjectParser.constructorArg(), NAME_FIELD);
|
||||
|
@ -39,12 +42,16 @@ public final class GetAutoFollowPatternResponse {
|
|||
}
|
||||
|
||||
private static final ConstructingObjectParser<GetAutoFollowPatternResponse, Void> PARSER = new ConstructingObjectParser<>(
|
||||
"get_auto_follow_pattern_response", true, args -> {
|
||||
"get_auto_follow_pattern_response",
|
||||
true,
|
||||
args -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Map.Entry<String, Pattern>> entries = (List<Map.Entry<String, Pattern>>) args[0];
|
||||
return new GetAutoFollowPatternResponse(entries.stream()
|
||||
.collect(Maps.toUnmodifiableSortedMap(Map.Entry::getKey, Map.Entry::getValue)));
|
||||
});
|
||||
return new GetAutoFollowPatternResponse(
|
||||
entries.stream().collect(Maps.toUnmodifiableSortedMap(Map.Entry::getKey, Map.Entry::getValue))
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
static {
|
||||
PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), ENTRY_PARSER, PATTERNS_FIELD);
|
||||
|
@ -83,17 +90,21 @@ public final class GetAutoFollowPatternResponse {
|
|||
private static final ConstructingObjectParser<Pattern, Void> PARSER = new ConstructingObjectParser<>(
|
||||
"pattern",
|
||||
true,
|
||||
args -> new Pattern((String) args[0],
|
||||
args -> new Pattern(
|
||||
(String) args[0],
|
||||
(List<String>) args[1],
|
||||
args[2] == null ? Collections.emptyList() : (List<String>) args[2],
|
||||
(String) args[3])
|
||||
(String) args[3]
|
||||
)
|
||||
);
|
||||
|
||||
static {
|
||||
PARSER.declareString(ConstructingObjectParser.constructorArg(), PutFollowRequest.REMOTE_CLUSTER_FIELD);
|
||||
PARSER.declareStringArray(ConstructingObjectParser.constructorArg(), PutAutoFollowPatternRequest.LEADER_PATTERNS_FIELD);
|
||||
PARSER.declareStringArray(ConstructingObjectParser.optionalConstructorArg(),
|
||||
PutAutoFollowPatternRequest.LEADER_EXCLUSION_PATTERNS_FIELD);
|
||||
PARSER.declareStringArray(
|
||||
ConstructingObjectParser.optionalConstructorArg(),
|
||||
PutAutoFollowPatternRequest.LEADER_EXCLUSION_PATTERNS_FIELD
|
||||
);
|
||||
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), PutAutoFollowPatternRequest.FOLLOW_PATTERN_FIELD);
|
||||
PARSER.declareObject(Pattern::setSettings, (p, c) -> Settings.fromXContent(p), PutAutoFollowPatternRequest.SETTINGS);
|
||||
PARSER.declareInt(Pattern::setMaxReadRequestOperationCount, FollowConfig.MAX_READ_REQUEST_OPERATION_COUNT);
|
||||
|
@ -101,31 +112,36 @@ public final class GetAutoFollowPatternResponse {
|
|||
Pattern::setMaxReadRequestSize,
|
||||
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), FollowConfig.MAX_READ_REQUEST_SIZE.getPreferredName()),
|
||||
PutFollowRequest.MAX_READ_REQUEST_SIZE,
|
||||
ObjectParser.ValueType.STRING);
|
||||
ObjectParser.ValueType.STRING
|
||||
);
|
||||
PARSER.declareInt(Pattern::setMaxOutstandingReadRequests, FollowConfig.MAX_OUTSTANDING_READ_REQUESTS);
|
||||
PARSER.declareInt(Pattern::setMaxWriteRequestOperationCount, FollowConfig.MAX_WRITE_REQUEST_OPERATION_COUNT);
|
||||
PARSER.declareField(
|
||||
Pattern::setMaxWriteRequestSize,
|
||||
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), FollowConfig.MAX_WRITE_REQUEST_SIZE.getPreferredName()),
|
||||
PutFollowRequest.MAX_WRITE_REQUEST_SIZE,
|
||||
ObjectParser.ValueType.STRING);
|
||||
ObjectParser.ValueType.STRING
|
||||
);
|
||||
PARSER.declareInt(Pattern::setMaxOutstandingWriteRequests, FollowConfig.MAX_OUTSTANDING_WRITE_REQUESTS);
|
||||
PARSER.declareInt(Pattern::setMaxWriteBufferCount, FollowConfig.MAX_WRITE_BUFFER_COUNT);
|
||||
PARSER.declareField(
|
||||
Pattern::setMaxWriteBufferSize,
|
||||
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), FollowConfig.MAX_WRITE_BUFFER_SIZE.getPreferredName()),
|
||||
PutFollowRequest.MAX_WRITE_BUFFER_SIZE,
|
||||
ObjectParser.ValueType.STRING);
|
||||
ObjectParser.ValueType.STRING
|
||||
);
|
||||
PARSER.declareField(
|
||||
Pattern::setMaxRetryDelay,
|
||||
(p, c) -> TimeValue.parseTimeValue(p.text(), FollowConfig.MAX_RETRY_DELAY_FIELD.getPreferredName()),
|
||||
PutFollowRequest.MAX_RETRY_DELAY_FIELD,
|
||||
ObjectParser.ValueType.STRING);
|
||||
ObjectParser.ValueType.STRING
|
||||
);
|
||||
PARSER.declareField(
|
||||
Pattern::setReadPollTimeout,
|
||||
(p, c) -> TimeValue.parseTimeValue(p.text(), FollowConfig.READ_POLL_TIMEOUT.getPreferredName()),
|
||||
PutFollowRequest.READ_POLL_TIMEOUT,
|
||||
ObjectParser.ValueType.STRING);
|
||||
ObjectParser.ValueType.STRING
|
||||
);
|
||||
}
|
||||
|
||||
private final String remoteCluster;
|
||||
|
@ -133,10 +149,12 @@ public final class GetAutoFollowPatternResponse {
|
|||
private final List<String> leaderIndexExclusionPatterns;
|
||||
private final String followIndexNamePattern;
|
||||
|
||||
Pattern(String remoteCluster,
|
||||
Pattern(
|
||||
String remoteCluster,
|
||||
List<String> leaderIndexPatterns,
|
||||
List<String> leaderIndexExclusionPatterns,
|
||||
String followIndexNamePattern) {
|
||||
String followIndexNamePattern
|
||||
) {
|
||||
this.remoteCluster = remoteCluster;
|
||||
this.leaderIndexPatterns = leaderIndexPatterns;
|
||||
this.leaderIndexExclusionPatterns = leaderIndexExclusionPatterns;
|
||||
|
@ -165,21 +183,15 @@ public final class GetAutoFollowPatternResponse {
|
|||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (super.equals(o) == false) return false;
|
||||
Pattern pattern = (Pattern) o;
|
||||
return Objects.equals(remoteCluster, pattern.remoteCluster) &&
|
||||
Objects.equals(leaderIndexPatterns, pattern.leaderIndexPatterns) &&
|
||||
Objects.equals(leaderIndexExclusionPatterns, pattern.leaderIndexExclusionPatterns) &&
|
||||
Objects.equals(followIndexNamePattern, pattern.followIndexNamePattern);
|
||||
return Objects.equals(remoteCluster, pattern.remoteCluster)
|
||||
&& Objects.equals(leaderIndexPatterns, pattern.leaderIndexPatterns)
|
||||
&& Objects.equals(leaderIndexExclusionPatterns, pattern.leaderIndexExclusionPatterns)
|
||||
&& Objects.equals(followIndexNamePattern, pattern.followIndexNamePattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(
|
||||
super.hashCode(),
|
||||
remoteCluster,
|
||||
leaderIndexPatterns,
|
||||
leaderIndexExclusionPatterns,
|
||||
followIndexNamePattern
|
||||
);
|
||||
return Objects.hash(super.hashCode(), remoteCluster, leaderIndexPatterns, leaderIndexExclusionPatterns, followIndexNamePattern);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ package org.elasticsearch.client.ccr;
|
|||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.util.Maps;
|
||||
import org.elasticsearch.core.Tuple;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.core.Tuple;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Collections;
|
||||
|
@ -29,26 +29,19 @@ public final class IndicesFollowStats {
|
|||
static final ParseField SHARDS_FIELD = new ParseField("shards");
|
||||
|
||||
private static final ConstructingObjectParser<Tuple<String, List<ShardFollowStats>>, Void> ENTRY_PARSER =
|
||||
new ConstructingObjectParser<>(
|
||||
"entry",
|
||||
true,
|
||||
args -> {
|
||||
new ConstructingObjectParser<>("entry", true, args -> {
|
||||
String index = (String) args[0];
|
||||
@SuppressWarnings("unchecked")
|
||||
List<ShardFollowStats> shardFollowStats = (List<ShardFollowStats>) args[1];
|
||||
return new Tuple<>(index, shardFollowStats);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
static {
|
||||
ENTRY_PARSER.declareString(ConstructingObjectParser.constructorArg(), INDEX_FIELD);
|
||||
ENTRY_PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), ShardFollowStats.PARSER, SHARDS_FIELD);
|
||||
}
|
||||
|
||||
static final ConstructingObjectParser<IndicesFollowStats, Void> PARSER = new ConstructingObjectParser<>(
|
||||
"indices",
|
||||
true,
|
||||
args -> {
|
||||
static final ConstructingObjectParser<IndicesFollowStats, Void> PARSER = new ConstructingObjectParser<>("indices", true, args -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Tuple<String, List<ShardFollowStats>>> entries = (List<Tuple<String, List<ShardFollowStats>>>) args[0];
|
||||
Map<String, List<ShardFollowStats>> shardFollowStats = entries.stream().collect(Collectors.toMap(Tuple::v1, Tuple::v2));
|
||||
|
@ -75,7 +68,6 @@ public final class IndicesFollowStats {
|
|||
|
||||
public static final class ShardFollowStats {
|
||||
|
||||
|
||||
static final ParseField LEADER_CLUSTER = new ParseField("remote_cluster");
|
||||
static final ParseField LEADER_INDEX = new ParseField("leader_index");
|
||||
static final ParseField FOLLOWER_INDEX = new ParseField("follower_index");
|
||||
|
@ -107,8 +99,7 @@ public final class IndicesFollowStats {
|
|||
static final ParseField FATAL_EXCEPTION = new ParseField("fatal_exception");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static final ConstructingObjectParser<ShardFollowStats, Void> PARSER =
|
||||
new ConstructingObjectParser<>(
|
||||
static final ConstructingObjectParser<ShardFollowStats, Void> PARSER = new ConstructingObjectParser<>(
|
||||
"shard-follow-stats",
|
||||
true,
|
||||
args -> new ShardFollowStats(
|
||||
|
@ -139,16 +130,18 @@ public final class IndicesFollowStats {
|
|||
(long) args[24],
|
||||
(long) args[25],
|
||||
(long) args[26],
|
||||
((List<Map.Entry<Long, Tuple<Integer, ElasticsearchException>>>) args[27])
|
||||
.stream()
|
||||
((List<Map.Entry<Long, Tuple<Integer, ElasticsearchException>>>) args[27]).stream()
|
||||
.collect(Maps.toUnmodifiableSortedMap(Map.Entry::getKey, Map.Entry::getValue)),
|
||||
(ElasticsearchException) args[28]));
|
||||
(ElasticsearchException) args[28]
|
||||
)
|
||||
);
|
||||
|
||||
static final ConstructingObjectParser<Map.Entry<Long, Tuple<Integer, ElasticsearchException>>, Void> READ_EXCEPTIONS_ENTRY_PARSER =
|
||||
new ConstructingObjectParser<>(
|
||||
"shard-follow-stats-read-exceptions-entry",
|
||||
true,
|
||||
args -> new AbstractMap.SimpleEntry<>((long) args[0], Tuple.tuple((Integer) args[1], (ElasticsearchException)args[2])));
|
||||
args -> new AbstractMap.SimpleEntry<>((long) args[0], Tuple.tuple((Integer) args[1], (ElasticsearchException) args[2]))
|
||||
);
|
||||
|
||||
static {
|
||||
PARSER.declareString(ConstructingObjectParser.constructorArg(), LEADER_CLUSTER);
|
||||
|
@ -179,9 +172,11 @@ public final class IndicesFollowStats {
|
|||
PARSER.declareLong(ConstructingObjectParser.constructorArg(), OPERATIONS_WRITTEN);
|
||||
PARSER.declareLong(ConstructingObjectParser.constructorArg(), TIME_SINCE_LAST_READ_MILLIS_FIELD);
|
||||
PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), READ_EXCEPTIONS_ENTRY_PARSER, READ_EXCEPTIONS);
|
||||
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(),
|
||||
PARSER.declareObject(
|
||||
ConstructingObjectParser.optionalConstructorArg(),
|
||||
(p, c) -> ElasticsearchException.fromXContent(p),
|
||||
FATAL_EXCEPTION);
|
||||
FATAL_EXCEPTION
|
||||
);
|
||||
}
|
||||
|
||||
static final ParseField READ_EXCEPTIONS_ENTRY_FROM_SEQ_NO = new ParseField("from_seq_no");
|
||||
|
@ -194,7 +189,8 @@ public final class IndicesFollowStats {
|
|||
READ_EXCEPTIONS_ENTRY_PARSER.declareObject(
|
||||
ConstructingObjectParser.constructorArg(),
|
||||
(p, c) -> ElasticsearchException.fromXContent(p),
|
||||
READ_EXCEPTIONS_ENTRY_EXCEPTION);
|
||||
READ_EXCEPTIONS_ENTRY_EXCEPTION
|
||||
);
|
||||
}
|
||||
|
||||
private final String remoteCluster;
|
||||
|
@ -227,7 +223,8 @@ public final class IndicesFollowStats {
|
|||
private final NavigableMap<Long, Tuple<Integer, ElasticsearchException>> readExceptions;
|
||||
private final ElasticsearchException fatalException;
|
||||
|
||||
ShardFollowStats(String remoteCluster,
|
||||
ShardFollowStats(
|
||||
String remoteCluster,
|
||||
String leaderIndex,
|
||||
String followerIndex,
|
||||
int shardId,
|
||||
|
@ -255,7 +252,8 @@ public final class IndicesFollowStats {
|
|||
long operationWritten,
|
||||
long timeSinceLastReadMillis,
|
||||
NavigableMap<Long, Tuple<Integer, ElasticsearchException>> readExceptions,
|
||||
ElasticsearchException fatalException) {
|
||||
ElasticsearchException fatalException
|
||||
) {
|
||||
this.remoteCluster = remoteCluster;
|
||||
this.leaderIndex = leaderIndex;
|
||||
this.followerIndex = followerIndex;
|
||||
|
|
|
@ -30,16 +30,16 @@ public final class PutAutoFollowPatternRequest extends FollowConfig implements V
|
|||
private final List<String> leaderIndexExclusionPatterns;
|
||||
private String followIndexNamePattern;
|
||||
|
||||
public PutAutoFollowPatternRequest(String name,
|
||||
String remoteCluster,
|
||||
List<String> leaderIndexPatterns) {
|
||||
public PutAutoFollowPatternRequest(String name, String remoteCluster, List<String> leaderIndexPatterns) {
|
||||
this(name, remoteCluster, leaderIndexPatterns, Collections.emptyList());
|
||||
}
|
||||
|
||||
public PutAutoFollowPatternRequest(String name,
|
||||
public PutAutoFollowPatternRequest(
|
||||
String name,
|
||||
String remoteCluster,
|
||||
List<String> leaderIndexPatterns,
|
||||
List<String> leaderIndexExclusionPatterns) {
|
||||
List<String> leaderIndexExclusionPatterns
|
||||
) {
|
||||
this.name = Objects.requireNonNull(name);
|
||||
this.remoteCluster = Objects.requireNonNull(remoteCluster);
|
||||
this.leaderIndexPatterns = Objects.requireNonNull(leaderIndexPatterns);
|
||||
|
@ -92,11 +92,11 @@ public final class PutAutoFollowPatternRequest extends FollowConfig implements V
|
|||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (super.equals(o) == false) return false;
|
||||
PutAutoFollowPatternRequest that = (PutAutoFollowPatternRequest) o;
|
||||
return Objects.equals(name, that.name) &&
|
||||
Objects.equals(remoteCluster, that.remoteCluster) &&
|
||||
Objects.equals(leaderIndexPatterns, that.leaderIndexPatterns) &&
|
||||
Objects.equals(leaderIndexExclusionPatterns, that.leaderIndexExclusionPatterns) &&
|
||||
Objects.equals(followIndexNamePattern, that.followIndexNamePattern);
|
||||
return Objects.equals(name, that.name)
|
||||
&& Objects.equals(remoteCluster, that.remoteCluster)
|
||||
&& Objects.equals(leaderIndexPatterns, that.leaderIndexPatterns)
|
||||
&& Objects.equals(leaderIndexExclusionPatterns, that.leaderIndexExclusionPatterns)
|
||||
&& Objects.equals(followIndexNamePattern, that.followIndexNamePattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -70,19 +70,14 @@ public final class PutFollowRequest extends FollowConfig implements Validatable,
|
|||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (super.equals(o) == false) return false;
|
||||
PutFollowRequest that = (PutFollowRequest) o;
|
||||
return Objects.equals(waitForActiveShards, that.waitForActiveShards) &&
|
||||
Objects.equals(remoteCluster, that.remoteCluster) &&
|
||||
Objects.equals(leaderIndex, that.leaderIndex) &&
|
||||
Objects.equals(followerIndex, that.followerIndex);
|
||||
return Objects.equals(waitForActiveShards, that.waitForActiveShards)
|
||||
&& Objects.equals(remoteCluster, that.remoteCluster)
|
||||
&& Objects.equals(leaderIndex, that.leaderIndex)
|
||||
&& Objects.equals(followerIndex, that.followerIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(
|
||||
super.hashCode(),
|
||||
remoteCluster,
|
||||
leaderIndex,
|
||||
followerIndex,
|
||||
waitForActiveShards);
|
||||
return Objects.hash(super.hashCode(), remoteCluster, leaderIndex, followerIndex, waitForActiveShards);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
package org.elasticsearch.client.ccr;
|
||||
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -22,7 +22,10 @@ public final class PutFollowResponse {
|
|||
static final ParseField INDEX_FOLLOWING_STARTED = new ParseField("index_following_started");
|
||||
|
||||
private static final ConstructingObjectParser<PutFollowResponse, Void> PARSER = new ConstructingObjectParser<>(
|
||||
"put_follow_response", true, args -> new PutFollowResponse((boolean) args[0], (boolean) args[1], (boolean) args[2]));
|
||||
"put_follow_response",
|
||||
true,
|
||||
args -> new PutFollowResponse((boolean) args[0], (boolean) args[1], (boolean) args[2])
|
||||
);
|
||||
|
||||
static {
|
||||
PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), FOLLOW_INDEX_CREATED);
|
||||
|
@ -61,9 +64,9 @@ public final class PutFollowResponse {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PutFollowResponse that = (PutFollowResponse) o;
|
||||
return followIndexCreated == that.followIndexCreated &&
|
||||
followIndexShardsAcked == that.followIndexShardsAcked &&
|
||||
indexFollowingStarted == that.indexFollowingStarted;
|
||||
return followIndexCreated == that.followIndexCreated
|
||||
&& followIndexShardsAcked == that.followIndexShardsAcked
|
||||
&& indexFollowingStarted == that.indexFollowingStarted;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -59,10 +59,10 @@ public class ProxyModeInfo implements RemoteConnectionInfo.ModeInfo {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ProxyModeInfo otherProxy = (ProxyModeInfo) o;
|
||||
return maxSocketConnections == otherProxy.maxSocketConnections &&
|
||||
numSocketsConnected == otherProxy.numSocketsConnected &&
|
||||
Objects.equals(address, otherProxy.address) &&
|
||||
Objects.equals(serverName, otherProxy.serverName);
|
||||
return maxSocketConnections == otherProxy.maxSocketConnections
|
||||
&& numSocketsConnected == otherProxy.numSocketsConnected
|
||||
&& Objects.equals(address, otherProxy.address)
|
||||
&& Objects.equals(serverName, otherProxy.serverName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
package org.elasticsearch.client.cluster;
|
||||
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -43,11 +43,9 @@ public final class RemoteConnectionInfo {
|
|||
} else {
|
||||
throw new IllegalArgumentException("mode cannot be " + mode);
|
||||
}
|
||||
return new RemoteConnectionInfo(clusterAlias,
|
||||
modeInfo,
|
||||
(String) args[2],
|
||||
(boolean) args[3]);
|
||||
});
|
||||
return new RemoteConnectionInfo(clusterAlias, modeInfo, (String) args[2], (boolean) args[3]);
|
||||
}
|
||||
);
|
||||
|
||||
static {
|
||||
PARSER.declareBoolean(constructorArg(), new ParseField(CONNECTED));
|
||||
|
@ -109,10 +107,10 @@ public final class RemoteConnectionInfo {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
RemoteConnectionInfo that = (RemoteConnectionInfo) o;
|
||||
return skipUnavailable == that.skipUnavailable &&
|
||||
Objects.equals(modeInfo, that.modeInfo) &&
|
||||
Objects.equals(initialConnectionTimeoutString, that.initialConnectionTimeoutString) &&
|
||||
Objects.equals(clusterAlias, that.clusterAlias);
|
||||
return skipUnavailable == that.skipUnavailable
|
||||
&& Objects.equals(modeInfo, that.modeInfo)
|
||||
&& Objects.equals(initialConnectionTimeoutString, that.initialConnectionTimeoutString)
|
||||
&& Objects.equals(clusterAlias, that.clusterAlias);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -53,9 +53,9 @@ public class SniffModeInfo implements RemoteConnectionInfo.ModeInfo {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
SniffModeInfo sniff = (SniffModeInfo) o;
|
||||
return maxConnectionsPerCluster == sniff.maxConnectionsPerCluster &&
|
||||
numNodesConnected == sniff.numNodesConnected &&
|
||||
Objects.equals(seedNodes, sniff.seedNodes);
|
||||
return maxConnectionsPerCluster == sniff.maxConnectionsPerCluster
|
||||
&& numNodesConnected == sniff.numNodesConnected
|
||||
&& Objects.equals(seedNodes, sniff.seedNodes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,8 +31,7 @@ public final class TimeUtil {
|
|||
} else if (parser.currentToken() == XContentParser.Token.VALUE_STRING) {
|
||||
return new Date(DateFormatters.from(DateTimeFormatter.ISO_INSTANT.parse(parser.text())).toInstant().toEpochMilli());
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + parser.currentToken() + "] for [" + fieldName + "]");
|
||||
throw new IllegalArgumentException("unexpected token [" + parser.currentToken() + "] for [" + fieldName + "]");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,8 +48,7 @@ public final class TimeUtil {
|
|||
} else if (parser.currentToken() == XContentParser.Token.VALUE_STRING) {
|
||||
return DateFormatters.from(DateTimeFormatter.ISO_INSTANT.parse(parser.text())).toInstant();
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + parser.currentToken() + "] for [" + fieldName + "]");
|
||||
throw new IllegalArgumentException("unexpected token [" + parser.currentToken() + "] for [" + fieldName + "]");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
package org.elasticsearch.client.core;
|
||||
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -21,8 +21,11 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
|
|||
public class AcknowledgedResponse {
|
||||
|
||||
protected static final String PARSE_FIELD_NAME = "acknowledged";
|
||||
private static final ConstructingObjectParser<AcknowledgedResponse, Void> PARSER = AcknowledgedResponse
|
||||
.generateParser("acknowledged_response", AcknowledgedResponse::new, AcknowledgedResponse.PARSE_FIELD_NAME);
|
||||
private static final ConstructingObjectParser<AcknowledgedResponse, Void> PARSER = AcknowledgedResponse.generateParser(
|
||||
"acknowledged_response",
|
||||
AcknowledgedResponse::new,
|
||||
AcknowledgedResponse.PARSE_FIELD_NAME
|
||||
);
|
||||
|
||||
private final boolean acknowledged;
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
package org.elasticsearch.client.core;
|
||||
|
||||
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -42,7 +42,8 @@ public class BroadcastResponse {
|
|||
|
||||
static final ConstructingObjectParser<BroadcastResponse, Void> PARSER = new ConstructingObjectParser<>(
|
||||
"broadcast_response",
|
||||
a -> new BroadcastResponse((Shards) a[0]));
|
||||
a -> new BroadcastResponse((Shards) a[0])
|
||||
);
|
||||
|
||||
static {
|
||||
declareShardsField(PARSER);
|
||||
|
@ -129,7 +130,8 @@ public class BroadcastResponse {
|
|||
final int successful,
|
||||
final int skipped,
|
||||
final int failed,
|
||||
final Collection<DefaultShardOperationFailedException> failures) {
|
||||
final Collection<DefaultShardOperationFailedException> failures
|
||||
) {
|
||||
this.total = total;
|
||||
this.successful = successful;
|
||||
this.skipped = skipped;
|
||||
|
@ -151,7 +153,9 @@ public class BroadcastResponse {
|
|||
(int) a[1], // successful
|
||||
a[2] == null ? 0 : (int) a[2], // skipped
|
||||
(int) a[3], // failed
|
||||
a[4] == null ? Collections.emptyList() : (Collection<DefaultShardOperationFailedException>) a[4])); // failures
|
||||
a[4] == null ? Collections.emptyList() : (Collection<DefaultShardOperationFailedException>) a[4]
|
||||
)
|
||||
); // failures
|
||||
|
||||
static {
|
||||
SHARDS_PARSER.declareInt(ConstructingObjectParser.constructorArg(), TOTAL_FIELD);
|
||||
|
@ -160,7 +164,9 @@ public class BroadcastResponse {
|
|||
SHARDS_PARSER.declareInt(ConstructingObjectParser.constructorArg(), FAILED_FIELD);
|
||||
SHARDS_PARSER.declareObjectArray(
|
||||
ConstructingObjectParser.optionalConstructorArg(),
|
||||
DefaultShardOperationFailedException.PARSER, FAILURES_FIELD);
|
||||
DefaultShardOperationFailedException.PARSER,
|
||||
FAILURES_FIELD
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@ package org.elasticsearch.client.core;
|
|||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.client.Validatable;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
import org.elasticsearch.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
@ -60,7 +60,8 @@ public final class CountRequest implements Validatable, ToXContentObject {
|
|||
*/
|
||||
public CountRequest(String[] indices, QueryBuilder query) {
|
||||
indices(indices);
|
||||
this.query = Objects.requireNonNull(query, "query must not be null");;
|
||||
this.query = Objects.requireNonNull(query, "query must not be null");
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -228,14 +229,14 @@ public final class CountRequest implements Validatable, ToXContentObject {
|
|||
return false;
|
||||
}
|
||||
CountRequest that = (CountRequest) o;
|
||||
return Objects.equals(indicesOptions, that.indicesOptions) &&
|
||||
Arrays.equals(indices, that.indices) &&
|
||||
Arrays.equals(types, that.types) &&
|
||||
Objects.equals(routing, that.routing) &&
|
||||
Objects.equals(preference, that.preference) &&
|
||||
Objects.equals(terminateAfter, that.terminateAfter) &&
|
||||
Objects.equals(minScore, that.minScore) &&
|
||||
Objects.equals(query, that.query);
|
||||
return Objects.equals(indicesOptions, that.indicesOptions)
|
||||
&& Arrays.equals(indices, that.indices)
|
||||
&& Arrays.equals(types, that.types)
|
||||
&& Objects.equals(routing, that.routing)
|
||||
&& Objects.equals(preference, that.preference)
|
||||
&& Objects.equals(terminateAfter, that.terminateAfter)
|
||||
&& Objects.equals(minScore, that.minScore)
|
||||
&& Objects.equals(query, that.query);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
package org.elasticsearch.client.core;
|
||||
|
||||
import org.elasticsearch.action.search.ShardSearchFailure;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -122,11 +122,13 @@ public final class CountResponse {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = "{" +
|
||||
"count=" + count +
|
||||
(isTerminatedEarly() != null ? ", terminatedEarly=" + terminatedEarly : "") +
|
||||
", " + shardStats +
|
||||
'}';
|
||||
String s = "{"
|
||||
+ "count="
|
||||
+ count
|
||||
+ (isTerminatedEarly() != null ? ", terminatedEarly=" + terminatedEarly : "")
|
||||
+ ", "
|
||||
+ shardStats
|
||||
+ '}';
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -212,13 +214,17 @@ public final class CountResponse {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "_shards : {" +
|
||||
"total=" + totalShards +
|
||||
", successful=" + successfulShards +
|
||||
", skipped=" + skippedShards +
|
||||
", failed=" + (shardFailures != null && shardFailures.length > 0 ? shardFailures.length : 0 ) +
|
||||
(shardFailures != null && shardFailures.length > 0 ? ", failures: " + Arrays.asList(shardFailures): "") +
|
||||
'}';
|
||||
return "_shards : {"
|
||||
+ "total="
|
||||
+ totalShards
|
||||
+ ", successful="
|
||||
+ successfulShards
|
||||
+ ", skipped="
|
||||
+ skippedShards
|
||||
+ ", failed="
|
||||
+ (shardFailures != null && shardFailures.length > 0 ? shardFailures.length : 0)
|
||||
+ (shardFailures != null && shardFailures.length > 0 ? ", failures: " + Arrays.asList(shardFailures) : "")
|
||||
+ '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,7 @@ public final class GetSourceRequest implements Validatable {
|
|||
}
|
||||
|
||||
public static GetSourceRequest from(GetRequest getRequest) {
|
||||
return new GetSourceRequest(getRequest.index(), getRequest.id())
|
||||
.routing(getRequest.routing())
|
||||
return new GetSourceRequest(getRequest.index(), getRequest.id()).routing(getRequest.routing())
|
||||
.preference(getRequest.preference())
|
||||
.refresh(getRequest.refresh())
|
||||
.realtime(getRequest.realtime())
|
||||
|
|
|
@ -39,9 +39,20 @@ public abstract class IndexerJobStats {
|
|||
protected final long indexFailures;
|
||||
protected final long searchFailures;
|
||||
|
||||
public IndexerJobStats(long numPages, long numInputDocuments, long numOutputDocuments, long numInvocations,
|
||||
long indexTime, long searchTime, long processingTime, long indexTotal, long searchTotal, long processingTotal,
|
||||
long indexFailures, long searchFailures) {
|
||||
public IndexerJobStats(
|
||||
long numPages,
|
||||
long numInputDocuments,
|
||||
long numOutputDocuments,
|
||||
long numInvocations,
|
||||
long indexTime,
|
||||
long searchTime,
|
||||
long processingTime,
|
||||
long indexTotal,
|
||||
long searchTotal,
|
||||
long processingTotal,
|
||||
long indexFailures,
|
||||
long searchFailures
|
||||
) {
|
||||
this.numPages = numPages;
|
||||
this.numInputDocuments = numInputDocuments;
|
||||
this.numOuputDocuments = numOutputDocuments;
|
||||
|
@ -141,7 +152,6 @@ public abstract class IndexerJobStats {
|
|||
return processingTotal;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
|
@ -169,24 +179,48 @@ public abstract class IndexerJobStats {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(numPages, numInputDocuments, numOuputDocuments, numInvocations,
|
||||
indexTime, searchTime, processingTime, indexFailures, searchFailures, searchTotal,
|
||||
indexTotal, processingTotal);
|
||||
return Objects.hash(
|
||||
numPages,
|
||||
numInputDocuments,
|
||||
numOuputDocuments,
|
||||
numInvocations,
|
||||
indexTime,
|
||||
searchTime,
|
||||
processingTime,
|
||||
indexFailures,
|
||||
searchFailures,
|
||||
searchTotal,
|
||||
indexTotal,
|
||||
processingTotal
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return "{pages=" + numPages
|
||||
+ ", input_docs=" + numInputDocuments
|
||||
+ ", output_docs=" + numOuputDocuments
|
||||
+ ", invocations=" + numInvocations
|
||||
+ ", index_failures=" + indexFailures
|
||||
+ ", search_failures=" + searchFailures
|
||||
+ ", index_time_in_ms=" + indexTime
|
||||
+ ", index_total=" + indexTotal
|
||||
+ ", search_time_in_ms=" + searchTime
|
||||
+ ", search_total=" + searchTotal
|
||||
+ ", processing_time_in_ms=" + processingTime
|
||||
+ ", processing_total=" + processingTotal + "}";
|
||||
return "{pages="
|
||||
+ numPages
|
||||
+ ", input_docs="
|
||||
+ numInputDocuments
|
||||
+ ", output_docs="
|
||||
+ numOuputDocuments
|
||||
+ ", invocations="
|
||||
+ numInvocations
|
||||
+ ", index_failures="
|
||||
+ indexFailures
|
||||
+ ", search_failures="
|
||||
+ searchFailures
|
||||
+ ", index_time_in_ms="
|
||||
+ indexTime
|
||||
+ ", index_total="
|
||||
+ indexTotal
|
||||
+ ", search_time_in_ms="
|
||||
+ searchTime
|
||||
+ ", search_total="
|
||||
+ searchTotal
|
||||
+ ", processing_time_in_ms="
|
||||
+ processingTime
|
||||
+ ", processing_total="
|
||||
+ processingTotal
|
||||
+ "}";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
package org.elasticsearch.client.core;
|
||||
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,5 +10,4 @@ package org.elasticsearch.client.core;
|
|||
|
||||
import org.elasticsearch.client.Validatable;
|
||||
|
||||
public class MainRequest implements Validatable {
|
||||
}
|
||||
public class MainRequest implements Validatable {}
|
||||
|
|
|
@ -8,19 +8,18 @@
|
|||
|
||||
package org.elasticsearch.client.core;
|
||||
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class MainResponse {
|
||||
|
||||
private static final ConstructingObjectParser<MainResponse, Void> PARSER =
|
||||
new ConstructingObjectParser<>(MainResponse.class.getName(), true,
|
||||
args -> {
|
||||
return new MainResponse((String) args[0], (Version) args[1], (String) args[2], (String) args[3], (String) args[4]);
|
||||
}
|
||||
private static final ConstructingObjectParser<MainResponse, Void> PARSER = new ConstructingObjectParser<>(
|
||||
MainResponse.class.getName(),
|
||||
true,
|
||||
args -> { return new MainResponse((String) args[0], (Version) args[1], (String) args[2], (String) args[3], (String) args[4]); }
|
||||
);
|
||||
|
||||
static {
|
||||
|
@ -75,11 +74,11 @@ public class MainResponse {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MainResponse that = (MainResponse) o;
|
||||
return nodeName.equals(that.nodeName) &&
|
||||
version.equals(that.version) &&
|
||||
clusterName.equals(that.clusterName) &&
|
||||
clusterUuid.equals(that.clusterUuid) &&
|
||||
tagline.equals(that.tagline);
|
||||
return nodeName.equals(that.nodeName)
|
||||
&& version.equals(that.version)
|
||||
&& clusterName.equals(that.clusterName)
|
||||
&& clusterUuid.equals(that.clusterUuid)
|
||||
&& tagline.equals(that.tagline);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -88,11 +87,21 @@ public class MainResponse {
|
|||
}
|
||||
|
||||
public static class Version {
|
||||
private static final ConstructingObjectParser<Version, Void> PARSER =
|
||||
new ConstructingObjectParser<>(Version.class.getName(), true,
|
||||
private static final ConstructingObjectParser<Version, Void> PARSER = new ConstructingObjectParser<>(
|
||||
Version.class.getName(),
|
||||
true,
|
||||
args -> {
|
||||
return new Version((String) args[0], (String) args[1], (String) args[2], (String) args[3], (String) args[4],
|
||||
(Boolean) args[5], (String) args[6], (String) args[7], (String) args[8]);
|
||||
return new Version(
|
||||
(String) args[0],
|
||||
(String) args[1],
|
||||
(String) args[2],
|
||||
(String) args[3],
|
||||
(String) args[4],
|
||||
(Boolean) args[5],
|
||||
(String) args[6],
|
||||
(String) args[7],
|
||||
(String) args[8]
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -117,8 +126,17 @@ public class MainResponse {
|
|||
private final String minimumWireCompatibilityVersion;
|
||||
private final String minimumIndexCompatibilityVersion;
|
||||
|
||||
public Version(String number, String buildFlavor, String buildType, String buildHash, String buildDate, boolean isSnapshot,
|
||||
String luceneVersion, String minimumWireCompatibilityVersion, String minimumIndexCompatibilityVersion) {
|
||||
public Version(
|
||||
String number,
|
||||
String buildFlavor,
|
||||
String buildType,
|
||||
String buildHash,
|
||||
String buildDate,
|
||||
boolean isSnapshot,
|
||||
String luceneVersion,
|
||||
String minimumWireCompatibilityVersion,
|
||||
String minimumIndexCompatibilityVersion
|
||||
) {
|
||||
this.number = number;
|
||||
this.buildFlavor = buildFlavor;
|
||||
this.buildType = buildType;
|
||||
|
@ -171,21 +189,30 @@ public class MainResponse {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Version version = (Version) o;
|
||||
return isSnapshot == version.isSnapshot &&
|
||||
number.equals(version.number) &&
|
||||
Objects.equals(buildFlavor, version.buildFlavor) &&
|
||||
Objects.equals(buildType, version.buildType) &&
|
||||
buildHash.equals(version.buildHash) &&
|
||||
buildDate.equals(version.buildDate) &&
|
||||
luceneVersion.equals(version.luceneVersion) &&
|
||||
minimumWireCompatibilityVersion.equals(version.minimumWireCompatibilityVersion) &&
|
||||
minimumIndexCompatibilityVersion.equals(version.minimumIndexCompatibilityVersion);
|
||||
return isSnapshot == version.isSnapshot
|
||||
&& number.equals(version.number)
|
||||
&& Objects.equals(buildFlavor, version.buildFlavor)
|
||||
&& Objects.equals(buildType, version.buildType)
|
||||
&& buildHash.equals(version.buildHash)
|
||||
&& buildDate.equals(version.buildDate)
|
||||
&& luceneVersion.equals(version.luceneVersion)
|
||||
&& minimumWireCompatibilityVersion.equals(version.minimumWireCompatibilityVersion)
|
||||
&& minimumIndexCompatibilityVersion.equals(version.minimumIndexCompatibilityVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(number, buildFlavor, buildType, buildHash, buildDate, isSnapshot, luceneVersion,
|
||||
minimumWireCompatibilityVersion, minimumIndexCompatibilityVersion);
|
||||
return Objects.hash(
|
||||
number,
|
||||
buildFlavor,
|
||||
buildType,
|
||||
buildHash,
|
||||
buildDate,
|
||||
isSnapshot,
|
||||
luceneVersion,
|
||||
minimumWireCompatibilityVersion,
|
||||
minimumIndexCompatibilityVersion
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,8 @@
|
|||
|
||||
package org.elasticsearch.client.core;
|
||||
|
||||
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -25,11 +24,13 @@ public class MultiTermVectorsResponse {
|
|||
this.responses = responses;
|
||||
}
|
||||
|
||||
private static final ConstructingObjectParser<MultiTermVectorsResponse, Void> PARSER =
|
||||
new ConstructingObjectParser<>("multi_term_vectors", true,
|
||||
private static final ConstructingObjectParser<MultiTermVectorsResponse, Void> PARSER = new ConstructingObjectParser<>(
|
||||
"multi_term_vectors",
|
||||
true,
|
||||
args -> {
|
||||
// as the response comes from server, we are sure that args[0] will be a list of TermVectorsResponse
|
||||
@SuppressWarnings("unchecked") List<TermVectorsResponse> termVectorsResponsesList = (List<TermVectorsResponse>) args[0];
|
||||
@SuppressWarnings("unchecked")
|
||||
List<TermVectorsResponse> termVectorsResponsesList = (List<TermVectorsResponse>) args[0];
|
||||
return new MultiTermVectorsResponse(termVectorsResponsesList);
|
||||
}
|
||||
);
|
||||
|
@ -49,7 +50,6 @@ public class MultiTermVectorsResponse {
|
|||
return responses;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
package org.elasticsearch.client.core;
|
||||
|
||||
import org.elasticsearch.core.Nullable;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
|
||||
|
@ -25,8 +25,10 @@ public class PageParams implements ToXContentObject {
|
|||
public static final ParseField FROM = new ParseField("from");
|
||||
public static final ParseField SIZE = new ParseField("size");
|
||||
|
||||
public static final ConstructingObjectParser<PageParams, Void> PARSER = new ConstructingObjectParser<>(PAGE.getPreferredName(),
|
||||
a -> new PageParams((Integer) a[0], (Integer) a[1]));
|
||||
public static final ConstructingObjectParser<PageParams, Void> PARSER = new ConstructingObjectParser<>(
|
||||
PAGE.getPreferredName(),
|
||||
a -> new PageParams((Integer) a[0], (Integer) a[1])
|
||||
);
|
||||
|
||||
static {
|
||||
PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), FROM);
|
||||
|
@ -81,8 +83,7 @@ public class PageParams implements ToXContentObject {
|
|||
return false;
|
||||
}
|
||||
PageParams other = (PageParams) obj;
|
||||
return Objects.equals(from, other.from) &&
|
||||
Objects.equals(size, other.size);
|
||||
return Objects.equals(from, other.from) && Objects.equals(size, other.size);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
*/
|
||||
package org.elasticsearch.client.core;
|
||||
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.xcontent.ParseField;
|
||||
import org.elasticsearch.xcontent.XContentParser;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -18,10 +18,14 @@ import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg
|
|||
public class ShardsAcknowledgedResponse extends AcknowledgedResponse {
|
||||
|
||||
protected static final String SHARDS_PARSE_FIELD_NAME = "shards_acknowledged";
|
||||
|
||||
private static ConstructingObjectParser<ShardsAcknowledgedResponse, Void> buildParser() {
|
||||
|
||||
ConstructingObjectParser<ShardsAcknowledgedResponse, Void> p = new ConstructingObjectParser<>("freeze", true,
|
||||
args -> new ShardsAcknowledgedResponse((boolean) args[0], (boolean) args[1]));
|
||||
ConstructingObjectParser<ShardsAcknowledgedResponse, Void> p = new ConstructingObjectParser<>(
|
||||
"freeze",
|
||||
true,
|
||||
args -> new ShardsAcknowledgedResponse((boolean) args[0], (boolean) args[1])
|
||||
);
|
||||
p.declareBoolean(constructorArg(), new ParseField(AcknowledgedResponse.PARSE_FIELD_NAME));
|
||||
p.declareBoolean(constructorArg(), new ParseField(SHARDS_PARSE_FIELD_NAME));
|
||||
return p;
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
package org.elasticsearch.client.core;
|
||||
|
||||
import org.elasticsearch.client.Validatable;
|
||||
import org.elasticsearch.core.Nullable;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.core.Nullable;
|
||||
import org.elasticsearch.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.xcontent.XContentBuilder;
|
||||
|
||||
|
@ -21,7 +21,8 @@ import java.util.Map;
|
|||
public class TermVectorsRequest implements ToXContentObject, Validatable {
|
||||
|
||||
private final String index;
|
||||
@Nullable private final String type;
|
||||
@Nullable
|
||||
private final String type;
|
||||
private String id = null;
|
||||
private XContentBuilder docBuilder = null;
|
||||
|
||||
|
@ -94,7 +95,6 @@ public class TermVectorsRequest implements ToXContentObject, Validatable {
|
|||
this.docBuilder = docBuilder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new TermVectorRequest from a template
|
||||
* using the provided document id
|
||||
|
@ -238,7 +238,6 @@ public class TermVectorsRequest implements ToXContentObject, Validatable {
|
|||
return realtime;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject();
|
||||
|
@ -265,8 +264,14 @@ public class TermVectorsRequest implements ToXContentObject, Validatable {
|
|||
|
||||
if (filterSettings != null) {
|
||||
builder.startObject("filter");
|
||||
String[] filterSettingNames =
|
||||
{"max_num_terms", "min_term_freq", "max_term_freq", "min_doc_freq", "max_doc_freq", "min_word_length", "max_word_length"};
|
||||
String[] filterSettingNames = {
|
||||
"max_num_terms",
|
||||
"min_term_freq",
|
||||
"max_term_freq",
|
||||
"min_doc_freq",
|
||||
"max_doc_freq",
|
||||
"min_word_length",
|
||||
"max_word_length" };
|
||||
for (String settingName : filterSettingNames) {
|
||||
if (filterSettings.containsKey(settingName)) builder.field(settingName, filterSettings.get(settingName));
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue