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

[AMORO-3235] Support action filter by ams backend #3236

Merged
merged 9 commits into from
Oct 14, 2024
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 @@ -278,6 +278,7 @@ private EndpointGroup apiGroup() {
path(
"/optimize",
() -> {
get("/actions", optimizerGroupController::getActions);
get(
"/optimizerGroups/{optimizerGroup}/tables",
optimizerGroupController::getOptimizerTables);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.amoro.server.dashboard.response.OkResponse;
import org.apache.amoro.server.dashboard.response.PageResult;
import org.apache.amoro.server.dashboard.utils.OptimizingUtil;
import org.apache.amoro.server.optimizing.OptimizingStatus;
import org.apache.amoro.server.persistence.TableRuntimeMeta;
import org.apache.amoro.server.resource.ContainerMetadata;
import org.apache.amoro.server.resource.OptimizerInstance;
Expand All @@ -40,10 +41,13 @@
import javax.ws.rs.BadRequestException;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/** The controller that handles optimizer requests. */
Expand All @@ -58,13 +62,22 @@ public OptimizerGroupController(
this.optimizerManager = optimizerManager;
}

public void getActions(Context ctx) {
ctx.json(
OkResponse.of(
Arrays.stream(OptimizingStatus.values())
.map(OptimizingStatus::displayValue)
.collect(Collectors.toList())));
}

/** Get optimize tables. * @return List of {@link TableOptimizingInfo} */
public void getOptimizerTables(Context ctx) {
String optimizerGroup = ctx.pathParam("optimizerGroup");
String dbFilterStr = ctx.queryParam("dbSearchInput");
String tableFilterStr = ctx.queryParam("tableSearchInput");
Integer page = ctx.queryParamAsClass("page", Integer.class).getOrDefault(1);
Integer pageSize = ctx.queryParamAsClass("pageSize", Integer.class).getOrDefault(20);
Set<String> actionFilter = new HashSet<>(ctx.queryParams("actions[]"));
int offset = (page - 1) * pageSize;

String optimizerGroupUsedInDbFilter = ALL_GROUP.equals(optimizerGroup) ? null : optimizerGroup;
Expand All @@ -76,6 +89,10 @@ public void getOptimizerTables(Context ctx) {
List<TableRuntime> tableRuntimes =
tableRuntimeBeans.stream()
.map(meta -> tableService.getRuntime(meta.getTableId()))
.filter(
tableRuntime ->
actionFilter.isEmpty()
|| actionFilter.contains(tableRuntime.getOptimizingStatus().displayValue()))
.collect(Collectors.toList());

PageResult<TableOptimizingInfo> amsPageResult =
Expand Down
Loading