healchow commented on code in PR #5744:
URL: https://github.com/apache/inlong/pull/5744#discussion_r959302769


##########
inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/reader/file/MonitorTextFile.java:
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.agent.plugin.sources.reader.file;
+
+import org.apache.inlong.agent.common.AgentThreadFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import static 
org.apache.inlong.agent.constant.JobConstants.INTERVAL_MILLISECONDS;
+import static 
org.apache.inlong.agent.constant.JobConstants.JOB_FILE_MONITOR_DEFAULT_EXPIRE;
+import static 
org.apache.inlong.agent.constant.JobConstants.JOB_FILE_MONITOR_EXPIRE;
+import static 
org.apache.inlong.agent.constant.JobConstants.JOB_FILE_MONITOR_INTERVAL;
+
+/**
+ * monitor files
+ */
+public final class MonitorTextFile {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(MonitorTextFile.class);
+    private static MonitorTextFile monitorTextFile;
+    // monitor thread pool
+    private final ThreadPoolExecutor runningPool = new ThreadPoolExecutor(
+            0, Integer.MAX_VALUE,
+            60L, TimeUnit.SECONDS,
+            new SynchronousQueue<>(),
+            new AgentThreadFactory("monitor-file"));
+
+    private MonitorTextFile() {
+
+    }
+
+    public static synchronized MonitorTextFile getInstance() {
+        if (null == monitorTextFile) {
+            monitorTextFile = new MonitorTextFile();
+        }
+        return monitorTextFile;
+    }
+
+    public void monitor(FileReaderOperator fileReaderOperator, TextFileReader 
textFileReader) {
+        MonitorEvent monitorEvent = new MonitorEvent(fileReaderOperator, 
textFileReader);
+        runningPool.execute(monitorEvent);
+    }
+
+    private class MonitorEvent implements Runnable {

Review Comment:
   Suggested changing to `MonitorEventRunnable`, and add Java doc, please.



-- 
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]

Reply via email to