Repository: incubator-edgent
Updated Branches:
  refs/heads/master aa3b5c867 -> a92c365ee


[Edgent-361] Add a sample for periodic use of textFileReader

Project: http://git-wip-us.apache.org/repos/asf/incubator-edgent/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-edgent/commit/e3847046
Tree: http://git-wip-us.apache.org/repos/asf/incubator-edgent/tree/e3847046
Diff: http://git-wip-us.apache.org/repos/asf/incubator-edgent/diff/e3847046

Branch: refs/heads/master
Commit: e384704664b55b4512c8387df4478c12e22ef3b7
Parents: a6090c8
Author: Dale LaBossiere <[email protected]>
Authored: Tue Jan 3 17:19:53 2017 -0500
Committer: Dale LaBossiere <[email protected]>
Committed: Tue Jan 3 17:19:53 2017 -0500

----------------------------------------------------------------------
 .../edgent/connectors/file/FileStreams.java     | 22 +++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/e3847046/connectors/file/src/main/java/org/apache/edgent/connectors/file/FileStreams.java
----------------------------------------------------------------------
diff --git 
a/connectors/file/src/main/java/org/apache/edgent/connectors/file/FileStreams.java
 
b/connectors/file/src/main/java/org/apache/edgent/connectors/file/FileStreams.java
index 8459299..1f4ca5e 100644
--- 
a/connectors/file/src/main/java/org/apache/edgent/connectors/file/FileStreams.java
+++ 
b/connectors/file/src/main/java/org/apache/edgent/connectors/file/FileStreams.java
@@ -117,8 +117,10 @@ public class FileStreams {
      * <p>
      * This is the same as {@code textFileReader(pathnames, null, null)}
      * <p>
-     * Sample use:
+     * Sample uses:
+     * 
      * <pre>{@code
+     * // continuously watch a directory for new files and process each one 
once
      * String dir = "/some/directory/path";
      * Topology t = ...
      * TStream<String> pathnames = FileStreams.directoryWatcher(t, () -> dir);
@@ -126,6 +128,24 @@ public class FileStreams {
      * contents.print();
      * }</pre>
      * 
+     * <pre>{@code
+     * // periodically process one or more files
+     * Supplier<List<String>> myPathnamesSupplier = () -> } {
+     * {@code
+     *    // implementation of List<String> get() - return a list of pathnames
+     *      //  return Arrays.asList("/some/pathname"); // a fixed list
+     *      //  return Arrays.asList(new File("/some/dir").list()); // query a 
directory
+     *      //  or query some other object(s) for a list ...
+     * }
+     *    };
+     * {@code
+     * Topology t = ...
+     * TStream<String> pathnames = t.poll(myPathnamesSupplier, 30, 
TimeUnit.SECONDS)
+     *                              .flatMap(tuple -> tuple);
+     * TStream<String> contents = FileStreams.textFileReader(pathnames);
+     * contents.print();
+     * }</pre>
+     * 
      * @param pathnames
      *            Stream containing pathnames of files to read.
      * @return Stream containing lines from the files.

Reply via email to