hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [14/51] [partial] hbase-site git commit: Published site at 82d554e3783372cc6b05489452c815b57c06f6cd.
Date Sat, 10 Jun 2017 15:00:04 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/476c54ed/devapidocs/src-html/org/apache/hadoop/hbase/quotas/SpaceQuotaSnapshot.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/quotas/SpaceQuotaSnapshot.html b/devapidocs/src-html/org/apache/hadoop/hbase/quotas/SpaceQuotaSnapshot.html
index 3a57bbd..b408e5f 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/quotas/SpaceQuotaSnapshot.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/quotas/SpaceQuotaSnapshot.html
@@ -30,182 +30,184 @@
 <span class="sourceLineNo">022</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.22"></a>
 <span class="sourceLineNo">023</span>import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;<a name="line.23"></a>
 <span class="sourceLineNo">024</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos;<a name="line.24"></a>
-<span class="sourceLineNo">025</span><a name="line.25"></a>
-<span class="sourceLineNo">026</span>/**<a name="line.26"></a>
-<span class="sourceLineNo">027</span> * A point-in-time view of a space quota on a table.<a name="line.27"></a>
-<span class="sourceLineNo">028</span> */<a name="line.28"></a>
-<span class="sourceLineNo">029</span>@InterfaceAudience.Private<a name="line.29"></a>
-<span class="sourceLineNo">030</span>public class SpaceQuotaSnapshot {<a name="line.30"></a>
-<span class="sourceLineNo">031</span>  private static final SpaceQuotaSnapshot NO_SUCH_SNAPSHOT = new SpaceQuotaSnapshot(<a name="line.31"></a>
-<span class="sourceLineNo">032</span>      SpaceQuotaStatus.notInViolation(), 0, Long.MAX_VALUE);<a name="line.32"></a>
-<span class="sourceLineNo">033</span>  private final SpaceQuotaStatus quotaStatus;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>  private final long usage;<a name="line.34"></a>
-<span class="sourceLineNo">035</span>  private final long limit;<a name="line.35"></a>
-<span class="sourceLineNo">036</span><a name="line.36"></a>
-<span class="sourceLineNo">037</span>  /**<a name="line.37"></a>
-<span class="sourceLineNo">038</span>   * Encapsulates the state of a quota on a table. The quota may or may not be in violation.<a name="line.38"></a>
-<span class="sourceLineNo">039</span>   * If the quota is not in violation, the violation may be null. If the quota is in violation,<a name="line.39"></a>
-<span class="sourceLineNo">040</span>   * there is guaranteed to be a non-null violation policy.<a name="line.40"></a>
-<span class="sourceLineNo">041</span>   */<a name="line.41"></a>
-<span class="sourceLineNo">042</span>  @InterfaceAudience.Private<a name="line.42"></a>
-<span class="sourceLineNo">043</span>  public static class SpaceQuotaStatus {<a name="line.43"></a>
-<span class="sourceLineNo">044</span>    private static final SpaceQuotaStatus NOT_IN_VIOLATION = new SpaceQuotaStatus(null, false);<a name="line.44"></a>
-<span class="sourceLineNo">045</span>    final SpaceViolationPolicy policy;<a name="line.45"></a>
-<span class="sourceLineNo">046</span>    final boolean inViolation;<a name="line.46"></a>
-<span class="sourceLineNo">047</span><a name="line.47"></a>
-<span class="sourceLineNo">048</span>    /**<a name="line.48"></a>
-<span class="sourceLineNo">049</span>     * Constructs a {@code SpaceQuotaSnapshot} which is in violation of the provided {@code policy}.<a name="line.49"></a>
-<span class="sourceLineNo">050</span>     *<a name="line.50"></a>
-<span class="sourceLineNo">051</span>     * Use {@link #notInViolation()} to obtain an instance of this class for the cases when the<a name="line.51"></a>
-<span class="sourceLineNo">052</span>     * quota is not in violation.<a name="line.52"></a>
-<span class="sourceLineNo">053</span>     *<a name="line.53"></a>
-<span class="sourceLineNo">054</span>     * @param policy The non-null policy being violated.<a name="line.54"></a>
-<span class="sourceLineNo">055</span>     */<a name="line.55"></a>
-<span class="sourceLineNo">056</span>    public SpaceQuotaStatus(SpaceViolationPolicy policy) {<a name="line.56"></a>
-<span class="sourceLineNo">057</span>      // If the caller is instantiating a status, the policy must be non-null<a name="line.57"></a>
-<span class="sourceLineNo">058</span>      this (Objects.requireNonNull(policy), true);<a name="line.58"></a>
-<span class="sourceLineNo">059</span>    }<a name="line.59"></a>
-<span class="sourceLineNo">060</span><a name="line.60"></a>
-<span class="sourceLineNo">061</span>    private SpaceQuotaStatus(SpaceViolationPolicy policy, boolean inViolation) {<a name="line.61"></a>
-<span class="sourceLineNo">062</span>      this.policy = policy;<a name="line.62"></a>
-<span class="sourceLineNo">063</span>      this.inViolation = inViolation;<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>    /**<a name="line.66"></a>
-<span class="sourceLineNo">067</span>     * Returns the violation policy, which may be null. It is guaranteed to be non-null if<a name="line.67"></a>
-<span class="sourceLineNo">068</span>     * {@link #isInViolation()} is {@code true}, but may be null otherwise.<a name="line.68"></a>
-<span class="sourceLineNo">069</span>     */<a name="line.69"></a>
-<span class="sourceLineNo">070</span>    public SpaceViolationPolicy getPolicy() {<a name="line.70"></a>
-<span class="sourceLineNo">071</span>      return policy;<a name="line.71"></a>
-<span class="sourceLineNo">072</span>    }<a name="line.72"></a>
-<span class="sourceLineNo">073</span><a name="line.73"></a>
-<span class="sourceLineNo">074</span>    /**<a name="line.74"></a>
-<span class="sourceLineNo">075</span>     * @return {@code true} if the quota is being violated, {@code false} otherwise.<a name="line.75"></a>
-<span class="sourceLineNo">076</span>     */<a name="line.76"></a>
-<span class="sourceLineNo">077</span>    public boolean isInViolation() {<a name="line.77"></a>
-<span class="sourceLineNo">078</span>      return inViolation;<a name="line.78"></a>
-<span class="sourceLineNo">079</span>    }<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>     * Returns a singleton referring to a quota which is not in violation.<a name="line.82"></a>
-<span class="sourceLineNo">083</span>     */<a name="line.83"></a>
-<span class="sourceLineNo">084</span>    public static SpaceQuotaStatus notInViolation() {<a name="line.84"></a>
-<span class="sourceLineNo">085</span>      return NOT_IN_VIOLATION;<a name="line.85"></a>
-<span class="sourceLineNo">086</span>    }<a name="line.86"></a>
-<span class="sourceLineNo">087</span><a name="line.87"></a>
-<span class="sourceLineNo">088</span>    @Override<a name="line.88"></a>
-<span class="sourceLineNo">089</span>    public int hashCode() {<a name="line.89"></a>
-<span class="sourceLineNo">090</span>      return new HashCodeBuilder().append(policy == null ? 0 : policy.hashCode())<a name="line.90"></a>
-<span class="sourceLineNo">091</span>          .append(inViolation).toHashCode();<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>    @Override<a name="line.94"></a>
-<span class="sourceLineNo">095</span>    public boolean equals(Object o) {<a name="line.95"></a>
-<span class="sourceLineNo">096</span>      if (o instanceof SpaceQuotaStatus) {<a name="line.96"></a>
-<span class="sourceLineNo">097</span>        SpaceQuotaStatus other = (SpaceQuotaStatus) o;<a name="line.97"></a>
-<span class="sourceLineNo">098</span>        return Objects.equals(policy, other.policy) &amp;&amp; inViolation == other.inViolation;<a name="line.98"></a>
-<span class="sourceLineNo">099</span>      }<a name="line.99"></a>
-<span class="sourceLineNo">100</span>      return false;<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>    @Override<a name="line.103"></a>
-<span class="sourceLineNo">104</span>    public String toString() {<a name="line.104"></a>
-<span class="sourceLineNo">105</span>      StringBuilder sb = new StringBuilder(getClass().getSimpleName());<a name="line.105"></a>
-<span class="sourceLineNo">106</span>      sb.append("[policy=").append(policy);<a name="line.106"></a>
-<span class="sourceLineNo">107</span>      sb.append(", inViolation=").append(inViolation).append("]");<a name="line.107"></a>
-<span class="sourceLineNo">108</span>      return sb.toString();<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>    public static QuotaProtos.SpaceQuotaStatus toProto(SpaceQuotaStatus status) {<a name="line.111"></a>
-<span class="sourceLineNo">112</span>      QuotaProtos.SpaceQuotaStatus.Builder builder = QuotaProtos.SpaceQuotaStatus.newBuilder();<a name="line.112"></a>
-<span class="sourceLineNo">113</span>      builder.setInViolation(status.inViolation);<a name="line.113"></a>
-<span class="sourceLineNo">114</span>      if (status.isInViolation()) {<a name="line.114"></a>
-<span class="sourceLineNo">115</span>        builder.setViolationPolicy(ProtobufUtil.toProtoViolationPolicy(status.getPolicy()));<a name="line.115"></a>
-<span class="sourceLineNo">116</span>      }<a name="line.116"></a>
-<span class="sourceLineNo">117</span>      return builder.build();<a name="line.117"></a>
-<span class="sourceLineNo">118</span>    }<a name="line.118"></a>
-<span class="sourceLineNo">119</span><a name="line.119"></a>
-<span class="sourceLineNo">120</span>    public static SpaceQuotaStatus toStatus(QuotaProtos.SpaceQuotaStatus proto) {<a name="line.120"></a>
-<span class="sourceLineNo">121</span>      if (proto.getInViolation()) {<a name="line.121"></a>
-<span class="sourceLineNo">122</span>        return new SpaceQuotaStatus(ProtobufUtil.toViolationPolicy(proto.getViolationPolicy()));<a name="line.122"></a>
-<span class="sourceLineNo">123</span>      } else {<a name="line.123"></a>
-<span class="sourceLineNo">124</span>        return NOT_IN_VIOLATION;<a name="line.124"></a>
-<span class="sourceLineNo">125</span>      }<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    }<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>  public SpaceQuotaSnapshot(SpaceQuotaStatus quotaStatus, long usage, long limit) {<a name="line.129"></a>
-<span class="sourceLineNo">130</span>    this.quotaStatus = Objects.requireNonNull(quotaStatus);<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    this.usage = usage;<a name="line.131"></a>
-<span class="sourceLineNo">132</span>    this.limit = limit;<a name="line.132"></a>
-<span class="sourceLineNo">133</span>  }<a name="line.133"></a>
-<span class="sourceLineNo">134</span><a name="line.134"></a>
-<span class="sourceLineNo">135</span>  /**<a name="line.135"></a>
-<span class="sourceLineNo">136</span>   * Returns the status of the quota.<a name="line.136"></a>
-<span class="sourceLineNo">137</span>   */<a name="line.137"></a>
-<span class="sourceLineNo">138</span>  public SpaceQuotaStatus getQuotaStatus() {<a name="line.138"></a>
-<span class="sourceLineNo">139</span>    return quotaStatus;<a name="line.139"></a>
-<span class="sourceLineNo">140</span>  }<a name="line.140"></a>
-<span class="sourceLineNo">141</span><a name="line.141"></a>
-<span class="sourceLineNo">142</span>  /**<a name="line.142"></a>
-<span class="sourceLineNo">143</span>   * Returns the current usage, in bytes, of the target (e.g. table, namespace).<a name="line.143"></a>
-<span class="sourceLineNo">144</span>   */<a name="line.144"></a>
-<span class="sourceLineNo">145</span>  public long getUsage() {<a name="line.145"></a>
-<span class="sourceLineNo">146</span>    return usage;<a name="line.146"></a>
-<span class="sourceLineNo">147</span>  }<a name="line.147"></a>
-<span class="sourceLineNo">148</span><a name="line.148"></a>
-<span class="sourceLineNo">149</span>  /**<a name="line.149"></a>
-<span class="sourceLineNo">150</span>   * Returns the limit, in bytes, of the target (e.g. table, namespace).<a name="line.150"></a>
-<span class="sourceLineNo">151</span>   */<a name="line.151"></a>
-<span class="sourceLineNo">152</span>  public long getLimit() {<a name="line.152"></a>
-<span class="sourceLineNo">153</span>    return limit;<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>  @Override<a name="line.156"></a>
-<span class="sourceLineNo">157</span>  public int hashCode() {<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    return new HashCodeBuilder()<a name="line.158"></a>
-<span class="sourceLineNo">159</span>        .append(quotaStatus.hashCode())<a name="line.159"></a>
-<span class="sourceLineNo">160</span>        .append(usage)<a name="line.160"></a>
-<span class="sourceLineNo">161</span>        .append(limit)<a name="line.161"></a>
-<span class="sourceLineNo">162</span>        .toHashCode();<a name="line.162"></a>
-<span class="sourceLineNo">163</span>  }<a name="line.163"></a>
-<span class="sourceLineNo">164</span><a name="line.164"></a>
-<span class="sourceLineNo">165</span>  @Override<a name="line.165"></a>
-<span class="sourceLineNo">166</span>  public boolean equals(Object o) {<a name="line.166"></a>
-<span class="sourceLineNo">167</span>    if (o instanceof SpaceQuotaSnapshot) {<a name="line.167"></a>
-<span class="sourceLineNo">168</span>      SpaceQuotaSnapshot other = (SpaceQuotaSnapshot) o;<a name="line.168"></a>
-<span class="sourceLineNo">169</span>      return quotaStatus.equals(other.quotaStatus) &amp;&amp; usage == other.usage &amp;&amp; limit == other.limit;<a name="line.169"></a>
-<span class="sourceLineNo">170</span>    }<a name="line.170"></a>
-<span class="sourceLineNo">171</span>    return false;<a name="line.171"></a>
-<span class="sourceLineNo">172</span>  }<a name="line.172"></a>
-<span class="sourceLineNo">173</span><a name="line.173"></a>
-<span class="sourceLineNo">174</span>  @Override<a name="line.174"></a>
-<span class="sourceLineNo">175</span>  public String toString() {<a name="line.175"></a>
-<span class="sourceLineNo">176</span>    StringBuilder sb = new StringBuilder(32);<a name="line.176"></a>
-<span class="sourceLineNo">177</span>    sb.append("SpaceQuotaSnapshot[policy=").append(quotaStatus).append(", use=");<a name="line.177"></a>
-<span class="sourceLineNo">178</span>    sb.append(usage).append("bytes/").append(limit).append("bytes]");<a name="line.178"></a>
-<span class="sourceLineNo">179</span>    return sb.toString();<a name="line.179"></a>
-<span class="sourceLineNo">180</span>  }<a name="line.180"></a>
-<span class="sourceLineNo">181</span><a name="line.181"></a>
-<span class="sourceLineNo">182</span>  // ProtobufUtil is in hbase-client, and this doesn't need to be public.<a name="line.182"></a>
-<span class="sourceLineNo">183</span>  public static SpaceQuotaSnapshot toSpaceQuotaSnapshot(QuotaProtos.SpaceQuotaSnapshot proto) {<a name="line.183"></a>
-<span class="sourceLineNo">184</span>    return new SpaceQuotaSnapshot(SpaceQuotaStatus.toStatus(proto.getQuotaStatus()),<a name="line.184"></a>
-<span class="sourceLineNo">185</span>        proto.getQuotaUsage(), proto.getQuotaLimit());<a name="line.185"></a>
-<span class="sourceLineNo">186</span>  }<a name="line.186"></a>
-<span class="sourceLineNo">187</span><a name="line.187"></a>
-<span class="sourceLineNo">188</span>  public static QuotaProtos.SpaceQuotaSnapshot toProtoSnapshot(SpaceQuotaSnapshot snapshot) {<a name="line.188"></a>
-<span class="sourceLineNo">189</span>    return QuotaProtos.SpaceQuotaSnapshot.newBuilder()<a name="line.189"></a>
-<span class="sourceLineNo">190</span>        .setQuotaStatus(SpaceQuotaStatus.toProto(snapshot.getQuotaStatus()))<a name="line.190"></a>
-<span class="sourceLineNo">191</span>        .setQuotaUsage(snapshot.getUsage()).setQuotaLimit(snapshot.getLimit()).build();<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>   * Returns a singleton that corresponds to no snapshot information.<a name="line.195"></a>
-<span class="sourceLineNo">196</span>   */<a name="line.196"></a>
-<span class="sourceLineNo">197</span>  public static SpaceQuotaSnapshot getNoSuchSnapshot() {<a name="line.197"></a>
-<span class="sourceLineNo">198</span>    return NO_SUCH_SNAPSHOT;<a name="line.198"></a>
-<span class="sourceLineNo">199</span>  }<a name="line.199"></a>
-<span class="sourceLineNo">200</span>}<a name="line.200"></a>
+<span class="sourceLineNo">025</span>import org.apache.hadoop.util.StringUtils;<a name="line.25"></a>
+<span class="sourceLineNo">026</span><a name="line.26"></a>
+<span class="sourceLineNo">027</span>/**<a name="line.27"></a>
+<span class="sourceLineNo">028</span> * A point-in-time view of a space quota on a table.<a name="line.28"></a>
+<span class="sourceLineNo">029</span> */<a name="line.29"></a>
+<span class="sourceLineNo">030</span>@InterfaceAudience.Private<a name="line.30"></a>
+<span class="sourceLineNo">031</span>public class SpaceQuotaSnapshot {<a name="line.31"></a>
+<span class="sourceLineNo">032</span>  private static final SpaceQuotaSnapshot NO_SUCH_SNAPSHOT = new SpaceQuotaSnapshot(<a name="line.32"></a>
+<span class="sourceLineNo">033</span>      SpaceQuotaStatus.notInViolation(), 0, Long.MAX_VALUE);<a name="line.33"></a>
+<span class="sourceLineNo">034</span>  private final SpaceQuotaStatus quotaStatus;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>  private final long usage;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>  private final long limit;<a name="line.36"></a>
+<span class="sourceLineNo">037</span><a name="line.37"></a>
+<span class="sourceLineNo">038</span>  /**<a name="line.38"></a>
+<span class="sourceLineNo">039</span>   * Encapsulates the state of a quota on a table. The quota may or may not be in violation.<a name="line.39"></a>
+<span class="sourceLineNo">040</span>   * If the quota is not in violation, the violation may be null. If the quota is in violation,<a name="line.40"></a>
+<span class="sourceLineNo">041</span>   * there is guaranteed to be a non-null violation policy.<a name="line.41"></a>
+<span class="sourceLineNo">042</span>   */<a name="line.42"></a>
+<span class="sourceLineNo">043</span>  @InterfaceAudience.Private<a name="line.43"></a>
+<span class="sourceLineNo">044</span>  public static class SpaceQuotaStatus {<a name="line.44"></a>
+<span class="sourceLineNo">045</span>    private static final SpaceQuotaStatus NOT_IN_VIOLATION = new SpaceQuotaStatus(null, false);<a name="line.45"></a>
+<span class="sourceLineNo">046</span>    final SpaceViolationPolicy policy;<a name="line.46"></a>
+<span class="sourceLineNo">047</span>    final boolean inViolation;<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>     * Constructs a {@code SpaceQuotaSnapshot} which is in violation of the provided {@code policy}.<a name="line.50"></a>
+<span class="sourceLineNo">051</span>     *<a name="line.51"></a>
+<span class="sourceLineNo">052</span>     * Use {@link #notInViolation()} to obtain an instance of this class for the cases when the<a name="line.52"></a>
+<span class="sourceLineNo">053</span>     * quota is not in violation.<a name="line.53"></a>
+<span class="sourceLineNo">054</span>     *<a name="line.54"></a>
+<span class="sourceLineNo">055</span>     * @param policy The non-null policy being violated.<a name="line.55"></a>
+<span class="sourceLineNo">056</span>     */<a name="line.56"></a>
+<span class="sourceLineNo">057</span>    public SpaceQuotaStatus(SpaceViolationPolicy policy) {<a name="line.57"></a>
+<span class="sourceLineNo">058</span>      // If the caller is instantiating a status, the policy must be non-null<a name="line.58"></a>
+<span class="sourceLineNo">059</span>      this (Objects.requireNonNull(policy), true);<a name="line.59"></a>
+<span class="sourceLineNo">060</span>    }<a name="line.60"></a>
+<span class="sourceLineNo">061</span><a name="line.61"></a>
+<span class="sourceLineNo">062</span>    private SpaceQuotaStatus(SpaceViolationPolicy policy, boolean inViolation) {<a name="line.62"></a>
+<span class="sourceLineNo">063</span>      this.policy = policy;<a name="line.63"></a>
+<span class="sourceLineNo">064</span>      this.inViolation = inViolation;<a name="line.64"></a>
+<span class="sourceLineNo">065</span>    }<a name="line.65"></a>
+<span class="sourceLineNo">066</span><a name="line.66"></a>
+<span class="sourceLineNo">067</span>    /**<a name="line.67"></a>
+<span class="sourceLineNo">068</span>     * Returns the violation policy, which may be null. It is guaranteed to be non-null if<a name="line.68"></a>
+<span class="sourceLineNo">069</span>     * {@link #isInViolation()} is {@code true}, but may be null otherwise.<a name="line.69"></a>
+<span class="sourceLineNo">070</span>     */<a name="line.70"></a>
+<span class="sourceLineNo">071</span>    public SpaceViolationPolicy getPolicy() {<a name="line.71"></a>
+<span class="sourceLineNo">072</span>      return policy;<a name="line.72"></a>
+<span class="sourceLineNo">073</span>    }<a name="line.73"></a>
+<span class="sourceLineNo">074</span><a name="line.74"></a>
+<span class="sourceLineNo">075</span>    /**<a name="line.75"></a>
+<span class="sourceLineNo">076</span>     * @return {@code true} if the quota is being violated, {@code false} otherwise.<a name="line.76"></a>
+<span class="sourceLineNo">077</span>     */<a name="line.77"></a>
+<span class="sourceLineNo">078</span>    public boolean isInViolation() {<a name="line.78"></a>
+<span class="sourceLineNo">079</span>      return inViolation;<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>    /**<a name="line.82"></a>
+<span class="sourceLineNo">083</span>     * Returns a singleton referring to a quota which is not in violation.<a name="line.83"></a>
+<span class="sourceLineNo">084</span>     */<a name="line.84"></a>
+<span class="sourceLineNo">085</span>    public static SpaceQuotaStatus notInViolation() {<a name="line.85"></a>
+<span class="sourceLineNo">086</span>      return NOT_IN_VIOLATION;<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>    @Override<a name="line.89"></a>
+<span class="sourceLineNo">090</span>    public int hashCode() {<a name="line.90"></a>
+<span class="sourceLineNo">091</span>      return new HashCodeBuilder().append(policy == null ? 0 : policy.hashCode())<a name="line.91"></a>
+<span class="sourceLineNo">092</span>          .append(inViolation).toHashCode();<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>    @Override<a name="line.95"></a>
+<span class="sourceLineNo">096</span>    public boolean equals(Object o) {<a name="line.96"></a>
+<span class="sourceLineNo">097</span>      if (o instanceof SpaceQuotaStatus) {<a name="line.97"></a>
+<span class="sourceLineNo">098</span>        SpaceQuotaStatus other = (SpaceQuotaStatus) o;<a name="line.98"></a>
+<span class="sourceLineNo">099</span>        return Objects.equals(policy, other.policy) &amp;&amp; inViolation == other.inViolation;<a name="line.99"></a>
+<span class="sourceLineNo">100</span>      }<a name="line.100"></a>
+<span class="sourceLineNo">101</span>      return false;<a name="line.101"></a>
+<span class="sourceLineNo">102</span>    }<a name="line.102"></a>
+<span class="sourceLineNo">103</span><a name="line.103"></a>
+<span class="sourceLineNo">104</span>    @Override<a name="line.104"></a>
+<span class="sourceLineNo">105</span>    public String toString() {<a name="line.105"></a>
+<span class="sourceLineNo">106</span>      StringBuilder sb = new StringBuilder(getClass().getSimpleName());<a name="line.106"></a>
+<span class="sourceLineNo">107</span>      sb.append("[policy=").append(policy);<a name="line.107"></a>
+<span class="sourceLineNo">108</span>      sb.append(", inViolation=").append(inViolation).append("]");<a name="line.108"></a>
+<span class="sourceLineNo">109</span>      return sb.toString();<a name="line.109"></a>
+<span class="sourceLineNo">110</span>    }<a name="line.110"></a>
+<span class="sourceLineNo">111</span><a name="line.111"></a>
+<span class="sourceLineNo">112</span>    public static QuotaProtos.SpaceQuotaStatus toProto(SpaceQuotaStatus status) {<a name="line.112"></a>
+<span class="sourceLineNo">113</span>      QuotaProtos.SpaceQuotaStatus.Builder builder = QuotaProtos.SpaceQuotaStatus.newBuilder();<a name="line.113"></a>
+<span class="sourceLineNo">114</span>      builder.setInViolation(status.inViolation);<a name="line.114"></a>
+<span class="sourceLineNo">115</span>      if (status.isInViolation()) {<a name="line.115"></a>
+<span class="sourceLineNo">116</span>        builder.setViolationPolicy(ProtobufUtil.toProtoViolationPolicy(status.getPolicy()));<a name="line.116"></a>
+<span class="sourceLineNo">117</span>      }<a name="line.117"></a>
+<span class="sourceLineNo">118</span>      return builder.build();<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>    public static SpaceQuotaStatus toStatus(QuotaProtos.SpaceQuotaStatus proto) {<a name="line.121"></a>
+<span class="sourceLineNo">122</span>      if (proto.getInViolation()) {<a name="line.122"></a>
+<span class="sourceLineNo">123</span>        return new SpaceQuotaStatus(ProtobufUtil.toViolationPolicy(proto.getViolationPolicy()));<a name="line.123"></a>
+<span class="sourceLineNo">124</span>      } else {<a name="line.124"></a>
+<span class="sourceLineNo">125</span>        return NOT_IN_VIOLATION;<a name="line.125"></a>
+<span class="sourceLineNo">126</span>      }<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><a name="line.129"></a>
+<span class="sourceLineNo">130</span>  public SpaceQuotaSnapshot(SpaceQuotaStatus quotaStatus, long usage, long limit) {<a name="line.130"></a>
+<span class="sourceLineNo">131</span>    this.quotaStatus = Objects.requireNonNull(quotaStatus);<a name="line.131"></a>
+<span class="sourceLineNo">132</span>    this.usage = usage;<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    this.limit = limit;<a name="line.133"></a>
+<span class="sourceLineNo">134</span>  }<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>   * Returns the status of the quota.<a name="line.137"></a>
+<span class="sourceLineNo">138</span>   */<a name="line.138"></a>
+<span class="sourceLineNo">139</span>  public SpaceQuotaStatus getQuotaStatus() {<a name="line.139"></a>
+<span class="sourceLineNo">140</span>    return quotaStatus;<a name="line.140"></a>
+<span class="sourceLineNo">141</span>  }<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>   * Returns the current usage, in bytes, of the target (e.g. table, namespace).<a name="line.144"></a>
+<span class="sourceLineNo">145</span>   */<a name="line.145"></a>
+<span class="sourceLineNo">146</span>  public long getUsage() {<a name="line.146"></a>
+<span class="sourceLineNo">147</span>    return usage;<a name="line.147"></a>
+<span class="sourceLineNo">148</span>  }<a name="line.148"></a>
+<span class="sourceLineNo">149</span><a name="line.149"></a>
+<span class="sourceLineNo">150</span>  /**<a name="line.150"></a>
+<span class="sourceLineNo">151</span>   * Returns the limit, in bytes, of the target (e.g. table, namespace).<a name="line.151"></a>
+<span class="sourceLineNo">152</span>   */<a name="line.152"></a>
+<span class="sourceLineNo">153</span>  public long getLimit() {<a name="line.153"></a>
+<span class="sourceLineNo">154</span>    return limit;<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>  @Override<a name="line.157"></a>
+<span class="sourceLineNo">158</span>  public int hashCode() {<a name="line.158"></a>
+<span class="sourceLineNo">159</span>    return new HashCodeBuilder()<a name="line.159"></a>
+<span class="sourceLineNo">160</span>        .append(quotaStatus.hashCode())<a name="line.160"></a>
+<span class="sourceLineNo">161</span>        .append(usage)<a name="line.161"></a>
+<span class="sourceLineNo">162</span>        .append(limit)<a name="line.162"></a>
+<span class="sourceLineNo">163</span>        .toHashCode();<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>  @Override<a name="line.166"></a>
+<span class="sourceLineNo">167</span>  public boolean equals(Object o) {<a name="line.167"></a>
+<span class="sourceLineNo">168</span>    if (o instanceof SpaceQuotaSnapshot) {<a name="line.168"></a>
+<span class="sourceLineNo">169</span>      SpaceQuotaSnapshot other = (SpaceQuotaSnapshot) o;<a name="line.169"></a>
+<span class="sourceLineNo">170</span>      return quotaStatus.equals(other.quotaStatus) &amp;&amp; usage == other.usage &amp;&amp; limit == other.limit;<a name="line.170"></a>
+<span class="sourceLineNo">171</span>    }<a name="line.171"></a>
+<span class="sourceLineNo">172</span>    return false;<a name="line.172"></a>
+<span class="sourceLineNo">173</span>  }<a name="line.173"></a>
+<span class="sourceLineNo">174</span><a name="line.174"></a>
+<span class="sourceLineNo">175</span>  @Override<a name="line.175"></a>
+<span class="sourceLineNo">176</span>  public String toString() {<a name="line.176"></a>
+<span class="sourceLineNo">177</span>    StringBuilder sb = new StringBuilder(32);<a name="line.177"></a>
+<span class="sourceLineNo">178</span>    sb.append("SpaceQuotaSnapshot[policy=").append(quotaStatus).append(", use=");<a name="line.178"></a>
+<span class="sourceLineNo">179</span>    sb.append(StringUtils.byteDesc(usage)).append("/");<a name="line.179"></a>
+<span class="sourceLineNo">180</span>    sb.append(StringUtils.byteDesc(limit)).append("]");<a name="line.180"></a>
+<span class="sourceLineNo">181</span>    return sb.toString();<a name="line.181"></a>
+<span class="sourceLineNo">182</span>  }<a name="line.182"></a>
+<span class="sourceLineNo">183</span><a name="line.183"></a>
+<span class="sourceLineNo">184</span>  // ProtobufUtil is in hbase-client, and this doesn't need to be public.<a name="line.184"></a>
+<span class="sourceLineNo">185</span>  public static SpaceQuotaSnapshot toSpaceQuotaSnapshot(QuotaProtos.SpaceQuotaSnapshot proto) {<a name="line.185"></a>
+<span class="sourceLineNo">186</span>    return new SpaceQuotaSnapshot(SpaceQuotaStatus.toStatus(proto.getQuotaStatus()),<a name="line.186"></a>
+<span class="sourceLineNo">187</span>        proto.getQuotaUsage(), proto.getQuotaLimit());<a name="line.187"></a>
+<span class="sourceLineNo">188</span>  }<a name="line.188"></a>
+<span class="sourceLineNo">189</span><a name="line.189"></a>
+<span class="sourceLineNo">190</span>  public static QuotaProtos.SpaceQuotaSnapshot toProtoSnapshot(SpaceQuotaSnapshot snapshot) {<a name="line.190"></a>
+<span class="sourceLineNo">191</span>    return QuotaProtos.SpaceQuotaSnapshot.newBuilder()<a name="line.191"></a>
+<span class="sourceLineNo">192</span>        .setQuotaStatus(SpaceQuotaStatus.toProto(snapshot.getQuotaStatus()))<a name="line.192"></a>
+<span class="sourceLineNo">193</span>        .setQuotaUsage(snapshot.getUsage()).setQuotaLimit(snapshot.getLimit()).build();<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>   * Returns a singleton that corresponds to no snapshot information.<a name="line.197"></a>
+<span class="sourceLineNo">198</span>   */<a name="line.198"></a>
+<span class="sourceLineNo">199</span>  public static SpaceQuotaSnapshot getNoSuchSnapshot() {<a name="line.199"></a>
+<span class="sourceLineNo">200</span>    return NO_SUCH_SNAPSHOT;<a name="line.200"></a>
+<span class="sourceLineNo">201</span>  }<a name="line.201"></a>
+<span class="sourceLineNo">202</span>}<a name="line.202"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/476c54ed/devapidocs/src-html/org/apache/hadoop/hbase/quotas/TableQuotaSnapshotStore.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/quotas/TableQuotaSnapshotStore.html b/devapidocs/src-html/org/apache/hadoop/hbase/quotas/TableQuotaSnapshotStore.html
index b7e80b6..12f3d31 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/quotas/TableQuotaSnapshotStore.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/quotas/TableQuotaSnapshotStore.html
@@ -26,113 +26,163 @@
 <span class="sourceLineNo">018</span><a name="line.18"></a>
 <span class="sourceLineNo">019</span>import java.io.IOException;<a name="line.19"></a>
 <span class="sourceLineNo">020</span>import java.util.Map;<a name="line.20"></a>
-<span class="sourceLineNo">021</span>import java.util.Objects;<a name="line.21"></a>
-<span class="sourceLineNo">022</span>import java.util.concurrent.locks.ReentrantReadWriteLock;<a name="line.22"></a>
-<span class="sourceLineNo">023</span>import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;<a name="line.23"></a>
-<span class="sourceLineNo">024</span>import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;<a name="line.24"></a>
-<span class="sourceLineNo">025</span>import java.util.Map.Entry;<a name="line.25"></a>
+<span class="sourceLineNo">021</span>import java.util.Map.Entry;<a name="line.21"></a>
+<span class="sourceLineNo">022</span>import java.util.Objects;<a name="line.22"></a>
+<span class="sourceLineNo">023</span>import java.util.concurrent.locks.ReentrantReadWriteLock;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;<a name="line.24"></a>
+<span class="sourceLineNo">025</span>import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;<a name="line.25"></a>
 <span class="sourceLineNo">026</span><a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.HRegionInfo;<a name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.TableName;<a name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.client.Connection;<a name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus;<a name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;<a name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas;<a name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota;<a name="line.34"></a>
-<span class="sourceLineNo">035</span><a name="line.35"></a>
-<span class="sourceLineNo">036</span>import com.google.common.base.Predicate;<a name="line.36"></a>
-<span class="sourceLineNo">037</span>import com.google.common.collect.Iterables;<a name="line.37"></a>
-<span class="sourceLineNo">038</span><a name="line.38"></a>
-<span class="sourceLineNo">039</span>/**<a name="line.39"></a>
-<span class="sourceLineNo">040</span> * {@link QuotaSnapshotStore} for tables.<a name="line.40"></a>
-<span class="sourceLineNo">041</span> */<a name="line.41"></a>
-<span class="sourceLineNo">042</span>@InterfaceAudience.Private<a name="line.42"></a>
-<span class="sourceLineNo">043</span>public class TableQuotaSnapshotStore implements QuotaSnapshotStore&lt;TableName&gt; {<a name="line.43"></a>
-<span class="sourceLineNo">044</span>  private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();<a name="line.44"></a>
-<span class="sourceLineNo">045</span>  private final ReadLock rlock = lock.readLock();<a name="line.45"></a>
-<span class="sourceLineNo">046</span>  private final WriteLock wlock = lock.writeLock();<a name="line.46"></a>
+<span class="sourceLineNo">027</span>import org.apache.commons.logging.Log;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.commons.logging.LogFactory;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.Cell;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.CellScanner;<a name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.HRegionInfo;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.TableName;<a name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.classification.InterfaceAudience;<a name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.client.Connection;<a name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.client.Result;<a name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.client.ResultScanner;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.apache.hadoop.hbase.client.Scan;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.apache.hadoop.hbase.client.Table;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>import org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException;<a name="line.40"></a>
+<span class="sourceLineNo">041</span>import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;<a name="line.41"></a>
+<span class="sourceLineNo">042</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas;<a name="line.42"></a>
+<span class="sourceLineNo">043</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota;<a name="line.43"></a>
+<span class="sourceLineNo">044</span><a name="line.44"></a>
+<span class="sourceLineNo">045</span>import com.google.common.base.Predicate;<a name="line.45"></a>
+<span class="sourceLineNo">046</span>import com.google.common.collect.Iterables;<a name="line.46"></a>
 <span class="sourceLineNo">047</span><a name="line.47"></a>
-<span class="sourceLineNo">048</span>  private final Connection conn;<a name="line.48"></a>
-<span class="sourceLineNo">049</span>  private final QuotaObserverChore chore;<a name="line.49"></a>
-<span class="sourceLineNo">050</span>  private Map&lt;HRegionInfo,Long&gt; regionUsage;<a name="line.50"></a>
-<span class="sourceLineNo">051</span><a name="line.51"></a>
-<span class="sourceLineNo">052</span>  public TableQuotaSnapshotStore(Connection conn, QuotaObserverChore chore, Map&lt;HRegionInfo,Long&gt; regionUsage) {<a name="line.52"></a>
-<span class="sourceLineNo">053</span>    this.conn = Objects.requireNonNull(conn);<a name="line.53"></a>
-<span class="sourceLineNo">054</span>    this.chore = Objects.requireNonNull(chore);<a name="line.54"></a>
-<span class="sourceLineNo">055</span>    this.regionUsage = Objects.requireNonNull(regionUsage);<a name="line.55"></a>
-<span class="sourceLineNo">056</span>  }<a name="line.56"></a>
-<span class="sourceLineNo">057</span><a name="line.57"></a>
-<span class="sourceLineNo">058</span>  @Override<a name="line.58"></a>
-<span class="sourceLineNo">059</span>  public SpaceQuota getSpaceQuota(TableName subject) throws IOException {<a name="line.59"></a>
-<span class="sourceLineNo">060</span>    Quotas quotas = getQuotaForTable(subject);<a name="line.60"></a>
-<span class="sourceLineNo">061</span>    if (quotas != null &amp;&amp; quotas.hasSpace()) {<a name="line.61"></a>
-<span class="sourceLineNo">062</span>      return quotas.getSpace();<a name="line.62"></a>
-<span class="sourceLineNo">063</span>    }<a name="line.63"></a>
-<span class="sourceLineNo">064</span>    return null;<a name="line.64"></a>
-<span class="sourceLineNo">065</span>  }<a name="line.65"></a>
-<span class="sourceLineNo">066</span>  /**<a name="line.66"></a>
-<span class="sourceLineNo">067</span>   * Fetches the table quota. Visible for mocking/testing.<a name="line.67"></a>
-<span class="sourceLineNo">068</span>   */<a name="line.68"></a>
-<span class="sourceLineNo">069</span>  Quotas getQuotaForTable(TableName table) throws IOException {<a name="line.69"></a>
-<span class="sourceLineNo">070</span>    return QuotaTableUtil.getTableQuota(conn, table);<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>  @Override<a name="line.73"></a>
-<span class="sourceLineNo">074</span>  public SpaceQuotaSnapshot getCurrentState(TableName table) {<a name="line.74"></a>
-<span class="sourceLineNo">075</span>    // Defer the "current state" to the chore<a name="line.75"></a>
-<span class="sourceLineNo">076</span>    return chore.getTableQuotaSnapshot(table);<a name="line.76"></a>
-<span class="sourceLineNo">077</span>  }<a name="line.77"></a>
-<span class="sourceLineNo">078</span><a name="line.78"></a>
-<span class="sourceLineNo">079</span>  @Override<a name="line.79"></a>
-<span class="sourceLineNo">080</span>  public SpaceQuotaSnapshot getTargetState(TableName table, SpaceQuota spaceQuota) {<a name="line.80"></a>
-<span class="sourceLineNo">081</span>    rlock.lock();<a name="line.81"></a>
-<span class="sourceLineNo">082</span>    try {<a name="line.82"></a>
-<span class="sourceLineNo">083</span>      final long sizeLimitInBytes = spaceQuota.getSoftLimit();<a name="line.83"></a>
-<span class="sourceLineNo">084</span>      long sum = 0L;<a name="line.84"></a>
-<span class="sourceLineNo">085</span>      for (Entry&lt;HRegionInfo,Long&gt; entry : filterBySubject(table)) {<a name="line.85"></a>
-<span class="sourceLineNo">086</span>        sum += entry.getValue();<a name="line.86"></a>
-<span class="sourceLineNo">087</span>      }<a name="line.87"></a>
-<span class="sourceLineNo">088</span>      // Observance is defined as the size of the table being less than the limit<a name="line.88"></a>
-<span class="sourceLineNo">089</span>      SpaceQuotaStatus status = sum &lt;= sizeLimitInBytes ? SpaceQuotaStatus.notInViolation()<a name="line.89"></a>
-<span class="sourceLineNo">090</span>          : new SpaceQuotaStatus(ProtobufUtil.toViolationPolicy(spaceQuota.getViolationPolicy()));<a name="line.90"></a>
-<span class="sourceLineNo">091</span>      return new SpaceQuotaSnapshot(status, sum, sizeLimitInBytes);<a name="line.91"></a>
-<span class="sourceLineNo">092</span>    } finally {<a name="line.92"></a>
-<span class="sourceLineNo">093</span>      rlock.unlock();<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><a name="line.96"></a>
-<span class="sourceLineNo">097</span>  @Override<a name="line.97"></a>
-<span class="sourceLineNo">098</span>  public Iterable&lt;Entry&lt;HRegionInfo,Long&gt;&gt; filterBySubject(TableName table) {<a name="line.98"></a>
-<span class="sourceLineNo">099</span>    rlock.lock();<a name="line.99"></a>
-<span class="sourceLineNo">100</span>    try {<a name="line.100"></a>
-<span class="sourceLineNo">101</span>      return Iterables.filter(regionUsage.entrySet(), new Predicate&lt;Entry&lt;HRegionInfo,Long&gt;&gt;() {<a name="line.101"></a>
-<span class="sourceLineNo">102</span>        @Override<a name="line.102"></a>
-<span class="sourceLineNo">103</span>        public boolean apply(Entry&lt;HRegionInfo,Long&gt; input) {<a name="line.103"></a>
-<span class="sourceLineNo">104</span>          return table.equals(input.getKey().getTable());<a name="line.104"></a>
-<span class="sourceLineNo">105</span>        }<a name="line.105"></a>
-<span class="sourceLineNo">106</span>      });<a name="line.106"></a>
-<span class="sourceLineNo">107</span>    } finally {<a name="line.107"></a>
-<span class="sourceLineNo">108</span>      rlock.unlock();<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><a name="line.111"></a>
-<span class="sourceLineNo">112</span>  @Override<a name="line.112"></a>
-<span class="sourceLineNo">113</span>  public void setCurrentState(TableName table, SpaceQuotaSnapshot snapshot) {<a name="line.113"></a>
-<span class="sourceLineNo">114</span>    // Defer the "current state" to the chore<a name="line.114"></a>
-<span class="sourceLineNo">115</span>    this.chore.setTableQuotaSnapshot(table, snapshot);<a name="line.115"></a>
-<span class="sourceLineNo">116</span>  }<a name="line.116"></a>
-<span class="sourceLineNo">117</span><a name="line.117"></a>
-<span class="sourceLineNo">118</span>  @Override<a name="line.118"></a>
-<span class="sourceLineNo">119</span>  public void setRegionUsage(Map&lt;HRegionInfo,Long&gt; regionUsage) {<a name="line.119"></a>
-<span class="sourceLineNo">120</span>    wlock.lock();<a name="line.120"></a>
-<span class="sourceLineNo">121</span>    try {<a name="line.121"></a>
-<span class="sourceLineNo">122</span>      this.regionUsage = Objects.requireNonNull(regionUsage);<a name="line.122"></a>
-<span class="sourceLineNo">123</span>    } finally {<a name="line.123"></a>
-<span class="sourceLineNo">124</span>      wlock.unlock();<a name="line.124"></a>
-<span class="sourceLineNo">125</span>    }<a name="line.125"></a>
-<span class="sourceLineNo">126</span>  }<a name="line.126"></a>
-<span class="sourceLineNo">127</span>}<a name="line.127"></a>
+<span class="sourceLineNo">048</span>/**<a name="line.48"></a>
+<span class="sourceLineNo">049</span> * {@link QuotaSnapshotStore} for tables.<a name="line.49"></a>
+<span class="sourceLineNo">050</span> */<a name="line.50"></a>
+<span class="sourceLineNo">051</span>@InterfaceAudience.Private<a name="line.51"></a>
+<span class="sourceLineNo">052</span>public class TableQuotaSnapshotStore implements QuotaSnapshotStore&lt;TableName&gt; {<a name="line.52"></a>
+<span class="sourceLineNo">053</span>  private static final Log LOG = LogFactory.getLog(TableQuotaSnapshotStore.class);<a name="line.53"></a>
+<span class="sourceLineNo">054</span><a name="line.54"></a>
+<span class="sourceLineNo">055</span>  private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();<a name="line.55"></a>
+<span class="sourceLineNo">056</span>  private final ReadLock rlock = lock.readLock();<a name="line.56"></a>
+<span class="sourceLineNo">057</span>  private final WriteLock wlock = lock.writeLock();<a name="line.57"></a>
+<span class="sourceLineNo">058</span><a name="line.58"></a>
+<span class="sourceLineNo">059</span>  private final Connection conn;<a name="line.59"></a>
+<span class="sourceLineNo">060</span>  private final QuotaObserverChore chore;<a name="line.60"></a>
+<span class="sourceLineNo">061</span>  private Map&lt;HRegionInfo,Long&gt; regionUsage;<a name="line.61"></a>
+<span class="sourceLineNo">062</span><a name="line.62"></a>
+<span class="sourceLineNo">063</span>  public TableQuotaSnapshotStore(Connection conn, QuotaObserverChore chore, Map&lt;HRegionInfo,Long&gt; regionUsage) {<a name="line.63"></a>
+<span class="sourceLineNo">064</span>    this.conn = Objects.requireNonNull(conn);<a name="line.64"></a>
+<span class="sourceLineNo">065</span>    this.chore = Objects.requireNonNull(chore);<a name="line.65"></a>
+<span class="sourceLineNo">066</span>    this.regionUsage = Objects.requireNonNull(regionUsage);<a name="line.66"></a>
+<span class="sourceLineNo">067</span>  }<a name="line.67"></a>
+<span class="sourceLineNo">068</span><a name="line.68"></a>
+<span class="sourceLineNo">069</span>  @Override<a name="line.69"></a>
+<span class="sourceLineNo">070</span>  public SpaceQuota getSpaceQuota(TableName subject) throws IOException {<a name="line.70"></a>
+<span class="sourceLineNo">071</span>    Quotas quotas = getQuotaForTable(subject);<a name="line.71"></a>
+<span class="sourceLineNo">072</span>    if (quotas != null &amp;&amp; quotas.hasSpace()) {<a name="line.72"></a>
+<span class="sourceLineNo">073</span>      return quotas.getSpace();<a name="line.73"></a>
+<span class="sourceLineNo">074</span>    }<a name="line.74"></a>
+<span class="sourceLineNo">075</span>    return null;<a name="line.75"></a>
+<span class="sourceLineNo">076</span>  }<a name="line.76"></a>
+<span class="sourceLineNo">077</span>  /**<a name="line.77"></a>
+<span class="sourceLineNo">078</span>   * Fetches the table quota. Visible for mocking/testing.<a name="line.78"></a>
+<span class="sourceLineNo">079</span>   */<a name="line.79"></a>
+<span class="sourceLineNo">080</span>  Quotas getQuotaForTable(TableName table) throws IOException {<a name="line.80"></a>
+<span class="sourceLineNo">081</span>    return QuotaTableUtil.getTableQuota(conn, table);<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>  @Override<a name="line.84"></a>
+<span class="sourceLineNo">085</span>  public SpaceQuotaSnapshot getCurrentState(TableName table) {<a name="line.85"></a>
+<span class="sourceLineNo">086</span>    // Defer the "current state" to the chore<a name="line.86"></a>
+<span class="sourceLineNo">087</span>    return chore.getTableQuotaSnapshot(table);<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>  @Override<a name="line.90"></a>
+<span class="sourceLineNo">091</span>  public SpaceQuotaSnapshot getTargetState(<a name="line.91"></a>
+<span class="sourceLineNo">092</span>      TableName table, SpaceQuota spaceQuota) throws IOException {<a name="line.92"></a>
+<span class="sourceLineNo">093</span>    rlock.lock();<a name="line.93"></a>
+<span class="sourceLineNo">094</span>    try {<a name="line.94"></a>
+<span class="sourceLineNo">095</span>      final long sizeLimitInBytes = spaceQuota.getSoftLimit();<a name="line.95"></a>
+<span class="sourceLineNo">096</span>      long sum = 0L;<a name="line.96"></a>
+<span class="sourceLineNo">097</span>      for (Entry&lt;HRegionInfo,Long&gt; entry : filterBySubject(table)) {<a name="line.97"></a>
+<span class="sourceLineNo">098</span>        sum += entry.getValue();<a name="line.98"></a>
+<span class="sourceLineNo">099</span>      }<a name="line.99"></a>
+<span class="sourceLineNo">100</span>      // Add in the size for any snapshots against this table<a name="line.100"></a>
+<span class="sourceLineNo">101</span>      sum += getSnapshotSizesForTable(table);<a name="line.101"></a>
+<span class="sourceLineNo">102</span>      // Observance is defined as the size of the table being less than the limit<a name="line.102"></a>
+<span class="sourceLineNo">103</span>      SpaceQuotaStatus status = sum &lt;= sizeLimitInBytes ? SpaceQuotaStatus.notInViolation()<a name="line.103"></a>
+<span class="sourceLineNo">104</span>          : new SpaceQuotaStatus(ProtobufUtil.toViolationPolicy(spaceQuota.getViolationPolicy()));<a name="line.104"></a>
+<span class="sourceLineNo">105</span>      return new SpaceQuotaSnapshot(status, sum, sizeLimitInBytes);<a name="line.105"></a>
+<span class="sourceLineNo">106</span>    } finally {<a name="line.106"></a>
+<span class="sourceLineNo">107</span>      rlock.unlock();<a name="line.107"></a>
+<span class="sourceLineNo">108</span>    }<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>  /**<a name="line.111"></a>
+<span class="sourceLineNo">112</span>   * Fetches any serialized snapshot sizes from the quota table for the {@code tn} provided. Any<a name="line.112"></a>
+<span class="sourceLineNo">113</span>   * malformed records are skipped with a warning printed out.<a name="line.113"></a>
+<span class="sourceLineNo">114</span>   */<a name="line.114"></a>
+<span class="sourceLineNo">115</span>  long getSnapshotSizesForTable(TableName tn) throws IOException {<a name="line.115"></a>
+<span class="sourceLineNo">116</span>    try (Table quotaTable = conn.getTable(QuotaTableUtil.QUOTA_TABLE_NAME)) {<a name="line.116"></a>
+<span class="sourceLineNo">117</span>      Scan s = QuotaTableUtil.createScanForSnapshotSizes(tn);<a name="line.117"></a>
+<span class="sourceLineNo">118</span>      ResultScanner rs = quotaTable.getScanner(s);<a name="line.118"></a>
+<span class="sourceLineNo">119</span>      try {<a name="line.119"></a>
+<span class="sourceLineNo">120</span>        long size = 0L;<a name="line.120"></a>
+<span class="sourceLineNo">121</span>        // Should just be a single row (for our table)<a name="line.121"></a>
+<span class="sourceLineNo">122</span>        for (Result result : rs) {<a name="line.122"></a>
+<span class="sourceLineNo">123</span>          // May have multiple columns, one for each snapshot<a name="line.123"></a>
+<span class="sourceLineNo">124</span>          CellScanner cs = result.cellScanner();<a name="line.124"></a>
+<span class="sourceLineNo">125</span>          while (cs.advance()) {<a name="line.125"></a>
+<span class="sourceLineNo">126</span>            Cell current = cs.current();<a name="line.126"></a>
+<span class="sourceLineNo">127</span>            try {<a name="line.127"></a>
+<span class="sourceLineNo">128</span>              long snapshotSize = QuotaTableUtil.parseSnapshotSize(current);<a name="line.128"></a>
+<span class="sourceLineNo">129</span>              if (LOG.isTraceEnabled()) {<a name="line.129"></a>
+<span class="sourceLineNo">130</span>                LOG.trace("Saw snapshot size of " + snapshotSize + " for " + current);<a name="line.130"></a>
+<span class="sourceLineNo">131</span>              }<a name="line.131"></a>
+<span class="sourceLineNo">132</span>              size += snapshotSize;<a name="line.132"></a>
+<span class="sourceLineNo">133</span>            } catch (InvalidProtocolBufferException e) {<a name="line.133"></a>
+<span class="sourceLineNo">134</span>              LOG.warn("Failed to parse snapshot size from cell: " + current);<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>        return size;<a name="line.138"></a>
+<span class="sourceLineNo">139</span>      } finally {<a name="line.139"></a>
+<span class="sourceLineNo">140</span>        if (null != rs) {<a name="line.140"></a>
+<span class="sourceLineNo">141</span>          rs.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>  }<a name="line.145"></a>
+<span class="sourceLineNo">146</span><a name="line.146"></a>
+<span class="sourceLineNo">147</span>  @Override<a name="line.147"></a>
+<span class="sourceLineNo">148</span>  public Iterable&lt;Entry&lt;HRegionInfo,Long&gt;&gt; filterBySubject(TableName table) {<a name="line.148"></a>
+<span class="sourceLineNo">149</span>    rlock.lock();<a name="line.149"></a>
+<span class="sourceLineNo">150</span>    try {<a name="line.150"></a>
+<span class="sourceLineNo">151</span>      return Iterables.filter(regionUsage.entrySet(), new Predicate&lt;Entry&lt;HRegionInfo,Long&gt;&gt;() {<a name="line.151"></a>
+<span class="sourceLineNo">152</span>        @Override<a name="line.152"></a>
+<span class="sourceLineNo">153</span>        public boolean apply(Entry&lt;HRegionInfo,Long&gt; input) {<a name="line.153"></a>
+<span class="sourceLineNo">154</span>          return table.equals(input.getKey().getTable());<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>    } finally {<a name="line.157"></a>
+<span class="sourceLineNo">158</span>      rlock.unlock();<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><a name="line.161"></a>
+<span class="sourceLineNo">162</span>  @Override<a name="line.162"></a>
+<span class="sourceLineNo">163</span>  public void setCurrentState(TableName table, SpaceQuotaSnapshot snapshot) {<a name="line.163"></a>
+<span class="sourceLineNo">164</span>    // Defer the "current state" to the chore<a name="line.164"></a>
+<span class="sourceLineNo">165</span>    this.chore.setTableQuotaSnapshot(table, snapshot);<a name="line.165"></a>
+<span class="sourceLineNo">166</span>  }<a name="line.166"></a>
+<span class="sourceLineNo">167</span><a name="line.167"></a>
+<span class="sourceLineNo">168</span>  @Override<a name="line.168"></a>
+<span class="sourceLineNo">169</span>  public void setRegionUsage(Map&lt;HRegionInfo,Long&gt; regionUsage) {<a name="line.169"></a>
+<span class="sourceLineNo">170</span>    wlock.lock();<a name="line.170"></a>
+<span class="sourceLineNo">171</span>    try {<a name="line.171"></a>
+<span class="sourceLineNo">172</span>      this.regionUsage = Objects.requireNonNull(regionUsage);<a name="line.172"></a>
+<span class="sourceLineNo">173</span>    } finally {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>      wlock.unlock();<a name="line.174"></a>
+<span class="sourceLineNo">175</span>    }<a name="line.175"></a>
+<span class="sourceLineNo">176</span>  }<a name="line.176"></a>
+<span class="sourceLineNo">177</span>}<a name="line.177"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/476c54ed/devapidocs/src-html/org/apache/hadoop/hbase/quotas/TableSpaceQuotaSnapshotNotifier.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/quotas/TableSpaceQuotaSnapshotNotifier.html b/devapidocs/src-html/org/apache/hadoop/hbase/quotas/TableSpaceQuotaSnapshotNotifier.html
index 8588251..3a3a9c1 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/quotas/TableSpaceQuotaSnapshotNotifier.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/quotas/TableSpaceQuotaSnapshotNotifier.html
@@ -44,7 +44,7 @@
 <span class="sourceLineNo">036</span>  @Override<a name="line.36"></a>
 <span class="sourceLineNo">037</span>  public void transitionTable(<a name="line.37"></a>
 <span class="sourceLineNo">038</span>      TableName tableName, SpaceQuotaSnapshot snapshot) throws IOException {<a name="line.38"></a>
-<span class="sourceLineNo">039</span>    final Put p = QuotaTableUtil.createPutSpaceSnapshot(tableName, snapshot);<a name="line.39"></a>
+<span class="sourceLineNo">039</span>    final Put p = QuotaTableUtil.createPutForSpaceSnapshot(tableName, snapshot);<a name="line.39"></a>
 <span class="sourceLineNo">040</span>    try (Table quotaTable = conn.getTable(QuotaTableUtil.QUOTA_TABLE_NAME)) {<a name="line.40"></a>
 <span class="sourceLineNo">041</span>      if (LOG.isTraceEnabled()) {<a name="line.41"></a>
 <span class="sourceLineNo">042</span>        LOG.trace("Persisting a space quota snapshot " + snapshot + " for " + tableName);<a name="line.42"></a>


Mime
View raw message