Copilot commented on code in PR #8795:
URL: https://github.com/apache/seatunnel/pull/8795#discussion_r2020515779


##########
seatunnel-connectors-v2/connector-tailfile/src/main/java/org/apache/seatunnel/connectors/tailfile/source/TailFileSourceReader.java:
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.seatunnel.connectors.tailfile.source;
+
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.source.Collector;
+import org.apache.seatunnel.api.source.SourceReader;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.tailfile.source.tailfile.FileManager;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+@Slf4j
+public class TailFileSourceReader implements SourceReader<SeaTunnelRow, 
TailFileSourceSplit> {
+    private final Context context;
+    private final TailFileSourceConfig config;
+    private final FileManager fileManager;
+    private volatile boolean noMoreSplit;
+
+    public TailFileSourceReader(Context context, TailFileSourceConfig config) {
+        this.context = context;
+        this.config = config;
+        this.fileManager = new FileManager(config);
+    }
+
+    @Override
+    public void open() throws Exception {
+        log.info("Open source reader {}", context.getIndexOfSubtask());
+    }
+
+    @Override
+    public void close() throws IOException {
+        log.info("Close source reader {}", context.getIndexOfSubtask());
+        fileManager.close();
+    }
+
+    @Override
+    public void pollNext(Collector<SeaTunnelRow> output) {
+        List<Long> fileInodes = Collections.emptyList();
+        synchronized (output.getCheckpointLock()) {
+            if (!fileManager.isEmpty()) {
+                fileInodes = fileManager.checkNeedTailFiles();
+            }
+        }
+
+        for (Long fileInode : fileInodes) {
+            synchronized (output.getCheckpointLock()) {
+                try {
+                    fileManager.tailFile(fileInode, output::collect);
+                } catch (Exception e) {
+                    log.error("Field to tail file {}", fileInode, e);

Review Comment:
   The error message contains a typo ('Field to tail file') which should be 
corrected to 'Failed to tail file' for clarity.
   ```suggestion
                       log.error("Failed to tail file {}", fileInode, e);
   ```



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