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

Fix several minor issues in RFS codebase #1161

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Expand Up @@ -176,7 +176,7 @@ public static class DocParams implements TransformerParams {
public String getTransformerConfigParameterArgPrefix() {
return DOC_CONFIG_PARAMETER_ARG_PREFIX;
}
final static String DOC_CONFIG_PARAMETER_ARG_PREFIX = "doc-";
private static final String DOC_CONFIG_PARAMETER_ARG_PREFIX = "doc-";

@Parameter(
required = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.opensearch.migrations.Flavor;
import org.opensearch.migrations.Version;
import org.opensearch.migrations.VersionMatchers;
import org.opensearch.migrations.bulkload.common.OpenSearchClient.OperationFailed;
import org.opensearch.migrations.bulkload.common.http.ConnectionContext;
import org.opensearch.migrations.bulkload.common.http.HttpResponse;
import org.opensearch.migrations.bulkload.tracing.IRfsContexts;
Expand All @@ -37,7 +36,7 @@ public class OpenSearchClient {

/** Amazon OpenSearch Serverless cluster don't have a version number, but
* its closely aligned with the latest open-source OpenSearch 2.X */
private static Version AMAZON_SERVERLESS_VERSION = Version.builder()
private static final Version AMAZON_SERVERLESS_VERSION = Version.builder()
.flavor(Flavor.AMAZON_SERVERLESS_OPENSEARCH)
.major(2)
.build();
Expand Down Expand Up @@ -89,7 +88,7 @@ public Version getClusterVersion() {
if (resp.statusCode == 404) {
return Mono.just(AMAZON_SERVERLESS_VERSION);
}
return Mono.error(new OperationFailed("Unexpected status code " + resp.statusCode, resp));
return Mono.error(new UnexpectedStatusCode(resp));
})
.doOnError(e -> log.error(e.getMessage()))
.retryWhen(CHECK_IF_ITEM_EXISTS_RETRY_STRATEGY)
Expand All @@ -105,7 +104,7 @@ public Version getClusterVersion() {
.retryWhen(CHECK_IF_ITEM_EXISTS_RETRY_STRATEGY)
.flatMap(hasCompatibilityModeEnabled -> {
log.atInfo().setMessage("Checking CompatibilityMode, was enabled? {}").addArgument(hasCompatibilityModeEnabled).log();
if (!hasCompatibilityModeEnabled) {
if (Boolean.FALSE.equals(hasCompatibilityModeEnabled)) {
return Mono.just(versionFromRootApi);
}
return client.getAsync("_nodes/_all/nodes,version?format=json", null)
Expand Down Expand Up @@ -150,7 +149,7 @@ private Mono<Version> versionFromResponse(HttpResponse resp) {

Mono<Boolean> checkCompatibilityModeFromResponse(HttpResponse resp) {
if (resp.statusCode != 200) {
return Mono.error(new OperationFailed("Unexpected status code " + resp.statusCode, resp));
return Mono.error(new UnexpectedStatusCode(resp));
}
try {
var body = Optional.of(objectMapper.readTree(resp.body));
Expand All @@ -175,7 +174,7 @@ private boolean inCompatibilityMode(Optional<JsonNode> node) {

private Mono<Version> getVersionFromNodes(HttpResponse resp) {
if (resp.statusCode != 200) {
return Mono.error(new OperationFailed("Unexpected status code " + resp.statusCode, resp));
return Mono.error(new UnexpectedStatusCode(resp));
}
var foundVersions = new HashSet<Version>();
try {
Expand All @@ -188,7 +187,7 @@ private Mono<Version> getVersionFromNodes(HttpResponse resp) {
foundVersions.add(nodeVersion);
});

if (foundVersions.size() == 0) {
if (foundVersions.isEmpty()) {
return Mono.error(new OperationFailed("Unable to find any version numbers", resp));
}

Expand Down Expand Up @@ -547,7 +546,7 @@ public String getFailureMessage() {
}
}

public static class OperationFailed extends RfsException {
public static class OperationFailed extends RuntimeException {
public final transient HttpResponse response;

public OperationFailed(String message, HttpResponse response) {
Expand All @@ -556,4 +555,10 @@ public OperationFailed(String message, HttpResponse response) {
this.response = response;
}
}

public static class UnexpectedStatusCode extends OperationFailed {
public UnexpectedStatusCode(HttpResponse response) {
super("Unexpected status code " + response.statusCode, response);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public boolean wasFatal() {

@AllArgsConstructor
@Getter
public static enum CreationFailureType {
public enum CreationFailureType {
ALREADY_EXISTS(false, "already exists"),
UNABLE_TO_TRANSFORM_FAILURE(true, "failed to transform to the target version"),
TARGET_CLUSTER_FAILURE(true, "failed on target cluster");
Expand Down
Loading