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

Ensure that supported params are computed once #113953

Merged
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 @@ -29,6 +29,23 @@
@ServerlessScope(Scope.PUBLIC)
public class RestGetDataStreamsAction extends BaseRestHandler {

private static final Set<String> SUPPORTED_QUERY_PARAMETERS = Set.copyOf(
Sets.union(
RestRequest.INTERNAL_MARKER_REQUEST_PARAMETERS,
Set.of(
"name",
"include_defaults",
"timeout",
"master_timeout",
IndicesOptions.WildcardOptions.EXPAND_WILDCARDS,
IndicesOptions.ConcreteTargetOptions.IGNORE_UNAVAILABLE,
IndicesOptions.WildcardOptions.ALLOW_NO_INDICES,
IndicesOptions.GatekeeperOptions.IGNORE_THROTTLED,
"verbose"
)
)
);

@Override
public String getName() {
return "get_data_streams_action";
Expand Down Expand Up @@ -63,19 +80,6 @@ public Set<String> supportedCapabilities() {

@Override
public Set<String> supportedQueryParameters() {
return Sets.union(
RestRequest.INTERNAL_MARKER_REQUEST_PARAMETERS,
Set.of(
"name",
"include_defaults",
"timeout",
"master_timeout",
IndicesOptions.WildcardOptions.EXPAND_WILDCARDS,
IndicesOptions.ConcreteTargetOptions.IGNORE_UNAVAILABLE,
IndicesOptions.WildcardOptions.ALLOW_NO_INDICES,
IndicesOptions.GatekeeperOptions.IGNORE_THROTTLED,
"verbose"
)
);
return SUPPORTED_QUERY_PARAMETERS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public final long getUsageCount() {
public final void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception {
// check if the query has any parameters that are not in the supported set (if declared)
Set<String> supported = allSupportedParameters();
assert supported == allSupportedParameters() : getName() + ": did not return same instance from allSupportedParameters()";
if (supported != null) {
var allSupported = Sets.union(
RestResponse.RESPONSE_PARAMS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ public boolean checkSupported(

if (handler != null) {
var supportedParams = handler.supportedQueryParameters();
assert supportedParams == handler.supportedQueryParameters()
: handler.getName() + ": did not return same instance from supportedQueryParameters()";
return (supportedParams == null || supportedParams.containsAll(parameters))
&& handler.supportedCapabilities().containsAll(capabilities);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ public class RestClusterStatsAction extends BaseRestHandler {
"human-readable-total-docs-size",
"verbose-dense-vector-mapping-stats"
);
private static final Set<String> SUPPORTED_CAPABILITIES_CCS_STATS = Sets.union(SUPPORTED_CAPABILITIES, Set.of("ccs-stats"));
private static final Set<String> SUPPORTED_CAPABILITIES_CCS_STATS = Set.copyOf(Sets.union(SUPPORTED_CAPABILITIES, Set.of("ccs-stats")));
public static final FeatureFlag CCS_TELEMETRY_FEATURE_FLAG = new FeatureFlag("ccs_telemetry");
private static final Set<String> SUPPORTED_QUERY_PARAMETERS = Set.of("include_remotes", "nodeId", REST_TIMEOUT_PARAM);

@Override
public List<Route> routes() {
Expand All @@ -50,7 +51,7 @@ public String getName() {

@Override
public Set<String> supportedQueryParameters() {
return Set.of("include_remotes", "nodeId", REST_TIMEOUT_PARAM);
return SUPPORTED_QUERY_PARAMETERS;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public class RestNodesCapabilitiesAction extends BaseRestHandler {

public static final NodeFeature CAPABILITIES_ACTION = new NodeFeature("rest.capabilities_action");
public static final NodeFeature LOCAL_ONLY_CAPABILITIES = new NodeFeature("rest.local_only_capabilities");
private static final Set<String> SUPPORTED_QUERY_PARAMETERS = Set.of(
"timeout",
"method",
"path",
"parameters",
"capabilities",
"local_only"
);

@Override
public List<Route> routes() {
Expand All @@ -40,7 +48,7 @@ public List<Route> routes() {

@Override
public Set<String> supportedQueryParameters() {
return Set.of("timeout", "method", "path", "parameters", "capabilities", "local_only");
return SUPPORTED_QUERY_PARAMETERS;
}

@Override
Expand Down