From e1aee5fd071257f969c694f36f9a413e29964903 Mon Sep 17 00:00:00 2001 From: "Xiaotian (Jackie) Jiang" <17555551+Jackie-Jiang@users.noreply.github.com> Date: Wed, 13 Mar 2024 09:35:11 -0700 Subject: [PATCH] Remove rest APIs that was deprecated more than 4 years ago (#12639) --- .../PinotSegmentRestletResource.java | 200 ------------------ .../resources/PinotTableIndexingConfigs.java | 98 --------- .../resources/PinotTableMetadataConfigs.java | 95 --------- .../resources/PinotTableRestletResource.java | 40 ---- .../resources/PinotTableSegmentConfigs.java | 100 --------- .../resources/PinotTaskRestletResource.java | 126 ----------- .../resources/PinotUpsertRestletResource.java | 1 + .../api/resources/TableAndSchemaConfig.java | 3 + .../helix/core/PinotHelixResourceManager.java | 44 ---- .../api/PinotTableRestletResourceTest.java | 48 ----- .../builder/ControllerRequestURLBuilder.java | 2 +- 11 files changed, 5 insertions(+), 752 deletions(-) delete mode 100644 pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableIndexingConfigs.java delete mode 100644 pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableMetadataConfigs.java delete mode 100644 pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableSegmentConfigs.java diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java index c3a7134b6746..03897f2456c3 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java @@ -54,7 +54,6 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; -import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; @@ -277,56 +276,6 @@ public Response listSegmentLineage( } } - @Deprecated - @GET - @Path("tables/{tableName}/segments") - @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.GET_SERVER_MAP) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Get a map from server to segments hosted by the server (deprecated, use 'GET " - + "/segments/{tableName}/servers' instead)", - notes = "Get a map from server to segments hosted by the server (deprecated, use 'GET " - + "/segments/{tableName}/servers' instead)") - public List> getServerToSegmentsMapDeprecated1( - @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, - @ApiParam(value = "MUST be null") @QueryParam("state") String stateStr, - @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr) - throws JsonProcessingException { - if (stateStr != null) { - throw new WebApplicationException("Cannot toggle segment state", Status.FORBIDDEN); - } - - List tableNamesWithType = ResourceUtils - .getExistingTableNamesWithType(_pinotHelixResourceManager, tableName, Constants.validateTableType(tableTypeStr), - LOGGER); - List> resultList = new ArrayList<>(tableNamesWithType.size()); - for (String tableNameWithType : tableNamesWithType) { - // NOTE: DO NOT change the format for backward-compatibility - Map resultForTable = new LinkedHashMap<>(); - resultForTable.put("tableName", tableNameWithType); - resultForTable.put("segments", - JsonUtils.objectToString(_pinotHelixResourceManager.getServerToSegmentsMap(tableNameWithType))); - resultList.add(resultForTable); - } - return resultList; - } - - @Deprecated - @GET - @Path("tables/{tableName}/segments/metadata") - @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.GET_SERVER_MAP) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Get a map from server to segments hosted by the server (deprecated, use 'GET " - + "/segments/{tableName}/servers' instead)", - notes = "Get a map from server to segments hosted by the server (deprecated, use 'GET " - + "/segments/{tableName}/servers' instead)") - public List> getServerToSegmentsMapDeprecated2( - @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, - @ApiParam(value = "MUST be null") @QueryParam("state") String stateStr, - @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr) - throws JsonProcessingException { - return getServerToSegmentsMapDeprecated1(tableName, stateStr, tableTypeStr); - } - @GET @Path("segments/{tableName}/crc") @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.GET_SEGMENT_MAP) @@ -343,20 +292,6 @@ public Map getSegmentToCrcMap( return _pinotHelixResourceManager.getSegmentsCrcForTable(offlineTableName); } - @Deprecated - @GET - @Path("tables/{tableName}/segments/crc") - @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.GET_SEGMENT_MAP) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - value = "Get a map from segment to CRC of the segment (deprecated, use 'GET /segments/{tableName}/crc' instead)", - notes = "Get a map from segment to CRC of the segment (deprecated, use 'GET /segments/{tableName}/crc' instead)") - public Map getSegmentToCrcMapDeprecated( - @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, - @Context HttpHeaders headers) { - return getSegmentToCrcMap(tableName, headers); - } - @GET @Path("segments/{tableName}/{segmentName}/metadata") @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.GET_METADATA) @@ -420,68 +355,6 @@ private Map getSegmentMetadataInternal(String tableNameWithType, return segmentZKMetadata != null ? segmentZKMetadata.toMap() : null; } - @Deprecated - @GET - @Path("tables/{tableName}/segments/{segmentName}/metadata") - @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.GET_METADATA) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - value = "Get the metadata for a segment (deprecated, use 'GET /segments/{tableName}/{segmentName}/metadata' " - + "instead)", - notes = "Get the metadata for a segment (deprecated, use 'GET /segments/{tableName}/{segmentName}/metadata' " - + "instead)") - public List>> getSegmentMetadataDeprecated1( - @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, - @ApiParam(value = "Name of the segment", required = true) @PathParam("segmentName") @Encoded String segmentName, - @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr, @Context HttpHeaders headers) { - segmentName = URIUtils.decode(segmentName); - TableType tableType = Constants.validateTableType(tableTypeStr); - List tableNamesWithType = - ResourceUtils.getExistingTableNamesWithType(_pinotHelixResourceManager, tableName, tableType, LOGGER); - List>> resultList = new ArrayList<>(tableNamesWithType.size()); - for (String tableNameWithType : tableNamesWithType) { - Map segmentMetadata = - getSegmentMetadata(tableNameWithType, segmentName, Collections.emptyList(), headers); - if (segmentMetadata != null) { - // NOTE: DO NOT change the format for backward-compatibility - Map resultForTable = new LinkedHashMap<>(); - resultForTable.put("tableName", tableNameWithType); - resultForTable.put("state", segmentMetadata); - resultList.add(Collections.singletonList(resultForTable)); - } - } - if (resultList.isEmpty()) { - String errorMessage = "Failed to find segment: " + segmentName + " in table: " + tableName; - if (tableType != null) { - errorMessage += " of type: " + tableType; - } - throw new ControllerApplicationException(LOGGER, errorMessage, Status.NOT_FOUND); - } - return resultList; - } - - @Deprecated - @GET - @Path("tables/{tableName}/segments/{segmentName}") - @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.GET_METADATA) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - value = "Get the metadata for a segment (deprecated, use 'GET /segments/{tableName}/{segmentName}/metadata' " - + "instead)", - notes = "Get the metadata for a segment (deprecated, use 'GET /segments/{tableName}/{segmentName}/metadata' " - + "instead)") - public List>> getSegmentMetadataDeprecated2( - @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, - @ApiParam(value = "Name of the segment", required = true) @PathParam("segmentName") @Encoded String segmentName, - @ApiParam(value = "MUST be null") @QueryParam("state") String stateStr, - @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr, @Context HttpHeaders headers) { - if (stateStr != null) { - throw new WebApplicationException("Cannot toggle segment state", Status.FORBIDDEN); - } - - return getSegmentMetadataDeprecated1(tableName, segmentName, tableTypeStr, headers); - } - @POST @Path("segments/{tableName}/{segmentName}/reload") @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.RELOAD_SEGMENT) @@ -615,44 +488,6 @@ public SuccessResponse resetSegments( } } - @Deprecated - @POST - @Path("tables/{tableName}/segments/{segmentName}/reload") - @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.RELOAD_SEGMENT) - @Authenticate(AccessType.UPDATE) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Reload a segment (deprecated, use 'POST /segments/{tableName}/{segmentName}/reload' instead)", - notes = "Reload a segment (deprecated, use 'POST /segments/{tableName}/{segmentName}/reload' instead)") - public SuccessResponse reloadSegmentDeprecated1( - @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, - @ApiParam(value = "Name of the segment", required = true) @PathParam("segmentName") @Encoded String segmentName, - @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr) { - segmentName = URIUtils.decode(segmentName); - List tableNamesWithType = ResourceUtils - .getExistingTableNamesWithType(_pinotHelixResourceManager, tableName, Constants.validateTableType(tableTypeStr), - LOGGER); - int numMessagesSent = 0; - for (String tableNameWithType : tableNamesWithType) { - numMessagesSent += _pinotHelixResourceManager.reloadSegment(tableNameWithType, segmentName, false).getLeft(); - } - return new SuccessResponse("Sent " + numMessagesSent + " reload messages"); - } - - @Deprecated - @GET - @Path("tables/{tableName}/segments/{segmentName}/reload") - @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.RELOAD_SEGMENT) - @Authenticate(AccessType.UPDATE) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Reload a segment (deprecated, use 'POST /segments/{tableName}/{segmentName}/reload' instead)", - notes = "Reload a segment (deprecated, use 'POST /segments/{tableName}/{segmentName}/reload' instead)") - public SuccessResponse reloadSegmentDeprecated2( - @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, - @ApiParam(value = "Name of the segment", required = true) @PathParam("segmentName") @Encoded String segmentName, - @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr) { - return reloadSegmentDeprecated1(tableName, segmentName, tableTypeStr); - } - @GET @Path("segments/segmentReloadStatus/{jobId}") @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_SEGMENT_RELOAD_STATUS) @@ -806,41 +641,6 @@ public SuccessResponse reloadAllSegments( return new SuccessResponse(JsonUtils.objectToString(perTableMsgData)); } - @Deprecated - @POST - @Path("tables/{tableName}/segments/reload") - @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.RELOAD_SEGMENT) - @Authenticate(AccessType.UPDATE) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Reload all segments (deprecated, use 'POST /segments/{tableName}/reload' instead)", - notes = "Reload all segments (deprecated, use 'POST /segments/{tableName}/reload' instead)") - public SuccessResponse reloadAllSegmentsDeprecated1( - @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, - @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr) { - List tableNamesWithType = ResourceUtils - .getExistingTableNamesWithType(_pinotHelixResourceManager, tableName, Constants.validateTableType(tableTypeStr), - LOGGER); - int numMessagesSent = 0; - for (String tableNameWithType : tableNamesWithType) { - numMessagesSent += _pinotHelixResourceManager.reloadAllSegments(tableNameWithType, false).getLeft(); - } - return new SuccessResponse("Sent " + numMessagesSent + " reload messages"); - } - - @Deprecated - @GET - @Path("tables/{tableName}/segments/reload") - @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.RELOAD_SEGMENT) - @Authenticate(AccessType.UPDATE) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Reload all segments (deprecated, use 'POST /segments/{tableName}/reload' instead)", - notes = "Reload all segments (deprecated, use 'POST /segments/{tableName}/reload' instead)") - public SuccessResponse reloadAllSegmentsDeprecated2( - @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, - @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr) { - return reloadAllSegmentsDeprecated1(tableName, tableTypeStr); - } - @DELETE @Produces(MediaType.APPLICATION_JSON) @Path("/segments/{tableName}/{segmentName}") diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableIndexingConfigs.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableIndexingConfigs.java deleted file mode 100644 index f00d680aa2b6..000000000000 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableIndexingConfigs.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.pinot.controller.api.resources; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiKeyAuthDefinition; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Authorization; -import io.swagger.annotations.SecurityDefinition; -import io.swagger.annotations.SwaggerDefinition; -import javax.inject.Inject; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.apache.pinot.controller.api.access.AccessType; -import org.apache.pinot.controller.api.access.Authenticate; -import org.apache.pinot.controller.api.exception.ControllerApplicationException; -import org.apache.pinot.controller.helix.core.PinotHelixResourceManager; -import org.apache.pinot.core.auth.Actions; -import org.apache.pinot.core.auth.Authorize; -import org.apache.pinot.core.auth.TargetType; -import org.apache.pinot.segment.local.utils.TableConfigUtils; -import org.apache.pinot.spi.config.table.TableConfig; -import org.apache.pinot.spi.data.Schema; -import org.apache.pinot.spi.utils.JsonUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.apache.pinot.spi.utils.CommonConstants.SWAGGER_AUTHORIZATION_KEY; - - -@Api(tags = Constants.TABLE_TAG, authorizations = {@Authorization(value = SWAGGER_AUTHORIZATION_KEY)}) -@SwaggerDefinition(securityDefinition = @SecurityDefinition(apiKeyAuthDefinitions = @ApiKeyAuthDefinition(name = - HttpHeaders.AUTHORIZATION, in = ApiKeyAuthDefinition.ApiKeyLocation.HEADER, key = SWAGGER_AUTHORIZATION_KEY))) -@Path("/") -public class PinotTableIndexingConfigs { - private static final Logger LOGGER = LoggerFactory.getLogger(PinotTableIndexingConfigs.class); - - @Inject - PinotHelixResourceManager _pinotHelixResourceManager; - - @Deprecated - @PUT - @Path("/tables/{tableName}/indexingConfigs") - @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.UPDATE_TABLE_CONFIG) - @Authenticate(AccessType.UPDATE) - @ApiOperation(value = "Update table indexing configuration") - @Produces(MediaType.APPLICATION_JSON) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Success"), - @ApiResponse(code = 404, message = "Table not found"), - @ApiResponse(code = 500, message = "Server error updating configuration") - }) - public SuccessResponse updateIndexingConfig( - @ApiParam(value = "Table name (without type)", required = true) @PathParam("tableName") String tableName, - String tableConfigString) { - TableConfig tableConfig; - try { - tableConfig = JsonUtils.stringToObject(tableConfigString, TableConfig.class); - Schema schema = _pinotHelixResourceManager.getSchemaForTableConfig(tableConfig); - TableConfigUtils.validate(tableConfig, schema); - } catch (Exception e) { - String msg = String.format("Invalid table config: %s", tableName); - throw new ControllerApplicationException(LOGGER, msg, Response.Status.BAD_REQUEST, e); - } - try { - _pinotHelixResourceManager.updateIndexingConfigFor(tableConfig.getTableName(), tableConfig.getTableType(), - tableConfig.getIndexingConfig()); - return new SuccessResponse("Updated indexing config for table " + tableName); - } catch (Exception e) { - String errStr = "Failed to update indexing config for table: " + tableName; - throw new ControllerApplicationException(LOGGER, errStr, Response.Status.INTERNAL_SERVER_ERROR, e); - } - } -} diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableMetadataConfigs.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableMetadataConfigs.java deleted file mode 100644 index d61ac73ce49e..000000000000 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableMetadataConfigs.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.pinot.controller.api.resources; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiKeyAuthDefinition; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Authorization; -import io.swagger.annotations.SecurityDefinition; -import io.swagger.annotations.SwaggerDefinition; -import javax.inject.Inject; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.apache.pinot.controller.api.access.AccessType; -import org.apache.pinot.controller.api.access.Authenticate; -import org.apache.pinot.controller.api.exception.ControllerApplicationException; -import org.apache.pinot.controller.helix.core.PinotHelixResourceManager; -import org.apache.pinot.core.auth.Actions; -import org.apache.pinot.core.auth.Authorize; -import org.apache.pinot.core.auth.TargetType; -import org.apache.pinot.segment.local.utils.TableConfigUtils; -import org.apache.pinot.spi.config.table.TableConfig; -import org.apache.pinot.spi.data.Schema; -import org.apache.pinot.spi.utils.JsonUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.apache.pinot.spi.utils.CommonConstants.SWAGGER_AUTHORIZATION_KEY; - - -@Api(tags = Constants.TABLE_TAG, authorizations = {@Authorization(value = SWAGGER_AUTHORIZATION_KEY)}) -@SwaggerDefinition(securityDefinition = @SecurityDefinition(apiKeyAuthDefinitions = @ApiKeyAuthDefinition(name = - HttpHeaders.AUTHORIZATION, in = ApiKeyAuthDefinition.ApiKeyLocation.HEADER, key = SWAGGER_AUTHORIZATION_KEY))) -@Path("/") -public class PinotTableMetadataConfigs { - private static final Logger LOGGER = LoggerFactory.getLogger(PinotTableMetadataConfigs.class); - - @Inject - PinotHelixResourceManager _pinotHelixResourceManager; - - @Deprecated - @PUT - @Path("/tables/{tableName}/metadataConfigs") - @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.UPDATE_TABLE_CONFIG) - @Authenticate(AccessType.UPDATE) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Update table metadata", notes = "Updates table configuration") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Success"), - @ApiResponse(code = 500, message = "Internal server error"), - @ApiResponse(code = 404, message = "Table not found") - }) - public SuccessResponse updateTableMetadata(@PathParam("tableName") String tableName, String tableConfigString) { - TableConfig tableConfig; - try { - tableConfig = JsonUtils.stringToObject(tableConfigString, TableConfig.class); - Schema schema = _pinotHelixResourceManager.getSchemaForTableConfig(tableConfig); - TableConfigUtils.validate(tableConfig, schema); - } catch (Exception e) { - String msg = String.format("Invalid table config: %s", tableName); - throw new ControllerApplicationException(LOGGER, msg, Response.Status.BAD_REQUEST, e); - } - try { - _pinotHelixResourceManager.updateMetadataConfigFor(tableConfig.getTableName(), tableConfig.getTableType(), - tableConfig.getCustomConfig()); - return new SuccessResponse("Successfully updated " + tableName + " configuration"); - } catch (Exception e) { - String errStr = "Error while updating table configuration, table: " + tableName; - throw new ControllerApplicationException(LOGGER, errStr, Response.Status.INTERNAL_SERVER_ERROR, e); - } - } -} diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java index 2329568d3b7e..534205fcbfa4 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java @@ -568,46 +568,6 @@ public ObjectNode checkTableConfig(String tableConfigStr, return validationResponse; } - @Deprecated - @POST - @Path("/tables/validateTableAndSchema") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Validate table config for a table along with specified schema", - notes = "Deprecated. Use /tableConfigs/validate instead." - + "Validate given table config and schema. If specified schema is null, attempt to retrieve schema using the " - + "table name. This API returns the table config that matches the one you get from 'GET /tables/{tableName}'." - + " This allows us to validate table config before apply.") - @ManualAuthorization // performed after parsing TableAndSchemaConfig - public String validateTableAndSchema(TableAndSchemaConfig tableSchemaConfig, - @ApiParam(value = "comma separated list of validation type(s) to skip. supported types: (ALL|TASK|UPSERT)") - @QueryParam("validationTypesToSkip") @Nullable String typesToSkip, @Context HttpHeaders httpHeaders, - @Context Request request) { - TableConfig tableConfig = tableSchemaConfig.getTableConfig(); - String tableNameWithType = DatabaseUtils.translateTableName(tableConfig.getTableName(), httpHeaders); - tableConfig.setTableName(tableNameWithType); - // Handle legacy config - SegmentsValidationAndRetentionConfig validationConfig = tableConfig.getValidationConfig(); - if (validationConfig.getSchemaName() != null) { - validationConfig.setSchemaName(DatabaseUtils.translateTableName(validationConfig.getSchemaName(), httpHeaders)); - } - Schema schema = tableSchemaConfig.getSchema(); - if (schema == null) { - schema = _pinotHelixResourceManager.getSchemaForTableConfig(tableConfig); - } - - // validate permission - String endpointUrl = request.getRequestURL().toString(); - AccessControl accessControl = _accessControlFactory.create(); - AccessControlUtils.validatePermission(tableNameWithType, AccessType.READ, httpHeaders, endpointUrl, accessControl); - if (!accessControl.hasAccess(httpHeaders, TargetType.TABLE, tableNameWithType, - Actions.Table.VALIDATE_TABLE_CONFIGS)) { - throw new ControllerApplicationException(LOGGER, "Permission denied", Response.Status.FORBIDDEN); - } - - return validateConfig(tableConfig, schema, typesToSkip).toString(); - } - private ObjectNode validateConfig(TableConfig tableConfig, Schema schema, @Nullable String typesToSkip) { try { if (schema == null) { diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableSegmentConfigs.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableSegmentConfigs.java deleted file mode 100644 index b8a788056c4e..000000000000 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableSegmentConfigs.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.pinot.controller.api.resources; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiKeyAuthDefinition; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Authorization; -import io.swagger.annotations.SecurityDefinition; -import io.swagger.annotations.SwaggerDefinition; -import javax.inject.Inject; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.apache.pinot.controller.api.access.AccessType; -import org.apache.pinot.controller.api.access.Authenticate; -import org.apache.pinot.controller.api.exception.ControllerApplicationException; -import org.apache.pinot.controller.helix.core.PinotHelixResourceManager; -import org.apache.pinot.core.auth.Actions; -import org.apache.pinot.core.auth.Authorize; -import org.apache.pinot.core.auth.TargetType; -import org.apache.pinot.segment.local.utils.TableConfigUtils; -import org.apache.pinot.spi.config.table.TableConfig; -import org.apache.pinot.spi.data.Schema; -import org.apache.pinot.spi.utils.JsonUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.apache.pinot.spi.utils.CommonConstants.SWAGGER_AUTHORIZATION_KEY; - - -@Api(tags = Constants.TABLE_TAG, authorizations = {@Authorization(value = SWAGGER_AUTHORIZATION_KEY)}) -@SwaggerDefinition(securityDefinition = @SecurityDefinition(apiKeyAuthDefinitions = @ApiKeyAuthDefinition(name = - HttpHeaders.AUTHORIZATION, in = ApiKeyAuthDefinition.ApiKeyLocation.HEADER, key = SWAGGER_AUTHORIZATION_KEY))) -@Path("/") -public class PinotTableSegmentConfigs { - private static final Logger LOGGER = LoggerFactory.getLogger(PinotTableSegmentConfigs.class); - - @Inject - PinotHelixResourceManager _pinotHelixResourceManager; - - @Deprecated - @PUT - @Path("/tables/{tableName}/segmentConfigs") - @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = Actions.Table.UPDATE_TABLE_CONFIG) - @Authenticate(AccessType.UPDATE) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Update segments configuration", - notes = "Updates segmentsConfig section (validation and retention) of a table") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "Success"), - @ApiResponse(code = 404, message = "Table not found"), - @ApiResponse(code = 500, message = "Internal server error") - }) - public SuccessResponse put(@ApiParam(value = "Table name", required = true) @PathParam("tableName") String tableName, - String tableConfigString) { - TableConfig tableConfig; - try { - tableConfig = JsonUtils.stringToObject(tableConfigString, TableConfig.class); - Schema schema = _pinotHelixResourceManager.getSchemaForTableConfig(tableConfig); - TableConfigUtils.validate(tableConfig, schema); - } catch (Exception e) { - String msg = String.format("Invalid table config: %s", tableName); - throw new ControllerApplicationException(LOGGER, msg, Response.Status.BAD_REQUEST, e); - } - try { - _pinotHelixResourceManager - .updateSegmentsValidationAndRetentionConfigFor(tableConfig.getTableName(), tableConfig.getTableType(), - tableConfig.getValidationConfig()); - return new SuccessResponse("Update segmentsConfig for table: " + tableName); - } catch (Exception e) { - throw new ControllerApplicationException(LOGGER, - String.format("Failed to update segments config for table: %s", tableName), - Response.Status.INTERNAL_SERVER_ERROR, e); - } - } -} diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java index b2d9b2a1ae71..09f685e8bb38 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java @@ -168,16 +168,6 @@ public Set listTaskTypes() { return _pinotHelixTaskResourceManager.getTaskTypes(); } - @Deprecated - @GET - @Path("/tasks/taskqueues") - @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_TASK) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation("List all task queues (deprecated)") - public Set getTaskQueues() { - return _pinotHelixTaskResourceManager.getTaskQueues(); - } - @GET @Path("/tasks/{taskType}/state") @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_TASK) @@ -188,17 +178,6 @@ public TaskState getTaskQueueState( return _pinotHelixTaskResourceManager.getTaskQueueState(taskType); } - @Deprecated - @GET - @Path("/tasks/taskqueuestate/{taskType}") - @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_TASK) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation("Get the state (task queue state) for the given task type (deprecated)") - public StringResultResponse getTaskQueueStateDeprecated( - @ApiParam(value = "Task type", required = true) @PathParam("taskType") String taskType) { - return new StringResultResponse(_pinotHelixTaskResourceManager.getTaskQueueState(taskType).toString()); - } - @GET @Path("/tasks/{taskType}/tasks") @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_TASK) @@ -366,17 +345,6 @@ public PinotHelixTaskResourceManager.TaskDebugInfo getTaskDebugInfo( return _pinotHelixTaskResourceManager.getTaskDebugInfo(taskName, verbosity); } - @Deprecated - @GET - @Path("/tasks/tasks/{taskType}") - @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_TASK) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation("List all tasks for the given task type (deprecated)") - public Set getTasksDeprecated( - @ApiParam(value = "Task type", required = true) @PathParam("taskType") String taskType) { - return _pinotHelixTaskResourceManager.getTasks(taskType); - } - @GET @Path("/tasks/{taskType}/taskstates") @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_TASK) @@ -387,17 +355,6 @@ public Map getTaskStates( return _pinotHelixTaskResourceManager.getTaskStates(taskType); } - @Deprecated - @GET - @Path("/tasks/taskstates/{taskType}") - @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_TASK) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation("Get a map from task to task state for the given task type (deprecated)") - public Map getTaskStatesDeprecated( - @ApiParam(value = "Task type", required = true) @PathParam("taskType") String taskType) { - return _pinotHelixTaskResourceManager.getTaskStates(taskType); - } - @GET @Path("/tasks/task/{taskName}/state") @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_TASK) @@ -408,17 +365,6 @@ public TaskState getTaskState( return _pinotHelixTaskResourceManager.getTaskState(taskName); } - @Deprecated - @GET - @Path("/tasks/taskstate/{taskName}") - @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_TASK) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation("Get the task state for the given task (deprecated)") - public StringResultResponse getTaskStateDeprecated( - @ApiParam(value = "Task name", required = true) @PathParam("taskName") String taskName) { - return new StringResultResponse(String.valueOf(_pinotHelixTaskResourceManager.getTaskState(taskName))); - } - @GET @Path("/tasks/subtask/{taskName}/state") @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_TASK) @@ -449,17 +395,6 @@ public Map getTaskConfig( return _pinotHelixTaskResourceManager.getTaskRuntimeConfig(taskName); } - @Deprecated - @GET - @Path("/tasks/taskconfig/{taskName}") - @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_TASK) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation("Get the task config (a list of child task configs) for the given task (deprecated)") - public List getTaskConfigsDeprecated( - @ApiParam(value = "Task name", required = true) @PathParam("taskName") String taskName) { - return _pinotHelixTaskResourceManager.getSubtaskConfigs(taskName); - } - @GET @Path("/tasks/subtask/{taskName}/config") @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_TASK) @@ -720,17 +655,6 @@ public void executeAdhocTask(AdhocTaskConfig adhocTaskConfig, @Suspended AsyncRe } } - @Deprecated - @PUT - @Path("/tasks/scheduletasks") - @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.CREATE_TASK) - @Produces(MediaType.APPLICATION_JSON) - @Authenticate(AccessType.UPDATE) - @ApiOperation("Schedule tasks (deprecated)") - public Map scheduleTasksDeprecated() { - return _pinotTaskManager.scheduleTasks(); - } - @PUT @Path("/tasks/{taskType}/cleanup") @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.CLEANUP_TASK) @@ -743,19 +667,6 @@ public SuccessResponse cleanUpTasks( return new SuccessResponse("Successfully cleaned up tasks for task type: " + taskType); } - @Deprecated - @PUT - @Path("/tasks/cleanuptasks/{taskType}") - @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.CLEANUP_TASK) - @Produces(MediaType.APPLICATION_JSON) - @Authenticate(AccessType.UPDATE) - @ApiOperation("Clean up finished tasks (COMPLETED, FAILED) for the given task type (deprecated)") - public SuccessResponse cleanUpTasksDeprecated( - @ApiParam(value = "Task type", required = true) @PathParam("taskType") String taskType) { - _pinotHelixTaskResourceManager.cleanUpTaskQueue(taskType); - return new SuccessResponse("Successfully cleaned up tasks for task type: " + taskType); - } - @PUT @Path("/tasks/{taskType}/stop") @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.STOP_TASK) @@ -780,28 +691,6 @@ public SuccessResponse resumeTasks( return new SuccessResponse("Successfully resumed tasks for task type: " + taskType); } - @Deprecated - @PUT - @Path("/tasks/taskqueue/{taskType}") - @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.UPDATE_TASK_QUEUE) - @Produces(MediaType.APPLICATION_JSON) - @Authenticate(AccessType.UPDATE) - @ApiOperation("Stop/resume a task queue (deprecated)") - public SuccessResponse toggleTaskQueueState( - @ApiParam(value = "Task type", required = true) @PathParam("taskType") String taskType, - @ApiParam(value = "state", required = true) @QueryParam("state") String state) { - switch (state.toUpperCase()) { - case TASK_QUEUE_STATE_STOP: - _pinotHelixTaskResourceManager.stopTaskQueue(taskType); - return new SuccessResponse("Successfully stopped task queue for task type: " + taskType); - case TASK_QUEUE_STATE_RESUME: - _pinotHelixTaskResourceManager.resumeTaskQueue(taskType); - return new SuccessResponse("Successfully resumed task queue for task type: " + taskType); - default: - throw new IllegalArgumentException("Unsupported state: " + state); - } - } - @DELETE @Path("/tasks/{taskType}") @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.DELETE_TASK) @@ -829,19 +718,4 @@ public SuccessResponse deleteTask( _pinotHelixTaskResourceManager.deleteTask(taskName, forceDelete); return new SuccessResponse("Successfully deleted task: " + taskName); } - - @Deprecated - @DELETE - @Path("/tasks/taskqueue/{taskType}") - @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.DELETE_TASK) - @Produces(MediaType.APPLICATION_JSON) - @Authenticate(AccessType.DELETE) - @ApiOperation("Delete a task queue (deprecated)") - public SuccessResponse deleteTaskQueue( - @ApiParam(value = "Task type", required = true) @PathParam("taskType") String taskType, - @ApiParam(value = "Whether to force delete the task queue (expert only option, enable with cautious") - @DefaultValue("false") @QueryParam("forceDelete") boolean forceDelete) { - _pinotHelixTaskResourceManager.deleteTaskQueue(taskType, forceDelete); - return new SuccessResponse("Successfully deleted task queue for task type: " + taskType); - } } diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotUpsertRestletResource.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotUpsertRestletResource.java index 9fe755172451..08fc9d6343c3 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotUpsertRestletResource.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotUpsertRestletResource.java @@ -92,6 +92,7 @@ public class PinotUpsertRestletResource { @ApiOperation(value = "Estimate memory usage for an upsert table", notes = "This API returns the estimated heap usage based on primary key column stats." + " This allows us to estimate table size before onboarding.") + // TODO: Switch to use TableConfigs public String estimateHeapUsage(String tableSchemaConfigStr, @ApiParam(value = "cardinality", required = true) @QueryParam("cardinality") long cardinality, @ApiParam(value = "primaryKeySize", defaultValue = "-1") @QueryParam("primaryKeySize") int primaryKeySize, diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableAndSchemaConfig.java b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableAndSchemaConfig.java index e6f031d9d98b..a4a76d152775 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableAndSchemaConfig.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableAndSchemaConfig.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonProcessingException; import javax.annotation.Nullable; +import org.apache.pinot.spi.config.TableConfigs; import org.apache.pinot.spi.config.table.TableConfig; import org.apache.pinot.spi.data.Schema; import org.apache.pinot.spi.utils.JsonUtils; @@ -29,7 +30,9 @@ /** * Wrapper for TableConfig and Schema used in validation API + * @deprecated Use {@link TableConfigs} instead. */ +@Deprecated public class TableAndSchemaConfig { private final TableConfig _tableConfig; private final Schema _schema; diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java index 2774971fedac..a54648676caf 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java @@ -59,7 +59,6 @@ import javax.ws.rs.core.Response; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; import org.apache.helix.AccessOption; import org.apache.helix.ClusterMessagingService; @@ -155,10 +154,7 @@ import org.apache.pinot.controller.helix.starter.HelixConfig; import org.apache.pinot.segment.spi.SegmentMetadata; import org.apache.pinot.spi.config.instance.Instance; -import org.apache.pinot.spi.config.table.IndexingConfig; -import org.apache.pinot.spi.config.table.SegmentsValidationAndRetentionConfig; import org.apache.pinot.spi.config.table.TableConfig; -import org.apache.pinot.spi.config.table.TableCustomConfig; import org.apache.pinot.spi.config.table.TableStats; import org.apache.pinot.spi.config.table.TableType; import org.apache.pinot.spi.config.table.TagOverrideConfig; @@ -1977,46 +1973,6 @@ public void setExistingTableConfig(TableConfig tableConfig, int expectedVersion) sendTableConfigRefreshMessage(tableNameWithType); } - public void updateMetadataConfigFor(String tableName, TableType type, TableCustomConfig newConfigs) - throws Exception { - String tableNameWithType = TableNameBuilder.forType(type).tableNameWithType(tableName); - ImmutablePair tableConfigWithVersion = - ZKMetadataProvider.getTableConfigWithVersion(_propertyStore, tableNameWithType); - if (tableConfigWithVersion == null) { - throw new RuntimeException("Table: " + tableName + " of type: " + type + " does not exist"); - } - TableConfig tableConfig = tableConfigWithVersion.getLeft(); - tableConfig.setCustomConfig(newConfigs); - setExistingTableConfig(tableConfig, tableConfigWithVersion.getRight()); - } - - public void updateSegmentsValidationAndRetentionConfigFor(String tableName, TableType type, - SegmentsValidationAndRetentionConfig newConfigs) - throws Exception { - String tableNameWithType = TableNameBuilder.forType(type).tableNameWithType(tableName); - ImmutablePair tableConfigWithVersion = - ZKMetadataProvider.getTableConfigWithVersion(_propertyStore, tableNameWithType); - if (tableConfigWithVersion == null) { - throw new RuntimeException("Table: " + tableName + " of type: " + type + " does not exist"); - } - TableConfig tableConfig = tableConfigWithVersion.getLeft(); - tableConfig.setValidationConfig(newConfigs); - setExistingTableConfig(tableConfig, tableConfigWithVersion.getRight()); - } - - public void updateIndexingConfigFor(String tableName, TableType type, IndexingConfig newConfigs) - throws Exception { - String tableNameWithType = TableNameBuilder.forType(type).tableNameWithType(tableName); - ImmutablePair tableConfigWithVersion = - ZKMetadataProvider.getTableConfigWithVersion(_propertyStore, tableNameWithType); - if (tableConfigWithVersion == null) { - throw new RuntimeException("Table: " + tableName + " of type: " + type + " does not exist"); - } - TableConfig tableConfig = tableConfigWithVersion.getLeft(); - tableConfig.setIndexingConfig(newConfigs); - setExistingTableConfig(tableConfig, tableConfigWithVersion.getRight()); - } - public void deleteUser(String username) { ZKMetadataProvider.removeUserConfigFromPropertyStore(_propertyStore, username); LOGGER.info("Deleting user{}: Removed from user resouces", username); diff --git a/pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotTableRestletResourceTest.java b/pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotTableRestletResourceTest.java index f1766835fd6a..54644c26aa62 100644 --- a/pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotTableRestletResourceTest.java +++ b/pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotTableRestletResourceTest.java @@ -28,7 +28,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.pinot.controller.api.resources.TableAndSchemaConfig; import org.apache.pinot.controller.helix.ControllerTest; import org.apache.pinot.controller.helix.core.minion.PinotTaskManager; import org.apache.pinot.controller.helix.core.rebalance.RebalanceResult; @@ -672,53 +671,6 @@ public void testValidate() } } - @Test - public void testValidateTableAndSchema() - throws IOException { - String tableName = "verificationTestTableAndSchema"; - // Create a dummy schema - Schema schema = DEFAULT_INSTANCE.createDummySchema(tableName); - - // Create a valid OFFLINE table config - TableConfig offlineTableConfig = - _offlineBuilder.setTableName(tableName).setInvertedIndexColumns(Arrays.asList("dimA", "dimB")).build(); - TableAndSchemaConfig tableAndSchemaConfig = new TableAndSchemaConfig(offlineTableConfig, schema); - - try { - sendPostRequest( - StringUtil.join("/", DEFAULT_INSTANCE.getControllerBaseApiUrl(), "tables", "validateTableAndSchema"), - tableAndSchemaConfig.toJsonString()); - } catch (IOException e) { - fail("Valid table config and schema validation should succeed."); - } - - // Add a dummy schema to Pinot - DEFAULT_INSTANCE.addDummySchema(tableName); - tableAndSchemaConfig = new TableAndSchemaConfig(offlineTableConfig, null); - try { - sendPostRequest( - StringUtil.join("/", DEFAULT_INSTANCE.getControllerBaseApiUrl(), "tables", "validateTableAndSchema"), - tableAndSchemaConfig.toJsonString()); - } catch (IOException e) { - fail("Valid table config and existing schema validation should succeed."); - } - - // Create an invalid table config - offlineTableConfig = - _offlineBuilder.setTableName(tableName).setInvertedIndexColumns(Arrays.asList("invalidColA", "invalidColB")) - .build(); - tableAndSchemaConfig = new TableAndSchemaConfig(offlineTableConfig, schema); - try { - sendPostRequest( - StringUtil.join("/", DEFAULT_INSTANCE.getControllerBaseApiUrl(), "tables", "validateTableAndSchema"), - tableAndSchemaConfig.toJsonString()); - fail("Validation of an invalid table config and schema should fail."); - } catch (IOException e) { - // Expected - assertTrue(e.getMessage().contains("Got error status code: 400")); - } - } - @Test public void testUnrecognizedProperties() throws IOException { diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/builder/ControllerRequestURLBuilder.java b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/builder/ControllerRequestURLBuilder.java index 66972561f9d4..2841849f14c3 100644 --- a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/builder/ControllerRequestURLBuilder.java +++ b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/builder/ControllerRequestURLBuilder.java @@ -384,7 +384,7 @@ public String forListAllSegmentLineages(String tableName, String tableType) { } public String forListAllCrcInformationForTable(String tableName) { - return StringUtil.join("/", _baseUrl, "tables", tableName, "segments", "crc"); + return StringUtil.join("/", _baseUrl, "segments", tableName, "crc"); } public String forDeleteTableWithType(String tableName, String tableType) {