Skip to content

Commit

Permalink
Remove rest APIs that was deprecated more than 4 years ago (apache#12639
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Jackie-Jiang authored Mar 13, 2024
1 parent 3b48a67 commit e1aee5f
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 752 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Map<String, String>> 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<String> tableNamesWithType = ResourceUtils
.getExistingTableNamesWithType(_pinotHelixResourceManager, tableName, Constants.validateTableType(tableTypeStr),
LOGGER);
List<Map<String, String>> resultList = new ArrayList<>(tableNamesWithType.size());
for (String tableNameWithType : tableNamesWithType) {
// NOTE: DO NOT change the format for backward-compatibility
Map<String, String> 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<Map<String, String>> 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)
Expand All @@ -343,20 +292,6 @@ public Map<String, String> 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<String, String> 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)
Expand Down Expand Up @@ -420,68 +355,6 @@ private Map<String, String> 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<List<Map<String, Object>>> 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<String> tableNamesWithType =
ResourceUtils.getExistingTableNamesWithType(_pinotHelixResourceManager, tableName, tableType, LOGGER);
List<List<Map<String, Object>>> resultList = new ArrayList<>(tableNamesWithType.size());
for (String tableNameWithType : tableNamesWithType) {
Map<String, Object> segmentMetadata =
getSegmentMetadata(tableNameWithType, segmentName, Collections.emptyList(), headers);
if (segmentMetadata != null) {
// NOTE: DO NOT change the format for backward-compatibility
Map<String, Object> 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<List<Map<String, Object>>> 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)
Expand Down Expand Up @@ -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<String> 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)
Expand Down Expand Up @@ -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<String> 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}")
Expand Down

This file was deleted.

Loading

0 comments on commit e1aee5f

Please sign in to comment.