I want to read the file contents in a directory in stream mode, that is, when new files are added into the directory, then read it.
Following is the sample code, I observed that after the program prints all the already existing files in the directory, and then I add a new file, but the program doesn't print the contents of the newly added file.
I am not sure where the problem is.
import org.apache.flink.api.java.io.TextInputFormat
import org.apache.flink.core.fs.Path
import org.apache.flink.streaming.api.functions.source.FileProcessingMode
import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment}
import org.apache.flink.streaming.api.scala._
object FileBasedDataStreamTest {
def main(args: Array[String]): Unit = {
val env = StreamExecutionEnvironment.getExecutionEnvironment
val path = "D:/flink-data/001"
val ds: DataStream[String] = env.readFile(new TextInputFormat(new Path(path)), path, FileProcessingMode.PROCESS_CONTINUOUSLY, 100)
ds.print()
env.execute()
}
}