Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] [2.x] Added missed API visibility annotations for public / experimental APIs (#12864) #12867

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@

import org.opensearch.common.CheckedFunction;
import org.opensearch.common.Nullable;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.collect.Tuple;
import org.opensearch.core.ParseField;
import org.opensearch.core.common.Strings;
@@ -69,8 +70,9 @@
/**
* A core library base class for all opensearch exceptions.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class OpenSearchException extends RuntimeException implements Writeable, ToXContentFragment {

protected static final Version UNKNOWN_VERSION_ADDED = Version.fromId(0);
Original file line number Diff line number Diff line change
@@ -32,14 +32,17 @@

package org.opensearch.core.common.breaker;

import org.opensearch.common.annotation.PublicApi;

import java.util.Locale;

/**
* Interface for an object that can be incremented, breaking after some
* configured limit has been reached.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface CircuitBreaker {

/**
@@ -72,8 +75,10 @@ public interface CircuitBreaker {
/**
* The type of breaker
* can be {@link #MEMORY}, {@link #PARENT}, or {@link #NOOP}
* @opensearch.internal
*
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
enum Type {
/** A regular or ChildMemoryCircuitBreaker */
MEMORY,
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@

package org.opensearch.core.common.transport;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.network.InetAddresses;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
@@ -44,8 +45,9 @@
* the addresses the transport is bound to, and the other is the published one that represents the address clients
* should communicate on.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class BoundTransportAddress implements Writeable {

private TransportAddress[] boundAddresses;
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@

package org.opensearch.core.transport;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;

@@ -40,8 +41,9 @@
/**
* Response over the transport interface
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public abstract class TransportResponse extends TransportMessage {

/**
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@

import org.opensearch.Version;
import org.opensearch.common.Nullable;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.xcontent.ToXContentFragment;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.semver.expr.Caret;
@@ -31,7 +32,10 @@
* <li>'~' Allows for patch version variability starting from the range version. For example, ~1.2.3 range would match versions greater than or equal to 1.2.3 but less than 1.3.0</li>
* <li>'^' Allows for patch and minor version variability starting from the range version. For example, ^1.2.3 range would match versions greater than or equal to 1.2.3 but less than 2.0.0</li>
* </ul>
*
* @opensearch.api
*/
@PublicApi(since = "2.13.0")
public class SemverRange implements ToXContentFragment {

private final Version rangeVersion;
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
package org.opensearch.action.support.clustermanager;

import org.opensearch.action.ActionRequest;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
@@ -42,8 +43,9 @@
/**
* A based request for cluster-manager based operation.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public abstract class ClusterManagerNodeRequest<Request extends ClusterManagerNodeRequest<Request>> extends ActionRequest {

public static final TimeValue DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT = TimeValue.timeValueSeconds(30);
Original file line number Diff line number Diff line change
@@ -32,11 +32,14 @@

package org.opensearch.common.cache;

import org.opensearch.common.annotation.ExperimentalApi;

/**
* Listener for removing an element from the cache
*
* @opensearch.internal
* @opensearch.experimental
*/
@ExperimentalApi
@FunctionalInterface
public interface RemovalListener<K, V> {
void onRemoval(RemovalNotification<K, V> notification);
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@

package org.opensearch.common.cache.policy;

import org.opensearch.common.annotation.ExperimentalApi;
import org.opensearch.core.common.bytes.BytesReference;
import org.opensearch.core.common.io.stream.NamedWriteableAwareStreamInput;
import org.opensearch.core.common.io.stream.NamedWriteableRegistry;
@@ -62,7 +63,10 @@ public void writeToNoId(StreamOutput out) throws IOException {
/**
* A class containing information needed for all cache policies
* to decide whether to admit a given value.
*
* @opensearch.experimental
*/
@ExperimentalApi
public static class PolicyValues implements Writeable {
final long tookTimeNanos;
// More values can be added here as they're needed for future policies
Original file line number Diff line number Diff line change
@@ -8,10 +8,15 @@

package org.opensearch.common.cache.serializer;

import org.opensearch.common.annotation.ExperimentalApi;

/**
* Defines an interface for serializers, to be used by pluggable caches.
* T is the class of the original object, and U is the serialized class.
*
* @opensearch.experimental
*/
@ExperimentalApi
public interface Serializer<T, U> {
/**
* Serializes an object.
Original file line number Diff line number Diff line change
@@ -84,8 +84,10 @@ public DelegatingCacheHelper getDelegatingCacheHelper() {

/**
* Wraps existing IndexReader cache helper which internally provides a way to wrap CacheKey.
* @opensearch.internal
*
* @opensearch.api
*/
@PublicApi(since = "2.13.0")
public class DelegatingCacheHelper implements CacheHelper {
private final CacheHelper cacheHelper;
private final DelegatingCacheKey serializableCacheKey;
@@ -113,7 +115,10 @@ public void addClosedListener(ClosedListener listener) {
/**
* Wraps internal IndexReader.CacheKey and attaches a uniqueId to it which can be eventually be used instead of
* object itself for serialization purposes.
*
* @opensearch.api
*/
@PublicApi(since = "2.13.0")
public class DelegatingCacheKey {
private final CacheKey cacheKey;
private final String uniqueId;
Original file line number Diff line number Diff line change
@@ -32,13 +32,16 @@

package org.opensearch.common.metrics;

import org.opensearch.common.annotation.PublicApi;

import java.util.concurrent.atomic.LongAdder;

/**
* An average metric for tracking.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class MeanMetric implements Metric {

private final LongAdder counter = new LongAdder();
4 changes: 3 additions & 1 deletion server/src/main/java/org/opensearch/http/HttpInfo.java
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@

package org.opensearch.http;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.common.network.InetAddresses;
import org.opensearch.core.common.io.stream.StreamInput;
@@ -47,8 +48,9 @@
/**
* Information about an http connection
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class HttpInfo implements ReportingService.Info {

private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(HttpInfo.class);
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@

package org.opensearch.http;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.lifecycle.LifecycleComponent;
import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.core.common.transport.BoundTransportAddress;
@@ -42,8 +43,9 @@
/**
* HTTP Transport server
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface HttpServerTransport extends LifecycleComponent, ReportingService<HttpInfo> {

String HTTP_SERVER_WORKER_THREAD_NAME_PREFIX = "http_server_worker";
4 changes: 3 additions & 1 deletion server/src/main/java/org/opensearch/http/HttpStats.java
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@

package org.opensearch.http;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.Writeable;
@@ -43,8 +44,9 @@
/**
* Stats for HTTP connections
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class HttpStats implements Writeable, ToXContentFragment {

private final long serverOpen;
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ class LongArrayBackedBitSet implements Accountable, Closeable {
/**
* Constructor which uses Lucene's IndexInput to read the bitset into a read-only buffer.
* @param in IndexInput containing the serialized bitset.
* @throws IOException
* @throws IOException I/O exception
*/
LongArrayBackedBitSet(IndexInput in) throws IOException {
underlyingArrayLength = in.readLong();
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
package org.opensearch.index.store;

import org.apache.lucene.store.Directory;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.blobstore.BlobPath;
import org.opensearch.core.index.shard.ShardId;
import org.opensearch.index.IndexSettings;
@@ -28,8 +29,9 @@
/**
* Factory for a remote store directory
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "2.3.0")
public class RemoteSegmentStoreDirectoryFactory implements IndexStorePlugin.DirectoryFactory {
private static final String SEGMENTS = "segments";

Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@
import org.opensearch.action.support.clustermanager.ClusterManagerNodeRequest;
import org.opensearch.client.node.NodeClient;
import org.opensearch.common.CheckedConsumer;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.collect.Tuple;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Setting.Property;
@@ -72,6 +73,7 @@
*
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public abstract class BaseRestHandler implements RestHandler {

public static final Setting<Boolean> MULTI_ALLOW_EXPLICIT_INDEX = Setting.boolSetting(
@@ -194,8 +196,11 @@ protected final String unrecognized(
/**
* REST requests are handled by preparing a channel consumer that represents the execution of
* the request against a channel.
*
* @opensearch.api
*/
@FunctionalInterface
@PublicApi(since = "1.0.0")
protected interface RestChannelConsumer extends CheckedConsumer<RestChannel, Exception> {}

/**
2 changes: 2 additions & 0 deletions server/src/main/java/org/opensearch/rest/RestChannel.java
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
package org.opensearch.rest;

import org.opensearch.common.Nullable;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.core.xcontent.MediaType;
import org.opensearch.core.xcontent.XContentBuilder;
@@ -44,6 +45,7 @@
*
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface RestChannel {

XContentBuilder newBuilder() throws IOException;
4 changes: 3 additions & 1 deletion server/src/main/java/org/opensearch/rest/RestHandler.java
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
package org.opensearch.rest;

import org.opensearch.client.node.NodeClient;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.xcontent.XContent;
import org.opensearch.rest.RestRequest.Method;

@@ -180,8 +181,9 @@ public boolean allowSystemIndexAccessByDefault() {
/**
* Route for the request.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
class Route {

protected final String path;
2 changes: 2 additions & 0 deletions server/src/main/java/org/opensearch/rest/RestResponse.java
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
package org.opensearch.rest;

import org.opensearch.OpenSearchException;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.lease.Releasable;
import org.opensearch.core.common.bytes.BytesReference;
import org.opensearch.core.rest.RestStatus;
@@ -49,6 +50,7 @@
*
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public abstract class RestResponse {

private Map<String, List<String>> customHeaders;
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@

import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.Nullable;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;

@@ -49,8 +50,9 @@
* A connection profile describes how many connection are established to specific node for each of the available request types.
* ({@link org.opensearch.transport.TransportRequestOptions.Type}). This allows to tailor a connection towards a specific usage.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public final class ConnectionProfile {

/**
4 changes: 3 additions & 1 deletion server/src/main/java/org/opensearch/transport/Header.java
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
package org.opensearch.transport;

import org.opensearch.Version;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.collect.Tuple;
import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.core.common.io.stream.StreamInput;
@@ -47,8 +48,9 @@
/**
* Transport Header
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class Header {

private static final String RESPONSE_NAME = "NO_ACTION_NAME_FOR_RESPONSES";
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@

package org.opensearch.transport;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.bytes.ReleasableBytesReference;
import org.opensearch.common.lease.Releasable;
import org.opensearch.common.lease.Releasables;
@@ -43,8 +44,9 @@
/**
* Inbound data as a message
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class InboundMessage implements Releasable {

private final Header header;
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@

package org.opensearch.transport;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.lease.Releasable;
import org.opensearch.common.lease.Releasables;
import org.opensearch.common.util.concurrent.ThreadContext;
@@ -47,8 +48,9 @@
/**
* Registry for OpenSearch RequestHandlers
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public final class RequestHandlerRegistry<Request extends TransportRequest> {

private final String action;
Original file line number Diff line number Diff line change
@@ -32,15 +32,17 @@

package org.opensearch.transport;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.metrics.MeanMetric;

import java.util.concurrent.atomic.LongAdder;

/**
* Tracks transport statistics
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public final class StatsTracker {

private final LongAdder bytesRead = new LongAdder();
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@

package org.opensearch.transport;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.network.CloseableChannel;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.core.action.ActionListener;
@@ -45,8 +46,9 @@
* abstraction used by the {@link TcpTransport} and {@link TransportService}. All tcp transport
* implementations must return channels that adhere to the required method contracts.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface TcpChannel extends CloseableChannel {

/**
@@ -114,8 +116,9 @@ default <T> Optional<T> get(String name, Class<T> clazz) {
/**
* Channel statistics
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
class ChannelStats {

private volatile long lastAccessedTime;
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@
import org.opensearch.action.support.ThreadedActionListener;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.Booleans;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.lifecycle.AbstractLifecycleComponent;
import org.opensearch.common.lifecycle.Lifecycle;
import org.opensearch.common.metrics.MeanMetric;
@@ -111,8 +112,9 @@
/**
* The TCP Transport layer
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public abstract class TcpTransport extends AbstractLifecycleComponent implements Transport {
private static final Logger logger = LogManager.getLogger(TcpTransport.class);

@@ -966,7 +968,10 @@ public static Set<ProfileSettings> getProfileSettings(Settings settings) {

/**
* Representation of a transport profile settings for a {@code transport.profiles.$profilename.*}
*
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public static final class ProfileSettings {
public final String profileName;
public final boolean tcpNoDelay;
12 changes: 10 additions & 2 deletions server/src/main/java/org/opensearch/transport/Transport.java
Original file line number Diff line number Diff line change
@@ -58,8 +58,9 @@
/**
* OpenSearch Transport Interface
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface Transport extends LifecycleComponent {

/**
@@ -166,7 +167,10 @@ default Object getCacheKey() {
/**
* This class represents a response context that encapsulates the actual response handler, the action and the connection it was
* executed on.
*
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
final class ResponseContext<T extends TransportResponse> {

private final TransportResponseHandler<T> handler;
@@ -196,7 +200,10 @@ public String action() {

/**
* This class is a registry that allows
*
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
final class ResponseHandlers {
private final ConcurrentMapLong<ResponseContext<? extends TransportResponse>> handlers = ConcurrentCollections
.newConcurrentMapLongWithAggressiveConcurrency();
@@ -276,8 +283,9 @@ public TransportResponseHandler<? extends TransportResponse> onResponseReceived(
/**
* Request handler implementations
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
final class RequestHandlers {

private volatile Map<String, RequestHandlerRegistry<? extends TransportRequest>> requestHandlers = Collections.emptyMap();
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.opensearch.Version;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.transport.TransportResponse;

import java.io.IOException;
@@ -46,6 +47,7 @@
*
* @opensearch.internal
*/
@PublicApi(since = "1.0.0")
public interface TransportChannel {

Logger logger = LogManager.getLogger(TransportChannel.class);
Original file line number Diff line number Diff line change
@@ -32,13 +32,15 @@
package org.opensearch.transport;

import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.transport.TransportResponse;

/**
* Listens for transport messages
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface TransportMessageListener {

TransportMessageListener NOOP_LISTENER = new TransportMessageListener() {
Original file line number Diff line number Diff line change
@@ -32,13 +32,15 @@

package org.opensearch.transport;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.tasks.Task;

/**
* Handles transport requests
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface TransportRequestHandler<T extends TransportRequest> {

void messageReceived(T request, TransportChannel channel, Task task) throws Exception;
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@

package org.opensearch.transport;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.core.transport.TransportResponse;
@@ -42,8 +43,9 @@
/**
* Handles transport responses
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface TransportResponseHandler<T extends TransportResponse> extends Writeable.Reader<T> {

void handleResponse(T response);
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
package org.opensearch.transport;

import org.opensearch.LegacyESVersion;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.Writeable;
@@ -45,8 +46,9 @@
/**
* Stats for transport activity
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class TransportStats implements Writeable, ToXContentFragment {

private final long serverOpen;