zhangayqian commented on a change in pull request #1616:
URL: https://github.com/apache/kylin/pull/1616#discussion_r600202574
##########
File path: server-base/src/main/java/org/apache/kylin/rest/msg/Message.java
##########
@@ -65,6 +65,10 @@ public String getDELETE_NOT_READY_SEG() {
return "Cannot delete segment '%s' as its status is not READY. Discard
the on-going job for it.";
}
+ public String getDELETE_READY_SEG_BY_UUID() {
+ return "Cannot delete segment by UUID '%s' as its status is READY or
its Cube is READY. ";
Review comment:
Remove the space at the end to keep the format uniform.
##########
File path:
server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java
##########
@@ -610,6 +610,32 @@ public CubeInstance rebuildLookupSnapshot(CubeInstance
cube, String segmentName,
return cube;
}
+ public CubeInstance deleteSegmentById(CubeInstance cube, String uuid)
throws IOException {
+ aclEvaluate.checkProjectWritePermission(cube);
+ Message msg = MsgPicker.getMsg();
+
+ CubeSegment toDelete = null;
+
+ toDelete = cube.getSegmentById(uuid);
+
+ if (toDelete == null) {
+ throw new BadRequestException(String.format(Locale.ROOT,
msg.getSEG_NOT_FOUND(), uuid));
+ }
+
+ if (cube.getStatus() == RealizationStatusEnum.DISABLED
+ || (cube.getStatus() == RealizationStatusEnum.READY &&
toDelete.getStatus() != SegmentStatusEnum.READY)) {
Review comment:
When a segment with `NEW` status has related running jobs, I think it
shouldn't be able to be deleted. Method
`CubeService.isOrphonSegment(CubeInstance cube, String segId)` can help to
judge whether a segment has related jobs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]