morningman commented on a change in pull request #4515:
URL: https://github.com/apache/incubator-doris/pull/4515#discussion_r487524636
##########
File path: fe/fe-core/src/main/java/org/apache/doris/load/Load.java
##########
@@ -1570,6 +1581,105 @@ public boolean isLabelExist(String dbName, String
label) throws DdlException {
}
}
+ public boolean cancelLoadJob(CancelLoadStmt stmt, boolean isAccurateMatch)
throws DdlException {
+ // get params
+ String dbName = stmt.getDbName();
+ String label = stmt.getLabel();
+
+ // get load job and check state
+ Database db = Catalog.getCurrentCatalog().getDb(dbName);
+ if (db == null) {
+ throw new DdlException("Db does not exist. name: " + dbName);
+ }
+ // List of load jobs waiting to be cancelled
+ List<LoadJob> loadJobs = Lists.newArrayList();
+ readLock();
+ try {
+ Map<String, List<LoadJob>> labelToLoadJobs =
dbLabelToLoadJobs.get(db.getId());
+ if (labelToLoadJobs == null) {
+ throw new DdlException("Load job does not exist");
+ }
+
+ // get jobs by label
+ List<LoadJob> matchLoadJobs = Lists.newArrayList();
+ if (isAccurateMatch) {
+ if (labelToLoadJobs.containsKey(label)) {
+ matchLoadJobs.addAll(labelToLoadJobs.get(label));
+ }
+ } else {
+ for (Map.Entry<String, List<LoadJob>> entry :
labelToLoadJobs.entrySet()) {
+ if (entry.getKey().contains(label)) {
+ matchLoadJobs.addAll(entry.getValue());
+ }
+ }
+ }
+
+ if (matchLoadJobs.isEmpty()) {
+ throw new DdlException("Load job does not exist");
+ }
+
+ // check state here
+ if (isAccurateMatch) {
+ // only the last one should be running
Review comment:
We should not rely on "the last one is running", better filter it by
state.
So that we can unify the logic just same as batch cancel.
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]