hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [02/11] hbase-site git commit: Published site at a31458bdee4353d99682cb4e108e265ec45f8944.
Date Tue, 06 Nov 2018 14:53:57 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/bd4d10ee/testdevapidocs/src-html/org/apache/hadoop/hbase/wal/IOTestProvider.IOTestWriter.html
----------------------------------------------------------------------
diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/wal/IOTestProvider.IOTestWriter.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/wal/IOTestProvider.IOTestWriter.html
index 080823f..1b350c9 100644
--- a/testdevapidocs/src-html/org/apache/hadoop/hbase/wal/IOTestProvider.IOTestWriter.html
+++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/wal/IOTestProvider.IOTestWriter.html
@@ -35,265 +35,268 @@
 <span class="sourceLineNo">027</span>import java.util.Collection;<a name="line.27"></a>
 <span class="sourceLineNo">028</span>import java.util.Collections;<a name="line.28"></a>
 <span class="sourceLineNo">029</span>import java.util.List;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.conf.Configuration;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.fs.FileSystem;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.fs.Path;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.HConstants;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.client.RegionInfo;<a name="line.34"></a>
-<span class="sourceLineNo">035</span>// imports for things that haven't moved from regionserver.wal yet.<a name="line.35"></a>
-<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.regionserver.wal.FSHLog;<a name="line.36"></a>
-<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.regionserver.wal.ProtobufLogWriter;<a name="line.37"></a>
-<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;<a name="line.38"></a>
-<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.util.CommonFSUtils;<a name="line.39"></a>
-<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.wal.WAL.Entry;<a name="line.40"></a>
-<span class="sourceLineNo">041</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.41"></a>
-<span class="sourceLineNo">042</span>import org.slf4j.Logger;<a name="line.42"></a>
-<span class="sourceLineNo">043</span>import org.slf4j.LoggerFactory;<a name="line.43"></a>
-<span class="sourceLineNo">044</span><a name="line.44"></a>
-<span class="sourceLineNo">045</span>/**<a name="line.45"></a>
-<span class="sourceLineNo">046</span> * A WAL Provider that returns a single thread safe WAL that optionally can skip parts of our normal<a name="line.46"></a>
-<span class="sourceLineNo">047</span> * interactions with HDFS.<a name="line.47"></a>
-<span class="sourceLineNo">048</span> * &lt;p&gt;<a name="line.48"></a>
-<span class="sourceLineNo">049</span> * This implementation picks a directory in HDFS based on the same mechanisms as the<a name="line.49"></a>
-<span class="sourceLineNo">050</span> * {@link FSHLogProvider}. Users can configure how much interaction we have with HDFS with the<a name="line.50"></a>
-<span class="sourceLineNo">051</span> * configuration property "hbase.wal.iotestprovider.operations". The value should be a comma<a name="line.51"></a>
-<span class="sourceLineNo">052</span> * separated list of allowed operations:<a name="line.52"></a>
-<span class="sourceLineNo">053</span> * &lt;ul&gt;<a name="line.53"></a>
-<span class="sourceLineNo">054</span> * &lt;li&gt;&lt;em&gt;append&lt;/em&gt; : edits will be written to the underlying filesystem&lt;/li&gt;<a name="line.54"></a>
-<span class="sourceLineNo">055</span> * &lt;li&gt;&lt;em&gt;sync&lt;/em&gt; : wal syncs will result in hflush calls&lt;/li&gt;<a name="line.55"></a>
-<span class="sourceLineNo">056</span> * &lt;li&gt;&lt;em&gt;fileroll&lt;/em&gt; : roll requests will result in creating a new file on the underlying<a name="line.56"></a>
-<span class="sourceLineNo">057</span> * filesystem.&lt;/li&gt;<a name="line.57"></a>
-<span class="sourceLineNo">058</span> * &lt;/ul&gt;<a name="line.58"></a>
-<span class="sourceLineNo">059</span> * Additionally, the special cases "all" and "none" are recognized. If ommited, the value defaults<a name="line.59"></a>
-<span class="sourceLineNo">060</span> * to "all." Behavior is undefined if "all" or "none" are paired with additional values. Behavior is<a name="line.60"></a>
-<span class="sourceLineNo">061</span> * also undefined if values not listed above are included.<a name="line.61"></a>
-<span class="sourceLineNo">062</span> * &lt;p&gt;<a name="line.62"></a>
-<span class="sourceLineNo">063</span> * Only those operations listed will occur between the returned WAL and HDFS. All others will be<a name="line.63"></a>
-<span class="sourceLineNo">064</span> * no-ops.<a name="line.64"></a>
-<span class="sourceLineNo">065</span> * &lt;p&gt;<a name="line.65"></a>
-<span class="sourceLineNo">066</span> * Note that in the case of allowing "append" operations but not allowing "fileroll", the returned<a name="line.66"></a>
-<span class="sourceLineNo">067</span> * WAL will just keep writing to the same file. This won't avoid all costs associated with file<a name="line.67"></a>
-<span class="sourceLineNo">068</span> * management over time, becaue the data set size may result in additional HDFS block allocations.<a name="line.68"></a>
-<span class="sourceLineNo">069</span> */<a name="line.69"></a>
-<span class="sourceLineNo">070</span>@InterfaceAudience.Private<a name="line.70"></a>
-<span class="sourceLineNo">071</span>public class IOTestProvider implements WALProvider {<a name="line.71"></a>
-<span class="sourceLineNo">072</span>  private static final Logger LOG = LoggerFactory.getLogger(IOTestProvider.class);<a name="line.72"></a>
-<span class="sourceLineNo">073</span><a name="line.73"></a>
-<span class="sourceLineNo">074</span>  private static final String ALLOWED_OPERATIONS = "hbase.wal.iotestprovider.operations";<a name="line.74"></a>
-<span class="sourceLineNo">075</span>  private enum AllowedOperations {<a name="line.75"></a>
-<span class="sourceLineNo">076</span>    all,<a name="line.76"></a>
-<span class="sourceLineNo">077</span>    append,<a name="line.77"></a>
-<span class="sourceLineNo">078</span>    sync,<a name="line.78"></a>
-<span class="sourceLineNo">079</span>    fileroll,<a name="line.79"></a>
-<span class="sourceLineNo">080</span>    none<a name="line.80"></a>
-<span class="sourceLineNo">081</span>  }<a name="line.81"></a>
-<span class="sourceLineNo">082</span><a name="line.82"></a>
-<span class="sourceLineNo">083</span>  private WALFactory factory;<a name="line.83"></a>
+<span class="sourceLineNo">030</span>import java.util.concurrent.atomic.AtomicBoolean;<a name="line.30"></a>
+<span class="sourceLineNo">031</span><a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.conf.Configuration;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.fs.FileSystem;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.fs.Path;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.HConstants;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.client.RegionInfo;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>// imports for things that haven't moved from regionserver.wal yet.<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.regionserver.wal.FSHLog;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.regionserver.wal.ProtobufLogWriter;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;<a name="line.40"></a>
+<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.util.CommonFSUtils;<a name="line.41"></a>
+<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.wal.WAL.Entry;<a name="line.42"></a>
+<span class="sourceLineNo">043</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.43"></a>
+<span class="sourceLineNo">044</span>import org.slf4j.Logger;<a name="line.44"></a>
+<span class="sourceLineNo">045</span>import org.slf4j.LoggerFactory;<a name="line.45"></a>
+<span class="sourceLineNo">046</span><a name="line.46"></a>
+<span class="sourceLineNo">047</span>/**<a name="line.47"></a>
+<span class="sourceLineNo">048</span> * A WAL Provider that returns a single thread safe WAL that optionally can skip parts of our normal<a name="line.48"></a>
+<span class="sourceLineNo">049</span> * interactions with HDFS.<a name="line.49"></a>
+<span class="sourceLineNo">050</span> * &lt;p&gt;<a name="line.50"></a>
+<span class="sourceLineNo">051</span> * This implementation picks a directory in HDFS based on the same mechanisms as the<a name="line.51"></a>
+<span class="sourceLineNo">052</span> * {@link FSHLogProvider}. Users can configure how much interaction we have with HDFS with the<a name="line.52"></a>
+<span class="sourceLineNo">053</span> * configuration property "hbase.wal.iotestprovider.operations". The value should be a comma<a name="line.53"></a>
+<span class="sourceLineNo">054</span> * separated list of allowed operations:<a name="line.54"></a>
+<span class="sourceLineNo">055</span> * &lt;ul&gt;<a name="line.55"></a>
+<span class="sourceLineNo">056</span> * &lt;li&gt;&lt;em&gt;append&lt;/em&gt; : edits will be written to the underlying filesystem&lt;/li&gt;<a name="line.56"></a>
+<span class="sourceLineNo">057</span> * &lt;li&gt;&lt;em&gt;sync&lt;/em&gt; : wal syncs will result in hflush calls&lt;/li&gt;<a name="line.57"></a>
+<span class="sourceLineNo">058</span> * &lt;li&gt;&lt;em&gt;fileroll&lt;/em&gt; : roll requests will result in creating a new file on the underlying<a name="line.58"></a>
+<span class="sourceLineNo">059</span> * filesystem.&lt;/li&gt;<a name="line.59"></a>
+<span class="sourceLineNo">060</span> * &lt;/ul&gt;<a name="line.60"></a>
+<span class="sourceLineNo">061</span> * Additionally, the special cases "all" and "none" are recognized. If ommited, the value defaults<a name="line.61"></a>
+<span class="sourceLineNo">062</span> * to "all." Behavior is undefined if "all" or "none" are paired with additional values. Behavior is<a name="line.62"></a>
+<span class="sourceLineNo">063</span> * also undefined if values not listed above are included.<a name="line.63"></a>
+<span class="sourceLineNo">064</span> * &lt;p&gt;<a name="line.64"></a>
+<span class="sourceLineNo">065</span> * Only those operations listed will occur between the returned WAL and HDFS. All others will be<a name="line.65"></a>
+<span class="sourceLineNo">066</span> * no-ops.<a name="line.66"></a>
+<span class="sourceLineNo">067</span> * &lt;p&gt;<a name="line.67"></a>
+<span class="sourceLineNo">068</span> * Note that in the case of allowing "append" operations but not allowing "fileroll", the returned<a name="line.68"></a>
+<span class="sourceLineNo">069</span> * WAL will just keep writing to the same file. This won't avoid all costs associated with file<a name="line.69"></a>
+<span class="sourceLineNo">070</span> * management over time, becaue the data set size may result in additional HDFS block allocations.<a name="line.70"></a>
+<span class="sourceLineNo">071</span> */<a name="line.71"></a>
+<span class="sourceLineNo">072</span>@InterfaceAudience.Private<a name="line.72"></a>
+<span class="sourceLineNo">073</span>public class IOTestProvider implements WALProvider {<a name="line.73"></a>
+<span class="sourceLineNo">074</span>  private static final Logger LOG = LoggerFactory.getLogger(IOTestProvider.class);<a name="line.74"></a>
+<span class="sourceLineNo">075</span><a name="line.75"></a>
+<span class="sourceLineNo">076</span>  private static final String ALLOWED_OPERATIONS = "hbase.wal.iotestprovider.operations";<a name="line.76"></a>
+<span class="sourceLineNo">077</span>  private enum AllowedOperations {<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    all,<a name="line.78"></a>
+<span class="sourceLineNo">079</span>    append,<a name="line.79"></a>
+<span class="sourceLineNo">080</span>    sync,<a name="line.80"></a>
+<span class="sourceLineNo">081</span>    fileroll,<a name="line.81"></a>
+<span class="sourceLineNo">082</span>    none<a name="line.82"></a>
+<span class="sourceLineNo">083</span>  }<a name="line.83"></a>
 <span class="sourceLineNo">084</span><a name="line.84"></a>
-<span class="sourceLineNo">085</span>  private Configuration conf;<a name="line.85"></a>
+<span class="sourceLineNo">085</span>  private WALFactory factory;<a name="line.85"></a>
 <span class="sourceLineNo">086</span><a name="line.86"></a>
-<span class="sourceLineNo">087</span>  private volatile FSHLog log;<a name="line.87"></a>
+<span class="sourceLineNo">087</span>  private Configuration conf;<a name="line.87"></a>
 <span class="sourceLineNo">088</span><a name="line.88"></a>
-<span class="sourceLineNo">089</span>  private String providerId;<a name="line.89"></a>
+<span class="sourceLineNo">089</span>  private volatile FSHLog log;<a name="line.89"></a>
 <span class="sourceLineNo">090</span><a name="line.90"></a>
-<span class="sourceLineNo">091</span>  private List&lt;WALActionsListener&gt; listeners = new ArrayList&lt;&gt;();<a name="line.91"></a>
-<span class="sourceLineNo">092</span>  /**<a name="line.92"></a>
-<span class="sourceLineNo">093</span>   * @param factory factory that made us, identity used for FS layout. may not be null<a name="line.93"></a>
-<span class="sourceLineNo">094</span>   * @param conf may not be null<a name="line.94"></a>
-<span class="sourceLineNo">095</span>   * @param providerId differentiate between providers from one facotry, used for FS layout. may be<a name="line.95"></a>
-<span class="sourceLineNo">096</span>   *                   null<a name="line.96"></a>
-<span class="sourceLineNo">097</span>   */<a name="line.97"></a>
-<span class="sourceLineNo">098</span>  @Override<a name="line.98"></a>
-<span class="sourceLineNo">099</span>  public void init(WALFactory factory, Configuration conf, String providerId) throws IOException {<a name="line.99"></a>
-<span class="sourceLineNo">100</span>    if (factory != null) {<a name="line.100"></a>
-<span class="sourceLineNo">101</span>      throw new IllegalStateException("WALProvider.init should only be called once.");<a name="line.101"></a>
-<span class="sourceLineNo">102</span>    }<a name="line.102"></a>
-<span class="sourceLineNo">103</span>    this.factory = factory;<a name="line.103"></a>
-<span class="sourceLineNo">104</span>    this.conf = conf;<a name="line.104"></a>
-<span class="sourceLineNo">105</span>    this.providerId = providerId != null ? providerId : DEFAULT_PROVIDER_ID;<a name="line.105"></a>
-<span class="sourceLineNo">106</span>  }<a name="line.106"></a>
-<span class="sourceLineNo">107</span><a name="line.107"></a>
-<span class="sourceLineNo">108</span>  @Override<a name="line.108"></a>
-<span class="sourceLineNo">109</span>  public List&lt;WAL&gt; getWALs() {<a name="line.109"></a>
-<span class="sourceLineNo">110</span>    return Collections.singletonList(log);<a name="line.110"></a>
-<span class="sourceLineNo">111</span>  }<a name="line.111"></a>
-<span class="sourceLineNo">112</span><a name="line.112"></a>
-<span class="sourceLineNo">113</span>  private FSHLog createWAL() throws IOException {<a name="line.113"></a>
-<span class="sourceLineNo">114</span>    String logPrefix = factory.factoryId + WAL_FILE_NAME_DELIMITER + providerId;<a name="line.114"></a>
-<span class="sourceLineNo">115</span>    return new IOTestWAL(CommonFSUtils.getWALFileSystem(conf), CommonFSUtils.getWALRootDir(conf),<a name="line.115"></a>
-<span class="sourceLineNo">116</span>        AbstractFSWALProvider.getWALDirectoryName(factory.factoryId),<a name="line.116"></a>
-<span class="sourceLineNo">117</span>        HConstants.HREGION_OLDLOGDIR_NAME, conf, listeners, true, logPrefix,<a name="line.117"></a>
-<span class="sourceLineNo">118</span>        META_WAL_PROVIDER_ID.equals(providerId) ? META_WAL_PROVIDER_ID : null);<a name="line.118"></a>
-<span class="sourceLineNo">119</span>  }<a name="line.119"></a>
-<span class="sourceLineNo">120</span><a name="line.120"></a>
-<span class="sourceLineNo">121</span>  @Override<a name="line.121"></a>
-<span class="sourceLineNo">122</span>  public WAL getWAL(RegionInfo region) throws IOException {<a name="line.122"></a>
-<span class="sourceLineNo">123</span>    FSHLog log = this.log;<a name="line.123"></a>
-<span class="sourceLineNo">124</span>    if (log != null) {<a name="line.124"></a>
-<span class="sourceLineNo">125</span>      return log;<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    }<a name="line.126"></a>
-<span class="sourceLineNo">127</span>    synchronized (this) {<a name="line.127"></a>
-<span class="sourceLineNo">128</span>      log = this.log;<a name="line.128"></a>
-<span class="sourceLineNo">129</span>      if (log == null) {<a name="line.129"></a>
-<span class="sourceLineNo">130</span>        log = createWAL();<a name="line.130"></a>
-<span class="sourceLineNo">131</span>        this.log = log;<a name="line.131"></a>
-<span class="sourceLineNo">132</span>      }<a name="line.132"></a>
-<span class="sourceLineNo">133</span>    }<a name="line.133"></a>
-<span class="sourceLineNo">134</span>    return log;<a name="line.134"></a>
-<span class="sourceLineNo">135</span>  }<a name="line.135"></a>
-<span class="sourceLineNo">136</span><a name="line.136"></a>
-<span class="sourceLineNo">137</span>  @Override<a name="line.137"></a>
-<span class="sourceLineNo">138</span>  public void close() throws IOException {<a name="line.138"></a>
-<span class="sourceLineNo">139</span>    FSHLog log = this.log;<a name="line.139"></a>
-<span class="sourceLineNo">140</span>    if (log != null) {<a name="line.140"></a>
-<span class="sourceLineNo">141</span>      log.close();<a name="line.141"></a>
-<span class="sourceLineNo">142</span>    }<a name="line.142"></a>
-<span class="sourceLineNo">143</span>  }<a name="line.143"></a>
-<span class="sourceLineNo">144</span><a name="line.144"></a>
-<span class="sourceLineNo">145</span>  @Override<a name="line.145"></a>
-<span class="sourceLineNo">146</span>  public void shutdown() throws IOException {<a name="line.146"></a>
-<span class="sourceLineNo">147</span>    FSHLog log = this.log;<a name="line.147"></a>
-<span class="sourceLineNo">148</span>    if (log != null) {<a name="line.148"></a>
-<span class="sourceLineNo">149</span>      log.shutdown();<a name="line.149"></a>
-<span class="sourceLineNo">150</span>    }<a name="line.150"></a>
-<span class="sourceLineNo">151</span>  }<a name="line.151"></a>
-<span class="sourceLineNo">152</span><a name="line.152"></a>
-<span class="sourceLineNo">153</span>  private static class IOTestWAL extends FSHLog {<a name="line.153"></a>
-<span class="sourceLineNo">154</span><a name="line.154"></a>
-<span class="sourceLineNo">155</span>    private final boolean doFileRolls;<a name="line.155"></a>
-<span class="sourceLineNo">156</span><a name="line.156"></a>
-<span class="sourceLineNo">157</span>    // Used to differntiate between roll calls before and after we finish construction.<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    private final boolean initialized;<a name="line.158"></a>
+<span class="sourceLineNo">091</span>  private String providerId;<a name="line.91"></a>
+<span class="sourceLineNo">092</span>  protected AtomicBoolean initialized = new AtomicBoolean(false);<a name="line.92"></a>
+<span class="sourceLineNo">093</span><a name="line.93"></a>
+<span class="sourceLineNo">094</span>  private List&lt;WALActionsListener&gt; listeners = new ArrayList&lt;&gt;();<a name="line.94"></a>
+<span class="sourceLineNo">095</span>  /**<a name="line.95"></a>
+<span class="sourceLineNo">096</span>   * @param factory factory that made us, identity used for FS layout. may not be null<a name="line.96"></a>
+<span class="sourceLineNo">097</span>   * @param conf may not be null<a name="line.97"></a>
+<span class="sourceLineNo">098</span>   * @param providerId differentiate between providers from one facotry, used for FS layout. may be<a name="line.98"></a>
+<span class="sourceLineNo">099</span>   *                   null<a name="line.99"></a>
+<span class="sourceLineNo">100</span>   */<a name="line.100"></a>
+<span class="sourceLineNo">101</span>  @Override<a name="line.101"></a>
+<span class="sourceLineNo">102</span>  public void init(WALFactory factory, Configuration conf, String providerId) throws IOException {<a name="line.102"></a>
+<span class="sourceLineNo">103</span>    if (!initialized.compareAndSet(false, true)) {<a name="line.103"></a>
+<span class="sourceLineNo">104</span>      throw new IllegalStateException("WALProvider.init should only be called once.");<a name="line.104"></a>
+<span class="sourceLineNo">105</span>    }<a name="line.105"></a>
+<span class="sourceLineNo">106</span>    this.factory = factory;<a name="line.106"></a>
+<span class="sourceLineNo">107</span>    this.conf = conf;<a name="line.107"></a>
+<span class="sourceLineNo">108</span>    this.providerId = providerId != null ? providerId : DEFAULT_PROVIDER_ID;<a name="line.108"></a>
+<span class="sourceLineNo">109</span>  }<a name="line.109"></a>
+<span class="sourceLineNo">110</span><a name="line.110"></a>
+<span class="sourceLineNo">111</span>  @Override<a name="line.111"></a>
+<span class="sourceLineNo">112</span>  public List&lt;WAL&gt; getWALs() {<a name="line.112"></a>
+<span class="sourceLineNo">113</span>    return Collections.singletonList(log);<a name="line.113"></a>
+<span class="sourceLineNo">114</span>  }<a name="line.114"></a>
+<span class="sourceLineNo">115</span><a name="line.115"></a>
+<span class="sourceLineNo">116</span>  private FSHLog createWAL() throws IOException {<a name="line.116"></a>
+<span class="sourceLineNo">117</span>    String logPrefix = factory.factoryId + WAL_FILE_NAME_DELIMITER + providerId;<a name="line.117"></a>
+<span class="sourceLineNo">118</span>    return new IOTestWAL(CommonFSUtils.getWALFileSystem(conf), CommonFSUtils.getWALRootDir(conf),<a name="line.118"></a>
+<span class="sourceLineNo">119</span>        AbstractFSWALProvider.getWALDirectoryName(factory.factoryId),<a name="line.119"></a>
+<span class="sourceLineNo">120</span>        HConstants.HREGION_OLDLOGDIR_NAME, conf, listeners, true, logPrefix,<a name="line.120"></a>
+<span class="sourceLineNo">121</span>        META_WAL_PROVIDER_ID.equals(providerId) ? META_WAL_PROVIDER_ID : null);<a name="line.121"></a>
+<span class="sourceLineNo">122</span>  }<a name="line.122"></a>
+<span class="sourceLineNo">123</span><a name="line.123"></a>
+<span class="sourceLineNo">124</span>  @Override<a name="line.124"></a>
+<span class="sourceLineNo">125</span>  public WAL getWAL(RegionInfo region) throws IOException {<a name="line.125"></a>
+<span class="sourceLineNo">126</span>    FSHLog log = this.log;<a name="line.126"></a>
+<span class="sourceLineNo">127</span>    if (log != null) {<a name="line.127"></a>
+<span class="sourceLineNo">128</span>      return log;<a name="line.128"></a>
+<span class="sourceLineNo">129</span>    }<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    synchronized (this) {<a name="line.130"></a>
+<span class="sourceLineNo">131</span>      log = this.log;<a name="line.131"></a>
+<span class="sourceLineNo">132</span>      if (log == null) {<a name="line.132"></a>
+<span class="sourceLineNo">133</span>        log = createWAL();<a name="line.133"></a>
+<span class="sourceLineNo">134</span>        this.log = log;<a name="line.134"></a>
+<span class="sourceLineNo">135</span>      }<a name="line.135"></a>
+<span class="sourceLineNo">136</span>    }<a name="line.136"></a>
+<span class="sourceLineNo">137</span>    return log;<a name="line.137"></a>
+<span class="sourceLineNo">138</span>  }<a name="line.138"></a>
+<span class="sourceLineNo">139</span><a name="line.139"></a>
+<span class="sourceLineNo">140</span>  @Override<a name="line.140"></a>
+<span class="sourceLineNo">141</span>  public void close() throws IOException {<a name="line.141"></a>
+<span class="sourceLineNo">142</span>    FSHLog log = this.log;<a name="line.142"></a>
+<span class="sourceLineNo">143</span>    if (log != null) {<a name="line.143"></a>
+<span class="sourceLineNo">144</span>      log.close();<a name="line.144"></a>
+<span class="sourceLineNo">145</span>    }<a name="line.145"></a>
+<span class="sourceLineNo">146</span>  }<a name="line.146"></a>
+<span class="sourceLineNo">147</span><a name="line.147"></a>
+<span class="sourceLineNo">148</span>  @Override<a name="line.148"></a>
+<span class="sourceLineNo">149</span>  public void shutdown() throws IOException {<a name="line.149"></a>
+<span class="sourceLineNo">150</span>    FSHLog log = this.log;<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    if (log != null) {<a name="line.151"></a>
+<span class="sourceLineNo">152</span>      log.shutdown();<a name="line.152"></a>
+<span class="sourceLineNo">153</span>    }<a name="line.153"></a>
+<span class="sourceLineNo">154</span>  }<a name="line.154"></a>
+<span class="sourceLineNo">155</span><a name="line.155"></a>
+<span class="sourceLineNo">156</span>  private static class IOTestWAL extends FSHLog {<a name="line.156"></a>
+<span class="sourceLineNo">157</span><a name="line.157"></a>
+<span class="sourceLineNo">158</span>    private final boolean doFileRolls;<a name="line.158"></a>
 <span class="sourceLineNo">159</span><a name="line.159"></a>
-<span class="sourceLineNo">160</span>    /**<a name="line.160"></a>
-<span class="sourceLineNo">161</span>     * Create an edit log at the given &lt;code&gt;dir&lt;/code&gt; location.<a name="line.161"></a>
-<span class="sourceLineNo">162</span>     *<a name="line.162"></a>
-<span class="sourceLineNo">163</span>     * You should never have to load an existing log. If there is a log at<a name="line.163"></a>
-<span class="sourceLineNo">164</span>     * startup, it should have already been processed and deleted by the time the<a name="line.164"></a>
-<span class="sourceLineNo">165</span>     * WAL object is started up.<a name="line.165"></a>
-<span class="sourceLineNo">166</span>     *<a name="line.166"></a>
-<span class="sourceLineNo">167</span>     * @param fs filesystem handle<a name="line.167"></a>
-<span class="sourceLineNo">168</span>     * @param rootDir path to where logs and oldlogs<a name="line.168"></a>
-<span class="sourceLineNo">169</span>     * @param logDir dir where wals are stored<a name="line.169"></a>
-<span class="sourceLineNo">170</span>     * @param archiveDir dir where wals are archived<a name="line.170"></a>
-<span class="sourceLineNo">171</span>     * @param conf configuration to use<a name="line.171"></a>
-<span class="sourceLineNo">172</span>     * @param listeners Listeners on WAL events. Listeners passed here will<a name="line.172"></a>
-<span class="sourceLineNo">173</span>     * be registered before we do anything else; e.g. the<a name="line.173"></a>
-<span class="sourceLineNo">174</span>     * Constructor {@link #rollWriter()}.<a name="line.174"></a>
-<span class="sourceLineNo">175</span>     * @param failIfWALExists If true IOException will be thrown if files related to this wal<a name="line.175"></a>
-<span class="sourceLineNo">176</span>     *        already exist.<a name="line.176"></a>
-<span class="sourceLineNo">177</span>     * @param prefix should always be hostname and port in distributed env and<a name="line.177"></a>
-<span class="sourceLineNo">178</span>     *        it will be URL encoded before being used.<a name="line.178"></a>
-<span class="sourceLineNo">179</span>     *        If prefix is null, "wal" will be used<a name="line.179"></a>
-<span class="sourceLineNo">180</span>     * @param suffix will be url encoded. null is treated as empty. non-empty must start with<a name="line.180"></a>
-<span class="sourceLineNo">181</span>     *        {@link AbstractFSWALProvider#WAL_FILE_NAME_DELIMITER}<a name="line.181"></a>
-<span class="sourceLineNo">182</span>     * @throws IOException<a name="line.182"></a>
-<span class="sourceLineNo">183</span>     */<a name="line.183"></a>
-<span class="sourceLineNo">184</span>    public IOTestWAL(final FileSystem fs, final Path rootDir, final String logDir,<a name="line.184"></a>
-<span class="sourceLineNo">185</span>        final String archiveDir, final Configuration conf,<a name="line.185"></a>
-<span class="sourceLineNo">186</span>        final List&lt;WALActionsListener&gt; listeners,<a name="line.186"></a>
-<span class="sourceLineNo">187</span>        final boolean failIfWALExists, final String prefix, final String suffix)<a name="line.187"></a>
-<span class="sourceLineNo">188</span>        throws IOException {<a name="line.188"></a>
-<span class="sourceLineNo">189</span>      super(fs, rootDir, logDir, archiveDir, conf, listeners, failIfWALExists, prefix, suffix);<a name="line.189"></a>
-<span class="sourceLineNo">190</span>      Collection&lt;String&gt; operations = conf.getStringCollection(ALLOWED_OPERATIONS);<a name="line.190"></a>
-<span class="sourceLineNo">191</span>      doFileRolls = operations.isEmpty() || operations.contains(AllowedOperations.all.name()) ||<a name="line.191"></a>
-<span class="sourceLineNo">192</span>          operations.contains(AllowedOperations.fileroll.name());<a name="line.192"></a>
-<span class="sourceLineNo">193</span>      initialized = true;<a name="line.193"></a>
-<span class="sourceLineNo">194</span>      LOG.info("Initialized with file rolling " + (doFileRolls ? "enabled" : "disabled"));<a name="line.194"></a>
-<span class="sourceLineNo">195</span>    }<a name="line.195"></a>
-<span class="sourceLineNo">196</span><a name="line.196"></a>
-<span class="sourceLineNo">197</span>    private Writer noRollsWriter;<a name="line.197"></a>
-<span class="sourceLineNo">198</span><a name="line.198"></a>
-<span class="sourceLineNo">199</span>    // creatWriterInstance is where the new pipeline is set up for doing file rolls<a name="line.199"></a>
-<span class="sourceLineNo">200</span>    // if we are skipping it, just keep returning the same writer.<a name="line.200"></a>
-<span class="sourceLineNo">201</span>    @Override<a name="line.201"></a>
-<span class="sourceLineNo">202</span>    protected Writer createWriterInstance(final Path path) throws IOException {<a name="line.202"></a>
-<span class="sourceLineNo">203</span>      // we get called from the FSHLog constructor (!); always roll in this case since<a name="line.203"></a>
-<span class="sourceLineNo">204</span>      // we don't know yet if we're supposed to generally roll and<a name="line.204"></a>
-<span class="sourceLineNo">205</span>      // we need an initial file in the case of doing appends but no rolls.<a name="line.205"></a>
-<span class="sourceLineNo">206</span>      if (!initialized || doFileRolls) {<a name="line.206"></a>
-<span class="sourceLineNo">207</span>        LOG.info("creating new writer instance.");<a name="line.207"></a>
-<span class="sourceLineNo">208</span>        final ProtobufLogWriter writer = new IOTestWriter();<a name="line.208"></a>
-<span class="sourceLineNo">209</span>        try {<a name="line.209"></a>
-<span class="sourceLineNo">210</span>          writer.init(fs, path, conf, false, this.blocksize);<a name="line.210"></a>
-<span class="sourceLineNo">211</span>        } catch (CommonFSUtils.StreamLacksCapabilityException exception) {<a name="line.211"></a>
-<span class="sourceLineNo">212</span>          throw new IOException("Can't create writer instance because underlying FileSystem " +<a name="line.212"></a>
-<span class="sourceLineNo">213</span>              "doesn't support needed stream capabilities.", exception);<a name="line.213"></a>
-<span class="sourceLineNo">214</span>        }<a name="line.214"></a>
-<span class="sourceLineNo">215</span>        if (!initialized) {<a name="line.215"></a>
-<span class="sourceLineNo">216</span>          LOG.info("storing initial writer instance in case file rolling isn't allowed.");<a name="line.216"></a>
-<span class="sourceLineNo">217</span>          noRollsWriter = writer;<a name="line.217"></a>
-<span class="sourceLineNo">218</span>        }<a name="line.218"></a>
-<span class="sourceLineNo">219</span>        return writer;<a name="line.219"></a>
-<span class="sourceLineNo">220</span>      } else {<a name="line.220"></a>
-<span class="sourceLineNo">221</span>        LOG.info("WAL rolling disabled, returning the first writer.");<a name="line.221"></a>
-<span class="sourceLineNo">222</span>        // Initial assignment happens during the constructor call, so there ought not be<a name="line.222"></a>
-<span class="sourceLineNo">223</span>        // a race for first assignment.<a name="line.223"></a>
-<span class="sourceLineNo">224</span>        return noRollsWriter;<a name="line.224"></a>
-<span class="sourceLineNo">225</span>      }<a name="line.225"></a>
-<span class="sourceLineNo">226</span>    }<a name="line.226"></a>
-<span class="sourceLineNo">227</span>  }<a name="line.227"></a>
-<span class="sourceLineNo">228</span><a name="line.228"></a>
-<span class="sourceLineNo">229</span>  /**<a name="line.229"></a>
-<span class="sourceLineNo">230</span>   * Presumes init will be called by a single thread prior to any access of other methods.<a name="line.230"></a>
-<span class="sourceLineNo">231</span>   */<a name="line.231"></a>
-<span class="sourceLineNo">232</span>  private static class IOTestWriter extends ProtobufLogWriter {<a name="line.232"></a>
-<span class="sourceLineNo">233</span>    private boolean doAppends;<a name="line.233"></a>
-<span class="sourceLineNo">234</span>    private boolean doSyncs;<a name="line.234"></a>
-<span class="sourceLineNo">235</span><a name="line.235"></a>
-<span class="sourceLineNo">236</span>    @Override<a name="line.236"></a>
-<span class="sourceLineNo">237</span>    public void init(FileSystem fs, Path path, Configuration conf, boolean overwritable,<a name="line.237"></a>
-<span class="sourceLineNo">238</span>        long blocksize) throws IOException, CommonFSUtils.StreamLacksCapabilityException {<a name="line.238"></a>
-<span class="sourceLineNo">239</span>      Collection&lt;String&gt; operations = conf.getStringCollection(ALLOWED_OPERATIONS);<a name="line.239"></a>
-<span class="sourceLineNo">240</span>      if (operations.isEmpty() || operations.contains(AllowedOperations.all.name())) {<a name="line.240"></a>
-<span class="sourceLineNo">241</span>        doAppends = doSyncs = true;<a name="line.241"></a>
-<span class="sourceLineNo">242</span>      } else if (operations.contains(AllowedOperations.none.name())) {<a name="line.242"></a>
-<span class="sourceLineNo">243</span>        doAppends = doSyncs = false;<a name="line.243"></a>
-<span class="sourceLineNo">244</span>      } else {<a name="line.244"></a>
-<span class="sourceLineNo">245</span>        doAppends = operations.contains(AllowedOperations.append.name());<a name="line.245"></a>
-<span class="sourceLineNo">246</span>        doSyncs = operations.contains(AllowedOperations.sync.name());<a name="line.246"></a>
-<span class="sourceLineNo">247</span>      }<a name="line.247"></a>
-<span class="sourceLineNo">248</span>      LOG.info("IOTestWriter initialized with appends " + (doAppends ? "enabled" : "disabled") +<a name="line.248"></a>
-<span class="sourceLineNo">249</span>          " and syncs " + (doSyncs ? "enabled" : "disabled"));<a name="line.249"></a>
-<span class="sourceLineNo">250</span>      super.init(fs, path, conf, overwritable, blocksize);<a name="line.250"></a>
-<span class="sourceLineNo">251</span>    }<a name="line.251"></a>
-<span class="sourceLineNo">252</span><a name="line.252"></a>
-<span class="sourceLineNo">253</span>    @Override<a name="line.253"></a>
-<span class="sourceLineNo">254</span>    protected String getWriterClassName() {<a name="line.254"></a>
-<span class="sourceLineNo">255</span>      return ProtobufLogWriter.class.getSimpleName();<a name="line.255"></a>
-<span class="sourceLineNo">256</span>    }<a name="line.256"></a>
-<span class="sourceLineNo">257</span><a name="line.257"></a>
-<span class="sourceLineNo">258</span>    @Override<a name="line.258"></a>
-<span class="sourceLineNo">259</span>    public void append(Entry entry) throws IOException {<a name="line.259"></a>
-<span class="sourceLineNo">260</span>      if (doAppends) {<a name="line.260"></a>
-<span class="sourceLineNo">261</span>        super.append(entry);<a name="line.261"></a>
-<span class="sourceLineNo">262</span>      }<a name="line.262"></a>
-<span class="sourceLineNo">263</span>    }<a name="line.263"></a>
-<span class="sourceLineNo">264</span><a name="line.264"></a>
-<span class="sourceLineNo">265</span>    @Override<a name="line.265"></a>
-<span class="sourceLineNo">266</span>    public void sync(boolean forceSync) throws IOException {<a name="line.266"></a>
-<span class="sourceLineNo">267</span>      if (doSyncs) {<a name="line.267"></a>
-<span class="sourceLineNo">268</span>        super.sync(forceSync);<a name="line.268"></a>
-<span class="sourceLineNo">269</span>      }<a name="line.269"></a>
-<span class="sourceLineNo">270</span>    }<a name="line.270"></a>
-<span class="sourceLineNo">271</span>  }<a name="line.271"></a>
-<span class="sourceLineNo">272</span><a name="line.272"></a>
-<span class="sourceLineNo">273</span>  @Override<a name="line.273"></a>
-<span class="sourceLineNo">274</span>  public long getNumLogFiles() {<a name="line.274"></a>
-<span class="sourceLineNo">275</span>    return this.log.getNumLogFiles();<a name="line.275"></a>
-<span class="sourceLineNo">276</span>  }<a name="line.276"></a>
-<span class="sourceLineNo">277</span><a name="line.277"></a>
-<span class="sourceLineNo">278</span>  @Override<a name="line.278"></a>
-<span class="sourceLineNo">279</span>  public long getLogFileSize() {<a name="line.279"></a>
-<span class="sourceLineNo">280</span>    return this.log.getLogFileSize();<a name="line.280"></a>
-<span class="sourceLineNo">281</span>  }<a name="line.281"></a>
-<span class="sourceLineNo">282</span><a name="line.282"></a>
-<span class="sourceLineNo">283</span>  @Override<a name="line.283"></a>
-<span class="sourceLineNo">284</span>  public void addWALActionsListener(WALActionsListener listener) {<a name="line.284"></a>
-<span class="sourceLineNo">285</span>    // TODO Implement WALProvider.addWALActionLister<a name="line.285"></a>
-<span class="sourceLineNo">286</span><a name="line.286"></a>
-<span class="sourceLineNo">287</span>  }<a name="line.287"></a>
-<span class="sourceLineNo">288</span>}<a name="line.288"></a>
+<span class="sourceLineNo">160</span>    // Used to differntiate between roll calls before and after we finish construction.<a name="line.160"></a>
+<span class="sourceLineNo">161</span>    private final boolean initialized;<a name="line.161"></a>
+<span class="sourceLineNo">162</span><a name="line.162"></a>
+<span class="sourceLineNo">163</span>    /**<a name="line.163"></a>
+<span class="sourceLineNo">164</span>     * Create an edit log at the given &lt;code&gt;dir&lt;/code&gt; location.<a name="line.164"></a>
+<span class="sourceLineNo">165</span>     *<a name="line.165"></a>
+<span class="sourceLineNo">166</span>     * You should never have to load an existing log. If there is a log at<a name="line.166"></a>
+<span class="sourceLineNo">167</span>     * startup, it should have already been processed and deleted by the time the<a name="line.167"></a>
+<span class="sourceLineNo">168</span>     * WAL object is started up.<a name="line.168"></a>
+<span class="sourceLineNo">169</span>     *<a name="line.169"></a>
+<span class="sourceLineNo">170</span>     * @param fs filesystem handle<a name="line.170"></a>
+<span class="sourceLineNo">171</span>     * @param rootDir path to where logs and oldlogs<a name="line.171"></a>
+<span class="sourceLineNo">172</span>     * @param logDir dir where wals are stored<a name="line.172"></a>
+<span class="sourceLineNo">173</span>     * @param archiveDir dir where wals are archived<a name="line.173"></a>
+<span class="sourceLineNo">174</span>     * @param conf configuration to use<a name="line.174"></a>
+<span class="sourceLineNo">175</span>     * @param listeners Listeners on WAL events. Listeners passed here will<a name="line.175"></a>
+<span class="sourceLineNo">176</span>     * be registered before we do anything else; e.g. the<a name="line.176"></a>
+<span class="sourceLineNo">177</span>     * Constructor {@link #rollWriter()}.<a name="line.177"></a>
+<span class="sourceLineNo">178</span>     * @param failIfWALExists If true IOException will be thrown if files related to this wal<a name="line.178"></a>
+<span class="sourceLineNo">179</span>     *        already exist.<a name="line.179"></a>
+<span class="sourceLineNo">180</span>     * @param prefix should always be hostname and port in distributed env and<a name="line.180"></a>
+<span class="sourceLineNo">181</span>     *        it will be URL encoded before being used.<a name="line.181"></a>
+<span class="sourceLineNo">182</span>     *        If prefix is null, "wal" will be used<a name="line.182"></a>
+<span class="sourceLineNo">183</span>     * @param suffix will be url encoded. null is treated as empty. non-empty must start with<a name="line.183"></a>
+<span class="sourceLineNo">184</span>     *        {@link AbstractFSWALProvider#WAL_FILE_NAME_DELIMITER}<a name="line.184"></a>
+<span class="sourceLineNo">185</span>     * @throws IOException<a name="line.185"></a>
+<span class="sourceLineNo">186</span>     */<a name="line.186"></a>
+<span class="sourceLineNo">187</span>    public IOTestWAL(final FileSystem fs, final Path rootDir, final String logDir,<a name="line.187"></a>
+<span class="sourceLineNo">188</span>        final String archiveDir, final Configuration conf,<a name="line.188"></a>
+<span class="sourceLineNo">189</span>        final List&lt;WALActionsListener&gt; listeners,<a name="line.189"></a>
+<span class="sourceLineNo">190</span>        final boolean failIfWALExists, final String prefix, final String suffix)<a name="line.190"></a>
+<span class="sourceLineNo">191</span>        throws IOException {<a name="line.191"></a>
+<span class="sourceLineNo">192</span>      super(fs, rootDir, logDir, archiveDir, conf, listeners, failIfWALExists, prefix, suffix);<a name="line.192"></a>
+<span class="sourceLineNo">193</span>      Collection&lt;String&gt; operations = conf.getStringCollection(ALLOWED_OPERATIONS);<a name="line.193"></a>
+<span class="sourceLineNo">194</span>      doFileRolls = operations.isEmpty() || operations.contains(AllowedOperations.all.name()) ||<a name="line.194"></a>
+<span class="sourceLineNo">195</span>          operations.contains(AllowedOperations.fileroll.name());<a name="line.195"></a>
+<span class="sourceLineNo">196</span>      initialized = true;<a name="line.196"></a>
+<span class="sourceLineNo">197</span>      LOG.info("Initialized with file rolling " + (doFileRolls ? "enabled" : "disabled"));<a name="line.197"></a>
+<span class="sourceLineNo">198</span>    }<a name="line.198"></a>
+<span class="sourceLineNo">199</span><a name="line.199"></a>
+<span class="sourceLineNo">200</span>    private Writer noRollsWriter;<a name="line.200"></a>
+<span class="sourceLineNo">201</span><a name="line.201"></a>
+<span class="sourceLineNo">202</span>    // creatWriterInstance is where the new pipeline is set up for doing file rolls<a name="line.202"></a>
+<span class="sourceLineNo">203</span>    // if we are skipping it, just keep returning the same writer.<a name="line.203"></a>
+<span class="sourceLineNo">204</span>    @Override<a name="line.204"></a>
+<span class="sourceLineNo">205</span>    protected Writer createWriterInstance(final Path path) throws IOException {<a name="line.205"></a>
+<span class="sourceLineNo">206</span>      // we get called from the FSHLog constructor (!); always roll in this case since<a name="line.206"></a>
+<span class="sourceLineNo">207</span>      // we don't know yet if we're supposed to generally roll and<a name="line.207"></a>
+<span class="sourceLineNo">208</span>      // we need an initial file in the case of doing appends but no rolls.<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      if (!initialized || doFileRolls) {<a name="line.209"></a>
+<span class="sourceLineNo">210</span>        LOG.info("creating new writer instance.");<a name="line.210"></a>
+<span class="sourceLineNo">211</span>        final ProtobufLogWriter writer = new IOTestWriter();<a name="line.211"></a>
+<span class="sourceLineNo">212</span>        try {<a name="line.212"></a>
+<span class="sourceLineNo">213</span>          writer.init(fs, path, conf, false, this.blocksize);<a name="line.213"></a>
+<span class="sourceLineNo">214</span>        } catch (CommonFSUtils.StreamLacksCapabilityException exception) {<a name="line.214"></a>
+<span class="sourceLineNo">215</span>          throw new IOException("Can't create writer instance because underlying FileSystem " +<a name="line.215"></a>
+<span class="sourceLineNo">216</span>              "doesn't support needed stream capabilities.", exception);<a name="line.216"></a>
+<span class="sourceLineNo">217</span>        }<a name="line.217"></a>
+<span class="sourceLineNo">218</span>        if (!initialized) {<a name="line.218"></a>
+<span class="sourceLineNo">219</span>          LOG.info("storing initial writer instance in case file rolling isn't allowed.");<a name="line.219"></a>
+<span class="sourceLineNo">220</span>          noRollsWriter = writer;<a name="line.220"></a>
+<span class="sourceLineNo">221</span>        }<a name="line.221"></a>
+<span class="sourceLineNo">222</span>        return writer;<a name="line.222"></a>
+<span class="sourceLineNo">223</span>      } else {<a name="line.223"></a>
+<span class="sourceLineNo">224</span>        LOG.info("WAL rolling disabled, returning the first writer.");<a name="line.224"></a>
+<span class="sourceLineNo">225</span>        // Initial assignment happens during the constructor call, so there ought not be<a name="line.225"></a>
+<span class="sourceLineNo">226</span>        // a race for first assignment.<a name="line.226"></a>
+<span class="sourceLineNo">227</span>        return noRollsWriter;<a name="line.227"></a>
+<span class="sourceLineNo">228</span>      }<a name="line.228"></a>
+<span class="sourceLineNo">229</span>    }<a name="line.229"></a>
+<span class="sourceLineNo">230</span>  }<a name="line.230"></a>
+<span class="sourceLineNo">231</span><a name="line.231"></a>
+<span class="sourceLineNo">232</span>  /**<a name="line.232"></a>
+<span class="sourceLineNo">233</span>   * Presumes init will be called by a single thread prior to any access of other methods.<a name="line.233"></a>
+<span class="sourceLineNo">234</span>   */<a name="line.234"></a>
+<span class="sourceLineNo">235</span>  private static class IOTestWriter extends ProtobufLogWriter {<a name="line.235"></a>
+<span class="sourceLineNo">236</span>    private boolean doAppends;<a name="line.236"></a>
+<span class="sourceLineNo">237</span>    private boolean doSyncs;<a name="line.237"></a>
+<span class="sourceLineNo">238</span><a name="line.238"></a>
+<span class="sourceLineNo">239</span>    @Override<a name="line.239"></a>
+<span class="sourceLineNo">240</span>    public void init(FileSystem fs, Path path, Configuration conf, boolean overwritable,<a name="line.240"></a>
+<span class="sourceLineNo">241</span>        long blocksize) throws IOException, CommonFSUtils.StreamLacksCapabilityException {<a name="line.241"></a>
+<span class="sourceLineNo">242</span>      Collection&lt;String&gt; operations = conf.getStringCollection(ALLOWED_OPERATIONS);<a name="line.242"></a>
+<span class="sourceLineNo">243</span>      if (operations.isEmpty() || operations.contains(AllowedOperations.all.name())) {<a name="line.243"></a>
+<span class="sourceLineNo">244</span>        doAppends = doSyncs = true;<a name="line.244"></a>
+<span class="sourceLineNo">245</span>      } else if (operations.contains(AllowedOperations.none.name())) {<a name="line.245"></a>
+<span class="sourceLineNo">246</span>        doAppends = doSyncs = false;<a name="line.246"></a>
+<span class="sourceLineNo">247</span>      } else {<a name="line.247"></a>
+<span class="sourceLineNo">248</span>        doAppends = operations.contains(AllowedOperations.append.name());<a name="line.248"></a>
+<span class="sourceLineNo">249</span>        doSyncs = operations.contains(AllowedOperations.sync.name());<a name="line.249"></a>
+<span class="sourceLineNo">250</span>      }<a name="line.250"></a>
+<span class="sourceLineNo">251</span>      LOG.info("IOTestWriter initialized with appends " + (doAppends ? "enabled" : "disabled") +<a name="line.251"></a>
+<span class="sourceLineNo">252</span>          " and syncs " + (doSyncs ? "enabled" : "disabled"));<a name="line.252"></a>
+<span class="sourceLineNo">253</span>      super.init(fs, path, conf, overwritable, blocksize);<a name="line.253"></a>
+<span class="sourceLineNo">254</span>    }<a name="line.254"></a>
+<span class="sourceLineNo">255</span><a name="line.255"></a>
+<span class="sourceLineNo">256</span>    @Override<a name="line.256"></a>
+<span class="sourceLineNo">257</span>    protected String getWriterClassName() {<a name="line.257"></a>
+<span class="sourceLineNo">258</span>      return ProtobufLogWriter.class.getSimpleName();<a name="line.258"></a>
+<span class="sourceLineNo">259</span>    }<a name="line.259"></a>
+<span class="sourceLineNo">260</span><a name="line.260"></a>
+<span class="sourceLineNo">261</span>    @Override<a name="line.261"></a>
+<span class="sourceLineNo">262</span>    public void append(Entry entry) throws IOException {<a name="line.262"></a>
+<span class="sourceLineNo">263</span>      if (doAppends) {<a name="line.263"></a>
+<span class="sourceLineNo">264</span>        super.append(entry);<a name="line.264"></a>
+<span class="sourceLineNo">265</span>      }<a name="line.265"></a>
+<span class="sourceLineNo">266</span>    }<a name="line.266"></a>
+<span class="sourceLineNo">267</span><a name="line.267"></a>
+<span class="sourceLineNo">268</span>    @Override<a name="line.268"></a>
+<span class="sourceLineNo">269</span>    public void sync(boolean forceSync) throws IOException {<a name="line.269"></a>
+<span class="sourceLineNo">270</span>      if (doSyncs) {<a name="line.270"></a>
+<span class="sourceLineNo">271</span>        super.sync(forceSync);<a name="line.271"></a>
+<span class="sourceLineNo">272</span>      }<a name="line.272"></a>
+<span class="sourceLineNo">273</span>    }<a name="line.273"></a>
+<span class="sourceLineNo">274</span>  }<a name="line.274"></a>
+<span class="sourceLineNo">275</span><a name="line.275"></a>
+<span class="sourceLineNo">276</span>  @Override<a name="line.276"></a>
+<span class="sourceLineNo">277</span>  public long getNumLogFiles() {<a name="line.277"></a>
+<span class="sourceLineNo">278</span>    return this.log.getNumLogFiles();<a name="line.278"></a>
+<span class="sourceLineNo">279</span>  }<a name="line.279"></a>
+<span class="sourceLineNo">280</span><a name="line.280"></a>
+<span class="sourceLineNo">281</span>  @Override<a name="line.281"></a>
+<span class="sourceLineNo">282</span>  public long getLogFileSize() {<a name="line.282"></a>
+<span class="sourceLineNo">283</span>    return this.log.getLogFileSize();<a name="line.283"></a>
+<span class="sourceLineNo">284</span>  }<a name="line.284"></a>
+<span class="sourceLineNo">285</span><a name="line.285"></a>
+<span class="sourceLineNo">286</span>  @Override<a name="line.286"></a>
+<span class="sourceLineNo">287</span>  public void addWALActionsListener(WALActionsListener listener) {<a name="line.287"></a>
+<span class="sourceLineNo">288</span>    // TODO Implement WALProvider.addWALActionLister<a name="line.288"></a>
+<span class="sourceLineNo">289</span><a name="line.289"></a>
+<span class="sourceLineNo">290</span>  }<a name="line.290"></a>
+<span class="sourceLineNo">291</span>}<a name="line.291"></a>
 
 
 


Mime
View raw message