blob: 46d8ac739fbcc930db7688c43444a76001ccd6ac [file] [log] [blame]
<!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>FileWriterPolicy (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="FileWriterPolicy (Apache Edgent (incubating) v1.2.0 API)";
}
}
catch(err) {
}
//-->
var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance 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/FileWriterPolicy.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/FileWriterFlushConfig.html" title="class in org.apache.edgent.connectors.file"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/edgent/connectors/file/FileWriterRetentionConfig.html" title="class in org.apache.edgent.connectors.file"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/edgent/connectors/file/FileWriterPolicy.html" target="_top">Frames</a></li>
<li><a href="FileWriterPolicy.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;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:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</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 FileWriterPolicy" class="title">Class FileWriterPolicy&lt;T&gt;</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.FileWriterPolicy&lt;T&gt;</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - stream tuple type</dd>
</dl>
<dl>
<dt>All Implemented Interfaces:</dt>
<dd>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy&lt;T&gt;</dd>
</dl>
<dl>
<dt>Direct Known Subclasses:</dt>
<dd><a href="../../../../../org/apache/edgent/connectors/file/CompressedFileWriterPolicy.html" title="class in org.apache.edgent.connectors.file">CompressedFileWriterPolicy</a></dd>
</dl>
<hr>
<br>
<pre>public class <span class="typeNameLabel">FileWriterPolicy&lt;T&gt;</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>
implements org.apache.edgent.connectors.file.runtime.IFileWriterPolicy&lt;T&gt;</pre>
<div class="block">A full featured <code>IFileWriterPolicy</code> implementation.
<p>
The policy implements strategies for:
<ul>
<li>Active and final file pathname control.</li>
<li>Active file flush control (via @{link FileWriterFlushControl})</li>
<li>Active file cycle control (when to close/finalize the current active file;
via @{link FileWriterCycleControl})</li>
<li>file retention control (via @{link FileWriterRetentionControl})</li>
</ul>
The policy is very configurable. If additional flexibility is required
the class can be extended and documented "hook" methods overridden,
or an alternative full implementation of <code>FileWriterPolicy</code> can be
created.
<p>
Sample use:
<pre>
FileWriterPolicy&lt;String&gt; policy = new FileWriterPolicy(
FileWriterFlushConfig.newImplicitConfig(),
FileWriterCycleConfig.newCountBasedConfig(1000),
FileWriterRetentionConfig.newCountBasedConfig(10));
String basePathname = "/some/directory/and_base_name";
TStream&lt;String&gt; streamToWrite = ...
FileStreams.textFileWriter(streamToWrite, () -&gt; basePathname, () -&gt; policy)
</pre></div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../org/apache/edgent/connectors/file/FileWriterFlushConfig.html" title="class in org.apache.edgent.connectors.file"><code>FileWriterFlushConfig</code></a>,
<a href="../../../../../org/apache/edgent/connectors/file/FileWriterCycleConfig.html" title="class in org.apache.edgent.connectors.file"><code>FileWriterCycleConfig</code></a>,
<a href="../../../../../org/apache/edgent/connectors/file/FileWriterRetentionConfig.html" title="class in org.apache.edgent.connectors.file"><code>FileWriterRetentionConfig</code></a></dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#FileWriterPolicy--">FileWriterPolicy</a></span>()</code>
<div class="block">Create a new file writer policy instance.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#FileWriterPolicy-org.apache.edgent.connectors.file.FileWriterFlushConfig-org.apache.edgent.connectors.file.FileWriterCycleConfig-org.apache.edgent.connectors.file.FileWriterRetentionConfig-">FileWriterPolicy</a></span>(<a href="../../../../../org/apache/edgent/connectors/file/FileWriterFlushConfig.html" title="class in org.apache.edgent.connectors.file">FileWriterFlushConfig</a>&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;&nbsp;flushConfig,
<a href="../../../../../org/apache/edgent/connectors/file/FileWriterCycleConfig.html" title="class in org.apache.edgent.connectors.file">FileWriterCycleConfig</a>&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;&nbsp;cycleConfig,
<a href="../../../../../org/apache/edgent/connectors/file/FileWriterRetentionConfig.html" title="class in org.apache.edgent.connectors.file">FileWriterRetentionConfig</a>&nbsp;retentionConfig)</code>
<div class="block">Create a new file writer policy instance.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== 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">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</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>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#close--">close</a></span>()</code>
<div class="block">Release any resources utilized by this policy.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code><a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#closeActiveFile-java.nio.file.Path-">closeActiveFile</a></span>(<a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a>&nbsp;path)</code>
<div class="block">Close the active file <code>path</code>.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/edgent/connectors/file/FileWriterCycleConfig.html" title="class in org.apache.edgent.connectors.file">FileWriterCycleConfig</a>&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#getCycleConfig--">getCycleConfig</a></span>()</code>
<div class="block">Get the policy's active file cycle configuration</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/edgent/connectors/file/FileWriterFlushConfig.html" title="class in org.apache.edgent.connectors.file">FileWriterFlushConfig</a>&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#getFlushConfig--">getFlushConfig</a></span>()</code>
<div class="block">Get the policy's active file flush configuration</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code><a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#getNextActiveFilePath--">getNextActiveFilePath</a></span>()</code>
<div class="block">Return the path for the next active file to write to.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/edgent/connectors/file/FileWriterRetentionConfig.html" title="class in org.apache.edgent.connectors.file">FileWriterRetentionConfig</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#getRetentionConfig--">getRetentionConfig</a></span>()</code>
<div class="block">Get the policy's retention configuration</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>protected <a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#hookGenerateFinalFilePath-java.nio.file.Path-">hookGenerateFinalFilePath</a></span>(<a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a>&nbsp;path)</code>
<div class="block">Generate the final file path for the active file.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>protected <a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#hookGenerateNextActiveFilePath--">hookGenerateNextActiveFilePath</a></span>()</code>
<div class="block">Generate the path for the next active file.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>protected void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#hookRenameFile-java.nio.file.Path-java.nio.file.Path-">hookRenameFile</a></span>(<a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a>&nbsp;activePath,
<a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a>&nbsp;finalPath)</code>
<div class="block">"Rename" the active file to the final path.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#initialize-java.lang.String-java.io.Flushable-java.io.Closeable-">initialize</a></span>(<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>&nbsp;basePathname,
<a href="http://docs.oracle.com/javase/8/docs/api/java/io/Flushable.html?is-external=true" title="class or interface in java.io">Flushable</a>&nbsp;flushable,
<a href="http://docs.oracle.com/javase/8/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</a>&nbsp;closeable)</code>
<div class="block">Initialize the policy with the base pathname of files to generate
and objects that can be
called to perform timer based flush or close (cycle) of the active file.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#shouldCycle--">shouldCycle</a></span>()</code>
<div class="block">Answers the question "should the active file be cycled?".</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#shouldFlush--">shouldFlush</a></span>()</code>
<div class="block">Answers the question "should the active file be flushed?".</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code><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/FileWriterPolicy.html#toString--">toString</a></span>()</code>&nbsp;</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#wrote-T-long-">wrote</a></span>(<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&nbsp;tuple,
long&nbsp;nbytes)</code>
<div class="block">Inform the policy of every tuple written to the active file.</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&nbsp;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#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">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="FileWriterPolicy--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>FileWriterPolicy</h4>
<pre>public&nbsp;FileWriterPolicy()</pre>
<div class="block">Create a new file writer policy instance.
<p>
The configuration is:
<ul>
<li>10 second time based active file flushing</li>
<li>1MB file size based active file cycling</li>
<li>10 file retention count</li>
</ul>
The active and final file pathname behavior is specified in
<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#FileWriterPolicy-org.apache.edgent.connectors.file.FileWriterFlushConfig-org.apache.edgent.connectors.file.FileWriterCycleConfig-org.apache.edgent.connectors.file.FileWriterRetentionConfig-"><code>FileWriterPolicy(FileWriterFlushConfig, FileWriterCycleConfig, FileWriterRetentionConfig)</code></a></div>
</li>
</ul>
<a name="FileWriterPolicy-org.apache.edgent.connectors.file.FileWriterFlushConfig-org.apache.edgent.connectors.file.FileWriterCycleConfig-org.apache.edgent.connectors.file.FileWriterRetentionConfig-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>FileWriterPolicy</h4>
<pre>public&nbsp;FileWriterPolicy(<a href="../../../../../org/apache/edgent/connectors/file/FileWriterFlushConfig.html" title="class in org.apache.edgent.connectors.file">FileWriterFlushConfig</a>&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;&nbsp;flushConfig,
<a href="../../../../../org/apache/edgent/connectors/file/FileWriterCycleConfig.html" title="class in org.apache.edgent.connectors.file">FileWriterCycleConfig</a>&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;&nbsp;cycleConfig,
<a href="../../../../../org/apache/edgent/connectors/file/FileWriterRetentionConfig.html" title="class in org.apache.edgent.connectors.file">FileWriterRetentionConfig</a>&nbsp;retentionConfig)</pre>
<div class="block">Create a new file writer policy instance.
<p>
<code>flushConfig</code>, <code>cycleConfig</code> and <code>retentionConfig</code>
specify the configuration of the various controls.
<p>
The active file and final file pathnames are based
on the <code>basePathname</code> received in
<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#initialize-java.lang.String-java.io.Flushable-java.io.Closeable-"><code>initialize(String, Flushable, Closeable)</code></a>.
<p>
Where <code>parent</code> and <code>baseLeafname</code> are the
parent path and file name respectively of <code>basePathname</code>:
<ul>
<li>the active file is <code>parent/.baseLeafname</code>"</li>
<li>final file names are <code>parent/baseLeafname_YYYYMMDD_HHMMSS[_&lt;n&gt;]</code>
where the optional <code>_&lt;n&gt;</code> suffix is only present if needed
to distinguish a file from the previously finalized file.
<code>&lt;n&gt;</code> starts at 1 and is monotonically incremented.
</li>
</ul></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>flushConfig</code> - active file flush control configuration</dd>
<dd><code>cycleConfig</code> - active file cycle control configuration</dd>
<dd><code>retentionConfig</code> - final file retention control configuration</dd>
</dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="close--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>close</h4>
<pre>public&nbsp;void&nbsp;close()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy</code></span></div>
<div class="block">Release any resources utilized by this policy.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code>close</code>&nbsp;in interface&nbsp;<code>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;</code></dd>
</dl>
</li>
</ul>
<a name="getFlushConfig--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getFlushConfig</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterFlushConfig.html" title="class in org.apache.edgent.connectors.file">FileWriterFlushConfig</a>&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;&nbsp;getFlushConfig()</pre>
<div class="block">Get the policy's active file flush configuration</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the flush configuration</dd>
</dl>
</li>
</ul>
<a name="getCycleConfig--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getCycleConfig</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterCycleConfig.html" title="class in org.apache.edgent.connectors.file">FileWriterCycleConfig</a>&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;&nbsp;getCycleConfig()</pre>
<div class="block">Get the policy's active file cycle configuration</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the cycle configuration</dd>
</dl>
</li>
</ul>
<a name="getRetentionConfig--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getRetentionConfig</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterRetentionConfig.html" title="class in org.apache.edgent.connectors.file">FileWriterRetentionConfig</a>&nbsp;getRetentionConfig()</pre>
<div class="block">Get the policy's retention configuration</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the retention configuration</dd>
</dl>
</li>
</ul>
<a name="initialize-java.lang.String-java.io.Flushable-java.io.Closeable-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>initialize</h4>
<pre>public&nbsp;void&nbsp;initialize(<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>&nbsp;basePathname,
<a href="http://docs.oracle.com/javase/8/docs/api/java/io/Flushable.html?is-external=true" title="class or interface in java.io">Flushable</a>&nbsp;flushable,
<a href="http://docs.oracle.com/javase/8/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</a>&nbsp;closeable)</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy</code></span></div>
<div class="block">Initialize the policy with the base pathname of files to generate
and objects that can be
called to perform timer based flush or close (cycle) of the active file.
<p>
Cycling involves finalizing the active file (getting it to its
final destination / pathname) and applying any retention policy.
<p>
The supplied <code>closeable</code> must close the active file's output stream
and then call <code>IFileWriterPolicy.closeActiveFile(Path)</code>.
<p>
For non-timer based strategies, the file writer generally triggers
flush and cycle processing
following a tuple write as informed by <code>IFileWriterPolicy.shouldCycle()</code> and
<code>IFileWriterPolicy.shouldFlush()</code>.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code>initialize</code>&nbsp;in interface&nbsp;<code>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;</code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>basePathname</code> - the directory and base leafname for final files</dd>
<dd><code>flushable</code> - function to perform the flush</dd>
<dd><code>closeable</code> - function to perform the close</dd>
</dl>
</li>
</ul>
<a name="wrote-java.lang.Object-long-">
<!-- -->
</a><a name="wrote-T-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>wrote</h4>
<pre>public&nbsp;void&nbsp;wrote(<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&nbsp;tuple,
long&nbsp;nbytes)</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy</code></span></div>
<div class="block">Inform the policy of every tuple written to the active file.
<p>
The policy can use this to update its state so that it
can answer the questions <code>IFileWriterPolicy.shouldFlush()</code>
and <code>IFileWriterPolicy.shouldCycle()</code> for count, size, or
tuple attribute based policies.
<p>
The policy can also use this to update its state
for implementing time based flush and cycle policies.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code>wrote</code>&nbsp;in interface&nbsp;<code>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;</code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>tuple</code> - the tuple written</dd>
<dd><code>nbytes</code> - the number of bytes written</dd>
</dl>
</li>
</ul>
<a name="shouldFlush--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>shouldFlush</h4>
<pre>public&nbsp;boolean&nbsp;shouldFlush()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy</code></span></div>
<div class="block">Answers the question "should the active file be flushed?".
<p>
The state is reset to false after this returns.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code>shouldFlush</code>&nbsp;in interface&nbsp;<code>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;</code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if the active file should be flushed</dd>
</dl>
</li>
</ul>
<a name="shouldCycle--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>shouldCycle</h4>
<pre>public&nbsp;boolean&nbsp;shouldCycle()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy</code></span></div>
<div class="block">Answers the question "should the active file be cycled?".
<p>
The state is reset to false after this returns.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code>shouldCycle</code>&nbsp;in interface&nbsp;<code>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;</code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if the active file should be cycled</dd>
</dl>
</li>
</ul>
<a name="getNextActiveFilePath--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getNextActiveFilePath</h4>
<pre>public&nbsp;<a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a>&nbsp;getNextActiveFilePath()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy</code></span></div>
<div class="block">Return the path for the next active file to write to.
<p>
If there was a current active file, <code>IFileWriterPolicy.closeActiveFile(Path)</code>
must be called prior to this.
<p>
The leafname must be a hidden file (<code>java.io.File.isHidden()==true</code>
to be compatible with a directory watcher
<a href="../../../../../org/apache/edgent/connectors/file/FileStreams.html#directoryWatcher-org.apache.edgent.topology.TopologyElement-org.apache.edgent.function.Supplier-"><code>FileStreams.directoryWatcher(org.apache.edgent.topology.TopologyElement, org.apache.edgent.function.Supplier)</code></a></div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code>getNextActiveFilePath</code>&nbsp;in interface&nbsp;<code>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;</code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>path for the active file</dd>
</dl>
</li>
</ul>
<a name="closeActiveFile-java.nio.file.Path-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>closeActiveFile</h4>
<pre>public&nbsp;<a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a>&nbsp;closeActiveFile(<a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a>&nbsp;path)
throws <a href="http://docs.oracle.com/javase/8/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy</code></span></div>
<div class="block">Close the active file <code>path</code>.
<p>
Generate the final path for the active file and
rename/move/copy it as necessary to be at that final path.
<p>
Apply the retention policy.
<p>
The active file's writer iostream must be closed prior to calling this.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code>closeActiveFile</code>&nbsp;in interface&nbsp;<code>org.apache.edgent.connectors.file.runtime.IFileWriterPolicy&lt;<a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;</code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>path</code> - the active file (from <code>IFileWriterPolicy.getNextActiveFilePath()</code>).</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the final path</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/8/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - on failure</dd>
</dl>
</li>
</ul>
<a name="hookGenerateFinalFilePath-java.nio.file.Path-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hookGenerateFinalFilePath</h4>
<pre>protected&nbsp;<a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a>&nbsp;hookGenerateFinalFilePath(<a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a>&nbsp;path)</pre>
<div class="block">Generate the final file path for the active file.
<p>
The default implementation yields:
<br>
final file names are <code>basePathname_YYYYMMDD_HHMMSS[_&lt;n&gt;]</code>
where the optional <code>_&lt;n&gt;</code> suffix is only present if needed
to distinguish a file from the previously finalized file.
<code>&lt;n&gt;</code> starts at 1 and is monitonically incremented.
<p>
This hook method can be overridden.
<p>
Note, the implementation must handle the unlikely, but happens
in tests, case where files are cycling very fast (multiple per sec)
and the retention config tosses some within that same second.
I.e., avoid generating final path sequences like:
<pre>
leaf_YYYYMMDD_103099
leaf_YYYYMMDD_103099_1
leaf_YYYYMMDD_103099_2
delete leaf_YYYYMMDD_103099 -- retention cnt was 2
leaf_YYYYMMDD_103099 // should be _3
</pre></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>path</code> - the active file path to finalize</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>final path for the file</dd>
</dl>
</li>
</ul>
<a name="hookGenerateNextActiveFilePath--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hookGenerateNextActiveFilePath</h4>
<pre>protected&nbsp;<a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a>&nbsp;hookGenerateNextActiveFilePath()</pre>
<div class="block">Generate the path for the next active file.
<p>
The default implementation yields <code>parent/.baseLeafname</code>
from <code>basePathname</code>.
<p>
This hook method can be overridden.
<p>
See <code>IFileWriterPolicy.getNextActiveFilePath()</code> regarding
constraints.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>path to use for the next active file.</dd>
</dl>
</li>
</ul>
<a name="hookRenameFile-java.nio.file.Path-java.nio.file.Path-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hookRenameFile</h4>
<pre>protected&nbsp;void&nbsp;hookRenameFile(<a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a>&nbsp;activePath,
<a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a>&nbsp;finalPath)
throws <a href="http://docs.oracle.com/javase/8/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
<div class="block">"Rename" the active file to the final path.
<p>
The default implementation uses <code>java.io.File.renameTo()</code>
and works for the default <a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#hookGenerateNextActiveFilePath--"><code>hookGenerateNextActiveFilePath()</code></a>
and <a href="../../../../../org/apache/edgent/connectors/file/FileWriterPolicy.html#hookGenerateFinalFilePath-java.nio.file.Path-"><code>hookGenerateFinalFilePath(Path path)</code></a> implementations.
<p>
This hook method can be overridden.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>activePath</code> - path of the active file</dd>
<dd><code>finalPath</code> - path to the final destination</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/8/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - on failure</dd>
</dl>
</li>
</ul>
<a name="toString--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>toString</h4>
<pre>public&nbsp;<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>&nbsp;toString()</pre>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><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></code>&nbsp;in class&nbsp;<code><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></code></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/FileWriterPolicy.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/FileWriterFlushConfig.html" title="class in org.apache.edgent.connectors.file"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/edgent/connectors/file/FileWriterRetentionConfig.html" title="class in org.apache.edgent.connectors.file"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/edgent/connectors/file/FileWriterPolicy.html" target="_top">Frames</a></li>
<li><a href="FileWriterPolicy.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;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:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</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 &#169; 2016&#x2013;2017 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>