Skip to content

Commit

Permalink
Remove custom flag from status API again
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmitterdorfer committed Oct 5, 2023
1 parent 2896896 commit a37dc3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public static class Response extends ActionResponse implements ToXContentObject
private boolean resourcesCreated;
private boolean pre891Data;
private boolean timedOut;
private boolean validLicense;

public Response(StreamInput in) throws IOException {
super(in);
Expand All @@ -45,21 +44,13 @@ public Response(StreamInput in) throws IOException {
resourcesCreated = in.readBoolean();
pre891Data = in.readBoolean();
timedOut = in.readBoolean();
validLicense = in.readBoolean();
}

public Response(
boolean profilingEnabled,
boolean resourceManagementEnabled,
boolean resourcesCreated,
boolean pre891Data,
boolean validLicense
) {
public Response(boolean profilingEnabled, boolean resourceManagementEnabled, boolean resourcesCreated, boolean pre891Data) {
this.profilingEnabled = profilingEnabled;
this.resourceManagementEnabled = resourceManagementEnabled;
this.resourcesCreated = resourcesCreated;
this.pre891Data = pre891Data;
this.validLicense = validLicense;
}

public void setTimedOut(boolean timedOut) {
Expand All @@ -73,7 +64,7 @@ public boolean isResourcesCreated() {
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.startObject("profiling").field("enabled", profilingEnabled).field("valid_license", validLicense).endObject();
builder.startObject("profiling").field("enabled", profilingEnabled).endObject();
builder.startObject("resource_management").field("enabled", resourceManagementEnabled).endObject();
builder.startObject("resources").field("created", resourcesCreated).field("pre_8_9_1_data", pre891Data).endObject();
builder.endObject();
Expand All @@ -87,7 +78,6 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(resourcesCreated);
out.writeBoolean(pre891Data);
out.writeBoolean(timedOut);
out.writeBoolean(validLicense);
}

@Override
Expand All @@ -99,13 +89,12 @@ public boolean equals(Object o) {
&& resourceManagementEnabled == response.resourceManagementEnabled
&& resourcesCreated == response.resourcesCreated
&& pre891Data == response.pre891Data
&& timedOut == response.timedOut
&& validLicense == response.validLicense;
&& timedOut == response.timedOut;
}

@Override
public int hashCode() {
return Objects.hash(profilingEnabled, resourceManagementEnabled, resourcesCreated, pre891Data, timedOut, validLicense);
return Objects.hash(profilingEnabled, resourceManagementEnabled, resourcesCreated, pre891Data, timedOut);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public TransportGetStatusAction(
ClusterService clusterService,
ThreadPool threadPool,
ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver,
ProfilingLicenseChecker licenseChecker
IndexNameExpressionResolver indexNameExpressionResolver
) {
super(
GetStatusAction.NAME,
Expand All @@ -55,7 +54,7 @@ public TransportGetStatusAction(
GetStatusAction.Response::new,
EsExecutors.DIRECT_EXECUTOR_SERVICE
);
this.resolver = new StatusResolver(clusterService, licenseChecker);
this.resolver = new StatusResolver(clusterService);
}

@Override
Expand Down Expand Up @@ -129,11 +128,9 @@ public void onTimeout(TimeValue timeout) {

private static class StatusResolver {
private final ClusterService clusterService;
private final ProfilingLicenseChecker licenseChecker;

private StatusResolver(ClusterService clusterService, ProfilingLicenseChecker licenseChecker) {
private StatusResolver(ClusterService clusterService) {
this.clusterService = clusterService;
this.licenseChecker = licenseChecker;
}

private GetStatusAction.Response getResponse(ClusterState state) {
Expand All @@ -152,9 +149,8 @@ private GetStatusAction.Response getResponse(ClusterState state) {
boolean indicesPre891 = ProfilingIndexManager.isAnyResourceTooOld(state, indexStateResolver);
boolean dataStreamsPre891 = ProfilingDataStreamManager.isAnyResourceTooOld(state, indexStateResolver);
boolean anyPre891Data = indicesPre891 || dataStreamsPre891;
boolean validLicense = licenseChecker.isSupportedLicense();

return new GetStatusAction.Response(pluginEnabled, resourceManagementEnabled, resourcesCreated, anyPre891Data, validLicense);
return new GetStatusAction.Response(pluginEnabled, resourceManagementEnabled, resourcesCreated, anyPre891Data);
}

private boolean getValue(ClusterState state, Setting<Boolean> setting) {
Expand Down

0 comments on commit a37dc3e

Please sign in to comment.