Fix Javadoc errors in `client/sniffer` (#802)
* Adds a gradle plugin to validate missing javadocs Use `./gradlew missingJavadoc` to validate missing javadocs. Currently this task fails because several modules are missing appropriate javadocs. Once added, this should pass. Also, precommit PomValidation check currently fails with missing Javadoc plugin, that needs to be fixed - https://github.com/opensearch-project/OpenSearch/issues/449 Thus keeping this in a separate feature branch. Signed-off-by: Himanshu Setia <setiah@amazon.com> * Fix Javadoc errors in client/sniffer module Signed-off-by: Gregor Zurowski <gregor@zurowski.org> * Add package info to client/sniffer module Signed-off-by: Gregor Zurowski <gregor@zurowski.org> Co-authored-by: Himanshu Setia <setiah@amazon.com>
This commit is contained in:
parent
6a8e303591
commit
0f9060761c
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Licensed to OpenSearch under one or more contributor
|
||||||
|
* license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright
|
||||||
|
* ownership. OpenSearch licenses this file to you under
|
||||||
|
* the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
* not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Adding a sample package level javadoc to pass javadoc validation
|
||||||
|
* on reaper package.
|
||||||
|
* TODO - Need to add package description
|
||||||
|
*/
|
||||||
|
package org.elasticsearch.gradle.reaper;
|
|
@ -69,6 +69,9 @@ public final class OpenSearchNodesSniffer implements NodesSniffer {
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(OpenSearchNodesSniffer.class);
|
private static final Log logger = LogFactory.getLog(OpenSearchNodesSniffer.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default sniff request timeout (in milliseconds).
|
||||||
|
*/
|
||||||
public static final long DEFAULT_SNIFF_REQUEST_TIMEOUT = TimeUnit.SECONDS.toMillis(1);
|
public static final long DEFAULT_SNIFF_REQUEST_TIMEOUT = TimeUnit.SECONDS.toMillis(1);
|
||||||
|
|
||||||
private final RestClient restClient;
|
private final RestClient restClient;
|
||||||
|
@ -310,8 +313,19 @@ public final class OpenSearchNodesSniffer implements NodesSniffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The supported host schemes.
|
||||||
|
*/
|
||||||
public enum Scheme {
|
public enum Scheme {
|
||||||
HTTP("http"), HTTPS("https");
|
/**
|
||||||
|
* The HTTP host scheme.
|
||||||
|
*/
|
||||||
|
HTTP("http"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The HTTPS host scheme.
|
||||||
|
*/
|
||||||
|
HTTPS("https");
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
|
|
@ -49,12 +49,18 @@ public class SniffOnFailureListener extends RestClient.FailureListener {
|
||||||
private volatile Sniffer sniffer;
|
private volatile Sniffer sniffer;
|
||||||
private final AtomicBoolean set;
|
private final AtomicBoolean set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@code SniffOnFailureListener} instance. The {@link Sniffer} needs to be set
|
||||||
|
* through {@link #setSniffer(Sniffer)} after instantiation.
|
||||||
|
*/
|
||||||
public SniffOnFailureListener() {
|
public SniffOnFailureListener() {
|
||||||
this.set = new AtomicBoolean(false);
|
this.set = new AtomicBoolean(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link Sniffer} instance used to perform sniffing
|
* Sets the {@link Sniffer} instance used to perform sniffing.
|
||||||
|
*
|
||||||
|
* @param sniffer The {@link Sniffer} instance to be used.
|
||||||
* @throws IllegalStateException if the sniffer was already set, as it can only be set once
|
* @throws IllegalStateException if the sniffer was already set, as it can only be set once
|
||||||
*/
|
*/
|
||||||
public void setSniffer(Sniffer sniffer) {
|
public void setSniffer(Sniffer sniffer) {
|
||||||
|
|
|
@ -41,7 +41,15 @@ import java.util.concurrent.TimeUnit;
|
||||||
* Sniffer builder. Helps creating a new {@link Sniffer}.
|
* Sniffer builder. Helps creating a new {@link Sniffer}.
|
||||||
*/
|
*/
|
||||||
public final class SnifferBuilder {
|
public final class SnifferBuilder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default sniff interval (in milliseconds).
|
||||||
|
*/
|
||||||
public static final long DEFAULT_SNIFF_INTERVAL = TimeUnit.MINUTES.toMillis(5);
|
public static final long DEFAULT_SNIFF_INTERVAL = TimeUnit.MINUTES.toMillis(5);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default delay of a sniff execution after a failure (in milliseconds).
|
||||||
|
*/
|
||||||
public static final long DEFAULT_SNIFF_AFTER_FAILURE_DELAY = TimeUnit.MINUTES.toMillis(1);
|
public static final long DEFAULT_SNIFF_AFTER_FAILURE_DELAY = TimeUnit.MINUTES.toMillis(1);
|
||||||
|
|
||||||
private final RestClient restClient;
|
private final RestClient restClient;
|
||||||
|
@ -60,6 +68,8 @@ public final class SnifferBuilder {
|
||||||
/**
|
/**
|
||||||
* Sets the interval between consecutive ordinary sniff executions in milliseconds. Will be honoured when
|
* Sets the interval between consecutive ordinary sniff executions in milliseconds. Will be honoured when
|
||||||
* sniffOnFailure is disabled or when there are no failures between consecutive sniff executions.
|
* sniffOnFailure is disabled or when there are no failures between consecutive sniff executions.
|
||||||
|
*
|
||||||
|
* @param sniffIntervalMillis the interval between sniff executions in milliseconds.
|
||||||
* @throws IllegalArgumentException if sniffIntervalMillis is not greater than 0
|
* @throws IllegalArgumentException if sniffIntervalMillis is not greater than 0
|
||||||
*/
|
*/
|
||||||
public SnifferBuilder setSniffIntervalMillis(int sniffIntervalMillis) {
|
public SnifferBuilder setSniffIntervalMillis(int sniffIntervalMillis) {
|
||||||
|
@ -71,7 +81,9 @@ public final class SnifferBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the delay of a sniff execution scheduled after a failure (in milliseconds)
|
* Sets the delay of a sniff execution scheduled after a failure (in milliseconds).
|
||||||
|
*
|
||||||
|
* @param sniffAfterFailureDelayMillis the sniff delay in milliseconds.
|
||||||
*/
|
*/
|
||||||
public SnifferBuilder setSniffAfterFailureDelayMillis(int sniffAfterFailureDelayMillis) {
|
public SnifferBuilder setSniffAfterFailureDelayMillis(int sniffAfterFailureDelayMillis) {
|
||||||
if (sniffAfterFailureDelayMillis <= 0) {
|
if (sniffAfterFailureDelayMillis <= 0) {
|
||||||
|
@ -85,6 +97,8 @@ public final class SnifferBuilder {
|
||||||
* Sets the {@link NodesSniffer} to be used to read hosts. A default instance of {@link OpenSearchNodesSniffer}
|
* Sets the {@link NodesSniffer} to be used to read hosts. A default instance of {@link OpenSearchNodesSniffer}
|
||||||
* is created when not provided. This method can be used to change the configuration of the {@link OpenSearchNodesSniffer},
|
* is created when not provided. This method can be used to change the configuration of the {@link OpenSearchNodesSniffer},
|
||||||
* or to provide a different implementation (e.g. in case hosts need to taken from a different source).
|
* or to provide a different implementation (e.g. in case hosts need to taken from a different source).
|
||||||
|
*
|
||||||
|
* @param nodesSniffer the {@link NodesSniffer} instance to be used.
|
||||||
*/
|
*/
|
||||||
public SnifferBuilder setNodesSniffer(NodesSniffer nodesSniffer) {
|
public SnifferBuilder setNodesSniffer(NodesSniffer nodesSniffer) {
|
||||||
Objects.requireNonNull(nodesSniffer, "nodesSniffer cannot be null");
|
Objects.requireNonNull(nodesSniffer, "nodesSniffer cannot be null");
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
/*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* The OpenSearch Contributors require contributions made to
|
||||||
|
* this file be licensed under the Apache-2.0 license or a
|
||||||
|
* compatible open source license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Support for sniffing nodes.
|
||||||
|
*/
|
||||||
|
package org.opensearch.client.sniff;
|
Loading…
Reference in New Issue