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 3)

Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Nov 13, 2023
1 parent c676479 commit 9b20bce
Show file tree
Hide file tree
Showing 90 changed files with 347 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.core.action;

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

Expand All @@ -42,6 +43,7 @@
*
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public abstract class ActionResponse extends TransportResponse {

public ActionResponse() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@
package org.opensearch.core.common.util;

import org.apache.lucene.util.BytesRef;
import org.opensearch.common.annotation.PublicApi;

import java.nio.ByteBuffer;

/**
* Abstraction of an array of byte values.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface ByteArray extends BigArray {

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

package org.opensearch.core.indices.breaker;

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;
Expand All @@ -43,8 +44,9 @@
/**
* Stats class encapsulating all of the different circuit breaker stats
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class AllCircuitBreakerStats implements Writeable, ToXContentFragment {

/** An array of all the circuit breaker stats */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,18 @@

package org.opensearch.core.indices.breaker;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.lifecycle.AbstractLifecycleComponent;
import org.opensearch.core.common.breaker.CircuitBreaker;

/**
* Interface for Circuit Breaker services, which provide breakers to classes
* that load field data.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public abstract class CircuitBreakerService extends AbstractLifecycleComponent {
private static final Logger logger = LogManager.getLogger(CircuitBreakerService.class);

protected CircuitBreakerService() {}

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

package org.opensearch.core.indices.breaker;

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;
Expand All @@ -45,8 +46,9 @@
/**
* Class encapsulating stats about the {@link org.opensearch.core.common.breaker.CircuitBreaker}
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class CircuitBreakerStats implements Writeable, ToXContentObject {

/** The name of the circuit breaker */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
package org.opensearch.core.xcontent;

import org.opensearch.common.Nullable;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.ParseField;

import java.io.IOException;
Expand Down Expand Up @@ -83,8 +84,9 @@
* It's highly recommended to use the high level declare methods like {@link #declareString(BiConsumer, ParseField)} instead of
* {@link #declareField} which can be used to implement exceptional parsing operations not covered by the high level methods.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public final class ObjectParser<Value, Context> extends AbstractObjectParser<Value, Context>
implements
BiFunction<XContentParser, Context, Value>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@

package org.opensearch.action;

import org.opensearch.common.annotation.PublicApi;

/**
* Needs to be implemented by all {@link org.opensearch.action.ActionRequest} subclasses that relate to
* one or more indices and one or more aliases. Meant to be used for aliases management requests (e.g. add/remove alias,
* get aliases) that hold aliases and indices in separate fields.
* Allows to retrieve which indices and aliases the action relates to.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface AliasesRequest extends IndicesRequest.Replaceable {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
package org.opensearch.action;

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

Expand All @@ -42,8 +43,9 @@
/**
* Used to keep track of original indices within internal (e.g. shard level) requests
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public final class OriginalIndices implements IndicesRequest {

// constant to use when original indices are not applicable and will not be serialized across the wire
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.opensearch.cluster.SnapshotsInProgress;
import org.opensearch.cluster.SnapshotsInProgress.State;
import org.opensearch.common.Nullable;
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 Down Expand Up @@ -68,8 +69,9 @@
/**
* Status of a snapshot
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class SnapshotStatus implements ToXContentObject, Writeable {

private final Snapshot snapshot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import org.opensearch.cluster.AbstractDiffable;
import org.opensearch.cluster.Diff;
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 @@ -52,8 +53,9 @@
/**
* Class for holding Rollover related information within an index
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class RolloverInfo extends AbstractDiffable<RolloverInfo> implements Writeable, ToXContentFragment {

public static final ParseField CONDITION_FIELD = new ParseField("met_conditions");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@

package org.opensearch.action.search;

import org.opensearch.common.annotation.PublicApi;

import java.util.Arrays;

/**
* Search scroll id that has been parsed
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class ParsedScrollId {

public static final String QUERY_THEN_FETCH_TYPE = "queryThenFetch";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
package org.opensearch.action.search;

import org.opensearch.common.Nullable;
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;
Expand All @@ -43,8 +44,9 @@
/**
* Id for a search context per node.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public final class SearchContextIdForNode implements Writeable {
private final String node;
private final ShardSearchContextId searchContextId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.opensearch.action.OriginalIndices;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.common.Nullable;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.action.ShardOperationFailedException;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
Expand All @@ -56,8 +57,9 @@
/**
* Represents a failure to search on a specific shard.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class ShardSearchFailure extends ShardOperationFailedException {

private static final String REASON_FIELD = "reason";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.cluster.routing.IndexRoutingTable;
import org.opensearch.cluster.routing.IndexShardRoutingTable;
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;
Expand All @@ -48,8 +49,9 @@
* A class whose instances represent a value for counting the number
* of active shard copies for a given shard in an index.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public final class ActiveShardCount implements Writeable {

private static final int ACTIVE_SHARD_COUNT_DEFAULT = -2;
Expand Down
10 changes: 7 additions & 3 deletions server/src/main/java/org/opensearch/cluster/ClusterState.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.opensearch.cluster.routing.ShardRouting;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.UUIDs;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.common.Strings;
Expand Down Expand Up @@ -97,8 +98,9 @@
* throws the {@link IncompatibleClusterStateVersionException}, which causes the publishing mechanism to send
* a full version of the cluster state to the node on which this exception was thrown.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class ClusterState implements ToXContentFragment, Diffable<ClusterState> {

public static final ClusterState EMPTY_STATE = builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).build();
Expand Down Expand Up @@ -139,8 +141,9 @@ static <T extends VersionedNamedWriteable & FeatureAware> boolean shouldSerializ
/**
* Custom cluster state.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface Custom extends NamedDiffable<Custom>, ToXContentFragment, FeatureAware {

/**
Expand Down Expand Up @@ -596,8 +599,9 @@ public static Builder builder(ClusterState state) {
/**
* Builder for cluster state.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public static class Builder {

private final ClusterName clusterName;
Expand Down
4 changes: 3 additions & 1 deletion server/src/main/java/org/opensearch/cluster/NamedDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@
package org.opensearch.cluster;

import org.opensearch.Version;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.common.io.stream.NamedWriteable;

/**
* Diff that also support NamedWriteable interface
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public interface NamedDiff<T extends Diffable<T>> extends Diff<T>, NamedWriteable {
/**
* The minimal version of the recipient this custom object can be sent to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.opensearch.Version;
import org.opensearch.cluster.ClusterState.Custom;
import org.opensearch.common.Nullable;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.core.common.Strings;
import org.opensearch.core.common.io.stream.StreamInput;
Expand Down Expand Up @@ -928,8 +929,9 @@ public String toString() {
/**
* State of the snapshots.
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public enum State {
INIT((byte) 0, false),
STARTED((byte) 1, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@

package org.opensearch.cluster.ack;

import org.opensearch.common.annotation.PublicApi;

/**
* Base response returned after a cluster state update
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class ClusterStateUpdateResponse {

private final boolean acknowledged;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
package org.opensearch.cluster.block;

import org.opensearch.OpenSearchException;
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.rest.RestStatus;
Expand All @@ -49,8 +50,9 @@
/**
* Internal exception on obtaining a cluster block
*
* @opensearch.internal
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class ClusterBlockException extends OpenSearchException {
private final Set<ClusterBlock> blocks;

Expand Down
Loading

0 comments on commit 9b20bce

Please sign in to comment.