[fix](load) exclude canceled job when canceling load (#19268)

This commit is contained in:
奕冷
2023-05-05 10:31:16 +08:00
committed by GitHub
parent 693a3651c1
commit 1a1aee3886

View File

@ -238,23 +238,29 @@ public class LoadManager implements Writable {
String state = stmt.getState();
PatternMatcher matcher = PatternMatcherWrapper.createMysqlPattern(label,
CaseSensibility.LABEL.getCaseSensibility());
matchLoadJobs.addAll(loadJobs.stream().filter(job -> {
if (stmt.getOperator() != null) {
// compound
boolean labelFilter =
label.contains("%") ? matcher.match(job.getLabel()) : job.getLabel().equalsIgnoreCase(label);
boolean stateFilter = job.getState().name().equalsIgnoreCase(state);
return Operator.AND.equals(stmt.getOperator()) ? labelFilter && stateFilter :
labelFilter || stateFilter;
}
if (StringUtils.isNotEmpty(label)) {
return label.contains("%") ? matcher.match(job.getLabel()) : job.getLabel().equalsIgnoreCase(label);
}
if (StringUtils.isNotEmpty(state)) {
return job.getState().name().equalsIgnoreCase(state);
}
return false;
}).collect(Collectors.toList()));
matchLoadJobs.addAll(
loadJobs.stream()
.filter(job -> job.getState() != JobState.CANCELLED)
.filter(job -> {
if (stmt.getOperator() != null) {
// compound
boolean labelFilter =
label.contains("%") ? matcher.match(job.getLabel())
: job.getLabel().equalsIgnoreCase(label);
boolean stateFilter = job.getState().name().equalsIgnoreCase(state);
return Operator.AND.equals(stmt.getOperator()) ? labelFilter && stateFilter :
labelFilter || stateFilter;
}
if (StringUtils.isNotEmpty(label)) {
return label.contains("%") ? matcher.match(job.getLabel())
: job.getLabel().equalsIgnoreCase(label);
}
if (StringUtils.isNotEmpty(state)) {
return job.getState().name().equalsIgnoreCase(state);
}
return false;
}).collect(Collectors.toList())
);
}
/**
@ -492,13 +498,13 @@ public class LoadManager implements Writable {
/**
* This method will return the jobs info which can meet the condition of input param.
*
* @param dbId used to filter jobs which belong to this db
* @param labelValue used to filter jobs which's label is or like labelValue.
* @param dbId used to filter jobs which belong to this db
* @param labelValue used to filter jobs which's label is or like labelValue.
* @param accurateMatch true: filter jobs which's label is labelValue. false: filter jobs which's label like itself.
* @param statesValue used to filter jobs which's state within the statesValue set.
* @param statesValue used to filter jobs which's state within the statesValue set.
* @return The result is the list of jobInfo.
* JobInfo is a list which includes the comparable object: jobId, label, state etc.
* The result is unordered.
* JobInfo is a list which includes the comparable object: jobId, label, state etc.
* The result is unordered.
*/
public List<List<Comparable>> getLoadJobInfosByDb(long dbId, String labelValue, boolean accurateMatch,
Set<String> statesValue) throws AnalysisException {