http://git-wip-us.apache.org/repos/asf/hbase-site/blob/f183e80f/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALFactory.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALFactory.html b/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALFactory.html index fadf667..14b2b69 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALFactory.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALFactory.html @@ -7,269 +7,269 @@ <body> <div class="sourceContainer"> <pre><span class="sourceLineNo">001</span>/**<a name="line.1"></a> -<span class="sourceLineNo">002</span> *<a name="line.2"></a> -<span class="sourceLineNo">003</span> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.3"></a> -<span class="sourceLineNo">004</span> * or more contributor license agreements. See the NOTICE file<a name="line.4"></a> -<span class="sourceLineNo">005</span> * distributed with this work for additional information<a name="line.5"></a> -<span class="sourceLineNo">006</span> * regarding copyright ownership. The ASF licenses this file<a name="line.6"></a> -<span class="sourceLineNo">007</span> * to you under the Apache License, Version 2.0 (the<a name="line.7"></a> -<span class="sourceLineNo">008</span> * "License"); you may not use this file except in compliance<a name="line.8"></a> -<span class="sourceLineNo">009</span> * with the License. You may obtain a copy of the License at<a name="line.9"></a> -<span class="sourceLineNo">010</span> *<a name="line.10"></a> -<span class="sourceLineNo">011</span> * http://www.apache.org/licenses/LICENSE-2.0<a name="line.11"></a> -<span class="sourceLineNo">012</span> *<a name="line.12"></a> -<span class="sourceLineNo">013</span> * Unless required by applicable law or agreed to in writing, software<a name="line.13"></a> -<span class="sourceLineNo">014</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.14"></a> -<span class="sourceLineNo">015</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.15"></a> -<span class="sourceLineNo">016</span> * See the License for the specific language governing permissions and<a name="line.16"></a> -<span class="sourceLineNo">017</span> * limitations under the License.<a name="line.17"></a> -<span class="sourceLineNo">018</span> */<a name="line.18"></a> +<span class="sourceLineNo">002</span> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.2"></a> +<span class="sourceLineNo">003</span> * or more contributor license agreements. See the NOTICE file<a name="line.3"></a> +<span class="sourceLineNo">004</span> * distributed with this work for additional information<a name="line.4"></a> +<span class="sourceLineNo">005</span> * regarding copyright ownership. The ASF licenses this file<a name="line.5"></a> +<span class="sourceLineNo">006</span> * to you under the Apache License, Version 2.0 (the<a name="line.6"></a> +<span class="sourceLineNo">007</span> * "License"); you may not use this file except in compliance<a name="line.7"></a> +<span class="sourceLineNo">008</span> * with the License. You may obtain a copy of the License at<a name="line.8"></a> +<span class="sourceLineNo">009</span> *<a name="line.9"></a> +<span class="sourceLineNo">010</span> * http://www.apache.org/licenses/LICENSE-2.0<a name="line.10"></a> +<span class="sourceLineNo">011</span> *<a name="line.11"></a> +<span class="sourceLineNo">012</span> * Unless required by applicable law or agreed to in writing, software<a name="line.12"></a> +<span class="sourceLineNo">013</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.13"></a> +<span class="sourceLineNo">014</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.14"></a> +<span class="sourceLineNo">015</span> * See the License for the specific language governing permissions and<a name="line.15"></a> +<span class="sourceLineNo">016</span> * limitations under the License.<a name="line.16"></a> +<span class="sourceLineNo">017</span> */<a name="line.17"></a> +<span class="sourceLineNo">018</span>package org.apache.hadoop.hbase.wal;<a name="line.18"></a> <span class="sourceLineNo">019</span><a name="line.19"></a> -<span class="sourceLineNo">020</span><a name="line.20"></a> -<span class="sourceLineNo">021</span>package org.apache.hadoop.hbase.wal;<a name="line.21"></a> -<span class="sourceLineNo">022</span><a name="line.22"></a> -<span class="sourceLineNo">023</span>import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;<a name="line.23"></a> -<span class="sourceLineNo">024</span><a name="line.24"></a> -<span class="sourceLineNo">025</span>import java.io.IOException;<a name="line.25"></a> -<span class="sourceLineNo">026</span>import java.io.InterruptedIOException;<a name="line.26"></a> -<span class="sourceLineNo">027</span>import java.util.Collections;<a name="line.27"></a> -<span class="sourceLineNo">028</span>import java.util.List;<a name="line.28"></a> -<span class="sourceLineNo">029</span>import java.util.OptionalLong;<a name="line.29"></a> -<span class="sourceLineNo">030</span>import java.util.concurrent.atomic.AtomicReference;<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.yetus.audience.InterfaceAudience;<a name="line.35"></a> -<span class="sourceLineNo">036</span>import org.slf4j.Logger;<a name="line.36"></a> -<span class="sourceLineNo">037</span>import org.slf4j.LoggerFactory;<a name="line.37"></a> -<span class="sourceLineNo">038</span>// imports for things that haven't moved from regionserver.wal yet.<a name="line.38"></a> -<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.regionserver.wal.MetricsWAL;<a name="line.39"></a> -<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.regionserver.wal.ProtobufLogReader;<a name="line.40"></a> -<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;<a name="line.41"></a> -<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.replication.regionserver.WALFileLengthProvider;<a name="line.42"></a> -<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.util.CancelableProgressable;<a name="line.43"></a> -<span class="sourceLineNo">044</span>import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;<a name="line.44"></a> -<span class="sourceLineNo">045</span>import org.apache.hadoop.hbase.util.LeaseNotRecoveredException;<a name="line.45"></a> -<span class="sourceLineNo">046</span>import org.apache.hadoop.hbase.wal.WAL.Reader;<a name="line.46"></a> -<span class="sourceLineNo">047</span>import org.apache.hadoop.hbase.wal.WALProvider.Writer;<a name="line.47"></a> -<span class="sourceLineNo">048</span><a name="line.48"></a> -<span class="sourceLineNo">049</span>/**<a name="line.49"></a> -<span class="sourceLineNo">050</span> * Entry point for users of the Write Ahead Log.<a name="line.50"></a> -<span class="sourceLineNo">051</span> * Acts as the shim between internal use and the particular WALProvider we use to handle wal<a name="line.51"></a> -<span class="sourceLineNo">052</span> * requests.<a name="line.52"></a> -<span class="sourceLineNo">053</span> *<a name="line.53"></a> -<span class="sourceLineNo">054</span> * Configure which provider gets used with the configuration setting "hbase.wal.provider". Available<a name="line.54"></a> -<span class="sourceLineNo">055</span> * implementations:<a name="line.55"></a> -<span class="sourceLineNo">056</span> * <ul><a name="line.56"></a> -<span class="sourceLineNo">057</span> * <li><em>defaultProvider</em> : whatever provider is standard for the hbase version. Currently<a name="line.57"></a> -<span class="sourceLineNo">058</span> * "filesystem"</li><a name="line.58"></a> -<span class="sourceLineNo">059</span> * <li><em>filesystem</em> : a provider that will run on top of an implementation of the Hadoop<a name="line.59"></a> -<span class="sourceLineNo">060</span> * FileSystem interface, normally HDFS.</li><a name="line.60"></a> -<span class="sourceLineNo">061</span> * <li><em>multiwal</em> : a provider that will use multiple "filesystem" wal instances per region<a name="line.61"></a> -<span class="sourceLineNo">062</span> * server.</li><a name="line.62"></a> -<span class="sourceLineNo">063</span> * </ul><a name="line.63"></a> -<span class="sourceLineNo">064</span> *<a name="line.64"></a> -<span class="sourceLineNo">065</span> * Alternatively, you may provide a custom implementation of {@link WALProvider} by class name.<a name="line.65"></a> -<span class="sourceLineNo">066</span> */<a name="line.66"></a> -<span class="sourceLineNo">067</span>@InterfaceAudience.Private<a name="line.67"></a> -<span class="sourceLineNo">068</span>public class WALFactory implements WALFileLengthProvider {<a name="line.68"></a> -<span class="sourceLineNo">069</span><a name="line.69"></a> -<span class="sourceLineNo">070</span> private static final Logger LOG = LoggerFactory.getLogger(WALFactory.class);<a name="line.70"></a> -<span class="sourceLineNo">071</span><a name="line.71"></a> -<span class="sourceLineNo">072</span> /**<a name="line.72"></a> -<span class="sourceLineNo">073</span> * Maps between configuration names for providers and implementation classes.<a name="line.73"></a> -<span class="sourceLineNo">074</span> */<a name="line.74"></a> -<span class="sourceLineNo">075</span> static enum Providers {<a name="line.75"></a> -<span class="sourceLineNo">076</span> defaultProvider(AsyncFSWALProvider.class),<a name="line.76"></a> -<span class="sourceLineNo">077</span> filesystem(FSHLogProvider.class),<a name="line.77"></a> -<span class="sourceLineNo">078</span> multiwal(RegionGroupingProvider.class),<a name="line.78"></a> -<span class="sourceLineNo">079</span> asyncfs(AsyncFSWALProvider.class);<a name="line.79"></a> -<span class="sourceLineNo">080</span><a name="line.80"></a> -<span class="sourceLineNo">081</span> Class<? extends WALProvider> clazz;<a name="line.81"></a> -<span class="sourceLineNo">082</span> Providers(Class<? extends WALProvider> clazz) {<a name="line.82"></a> -<span class="sourceLineNo">083</span> this.clazz = clazz;<a name="line.83"></a> -<span class="sourceLineNo">084</span> }<a name="line.84"></a> -<span class="sourceLineNo">085</span> }<a name="line.85"></a> +<span class="sourceLineNo">020</span>import java.io.IOException;<a name="line.20"></a> +<span class="sourceLineNo">021</span>import java.io.InterruptedIOException;<a name="line.21"></a> +<span class="sourceLineNo">022</span>import java.util.Collections;<a name="line.22"></a> +<span class="sourceLineNo">023</span>import java.util.List;<a name="line.23"></a> +<span class="sourceLineNo">024</span>import java.util.OptionalLong;<a name="line.24"></a> +<span class="sourceLineNo">025</span>import java.util.concurrent.atomic.AtomicReference;<a name="line.25"></a> +<span class="sourceLineNo">026</span>import org.apache.hadoop.conf.Configuration;<a name="line.26"></a> +<span class="sourceLineNo">027</span>import org.apache.hadoop.fs.FileSystem;<a name="line.27"></a> +<span class="sourceLineNo">028</span>import org.apache.hadoop.fs.Path;<a name="line.28"></a> +<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.client.RegionInfo;<a name="line.29"></a> +<span class="sourceLineNo">030</span>// imports for things that haven't moved from regionserver.wal yet.<a name="line.30"></a> +<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.regionserver.wal.MetricsWAL;<a name="line.31"></a> +<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.regionserver.wal.ProtobufLogReader;<a name="line.32"></a> +<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;<a name="line.33"></a> +<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.replication.regionserver.WALFileLengthProvider;<a name="line.34"></a> +<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.util.CancelableProgressable;<a name="line.35"></a> +<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;<a name="line.36"></a> +<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.util.LeaseNotRecoveredException;<a name="line.37"></a> +<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.wal.WAL.Reader;<a name="line.38"></a> +<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.wal.WALProvider.Writer;<a name="line.39"></a> +<span class="sourceLineNo">040</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.40"></a> +<span class="sourceLineNo">041</span>import org.slf4j.Logger;<a name="line.41"></a> +<span class="sourceLineNo">042</span>import org.slf4j.LoggerFactory;<a name="line.42"></a> +<span class="sourceLineNo">043</span><a name="line.43"></a> +<span class="sourceLineNo">044</span>import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;<a name="line.44"></a> +<span class="sourceLineNo">045</span><a name="line.45"></a> +<span class="sourceLineNo">046</span>/**<a name="line.46"></a> +<span class="sourceLineNo">047</span> * Entry point for users of the Write Ahead Log.<a name="line.47"></a> +<span class="sourceLineNo">048</span> * Acts as the shim between internal use and the particular WALProvider we use to handle wal<a name="line.48"></a> +<span class="sourceLineNo">049</span> * requests.<a name="line.49"></a> +<span class="sourceLineNo">050</span> *<a name="line.50"></a> +<span class="sourceLineNo">051</span> * Configure which provider gets used with the configuration setting "hbase.wal.provider". Available<a name="line.51"></a> +<span class="sourceLineNo">052</span> * implementations:<a name="line.52"></a> +<span class="sourceLineNo">053</span> * <ul><a name="line.53"></a> +<span class="sourceLineNo">054</span> * <li><em>defaultProvider</em> : whatever provider is standard for the hbase version. Currently<a name="line.54"></a> +<span class="sourceLineNo">055</span> * "filesystem"</li><a name="line.55"></a> +<span class="sourceLineNo">056</span> * <li><em>filesystem</em> : a provider that will run on top of an implementation of the Hadoop<a name="line.56"></a> +<span class="sourceLineNo">057</span> * FileSystem interface, normally HDFS.</li><a name="line.57"></a> +<span class="sourceLineNo">058</span> * <li><em>multiwal</em> : a provider that will use multiple "filesystem" wal instances per region<a name="line.58"></a> +<span class="sourceLineNo">059</span> * server.</li><a name="line.59"></a> +<span class="sourceLineNo">060</span> * </ul><a name="line.60"></a> +<span class="sourceLineNo">061</span> *<a name="line.61"></a> +<span class="sourceLineNo">062</span> * Alternatively, you may provide a custom implementation of {@link WALProvider} by class name.<a name="line.62"></a> +<span class="sourceLineNo">063</span> */<a name="line.63"></a> +<span class="sourceLineNo">064</span>@InterfaceAudience.Private<a name="line.64"></a> +<span class="sourceLineNo">065</span>public class WALFactory implements WALFileLengthProvider {<a name="line.65"></a> +<span class="sourceLineNo">066</span><a name="line.66"></a> +<span class="sourceLineNo">067</span> private static final Logger LOG = LoggerFactory.getLogger(WALFactory.class);<a name="line.67"></a> +<span class="sourceLineNo">068</span><a name="line.68"></a> +<span class="sourceLineNo">069</span> /**<a name="line.69"></a> +<span class="sourceLineNo">070</span> * Maps between configuration names for providers and implementation classes.<a name="line.70"></a> +<span class="sourceLineNo">071</span> */<a name="line.71"></a> +<span class="sourceLineNo">072</span> static enum Providers {<a name="line.72"></a> +<span class="sourceLineNo">073</span> defaultProvider(AsyncFSWALProvider.class),<a name="line.73"></a> +<span class="sourceLineNo">074</span> filesystem(FSHLogProvider.class),<a name="line.74"></a> +<span class="sourceLineNo">075</span> multiwal(RegionGroupingProvider.class),<a name="line.75"></a> +<span class="sourceLineNo">076</span> asyncfs(AsyncFSWALProvider.class);<a name="line.76"></a> +<span class="sourceLineNo">077</span><a name="line.77"></a> +<span class="sourceLineNo">078</span> Class<? extends WALProvider> clazz;<a name="line.78"></a> +<span class="sourceLineNo">079</span> Providers(Class<? extends WALProvider> clazz) {<a name="line.79"></a> +<span class="sourceLineNo">080</span> this.clazz = clazz;<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><a name="line.83"></a> +<span class="sourceLineNo">084</span> public static final String WAL_PROVIDER = "hbase.wal.provider";<a name="line.84"></a> +<span class="sourceLineNo">085</span> static final String DEFAULT_WAL_PROVIDER = Providers.defaultProvider.name();<a name="line.85"></a> <span class="sourceLineNo">086</span><a name="line.86"></a> -<span class="sourceLineNo">087</span> public static final String WAL_PROVIDER = "hbase.wal.provider";<a name="line.87"></a> -<span class="sourceLineNo">088</span> static final String DEFAULT_WAL_PROVIDER = Providers.defaultProvider.name();<a name="line.88"></a> +<span class="sourceLineNo">087</span> public static final String META_WAL_PROVIDER = "hbase.wal.meta_provider";<a name="line.87"></a> +<span class="sourceLineNo">088</span> static final String DEFAULT_META_WAL_PROVIDER = Providers.defaultProvider.name();<a name="line.88"></a> <span class="sourceLineNo">089</span><a name="line.89"></a> -<span class="sourceLineNo">090</span> public static final String META_WAL_PROVIDER = "hbase.wal.meta_provider";<a name="line.90"></a> -<span class="sourceLineNo">091</span> static final String DEFAULT_META_WAL_PROVIDER = Providers.defaultProvider.name();<a name="line.91"></a> -<span class="sourceLineNo">092</span><a name="line.92"></a> -<span class="sourceLineNo">093</span> final String factoryId;<a name="line.93"></a> -<span class="sourceLineNo">094</span> final WALProvider provider;<a name="line.94"></a> -<span class="sourceLineNo">095</span> // The meta updates are written to a different wal. If this<a name="line.95"></a> -<span class="sourceLineNo">096</span> // regionserver holds meta regions, then this ref will be non-null.<a name="line.96"></a> -<span class="sourceLineNo">097</span> // lazily intialized; most RegionServers don't deal with META<a name="line.97"></a> -<span class="sourceLineNo">098</span> final AtomicReference<WALProvider> metaProvider = new AtomicReference<>();<a name="line.98"></a> -<span class="sourceLineNo">099</span><a name="line.99"></a> -<span class="sourceLineNo">100</span> /**<a name="line.100"></a> -<span class="sourceLineNo">101</span> * Configuration-specified WAL Reader used when a custom reader is requested<a name="line.101"></a> -<span class="sourceLineNo">102</span> */<a name="line.102"></a> -<span class="sourceLineNo">103</span> private final Class<? extends AbstractFSWALProvider.Reader> logReaderClass;<a name="line.103"></a> -<span class="sourceLineNo">104</span><a name="line.104"></a> -<span class="sourceLineNo">105</span> /**<a name="line.105"></a> -<span class="sourceLineNo">106</span> * How long to attempt opening in-recovery wals<a name="line.106"></a> -<span class="sourceLineNo">107</span> */<a name="line.107"></a> -<span class="sourceLineNo">108</span> private final int timeoutMillis;<a name="line.108"></a> -<span class="sourceLineNo">109</span><a name="line.109"></a> -<span class="sourceLineNo">110</span> private final Configuration conf;<a name="line.110"></a> -<span class="sourceLineNo">111</span><a name="line.111"></a> -<span class="sourceLineNo">112</span> // Used for the singleton WALFactory, see below.<a name="line.112"></a> -<span class="sourceLineNo">113</span> private WALFactory(Configuration conf) {<a name="line.113"></a> -<span class="sourceLineNo">114</span> // this code is duplicated here so we can keep our members final.<a name="line.114"></a> -<span class="sourceLineNo">115</span> // until we've moved reader/writer construction down into providers, this initialization must<a name="line.115"></a> -<span class="sourceLineNo">116</span> // happen prior to provider initialization, in case they need to instantiate a reader/writer.<a name="line.116"></a> -<span class="sourceLineNo">117</span> timeoutMillis = conf.getInt("hbase.hlog.open.timeout", 300000);<a name="line.117"></a> -<span class="sourceLineNo">118</span> /* TODO Both of these are probably specific to the fs wal provider */<a name="line.118"></a> -<span class="sourceLineNo">119</span> logReaderClass = conf.getClass("hbase.regionserver.hlog.reader.impl", ProtobufLogReader.class,<a name="line.119"></a> -<span class="sourceLineNo">120</span> AbstractFSWALProvider.Reader.class);<a name="line.120"></a> -<span class="sourceLineNo">121</span> this.conf = conf;<a name="line.121"></a> -<span class="sourceLineNo">122</span> // end required early initialization<a name="line.122"></a> -<span class="sourceLineNo">123</span><a name="line.123"></a> -<span class="sourceLineNo">124</span> // this instance can't create wals, just reader/writers.<a name="line.124"></a> -<span class="sourceLineNo">125</span> provider = null;<a name="line.125"></a> -<span class="sourceLineNo">126</span> factoryId = SINGLETON_ID;<a name="line.126"></a> -<span class="sourceLineNo">127</span> }<a name="line.127"></a> -<span class="sourceLineNo">128</span><a name="line.128"></a> -<span class="sourceLineNo">129</span> @VisibleForTesting<a name="line.129"></a> -<span class="sourceLineNo">130</span> public Class<? extends WALProvider> getProviderClass(String key, String defaultValue) {<a name="line.130"></a> -<span class="sourceLineNo">131</span> try {<a name="line.131"></a> -<span class="sourceLineNo">132</span> return Providers.valueOf(conf.get(key, defaultValue)).clazz;<a name="line.132"></a> -<span class="sourceLineNo">133</span> } catch (IllegalArgumentException exception) {<a name="line.133"></a> -<span class="sourceLineNo">134</span> // Fall back to them specifying a class name<a name="line.134"></a> -<span class="sourceLineNo">135</span> // Note that the passed default class shouldn't actually be used, since the above only fails<a name="line.135"></a> -<span class="sourceLineNo">136</span> // when there is a config value present.<a name="line.136"></a> -<span class="sourceLineNo">137</span> return conf.getClass(key, Providers.defaultProvider.clazz, WALProvider.class);<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><a name="line.140"></a> -<span class="sourceLineNo">141</span> WALProvider createProvider(Class<? extends WALProvider> clazz,<a name="line.141"></a> -<span class="sourceLineNo">142</span> List<WALActionsListener> listeners, String providerId) throws IOException {<a name="line.142"></a> -<span class="sourceLineNo">143</span> LOG.info("Instantiating WALProvider of type " + clazz);<a name="line.143"></a> -<span class="sourceLineNo">144</span> try {<a name="line.144"></a> -<span class="sourceLineNo">145</span> final WALProvider result = clazz.newInstance();<a name="line.145"></a> -<span class="sourceLineNo">146</span> result.init(this, conf, listeners, providerId);<a name="line.146"></a> -<span class="sourceLineNo">147</span> return result;<a name="line.147"></a> -<span class="sourceLineNo">148</span> } catch (InstantiationException exception) {<a name="line.148"></a> -<span class="sourceLineNo">149</span> LOG.error("couldn't set up WALProvider, the configured class is " + clazz);<a name="line.149"></a> -<span class="sourceLineNo">150</span> LOG.debug("Exception details for failure to load WALProvider.", exception);<a name="line.150"></a> -<span class="sourceLineNo">151</span> throw new IOException("couldn't set up WALProvider", exception);<a name="line.151"></a> -<span class="sourceLineNo">152</span> } catch (IllegalAccessException exception) {<a name="line.152"></a> -<span class="sourceLineNo">153</span> LOG.error("couldn't set up WALProvider, the configured class is " + clazz);<a name="line.153"></a> -<span class="sourceLineNo">154</span> LOG.debug("Exception details for failure to load WALProvider.", exception);<a name="line.154"></a> -<span class="sourceLineNo">155</span> throw new IOException("couldn't set up WALProvider", exception);<a name="line.155"></a> -<span class="sourceLineNo">156</span> }<a name="line.156"></a> -<span class="sourceLineNo">157</span> }<a name="line.157"></a> -<span class="sourceLineNo">158</span><a name="line.158"></a> -<span class="sourceLineNo">159</span> /**<a name="line.159"></a> -<span class="sourceLineNo">160</span> * instantiate a provider from a config property.<a name="line.160"></a> -<span class="sourceLineNo">161</span> * requires conf to have already been set (as well as anything the provider might need to read).<a name="line.161"></a> -<span class="sourceLineNo">162</span> */<a name="line.162"></a> -<span class="sourceLineNo">163</span> WALProvider getProvider(final String key, final String defaultValue,<a name="line.163"></a> -<span class="sourceLineNo">164</span> final List<WALActionsListener> listeners, final String providerId) throws IOException {<a name="line.164"></a> -<span class="sourceLineNo">165</span> Class<? extends WALProvider> clazz = getProviderClass(key, defaultValue);<a name="line.165"></a> -<span class="sourceLineNo">166</span> return createProvider(clazz, listeners, providerId);<a name="line.166"></a> -<span class="sourceLineNo">167</span> }<a name="line.167"></a> -<span class="sourceLineNo">168</span><a name="line.168"></a> -<span class="sourceLineNo">169</span> /**<a name="line.169"></a> -<span class="sourceLineNo">170</span> * @param conf must not be null, will keep a reference to read params in later reader/writer<a name="line.170"></a> -<span class="sourceLineNo">171</span> * instances.<a name="line.171"></a> -<span class="sourceLineNo">172</span> * @param listeners may be null. will be given to all created wals (and not meta-wals)<a name="line.172"></a> -<span class="sourceLineNo">173</span> * @param factoryId a unique identifier for this factory. used i.e. by filesystem implementations<a name="line.173"></a> -<span class="sourceLineNo">174</span> * to make a directory<a name="line.174"></a> -<span class="sourceLineNo">175</span> */<a name="line.175"></a> -<span class="sourceLineNo">176</span> public WALFactory(final Configuration conf, final List<WALActionsListener> listeners,<a name="line.176"></a> -<span class="sourceLineNo">177</span> final String factoryId) throws IOException {<a name="line.177"></a> -<span class="sourceLineNo">178</span> // until we've moved reader/writer construction down into providers, this initialization must<a name="line.178"></a> -<span class="sourceLineNo">179</span> // happen prior to provider initialization, in case they need to instantiate a reader/writer.<a name="line.179"></a> -<span class="sourceLineNo">180</span> timeoutMillis = conf.getInt("hbase.hlog.open.timeout", 300000);<a name="line.180"></a> -<span class="sourceLineNo">181</span> /* TODO Both of these are probably specific to the fs wal provider */<a name="line.181"></a> -<span class="sourceLineNo">182</span> logReaderClass = conf.getClass("hbase.regionserver.hlog.reader.impl", ProtobufLogReader.class,<a name="line.182"></a> -<span class="sourceLineNo">183</span> AbstractFSWALProvider.Reader.class);<a name="line.183"></a> -<span class="sourceLineNo">184</span> this.conf = conf;<a name="line.184"></a> -<span class="sourceLineNo">185</span> this.factoryId = factoryId;<a name="line.185"></a> -<span class="sourceLineNo">186</span> // end required early initialization<a name="line.186"></a> -<span class="sourceLineNo">187</span> if (conf.getBoolean("hbase.regionserver.hlog.enabled", true)) {<a name="line.187"></a> -<span class="sourceLineNo">188</span> provider = getProvider(WAL_PROVIDER, DEFAULT_WAL_PROVIDER, listeners, null);<a name="line.188"></a> -<span class="sourceLineNo">189</span> } else {<a name="line.189"></a> -<span class="sourceLineNo">190</span> // special handling of existing configuration behavior.<a name="line.190"></a> -<span class="sourceLineNo">191</span> LOG.warn("Running with WAL disabled.");<a name="line.191"></a> -<span class="sourceLineNo">192</span> provider = new DisabledWALProvider();<a name="line.192"></a> -<span class="sourceLineNo">193</span> provider.init(this, conf, null, factoryId);<a name="line.193"></a> -<span class="sourceLineNo">194</span> }<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> /**<a name="line.197"></a> -<span class="sourceLineNo">198</span> * Shutdown all WALs and clean up any underlying storage.<a name="line.198"></a> -<span class="sourceLineNo">199</span> * Use only when you will not need to replay and edits that have gone to any wals from this<a name="line.199"></a> -<span class="sourceLineNo">200</span> * factory.<a name="line.200"></a> -<span class="sourceLineNo">201</span> */<a name="line.201"></a> -<span class="sourceLineNo">202</span> public void close() throws IOException {<a name="line.202"></a> -<span class="sourceLineNo">203</span> final WALProvider metaProvider = this.metaProvider.get();<a name="line.203"></a> -<span class="sourceLineNo">204</span> if (null != metaProvider) {<a name="line.204"></a> -<span class="sourceLineNo">205</span> metaProvider.close();<a name="line.205"></a> -<span class="sourceLineNo">206</span> }<a name="line.206"></a> -<span class="sourceLineNo">207</span> // close is called on a WALFactory with null provider in the case of contention handling<a name="line.207"></a> -<span class="sourceLineNo">208</span> // within the getInstance method.<a name="line.208"></a> -<span class="sourceLineNo">209</span> if (null != provider) {<a name="line.209"></a> -<span class="sourceLineNo">210</span> provider.close();<a name="line.210"></a> -<span class="sourceLineNo">211</span> }<a name="line.211"></a> -<span class="sourceLineNo">212</span> }<a name="line.212"></a> -<span class="sourceLineNo">213</span><a name="line.213"></a> -<span class="sourceLineNo">214</span> /**<a name="line.214"></a> -<span class="sourceLineNo">215</span> * Tell the underlying WAL providers to shut down, but do not clean up underlying storage.<a name="line.215"></a> -<span class="sourceLineNo">216</span> * If you are not ending cleanly and will need to replay edits from this factory's wals,<a name="line.216"></a> -<span class="sourceLineNo">217</span> * use this method if you can as it will try to leave things as tidy as possible.<a name="line.217"></a> -<span class="sourceLineNo">218</span> */<a name="line.218"></a> -<span class="sourceLineNo">219</span> public void shutdown() throws IOException {<a name="line.219"></a> -<span class="sourceLineNo">220</span> IOException exception = null;<a name="line.220"></a> -<span class="sourceLineNo">221</span> final WALProvider metaProvider = this.metaProvider.get();<a name="line.221"></a> -<span class="sourceLineNo">222</span> if (null != metaProvider) {<a name="line.222"></a> -<span class="sourceLineNo">223</span> try {<a name="line.223"></a> -<span class="sourceLineNo">224</span> metaProvider.shutdown();<a name="line.224"></a> -<span class="sourceLineNo">225</span> } catch(IOException ioe) {<a name="line.225"></a> -<span class="sourceLineNo">226</span> exception = ioe;<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> provider.shutdown();<a name="line.229"></a> -<span class="sourceLineNo">230</span> if (null != exception) {<a name="line.230"></a> -<span class="sourceLineNo">231</span> throw exception;<a name="line.231"></a> -<span class="sourceLineNo">232</span> }<a name="line.232"></a> -<span class="sourceLineNo">233</span> }<a name="line.233"></a> -<span class="sourceLineNo">234</span><a name="line.234"></a> -<span class="sourceLineNo">235</span> public List<WAL> getWALs() {<a name="line.235"></a> -<span class="sourceLineNo">236</span> return provider.getWALs();<a name="line.236"></a> -<span class="sourceLineNo">237</span> }<a name="line.237"></a> -<span class="sourceLineNo">238</span><a name="line.238"></a> -<span class="sourceLineNo">239</span> /**<a name="line.239"></a> -<span class="sourceLineNo">240</span> * @param identifier may not be null, contents will not be altered<a name="line.240"></a> -<span class="sourceLineNo">241</span> * @param namespace could be null, and will use default namespace if null<a name="line.241"></a> -<span class="sourceLineNo">242</span> */<a name="line.242"></a> -<span class="sourceLineNo">243</span> public WAL getWAL(final byte[] identifier, final byte[] namespace) throws IOException {<a name="line.243"></a> -<span class="sourceLineNo">244</span> return provider.getWAL(identifier, namespace);<a name="line.244"></a> -<span class="sourceLineNo">245</span> }<a name="line.245"></a> -<span class="sourceLineNo">246</span><a name="line.246"></a> -<span class="sourceLineNo">247</span> /**<a name="line.247"></a> -<span class="sourceLineNo">248</span> * @param identifier may not be null, contents will not be altered<a name="line.248"></a> -<span class="sourceLineNo">249</span> */<a name="line.249"></a> -<span class="sourceLineNo">250</span> public WAL getMetaWAL(final byte[] identifier) throws IOException {<a name="line.250"></a> -<span class="sourceLineNo">251</span> WALProvider metaProvider = this.metaProvider.get();<a name="line.251"></a> -<span class="sourceLineNo">252</span> if (null == metaProvider) {<a name="line.252"></a> -<span class="sourceLineNo">253</span> final WALProvider temp = getProvider(META_WAL_PROVIDER, DEFAULT_META_WAL_PROVIDER,<a name="line.253"></a> -<span class="sourceLineNo">254</span> Collections.<WALActionsListener>singletonList(new MetricsWAL()),<a name="line.254"></a> -<span class="sourceLineNo">255</span> AbstractFSWALProvider.META_WAL_PROVIDER_ID);<a name="line.255"></a> -<span class="sourceLineNo">256</span> if (this.metaProvider.compareAndSet(null, temp)) {<a name="line.256"></a> -<span class="sourceLineNo">257</span> metaProvider = temp;<a name="line.257"></a> -<span class="sourceLineNo">258</span> } else {<a name="line.258"></a> -<span class="sourceLineNo">259</span> // reference must now be to a provider created in another thread.<a name="line.259"></a> -<span class="sourceLineNo">260</span> temp.close();<a name="line.260"></a> -<span class="sourceLineNo">261</span> metaProvider = this.metaProvider.get();<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> return metaProvider.getWAL(identifier, null);<a name="line.264"></a> +<span class="sourceLineNo">090</span> final String factoryId;<a name="line.90"></a> +<span class="sourceLineNo">091</span> private final WALProvider provider;<a name="line.91"></a> +<span class="sourceLineNo">092</span> // The meta updates are written to a different wal. If this<a name="line.92"></a> +<span class="sourceLineNo">093</span> // regionserver holds meta regions, then this ref will be non-null.<a name="line.93"></a> +<span class="sourceLineNo">094</span> // lazily intialized; most RegionServers don't deal with META<a name="line.94"></a> +<span class="sourceLineNo">095</span> private final AtomicReference<WALProvider> metaProvider = new AtomicReference<>();<a name="line.95"></a> +<span class="sourceLineNo">096</span><a name="line.96"></a> +<span class="sourceLineNo">097</span> /**<a name="line.97"></a> +<span class="sourceLineNo">098</span> * Configuration-specified WAL Reader used when a custom reader is requested<a name="line.98"></a> +<span class="sourceLineNo">099</span> */<a name="line.99"></a> +<span class="sourceLineNo">100</span> private final Class<? extends AbstractFSWALProvider.Reader> logReaderClass;<a name="line.100"></a> +<span class="sourceLineNo">101</span><a name="line.101"></a> +<span class="sourceLineNo">102</span> /**<a name="line.102"></a> +<span class="sourceLineNo">103</span> * How long to attempt opening in-recovery wals<a name="line.103"></a> +<span class="sourceLineNo">104</span> */<a name="line.104"></a> +<span class="sourceLineNo">105</span> private final int timeoutMillis;<a name="line.105"></a> +<span class="sourceLineNo">106</span><a name="line.106"></a> +<span class="sourceLineNo">107</span> private final Configuration conf;<a name="line.107"></a> +<span class="sourceLineNo">108</span><a name="line.108"></a> +<span class="sourceLineNo">109</span> // Used for the singleton WALFactory, see below.<a name="line.109"></a> +<span class="sourceLineNo">110</span> private WALFactory(Configuration conf) {<a name="line.110"></a> +<span class="sourceLineNo">111</span> // this code is duplicated here so we can keep our members final.<a name="line.111"></a> +<span class="sourceLineNo">112</span> // until we've moved reader/writer construction down into providers, this initialization must<a name="line.112"></a> +<span class="sourceLineNo">113</span> // happen prior to provider initialization, in case they need to instantiate a reader/writer.<a name="line.113"></a> +<span class="sourceLineNo">114</span> timeoutMillis = conf.getInt("hbase.hlog.open.timeout", 300000);<a name="line.114"></a> +<span class="sourceLineNo">115</span> /* TODO Both of these are probably specific to the fs wal provider */<a name="line.115"></a> +<span class="sourceLineNo">116</span> logReaderClass = conf.getClass("hbase.regionserver.hlog.reader.impl", ProtobufLogReader.class,<a name="line.116"></a> +<span class="sourceLineNo">117</span> AbstractFSWALProvider.Reader.class);<a name="line.117"></a> +<span class="sourceLineNo">118</span> this.conf = conf;<a name="line.118"></a> +<span class="sourceLineNo">119</span> // end required early initialization<a name="line.119"></a> +<span class="sourceLineNo">120</span><a name="line.120"></a> +<span class="sourceLineNo">121</span> // this instance can't create wals, just reader/writers.<a name="line.121"></a> +<span class="sourceLineNo">122</span> provider = null;<a name="line.122"></a> +<span class="sourceLineNo">123</span> factoryId = SINGLETON_ID;<a name="line.123"></a> +<span class="sourceLineNo">124</span> }<a name="line.124"></a> +<span class="sourceLineNo">125</span><a name="line.125"></a> +<span class="sourceLineNo">126</span> @VisibleForTesting<a name="line.126"></a> +<span class="sourceLineNo">127</span> public Class<? extends WALProvider> getProviderClass(String key, String defaultValue) {<a name="line.127"></a> +<span class="sourceLineNo">128</span> try {<a name="line.128"></a> +<span class="sourceLineNo">129</span> return Providers.valueOf(conf.get(key, defaultValue)).clazz;<a name="line.129"></a> +<span class="sourceLineNo">130</span> } catch (IllegalArgumentException exception) {<a name="line.130"></a> +<span class="sourceLineNo">131</span> // Fall back to them specifying a class name<a name="line.131"></a> +<span class="sourceLineNo">132</span> // Note that the passed default class shouldn't actually be used, since the above only fails<a name="line.132"></a> +<span class="sourceLineNo">133</span> // when there is a config value present.<a name="line.133"></a> +<span class="sourceLineNo">134</span> return conf.getClass(key, Providers.defaultProvider.clazz, WALProvider.class);<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><a name="line.137"></a> +<span class="sourceLineNo">138</span> WALProvider createProvider(Class<? extends WALProvider> clazz,<a name="line.138"></a> +<span class="sourceLineNo">139</span> List<WALActionsListener> listeners, String providerId) throws IOException {<a name="line.139"></a> +<span class="sourceLineNo">140</span> LOG.info("Instantiating WALProvider of type " + clazz);<a name="line.140"></a> +<span class="sourceLineNo">141</span> try {<a name="line.141"></a> +<span class="sourceLineNo">142</span> final WALProvider result = clazz.newInstance();<a name="line.142"></a> +<span class="sourceLineNo">143</span> result.init(this, conf, listeners, providerId);<a name="line.143"></a> +<span class="sourceLineNo">144</span> return result;<a name="line.144"></a> +<span class="sourceLineNo">145</span> } catch (InstantiationException exception) {<a name="line.145"></a> +<span class="sourceLineNo">146</span> LOG.error("couldn't set up WALProvider, the configured class is " + clazz);<a name="line.146"></a> +<span class="sourceLineNo">147</span> LOG.debug("Exception details for failure to load WALProvider.", exception);<a name="line.147"></a> +<span class="sourceLineNo">148</span> throw new IOException("couldn't set up WALProvider", exception);<a name="line.148"></a> +<span class="sourceLineNo">149</span> } catch (IllegalAccessException exception) {<a name="line.149"></a> +<span class="sourceLineNo">150</span> LOG.error("couldn't set up WALProvider, the configured class is " + clazz);<a name="line.150"></a> +<span class="sourceLineNo">151</span> LOG.debug("Exception details for failure to load WALProvider.", exception);<a name="line.151"></a> +<span class="sourceLineNo">152</span> throw new IOException("couldn't set up WALProvider", exception);<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> /**<a name="line.156"></a> +<span class="sourceLineNo">157</span> * instantiate a provider from a config property.<a name="line.157"></a> +<span class="sourceLineNo">158</span> * requires conf to have already been set (as well as anything the provider might need to read).<a name="line.158"></a> +<span class="sourceLineNo">159</span> */<a name="line.159"></a> +<span class="sourceLineNo">160</span> WALProvider getProvider(final String key, final String defaultValue,<a name="line.160"></a> +<span class="sourceLineNo">161</span> final List<WALActionsListener> listeners, final String providerId) throws IOException {<a name="line.161"></a> +<span class="sourceLineNo">162</span> Class<? extends WALProvider> clazz = getProviderClass(key, defaultValue);<a name="line.162"></a> +<span class="sourceLineNo">163</span> return createProvider(clazz, listeners, providerId);<a name="line.163"></a> +<span class="sourceLineNo">164</span> }<a name="line.164"></a> +<span class="sourceLineNo">165</span><a name="line.165"></a> +<span class="sourceLineNo">166</span> /**<a name="line.166"></a> +<span class="sourceLineNo">167</span> * @param conf must not be null, will keep a reference to read params in later reader/writer<a name="line.167"></a> +<span class="sourceLineNo">168</span> * instances.<a name="line.168"></a> +<span class="sourceLineNo">169</span> * @param listeners may be null. will be given to all created wals (and not meta-wals)<a name="line.169"></a> +<span class="sourceLineNo">170</span> * @param factoryId a unique identifier for this factory. used i.e. by filesystem implementations<a name="line.170"></a> +<span class="sourceLineNo">171</span> * to make a directory<a name="line.171"></a> +<span class="sourceLineNo">172</span> */<a name="line.172"></a> +<span class="sourceLineNo">173</span> public WALFactory(final Configuration conf, final List<WALActionsListener> listeners,<a name="line.173"></a> +<span class="sourceLineNo">174</span> final String factoryId) throws IOException {<a name="line.174"></a> +<span class="sourceLineNo">175</span> // until we've moved reader/writer construction down into providers, this initialization must<a name="line.175"></a> +<span class="sourceLineNo">176</span> // happen prior to provider initialization, in case they need to instantiate a reader/writer.<a name="line.176"></a> +<span class="sourceLineNo">177</span> timeoutMillis = conf.getInt("hbase.hlog.open.timeout", 300000);<a name="line.177"></a> +<span class="sourceLineNo">178</span> /* TODO Both of these are probably specific to the fs wal provider */<a name="line.178"></a> +<span class="sourceLineNo">179</span> logReaderClass = conf.getClass("hbase.regionserver.hlog.reader.impl", ProtobufLogReader.class,<a name="line.179"></a> +<span class="sourceLineNo">180</span> AbstractFSWALProvider.Reader.class);<a name="line.180"></a> +<span class="sourceLineNo">181</span> this.conf = conf;<a name="line.181"></a> +<span class="sourceLineNo">182</span> this.factoryId = factoryId;<a name="line.182"></a> +<span class="sourceLineNo">183</span> // end required early initialization<a name="line.183"></a> +<span class="sourceLineNo">184</span> if (conf.getBoolean("hbase.regionserver.hlog.enabled", true)) {<a name="line.184"></a> +<span class="sourceLineNo">185</span> provider = getProvider(WAL_PROVIDER, DEFAULT_WAL_PROVIDER, listeners, null);<a name="line.185"></a> +<span class="sourceLineNo">186</span> } else {<a name="line.186"></a> +<span class="sourceLineNo">187</span> // special handling of existing configuration behavior.<a name="line.187"></a> +<span class="sourceLineNo">188</span> LOG.warn("Running with WAL disabled.");<a name="line.188"></a> +<span class="sourceLineNo">189</span> provider = new DisabledWALProvider();<a name="line.189"></a> +<span class="sourceLineNo">190</span> provider.init(this, conf, null, factoryId);<a name="line.190"></a> +<span class="sourceLineNo">191</span> }<a name="line.191"></a> +<span class="sourceLineNo">192</span> }<a name="line.192"></a> +<span class="sourceLineNo">193</span><a name="line.193"></a> +<span class="sourceLineNo">194</span> /**<a name="line.194"></a> +<span class="sourceLineNo">195</span> * Shutdown all WALs and clean up any underlying storage.<a name="line.195"></a> +<span class="sourceLineNo">196</span> * Use only when you will not need to replay and edits that have gone to any wals from this<a name="line.196"></a> +<span class="sourceLineNo">197</span> * factory.<a name="line.197"></a> +<span class="sourceLineNo">198</span> */<a name="line.198"></a> +<span class="sourceLineNo">199</span> public void close() throws IOException {<a name="line.199"></a> +<span class="sourceLineNo">200</span> final WALProvider metaProvider = this.metaProvider.get();<a name="line.200"></a> +<span class="sourceLineNo">201</span> if (null != metaProvider) {<a name="line.201"></a> +<span class="sourceLineNo">202</span> metaProvider.close();<a name="line.202"></a> +<span class="sourceLineNo">203</span> }<a name="line.203"></a> +<span class="sourceLineNo">204</span> // close is called on a WALFactory with null provider in the case of contention handling<a name="line.204"></a> +<span class="sourceLineNo">205</span> // within the getInstance method.<a name="line.205"></a> +<span class="sourceLineNo">206</span> if (null != provider) {<a name="line.206"></a> +<span class="sourceLineNo">207</span> provider.close();<a name="line.207"></a> +<span class="sourceLineNo">208</span> }<a name="line.208"></a> +<span class="sourceLineNo">209</span> }<a name="line.209"></a> +<span class="sourceLineNo">210</span><a name="line.210"></a> +<span class="sourceLineNo">211</span> /**<a name="line.211"></a> +<span class="sourceLineNo">212</span> * Tell the underlying WAL providers to shut down, but do not clean up underlying storage.<a name="line.212"></a> +<span class="sourceLineNo">213</span> * If you are not ending cleanly and will need to replay edits from this factory's wals,<a name="line.213"></a> +<span class="sourceLineNo">214</span> * use this method if you can as it will try to leave things as tidy as possible.<a name="line.214"></a> +<span class="sourceLineNo">215</span> */<a name="line.215"></a> +<span class="sourceLineNo">216</span> public void shutdown() throws IOException {<a name="line.216"></a> +<span class="sourceLineNo">217</span> IOException exception = null;<a name="line.217"></a> +<span class="sourceLineNo">218</span> final WALProvider metaProvider = this.metaProvider.get();<a name="line.218"></a> +<span class="sourceLineNo">219</span> if (null != metaProvider) {<a name="line.219"></a> +<span class="sourceLineNo">220</span> try {<a name="line.220"></a> +<span class="sourceLineNo">221</span> metaProvider.shutdown();<a name="line.221"></a> +<span class="sourceLineNo">222</span> } catch(IOException ioe) {<a name="line.222"></a> +<span class="sourceLineNo">223</span> exception = ioe;<a name="line.223"></a> +<span class="sourceLineNo">224</span> }<a name="line.224"></a> +<span class="sourceLineNo">225</span> }<a name="line.225"></a> +<span class="sourceLineNo">226</span> provider.shutdown();<a name="line.226"></a> +<span class="sourceLineNo">227</span> if (null != exception) {<a name="line.227"></a> +<span class="sourceLineNo">228</span> throw exception;<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> public List<WAL> getWALs() {<a name="line.232"></a> +<span class="sourceLineNo">233</span> return provider.getWALs();<a name="line.233"></a> +<span class="sourceLineNo">234</span> }<a name="line.234"></a> +<span class="sourceLineNo">235</span><a name="line.235"></a> +<span class="sourceLineNo">236</span> private WALProvider getMetaProvider() throws IOException {<a name="line.236"></a> +<span class="sourceLineNo">237</span> for (;;) {<a name="line.237"></a> +<span class="sourceLineNo">238</span> WALProvider provider = this.metaProvider.get();<a name="line.238"></a> +<span class="sourceLineNo">239</span> if (provider != null) {<a name="line.239"></a> +<span class="sourceLineNo">240</span> return provider;<a name="line.240"></a> +<span class="sourceLineNo">241</span> }<a name="line.241"></a> +<span class="sourceLineNo">242</span> provider = getProvider(META_WAL_PROVIDER, DEFAULT_META_WAL_PROVIDER,<a name="line.242"></a> +<span class="sourceLineNo">243</span> Collections.<WALActionsListener> singletonList(new MetricsWAL()),<a name="line.243"></a> +<span class="sourceLineNo">244</span> AbstractFSWALProvider.META_WAL_PROVIDER_ID);<a name="line.244"></a> +<span class="sourceLineNo">245</span> if (metaProvider.compareAndSet(null, provider)) {<a name="line.245"></a> +<span class="sourceLineNo">246</span> return provider;<a name="line.246"></a> +<span class="sourceLineNo">247</span> } else {<a name="line.247"></a> +<span class="sourceLineNo">248</span> // someone is ahead of us, close and try again.<a name="line.248"></a> +<span class="sourceLineNo">249</span> provider.close();<a name="line.249"></a> +<span class="sourceLineNo">250</span> }<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><a name="line.253"></a> +<span class="sourceLineNo">254</span> /**<a name="line.254"></a> +<span class="sourceLineNo">255</span> * @param region the region which we want to get a WAL for it. Could be null.<a name="line.255"></a> +<span class="sourceLineNo">256</span> */<a name="line.256"></a> +<span class="sourceLineNo">257</span> public WAL getWAL(RegionInfo region) throws IOException {<a name="line.257"></a> +<span class="sourceLineNo">258</span> // use different WAL for hbase:meta<a name="line.258"></a> +<span class="sourceLineNo">259</span> if (region != null && region.isMetaRegion() &&<a name="line.259"></a> +<span class="sourceLineNo">260</span> region.getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID) {<a name="line.260"></a> +<span class="sourceLineNo">261</span> return getMetaProvider().getWAL(region);<a name="line.261"></a> +<span class="sourceLineNo">262</span> } else {<a name="line.262"></a> +<span class="sourceLineNo">263</span> return provider.getWAL(region);<a name="line.263"></a> +<span class="sourceLineNo">264</span> }<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> public Reader createReader(final FileSystem fs, final Path path) throws IOException {<a name="line.267"></a>
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/f183e80f/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALProvider.AsyncWriter.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALProvider.AsyncWriter.html b/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALProvider.AsyncWriter.html index 59680d7..e118e2f 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALProvider.AsyncWriter.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALProvider.AsyncWriter.html @@ -30,87 +30,86 @@ <span class="sourceLineNo">022</span>import java.io.IOException;<a name="line.22"></a> <span class="sourceLineNo">023</span>import java.util.List;<a name="line.23"></a> <span class="sourceLineNo">024</span>import java.util.concurrent.CompletableFuture;<a name="line.24"></a> -<span class="sourceLineNo">025</span><a name="line.25"></a> -<span class="sourceLineNo">026</span>import org.apache.hadoop.conf.Configuration;<a name="line.26"></a> -<span class="sourceLineNo">027</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.27"></a> -<span class="sourceLineNo">028</span>// imports for things that haven't moved from regionserver.wal yet.<a name="line.28"></a> -<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;<a name="line.29"></a> -<span class="sourceLineNo">030</span><a name="line.30"></a> -<span class="sourceLineNo">031</span>/**<a name="line.31"></a> -<span class="sourceLineNo">032</span> * The Write Ahead Log (WAL) stores all durable edits to the HRegion.<a name="line.32"></a> -<span class="sourceLineNo">033</span> * This interface provides the entry point for all WAL implementors.<a name="line.33"></a> -<span class="sourceLineNo">034</span> * <p><a name="line.34"></a> -<span class="sourceLineNo">035</span> * See {@link FSHLogProvider} for an example implementation.<a name="line.35"></a> -<span class="sourceLineNo">036</span> *<a name="line.36"></a> -<span class="sourceLineNo">037</span> * A single WALProvider will be used for retrieving multiple WALs in a particular region server<a name="line.37"></a> -<span class="sourceLineNo">038</span> * and must be threadsafe.<a name="line.38"></a> -<span class="sourceLineNo">039</span> */<a name="line.39"></a> -<span class="sourceLineNo">040</span>@InterfaceAudience.Private<a name="line.40"></a> -<span class="sourceLineNo">041</span>public interface WALProvider {<a name="line.41"></a> -<span class="sourceLineNo">042</span><a name="line.42"></a> -<span class="sourceLineNo">043</span> /**<a name="line.43"></a> -<span class="sourceLineNo">044</span> * Set up the provider to create wals.<a name="line.44"></a> -<span class="sourceLineNo">045</span> * will only be called once per instance.<a name="line.45"></a> -<span class="sourceLineNo">046</span> * @param factory factory that made us may not be null<a name="line.46"></a> -<span class="sourceLineNo">047</span> * @param conf may not be null<a name="line.47"></a> -<span class="sourceLineNo">048</span> * @param listeners may be null<a name="line.48"></a> -<span class="sourceLineNo">049</span> * @param providerId differentiate between providers from one factory. may be null<a name="line.49"></a> -<span class="sourceLineNo">050</span> */<a name="line.50"></a> -<span class="sourceLineNo">051</span> void init(final WALFactory factory, final Configuration conf,<a name="line.51"></a> -<span class="sourceLineNo">052</span> final List<WALActionsListener> listeners, final String providerId) throws IOException;<a name="line.52"></a> -<span class="sourceLineNo">053</span><a name="line.53"></a> -<span class="sourceLineNo">054</span> /**<a name="line.54"></a> -<span class="sourceLineNo">055</span> * @param identifier may not be null. contents will not be altered.<a name="line.55"></a> -<span class="sourceLineNo">056</span> * @param namespace could be null, and will use default namespace if null<a name="line.56"></a> -<span class="sourceLineNo">057</span> * @return a WAL for writing entries for the given region.<a name="line.57"></a> -<span class="sourceLineNo">058</span> */<a name="line.58"></a> -<span class="sourceLineNo">059</span> WAL getWAL(final byte[] identifier, byte[] namespace) throws IOException;<a name="line.59"></a> -<span class="sourceLineNo">060</span><a name="line.60"></a> -<span class="sourceLineNo">061</span> /** @return the List of WALs that are used by this server<a name="line.61"></a> -<span class="sourceLineNo">062</span> */<a name="line.62"></a> -<span class="sourceLineNo">063</span> List<WAL> getWALs();<a name="line.63"></a> -<span class="sourceLineNo">064</span><a name="line.64"></a> -<span class="sourceLineNo">065</span> /**<a name="line.65"></a> -<span class="sourceLineNo">066</span> * persist outstanding WALs to storage and stop accepting new appends.<a name="line.66"></a> -<span class="sourceLineNo">067</span> * This method serves as shorthand for sending a sync to every WAL provided by a given<a name="line.67"></a> -<span class="sourceLineNo">068</span> * implementation. Those WALs will also stop accepting new writes.<a name="line.68"></a> -<span class="sourceLineNo">069</span> */<a name="line.69"></a> -<span class="sourceLineNo">070</span> void shutdown() throws IOException;<a name="line.70"></a> -<span class="sourceLineNo">071</span><a name="line.71"></a> -<span class="sourceLineNo">072</span> /**<a name="line.72"></a> -<span class="sourceLineNo">073</span> * shutdown utstanding WALs and clean up any persisted state.<a name="line.73"></a> -<span class="sourceLineNo">074</span> * Call this method only when you will not need to replay any of the edits to the WALs from<a name="line.74"></a> -<span class="sourceLineNo">075</span> * this provider. After this call completes, the underlying resources should have been reclaimed.<a name="line.75"></a> -<span class="sourceLineNo">076</span> */<a name="line.76"></a> -<span class="sourceLineNo">077</span> void close() throws IOException;<a name="line.77"></a> -<span class="sourceLineNo">078</span><a name="line.78"></a> -<span class="sourceLineNo">079</span> interface WriterBase extends Closeable {<a name="line.79"></a> -<span class="sourceLineNo">080</span> long getLength();<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> // Writers are used internally. Users outside of the WAL should be relying on the<a name="line.83"></a> -<span class="sourceLineNo">084</span> // interface provided by WAL.<a name="line.84"></a> -<span class="sourceLineNo">085</span> interface Writer extends WriterBase {<a name="line.85"></a> -<span class="sourceLineNo">086</span> void sync() throws IOException;<a name="line.86"></a> -<span class="sourceLineNo">087</span> void append(WAL.Entry entry) throws IOException;<a name="line.87"></a> -<span class="sourceLineNo">088</span> }<a name="line.88"></a> -<span class="sourceLineNo">089</span><a name="line.89"></a> -<span class="sourceLineNo">090</span> interface AsyncWriter extends WriterBase {<a name="line.90"></a> -<span class="sourceLineNo">091</span> CompletableFuture<Long> sync();<a name="line.91"></a> -<span class="sourceLineNo">092</span> void append(WAL.Entry entry);<a name="line.92"></a> -<span class="sourceLineNo">093</span> }<a name="line.93"></a> -<span class="sourceLineNo">094</span><a name="line.94"></a> -<span class="sourceLineNo">095</span> /**<a name="line.95"></a> -<span class="sourceLineNo">096</span> * Get number of the log files this provider is managing<a name="line.96"></a> -<span class="sourceLineNo">097</span> */<a name="line.97"></a> -<span class="sourceLineNo">098</span> long getNumLogFiles();<a name="line.98"></a> -<span class="sourceLineNo">099</span><a name="line.99"></a> -<span class="sourceLineNo">100</span> /**<a name="line.100"></a> -<span class="sourceLineNo">101</span> * Get size of the log files this provider is managing<a name="line.101"></a> -<span class="sourceLineNo">102</span> */<a name="line.102"></a> -<span class="sourceLineNo">103</span> long getLogFileSize();<a name="line.103"></a> -<span class="sourceLineNo">104</span><a name="line.104"></a> -<span class="sourceLineNo">105</span>}<a name="line.105"></a> +<span class="sourceLineNo">025</span>import org.apache.hadoop.conf.Configuration;<a name="line.25"></a> +<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.client.RegionInfo;<a name="line.26"></a> +<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;<a name="line.27"></a> +<span class="sourceLineNo">028</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.28"></a> +<span class="sourceLineNo">029</span><a name="line.29"></a> +<span class="sourceLineNo">030</span>/**<a name="line.30"></a> +<span class="sourceLineNo">031</span> * The Write Ahead Log (WAL) stores all durable edits to the HRegion.<a name="line.31"></a> +<span class="sourceLineNo">032</span> * This interface provides the entry point for all WAL implementors.<a name="line.32"></a> +<span class="sourceLineNo">033</span> * <p><a name="line.33"></a> +<span class="sourceLineNo">034</span> * See {@link FSHLogProvider} for an example implementation.<a name="line.34"></a> +<span class="sourceLineNo">035</span> *<a name="line.35"></a> +<span class="sourceLineNo">036</span> * A single WALProvider will be used for retrieving multiple WALs in a particular region server<a name="line.36"></a> +<span class="sourceLineNo">037</span> * and must be threadsafe.<a name="line.37"></a> +<span class="sourceLineNo">038</span> */<a name="line.38"></a> +<span class="sourceLineNo">039</span>@InterfaceAudience.Private<a name="line.39"></a> +<span class="sourceLineNo">040</span>public interface WALProvider {<a name="line.40"></a> +<span class="sourceLineNo">041</span><a name="line.41"></a> +<span class="sourceLineNo">042</span> /**<a name="line.42"></a> +<span class="sourceLineNo">043</span> * Set up the provider to create wals.<a name="line.43"></a> +<span class="sourceLineNo">044</span> * will only be called once per instance.<a name="line.44"></a> +<span class="sourceLineNo">045</span> * @param factory factory that made us may not be null<a name="line.45"></a> +<span class="sourceLineNo">046</span> * @param conf may not be null<a name="line.46"></a> +<span class="sourceLineNo">047</span> * @param listeners may be null<a name="line.47"></a> +<span class="sourceLineNo">048</span> * @param providerId differentiate between providers from one factory. may be null<a name="line.48"></a> +<span class="sourceLineNo">049</span> */<a name="line.49"></a> +<span class="sourceLineNo">050</span> void init(WALFactory factory, Configuration conf, List<WALActionsListener> listeners,<a name="line.50"></a> +<span class="sourceLineNo">051</span> String providerId) throws IOException;<a name="line.51"></a> +<span class="sourceLineNo">052</span><a name="line.52"></a> +<span class="sourceLineNo">053</span> /**<a name="line.53"></a> +<span class="sourceLineNo">054</span> * @param region the region which we want to get a WAL for it. Could be null.<a name="line.54"></a> +<span class="sourceLineNo">055</span> * @return a WAL for writing entries for the given region.<a name="line.55"></a> +<span class="sourceLineNo">056</span> */<a name="line.56"></a> +<span class="sourceLineNo">057</span> WAL getWAL(RegionInfo region) throws IOException;<a name="line.57"></a> +<span class="sourceLineNo">058</span><a name="line.58"></a> +<span class="sourceLineNo">059</span> /**<a name="line.59"></a> +<span class="sourceLineNo">060</span> * @return the List of WALs that are used by this server<a name="line.60"></a> +<span class="sourceLineNo">061</span> */<a name="line.61"></a> +<span class="sourceLineNo">062</span> List<WAL> getWALs();<a name="line.62"></a> +<span class="sourceLineNo">063</span><a name="line.63"></a> +<span class="sourceLineNo">064</span> /**<a name="line.64"></a> +<span class="sourceLineNo">065</span> * persist outstanding WALs to storage and stop accepting new appends.<a name="line.65"></a> +<span class="sourceLineNo">066</span> * This method serves as shorthand for sending a sync to every WAL provided by a given<a name="line.66"></a> +<span class="sourceLineNo">067</span> * implementation. Those WALs will also stop accepting new writes.<a name="line.67"></a> +<span class="sourceLineNo">068</span> */<a name="line.68"></a> +<span class="sourceLineNo">069</span> void shutdown() throws IOException;<a name="line.69"></a> +<span class="sourceLineNo">070</span><a name="line.70"></a> +<span class="sourceLineNo">071</span> /**<a name="line.71"></a> +<span class="sourceLineNo">072</span> * shutdown utstanding WALs and clean up any persisted state.<a name="line.72"></a> +<span class="sourceLineNo">073</span> * Call this method only when you will not need to replay any of the edits to the WALs from<a name="line.73"></a> +<span class="sourceLineNo">074</span> * this provider. After this call completes, the underlying resources should have been reclaimed.<a name="line.74"></a> +<span class="sourceLineNo">075</span> */<a name="line.75"></a> +<span class="sourceLineNo">076</span> void close() throws IOException;<a name="line.76"></a> +<span class="sourceLineNo">077</span><a name="line.77"></a> +<span class="sourceLineNo">078</span> interface WriterBase extends Closeable {<a name="line.78"></a> +<span class="sourceLineNo">079</span> long getLength();<a name="line.79"></a> +<span class="sourceLineNo">080</span> }<a name="line.80"></a> +<span class="sourceLineNo">081</span><a name="line.81"></a> +<span class="sourceLineNo">082</span> // Writers are used internally. Users outside of the WAL should be relying on the<a name="line.82"></a> +<span class="sourceLineNo">083</span> // interface provided by WAL.<a name="line.83"></a> +<span class="sourceLineNo">084</span> interface Writer extends WriterBase {<a name="line.84"></a> +<span class="sourceLineNo">085</span> void sync() throws IOException;<a name="line.85"></a> +<span class="sourceLineNo">086</span> void append(WAL.Entry entry) throws IOException;<a name="line.86"></a> +<span class="sourceLineNo">087</span> }<a name="line.87"></a> +<span class="sourceLineNo">088</span><a name="line.88"></a> +<span class="sourceLineNo">089</span> interface AsyncWriter extends WriterBase {<a name="line.89"></a> +<span class="sourceLineNo">090</span> CompletableFuture<Long> sync();<a name="line.90"></a> +<span class="sourceLineNo">091</span> void append(WAL.Entry entry);<a name="line.91"></a> +<span class="sourceLineNo">092</span> }<a name="line.92"></a> +<span class="sourceLineNo">093</span><a name="line.93"></a> +<span class="sourceLineNo">094</span> /**<a name="line.94"></a> +<span class="sourceLineNo">095</span> * Get number of the log files this provider is managing<a name="line.95"></a> +<span class="sourceLineNo">096</span> */<a name="line.96"></a> +<span class="sourceLineNo">097</span> long getNumLogFiles();<a name="line.97"></a> +<span class="sourceLineNo">098</span><a name="line.98"></a> +<span class="sourceLineNo">099</span> /**<a name="line.99"></a> +<span class="sourceLineNo">100</span> * Get size of the log files this provider is managing<a name="line.100"></a> +<span class="sourceLineNo">101</span> */<a name="line.101"></a> +<span class="sourceLineNo">102</span> long getLogFileSize();<a name="line.102"></a> +<span class="sourceLineNo">103</span><a name="line.103"></a> +<span class="sourceLineNo">104</span>}<a name="line.104"></a> http://git-wip-us.apache.org/repos/asf/hbase-site/blob/f183e80f/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALProvider.Writer.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALProvider.Writer.html b/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALProvider.Writer.html index 59680d7..e118e2f 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALProvider.Writer.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/wal/WALProvider.Writer.html @@ -30,87 +30,86 @@ <span class="sourceLineNo">022</span>import java.io.IOException;<a name="line.22"></a> <span class="sourceLineNo">023</span>import java.util.List;<a name="line.23"></a> <span class="sourceLineNo">024</span>import java.util.concurrent.CompletableFuture;<a name="line.24"></a> -<span class="sourceLineNo">025</span><a name="line.25"></a> -<span class="sourceLineNo">026</span>import org.apache.hadoop.conf.Configuration;<a name="line.26"></a> -<span class="sourceLineNo">027</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.27"></a> -<span class="sourceLineNo">028</span>// imports for things that haven't moved from regionserver.wal yet.<a name="line.28"></a> -<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;<a name="line.29"></a> -<span class="sourceLineNo">030</span><a name="line.30"></a> -<span class="sourceLineNo">031</span>/**<a name="line.31"></a> -<span class="sourceLineNo">032</span> * The Write Ahead Log (WAL) stores all durable edits to the HRegion.<a name="line.32"></a> -<span class="sourceLineNo">033</span> * This interface provides the entry point for all WAL implementors.<a name="line.33"></a> -<span class="sourceLineNo">034</span> * <p><a name="line.34"></a> -<span class="sourceLineNo">035</span> * See {@link FSHLogProvider} for an example implementation.<a name="line.35"></a> -<span class="sourceLineNo">036</span> *<a name="line.36"></a> -<span class="sourceLineNo">037</span> * A single WALProvider will be used for retrieving multiple WALs in a particular region server<a name="line.37"></a> -<span class="sourceLineNo">038</span> * and must be threadsafe.<a name="line.38"></a> -<span class="sourceLineNo">039</span> */<a name="line.39"></a> -<span class="sourceLineNo">040</span>@InterfaceAudience.Private<a name="line.40"></a> -<span class="sourceLineNo">041</span>public interface WALProvider {<a name="line.41"></a> -<span class="sourceLineNo">042</span><a name="line.42"></a> -<span class="sourceLineNo">043</span> /**<a name="line.43"></a> -<span class="sourceLineNo">044</span> * Set up the provider to create wals.<a name="line.44"></a> -<span class="sourceLineNo">045</span> * will only be called once per instance.<a name="line.45"></a> -<span class="sourceLineNo">046</span> * @param factory factory that made us may not be null<a name="line.46"></a> -<span class="sourceLineNo">047</span> * @param conf may not be null<a name="line.47"></a> -<span class="sourceLineNo">048</span> * @param listeners may be null<a name="line.48"></a> -<span class="sourceLineNo">049</span> * @param providerId differentiate between providers from one factory. may be null<a name="line.49"></a> -<span class="sourceLineNo">050</span> */<a name="line.50"></a> -<span class="sourceLineNo">051</span> void init(final WALFactory factory, final Configuration conf,<a name="line.51"></a> -<span class="sourceLineNo">052</span> final List<WALActionsListener> listeners, final String providerId) throws IOException;<a name="line.52"></a> -<span class="sourceLineNo">053</span><a name="line.53"></a> -<span class="sourceLineNo">054</span> /**<a name="line.54"></a> -<span class="sourceLineNo">055</span> * @param identifier may not be null. contents will not be altered.<a name="line.55"></a> -<span class="sourceLineNo">056</span> * @param namespace could be null, and will use default namespace if null<a name="line.56"></a> -<span class="sourceLineNo">057</span> * @return a WAL for writing entries for the given region.<a name="line.57"></a> -<span class="sourceLineNo">058</span> */<a name="line.58"></a> -<span class="sourceLineNo">059</span> WAL getWAL(final byte[] identifier, byte[] namespace) throws IOException;<a name="line.59"></a> -<span class="sourceLineNo">060</span><a name="line.60"></a> -<span class="sourceLineNo">061</span> /** @return the List of WALs that are used by this server<a name="line.61"></a> -<span class="sourceLineNo">062</span> */<a name="line.62"></a> -<span class="sourceLineNo">063</span> List<WAL> getWALs();<a name="line.63"></a> -<span class="sourceLineNo">064</span><a name="line.64"></a> -<span class="sourceLineNo">065</span> /**<a name="line.65"></a> -<span class="sourceLineNo">066</span> * persist outstanding WALs to storage and stop accepting new appends.<a name="line.66"></a> -<span class="sourceLineNo">067</span> * This method serves as shorthand for sending a sync to every WAL provided by a given<a name="line.67"></a> -<span class="sourceLineNo">068</span> * implementation. Those WALs will also stop accepting new writes.<a name="line.68"></a> -<span class="sourceLineNo">069</span> */<a name="line.69"></a> -<span class="sourceLineNo">070</span> void shutdown() throws IOException;<a name="line.70"></a> -<span class="sourceLineNo">071</span><a name="line.71"></a> -<span class="sourceLineNo">072</span> /**<a name="line.72"></a> -<span class="sourceLineNo">073</span> * shutdown utstanding WALs and clean up any persisted state.<a name="line.73"></a> -<span class="sourceLineNo">074</span> * Call this method only when you will not need to replay any of the edits to the WALs from<a name="line.74"></a> -<span class="sourceLineNo">075</span> * this provider. After this call completes, the underlying resources should have been reclaimed.<a name="line.75"></a> -<span class="sourceLineNo">076</span> */<a name="line.76"></a> -<span class="sourceLineNo">077</span> void close() throws IOException;<a name="line.77"></a> -<span class="sourceLineNo">078</span><a name="line.78"></a> -<span class="sourceLineNo">079</span> interface WriterBase extends Closeable {<a name="line.79"></a> -<span class="sourceLineNo">080</span> long getLength();<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> // Writers are used internally. Users outside of the WAL should be relying on the<a name="line.83"></a> -<span class="sourceLineNo">084</span> // interface provided by WAL.<a name="line.84"></a> -<span class="sourceLineNo">085</span> interface Writer extends WriterBase {<a name="line.85"></a> -<span class="sourceLineNo">086</span> void sync() throws IOException;<a name="line.86"></a> -<span class="sourceLineNo">087</span> void append(WAL.Entry entry) throws IOException;<a name="line.87"></a> -<span class="sourceLineNo">088</span> }<a name="line.88"></a> -<span class="sourceLineNo">089</span><a name="line.89"></a> -<span class="sourceLineNo">090</span> interface AsyncWriter extends WriterBase {<a name="line.90"></a> -<span class="sourceLineNo">091</span> CompletableFuture<Long> sync();<a name="line.91"></a> -<span class="sourceLineNo">092</span> void append(WAL.Entry entry);<a name="line.92"></a> -<span class="sourceLineNo">093</span> }<a name="line.93"></a> -<span class="sourceLineNo">094</span><a name="line.94"></a> -<span class="sourceLineNo">095</span> /**<a name="line.95"></a> -<span class="sourceLineNo">096</span> * Get number of the log files this provider is managing<a name="line.96"></a> -<span class="sourceLineNo">097</span> */<a name="line.97"></a> -<span class="sourceLineNo">098</span> long getNumLogFiles();<a name="line.98"></a> -<span class="sourceLineNo">099</span><a name="line.99"></a> -<span class="sourceLineNo">100</span> /**<a name="line.100"></a> -<span class="sourceLineNo">101</span> * Get size of the log files this provider is managing<a name="line.101"></a> -<span class="sourceLineNo">102</span> */<a name="line.102"></a> -<span class="sourceLineNo">103</span> long getLogFileSize();<a name="line.103"></a> -<span class="sourceLineNo">104</span><a name="line.104"></a> -<span class="sourceLineNo">105</span>}<a name="line.105"></a> +<span class="sourceLineNo">025</span>import org.apache.hadoop.conf.Configuration;<a name="line.25"></a> +<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.client.RegionInfo;<a name="line.26"></a> +<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;<a name="line.27"></a> +<span class="sourceLineNo">028</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.28"></a> +<span class="sourceLineNo">029</span><a name="line.29"></a> +<span class="sourceLineNo">030</span>/**<a name="line.30"></a> +<span class="sourceLineNo">031</span> * The Write Ahead Log (WAL) stores all durable edits to the HRegion.<a name="line.31"></a> +<span class="sourceLineNo">032</span> * This interface provides the entry point for all WAL implementors.<a name="line.32"></a> +<span class="sourceLineNo">033</span> * <p><a name="line.33"></a> +<span class="sourceLineNo">034</span> * See {@link FSHLogProvider} for an example implementation.<a name="line.34"></a> +<span class="sourceLineNo">035</span> *<a name="line.35"></a> +<span class="sourceLineNo">036</span> * A single WALProvider will be used for retrieving multiple WALs in a particular region server<a name="line.36"></a> +<span class="sourceLineNo">037</span> * and must be threadsafe.<a name="line.37"></a> +<span class="sourceLineNo">038</span> */<a name="line.38"></a> +<span class="sourceLineNo">039</span>@InterfaceAudience.Private<a name="line.39"></a> +<span class="sourceLineNo">040</span>public interface WALProvider {<a name="line.40"></a> +<span class="sourceLineNo">041</span><a name="line.41"></a> +<span class="sourceLineNo">042</span> /**<a name="line.42"></a> +<span class="sourceLineNo">043</span> * Set up the provider to create wals.<a name="line.43"></a> +<span class="sourceLineNo">044</span> * will only be called once per instance.<a name="line.44"></a> +<span class="sourceLineNo">045</span> * @param factory factory that made us may not be null<a name="line.45"></a> +<span class="sourceLineNo">046</span> * @param conf may not be null<a name="line.46"></a> +<span class="sourceLineNo">047</span> * @param listeners may be null<a name="line.47"></a> +<span class="sourceLineNo">048</span> * @param providerId differentiate between providers from one factory. may be null<a name="line.48"></a> +<span class="sourceLineNo">049</span> */<a name="line.49"></a> +<span class="sourceLineNo">050</span> void init(WALFactory factory, Configuration conf, List<WALActionsListener> listeners,<a name="line.50"></a> +<span class="sourceLineNo">051</span> String providerId) throws IOException;<a name="line.51"></a> +<span class="sourceLineNo">052</span><a name="line.52"></a> +<span class="sourceLineNo">053</span> /**<a name="line.53"></a> +<span class="sourceLineNo">054</span> * @param region the region which we want to get a WAL for it. Could be null.<a name="line.54"></a> +<span class="sourceLineNo">055</span> * @return a WAL for writing entries for the given region.<a name="line.55"></a> +<span class="sourceLineNo">056</span> */<a name="line.56"></a> +<span class="sourceLineNo">057</span> WAL getWAL(RegionInfo region) throws IOException;<a name="line.57"></a> +<span class="sourceLineNo">058</span><a name="line.58"></a> +<span class="sourceLineNo">059</span> /**<a name="line.59"></a> +<span class="sourceLineNo">060</span> * @return the List of WALs that are used by this server<a name="line.60"></a> +<span class="sourceLineNo">061</span> */<a name="line.61"></a> +<span class="sourceLineNo">062</span> List<WAL> getWALs();<a name="line.62"></a> +<span class="sourceLineNo">063</span><a name="line.63"></a> +<span class="sourceLineNo">064</span> /**<a name="line.64"></a> +<span class="sourceLineNo">065</span> * persist outstanding WALs to storage and stop accepting new appends.<a name="line.65"></a> +<span class="sourceLineNo">066</span> * This method serves as shorthand for sending a sync to every WAL provided by a given<a name="line.66"></a> +<span class="sourceLineNo">067</span> * implementation. Those WALs will also stop accepting new writes.<a name="line.67"></a> +<span class="sourceLineNo">068</span> */<a name="line.68"></a> +<span class="sourceLineNo">069</span> void shutdown() throws IOException;<a name="line.69"></a> +<span class="sourceLineNo">070</span><a name="line.70"></a> +<span class="sourceLineNo">071</span> /**<a name="line.71"></a> +<span class="sourceLineNo">072</span> * shutdown utstanding WALs and clean up any persisted state.<a name="line.72"></a> +<span class="sourceLineNo">073</span> * Call this method only when you will not need to replay any of the edits to the WALs from<a name="line.73"></a> +<span class="sourceLineNo">074</span> * this provider. After this call completes, the underlying resources should have been reclaimed.<a name="line.74"></a> +<span class="sourceLineNo">075</span> */<a name="line.75"></a> +<span class="sourceLineNo">076</span> void close() throws IOException;<a name="line.76"></a> +<span class="sourceLineNo">077</span><a name="line.77"></a> +<span class="sourceLineNo">078</span> interface WriterBase extends Closeable {<a name="line.78"></a> +<span class="sourceLineNo">079</span> long getLength();<a name="line.79"></a> +<span class="sourceLineNo">080</span> }<a name="line.80"></a> +<span class="sourceLineNo">081</span><a name="line.81"></a> +<span class="sourceLineNo">082</span> // Writers are used internally. Users outside of the WAL should be relying on the<a name="line.82"></a> +<span class="sourceLineNo">083</span> // interface provided by WAL.<a name="line.83"></a> +<span class="sourceLineNo">084</span> interface Writer extends WriterBase {<a name="line.84"></a> +<span class="sourceLineNo">085</span> void sync() throws IOException;<a name="line.85"></a> +<span class="sourceLineNo">086</span> void append(WAL.Entry entry) throws IOException;<a name="line.86"></a> +<span class="sourceLineNo">087</span> }<a name="line.87"></a> +<span class="sourceLineNo">088</span><a name="line.88"></a> +<span class="sourceLineNo">089</span> interface AsyncWriter extends WriterBase {<a name="line.89"></a> +<span class="sourceLineNo">090</span> CompletableFuture<Long> sync();<a name="line.90"></a> +<span class="sourceLineNo">091</span> void append(WAL.Entry entry);<a name="line.91"></a> +<span class="sourceLineNo">092</span> }<a name="line.92"></a> +<span class="sourceLineNo">093</span><a name="line.93"></a> +<span class="sourceLineNo">094</span> /**<a name="line.94"></a> +<span class="sourceLineNo">095</span> * Get number of the log files this provider is managing<a name="line.95"></a> +<span class="sourceLineNo">096</span> */<a name="line.96"></a> +<span class="sourceLineNo">097</span> long getNumLogFiles();<a name="line.97"></a> +<span class="sourceLineNo">098</span><a name="line.98"></a> +<span class="sourceLineNo">099</span> /**<a name="line.99"></a> +<span class="sourceLineNo">100</span> * Get size of the log files this provider is managing<a name="line.100"></a> +<span class="sourceLineNo">101</span> */<a name="line.101"></a> +<span class="sourceLineNo">102</span> long getLogFileSize();<a name="line.102"></a> +<span class="sourceLineNo">103</span><a name="line.103"></a> +<span class="sourceLineNo">104</span>}<a name="line.104"></a>