public void cancelOptimizingProcess(Context ctx) {
    String catalog = ctx.pathParam("catalog");
    String db = ctx.pathParam("db");
    String table = ctx.pathParam("table");
    String processIds = ctx.pathParam("processId");
    Preconditions.checkArgument(
        StringUtils.isNotBlank(catalog)
            && StringUtils.isNotBlank(db)
            && StringUtils.isNotBlank(table),
        "catalog.database.tableName can not be empty in any element");
    Preconditions.checkState(catalogManager.catalogExist(catalog), "invalid catalog!");
    long processId = Long.parseLong(processIds);
    ServerTableIdentifier serverTableIdentifier =
        tableManager.getServerTableIdentifier(
            TableIdentifier.of(catalog, db, table).buildTableIdentifier());
    TableRuntimeMeta meta = tableManager.getTableRuntimeMata(serverTableIdentifier);
    if (meta == null || meta.getOptimizingProcessId() != processId) {
      throw new IllegalArgumentException(
          String.format("Can't cancel optimizing process %s", processId));
    }

    OptimizingService.Iface client =
        OptimizingClientPools.getClient(
            AmsUtil.getAMSThriftAddress(serviceConfig, Constants.THRIFT_OPTIMIZING_SERVICE_NAME));
    try {
      client.cancelProcess(processId);
    } catch (TException e) {
      throw new IllegalStateException("Failed to cancel optimizing process:" + e.getMessage());
    }
    ctx.json(OkResponse.ok());
  }
cancel the running optimizing process of one certain table.

@param ctx - context for handling the request and response
amoro-ams/src/main/java/org/apache/amoro/server/dashboard/controller/TableController.java