hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [14/49] hbase-site git commit: Published site at .
Date Sun, 24 Sep 2017 15:13:40 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/e6bd0774/devapidocs/src-html/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.html b/devapidocs/src-html/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.html
index 38b0f89..f3ea369 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/quotas/SpaceLimitSettings.html
@@ -76,136 +76,179 @@
 <span class="sourceLineNo">068</span>    proto = buildProtoRemoveQuota();<a name="line.68"></a>
 <span class="sourceLineNo">069</span>  }<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>   * Builds a {@link SpaceQuota} protobuf object given the arguments.<a name="line.72"></a>
-<span class="sourceLineNo">073</span>   *<a name="line.73"></a>
-<span class="sourceLineNo">074</span>   * @param sizeLimit The size limit of the quota.<a name="line.74"></a>
-<span class="sourceLineNo">075</span>   * @param violationPolicy The action to take when the quota is exceeded.<a name="line.75"></a>
-<span class="sourceLineNo">076</span>   * @return The protobuf SpaceQuota representation.<a name="line.76"></a>
-<span class="sourceLineNo">077</span>   */<a name="line.77"></a>
-<span class="sourceLineNo">078</span>  private SpaceLimitRequest buildProtoAddQuota(<a name="line.78"></a>
-<span class="sourceLineNo">079</span>      long sizeLimit, SpaceViolationPolicy violationPolicy) {<a name="line.79"></a>
-<span class="sourceLineNo">080</span>    return SpaceLimitRequest.newBuilder().setQuota(<a name="line.80"></a>
-<span class="sourceLineNo">081</span>        SpaceQuota.newBuilder()<a name="line.81"></a>
-<span class="sourceLineNo">082</span>            .setSoftLimit(sizeLimit)<a name="line.82"></a>
-<span class="sourceLineNo">083</span>            .setViolationPolicy(ProtobufUtil.toProtoViolationPolicy(violationPolicy))<a name="line.83"></a>
-<span class="sourceLineNo">084</span>            .build())<a name="line.84"></a>
-<span class="sourceLineNo">085</span>        .build();<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>  /**<a name="line.88"></a>
-<span class="sourceLineNo">089</span>   * Builds a {@link SpaceQuota} protobuf object to remove a quota.<a name="line.89"></a>
-<span class="sourceLineNo">090</span>   *<a name="line.90"></a>
+<span class="sourceLineNo">071</span>  SpaceLimitSettings(TableName tableName, String namespace, SpaceLimitRequest req) {<a name="line.71"></a>
+<span class="sourceLineNo">072</span>    super(null, tableName, namespace);<a name="line.72"></a>
+<span class="sourceLineNo">073</span>    proto = req;<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>  /**<a name="line.76"></a>
+<span class="sourceLineNo">077</span>   * Build a {@link SpaceLimitRequest} protobuf object from the given {@link SpaceQuota}.<a name="line.77"></a>
+<span class="sourceLineNo">078</span>   *<a name="line.78"></a>
+<span class="sourceLineNo">079</span>   * @param protoQuota The preconstructed SpaceQuota protobuf<a name="line.79"></a>
+<span class="sourceLineNo">080</span>   * @return A protobuf request to change a space limit quota<a name="line.80"></a>
+<span class="sourceLineNo">081</span>   */<a name="line.81"></a>
+<span class="sourceLineNo">082</span>  private SpaceLimitRequest buildProtoFromQuota(SpaceQuota protoQuota) {<a name="line.82"></a>
+<span class="sourceLineNo">083</span>    return SpaceLimitRequest.newBuilder().setQuota(protoQuota).build();<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">086</span>  /**<a name="line.86"></a>
+<span class="sourceLineNo">087</span>   * Builds a {@link SpaceQuota} protobuf object given the arguments.<a name="line.87"></a>
+<span class="sourceLineNo">088</span>   *<a name="line.88"></a>
+<span class="sourceLineNo">089</span>   * @param sizeLimit The size limit of the quota.<a name="line.89"></a>
+<span class="sourceLineNo">090</span>   * @param violationPolicy The action to take when the quota is exceeded.<a name="line.90"></a>
 <span class="sourceLineNo">091</span>   * @return The protobuf SpaceQuota representation.<a name="line.91"></a>
 <span class="sourceLineNo">092</span>   */<a name="line.92"></a>
-<span class="sourceLineNo">093</span>  private SpaceLimitRequest buildProtoRemoveQuota() {<a name="line.93"></a>
-<span class="sourceLineNo">094</span>    return SpaceLimitRequest.newBuilder().setQuota(<a name="line.94"></a>
-<span class="sourceLineNo">095</span>        SpaceQuota.newBuilder()<a name="line.95"></a>
-<span class="sourceLineNo">096</span>            .setRemove(true)<a name="line.96"></a>
-<span class="sourceLineNo">097</span>            .build())<a name="line.97"></a>
-<span class="sourceLineNo">098</span>        .build();<a name="line.98"></a>
+<span class="sourceLineNo">093</span>  private SpaceLimitRequest buildProtoAddQuota(<a name="line.93"></a>
+<span class="sourceLineNo">094</span>      long sizeLimit, SpaceViolationPolicy violationPolicy) {<a name="line.94"></a>
+<span class="sourceLineNo">095</span>    return buildProtoFromQuota(SpaceQuota.newBuilder()<a name="line.95"></a>
+<span class="sourceLineNo">096</span>            .setSoftLimit(sizeLimit)<a name="line.96"></a>
+<span class="sourceLineNo">097</span>            .setViolationPolicy(ProtobufUtil.toProtoViolationPolicy(violationPolicy))<a name="line.97"></a>
+<span class="sourceLineNo">098</span>            .build());<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>  /**<a name="line.101"></a>
-<span class="sourceLineNo">102</span>   * Returns a copy of the internal state of &lt;code&gt;this&lt;/code&gt;<a name="line.102"></a>
-<span class="sourceLineNo">103</span>   */<a name="line.103"></a>
-<span class="sourceLineNo">104</span>  SpaceLimitRequest getProto() {<a name="line.104"></a>
-<span class="sourceLineNo">105</span>    return proto.toBuilder().build();<a name="line.105"></a>
-<span class="sourceLineNo">106</span>  }<a name="line.106"></a>
-<span class="sourceLineNo">107</span><a name="line.107"></a>
-<span class="sourceLineNo">108</span>  @Override<a name="line.108"></a>
-<span class="sourceLineNo">109</span>  public QuotaType getQuotaType() {<a name="line.109"></a>
-<span class="sourceLineNo">110</span>    return QuotaType.SPACE;<a name="line.110"></a>
-<span class="sourceLineNo">111</span>  }<a name="line.111"></a>
-<span class="sourceLineNo">112</span><a name="line.112"></a>
-<span class="sourceLineNo">113</span>  @Override<a name="line.113"></a>
-<span class="sourceLineNo">114</span>  protected void setupSetQuotaRequest(Builder builder) {<a name="line.114"></a>
-<span class="sourceLineNo">115</span>    // TableName/Namespace are serialized in QuotaSettings<a name="line.115"></a>
-<span class="sourceLineNo">116</span>    builder.setSpaceLimit(proto);<a name="line.116"></a>
-<span class="sourceLineNo">117</span>  }<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>   * Constructs a {@link SpaceLimitSettings} from the provided protobuf message and tablename.<a name="line.120"></a>
-<span class="sourceLineNo">121</span>   *<a name="line.121"></a>
-<span class="sourceLineNo">122</span>   * @param tableName The target tablename for the limit.<a name="line.122"></a>
-<span class="sourceLineNo">123</span>   * @param proto The protobuf representation.<a name="line.123"></a>
-<span class="sourceLineNo">124</span>   * @return A QuotaSettings.<a name="line.124"></a>
-<span class="sourceLineNo">125</span>   */<a name="line.125"></a>
-<span class="sourceLineNo">126</span>  static SpaceLimitSettings fromSpaceQuota(<a name="line.126"></a>
-<span class="sourceLineNo">127</span>      final TableName tableName, final QuotaProtos.SpaceQuota proto) {<a name="line.127"></a>
-<span class="sourceLineNo">128</span>    validateProtoArguments(proto);<a name="line.128"></a>
-<span class="sourceLineNo">129</span>    return new SpaceLimitSettings(tableName, proto.getSoftLimit(),<a name="line.129"></a>
-<span class="sourceLineNo">130</span>        ProtobufUtil.toViolationPolicy(proto.getViolationPolicy()));<a name="line.130"></a>
-<span class="sourceLineNo">131</span>  }<a name="line.131"></a>
-<span class="sourceLineNo">132</span><a name="line.132"></a>
-<span class="sourceLineNo">133</span>  /**<a name="line.133"></a>
-<span class="sourceLineNo">134</span>   * Constructs a {@link SpaceLimitSettings} from the provided protobuf message and namespace.<a name="line.134"></a>
-<span class="sourceLineNo">135</span>   *<a name="line.135"></a>
-<span class="sourceLineNo">136</span>   * @param namespace The target namespace for the limit.<a name="line.136"></a>
-<span class="sourceLineNo">137</span>   * @param proto The protobuf representation.<a name="line.137"></a>
-<span class="sourceLineNo">138</span>   * @return A QuotaSettings.<a name="line.138"></a>
-<span class="sourceLineNo">139</span>   */<a name="line.139"></a>
-<span class="sourceLineNo">140</span>  static SpaceLimitSettings fromSpaceQuota(<a name="line.140"></a>
-<span class="sourceLineNo">141</span>      final String namespace, final QuotaProtos.SpaceQuota proto) {<a name="line.141"></a>
-<span class="sourceLineNo">142</span>    validateProtoArguments(proto);<a name="line.142"></a>
-<span class="sourceLineNo">143</span>    return new SpaceLimitSettings(namespace, proto.getSoftLimit(),<a name="line.143"></a>
-<span class="sourceLineNo">144</span>        ProtobufUtil.toViolationPolicy(proto.getViolationPolicy()));<a name="line.144"></a>
-<span class="sourceLineNo">145</span>  }<a name="line.145"></a>
-<span class="sourceLineNo">146</span><a name="line.146"></a>
-<span class="sourceLineNo">147</span>  /**<a name="line.147"></a>
-<span class="sourceLineNo">148</span>   * Validates that the provided protobuf SpaceQuota has the necessary information to construct<a name="line.148"></a>
-<span class="sourceLineNo">149</span>   * a {@link SpaceLimitSettings}.<a name="line.149"></a>
-<span class="sourceLineNo">150</span>   *<a name="line.150"></a>
-<span class="sourceLineNo">151</span>   * @param proto The protobuf message to validate.<a name="line.151"></a>
+<span class="sourceLineNo">102</span>   * Builds a {@link SpaceQuota} protobuf object to remove a quota.<a name="line.102"></a>
+<span class="sourceLineNo">103</span>   *<a name="line.103"></a>
+<span class="sourceLineNo">104</span>   * @return The protobuf SpaceQuota representation.<a name="line.104"></a>
+<span class="sourceLineNo">105</span>   */<a name="line.105"></a>
+<span class="sourceLineNo">106</span>  private SpaceLimitRequest buildProtoRemoveQuota() {<a name="line.106"></a>
+<span class="sourceLineNo">107</span>    return SpaceLimitRequest.newBuilder().setQuota(<a name="line.107"></a>
+<span class="sourceLineNo">108</span>        SpaceQuota.newBuilder()<a name="line.108"></a>
+<span class="sourceLineNo">109</span>            .setRemove(true)<a name="line.109"></a>
+<span class="sourceLineNo">110</span>            .build())<a name="line.110"></a>
+<span class="sourceLineNo">111</span>        .build();<a name="line.111"></a>
+<span class="sourceLineNo">112</span>  }<a name="line.112"></a>
+<span class="sourceLineNo">113</span><a name="line.113"></a>
+<span class="sourceLineNo">114</span>  /**<a name="line.114"></a>
+<span class="sourceLineNo">115</span>   * Returns a copy of the internal state of &lt;code&gt;this&lt;/code&gt;<a name="line.115"></a>
+<span class="sourceLineNo">116</span>   */<a name="line.116"></a>
+<span class="sourceLineNo">117</span>  SpaceLimitRequest getProto() {<a name="line.117"></a>
+<span class="sourceLineNo">118</span>    return proto.toBuilder().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>  @Override<a name="line.121"></a>
+<span class="sourceLineNo">122</span>  public QuotaType getQuotaType() {<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    return QuotaType.SPACE;<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>  @Override<a name="line.126"></a>
+<span class="sourceLineNo">127</span>  protected void setupSetQuotaRequest(Builder builder) {<a name="line.127"></a>
+<span class="sourceLineNo">128</span>    // TableName/Namespace are serialized in QuotaSettings<a name="line.128"></a>
+<span class="sourceLineNo">129</span>    builder.setSpaceLimit(proto);<a name="line.129"></a>
+<span class="sourceLineNo">130</span>  }<a name="line.130"></a>
+<span class="sourceLineNo">131</span><a name="line.131"></a>
+<span class="sourceLineNo">132</span>  /**<a name="line.132"></a>
+<span class="sourceLineNo">133</span>   * Constructs a {@link SpaceLimitSettings} from the provided protobuf message and tablename.<a name="line.133"></a>
+<span class="sourceLineNo">134</span>   *<a name="line.134"></a>
+<span class="sourceLineNo">135</span>   * @param tableName The target tablename for the limit.<a name="line.135"></a>
+<span class="sourceLineNo">136</span>   * @param proto The protobuf representation.<a name="line.136"></a>
+<span class="sourceLineNo">137</span>   * @return A QuotaSettings.<a name="line.137"></a>
+<span class="sourceLineNo">138</span>   */<a name="line.138"></a>
+<span class="sourceLineNo">139</span>  static SpaceLimitSettings fromSpaceQuota(<a name="line.139"></a>
+<span class="sourceLineNo">140</span>      final TableName tableName, final QuotaProtos.SpaceQuota proto) {<a name="line.140"></a>
+<span class="sourceLineNo">141</span>    validateProtoArguments(proto);<a name="line.141"></a>
+<span class="sourceLineNo">142</span>    return new SpaceLimitSettings(tableName, proto.getSoftLimit(),<a name="line.142"></a>
+<span class="sourceLineNo">143</span>        ProtobufUtil.toViolationPolicy(proto.getViolationPolicy()));<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>   * Constructs a {@link SpaceLimitSettings} from the provided protobuf message and namespace.<a name="line.147"></a>
+<span class="sourceLineNo">148</span>   *<a name="line.148"></a>
+<span class="sourceLineNo">149</span>   * @param namespace The target namespace for the limit.<a name="line.149"></a>
+<span class="sourceLineNo">150</span>   * @param proto The protobuf representation.<a name="line.150"></a>
+<span class="sourceLineNo">151</span>   * @return A QuotaSettings.<a name="line.151"></a>
 <span class="sourceLineNo">152</span>   */<a name="line.152"></a>
-<span class="sourceLineNo">153</span>  static void validateProtoArguments(final QuotaProtos.SpaceQuota proto) {<a name="line.153"></a>
-<span class="sourceLineNo">154</span>    if (!Objects.requireNonNull(proto).hasSoftLimit()) {<a name="line.154"></a>
-<span class="sourceLineNo">155</span>      throw new IllegalArgumentException("Cannot handle SpaceQuota without a soft limit");<a name="line.155"></a>
-<span class="sourceLineNo">156</span>    }<a name="line.156"></a>
-<span class="sourceLineNo">157</span>    if (!proto.hasViolationPolicy()) {<a name="line.157"></a>
-<span class="sourceLineNo">158</span>      throw new IllegalArgumentException("Cannot handle SpaceQuota without a violation policy");<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 int hashCode() {<a name="line.163"></a>
-<span class="sourceLineNo">164</span>    return Objects.hash(getTableName(), getNamespace(), proto);<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>  @Override<a name="line.167"></a>
-<span class="sourceLineNo">168</span>  public boolean equals(Object o) {<a name="line.168"></a>
-<span class="sourceLineNo">169</span>    if (o == this) {<a name="line.169"></a>
-<span class="sourceLineNo">170</span>      return true;<a name="line.170"></a>
-<span class="sourceLineNo">171</span>    }<a name="line.171"></a>
-<span class="sourceLineNo">172</span>    if (!(o instanceof SpaceLimitSettings)) {<a name="line.172"></a>
-<span class="sourceLineNo">173</span>      return false;<a name="line.173"></a>
-<span class="sourceLineNo">174</span>    }<a name="line.174"></a>
-<span class="sourceLineNo">175</span>    // o is non-null and an instance of SpaceLimitSettings<a name="line.175"></a>
-<span class="sourceLineNo">176</span>    SpaceLimitSettings other = (SpaceLimitSettings) o;<a name="line.176"></a>
-<span class="sourceLineNo">177</span>    return Objects.equals(getTableName(), other.getTableName()) &amp;&amp;<a name="line.177"></a>
-<span class="sourceLineNo">178</span>        Objects.equals(getNamespace(), other.getNamespace()) &amp;&amp;<a name="line.178"></a>
-<span class="sourceLineNo">179</span>        Objects.equals(proto, other.proto);<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>  @Override<a name="line.182"></a>
-<span class="sourceLineNo">183</span>  public String toString() {<a name="line.183"></a>
-<span class="sourceLineNo">184</span>    StringBuilder sb = new StringBuilder();<a name="line.184"></a>
-<span class="sourceLineNo">185</span>    sb.append("TYPE =&gt; SPACE");<a name="line.185"></a>
-<span class="sourceLineNo">186</span>    if (getTableName() != null) {<a name="line.186"></a>
-<span class="sourceLineNo">187</span>      sb.append(", TABLE =&gt; ").append(getTableName());<a name="line.187"></a>
-<span class="sourceLineNo">188</span>    }<a name="line.188"></a>
-<span class="sourceLineNo">189</span>    if (getNamespace() != null) {<a name="line.189"></a>
-<span class="sourceLineNo">190</span>      sb.append(", NAMESPACE =&gt; ").append(getNamespace());<a name="line.190"></a>
-<span class="sourceLineNo">191</span>    }<a name="line.191"></a>
-<span class="sourceLineNo">192</span>    if (proto.getQuota().getRemove()) {<a name="line.192"></a>
-<span class="sourceLineNo">193</span>      sb.append(", REMOVE =&gt; ").append(proto.getQuota().getRemove());<a name="line.193"></a>
-<span class="sourceLineNo">194</span>    } else {<a name="line.194"></a>
-<span class="sourceLineNo">195</span>      sb.append(", LIMIT =&gt; ").append(proto.getQuota().getSoftLimit());<a name="line.195"></a>
-<span class="sourceLineNo">196</span>      sb.append(", VIOLATION_POLICY =&gt; ").append(proto.getQuota().getViolationPolicy());<a name="line.196"></a>
-<span class="sourceLineNo">197</span>    }<a name="line.197"></a>
-<span class="sourceLineNo">198</span>    return sb.toString();<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">153</span>  static SpaceLimitSettings fromSpaceQuota(<a name="line.153"></a>
+<span class="sourceLineNo">154</span>      final String namespace, final QuotaProtos.SpaceQuota proto) {<a name="line.154"></a>
+<span class="sourceLineNo">155</span>    validateProtoArguments(proto);<a name="line.155"></a>
+<span class="sourceLineNo">156</span>    return new SpaceLimitSettings(namespace, proto.getSoftLimit(),<a name="line.156"></a>
+<span class="sourceLineNo">157</span>        ProtobufUtil.toViolationPolicy(proto.getViolationPolicy()));<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>  /**<a name="line.160"></a>
+<span class="sourceLineNo">161</span>   * Validates that the provided protobuf SpaceQuota has the necessary information to construct<a name="line.161"></a>
+<span class="sourceLineNo">162</span>   * a {@link SpaceLimitSettings}.<a name="line.162"></a>
+<span class="sourceLineNo">163</span>   *<a name="line.163"></a>
+<span class="sourceLineNo">164</span>   * @param proto The protobuf message to validate.<a name="line.164"></a>
+<span class="sourceLineNo">165</span>   */<a name="line.165"></a>
+<span class="sourceLineNo">166</span>  static void validateProtoArguments(final QuotaProtos.SpaceQuota proto) {<a name="line.166"></a>
+<span class="sourceLineNo">167</span>    if (!Objects.requireNonNull(proto).hasSoftLimit()) {<a name="line.167"></a>
+<span class="sourceLineNo">168</span>      throw new IllegalArgumentException("Cannot handle SpaceQuota without a soft limit");<a name="line.168"></a>
+<span class="sourceLineNo">169</span>    }<a name="line.169"></a>
+<span class="sourceLineNo">170</span>    if (!proto.hasViolationPolicy()) {<a name="line.170"></a>
+<span class="sourceLineNo">171</span>      throw new IllegalArgumentException("Cannot handle SpaceQuota without a violation policy");<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><a name="line.174"></a>
+<span class="sourceLineNo">175</span>  @Override<a name="line.175"></a>
+<span class="sourceLineNo">176</span>  public int hashCode() {<a name="line.176"></a>
+<span class="sourceLineNo">177</span>    return Objects.hash(getTableName(), getNamespace(), proto);<a name="line.177"></a>
+<span class="sourceLineNo">178</span>  }<a name="line.178"></a>
+<span class="sourceLineNo">179</span><a name="line.179"></a>
+<span class="sourceLineNo">180</span>  @Override<a name="line.180"></a>
+<span class="sourceLineNo">181</span>  public boolean equals(Object o) {<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    if (o == this) {<a name="line.182"></a>
+<span class="sourceLineNo">183</span>      return true;<a name="line.183"></a>
+<span class="sourceLineNo">184</span>    }<a name="line.184"></a>
+<span class="sourceLineNo">185</span>    if (!(o instanceof SpaceLimitSettings)) {<a name="line.185"></a>
+<span class="sourceLineNo">186</span>      return false;<a name="line.186"></a>
+<span class="sourceLineNo">187</span>    }<a name="line.187"></a>
+<span class="sourceLineNo">188</span>    // o is non-null and an instance of SpaceLimitSettings<a name="line.188"></a>
+<span class="sourceLineNo">189</span>    SpaceLimitSettings other = (SpaceLimitSettings) o;<a name="line.189"></a>
+<span class="sourceLineNo">190</span>    return Objects.equals(getTableName(), other.getTableName()) &amp;&amp;<a name="line.190"></a>
+<span class="sourceLineNo">191</span>        Objects.equals(getNamespace(), other.getNamespace()) &amp;&amp;<a name="line.191"></a>
+<span class="sourceLineNo">192</span>        Objects.equals(proto, other.proto);<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>  @Override<a name="line.195"></a>
+<span class="sourceLineNo">196</span>  public String toString() {<a name="line.196"></a>
+<span class="sourceLineNo">197</span>    StringBuilder sb = new StringBuilder();<a name="line.197"></a>
+<span class="sourceLineNo">198</span>    sb.append("TYPE =&gt; SPACE");<a name="line.198"></a>
+<span class="sourceLineNo">199</span>    if (getTableName() != null) {<a name="line.199"></a>
+<span class="sourceLineNo">200</span>      sb.append(", TABLE =&gt; ").append(getTableName());<a name="line.200"></a>
+<span class="sourceLineNo">201</span>    }<a name="line.201"></a>
+<span class="sourceLineNo">202</span>    if (getNamespace() != null) {<a name="line.202"></a>
+<span class="sourceLineNo">203</span>      sb.append(", NAMESPACE =&gt; ").append(getNamespace());<a name="line.203"></a>
+<span class="sourceLineNo">204</span>    }<a name="line.204"></a>
+<span class="sourceLineNo">205</span>    if (proto.getQuota().getRemove()) {<a name="line.205"></a>
+<span class="sourceLineNo">206</span>      sb.append(", REMOVE =&gt; ").append(proto.getQuota().getRemove());<a name="line.206"></a>
+<span class="sourceLineNo">207</span>    } else {<a name="line.207"></a>
+<span class="sourceLineNo">208</span>      sb.append(", LIMIT =&gt; ").append(proto.getQuota().getSoftLimit());<a name="line.208"></a>
+<span class="sourceLineNo">209</span>      sb.append(", VIOLATION_POLICY =&gt; ").append(proto.getQuota().getViolationPolicy());<a name="line.209"></a>
+<span class="sourceLineNo">210</span>    }<a name="line.210"></a>
+<span class="sourceLineNo">211</span>    return sb.toString();<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>  @Override<a name="line.214"></a>
+<span class="sourceLineNo">215</span>  protected QuotaSettings merge(QuotaSettings newSettings) {<a name="line.215"></a>
+<span class="sourceLineNo">216</span>    if (newSettings instanceof SpaceLimitSettings) {<a name="line.216"></a>
+<span class="sourceLineNo">217</span>      SpaceLimitSettings settingsToMerge = (SpaceLimitSettings) newSettings;<a name="line.217"></a>
+<span class="sourceLineNo">218</span><a name="line.218"></a>
+<span class="sourceLineNo">219</span>      // The message contained the expect SpaceQuota object<a name="line.219"></a>
+<span class="sourceLineNo">220</span>      if (settingsToMerge.proto.hasQuota()) {<a name="line.220"></a>
+<span class="sourceLineNo">221</span>        SpaceQuota quotaToMerge = settingsToMerge.proto.getQuota();<a name="line.221"></a>
+<span class="sourceLineNo">222</span>        if (quotaToMerge.getRemove()) {<a name="line.222"></a>
+<span class="sourceLineNo">223</span>          return settingsToMerge;<a name="line.223"></a>
+<span class="sourceLineNo">224</span>        } else {<a name="line.224"></a>
+<span class="sourceLineNo">225</span>          // Validate that the two settings are for the same target.<a name="line.225"></a>
+<span class="sourceLineNo">226</span>          // SpaceQuotas either apply to a table or a namespace (no user spacequota).<a name="line.226"></a>
+<span class="sourceLineNo">227</span>          if (!Objects.equals(getTableName(), settingsToMerge.getTableName())<a name="line.227"></a>
+<span class="sourceLineNo">228</span>              &amp;&amp; !Objects.equals(getNamespace(), settingsToMerge.getNamespace())) {<a name="line.228"></a>
+<span class="sourceLineNo">229</span>            throw new IllegalArgumentException("Cannot merge " + newSettings + " into " + this);<a name="line.229"></a>
+<span class="sourceLineNo">230</span>          }<a name="line.230"></a>
+<span class="sourceLineNo">231</span>          // Create a builder from the old settings<a name="line.231"></a>
+<span class="sourceLineNo">232</span>          SpaceQuota.Builder mergedBuilder = this.proto.getQuota().toBuilder();<a name="line.232"></a>
+<span class="sourceLineNo">233</span>          // Build a new SpaceQuotas object from merging in the new settings<a name="line.233"></a>
+<span class="sourceLineNo">234</span>          return new SpaceLimitSettings(<a name="line.234"></a>
+<span class="sourceLineNo">235</span>              getTableName(), getNamespace(),<a name="line.235"></a>
+<span class="sourceLineNo">236</span>              buildProtoFromQuota(mergedBuilder.mergeFrom(quotaToMerge).build()));<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>      // else, we don't know what to do, so return the original object<a name="line.239"></a>
+<span class="sourceLineNo">240</span>    }<a name="line.240"></a>
+<span class="sourceLineNo">241</span>    return this;<a name="line.241"></a>
+<span class="sourceLineNo">242</span>  }<a name="line.242"></a>
+<span class="sourceLineNo">243</span>}<a name="line.243"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/e6bd0774/devapidocs/src-html/org/apache/hadoop/hbase/quotas/ThrottleSettings.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/quotas/ThrottleSettings.html b/devapidocs/src-html/org/apache/hadoop/hbase/quotas/ThrottleSettings.html
index b9209d8..2fbb06f 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/quotas/ThrottleSettings.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/quotas/ThrottleSettings.html
@@ -25,97 +25,142 @@
 <span class="sourceLineNo">017</span> */<a name="line.17"></a>
 <span class="sourceLineNo">018</span>package org.apache.hadoop.hbase.quotas;<a name="line.18"></a>
 <span class="sourceLineNo">019</span><a name="line.19"></a>
-<span class="sourceLineNo">020</span>import java.util.concurrent.TimeUnit;<a name="line.20"></a>
-<span class="sourceLineNo">021</span><a name="line.21"></a>
-<span class="sourceLineNo">022</span>import org.apache.hadoop.hbase.TableName;<a name="line.22"></a>
-<span class="sourceLineNo">023</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.23"></a>
-<span class="sourceLineNo">024</span>import org.apache.yetus.audience.InterfaceStability;<a name="line.24"></a>
-<span class="sourceLineNo">025</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaRequest;<a name="line.25"></a>
-<span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;<a name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos;<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>@InterfaceStability.Evolving<a name="line.30"></a>
-<span class="sourceLineNo">031</span>class ThrottleSettings extends QuotaSettings {<a name="line.31"></a>
-<span class="sourceLineNo">032</span>  private final QuotaProtos.ThrottleRequest proto;<a name="line.32"></a>
-<span class="sourceLineNo">033</span><a name="line.33"></a>
-<span class="sourceLineNo">034</span>  ThrottleSettings(final String userName, final TableName tableName,<a name="line.34"></a>
-<span class="sourceLineNo">035</span>      final String namespace, final QuotaProtos.ThrottleRequest proto) {<a name="line.35"></a>
-<span class="sourceLineNo">036</span>    super(userName, tableName, namespace);<a name="line.36"></a>
-<span class="sourceLineNo">037</span>    this.proto = proto;<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>  public ThrottleType getThrottleType() {<a name="line.40"></a>
-<span class="sourceLineNo">041</span>    return ProtobufUtil.toThrottleType(proto.getType());<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>  public long getSoftLimit() {<a name="line.44"></a>
-<span class="sourceLineNo">045</span>    return proto.hasTimedQuota() ? proto.getTimedQuota().getSoftLimit() : -1;<a name="line.45"></a>
-<span class="sourceLineNo">046</span>  }<a name="line.46"></a>
-<span class="sourceLineNo">047</span><a name="line.47"></a>
-<span class="sourceLineNo">048</span>  public TimeUnit getTimeUnit() {<a name="line.48"></a>
-<span class="sourceLineNo">049</span>    return proto.hasTimedQuota() ?<a name="line.49"></a>
-<span class="sourceLineNo">050</span>      ProtobufUtil.toTimeUnit(proto.getTimedQuota().getTimeUnit()) : null;<a name="line.50"></a>
-<span class="sourceLineNo">051</span>  }<a name="line.51"></a>
-<span class="sourceLineNo">052</span><a name="line.52"></a>
-<span class="sourceLineNo">053</span>  @Override<a name="line.53"></a>
-<span class="sourceLineNo">054</span>  public QuotaType getQuotaType() {<a name="line.54"></a>
-<span class="sourceLineNo">055</span>    return QuotaType.THROTTLE;<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>  protected void setupSetQuotaRequest(SetQuotaRequest.Builder builder) {<a name="line.59"></a>
-<span class="sourceLineNo">060</span>    builder.setThrottle(proto);<a name="line.60"></a>
-<span class="sourceLineNo">061</span>  }<a name="line.61"></a>
-<span class="sourceLineNo">062</span><a name="line.62"></a>
-<span class="sourceLineNo">063</span>  @Override<a name="line.63"></a>
-<span class="sourceLineNo">064</span>  public String toString() {<a name="line.64"></a>
-<span class="sourceLineNo">065</span>    StringBuilder builder = new StringBuilder();<a name="line.65"></a>
-<span class="sourceLineNo">066</span>    builder.append("TYPE =&gt; THROTTLE");<a name="line.66"></a>
-<span class="sourceLineNo">067</span>    if (proto.hasType()) {<a name="line.67"></a>
-<span class="sourceLineNo">068</span>      builder.append(", THROTTLE_TYPE =&gt; ");<a name="line.68"></a>
-<span class="sourceLineNo">069</span>      builder.append(proto.getType().toString());<a name="line.69"></a>
-<span class="sourceLineNo">070</span>    }<a name="line.70"></a>
-<span class="sourceLineNo">071</span>    if (proto.hasTimedQuota()) {<a name="line.71"></a>
-<span class="sourceLineNo">072</span>      QuotaProtos.TimedQuota timedQuota = proto.getTimedQuota();<a name="line.72"></a>
-<span class="sourceLineNo">073</span>      builder.append(", LIMIT =&gt; ");<a name="line.73"></a>
-<span class="sourceLineNo">074</span>      if (timedQuota.hasSoftLimit()) {<a name="line.74"></a>
-<span class="sourceLineNo">075</span>        switch (getThrottleType()) {<a name="line.75"></a>
-<span class="sourceLineNo">076</span>          case REQUEST_NUMBER:<a name="line.76"></a>
-<span class="sourceLineNo">077</span>          case WRITE_NUMBER:<a name="line.77"></a>
-<span class="sourceLineNo">078</span>          case READ_NUMBER:<a name="line.78"></a>
-<span class="sourceLineNo">079</span>            builder.append(String.format("%dreq", timedQuota.getSoftLimit()));<a name="line.79"></a>
-<span class="sourceLineNo">080</span>            break;<a name="line.80"></a>
-<span class="sourceLineNo">081</span>          case REQUEST_SIZE:<a name="line.81"></a>
-<span class="sourceLineNo">082</span>          case WRITE_SIZE:<a name="line.82"></a>
-<span class="sourceLineNo">083</span>          case READ_SIZE:<a name="line.83"></a>
-<span class="sourceLineNo">084</span>            builder.append(sizeToString(timedQuota.getSoftLimit()));<a name="line.84"></a>
-<span class="sourceLineNo">085</span>            break;<a name="line.85"></a>
-<span class="sourceLineNo">086</span>        }<a name="line.86"></a>
-<span class="sourceLineNo">087</span>      } else if (timedQuota.hasShare()) {<a name="line.87"></a>
-<span class="sourceLineNo">088</span>        builder.append(String.format("%.2f%%", timedQuota.getShare()));<a name="line.88"></a>
-<span class="sourceLineNo">089</span>      }<a name="line.89"></a>
-<span class="sourceLineNo">090</span>      builder.append('/');<a name="line.90"></a>
-<span class="sourceLineNo">091</span>      builder.append(timeToString(ProtobufUtil.toTimeUnit(timedQuota.getTimeUnit())));<a name="line.91"></a>
-<span class="sourceLineNo">092</span>      if (timedQuota.hasScope()) {<a name="line.92"></a>
-<span class="sourceLineNo">093</span>        builder.append(", SCOPE =&gt; ");<a name="line.93"></a>
-<span class="sourceLineNo">094</span>        builder.append(timedQuota.getScope().toString());<a name="line.94"></a>
-<span class="sourceLineNo">095</span>      }<a name="line.95"></a>
-<span class="sourceLineNo">096</span>    } else {<a name="line.96"></a>
-<span class="sourceLineNo">097</span>      builder.append(", LIMIT =&gt; NONE");<a name="line.97"></a>
-<span class="sourceLineNo">098</span>    }<a name="line.98"></a>
-<span class="sourceLineNo">099</span>    return builder.toString();<a name="line.99"></a>
-<span class="sourceLineNo">100</span>  }<a name="line.100"></a>
-<span class="sourceLineNo">101</span><a name="line.101"></a>
-<span class="sourceLineNo">102</span>  static ThrottleSettings fromTimedQuota(final String userName,<a name="line.102"></a>
-<span class="sourceLineNo">103</span>      final TableName tableName, final String namespace,<a name="line.103"></a>
-<span class="sourceLineNo">104</span>      ThrottleType type, QuotaProtos.TimedQuota timedQuota) {<a name="line.104"></a>
-<span class="sourceLineNo">105</span>    QuotaProtos.ThrottleRequest.Builder builder = QuotaProtos.ThrottleRequest.newBuilder();<a name="line.105"></a>
-<span class="sourceLineNo">106</span>    builder.setType(ProtobufUtil.toProtoThrottleType(type));<a name="line.106"></a>
-<span class="sourceLineNo">107</span>    builder.setTimedQuota(timedQuota);<a name="line.107"></a>
-<span class="sourceLineNo">108</span>    return new ThrottleSettings(userName, tableName, namespace, builder.build());<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">020</span>import java.io.IOException;<a name="line.20"></a>
+<span class="sourceLineNo">021</span>import java.util.concurrent.TimeUnit;<a name="line.21"></a>
+<span class="sourceLineNo">022</span><a name="line.22"></a>
+<span class="sourceLineNo">023</span>import org.apache.hadoop.hbase.DoNotRetryIOException;<a name="line.23"></a>
+<span class="sourceLineNo">024</span>import org.apache.hadoop.hbase.TableName;<a name="line.24"></a>
+<span class="sourceLineNo">025</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.25"></a>
+<span class="sourceLineNo">026</span>import org.apache.yetus.audience.InterfaceStability;<a name="line.26"></a>
+<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaRequest;<a name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota;<a name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;<a name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos;<a name="line.30"></a>
+<span class="sourceLineNo">031</span><a name="line.31"></a>
+<span class="sourceLineNo">032</span>@InterfaceAudience.Private<a name="line.32"></a>
+<span class="sourceLineNo">033</span>@InterfaceStability.Evolving<a name="line.33"></a>
+<span class="sourceLineNo">034</span>class ThrottleSettings extends QuotaSettings {<a name="line.34"></a>
+<span class="sourceLineNo">035</span>  final QuotaProtos.ThrottleRequest proto;<a name="line.35"></a>
+<span class="sourceLineNo">036</span><a name="line.36"></a>
+<span class="sourceLineNo">037</span>  ThrottleSettings(final String userName, final TableName tableName,<a name="line.37"></a>
+<span class="sourceLineNo">038</span>      final String namespace, final QuotaProtos.ThrottleRequest proto) {<a name="line.38"></a>
+<span class="sourceLineNo">039</span>    super(userName, tableName, namespace);<a name="line.39"></a>
+<span class="sourceLineNo">040</span>    this.proto = proto;<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>  public ThrottleType getThrottleType() {<a name="line.43"></a>
+<span class="sourceLineNo">044</span>    return ProtobufUtil.toThrottleType(proto.getType());<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>  public long getSoftLimit() {<a name="line.47"></a>
+<span class="sourceLineNo">048</span>    return proto.hasTimedQuota() ? proto.getTimedQuota().getSoftLimit() : -1;<a name="line.48"></a>
+<span class="sourceLineNo">049</span>  }<a name="line.49"></a>
+<span class="sourceLineNo">050</span><a name="line.50"></a>
+<span class="sourceLineNo">051</span>  public TimeUnit getTimeUnit() {<a name="line.51"></a>
+<span class="sourceLineNo">052</span>    return proto.hasTimedQuota() ?<a name="line.52"></a>
+<span class="sourceLineNo">053</span>      ProtobufUtil.toTimeUnit(proto.getTimedQuota().getTimeUnit()) : null;<a name="line.53"></a>
+<span class="sourceLineNo">054</span>  }<a name="line.54"></a>
+<span class="sourceLineNo">055</span><a name="line.55"></a>
+<span class="sourceLineNo">056</span>  @Override<a name="line.56"></a>
+<span class="sourceLineNo">057</span>  public QuotaType getQuotaType() {<a name="line.57"></a>
+<span class="sourceLineNo">058</span>    return QuotaType.THROTTLE;<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>  @Override<a name="line.61"></a>
+<span class="sourceLineNo">062</span>  protected void setupSetQuotaRequest(SetQuotaRequest.Builder builder) {<a name="line.62"></a>
+<span class="sourceLineNo">063</span>    builder.setThrottle(proto);<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>  @Override<a name="line.66"></a>
+<span class="sourceLineNo">067</span>  public String toString() {<a name="line.67"></a>
+<span class="sourceLineNo">068</span>    StringBuilder builder = new StringBuilder();<a name="line.68"></a>
+<span class="sourceLineNo">069</span>    builder.append("TYPE =&gt; THROTTLE");<a name="line.69"></a>
+<span class="sourceLineNo">070</span>    if (proto.hasType()) {<a name="line.70"></a>
+<span class="sourceLineNo">071</span>      builder.append(", THROTTLE_TYPE =&gt; ");<a name="line.71"></a>
+<span class="sourceLineNo">072</span>      builder.append(proto.getType().toString());<a name="line.72"></a>
+<span class="sourceLineNo">073</span>    }<a name="line.73"></a>
+<span class="sourceLineNo">074</span>    if (proto.hasTimedQuota()) {<a name="line.74"></a>
+<span class="sourceLineNo">075</span>      QuotaProtos.TimedQuota timedQuota = proto.getTimedQuota();<a name="line.75"></a>
+<span class="sourceLineNo">076</span>      builder.append(", LIMIT =&gt; ");<a name="line.76"></a>
+<span class="sourceLineNo">077</span>      if (timedQuota.hasSoftLimit()) {<a name="line.77"></a>
+<span class="sourceLineNo">078</span>        switch (getThrottleType()) {<a name="line.78"></a>
+<span class="sourceLineNo">079</span>          case REQUEST_NUMBER:<a name="line.79"></a>
+<span class="sourceLineNo">080</span>          case WRITE_NUMBER:<a name="line.80"></a>
+<span class="sourceLineNo">081</span>          case READ_NUMBER:<a name="line.81"></a>
+<span class="sourceLineNo">082</span>            builder.append(String.format("%dreq", timedQuota.getSoftLimit()));<a name="line.82"></a>
+<span class="sourceLineNo">083</span>            break;<a name="line.83"></a>
+<span class="sourceLineNo">084</span>          case REQUEST_SIZE:<a name="line.84"></a>
+<span class="sourceLineNo">085</span>          case WRITE_SIZE:<a name="line.85"></a>
+<span class="sourceLineNo">086</span>          case READ_SIZE:<a name="line.86"></a>
+<span class="sourceLineNo">087</span>            builder.append(sizeToString(timedQuota.getSoftLimit()));<a name="line.87"></a>
+<span class="sourceLineNo">088</span>            break;<a name="line.88"></a>
+<span class="sourceLineNo">089</span>        }<a name="line.89"></a>
+<span class="sourceLineNo">090</span>      } else if (timedQuota.hasShare()) {<a name="line.90"></a>
+<span class="sourceLineNo">091</span>        builder.append(String.format("%.2f%%", timedQuota.getShare()));<a name="line.91"></a>
+<span class="sourceLineNo">092</span>      }<a name="line.92"></a>
+<span class="sourceLineNo">093</span>      builder.append('/');<a name="line.93"></a>
+<span class="sourceLineNo">094</span>      builder.append(timeToString(ProtobufUtil.toTimeUnit(timedQuota.getTimeUnit())));<a name="line.94"></a>
+<span class="sourceLineNo">095</span>      if (timedQuota.hasScope()) {<a name="line.95"></a>
+<span class="sourceLineNo">096</span>        builder.append(", SCOPE =&gt; ");<a name="line.96"></a>
+<span class="sourceLineNo">097</span>        builder.append(timedQuota.getScope().toString());<a name="line.97"></a>
+<span class="sourceLineNo">098</span>      }<a name="line.98"></a>
+<span class="sourceLineNo">099</span>    } else {<a name="line.99"></a>
+<span class="sourceLineNo">100</span>      builder.append(", LIMIT =&gt; NONE");<a name="line.100"></a>
+<span class="sourceLineNo">101</span>    }<a name="line.101"></a>
+<span class="sourceLineNo">102</span>    return builder.toString();<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>
+<span class="sourceLineNo">105</span>  @Override<a name="line.105"></a>
+<span class="sourceLineNo">106</span>  protected ThrottleSettings merge(QuotaSettings other) throws IOException {<a name="line.106"></a>
+<span class="sourceLineNo">107</span>    if (other instanceof ThrottleSettings) {<a name="line.107"></a>
+<span class="sourceLineNo">108</span>      ThrottleSettings otherThrottle = (ThrottleSettings) other;<a name="line.108"></a>
+<span class="sourceLineNo">109</span><a name="line.109"></a>
+<span class="sourceLineNo">110</span>      // Make sure this and the other target the same "subject"<a name="line.110"></a>
+<span class="sourceLineNo">111</span>      validateQuotaTarget(other);<a name="line.111"></a>
+<span class="sourceLineNo">112</span><a name="line.112"></a>
+<span class="sourceLineNo">113</span>      QuotaProtos.ThrottleRequest.Builder builder = proto.toBuilder();<a name="line.113"></a>
+<span class="sourceLineNo">114</span>      if (!otherThrottle.proto.hasType()) {<a name="line.114"></a>
+<span class="sourceLineNo">115</span>        return null;<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>      QuotaProtos.ThrottleRequest otherProto = otherThrottle.proto;<a name="line.118"></a>
+<span class="sourceLineNo">119</span>      if (otherProto.hasTimedQuota()) {<a name="line.119"></a>
+<span class="sourceLineNo">120</span>        if (otherProto.hasTimedQuota()) {<a name="line.120"></a>
+<span class="sourceLineNo">121</span>          validateTimedQuota(otherProto.getTimedQuota());<a name="line.121"></a>
+<span class="sourceLineNo">122</span>        }<a name="line.122"></a>
+<span class="sourceLineNo">123</span><a name="line.123"></a>
+<span class="sourceLineNo">124</span>        if (!proto.getType().equals(otherProto.getType())) {<a name="line.124"></a>
+<span class="sourceLineNo">125</span>          throw new IllegalArgumentException(<a name="line.125"></a>
+<span class="sourceLineNo">126</span>              "Cannot merge a ThrottleRequest for " + proto.getType() + " with " +<a name="line.126"></a>
+<span class="sourceLineNo">127</span>                  otherProto.getType());<a name="line.127"></a>
+<span class="sourceLineNo">128</span>        }<a name="line.128"></a>
+<span class="sourceLineNo">129</span>        QuotaProtos.TimedQuota.Builder timedQuotaBuilder = proto.getTimedQuota().toBuilder();<a name="line.129"></a>
+<span class="sourceLineNo">130</span>        timedQuotaBuilder.mergeFrom(otherProto.getTimedQuota());<a name="line.130"></a>
+<span class="sourceLineNo">131</span><a name="line.131"></a>
+<span class="sourceLineNo">132</span>        QuotaProtos.ThrottleRequest mergedReq = builder.setTimedQuota(<a name="line.132"></a>
+<span class="sourceLineNo">133</span>            timedQuotaBuilder.build()).build();<a name="line.133"></a>
+<span class="sourceLineNo">134</span>        return new ThrottleSettings(getUserName(), getTableName(), getNamespace(), mergedReq);<a name="line.134"></a>
+<span class="sourceLineNo">135</span>      }<a name="line.135"></a>
+<span class="sourceLineNo">136</span>    }<a name="line.136"></a>
+<span class="sourceLineNo">137</span>    return this;<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>  private void validateTimedQuota(final TimedQuota timedQuota) throws IOException {<a name="line.140"></a>
+<span class="sourceLineNo">141</span>    if (timedQuota.getSoftLimit() &lt; 1) {<a name="line.141"></a>
+<span class="sourceLineNo">142</span>      throw new DoNotRetryIOException(new UnsupportedOperationException(<a name="line.142"></a>
+<span class="sourceLineNo">143</span>          "The throttle limit must be greater then 0, got " + timedQuota.getSoftLimit()));<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>  static ThrottleSettings fromTimedQuota(final String userName,<a name="line.147"></a>
+<span class="sourceLineNo">148</span>      final TableName tableName, final String namespace,<a name="line.148"></a>
+<span class="sourceLineNo">149</span>      ThrottleType type, QuotaProtos.TimedQuota timedQuota) {<a name="line.149"></a>
+<span class="sourceLineNo">150</span>    QuotaProtos.ThrottleRequest.Builder builder = QuotaProtos.ThrottleRequest.newBuilder();<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    builder.setType(ProtobufUtil.toProtoThrottleType(type));<a name="line.151"></a>
+<span class="sourceLineNo">152</span>    builder.setTimedQuota(timedQuota);<a name="line.152"></a>
+<span class="sourceLineNo">153</span>    return new ThrottleSettings(userName, tableName, namespace, builder.build());<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>
 
 
 


Mime
View raw message