blob: da9b78354fbeba1b2b7647ea705a277a1dcea77a [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_71) on Tue May 17 00:28:45 UTC 2016 -->
<title>FileWriterPolicy (Quarks v0.4.0)</title>
<meta name="date" content="2016-05-17">
<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 (Quarks v0.4.0)";
}
}
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="../../../quarks/connectors/file/FileWriterFlushConfig.html" title="class in quarks.connectors.file"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../quarks/connectors/file/FileWriterRetentionConfig.html" title="class in quarks.connectors.file"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?quarks/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">quarks.connectors.file</div>
<h2 title="Class FileWriterPolicy" class="title">Class FileWriterPolicy&lt;T&gt;</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>quarks.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>quarks.connectors.file.runtime.IFileWriterPolicy&lt;T&gt;</dd>
</dl>
<hr>
<br>
<pre>public class <span class="typeNameLabel">FileWriterPolicy&lt;T&gt;</span>
extends java.lang.Object
implements quarks.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="../../../quarks/connectors/file/FileWriterFlushConfig.html" title="class in quarks.connectors.file"><code>FileWriterFlushConfig</code></a>,
<a href="../../../quarks/connectors/file/FileWriterCycleConfig.html" title="class in quarks.connectors.file"><code>FileWriterCycleConfig</code></a>,
<a href="../../../quarks/connectors/file/FileWriterRetentionConfig.html" title="class in quarks.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="../../../quarks/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="../../../quarks/connectors/file/FileWriterPolicy.html#FileWriterPolicy-quarks.connectors.file.FileWriterFlushConfig-quarks.connectors.file.FileWriterCycleConfig-quarks.connectors.file.FileWriterRetentionConfig-">FileWriterPolicy</a></span>(<a href="../../../quarks/connectors/file/FileWriterFlushConfig.html" title="class in quarks.connectors.file">FileWriterFlushConfig</a>&lt;<a href="../../../quarks/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;&nbsp;flushConfig,
<a href="../../../quarks/connectors/file/FileWriterCycleConfig.html" title="class in quarks.connectors.file">FileWriterCycleConfig</a>&lt;<a href="../../../quarks/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;&nbsp;cycleConfig,
<a href="../../../quarks/connectors/file/FileWriterRetentionConfig.html" title="class in quarks.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="../../../quarks/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>java.nio.file.Path</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../quarks/connectors/file/FileWriterPolicy.html#closeActiveFile-java.nio.file.Path-">closeActiveFile</a></span>(java.nio.file.Path&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="../../../quarks/connectors/file/FileWriterCycleConfig.html" title="class in quarks.connectors.file">FileWriterCycleConfig</a>&lt;<a href="../../../quarks/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../quarks/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="../../../quarks/connectors/file/FileWriterFlushConfig.html" title="class in quarks.connectors.file">FileWriterFlushConfig</a>&lt;<a href="../../../quarks/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../quarks/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>java.nio.file.Path</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../quarks/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="../../../quarks/connectors/file/FileWriterRetentionConfig.html" title="class in quarks.connectors.file">FileWriterRetentionConfig</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../quarks/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 java.nio.file.Path</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../quarks/connectors/file/FileWriterPolicy.html#hookGenerateFinalFilePath-java.nio.file.Path-">hookGenerateFinalFilePath</a></span>(java.nio.file.Path&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 java.nio.file.Path</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../quarks/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="../../../quarks/connectors/file/FileWriterPolicy.html#hookRenameFile-java.nio.file.Path-java.nio.file.Path-">hookRenameFile</a></span>(java.nio.file.Path&nbsp;activePath,
java.nio.file.Path&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="../../../quarks/connectors/file/FileWriterPolicy.html#initialize-java.lang.String-java.io.Flushable-java.io.Closeable-">initialize</a></span>(java.lang.String&nbsp;basePathname,
java.io.Flushable&nbsp;flushable,
java.io.Closeable&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="../../../quarks/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="../../../quarks/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>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../quarks/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="../../../quarks/connectors/file/FileWriterPolicy.html#wrote-T-long-">wrote</a></span>(<a href="../../../quarks/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.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait</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="../../../quarks/connectors/file/FileWriterPolicy.html#FileWriterPolicy-quarks.connectors.file.FileWriterFlushConfig-quarks.connectors.file.FileWriterCycleConfig-quarks.connectors.file.FileWriterRetentionConfig-"><code>FileWriterPolicy(FileWriterFlushConfig, FileWriterCycleConfig, FileWriterRetentionConfig)</code></a></div>
</li>
</ul>
<a name="FileWriterPolicy-quarks.connectors.file.FileWriterFlushConfig-quarks.connectors.file.FileWriterCycleConfig-quarks.connectors.file.FileWriterRetentionConfig-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>FileWriterPolicy</h4>
<pre>public&nbsp;FileWriterPolicy(<a href="../../../quarks/connectors/file/FileWriterFlushConfig.html" title="class in quarks.connectors.file">FileWriterFlushConfig</a>&lt;<a href="../../../quarks/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;&nbsp;flushConfig,
<a href="../../../quarks/connectors/file/FileWriterCycleConfig.html" title="class in quarks.connectors.file">FileWriterCycleConfig</a>&lt;<a href="../../../quarks/connectors/file/FileWriterPolicy.html" title="type parameter in FileWriterPolicy">T</a>&gt;&nbsp;cycleConfig,
<a href="../../../quarks/connectors/file/FileWriterRetentionConfig.html" title="class in quarks.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="../../../quarks/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>quarks.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>quarks.connectors.file.runtime.IFileWriterPolicy&lt;<a href="../../../quarks/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="../../../quarks/connectors/file/FileWriterFlushConfig.html" title="class in quarks.connectors.file">FileWriterFlushConfig</a>&lt;<a href="../../../quarks/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="../../../quarks/connectors/file/FileWriterCycleConfig.html" title="class in quarks.connectors.file">FileWriterCycleConfig</a>&lt;<a href="../../../quarks/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="../../../quarks/connectors/file/FileWriterRetentionConfig.html" title="class in quarks.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(java.lang.String&nbsp;basePathname,
java.io.Flushable&nbsp;flushable,
java.io.Closeable&nbsp;closeable)</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code>quarks.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>quarks.connectors.file.runtime.IFileWriterPolicy&lt;<a href="../../../quarks/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>
</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="../../../quarks/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>quarks.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>quarks.connectors.file.runtime.IFileWriterPolicy&lt;<a href="../../../quarks/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>quarks.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>quarks.connectors.file.runtime.IFileWriterPolicy&lt;<a href="../../../quarks/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>quarks.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>quarks.connectors.file.runtime.IFileWriterPolicy&lt;<a href="../../../quarks/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;java.nio.file.Path&nbsp;getNextActiveFilePath()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code>quarks.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="../../../quarks/connectors/file/FileStreams.html#directoryWatcher-quarks.topology.TopologyElement-quarks.function.Supplier-"><code>FileStreams.directoryWatcher(quarks.topology.TopologyElement, quarks.function.Supplier)</code></a></div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code>getNextActiveFilePath</code>&nbsp;in interface&nbsp;<code>quarks.connectors.file.runtime.IFileWriterPolicy&lt;<a href="../../../quarks/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;java.nio.file.Path&nbsp;closeActiveFile(java.nio.file.Path&nbsp;path)
throws java.io.IOException</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code>quarks.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>quarks.connectors.file.runtime.IFileWriterPolicy&lt;<a href="../../../quarks/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>java.io.IOException</code></dd>
</dl>
</li>
</ul>
<a name="hookGenerateFinalFilePath-java.nio.file.Path-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hookGenerateFinalFilePath</h4>
<pre>protected&nbsp;java.nio.file.Path&nbsp;hookGenerateFinalFilePath(java.nio.file.Path&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;java.nio.file.Path&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(java.nio.file.Path&nbsp;activePath,
java.nio.file.Path&nbsp;finalPath)
throws java.io.IOException</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="../../../quarks/connectors/file/FileWriterPolicy.html#hookGenerateNextActiveFilePath--"><code>hookGenerateNextActiveFilePath()</code></a>
and <a href="../../../quarks/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>java.io.IOException</code></dd>
</dl>
</li>
</ul>
<a name="toString--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>toString</h4>
<pre>public&nbsp;java.lang.String&nbsp;toString()</pre>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code>toString</code>&nbsp;in class&nbsp;<code>java.lang.Object</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 class="aboutLanguage"><a href="http://quarks.incubator.apache.org">Apache Quarks (incubating)</a></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../quarks/connectors/file/FileWriterFlushConfig.html" title="class in quarks.connectors.file"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../quarks/connectors/file/FileWriterRetentionConfig.html" title="class in quarks.connectors.file"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?quarks/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 &copy; 2016 The Apache Software Foundation. All Rights Reserved - d6cdfc6-20160517-0028</small></p>
</body>
</html>