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

Use correct terms in GET feature migration status API #79017

Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -11,8 +11,8 @@
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.client.migration.DeprecationInfoRequest;
import org.elasticsearch.client.migration.DeprecationInfoResponse;
import org.elasticsearch.client.migration.GetFeatureUpgradeStatusRequest;
import org.elasticsearch.client.migration.GetFeatureUpgradeStatusResponse;
import org.elasticsearch.client.migration.GetFeatureMigrationStatusRequest;
import org.elasticsearch.client.migration.GetFeatureMigrationStatusResponse;
import org.elasticsearch.client.migration.PostFeatureUpgradeRequest;
import org.elasticsearch.client.migration.PostFeatureUpgradeResponse;

Expand Down Expand Up @@ -60,37 +60,37 @@ public Cancellable getDeprecationInfoAsync(DeprecationInfoRequest request, Reque
}

/**
* Get a list of system features that need to be upgraded for the next release
* Get a list of system features that need to be migrated for the next release
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public GetFeatureUpgradeStatusResponse getFeatureUpgradeStatus(
GetFeatureUpgradeStatusRequest request, RequestOptions options) throws IOException {
public GetFeatureMigrationStatusResponse getFeatureMigrationStatus(
GetFeatureMigrationStatusRequest request, RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(
request,
MigrationRequestConverters::getFeatureUpgradeStatus,
MigrationRequestConverters::getFeatureMigrationStatus,
options,
GetFeatureUpgradeStatusResponse::parse,
GetFeatureMigrationStatusResponse::parse,
Collections.emptySet()
);
}

/**
* Asynchronously get a list of system features that need to be upgraded for the next release
* Asynchronously get a list of system features that need to be migrated for the next release
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public Cancellable getFeatureUpgradeStatusAsync(GetFeatureUpgradeStatusRequest request,
RequestOptions options, ActionListener<GetFeatureUpgradeStatusResponse> listener) {
public Cancellable getFeatureMigrationStatusAsync(GetFeatureMigrationStatusRequest request,
RequestOptions options, ActionListener<GetFeatureMigrationStatusResponse> listener) {
return restHighLevelClient.performRequestAsyncAndParseEntity(
request,
MigrationRequestConverters::getFeatureUpgradeStatus,
MigrationRequestConverters::getFeatureMigrationStatus,
options,
GetFeatureUpgradeStatusResponse::parse,
GetFeatureMigrationStatusResponse::parse,
listener,
Collections.emptySet()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.elasticsearch.client.migration.DeprecationInfoRequest;
import org.elasticsearch.client.migration.GetFeatureUpgradeStatusRequest;
import org.elasticsearch.client.migration.GetFeatureMigrationStatusRequest;
import org.elasticsearch.client.migration.PostFeatureUpgradeRequest;

final class MigrationRequestConverters {
Expand All @@ -29,11 +29,11 @@ static Request getDeprecationInfo(DeprecationInfoRequest deprecationInfoRequest)
}

/**
* Convert a {@link GetFeatureUpgradeStatusRequest} to a {@link Request}
* @param getFeatureUpgradeStatusRequest a request for feature upgrade status
* Convert a {@link GetFeatureMigrationStatusRequest} to a {@link Request}
* @param getFeatureMigrationStatusRequest a request for feature migration status
* @return a {@link Request} with the correct path and HTTP request type
*/
static Request getFeatureUpgradeStatus(GetFeatureUpgradeStatusRequest getFeatureUpgradeStatusRequest) {
static Request getFeatureMigrationStatus(GetFeatureMigrationStatusRequest getFeatureMigrationStatusRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_migration", "system_features")
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import org.elasticsearch.client.TimedRequest;

/**
* A request for information about which system features need to be upgraded.
* A request for information about which system features need to be migrated.
*/
public class GetFeatureUpgradeStatusRequest extends TimedRequest {
public class GetFeatureMigrationStatusRequest extends TimedRequest {

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,69 +19,69 @@
import java.util.Objects;

/**
* Information about which system features need to be upgraded before the next
* Information about which system features need to be migrated before the next
* major version.
*/
public class GetFeatureUpgradeStatusResponse {
public class GetFeatureMigrationStatusResponse {

private static final ParseField FEATURE_UPGRADE_STATUSES = new ParseField("features");
private static final ParseField UPGRADE_STATUS = new ParseField("upgrade_status");
private static final ParseField FEATURE_MIGRATION_STATUSES = new ParseField("features");
private static final ParseField MIGRATION_STATUS = new ParseField("migration_status");

private final List<FeatureUpgradeStatus> featureUpgradeStatuses;
private final String upgradeStatus;
private final List<FeatureMigrationStatus> featureMigrationStatuses;
private final String migrationStatus;

@SuppressWarnings("unchecked")
private static final ConstructingObjectParser<GetFeatureUpgradeStatusResponse, Void> PARSER = new ConstructingObjectParser<>(
"get_feature_upgrade_response", true, (a, ctx) -> new GetFeatureUpgradeStatusResponse(
(List<FeatureUpgradeStatus>) a[0], (String) a[1])
private static final ConstructingObjectParser<GetFeatureMigrationStatusResponse, Void> PARSER = new ConstructingObjectParser<>(
"get_feature_migration_response", true, (a, ctx) -> new GetFeatureMigrationStatusResponse(
(List<FeatureMigrationStatus>) a[0], (String) a[1])
);

static {
PARSER.declareObjectArray(ConstructingObjectParser.optionalConstructorArg(),
FeatureUpgradeStatus::parse, FEATURE_UPGRADE_STATUSES);
FeatureMigrationStatus::parse, FEATURE_MIGRATION_STATUSES);
PARSER.declareField(ConstructingObjectParser.constructorArg(),
(p, c) -> p.text(), UPGRADE_STATUS, ObjectParser.ValueType.STRING);
(p, c) -> p.text(), MIGRATION_STATUS, ObjectParser.ValueType.STRING);
}

/**
* Constructor for the response object
* @param featureUpgradeStatuses A list of feature, their upgrade statuses, and other relevant information for upgrading
* @param upgradeStatus Does this feature need to be upgraded or not?
* @param featureMigrationStatuses A list of feature, their migration statuses, and other relevant information for upgrading
* @param migrationStatus Does this feature need to be migrated or not?
*/
public GetFeatureUpgradeStatusResponse(List<FeatureUpgradeStatus> featureUpgradeStatuses, String upgradeStatus) {
this.featureUpgradeStatuses = Objects.nonNull(featureUpgradeStatuses) ? featureUpgradeStatuses : Collections.emptyList();
this.upgradeStatus = upgradeStatus;
public GetFeatureMigrationStatusResponse(List<FeatureMigrationStatus> featureMigrationStatuses, String migrationStatus) {
this.featureMigrationStatuses = Objects.nonNull(featureMigrationStatuses) ? featureMigrationStatuses : Collections.emptyList();
this.migrationStatus = migrationStatus;
}

public static GetFeatureUpgradeStatusResponse parse(XContentParser parser) throws IOException {
public static GetFeatureMigrationStatusResponse parse(XContentParser parser) throws IOException {
return PARSER.apply(parser, null);
}

public List<FeatureUpgradeStatus> getFeatureUpgradeStatuses() {
return featureUpgradeStatuses;
public List<FeatureMigrationStatus> getFeatureMigrationStatuses() {
return featureMigrationStatuses;
}

public String getUpgradeStatus() {
return upgradeStatus;
public String getMigrationStatus() {
return migrationStatus;
}

/**
* This class represents a particular feature and whether it needs to be upgraded.
* This class represents a particular feature and whether it needs to be migrated.
*/
public static class FeatureUpgradeStatus {
public static class FeatureMigrationStatus {
private final String featureName;
private final String minimumIndexVersion;
private final String upgradeStatus;
private final String migrationStatus;
private final List<IndexVersion> indexVersions;

private static final ParseField FEATURE_NAME = new ParseField("feature_name");
private static final ParseField MINIMUM_INDEX_VERSION = new ParseField("minimum_index_version");
private static final ParseField UPGRADE_STATUS = new ParseField("upgrade_status");
private static final ParseField MIGRATION_STATUS = new ParseField("migration_status");
private static final ParseField INDEX_VERSIONS = new ParseField("indices");

@SuppressWarnings("unchecked")
private static final ConstructingObjectParser<FeatureUpgradeStatus, Void> PARSER = new ConstructingObjectParser<>(
"feature_upgrade_status", true, (a, ctx) -> new FeatureUpgradeStatus(
private static final ConstructingObjectParser<FeatureMigrationStatus, Void> PARSER = new ConstructingObjectParser<>(
"feature_migration_status", true, (a, ctx) -> new FeatureMigrationStatus(
(String) a[0], (String) a[1], (String) a[2], (List<IndexVersion>) a[3]));

static {
Expand All @@ -90,30 +90,30 @@ public static class FeatureUpgradeStatus {
PARSER.declareField(ConstructingObjectParser.constructorArg(),
(p, c) -> p.text(), MINIMUM_INDEX_VERSION, ObjectParser.ValueType.STRING);
PARSER.declareField(ConstructingObjectParser.constructorArg(),
(p, c) -> p.text(), UPGRADE_STATUS, ObjectParser.ValueType.STRING);
(p, c) -> p.text(), MIGRATION_STATUS, ObjectParser.ValueType.STRING);
PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), IndexVersion::parse, INDEX_VERSIONS);
}

/**
* A feature upgrade status object
* A feature migration status object
* @param featureName Name of the feature
* @param minimumIndexVersion The earliest version of Elasticsearch used to create one of this feature's system indices
* @param upgradeStatus Whether this feature needs to be upgraded
* @param migrationStatus Whether this feature needs to be migrated
* @param indexVersions A list of individual indices and which version of Elasticsearch created them
*/
public FeatureUpgradeStatus(
public FeatureMigrationStatus(
String featureName,
String minimumIndexVersion,
String upgradeStatus,
String migrationStatus,
List<IndexVersion> indexVersions
) {
this.featureName = featureName;
this.minimumIndexVersion = minimumIndexVersion;
this.upgradeStatus = upgradeStatus;
this.migrationStatus = migrationStatus;
this.indexVersions = indexVersions;
}

public static FeatureUpgradeStatus parse(XContentParser parser, Void ctx) {
public static FeatureMigrationStatus parse(XContentParser parser, Void ctx) {
return PARSER.apply(parser, null);
}

Expand All @@ -125,8 +125,8 @@ public String getMinimumIndexVersion() {
return minimumIndexVersion;
}

public String getUpgradeStatus() {
return upgradeStatus;
public String getMigrationStatus() {
return migrationStatus;
}

public List<IndexVersion> getIndexVersions() {
Expand All @@ -137,16 +137,16 @@ public List<IndexVersion> getIndexVersions() {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FeatureUpgradeStatus that = (FeatureUpgradeStatus) o;
FeatureMigrationStatus that = (FeatureMigrationStatus) o;
return Objects.equals(featureName, that.featureName)
&& Objects.equals(minimumIndexVersion, that.minimumIndexVersion)
&& Objects.equals(upgradeStatus, that.upgradeStatus)
&& Objects.equals(migrationStatus, that.migrationStatus)
&& Objects.equals(indexVersions, that.indexVersions);
}

@Override
public int hashCode() {
return Objects.hash(featureName, minimumIndexVersion, upgradeStatus, indexVersions);
return Objects.hash(featureName, minimumIndexVersion, migrationStatus, indexVersions);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import org.elasticsearch.Version;
import org.elasticsearch.client.migration.DeprecationInfoRequest;
import org.elasticsearch.client.migration.DeprecationInfoResponse;
import org.elasticsearch.client.migration.GetFeatureUpgradeStatusRequest;
import org.elasticsearch.client.migration.GetFeatureUpgradeStatusResponse;
import org.elasticsearch.client.migration.GetFeatureMigrationStatusRequest;
import org.elasticsearch.client.migration.GetFeatureMigrationStatusResponse;
import org.elasticsearch.client.migration.PostFeatureUpgradeRequest;
import org.elasticsearch.client.migration.PostFeatureUpgradeResponse;
import org.elasticsearch.common.settings.Settings;
Expand All @@ -39,20 +39,22 @@ public void testGetDeprecationInfo() throws IOException {
assertThat(response.getMlSettingsIssues().size(), equalTo(0));
}

public void testGetFeatureUpgradeStatus() throws IOException {
GetFeatureUpgradeStatusRequest request = new GetFeatureUpgradeStatusRequest();
GetFeatureUpgradeStatusResponse response = highLevelClient().migration().getFeatureUpgradeStatus(request, RequestOptions.DEFAULT);
assertThat(response.getUpgradeStatus(), equalTo("NO_UPGRADE_NEEDED"));
assertThat(response.getFeatureUpgradeStatuses().size(), greaterThanOrEqualTo(1));
Optional<GetFeatureUpgradeStatusResponse.FeatureUpgradeStatus> optionalTasksStatus = response.getFeatureUpgradeStatuses().stream()
public void testGetFeatureMigrationStatus() throws IOException {
GetFeatureMigrationStatusRequest request = new GetFeatureMigrationStatusRequest();
GetFeatureMigrationStatusResponse response = highLevelClient().migration()
.getFeatureMigrationStatus(request, RequestOptions.DEFAULT);
assertThat(response.getMigrationStatus(), equalTo("NO_MIGRATION_NEEDED"));
assertThat(response.getFeatureMigrationStatuses().size(), greaterThanOrEqualTo(1));
Optional<GetFeatureMigrationStatusResponse.FeatureMigrationStatus> optionalTasksStatus = response.getFeatureMigrationStatuses()
.stream()
.filter(status -> "tasks".equals(status.getFeatureName()))
.findFirst();

assertThat(optionalTasksStatus.isPresent(), is(true));

GetFeatureUpgradeStatusResponse.FeatureUpgradeStatus tasksStatus = optionalTasksStatus.get();
GetFeatureMigrationStatusResponse.FeatureMigrationStatus tasksStatus = optionalTasksStatus.get();

assertThat(tasksStatus.getUpgradeStatus(), equalTo("NO_UPGRADE_NEEDED"));
assertThat(tasksStatus.getMigrationStatus(), equalTo("NO_MIGRATION_NEEDED"));
assertThat(tasksStatus.getMinimumIndexVersion(), equalTo(Version.CURRENT.toString()));
assertThat(tasksStatus.getFeatureName(), equalTo("tasks"));
}
Expand Down
Loading