healchow commented on code in PR #5910:
URL: https://github.com/apache/inlong/pull/5910#discussion_r974847679
##########
inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/fetcher/ManagerFetcher.java:
##########
@@ -300,6 +307,24 @@ private void dealWithFetchResult(TaskResult taskResult) {
}
}
+ private boolean triggerIsRunning(TriggerProfile newProfile) {
+ int type =
ManagerOpEnum.getOpType(newProfile.getInt(JOB_OP)).getType();
+ if (ManagerOpEnum.ACTIVE.getType() != type ||
ManagerOpEnum.ADD.getType() != type) {
+ return false;
+ }
+ JobProfileDb jobProfileDb = agentManager.getJobProfileDb();
+ List<JobProfile> jobsByState =
jobProfileDb.getJobsByState(StateSearchKey.ACCEPTED);
+
jobsByState.addAll(jobProfileDb.getJobsByState(StateSearchKey.RUNNING));
+ AtomicBoolean jobIsRunning = new AtomicBoolean(false);
+ jobsByState.forEach(jobProfile -> {
+ if (jobProfile.get(JOB_ID).equals(newProfile.get(JOB_ID))) {
Review Comment:
Will `jobProfile.get(JOB_ID)` be null?
Wouldn't it be better to use `Objects.equals()` here?
##########
inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/job/Job.java:
##########
@@ -83,8 +88,21 @@ public void setJobInstanceId(String jobInstanceId) {
* @return taskList
*/
public List<Task> createTasks() {
+ return getTasks(this.jobConf);
+ }
+
+ /**
+ * build task from job config
+ *
+ * @param jobConf
Review Comment:
Please add a description for the param and return.
##########
inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/trigger/TriggerManager.java:
##########
@@ -156,6 +169,35 @@ private Runnable jobFetchThread() {
};
}
+ private boolean isRunningJob(JobProfile profile, Map<String, JobWrapper>
jobWrapperMap) {
+ JobWrapper jobWrapper;
+ try {
+ jobWrapper = jobWrapperMap.get(profile.getInstanceId());
+ } catch (Exception exception) {
+ LOGGER.warn("jobWrapper is null");
+ return false;
+ }
+ List<Task> tasks = jobWrapper.getAllTasks();
+ for (Task task : tasks) {
+ JobProfile runJobProfile = task.getJobConf();
+ if
(runJobProfile.get(JOB_DIR_FILTER_PATTERN).equals(profile.get(JOB_DIR_FILTER_PATTERN)))
{
Review Comment:
Will `jobProfile.get(JOB_DIR_FILTER_PATTERN)` be null?
Wouldn't it be better to use `Objects.equals()` here?
##########
inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/job/JobWrapper.java:
##########
@@ -169,4 +170,11 @@ public void addCallbacks() {
public List<Task> getAllTasks() {
return allTasks;
}
+
Review Comment:
Suggest adding Java doc for public methods.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]