private void runForWatching() {
        /* Deal with those failed watcher creation tasks. */
        Set<String> tmpWatchFailedDirs = new HashSet<>(watchFailedDirs);
        for (String originPattern : tmpWatchFailedDirs) {
            addPathPattern(originPattern);
        }
        /*
         * Visit the watchers to see if it gets any new file creation, if it exists and fits the file name pattern, add
         * it to the task list.
         */
        for (Map.Entry<String, WatchEntity> entry : watchers.entrySet()) {
            dealWithWatchEntity(entry.getKey());
        }
    }
Watch directory, if new valid files are created, create instance correspondingly.
inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/task/logcollection/local/FileTask.java