| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <!-- Generated by javadoc (1.8.0_112) on Mon Dec 18 11:25:20 EST 2017 --> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <title>FileStreams (Apache Edgent (incubating) v1.2.0 API)</title> |
| <meta name="date" content="2017-12-18"> |
| <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> |
| <script type="text/javascript" src="../../../../../script.js"></script> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| try { |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="FileStreams (Apache Edgent (incubating) v1.2.0 API)"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| var methods = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9}; |
| var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]}; |
| var altColor = "altColor"; |
| var rowColor = "rowColor"; |
| var tableTab = "tableTab"; |
| var activeTableTab = "activeTableTab"; |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="topNav"><a name="navbar.top"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.top.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="class-use/FileStreams.html">Use</a></li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../../org/apache/edgent/connectors/file/CompressedFileWriterPolicy.html" title="class in org.apache.edgent.connectors.file"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../../org/apache/edgent/connectors/file/FileWriterCycleConfig.html" title="class in org.apache.edgent.connectors.file"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../index.html?org/apache/edgent/connectors/file/FileStreams.html" target="_top">Frames</a></li> |
| <li><a href="FileStreams.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_top"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.top"> |
| <!-- --> |
| </a></div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="subTitle">org.apache.edgent.connectors.file</div> |
| <h2 title="Class FileStreams" class="title">Class FileStreams</h2> |
| </div> |
| <div class="contentContainer"> |
| <ul class="inheritance"> |
| <li><a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li> |
| <li> |
| <ul class="inheritance"> |
| <li>org.apache.edgent.connectors.file.FileStreams</li> |
| </ul> |
| </li> |
| </ul> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <hr> |
| <br> |
| <pre>public class <span class="typeNameLabel">FileStreams</span> |
| extends <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre> |
| <div class="block"><code>FileStreams</code> is a connector for integrating with file system objects. |
| <p> |
| File stream operations include: |
| <ul> |
| <li>Write tuples to text files - <a href="../../../../../org/apache/edgent/connectors/file/FileStreams.html#textFileWriter-org.apache.edgent.topology.TStream-org.apache.edgent.function.Supplier-org.apache.edgent.function.Supplier-"><code>textFileWriter</code></a></li> |
| <li>Watch a directory for new files - <a href="../../../../../org/apache/edgent/connectors/file/FileStreams.html#directoryWatcher-org.apache.edgent.topology.TopologyElement-org.apache.edgent.function.Supplier-"><code>directoryWatcher</code></a></li> |
| <li>Create tuples from text files - <a href="../../../../../org/apache/edgent/connectors/file/FileStreams.html#textFileReader-org.apache.edgent.topology.TStream-org.apache.edgent.function.Function-org.apache.edgent.function.BiFunction-"><code>textFileReader</code></a></li> |
| </ul></div> |
| </li> |
| </ul> |
| </div> |
| <div class="summary"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.summary"> |
| <!-- --> |
| </a> |
| <h3>Method Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> |
| <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Method and Description</th> |
| </tr> |
| <tr id="i0" class="altColor"> |
| <td class="colFirst"><code>static <a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileStreams.html#directoryWatcher-org.apache.edgent.topology.TopologyElement-org.apache.edgent.function.Supplier-">directoryWatcher</a></span>(<a href="../../../../../org/apache/edgent/topology/TopologyElement.html" title="interface in org.apache.edgent.topology">TopologyElement</a> te, |
| <a href="../../../../../org/apache/edgent/function/Supplier.html" title="interface in org.apache.edgent.function">Supplier</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> directory)</code> |
| <div class="block">Declare a stream containing the absolute pathname of |
| newly created file names from watching <code>directory</code>.</div> |
| </td> |
| </tr> |
| <tr id="i1" class="rowColor"> |
| <td class="colFirst"><code>static <a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileStreams.html#directoryWatcher-org.apache.edgent.topology.TopologyElement-org.apache.edgent.function.Supplier-java.util.Comparator-">directoryWatcher</a></span>(<a href="../../../../../org/apache/edgent/topology/TopologyElement.html" title="interface in org.apache.edgent.topology">TopologyElement</a> te, |
| <a href="../../../../../org/apache/edgent/function/Supplier.html" title="interface in org.apache.edgent.function">Supplier</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> directory, |
| <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html?is-external=true" title="class or interface in java.util">Comparator</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>> comparator)</code> |
| <div class="block">Declare a stream containing the absolute pathname of |
| newly created file names from watching <code>directory</code>.</div> |
| </td> |
| </tr> |
| <tr id="i2" class="altColor"> |
| <td class="colFirst"><code>static <a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileStreams.html#textFileReader-org.apache.edgent.topology.TStream-">textFileReader</a></span>(<a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> pathnames)</code> |
| <div class="block">Declare a stream containing the lines read from the files |
| whose pathnames correspond to each tuple on the <code>pathnames</code> |
| stream.</div> |
| </td> |
| </tr> |
| <tr id="i3" class="rowColor"> |
| <td class="colFirst"><code>static <a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileStreams.html#textFileReader-org.apache.edgent.topology.TStream-org.apache.edgent.function.Function-org.apache.edgent.function.BiFunction-">textFileReader</a></span>(<a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> pathnames, |
| <a href="../../../../../org/apache/edgent/function/Function.html" title="interface in org.apache.edgent.function">Function</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> preFn, |
| <a href="../../../../../org/apache/edgent/function/BiFunction.html" title="interface in org.apache.edgent.function">BiFunction</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</a>,<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> postFn)</code> |
| <div class="block">Declare a stream containing the lines read from the files |
| whose pathnames correspond to each tuple on the <code>pathnames</code> |
| stream.</div> |
| </td> |
| </tr> |
| <tr id="i4" class="altColor"> |
| <td class="colFirst"><code>static <a href="../../../../../org/apache/edgent/topology/TSink.html" title="interface in org.apache.edgent.topology">TSink</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileStreams.html#textFileWriter-org.apache.edgent.topology.TStream-org.apache.edgent.function.Supplier-">textFileWriter</a></span>(<a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> contents, |
| <a href="../../../../../org/apache/edgent/function/Supplier.html" title="interface in org.apache.edgent.function">Supplier</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> basePathname)</code> |
| <div class="block">Write the contents of a stream to files.</div> |
| </td> |
| </tr> |
| <tr id="i5" class="rowColor"> |
| <td class="colFirst"><code>static <a href="../../../../../org/apache/edgent/topology/TSink.html" title="interface in org.apache.edgent.topology">TSink</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileStreams.html#textFileWriter-org.apache.edgent.topology.TStream-org.apache.edgent.function.Supplier-org.apache.edgent.function.Supplier-">textFileWriter</a></span>(<a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> contents, |
| <a href="../../../../../org/apache/edgent/function/Supplier.html" title="interface in org.apache.edgent.function">Supplier</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> basePathname, |
| <a href="../../../../../org/apache/edgent/function/Supplier.html" title="interface in org.apache.edgent.function">Supplier</a><org.apache.edgent.connectors.file.runtime.IFileWriterPolicy<<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>>> policy)</code> |
| <div class="block">Write the contents of a stream to files subject to the control |
| of a file writer policy.</div> |
| </td> |
| </tr> |
| </table> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class java.lang.<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3> |
| <code><a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="details"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ============ METHOD DETAIL ========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.detail"> |
| <!-- --> |
| </a> |
| <h3>Method Detail</h3> |
| <a name="directoryWatcher-org.apache.edgent.topology.TopologyElement-org.apache.edgent.function.Supplier-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>directoryWatcher</h4> |
| <pre>public static <a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> directoryWatcher(<a href="../../../../../org/apache/edgent/topology/TopologyElement.html" title="interface in org.apache.edgent.topology">TopologyElement</a> te, |
| <a href="../../../../../org/apache/edgent/function/Supplier.html" title="interface in org.apache.edgent.function">Supplier</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> directory)</pre> |
| <div class="block">Declare a stream containing the absolute pathname of |
| newly created file names from watching <code>directory</code>. |
| <p> |
| This is the same as <code>directoryWatcher(t, () -> dir, null)</code>.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>te</code> - topology element whose topology the watcher will be added to</dd> |
| <dd><code>directory</code> - Name of the directory to watch.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>Stream containing absolute pathnames of newly created files in |
| <code>directory</code>.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="directoryWatcher-org.apache.edgent.topology.TopologyElement-org.apache.edgent.function.Supplier-java.util.Comparator-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>directoryWatcher</h4> |
| <pre>public static <a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> directoryWatcher(<a href="../../../../../org/apache/edgent/topology/TopologyElement.html" title="interface in org.apache.edgent.topology">TopologyElement</a> te, |
| <a href="../../../../../org/apache/edgent/function/Supplier.html" title="interface in org.apache.edgent.function">Supplier</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> directory, |
| <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html?is-external=true" title="class or interface in java.util">Comparator</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>> comparator)</pre> |
| <div class="block">Declare a stream containing the absolute pathname of |
| newly created file names from watching <code>directory</code>. |
| <p> |
| Hidden files (java.io.File.isHidden()==true) are ignored. |
| This is compatible with <code>textFileWriter</code>. |
| <p> |
| Sample use: |
| <pre><code> |
| String dir = "/some/directory/path"; |
| Topology t = ... |
| TStream<String> pathnames = FileStreams.directoryWatcher(t, () -> dir, null); |
| </code></pre> |
| <p> |
| The order of the files in the stream is dictated by a <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html?is-external=true" title="class or interface in java.util"><code>Comparator</code></a>. |
| The default comparator orders files by <a href="http://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true#lastModified--" title="class or interface in java.io"><code>File.lastModified()</code></a> values. |
| There are no guarantees on the processing order of files that |
| have the same lastModified value. |
| Note, lastModified values are subject to filesystem timestamp |
| quantization - e.g., 1second. |
| <p> |
| Note: due to the asynchronous nature of things, if files in the |
| directory may be removed, the receiver of a tuple with a "new" file |
| pathname may need to be prepared for the pathname to no longer be |
| valid when it receives the tuple or during its processing of the tuple. |
| <p> |
| The behavior on MacOS may be unsavory, even as recent as Java8, as |
| MacOs Java lacks a native implementation of <a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/WatchService.html?is-external=true" title="class or interface in java.nio.file"><code>WatchService</code></a>. |
| The result can be a delay in detecting newly created files (e.g., 10sec) |
| as well not detecting rapid deletion and recreation of a file.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>te</code> - topology element whose topology the watcher will be added to</dd> |
| <dd><code>directory</code> - Name of the directory to watch.</dd> |
| <dd><code>comparator</code> - Comparator to use to order newly seen file pathnames. |
| May be null.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>Stream containing absolute pathnames of newly created files in |
| <code>directory</code>.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="textFileReader-org.apache.edgent.topology.TStream-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>textFileReader</h4> |
| <pre>public static <a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> textFileReader(<a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> pathnames)</pre> |
| <div class="block">Declare a stream containing the lines read from the files |
| whose pathnames correspond to each tuple on the <code>pathnames</code> |
| stream. |
| <p> |
| This is the same as <code>textFileReader(pathnames, null, null)</code> |
| <p> |
| 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); |
| TStream<String> contents = FileStreams.textFileReader(pathnames); |
| contents.print(); |
| </code></pre> |
| |
| <pre><code> |
| // periodically process one or more files |
| Supplier<List<String>> myPathnamesSupplier = () -> </code> { |
| <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> |
| }; |
| <code> |
| Topology t = ... |
| TStream<String> pathnames = t.poll(myPathnamesSupplier, 30, TimeUnit.SECONDS) |
| .flatMap(tuple -> tuple); |
| TStream<String> contents = FileStreams.textFileReader(pathnames); |
| contents.print(); |
| </code></pre></div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>pathnames</code> - Stream containing pathnames of files to read.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>Stream containing lines from the files.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="textFileReader-org.apache.edgent.topology.TStream-org.apache.edgent.function.Function-org.apache.edgent.function.BiFunction-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>textFileReader</h4> |
| <pre>public static <a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> textFileReader(<a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> pathnames, |
| <a href="../../../../../org/apache/edgent/function/Function.html" title="interface in org.apache.edgent.function">Function</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> preFn, |
| <a href="../../../../../org/apache/edgent/function/BiFunction.html" title="interface in org.apache.edgent.function">BiFunction</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</a>,<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> postFn)</pre> |
| <div class="block">Declare a stream containing the lines read from the files |
| whose pathnames correspond to each tuple on the <code>pathnames</code> |
| stream. |
| <p> |
| All files are assumed to be encoded in UTF-8. The lines are |
| output in the order they appear in each file, with the first line of |
| a file appearing first. A file is not subsequently monitored for |
| additional lines. |
| <p> |
| If a file can not be read, e.g., a file doesn't exist at that pathname |
| or the pathname is for a directory, |
| an error will be logged. |
| <p> |
| Optional <code>preFn</code> and <code>postFn</code> functions may be supplied. |
| These are called prior to processing a tuple (pathname) and after |
| respectively. They provide a way to encode markers in the generated |
| stream. |
| <p> |
| Sample use: |
| <pre><code> |
| // watch a directory for files, creating a stream with the contents of |
| // each file. Use a preFn to include a file separator marker in the |
| // stream. Use a postFn to delete a file once it's been processed. |
| String dir = "/some/directory/path"; |
| Topology t = ... |
| TStream<String> pathnames = FileStreams.directoryWatcher(t, () -> dir); |
| TStream<String> contents = FileStreams.textFileReader( |
| pathnames, |
| path -> { return "###<PATH-MARKER>### " + path }, |
| (path,exception) -> { new File(path).delete(), return null; } |
| ); |
| contents.print(); |
| </code></pre></div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>pathnames</code> - Stream containing pathnames of files to read.</dd> |
| <dd><code>preFn</code> - Pre-visit <code>Function<String,String></code>. |
| The input is the pathname. |
| The result, when non-null, is added to the output stream. |
| The function may be null.</dd> |
| <dd><code>postFn</code> - Post-visit <code>BiFunction<String,Exception,String></code>. |
| The input is the pathname and an exception. The exception |
| is null if there were no errors. |
| The result, when non-null, is added to the output stream. |
| The function may be null.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>Stream containing lines from the files.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="textFileWriter-org.apache.edgent.topology.TStream-org.apache.edgent.function.Supplier-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>textFileWriter</h4> |
| <pre>public static <a href="../../../../../org/apache/edgent/topology/TSink.html" title="interface in org.apache.edgent.topology">TSink</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> textFileWriter(<a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> contents, |
| <a href="../../../../../org/apache/edgent/function/Supplier.html" title="interface in org.apache.edgent.function">Supplier</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> basePathname)</pre> |
| <div class="block">Write the contents of a stream to files. |
| <p> |
| The default <a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="class in org.apache.edgent.connectors.file"><code>FileWriterPolicy</code></a> is used. |
| <p> |
| This is the same as <code>textFileWriter(contents, basePathname, null)</code>. |
| <p> |
| Sample use: |
| <pre><code> |
| // write a stream of LogEvent to files, using the default |
| // file writer policy |
| String basePathname = "/myLogDir/LOG"; // yield LOG_YYYYMMDD_HHMMSS |
| TStream<MyLogEvent> events = ... |
| TStream<String> stringEvents = events.map(event -> event.toString()); |
| FileStreams.textFileWriter(stringEvents, () -> basePathname); |
| </code></pre></div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>contents</code> - the lines to write</dd> |
| <dd><code>basePathname</code> - the base pathname of the created files</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>a TSink</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="textFileWriter-org.apache.edgent.topology.TStream-org.apache.edgent.function.Supplier-org.apache.edgent.function.Supplier-"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>textFileWriter</h4> |
| <pre>public static <a href="../../../../../org/apache/edgent/topology/TSink.html" title="interface in org.apache.edgent.topology">TSink</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> textFileWriter(<a href="../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> contents, |
| <a href="../../../../../org/apache/edgent/function/Supplier.html" title="interface in org.apache.edgent.function">Supplier</a><<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> basePathname, |
| <a href="../../../../../org/apache/edgent/function/Supplier.html" title="interface in org.apache.edgent.function">Supplier</a><org.apache.edgent.connectors.file.runtime.IFileWriterPolicy<<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>>> policy)</pre> |
| <div class="block">Write the contents of a stream to files subject to the control |
| of a file writer policy. |
| <p> |
| A separate policy instance must be used for invocation. |
| A default <a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="class in org.apache.edgent.connectors.file"><code>FileWriterPolicy</code></a> is used if a policy is not specified. |
| <p> |
| Sample use: |
| <pre><code> |
| // write a stream of LogEvent to files using a policy of: |
| // no additional flush, 100 events per file, retain 5 files |
| IFileWriterPolicy<String> policy = new FileWriterPolicy<String>( |
| FileWriterFlushConfig.newImplicitConfig(), |
| FileWriterCycleConfig.newCountBasedConfig(100), |
| FileWriterRetentionConfig.newFileCountBasedConfig(5) |
| ); |
| String basePathname = "/myLogDir/LOG"; // yield LOG_YYYYMMDD_HHMMSS |
| TStream<MyLogEvent> events = ... |
| TStream<String> stringEvents = events.map(event -> event.toString()); |
| FileStreams.textFileWriter(stringEvents, () -> basePathname, () -> policy); |
| </code></pre></div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>contents</code> - the lines to write</dd> |
| <dd><code>basePathname</code> - the base pathname of the created files</dd> |
| <dd><code>policy</code> - the policy to use. may be null.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>a TSink</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="class in org.apache.edgent.connectors.file"><code>FileWriterPolicy</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| <!-- ========= END OF CLASS DATA ========= --> |
| <!-- ======= START OF BOTTOM NAVBAR ====== --> |
| <div class="bottomNav"><a name="navbar.bottom"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.bottom.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="class-use/FileStreams.html">Use</a></li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../../org/apache/edgent/connectors/file/CompressedFileWriterPolicy.html" title="class in org.apache.edgent.connectors.file"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../../org/apache/edgent/connectors/file/FileWriterCycleConfig.html" title="class in org.apache.edgent.connectors.file"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../index.html?org/apache/edgent/connectors/file/FileStreams.html" target="_top">Frames</a></li> |
| <li><a href="FileStreams.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_bottom"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| <p class="legalCopy"><small>Copyright © 2016–2017 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p> |
| </body> |
| </html> |