Skip to content

Commit

Permalink
[BWC and API enforcement] Decorate the existing APIs with proper anno…
Browse files Browse the repository at this point in the history
…tations (part 2) (#10950)

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
reta authored Nov 9, 2023
1 parent 3eda422 commit 0d54c16
Show file tree
Hide file tree
Showing 497 changed files with 1,757 additions and 579 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@

package org.opensearch.common;

import org.opensearch.common.annotation.PublicApi;

import java.util.function.BiConsumer;

/**
* A {@link BiConsumer}-like interface which allows throwing checked exceptions.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
@FunctionalInterface
public interface CheckedBiConsumer<T, U, E extends Exception> {
void accept(T t, U u) throws E;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@

package org.opensearch.common;

import org.opensearch.common.annotation.PublicApi;

import java.util.function.Function;

/**
* A {@link Function}-like interface which allows throwing checked exceptions.
*
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
@FunctionalInterface
public interface CheckedFunction<T, R, E extends Exception> {
R apply(T t) throws E;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

package org.opensearch.common;

import org.opensearch.common.annotation.PublicApi;

/**
* Represents a function that accepts three arguments and produces a result.
*
Expand All @@ -40,8 +42,9 @@
* @param <U> the type of the third argument
* @param <R> the return type
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
@FunctionalInterface
public interface TriFunction<S, T, U, R> {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@

package org.opensearch.common.collect;

import org.opensearch.common.annotation.PublicApi;

/**
* Java 9 Tuple
* todo: deprecate and remove w/ min jdk upgrade to 11?
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class Tuple<V1, V2> {

public static <V1, V2> Tuple<V1, V2> tuple(V1 v1, V2 v2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
*/
package org.opensearch.common.crypto;

import org.opensearch.common.annotation.ExperimentalApi;

import java.io.Closeable;
import java.util.Map;

/**
* Master key provider responsible for management of master keys.
*
* @opensearch.experimental
*/
@ExperimentalApi
public interface MasterKeyProvider extends Closeable {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@

package org.opensearch.common.io;

import org.opensearch.common.annotation.ExperimentalApi;

import java.io.InputStream;

/**
* Model composed of an input stream and the total content length of the stream
*
* @opensearch.internal
* @opensearch.experimental
*/
@ExperimentalApi
public class InputStreamContainer {

private final InputStream inputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package org.opensearch;

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

Expand All @@ -40,8 +41,9 @@
/**
* Unchecked exception that is translated into a {@code 400 BAD REQUEST} error when it bubbles out over HTTP.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class OpenSearchParseException extends OpenSearchException {

public OpenSearchParseException(String msg, Object... args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@

package org.opensearch.core.action;

import org.opensearch.common.annotation.PublicApi;

import java.util.concurrent.atomic.AtomicBoolean;

/**
* A listener that ensures that only one of onResponse or onFailure is called. And the method
* the is called is only called once. Subclasses should implement notification logic with
* innerOnResponse and innerOnFailure.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public abstract class NotifyOnceListener<Response> implements ActionListener<Response> {

private final AtomicBoolean hasBeenCalled = new AtomicBoolean(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
package org.opensearch.core.common.text;

import org.apache.lucene.util.BytesRef;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.common.bytes.BytesArray;
import org.opensearch.core.common.bytes.BytesReference;
import org.opensearch.core.xcontent.ToXContentFragment;
Expand All @@ -44,8 +45,9 @@
* Both {@link String} and {@link BytesReference} representation of the text. Starts with one of those, and if
* the other is requests, caches the other one in a local reference so no additional conversion will be needed.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public final class Text implements Comparable<Text>, ToXContentFragment {

public static final Text[] EMPTY_ARRAY = new Text[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.core.common.transport;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.network.NetworkAddress;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
Expand All @@ -47,8 +48,9 @@
/**
* A transport address used for IP socket address (wraps {@link java.net.InetSocketAddress}).
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public final class TransportAddress implements Writeable, ToXContentFragment {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

package org.opensearch.core.tasks.resourcetracker;

import org.opensearch.common.annotation.PublicApi;

/**
* Different resource stats are defined.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "2.1.0")
public enum ResourceStats {
CPU("cpu_time_in_nanos"),
MEMORY("memory_in_bytes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

package org.opensearch.core.tasks.resourcetracker;

import org.opensearch.common.annotation.PublicApi;

/**
* Defines the different types of resource stats.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "2.1.0")
public enum ResourceStatsType {
// resource stats of the worker thread reported directly from runnable.
WORKER_STATS("worker_stats", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.common.annotation.PublicApi;

import java.util.Collections;
import java.util.EnumMap;
Expand All @@ -22,8 +23,9 @@
* It captures the resource usage information like memory, CPU about a particular execution of thread
* for a specific stats type.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "2.1.0")
public class ResourceUsageInfo {
private static final Logger logger = LogManager.getLogger(ResourceUsageInfo.class);
private final EnumMap<ResourceStats, ResourceStatsInfo> statsInfo = new EnumMap<>(ResourceStats.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

package org.opensearch.core.tasks.resourcetracker;

import org.opensearch.common.annotation.PublicApi;

/**
* Information about resource usage
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "2.1.0")
public class ResourceUsageMetric {
private final ResourceStats stats;
private final long value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.opensearch.core.tasks.resourcetracker;

import org.opensearch.Version;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.common.Strings;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
Expand All @@ -29,8 +30,9 @@
* Writeable TaskResourceStats objects are used to represent resource
* snapshot information about currently running task.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "2.1.0")
public class TaskResourceStats implements Writeable, ToXContentFragment {
private final Map<String, TaskResourceUsage> resourceUsage;
private final TaskThreadUsage threadUsage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.core.tasks.resourcetracker;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.ParseField;
import org.opensearch.core.common.Strings;
import org.opensearch.core.common.io.stream.StreamInput;
Expand All @@ -30,8 +31,9 @@
* Writeable TaskResourceUsage objects are used to represent resource usage
* information of running tasks.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "2.1.0")
public class TaskResourceUsage implements Writeable, ToXContentFragment {
private static final ParseField CPU_TIME_IN_NANOS = new ParseField("cpu_time_in_nanos");
private static final ParseField MEMORY_IN_BYTES = new ParseField("memory_in_bytes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.core.tasks.resourcetracker;

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.ParseField;
import org.opensearch.core.common.Strings;
import org.opensearch.core.common.io.stream.StreamInput;
Expand All @@ -29,8 +30,9 @@
* Writeable TaskThreadExecutions objects are used to represent thread related resource usage of running tasks.
* asd
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "2.1.0")
public class TaskThreadUsage implements Writeable, ToXContentFragment {

private static final String THREAD_EXECUTIONS = "thread_executions";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@

package org.opensearch.core.tasks.resourcetracker;

import org.opensearch.common.annotation.PublicApi;

/**
* Resource consumption information about a particular execution of thread.
* <p>
* It captures the resource usage information about a particular execution of thread
* for a specific stats type like worker_stats or response_stats etc.,
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "2.1.0")
public class ThreadResourceInfo {
private final long threadId;
private volatile boolean isActive = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
package org.opensearch.core.xcontent;

import org.opensearch.common.CheckedFunction;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.ParseField;
import org.opensearch.core.xcontent.ObjectParser.NamedObjectParser;
import org.opensearch.core.xcontent.ObjectParser.ValueType;
Expand All @@ -47,8 +48,9 @@
/**
* Superclass for {@link ObjectParser} and {@link ConstructingObjectParser}. Defines most of the "declare" methods so they can be shared.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public abstract class AbstractObjectParser<Value, Context> {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@

package org.opensearch.core.xcontent;

import org.opensearch.common.annotation.PublicApi;

import java.io.IOException;

/**
* Reads an object from a parser using some context.
*
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
@FunctionalInterface
public interface ContextParser<Context, T> {
T parse(XContentParser p, Context c) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@

package org.opensearch.core.xcontent;

import org.opensearch.common.annotation.PublicApi;

import java.util.function.Supplier;

/**
* Callback for notifying the creator of the {@link XContentParser} that
* parsing hit a deprecated field.
*
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface DeprecationHandler {
/**
* Throws an {@link UnsupportedOperationException} when parsing hits a
Expand Down
Loading

0 comments on commit 0d54c16

Please sign in to comment.