hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [15/23] hbase-site git commit: Published site at f1d453599a944440b8a1075082e2dc7b7676416f.
Date Mon, 21 Mar 2016 16:17:29 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/a4cb7eaa/devapidocs/src-html/org/apache/hadoop/hbase/namespace/NamespaceAuditor.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/namespace/NamespaceAuditor.html b/devapidocs/src-html/org/apache/hadoop/hbase/namespace/NamespaceAuditor.html
index 9a67d16..14b16a3 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/namespace/NamespaceAuditor.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/namespace/NamespaceAuditor.html
@@ -108,65 +108,80 @@
 <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><a name="line.102"></a>
-<span class="sourceLineNo">103</span>  public void checkQuotaToSplitRegion(HRegionInfo hri) throws IOException {<a name="line.103"></a>
-<span class="sourceLineNo">104</span>    if (!stateManager.isInitialized()) {<a name="line.104"></a>
-<span class="sourceLineNo">105</span>      throw new IOException(<a name="line.105"></a>
-<span class="sourceLineNo">106</span>          "Split operation is being performed even before namespace auditor is initialized.");<a name="line.106"></a>
-<span class="sourceLineNo">107</span>    } else if (!stateManager<a name="line.107"></a>
-<span class="sourceLineNo">108</span>        .checkAndUpdateNamespaceRegionCount(hri.getTable(), hri.getRegionName(), 1)) {<a name="line.108"></a>
-<span class="sourceLineNo">109</span>      throw new QuotaExceededException("Region split not possible for :" + hri.getEncodedName()<a name="line.109"></a>
-<span class="sourceLineNo">110</span>          + " as quota limits are exceeded ");<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><a name="line.113"></a>
-<span class="sourceLineNo">114</span>  public void updateQuotaForRegionMerge(HRegionInfo hri) throws IOException {<a name="line.114"></a>
-<span class="sourceLineNo">115</span>    if (!stateManager.isInitialized()) {<a name="line.115"></a>
-<span class="sourceLineNo">116</span>      throw new IOException(<a name="line.116"></a>
-<span class="sourceLineNo">117</span>          "Merge operation is being performed even before namespace auditor is initialized.");<a name="line.117"></a>
-<span class="sourceLineNo">118</span>    } else if (!stateManager<a name="line.118"></a>
-<span class="sourceLineNo">119</span>        .checkAndUpdateNamespaceRegionCount(hri.getTable(), hri.getRegionName(), -1)) {<a name="line.119"></a>
-<span class="sourceLineNo">120</span>      throw new QuotaExceededException("Region split not possible for :" + hri.getEncodedName()<a name="line.120"></a>
-<span class="sourceLineNo">121</span>          + " as quota limits are exceeded ");<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><a name="line.124"></a>
-<span class="sourceLineNo">125</span>  public void addNamespace(NamespaceDescriptor ns) throws IOException {<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    stateManager.addNamespace(ns.getName());<a name="line.126"></a>
+<span class="sourceLineNo">103</span>  /**<a name="line.103"></a>
+<span class="sourceLineNo">104</span>   * Get region count for table<a name="line.104"></a>
+<span class="sourceLineNo">105</span>   * @param tName - table name<a name="line.105"></a>
+<span class="sourceLineNo">106</span>   * @return cached region count, or -1 if table status not found<a name="line.106"></a>
+<span class="sourceLineNo">107</span>   * @throws IOException Signals that the namespace auditor has not been initialized<a name="line.107"></a>
+<span class="sourceLineNo">108</span>   */<a name="line.108"></a>
+<span class="sourceLineNo">109</span>  public int getRegionCountOfTable(TableName tName) throws IOException {<a name="line.109"></a>
+<span class="sourceLineNo">110</span>    if (stateManager.isInitialized()) {<a name="line.110"></a>
+<span class="sourceLineNo">111</span>      NamespaceTableAndRegionInfo state = stateManager.getState(tName.getNamespaceAsString());<a name="line.111"></a>
+<span class="sourceLineNo">112</span>      return state != null ? state.getRegionCountOfTable(tName) : -1;<a name="line.112"></a>
+<span class="sourceLineNo">113</span>    }<a name="line.113"></a>
+<span class="sourceLineNo">114</span>    checkTableTypeAndThrowException(tName);<a name="line.114"></a>
+<span class="sourceLineNo">115</span>    return -1;<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>  public void checkQuotaToSplitRegion(HRegionInfo hri) throws IOException {<a name="line.118"></a>
+<span class="sourceLineNo">119</span>    if (!stateManager.isInitialized()) {<a name="line.119"></a>
+<span class="sourceLineNo">120</span>      throw new IOException(<a name="line.120"></a>
+<span class="sourceLineNo">121</span>          "Split operation is being performed even before namespace auditor is initialized.");<a name="line.121"></a>
+<span class="sourceLineNo">122</span>    } else if (!stateManager<a name="line.122"></a>
+<span class="sourceLineNo">123</span>        .checkAndUpdateNamespaceRegionCount(hri.getTable(), hri.getRegionName(), 1)) {<a name="line.123"></a>
+<span class="sourceLineNo">124</span>      throw new QuotaExceededException("Region split not possible for :" + hri.getEncodedName()<a name="line.124"></a>
+<span class="sourceLineNo">125</span>          + " as quota limits are exceeded ");<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 void deleteNamespace(String namespace) throws IOException {<a name="line.129"></a>
-<span class="sourceLineNo">130</span>    stateManager.deleteNamespace(namespace);<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>  public void removeFromNamespaceUsage(TableName tableName)<a name="line.133"></a>
-<span class="sourceLineNo">134</span>      throws IOException {<a name="line.134"></a>
-<span class="sourceLineNo">135</span>    stateManager.removeTable(tableName);<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>  public void removeRegionFromNamespaceUsage(HRegionInfo hri) throws IOException {<a name="line.138"></a>
-<span class="sourceLineNo">139</span>    stateManager.removeRegionFromTable(hri);<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>   * @param namespace The name of the namespace<a name="line.143"></a>
-<span class="sourceLineNo">144</span>   * @return An instance of NamespaceTableAndRegionInfo<a name="line.144"></a>
-<span class="sourceLineNo">145</span>   */<a name="line.145"></a>
-<span class="sourceLineNo">146</span>  public NamespaceTableAndRegionInfo getState(String namespace) {<a name="line.146"></a>
-<span class="sourceLineNo">147</span>    if (stateManager.isInitialized()) {<a name="line.147"></a>
-<span class="sourceLineNo">148</span>      return stateManager.getState(namespace);<a name="line.148"></a>
-<span class="sourceLineNo">149</span>    }<a name="line.149"></a>
-<span class="sourceLineNo">150</span>    return null;<a name="line.150"></a>
+<span class="sourceLineNo">129</span>  public void updateQuotaForRegionMerge(HRegionInfo hri) throws IOException {<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    if (!stateManager.isInitialized()) {<a name="line.130"></a>
+<span class="sourceLineNo">131</span>      throw new IOException(<a name="line.131"></a>
+<span class="sourceLineNo">132</span>          "Merge operation is being performed even before namespace auditor is initialized.");<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    } else if (!stateManager<a name="line.133"></a>
+<span class="sourceLineNo">134</span>        .checkAndUpdateNamespaceRegionCount(hri.getTable(), hri.getRegionName(), -1)) {<a name="line.134"></a>
+<span class="sourceLineNo">135</span>      throw new QuotaExceededException("Region split not possible for :" + hri.getEncodedName()<a name="line.135"></a>
+<span class="sourceLineNo">136</span>          + " as quota limits are exceeded ");<a name="line.136"></a>
+<span class="sourceLineNo">137</span>    }<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>  public void addNamespace(NamespaceDescriptor ns) throws IOException {<a name="line.140"></a>
+<span class="sourceLineNo">141</span>    stateManager.addNamespace(ns.getName());<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>  public void deleteNamespace(String namespace) throws IOException {<a name="line.144"></a>
+<span class="sourceLineNo">145</span>    stateManager.deleteNamespace(namespace);<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>  public void removeFromNamespaceUsage(TableName tableName)<a name="line.148"></a>
+<span class="sourceLineNo">149</span>      throws IOException {<a name="line.149"></a>
+<span class="sourceLineNo">150</span>    stateManager.removeTable(tableName);<a name="line.150"></a>
 <span class="sourceLineNo">151</span>  }<a name="line.151"></a>
 <span class="sourceLineNo">152</span><a name="line.152"></a>
-<span class="sourceLineNo">153</span>  /**<a name="line.153"></a>
-<span class="sourceLineNo">154</span>   * Checks if namespace auditor is initialized. Used only for testing.<a name="line.154"></a>
-<span class="sourceLineNo">155</span>   *<a name="line.155"></a>
-<span class="sourceLineNo">156</span>   * @return true, if is initialized<a name="line.156"></a>
-<span class="sourceLineNo">157</span>   */<a name="line.157"></a>
-<span class="sourceLineNo">158</span>  public boolean isInitialized() {<a name="line.158"></a>
-<span class="sourceLineNo">159</span>    return stateManager.isInitialized();<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">153</span>  public void removeRegionFromNamespaceUsage(HRegionInfo hri) throws IOException {<a name="line.153"></a>
+<span class="sourceLineNo">154</span>    stateManager.removeRegionFromTable(hri);<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>  /**<a name="line.157"></a>
+<span class="sourceLineNo">158</span>   * @param namespace The name of the namespace<a name="line.158"></a>
+<span class="sourceLineNo">159</span>   * @return An instance of NamespaceTableAndRegionInfo<a name="line.159"></a>
+<span class="sourceLineNo">160</span>   */<a name="line.160"></a>
+<span class="sourceLineNo">161</span>  public NamespaceTableAndRegionInfo getState(String namespace) {<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    if (stateManager.isInitialized()) {<a name="line.162"></a>
+<span class="sourceLineNo">163</span>      return stateManager.getState(namespace);<a name="line.163"></a>
+<span class="sourceLineNo">164</span>    }<a name="line.164"></a>
+<span class="sourceLineNo">165</span>    return null;<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>  /**<a name="line.168"></a>
+<span class="sourceLineNo">169</span>   * Checks if namespace auditor is initialized. Used only for testing.<a name="line.169"></a>
+<span class="sourceLineNo">170</span>   *<a name="line.170"></a>
+<span class="sourceLineNo">171</span>   * @return true, if is initialized<a name="line.171"></a>
+<span class="sourceLineNo">172</span>   */<a name="line.172"></a>
+<span class="sourceLineNo">173</span>  public boolean isInitialized() {<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    return stateManager.isInitialized();<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>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/a4cb7eaa/devapidocs/src-html/org/apache/hadoop/hbase/namespace/NamespaceStateManager.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/namespace/NamespaceStateManager.html b/devapidocs/src-html/org/apache/hadoop/hbase/namespace/NamespaceStateManager.html
index 1f8d996..396fa6c 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/namespace/NamespaceStateManager.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/namespace/NamespaceStateManager.html
@@ -159,7 +159,7 @@
 <span class="sourceLineNo">151</span>      currentStatus = getState(nspdesc.getName());<a name="line.151"></a>
 <span class="sourceLineNo">152</span>      if ((currentStatus.getTables().size()) &gt;= TableNamespaceManager.getMaxTables(nspdesc)) {<a name="line.152"></a>
 <span class="sourceLineNo">153</span>        throw new QuotaExceededException("The table " + table.getNameAsString()<a name="line.153"></a>
-<span class="sourceLineNo">154</span>            + "cannot be created as it would exceed maximum number of tables allowed "<a name="line.154"></a>
+<span class="sourceLineNo">154</span>            + " cannot be created as it would exceed maximum number of tables allowed "<a name="line.154"></a>
 <span class="sourceLineNo">155</span>            + " in the namespace.  The total number of tables permitted is "<a name="line.155"></a>
 <span class="sourceLineNo">156</span>            + TableNamespaceManager.getMaxTables(nspdesc));<a name="line.156"></a>
 <span class="sourceLineNo">157</span>      }<a name="line.157"></a>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/a4cb7eaa/devapidocs/src-html/org/apache/hadoop/hbase/quotas/MasterQuotaManager.NamedLock.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/quotas/MasterQuotaManager.NamedLock.html b/devapidocs/src-html/org/apache/hadoop/hbase/quotas/MasterQuotaManager.NamedLock.html
index 6b044ba..e698840 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/quotas/MasterQuotaManager.NamedLock.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/quotas/MasterQuotaManager.NamedLock.html
@@ -328,172 +328,182 @@
 <span class="sourceLineNo">320</span>    }<a name="line.320"></a>
 <span class="sourceLineNo">321</span>  }<a name="line.321"></a>
 <span class="sourceLineNo">322</span><a name="line.322"></a>
-<span class="sourceLineNo">323</span>  public void onRegionMerged(HRegionInfo hri) throws IOException {<a name="line.323"></a>
-<span class="sourceLineNo">324</span>    if (enabled) {<a name="line.324"></a>
-<span class="sourceLineNo">325</span>      namespaceQuotaManager.updateQuotaForRegionMerge(hri);<a name="line.325"></a>
-<span class="sourceLineNo">326</span>    }<a name="line.326"></a>
-<span class="sourceLineNo">327</span>  }<a name="line.327"></a>
-<span class="sourceLineNo">328</span><a name="line.328"></a>
-<span class="sourceLineNo">329</span>  public void onRegionSplit(HRegionInfo hri) throws IOException {<a name="line.329"></a>
-<span class="sourceLineNo">330</span>    if (enabled) {<a name="line.330"></a>
-<span class="sourceLineNo">331</span>      namespaceQuotaManager.checkQuotaToSplitRegion(hri);<a name="line.331"></a>
-<span class="sourceLineNo">332</span>    }<a name="line.332"></a>
-<span class="sourceLineNo">333</span>  }<a name="line.333"></a>
-<span class="sourceLineNo">334</span><a name="line.334"></a>
-<span class="sourceLineNo">335</span>  /**<a name="line.335"></a>
-<span class="sourceLineNo">336</span>   * Remove table from namespace quota.<a name="line.336"></a>
-<span class="sourceLineNo">337</span>   *<a name="line.337"></a>
-<span class="sourceLineNo">338</span>   * @param tName - The table name to update quota usage.<a name="line.338"></a>
-<span class="sourceLineNo">339</span>   * @throws IOException Signals that an I/O exception has occurred.<a name="line.339"></a>
-<span class="sourceLineNo">340</span>   */<a name="line.340"></a>
-<span class="sourceLineNo">341</span>  public void removeTableFromNamespaceQuota(TableName tName) throws IOException {<a name="line.341"></a>
-<span class="sourceLineNo">342</span>    if (enabled) {<a name="line.342"></a>
-<span class="sourceLineNo">343</span>      namespaceQuotaManager.removeFromNamespaceUsage(tName);<a name="line.343"></a>
-<span class="sourceLineNo">344</span>    }<a name="line.344"></a>
-<span class="sourceLineNo">345</span>  }<a name="line.345"></a>
-<span class="sourceLineNo">346</span><a name="line.346"></a>
-<span class="sourceLineNo">347</span>  public NamespaceAuditor getNamespaceQuotaManager() {<a name="line.347"></a>
-<span class="sourceLineNo">348</span>    return this.namespaceQuotaManager;<a name="line.348"></a>
-<span class="sourceLineNo">349</span>  }<a name="line.349"></a>
-<span class="sourceLineNo">350</span><a name="line.350"></a>
-<span class="sourceLineNo">351</span>  private static interface SetQuotaOperations {<a name="line.351"></a>
-<span class="sourceLineNo">352</span>    Quotas fetch() throws IOException;<a name="line.352"></a>
-<span class="sourceLineNo">353</span>    void delete() throws IOException;<a name="line.353"></a>
-<span class="sourceLineNo">354</span>    void update(final Quotas quotas) throws IOException;<a name="line.354"></a>
-<span class="sourceLineNo">355</span>    void preApply(final Quotas quotas) throws IOException;<a name="line.355"></a>
-<span class="sourceLineNo">356</span>    void postApply(final Quotas quotas) throws IOException;<a name="line.356"></a>
-<span class="sourceLineNo">357</span>  }<a name="line.357"></a>
-<span class="sourceLineNo">358</span><a name="line.358"></a>
-<span class="sourceLineNo">359</span>  /* ==========================================================================<a name="line.359"></a>
-<span class="sourceLineNo">360</span>   *  Helpers to apply changes to the quotas<a name="line.360"></a>
-<span class="sourceLineNo">361</span>   */<a name="line.361"></a>
-<span class="sourceLineNo">362</span>  private void applyThrottle(final Quotas.Builder quotas, final ThrottleRequest req)<a name="line.362"></a>
-<span class="sourceLineNo">363</span>      throws IOException {<a name="line.363"></a>
-<span class="sourceLineNo">364</span>    Throttle.Builder throttle;<a name="line.364"></a>
-<span class="sourceLineNo">365</span><a name="line.365"></a>
-<span class="sourceLineNo">366</span>    if (req.hasType() &amp;&amp; (req.hasTimedQuota() || quotas.hasThrottle())) {<a name="line.366"></a>
-<span class="sourceLineNo">367</span>      // Validate timed quota if present<a name="line.367"></a>
-<span class="sourceLineNo">368</span>      if (req.hasTimedQuota()) validateTimedQuota(req.getTimedQuota());<a name="line.368"></a>
-<span class="sourceLineNo">369</span><a name="line.369"></a>
-<span class="sourceLineNo">370</span>      // apply the new settings<a name="line.370"></a>
-<span class="sourceLineNo">371</span>      throttle = quotas.hasThrottle() ? quotas.getThrottle().toBuilder() : Throttle.newBuilder();<a name="line.371"></a>
-<span class="sourceLineNo">372</span><a name="line.372"></a>
-<span class="sourceLineNo">373</span>      switch (req.getType()) {<a name="line.373"></a>
-<span class="sourceLineNo">374</span>        case REQUEST_NUMBER:<a name="line.374"></a>
-<span class="sourceLineNo">375</span>          if (req.hasTimedQuota()) {<a name="line.375"></a>
-<span class="sourceLineNo">376</span>            throttle.setReqNum(req.getTimedQuota());<a name="line.376"></a>
-<span class="sourceLineNo">377</span>          } else {<a name="line.377"></a>
-<span class="sourceLineNo">378</span>            throttle.clearReqNum();<a name="line.378"></a>
-<span class="sourceLineNo">379</span>          }<a name="line.379"></a>
-<span class="sourceLineNo">380</span>          break;<a name="line.380"></a>
-<span class="sourceLineNo">381</span>        case REQUEST_SIZE:<a name="line.381"></a>
-<span class="sourceLineNo">382</span>          if (req.hasTimedQuota()) {<a name="line.382"></a>
-<span class="sourceLineNo">383</span>            throttle.setReqSize(req.getTimedQuota());<a name="line.383"></a>
-<span class="sourceLineNo">384</span>          } else {<a name="line.384"></a>
-<span class="sourceLineNo">385</span>            throttle.clearReqSize();<a name="line.385"></a>
-<span class="sourceLineNo">386</span>          }<a name="line.386"></a>
-<span class="sourceLineNo">387</span>          break;<a name="line.387"></a>
-<span class="sourceLineNo">388</span>        case WRITE_NUMBER:<a name="line.388"></a>
-<span class="sourceLineNo">389</span>          if (req.hasTimedQuota()) {<a name="line.389"></a>
-<span class="sourceLineNo">390</span>            throttle.setWriteNum(req.getTimedQuota());<a name="line.390"></a>
-<span class="sourceLineNo">391</span>          } else {<a name="line.391"></a>
-<span class="sourceLineNo">392</span>            throttle.clearWriteNum();<a name="line.392"></a>
-<span class="sourceLineNo">393</span>          }<a name="line.393"></a>
-<span class="sourceLineNo">394</span>          break;<a name="line.394"></a>
-<span class="sourceLineNo">395</span>        case WRITE_SIZE:<a name="line.395"></a>
-<span class="sourceLineNo">396</span>          if (req.hasTimedQuota()) {<a name="line.396"></a>
-<span class="sourceLineNo">397</span>            throttle.setWriteSize(req.getTimedQuota());<a name="line.397"></a>
-<span class="sourceLineNo">398</span>          } else {<a name="line.398"></a>
-<span class="sourceLineNo">399</span>            throttle.clearWriteSize();<a name="line.399"></a>
-<span class="sourceLineNo">400</span>          }<a name="line.400"></a>
-<span class="sourceLineNo">401</span>          break;<a name="line.401"></a>
-<span class="sourceLineNo">402</span>        case READ_NUMBER:<a name="line.402"></a>
-<span class="sourceLineNo">403</span>          if (req.hasTimedQuota()) {<a name="line.403"></a>
-<span class="sourceLineNo">404</span>            throttle.setReadNum(req.getTimedQuota());<a name="line.404"></a>
-<span class="sourceLineNo">405</span>          } else {<a name="line.405"></a>
-<span class="sourceLineNo">406</span>            throttle.clearReqNum();<a name="line.406"></a>
-<span class="sourceLineNo">407</span>          }<a name="line.407"></a>
-<span class="sourceLineNo">408</span>          break;<a name="line.408"></a>
-<span class="sourceLineNo">409</span>        case READ_SIZE:<a name="line.409"></a>
-<span class="sourceLineNo">410</span>          if (req.hasTimedQuota()) {<a name="line.410"></a>
-<span class="sourceLineNo">411</span>            throttle.setReadSize(req.getTimedQuota());<a name="line.411"></a>
-<span class="sourceLineNo">412</span>          } else {<a name="line.412"></a>
-<span class="sourceLineNo">413</span>            throttle.clearReadSize();<a name="line.413"></a>
-<span class="sourceLineNo">414</span>          }<a name="line.414"></a>
-<span class="sourceLineNo">415</span>          break;<a name="line.415"></a>
-<span class="sourceLineNo">416</span>      }<a name="line.416"></a>
-<span class="sourceLineNo">417</span>      quotas.setThrottle(throttle.build());<a name="line.417"></a>
-<span class="sourceLineNo">418</span>    } else {<a name="line.418"></a>
-<span class="sourceLineNo">419</span>      quotas.clearThrottle();<a name="line.419"></a>
-<span class="sourceLineNo">420</span>    }<a name="line.420"></a>
-<span class="sourceLineNo">421</span>  }<a name="line.421"></a>
-<span class="sourceLineNo">422</span><a name="line.422"></a>
-<span class="sourceLineNo">423</span>  private void applyBypassGlobals(final Quotas.Builder quotas, boolean bypassGlobals) {<a name="line.423"></a>
-<span class="sourceLineNo">424</span>    if (bypassGlobals) {<a name="line.424"></a>
-<span class="sourceLineNo">425</span>      quotas.setBypassGlobals(bypassGlobals);<a name="line.425"></a>
-<span class="sourceLineNo">426</span>    } else {<a name="line.426"></a>
-<span class="sourceLineNo">427</span>      quotas.clearBypassGlobals();<a name="line.427"></a>
-<span class="sourceLineNo">428</span>    }<a name="line.428"></a>
-<span class="sourceLineNo">429</span>  }<a name="line.429"></a>
-<span class="sourceLineNo">430</span><a name="line.430"></a>
-<span class="sourceLineNo">431</span>  private void validateTimedQuota(final TimedQuota timedQuota) throws IOException {<a name="line.431"></a>
-<span class="sourceLineNo">432</span>    if (timedQuota.getSoftLimit() &lt; 1) {<a name="line.432"></a>
-<span class="sourceLineNo">433</span>      throw new DoNotRetryIOException(new UnsupportedOperationException(<a name="line.433"></a>
-<span class="sourceLineNo">434</span>          "The throttle limit must be greater then 0, got " + timedQuota.getSoftLimit()));<a name="line.434"></a>
-<span class="sourceLineNo">435</span>    }<a name="line.435"></a>
-<span class="sourceLineNo">436</span>  }<a name="line.436"></a>
-<span class="sourceLineNo">437</span><a name="line.437"></a>
-<span class="sourceLineNo">438</span>  /* ==========================================================================<a name="line.438"></a>
-<span class="sourceLineNo">439</span>   *  Helpers<a name="line.439"></a>
-<span class="sourceLineNo">440</span>   */<a name="line.440"></a>
-<span class="sourceLineNo">441</span><a name="line.441"></a>
-<span class="sourceLineNo">442</span>  private void checkQuotaSupport() throws IOException {<a name="line.442"></a>
-<span class="sourceLineNo">443</span>    if (!enabled) {<a name="line.443"></a>
-<span class="sourceLineNo">444</span>      throw new DoNotRetryIOException(<a name="line.444"></a>
-<span class="sourceLineNo">445</span>        new UnsupportedOperationException("quota support disabled"));<a name="line.445"></a>
-<span class="sourceLineNo">446</span>    }<a name="line.446"></a>
-<span class="sourceLineNo">447</span>  }<a name="line.447"></a>
-<span class="sourceLineNo">448</span><a name="line.448"></a>
-<span class="sourceLineNo">449</span>  private void createQuotaTable() throws IOException {<a name="line.449"></a>
-<span class="sourceLineNo">450</span>    HRegionInfo newRegions[] = new HRegionInfo[] {<a name="line.450"></a>
-<span class="sourceLineNo">451</span>      new HRegionInfo(QuotaUtil.QUOTA_TABLE_NAME)<a name="line.451"></a>
-<span class="sourceLineNo">452</span>    };<a name="line.452"></a>
-<span class="sourceLineNo">453</span><a name="line.453"></a>
-<span class="sourceLineNo">454</span>    masterServices.getMasterProcedureExecutor()<a name="line.454"></a>
-<span class="sourceLineNo">455</span>      .submitProcedure(new CreateTableProcedure(<a name="line.455"></a>
-<span class="sourceLineNo">456</span>          masterServices.getMasterProcedureExecutor().getEnvironment(),<a name="line.456"></a>
-<span class="sourceLineNo">457</span>          QuotaUtil.QUOTA_TABLE_DESC,<a name="line.457"></a>
-<span class="sourceLineNo">458</span>          newRegions));<a name="line.458"></a>
-<span class="sourceLineNo">459</span>  }<a name="line.459"></a>
-<span class="sourceLineNo">460</span><a name="line.460"></a>
-<span class="sourceLineNo">461</span>  private static class NamedLock&lt;T&gt; {<a name="line.461"></a>
-<span class="sourceLineNo">462</span>    private HashSet&lt;T&gt; locks = new HashSet&lt;T&gt;();<a name="line.462"></a>
+<span class="sourceLineNo">323</span>  /**<a name="line.323"></a>
+<span class="sourceLineNo">324</span>   * @return cached region count, or -1 if quota manager is disabled or table status not found<a name="line.324"></a>
+<span class="sourceLineNo">325</span>  */<a name="line.325"></a>
+<span class="sourceLineNo">326</span>  public int getRegionCountOfTable(TableName tName) throws IOException {<a name="line.326"></a>
+<span class="sourceLineNo">327</span>    if (enabled) {<a name="line.327"></a>
+<span class="sourceLineNo">328</span>      return namespaceQuotaManager.getRegionCountOfTable(tName);<a name="line.328"></a>
+<span class="sourceLineNo">329</span>    }<a name="line.329"></a>
+<span class="sourceLineNo">330</span>    return -1;<a name="line.330"></a>
+<span class="sourceLineNo">331</span>  }<a name="line.331"></a>
+<span class="sourceLineNo">332</span><a name="line.332"></a>
+<span class="sourceLineNo">333</span>  public void onRegionMerged(HRegionInfo hri) throws IOException {<a name="line.333"></a>
+<span class="sourceLineNo">334</span>    if (enabled) {<a name="line.334"></a>
+<span class="sourceLineNo">335</span>      namespaceQuotaManager.updateQuotaForRegionMerge(hri);<a name="line.335"></a>
+<span class="sourceLineNo">336</span>    }<a name="line.336"></a>
+<span class="sourceLineNo">337</span>  }<a name="line.337"></a>
+<span class="sourceLineNo">338</span><a name="line.338"></a>
+<span class="sourceLineNo">339</span>  public void onRegionSplit(HRegionInfo hri) throws IOException {<a name="line.339"></a>
+<span class="sourceLineNo">340</span>    if (enabled) {<a name="line.340"></a>
+<span class="sourceLineNo">341</span>      namespaceQuotaManager.checkQuotaToSplitRegion(hri);<a name="line.341"></a>
+<span class="sourceLineNo">342</span>    }<a name="line.342"></a>
+<span class="sourceLineNo">343</span>  }<a name="line.343"></a>
+<span class="sourceLineNo">344</span><a name="line.344"></a>
+<span class="sourceLineNo">345</span>  /**<a name="line.345"></a>
+<span class="sourceLineNo">346</span>   * Remove table from namespace quota.<a name="line.346"></a>
+<span class="sourceLineNo">347</span>   *<a name="line.347"></a>
+<span class="sourceLineNo">348</span>   * @param tName - The table name to update quota usage.<a name="line.348"></a>
+<span class="sourceLineNo">349</span>   * @throws IOException Signals that an I/O exception has occurred.<a name="line.349"></a>
+<span class="sourceLineNo">350</span>   */<a name="line.350"></a>
+<span class="sourceLineNo">351</span>  public void removeTableFromNamespaceQuota(TableName tName) throws IOException {<a name="line.351"></a>
+<span class="sourceLineNo">352</span>    if (enabled) {<a name="line.352"></a>
+<span class="sourceLineNo">353</span>      namespaceQuotaManager.removeFromNamespaceUsage(tName);<a name="line.353"></a>
+<span class="sourceLineNo">354</span>    }<a name="line.354"></a>
+<span class="sourceLineNo">355</span>  }<a name="line.355"></a>
+<span class="sourceLineNo">356</span><a name="line.356"></a>
+<span class="sourceLineNo">357</span>  public NamespaceAuditor getNamespaceQuotaManager() {<a name="line.357"></a>
+<span class="sourceLineNo">358</span>    return this.namespaceQuotaManager;<a name="line.358"></a>
+<span class="sourceLineNo">359</span>  }<a name="line.359"></a>
+<span class="sourceLineNo">360</span><a name="line.360"></a>
+<span class="sourceLineNo">361</span>  private static interface SetQuotaOperations {<a name="line.361"></a>
+<span class="sourceLineNo">362</span>    Quotas fetch() throws IOException;<a name="line.362"></a>
+<span class="sourceLineNo">363</span>    void delete() throws IOException;<a name="line.363"></a>
+<span class="sourceLineNo">364</span>    void update(final Quotas quotas) throws IOException;<a name="line.364"></a>
+<span class="sourceLineNo">365</span>    void preApply(final Quotas quotas) throws IOException;<a name="line.365"></a>
+<span class="sourceLineNo">366</span>    void postApply(final Quotas quotas) throws IOException;<a name="line.366"></a>
+<span class="sourceLineNo">367</span>  }<a name="line.367"></a>
+<span class="sourceLineNo">368</span><a name="line.368"></a>
+<span class="sourceLineNo">369</span>  /* ==========================================================================<a name="line.369"></a>
+<span class="sourceLineNo">370</span>   *  Helpers to apply changes to the quotas<a name="line.370"></a>
+<span class="sourceLineNo">371</span>   */<a name="line.371"></a>
+<span class="sourceLineNo">372</span>  private void applyThrottle(final Quotas.Builder quotas, final ThrottleRequest req)<a name="line.372"></a>
+<span class="sourceLineNo">373</span>      throws IOException {<a name="line.373"></a>
+<span class="sourceLineNo">374</span>    Throttle.Builder throttle;<a name="line.374"></a>
+<span class="sourceLineNo">375</span><a name="line.375"></a>
+<span class="sourceLineNo">376</span>    if (req.hasType() &amp;&amp; (req.hasTimedQuota() || quotas.hasThrottle())) {<a name="line.376"></a>
+<span class="sourceLineNo">377</span>      // Validate timed quota if present<a name="line.377"></a>
+<span class="sourceLineNo">378</span>      if (req.hasTimedQuota()) validateTimedQuota(req.getTimedQuota());<a name="line.378"></a>
+<span class="sourceLineNo">379</span><a name="line.379"></a>
+<span class="sourceLineNo">380</span>      // apply the new settings<a name="line.380"></a>
+<span class="sourceLineNo">381</span>      throttle = quotas.hasThrottle() ? quotas.getThrottle().toBuilder() : Throttle.newBuilder();<a name="line.381"></a>
+<span class="sourceLineNo">382</span><a name="line.382"></a>
+<span class="sourceLineNo">383</span>      switch (req.getType()) {<a name="line.383"></a>
+<span class="sourceLineNo">384</span>        case REQUEST_NUMBER:<a name="line.384"></a>
+<span class="sourceLineNo">385</span>          if (req.hasTimedQuota()) {<a name="line.385"></a>
+<span class="sourceLineNo">386</span>            throttle.setReqNum(req.getTimedQuota());<a name="line.386"></a>
+<span class="sourceLineNo">387</span>          } else {<a name="line.387"></a>
+<span class="sourceLineNo">388</span>            throttle.clearReqNum();<a name="line.388"></a>
+<span class="sourceLineNo">389</span>          }<a name="line.389"></a>
+<span class="sourceLineNo">390</span>          break;<a name="line.390"></a>
+<span class="sourceLineNo">391</span>        case REQUEST_SIZE:<a name="line.391"></a>
+<span class="sourceLineNo">392</span>          if (req.hasTimedQuota()) {<a name="line.392"></a>
+<span class="sourceLineNo">393</span>            throttle.setReqSize(req.getTimedQuota());<a name="line.393"></a>
+<span class="sourceLineNo">394</span>          } else {<a name="line.394"></a>
+<span class="sourceLineNo">395</span>            throttle.clearReqSize();<a name="line.395"></a>
+<span class="sourceLineNo">396</span>          }<a name="line.396"></a>
+<span class="sourceLineNo">397</span>          break;<a name="line.397"></a>
+<span class="sourceLineNo">398</span>        case WRITE_NUMBER:<a name="line.398"></a>
+<span class="sourceLineNo">399</span>          if (req.hasTimedQuota()) {<a name="line.399"></a>
+<span class="sourceLineNo">400</span>            throttle.setWriteNum(req.getTimedQuota());<a name="line.400"></a>
+<span class="sourceLineNo">401</span>          } else {<a name="line.401"></a>
+<span class="sourceLineNo">402</span>            throttle.clearWriteNum();<a name="line.402"></a>
+<span class="sourceLineNo">403</span>          }<a name="line.403"></a>
+<span class="sourceLineNo">404</span>          break;<a name="line.404"></a>
+<span class="sourceLineNo">405</span>        case WRITE_SIZE:<a name="line.405"></a>
+<span class="sourceLineNo">406</span>          if (req.hasTimedQuota()) {<a name="line.406"></a>
+<span class="sourceLineNo">407</span>            throttle.setWriteSize(req.getTimedQuota());<a name="line.407"></a>
+<span class="sourceLineNo">408</span>          } else {<a name="line.408"></a>
+<span class="sourceLineNo">409</span>            throttle.clearWriteSize();<a name="line.409"></a>
+<span class="sourceLineNo">410</span>          }<a name="line.410"></a>
+<span class="sourceLineNo">411</span>          break;<a name="line.411"></a>
+<span class="sourceLineNo">412</span>        case READ_NUMBER:<a name="line.412"></a>
+<span class="sourceLineNo">413</span>          if (req.hasTimedQuota()) {<a name="line.413"></a>
+<span class="sourceLineNo">414</span>            throttle.setReadNum(req.getTimedQuota());<a name="line.414"></a>
+<span class="sourceLineNo">415</span>          } else {<a name="line.415"></a>
+<span class="sourceLineNo">416</span>            throttle.clearReqNum();<a name="line.416"></a>
+<span class="sourceLineNo">417</span>          }<a name="line.417"></a>
+<span class="sourceLineNo">418</span>          break;<a name="line.418"></a>
+<span class="sourceLineNo">419</span>        case READ_SIZE:<a name="line.419"></a>
+<span class="sourceLineNo">420</span>          if (req.hasTimedQuota()) {<a name="line.420"></a>
+<span class="sourceLineNo">421</span>            throttle.setReadSize(req.getTimedQuota());<a name="line.421"></a>
+<span class="sourceLineNo">422</span>          } else {<a name="line.422"></a>
+<span class="sourceLineNo">423</span>            throttle.clearReadSize();<a name="line.423"></a>
+<span class="sourceLineNo">424</span>          }<a name="line.424"></a>
+<span class="sourceLineNo">425</span>          break;<a name="line.425"></a>
+<span class="sourceLineNo">426</span>      }<a name="line.426"></a>
+<span class="sourceLineNo">427</span>      quotas.setThrottle(throttle.build());<a name="line.427"></a>
+<span class="sourceLineNo">428</span>    } else {<a name="line.428"></a>
+<span class="sourceLineNo">429</span>      quotas.clearThrottle();<a name="line.429"></a>
+<span class="sourceLineNo">430</span>    }<a name="line.430"></a>
+<span class="sourceLineNo">431</span>  }<a name="line.431"></a>
+<span class="sourceLineNo">432</span><a name="line.432"></a>
+<span class="sourceLineNo">433</span>  private void applyBypassGlobals(final Quotas.Builder quotas, boolean bypassGlobals) {<a name="line.433"></a>
+<span class="sourceLineNo">434</span>    if (bypassGlobals) {<a name="line.434"></a>
+<span class="sourceLineNo">435</span>      quotas.setBypassGlobals(bypassGlobals);<a name="line.435"></a>
+<span class="sourceLineNo">436</span>    } else {<a name="line.436"></a>
+<span class="sourceLineNo">437</span>      quotas.clearBypassGlobals();<a name="line.437"></a>
+<span class="sourceLineNo">438</span>    }<a name="line.438"></a>
+<span class="sourceLineNo">439</span>  }<a name="line.439"></a>
+<span class="sourceLineNo">440</span><a name="line.440"></a>
+<span class="sourceLineNo">441</span>  private void validateTimedQuota(final TimedQuota timedQuota) throws IOException {<a name="line.441"></a>
+<span class="sourceLineNo">442</span>    if (timedQuota.getSoftLimit() &lt; 1) {<a name="line.442"></a>
+<span class="sourceLineNo">443</span>      throw new DoNotRetryIOException(new UnsupportedOperationException(<a name="line.443"></a>
+<span class="sourceLineNo">444</span>          "The throttle limit must be greater then 0, got " + timedQuota.getSoftLimit()));<a name="line.444"></a>
+<span class="sourceLineNo">445</span>    }<a name="line.445"></a>
+<span class="sourceLineNo">446</span>  }<a name="line.446"></a>
+<span class="sourceLineNo">447</span><a name="line.447"></a>
+<span class="sourceLineNo">448</span>  /* ==========================================================================<a name="line.448"></a>
+<span class="sourceLineNo">449</span>   *  Helpers<a name="line.449"></a>
+<span class="sourceLineNo">450</span>   */<a name="line.450"></a>
+<span class="sourceLineNo">451</span><a name="line.451"></a>
+<span class="sourceLineNo">452</span>  private void checkQuotaSupport() throws IOException {<a name="line.452"></a>
+<span class="sourceLineNo">453</span>    if (!enabled) {<a name="line.453"></a>
+<span class="sourceLineNo">454</span>      throw new DoNotRetryIOException(<a name="line.454"></a>
+<span class="sourceLineNo">455</span>        new UnsupportedOperationException("quota support disabled"));<a name="line.455"></a>
+<span class="sourceLineNo">456</span>    }<a name="line.456"></a>
+<span class="sourceLineNo">457</span>  }<a name="line.457"></a>
+<span class="sourceLineNo">458</span><a name="line.458"></a>
+<span class="sourceLineNo">459</span>  private void createQuotaTable() throws IOException {<a name="line.459"></a>
+<span class="sourceLineNo">460</span>    HRegionInfo newRegions[] = new HRegionInfo[] {<a name="line.460"></a>
+<span class="sourceLineNo">461</span>      new HRegionInfo(QuotaUtil.QUOTA_TABLE_NAME)<a name="line.461"></a>
+<span class="sourceLineNo">462</span>    };<a name="line.462"></a>
 <span class="sourceLineNo">463</span><a name="line.463"></a>
-<span class="sourceLineNo">464</span>    public void lock(final T name) throws InterruptedException {<a name="line.464"></a>
-<span class="sourceLineNo">465</span>      synchronized (locks) {<a name="line.465"></a>
-<span class="sourceLineNo">466</span>        while (locks.contains(name)) {<a name="line.466"></a>
-<span class="sourceLineNo">467</span>          locks.wait();<a name="line.467"></a>
-<span class="sourceLineNo">468</span>        }<a name="line.468"></a>
-<span class="sourceLineNo">469</span>        locks.add(name);<a name="line.469"></a>
-<span class="sourceLineNo">470</span>      }<a name="line.470"></a>
-<span class="sourceLineNo">471</span>    }<a name="line.471"></a>
-<span class="sourceLineNo">472</span><a name="line.472"></a>
-<span class="sourceLineNo">473</span>    public void unlock(final T name) {<a name="line.473"></a>
-<span class="sourceLineNo">474</span>      synchronized (locks) {<a name="line.474"></a>
-<span class="sourceLineNo">475</span>        locks.remove(name);<a name="line.475"></a>
-<span class="sourceLineNo">476</span>        locks.notifyAll();<a name="line.476"></a>
-<span class="sourceLineNo">477</span>      }<a name="line.477"></a>
-<span class="sourceLineNo">478</span>    }<a name="line.478"></a>
-<span class="sourceLineNo">479</span>  }<a name="line.479"></a>
-<span class="sourceLineNo">480</span><a name="line.480"></a>
-<span class="sourceLineNo">481</span>  @Override<a name="line.481"></a>
-<span class="sourceLineNo">482</span>  public void onRegionSplitReverted(HRegionInfo hri) throws IOException {<a name="line.482"></a>
-<span class="sourceLineNo">483</span>    if (enabled) {<a name="line.483"></a>
-<span class="sourceLineNo">484</span>      this.namespaceQuotaManager.removeRegionFromNamespaceUsage(hri);<a name="line.484"></a>
-<span class="sourceLineNo">485</span>    }<a name="line.485"></a>
-<span class="sourceLineNo">486</span>  }<a name="line.486"></a>
-<span class="sourceLineNo">487</span>}<a name="line.487"></a>
-<span class="sourceLineNo">488</span><a name="line.488"></a>
+<span class="sourceLineNo">464</span>    masterServices.getMasterProcedureExecutor()<a name="line.464"></a>
+<span class="sourceLineNo">465</span>      .submitProcedure(new CreateTableProcedure(<a name="line.465"></a>
+<span class="sourceLineNo">466</span>          masterServices.getMasterProcedureExecutor().getEnvironment(),<a name="line.466"></a>
+<span class="sourceLineNo">467</span>          QuotaUtil.QUOTA_TABLE_DESC,<a name="line.467"></a>
+<span class="sourceLineNo">468</span>          newRegions));<a name="line.468"></a>
+<span class="sourceLineNo">469</span>  }<a name="line.469"></a>
+<span class="sourceLineNo">470</span><a name="line.470"></a>
+<span class="sourceLineNo">471</span>  private static class NamedLock&lt;T&gt; {<a name="line.471"></a>
+<span class="sourceLineNo">472</span>    private HashSet&lt;T&gt; locks = new HashSet&lt;T&gt;();<a name="line.472"></a>
+<span class="sourceLineNo">473</span><a name="line.473"></a>
+<span class="sourceLineNo">474</span>    public void lock(final T name) throws InterruptedException {<a name="line.474"></a>
+<span class="sourceLineNo">475</span>      synchronized (locks) {<a name="line.475"></a>
+<span class="sourceLineNo">476</span>        while (locks.contains(name)) {<a name="line.476"></a>
+<span class="sourceLineNo">477</span>          locks.wait();<a name="line.477"></a>
+<span class="sourceLineNo">478</span>        }<a name="line.478"></a>
+<span class="sourceLineNo">479</span>        locks.add(name);<a name="line.479"></a>
+<span class="sourceLineNo">480</span>      }<a name="line.480"></a>
+<span class="sourceLineNo">481</span>    }<a name="line.481"></a>
+<span class="sourceLineNo">482</span><a name="line.482"></a>
+<span class="sourceLineNo">483</span>    public void unlock(final T name) {<a name="line.483"></a>
+<span class="sourceLineNo">484</span>      synchronized (locks) {<a name="line.484"></a>
+<span class="sourceLineNo">485</span>        locks.remove(name);<a name="line.485"></a>
+<span class="sourceLineNo">486</span>        locks.notifyAll();<a name="line.486"></a>
+<span class="sourceLineNo">487</span>      }<a name="line.487"></a>
+<span class="sourceLineNo">488</span>    }<a name="line.488"></a>
+<span class="sourceLineNo">489</span>  }<a name="line.489"></a>
+<span class="sourceLineNo">490</span><a name="line.490"></a>
+<span class="sourceLineNo">491</span>  @Override<a name="line.491"></a>
+<span class="sourceLineNo">492</span>  public void onRegionSplitReverted(HRegionInfo hri) throws IOException {<a name="line.492"></a>
+<span class="sourceLineNo">493</span>    if (enabled) {<a name="line.493"></a>
+<span class="sourceLineNo">494</span>      this.namespaceQuotaManager.removeRegionFromNamespaceUsage(hri);<a name="line.494"></a>
+<span class="sourceLineNo">495</span>    }<a name="line.495"></a>
+<span class="sourceLineNo">496</span>  }<a name="line.496"></a>
+<span class="sourceLineNo">497</span>}<a name="line.497"></a>
+<span class="sourceLineNo">498</span><a name="line.498"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/a4cb7eaa/devapidocs/src-html/org/apache/hadoop/hbase/quotas/MasterQuotaManager.SetQuotaOperations.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/quotas/MasterQuotaManager.SetQuotaOperations.html b/devapidocs/src-html/org/apache/hadoop/hbase/quotas/MasterQuotaManager.SetQuotaOperations.html
index 6b044ba..e698840 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/quotas/MasterQuotaManager.SetQuotaOperations.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/quotas/MasterQuotaManager.SetQuotaOperations.html
@@ -328,172 +328,182 @@
 <span class="sourceLineNo">320</span>    }<a name="line.320"></a>
 <span class="sourceLineNo">321</span>  }<a name="line.321"></a>
 <span class="sourceLineNo">322</span><a name="line.322"></a>
-<span class="sourceLineNo">323</span>  public void onRegionMerged(HRegionInfo hri) throws IOException {<a name="line.323"></a>
-<span class="sourceLineNo">324</span>    if (enabled) {<a name="line.324"></a>
-<span class="sourceLineNo">325</span>      namespaceQuotaManager.updateQuotaForRegionMerge(hri);<a name="line.325"></a>
-<span class="sourceLineNo">326</span>    }<a name="line.326"></a>
-<span class="sourceLineNo">327</span>  }<a name="line.327"></a>
-<span class="sourceLineNo">328</span><a name="line.328"></a>
-<span class="sourceLineNo">329</span>  public void onRegionSplit(HRegionInfo hri) throws IOException {<a name="line.329"></a>
-<span class="sourceLineNo">330</span>    if (enabled) {<a name="line.330"></a>
-<span class="sourceLineNo">331</span>      namespaceQuotaManager.checkQuotaToSplitRegion(hri);<a name="line.331"></a>
-<span class="sourceLineNo">332</span>    }<a name="line.332"></a>
-<span class="sourceLineNo">333</span>  }<a name="line.333"></a>
-<span class="sourceLineNo">334</span><a name="line.334"></a>
-<span class="sourceLineNo">335</span>  /**<a name="line.335"></a>
-<span class="sourceLineNo">336</span>   * Remove table from namespace quota.<a name="line.336"></a>
-<span class="sourceLineNo">337</span>   *<a name="line.337"></a>
-<span class="sourceLineNo">338</span>   * @param tName - The table name to update quota usage.<a name="line.338"></a>
-<span class="sourceLineNo">339</span>   * @throws IOException Signals that an I/O exception has occurred.<a name="line.339"></a>
-<span class="sourceLineNo">340</span>   */<a name="line.340"></a>
-<span class="sourceLineNo">341</span>  public void removeTableFromNamespaceQuota(TableName tName) throws IOException {<a name="line.341"></a>
-<span class="sourceLineNo">342</span>    if (enabled) {<a name="line.342"></a>
-<span class="sourceLineNo">343</span>      namespaceQuotaManager.removeFromNamespaceUsage(tName);<a name="line.343"></a>
-<span class="sourceLineNo">344</span>    }<a name="line.344"></a>
-<span class="sourceLineNo">345</span>  }<a name="line.345"></a>
-<span class="sourceLineNo">346</span><a name="line.346"></a>
-<span class="sourceLineNo">347</span>  public NamespaceAuditor getNamespaceQuotaManager() {<a name="line.347"></a>
-<span class="sourceLineNo">348</span>    return this.namespaceQuotaManager;<a name="line.348"></a>
-<span class="sourceLineNo">349</span>  }<a name="line.349"></a>
-<span class="sourceLineNo">350</span><a name="line.350"></a>
-<span class="sourceLineNo">351</span>  private static interface SetQuotaOperations {<a name="line.351"></a>
-<span class="sourceLineNo">352</span>    Quotas fetch() throws IOException;<a name="line.352"></a>
-<span class="sourceLineNo">353</span>    void delete() throws IOException;<a name="line.353"></a>
-<span class="sourceLineNo">354</span>    void update(final Quotas quotas) throws IOException;<a name="line.354"></a>
-<span class="sourceLineNo">355</span>    void preApply(final Quotas quotas) throws IOException;<a name="line.355"></a>
-<span class="sourceLineNo">356</span>    void postApply(final Quotas quotas) throws IOException;<a name="line.356"></a>
-<span class="sourceLineNo">357</span>  }<a name="line.357"></a>
-<span class="sourceLineNo">358</span><a name="line.358"></a>
-<span class="sourceLineNo">359</span>  /* ==========================================================================<a name="line.359"></a>
-<span class="sourceLineNo">360</span>   *  Helpers to apply changes to the quotas<a name="line.360"></a>
-<span class="sourceLineNo">361</span>   */<a name="line.361"></a>
-<span class="sourceLineNo">362</span>  private void applyThrottle(final Quotas.Builder quotas, final ThrottleRequest req)<a name="line.362"></a>
-<span class="sourceLineNo">363</span>      throws IOException {<a name="line.363"></a>
-<span class="sourceLineNo">364</span>    Throttle.Builder throttle;<a name="line.364"></a>
-<span class="sourceLineNo">365</span><a name="line.365"></a>
-<span class="sourceLineNo">366</span>    if (req.hasType() &amp;&amp; (req.hasTimedQuota() || quotas.hasThrottle())) {<a name="line.366"></a>
-<span class="sourceLineNo">367</span>      // Validate timed quota if present<a name="line.367"></a>
-<span class="sourceLineNo">368</span>      if (req.hasTimedQuota()) validateTimedQuota(req.getTimedQuota());<a name="line.368"></a>
-<span class="sourceLineNo">369</span><a name="line.369"></a>
-<span class="sourceLineNo">370</span>      // apply the new settings<a name="line.370"></a>
-<span class="sourceLineNo">371</span>      throttle = quotas.hasThrottle() ? quotas.getThrottle().toBuilder() : Throttle.newBuilder();<a name="line.371"></a>
-<span class="sourceLineNo">372</span><a name="line.372"></a>
-<span class="sourceLineNo">373</span>      switch (req.getType()) {<a name="line.373"></a>
-<span class="sourceLineNo">374</span>        case REQUEST_NUMBER:<a name="line.374"></a>
-<span class="sourceLineNo">375</span>          if (req.hasTimedQuota()) {<a name="line.375"></a>
-<span class="sourceLineNo">376</span>            throttle.setReqNum(req.getTimedQuota());<a name="line.376"></a>
-<span class="sourceLineNo">377</span>          } else {<a name="line.377"></a>
-<span class="sourceLineNo">378</span>            throttle.clearReqNum();<a name="line.378"></a>
-<span class="sourceLineNo">379</span>          }<a name="line.379"></a>
-<span class="sourceLineNo">380</span>          break;<a name="line.380"></a>
-<span class="sourceLineNo">381</span>        case REQUEST_SIZE:<a name="line.381"></a>
-<span class="sourceLineNo">382</span>          if (req.hasTimedQuota()) {<a name="line.382"></a>
-<span class="sourceLineNo">383</span>            throttle.setReqSize(req.getTimedQuota());<a name="line.383"></a>
-<span class="sourceLineNo">384</span>          } else {<a name="line.384"></a>
-<span class="sourceLineNo">385</span>            throttle.clearReqSize();<a name="line.385"></a>
-<span class="sourceLineNo">386</span>          }<a name="line.386"></a>
-<span class="sourceLineNo">387</span>          break;<a name="line.387"></a>
-<span class="sourceLineNo">388</span>        case WRITE_NUMBER:<a name="line.388"></a>
-<span class="sourceLineNo">389</span>          if (req.hasTimedQuota()) {<a name="line.389"></a>
-<span class="sourceLineNo">390</span>            throttle.setWriteNum(req.getTimedQuota());<a name="line.390"></a>
-<span class="sourceLineNo">391</span>          } else {<a name="line.391"></a>
-<span class="sourceLineNo">392</span>            throttle.clearWriteNum();<a name="line.392"></a>
-<span class="sourceLineNo">393</span>          }<a name="line.393"></a>
-<span class="sourceLineNo">394</span>          break;<a name="line.394"></a>
-<span class="sourceLineNo">395</span>        case WRITE_SIZE:<a name="line.395"></a>
-<span class="sourceLineNo">396</span>          if (req.hasTimedQuota()) {<a name="line.396"></a>
-<span class="sourceLineNo">397</span>            throttle.setWriteSize(req.getTimedQuota());<a name="line.397"></a>
-<span class="sourceLineNo">398</span>          } else {<a name="line.398"></a>
-<span class="sourceLineNo">399</span>            throttle.clearWriteSize();<a name="line.399"></a>
-<span class="sourceLineNo">400</span>          }<a name="line.400"></a>
-<span class="sourceLineNo">401</span>          break;<a name="line.401"></a>
-<span class="sourceLineNo">402</span>        case READ_NUMBER:<a name="line.402"></a>
-<span class="sourceLineNo">403</span>          if (req.hasTimedQuota()) {<a name="line.403"></a>
-<span class="sourceLineNo">404</span>            throttle.setReadNum(req.getTimedQuota());<a name="line.404"></a>
-<span class="sourceLineNo">405</span>          } else {<a name="line.405"></a>
-<span class="sourceLineNo">406</span>            throttle.clearReqNum();<a name="line.406"></a>
-<span class="sourceLineNo">407</span>          }<a name="line.407"></a>
-<span class="sourceLineNo">408</span>          break;<a name="line.408"></a>
-<span class="sourceLineNo">409</span>        case READ_SIZE:<a name="line.409"></a>
-<span class="sourceLineNo">410</span>          if (req.hasTimedQuota()) {<a name="line.410"></a>
-<span class="sourceLineNo">411</span>            throttle.setReadSize(req.getTimedQuota());<a name="line.411"></a>
-<span class="sourceLineNo">412</span>          } else {<a name="line.412"></a>
-<span class="sourceLineNo">413</span>            throttle.clearReadSize();<a name="line.413"></a>
-<span class="sourceLineNo">414</span>          }<a name="line.414"></a>
-<span class="sourceLineNo">415</span>          break;<a name="line.415"></a>
-<span class="sourceLineNo">416</span>      }<a name="line.416"></a>
-<span class="sourceLineNo">417</span>      quotas.setThrottle(throttle.build());<a name="line.417"></a>
-<span class="sourceLineNo">418</span>    } else {<a name="line.418"></a>
-<span class="sourceLineNo">419</span>      quotas.clearThrottle();<a name="line.419"></a>
-<span class="sourceLineNo">420</span>    }<a name="line.420"></a>
-<span class="sourceLineNo">421</span>  }<a name="line.421"></a>
-<span class="sourceLineNo">422</span><a name="line.422"></a>
-<span class="sourceLineNo">423</span>  private void applyBypassGlobals(final Quotas.Builder quotas, boolean bypassGlobals) {<a name="line.423"></a>
-<span class="sourceLineNo">424</span>    if (bypassGlobals) {<a name="line.424"></a>
-<span class="sourceLineNo">425</span>      quotas.setBypassGlobals(bypassGlobals);<a name="line.425"></a>
-<span class="sourceLineNo">426</span>    } else {<a name="line.426"></a>
-<span class="sourceLineNo">427</span>      quotas.clearBypassGlobals();<a name="line.427"></a>
-<span class="sourceLineNo">428</span>    }<a name="line.428"></a>
-<span class="sourceLineNo">429</span>  }<a name="line.429"></a>
-<span class="sourceLineNo">430</span><a name="line.430"></a>
-<span class="sourceLineNo">431</span>  private void validateTimedQuota(final TimedQuota timedQuota) throws IOException {<a name="line.431"></a>
-<span class="sourceLineNo">432</span>    if (timedQuota.getSoftLimit() &lt; 1) {<a name="line.432"></a>
-<span class="sourceLineNo">433</span>      throw new DoNotRetryIOException(new UnsupportedOperationException(<a name="line.433"></a>
-<span class="sourceLineNo">434</span>          "The throttle limit must be greater then 0, got " + timedQuota.getSoftLimit()));<a name="line.434"></a>
-<span class="sourceLineNo">435</span>    }<a name="line.435"></a>
-<span class="sourceLineNo">436</span>  }<a name="line.436"></a>
-<span class="sourceLineNo">437</span><a name="line.437"></a>
-<span class="sourceLineNo">438</span>  /* ==========================================================================<a name="line.438"></a>
-<span class="sourceLineNo">439</span>   *  Helpers<a name="line.439"></a>
-<span class="sourceLineNo">440</span>   */<a name="line.440"></a>
-<span class="sourceLineNo">441</span><a name="line.441"></a>
-<span class="sourceLineNo">442</span>  private void checkQuotaSupport() throws IOException {<a name="line.442"></a>
-<span class="sourceLineNo">443</span>    if (!enabled) {<a name="line.443"></a>
-<span class="sourceLineNo">444</span>      throw new DoNotRetryIOException(<a name="line.444"></a>
-<span class="sourceLineNo">445</span>        new UnsupportedOperationException("quota support disabled"));<a name="line.445"></a>
-<span class="sourceLineNo">446</span>    }<a name="line.446"></a>
-<span class="sourceLineNo">447</span>  }<a name="line.447"></a>
-<span class="sourceLineNo">448</span><a name="line.448"></a>
-<span class="sourceLineNo">449</span>  private void createQuotaTable() throws IOException {<a name="line.449"></a>
-<span class="sourceLineNo">450</span>    HRegionInfo newRegions[] = new HRegionInfo[] {<a name="line.450"></a>
-<span class="sourceLineNo">451</span>      new HRegionInfo(QuotaUtil.QUOTA_TABLE_NAME)<a name="line.451"></a>
-<span class="sourceLineNo">452</span>    };<a name="line.452"></a>
-<span class="sourceLineNo">453</span><a name="line.453"></a>
-<span class="sourceLineNo">454</span>    masterServices.getMasterProcedureExecutor()<a name="line.454"></a>
-<span class="sourceLineNo">455</span>      .submitProcedure(new CreateTableProcedure(<a name="line.455"></a>
-<span class="sourceLineNo">456</span>          masterServices.getMasterProcedureExecutor().getEnvironment(),<a name="line.456"></a>
-<span class="sourceLineNo">457</span>          QuotaUtil.QUOTA_TABLE_DESC,<a name="line.457"></a>
-<span class="sourceLineNo">458</span>          newRegions));<a name="line.458"></a>
-<span class="sourceLineNo">459</span>  }<a name="line.459"></a>
-<span class="sourceLineNo">460</span><a name="line.460"></a>
-<span class="sourceLineNo">461</span>  private static class NamedLock&lt;T&gt; {<a name="line.461"></a>
-<span class="sourceLineNo">462</span>    private HashSet&lt;T&gt; locks = new HashSet&lt;T&gt;();<a name="line.462"></a>
+<span class="sourceLineNo">323</span>  /**<a name="line.323"></a>
+<span class="sourceLineNo">324</span>   * @return cached region count, or -1 if quota manager is disabled or table status not found<a name="line.324"></a>
+<span class="sourceLineNo">325</span>  */<a name="line.325"></a>
+<span class="sourceLineNo">326</span>  public int getRegionCountOfTable(TableName tName) throws IOException {<a name="line.326"></a>
+<span class="sourceLineNo">327</span>    if (enabled) {<a name="line.327"></a>
+<span class="sourceLineNo">328</span>      return namespaceQuotaManager.getRegionCountOfTable(tName);<a name="line.328"></a>
+<span class="sourceLineNo">329</span>    }<a name="line.329"></a>
+<span class="sourceLineNo">330</span>    return -1;<a name="line.330"></a>
+<span class="sourceLineNo">331</span>  }<a name="line.331"></a>
+<span class="sourceLineNo">332</span><a name="line.332"></a>
+<span class="sourceLineNo">333</span>  public void onRegionMerged(HRegionInfo hri) throws IOException {<a name="line.333"></a>
+<span class="sourceLineNo">334</span>    if (enabled) {<a name="line.334"></a>
+<span class="sourceLineNo">335</span>      namespaceQuotaManager.updateQuotaForRegionMerge(hri);<a name="line.335"></a>
+<span class="sourceLineNo">336</span>    }<a name="line.336"></a>
+<span class="sourceLineNo">337</span>  }<a name="line.337"></a>
+<span class="sourceLineNo">338</span><a name="line.338"></a>
+<span class="sourceLineNo">339</span>  public void onRegionSplit(HRegionInfo hri) throws IOException {<a name="line.339"></a>
+<span class="sourceLineNo">340</span>    if (enabled) {<a name="line.340"></a>
+<span class="sourceLineNo">341</span>      namespaceQuotaManager.checkQuotaToSplitRegion(hri);<a name="line.341"></a>
+<span class="sourceLineNo">342</span>    }<a name="line.342"></a>
+<span class="sourceLineNo">343</span>  }<a name="line.343"></a>
+<span class="sourceLineNo">344</span><a name="line.344"></a>
+<span class="sourceLineNo">345</span>  /**<a name="line.345"></a>
+<span class="sourceLineNo">346</span>   * Remove table from namespace quota.<a name="line.346"></a>
+<span class="sourceLineNo">347</span>   *<a name="line.347"></a>
+<span class="sourceLineNo">348</span>   * @param tName - The table name to update quota usage.<a name="line.348"></a>
+<span class="sourceLineNo">349</span>   * @throws IOException Signals that an I/O exception has occurred.<a name="line.349"></a>
+<span class="sourceLineNo">350</span>   */<a name="line.350"></a>
+<span class="sourceLineNo">351</span>  public void removeTableFromNamespaceQuota(TableName tName) throws IOException {<a name="line.351"></a>
+<span class="sourceLineNo">352</span>    if (enabled) {<a name="line.352"></a>
+<span class="sourceLineNo">353</span>      namespaceQuotaManager.removeFromNamespaceUsage(tName);<a name="line.353"></a>
+<span class="sourceLineNo">354</span>    }<a name="line.354"></a>
+<span class="sourceLineNo">355</span>  }<a name="line.355"></a>
+<span class="sourceLineNo">356</span><a name="line.356"></a>
+<span class="sourceLineNo">357</span>  public NamespaceAuditor getNamespaceQuotaManager() {<a name="line.357"></a>
+<span class="sourceLineNo">358</span>    return this.namespaceQuotaManager;<a name="line.358"></a>
+<span class="sourceLineNo">359</span>  }<a name="line.359"></a>
+<span class="sourceLineNo">360</span><a name="line.360"></a>
+<span class="sourceLineNo">361</span>  private static interface SetQuotaOperations {<a name="line.361"></a>
+<span class="sourceLineNo">362</span>    Quotas fetch() throws IOException;<a name="line.362"></a>
+<span class="sourceLineNo">363</span>    void delete() throws IOException;<a name="line.363"></a>
+<span class="sourceLineNo">364</span>    void update(final Quotas quotas) throws IOException;<a name="line.364"></a>
+<span class="sourceLineNo">365</span>    void preApply(final Quotas quotas) throws IOException;<a name="line.365"></a>
+<span class="sourceLineNo">366</span>    void postApply(final Quotas quotas) throws IOException;<a name="line.366"></a>
+<span class="sourceLineNo">367</span>  }<a name="line.367"></a>
+<span class="sourceLineNo">368</span><a name="line.368"></a>
+<span class="sourceLineNo">369</span>  /* ==========================================================================<a name="line.369"></a>
+<span class="sourceLineNo">370</span>   *  Helpers to apply changes to the quotas<a name="line.370"></a>
+<span class="sourceLineNo">371</span>   */<a name="line.371"></a>
+<span class="sourceLineNo">372</span>  private void applyThrottle(final Quotas.Builder quotas, final ThrottleRequest req)<a name="line.372"></a>
+<span class="sourceLineNo">373</span>      throws IOException {<a name="line.373"></a>
+<span class="sourceLineNo">374</span>    Throttle.Builder throttle;<a name="line.374"></a>
+<span class="sourceLineNo">375</span><a name="line.375"></a>
+<span class="sourceLineNo">376</span>    if (req.hasType() &amp;&amp; (req.hasTimedQuota() || quotas.hasThrottle())) {<a name="line.376"></a>
+<span class="sourceLineNo">377</span>      // Validate timed quota if present<a name="line.377"></a>
+<span class="sourceLineNo">378</span>      if (req.hasTimedQuota()) validateTimedQuota(req.getTimedQuota());<a name="line.378"></a>
+<span class="sourceLineNo">379</span><a name="line.379"></a>
+<span class="sourceLineNo">380</span>      // apply the new settings<a name="line.380"></a>
+<span class="sourceLineNo">381</span>      throttle = quotas.hasThrottle() ? quotas.getThrottle().toBuilder() : Throttle.newBuilder();<a name="line.381"></a>
+<span class="sourceLineNo">382</span><a name="line.382"></a>
+<span class="sourceLineNo">383</span>      switch (req.getType()) {<a name="line.383"></a>
+<span class="sourceLineNo">384</span>        case REQUEST_NUMBER:<a name="line.384"></a>
+<span class="sourceLineNo">385</span>          if (req.hasTimedQuota()) {<a name="line.385"></a>
+<span class="sourceLineNo">386</span>            throttle.setReqNum(req.getTimedQuota());<a name="line.386"></a>
+<span class="sourceLineNo">387</span>          } else {<a name="line.387"></a>
+<span class="sourceLineNo">388</span>            throttle.clearReqNum();<a name="line.388"></a>
+<span class="sourceLineNo">389</span>          }<a name="line.389"></a>
+<span class="sourceLineNo">390</span>          break;<a name="line.390"></a>
+<span class="sourceLineNo">391</span>        case REQUEST_SIZE:<a name="line.391"></a>
+<span class="sourceLineNo">392</span>          if (req.hasTimedQuota()) {<a name="line.392"></a>
+<span class="sourceLineNo">393</span>            throttle.setReqSize(req.getTimedQuota());<a name="line.393"></a>
+<span class="sourceLineNo">394</span>          } else {<a name="line.394"></a>
+<span class="sourceLineNo">395</span>            throttle.clearReqSize();<a name="line.395"></a>
+<span class="sourceLineNo">396</span>          }<a name="line.396"></a>
+<span class="sourceLineNo">397</span>          break;<a name="line.397"></a>
+<span class="sourceLineNo">398</span>        case WRITE_NUMBER:<a name="line.398"></a>
+<span class="sourceLineNo">399</span>          if (req.hasTimedQuota()) {<a name="line.399"></a>
+<span class="sourceLineNo">400</span>            throttle.setWriteNum(req.getTimedQuota());<a name="line.400"></a>
+<span class="sourceLineNo">401</span>          } else {<a name="line.401"></a>
+<span class="sourceLineNo">402</span>            throttle.clearWriteNum();<a name="line.402"></a>
+<span class="sourceLineNo">403</span>          }<a name="line.403"></a>
+<span class="sourceLineNo">404</span>          break;<a name="line.404"></a>
+<span class="sourceLineNo">405</span>        case WRITE_SIZE:<a name="line.405"></a>
+<span class="sourceLineNo">406</span>          if (req.hasTimedQuota()) {<a name="line.406"></a>
+<span class="sourceLineNo">407</span>            throttle.setWriteSize(req.getTimedQuota());<a name="line.407"></a>
+<span class="sourceLineNo">408</span>          } else {<a name="line.408"></a>
+<span class="sourceLineNo">409</span>            throttle.clearWriteSize();<a name="line.409"></a>
+<span class="sourceLineNo">410</span>          }<a name="line.410"></a>
+<span class="sourceLineNo">411</span>          break;<a name="line.411"></a>
+<span class="sourceLineNo">412</span>        case READ_NUMBER:<a name="line.412"></a>
+<span class="sourceLineNo">413</span>          if (req.hasTimedQuota()) {<a name="line.413"></a>
+<span class="sourceLineNo">414</span>            throttle.setReadNum(req.getTimedQuota());<a name="line.414"></a>
+<span class="sourceLineNo">415</span>          } else {<a name="line.415"></a>
+<span class="sourceLineNo">416</span>            throttle.clearReqNum();<a name="line.416"></a>
+<span class="sourceLineNo">417</span>          }<a name="line.417"></a>
+<span class="sourceLineNo">418</span>          break;<a name="line.418"></a>
+<span class="sourceLineNo">419</span>        case READ_SIZE:<a name="line.419"></a>
+<span class="sourceLineNo">420</span>          if (req.hasTimedQuota()) {<a name="line.420"></a>
+<span class="sourceLineNo">421</span>            throttle.setReadSize(req.getTimedQuota());<a name="line.421"></a>
+<span class="sourceLineNo">422</span>          } else {<a name="line.422"></a>
+<span class="sourceLineNo">423</span>            throttle.clearReadSize();<a name="line.423"></a>
+<span class="sourceLineNo">424</span>          }<a name="line.424"></a>
+<span class="sourceLineNo">425</span>          break;<a name="line.425"></a>
+<span class="sourceLineNo">426</span>      }<a name="line.426"></a>
+<span class="sourceLineNo">427</span>      quotas.setThrottle(throttle.build());<a name="line.427"></a>
+<span class="sourceLineNo">428</span>    } else {<a name="line.428"></a>
+<span class="sourceLineNo">429</span>      quotas.clearThrottle();<a name="line.429"></a>
+<span class="sourceLineNo">430</span>    }<a name="line.430"></a>
+<span class="sourceLineNo">431</span>  }<a name="line.431"></a>
+<span class="sourceLineNo">432</span><a name="line.432"></a>
+<span class="sourceLineNo">433</span>  private void applyBypassGlobals(final Quotas.Builder quotas, boolean bypassGlobals) {<a name="line.433"></a>
+<span class="sourceLineNo">434</span>    if (bypassGlobals) {<a name="line.434"></a>
+<span class="sourceLineNo">435</span>      quotas.setBypassGlobals(bypassGlobals);<a name="line.435"></a>
+<span class="sourceLineNo">436</span>    } else {<a name="line.436"></a>
+<span class="sourceLineNo">437</span>      quotas.clearBypassGlobals();<a name="line.437"></a>
+<span class="sourceLineNo">438</span>    }<a name="line.438"></a>
+<span class="sourceLineNo">439</span>  }<a name="line.439"></a>
+<span class="sourceLineNo">440</span><a name="line.440"></a>
+<span class="sourceLineNo">441</span>  private void validateTimedQuota(final TimedQuota timedQuota) throws IOException {<a name="line.441"></a>
+<span class="sourceLineNo">442</span>    if (timedQuota.getSoftLimit() &lt; 1) {<a name="line.442"></a>
+<span class="sourceLineNo">443</span>      throw new DoNotRetryIOException(new UnsupportedOperationException(<a name="line.443"></a>
+<span class="sourceLineNo">444</span>          "The throttle limit must be greater then 0, got " + timedQuota.getSoftLimit()));<a name="line.444"></a>
+<span class="sourceLineNo">445</span>    }<a name="line.445"></a>
+<span class="sourceLineNo">446</span>  }<a name="line.446"></a>
+<span class="sourceLineNo">447</span><a name="line.447"></a>
+<span class="sourceLineNo">448</span>  /* ==========================================================================<a name="line.448"></a>
+<span class="sourceLineNo">449</span>   *  Helpers<a name="line.449"></a>
+<span class="sourceLineNo">450</span>   */<a name="line.450"></a>
+<span class="sourceLineNo">451</span><a name="line.451"></a>
+<span class="sourceLineNo">452</span>  private void checkQuotaSupport() throws IOException {<a name="line.452"></a>
+<span class="sourceLineNo">453</span>    if (!enabled) {<a name="line.453"></a>
+<span class="sourceLineNo">454</span>      throw new DoNotRetryIOException(<a name="line.454"></a>
+<span class="sourceLineNo">455</span>        new UnsupportedOperationException("quota support disabled"));<a name="line.455"></a>
+<span class="sourceLineNo">456</span>    }<a name="line.456"></a>
+<span class="sourceLineNo">457</span>  }<a name="line.457"></a>
+<span class="sourceLineNo">458</span><a name="line.458"></a>
+<span class="sourceLineNo">459</span>  private void createQuotaTable() throws IOException {<a name="line.459"></a>
+<span class="sourceLineNo">460</span>    HRegionInfo newRegions[] = new HRegionInfo[] {<a name="line.460"></a>
+<span class="sourceLineNo">461</span>      new HRegionInfo(QuotaUtil.QUOTA_TABLE_NAME)<a name="line.461"></a>
+<span class="sourceLineNo">462</span>    };<a name="line.462"></a>
 <span class="sourceLineNo">463</span><a name="line.463"></a>
-<span class="sourceLineNo">464</span>    public void lock(final T name) throws InterruptedException {<a name="line.464"></a>
-<span class="sourceLineNo">465</span>      synchronized (locks) {<a name="line.465"></a>
-<span class="sourceLineNo">466</span>        while (locks.contains(name)) {<a name="line.466"></a>
-<span class="sourceLineNo">467</span>          locks.wait();<a name="line.467"></a>
-<span class="sourceLineNo">468</span>        }<a name="line.468"></a>
-<span class="sourceLineNo">469</span>        locks.add(name);<a name="line.469"></a>
-<span class="sourceLineNo">470</span>      }<a name="line.470"></a>
-<span class="sourceLineNo">471</span>    }<a name="line.471"></a>
-<span class="sourceLineNo">472</span><a name="line.472"></a>
-<span class="sourceLineNo">473</span>    public void unlock(final T name) {<a name="line.473"></a>
-<span class="sourceLineNo">474</span>      synchronized (locks) {<a name="line.474"></a>
-<span class="sourceLineNo">475</span>        locks.remove(name);<a name="line.475"></a>
-<span class="sourceLineNo">476</span>        locks.notifyAll();<a name="line.476"></a>
-<span class="sourceLineNo">477</span>      }<a name="line.477"></a>
-<span class="sourceLineNo">478</span>    }<a name="line.478"></a>
-<span class="sourceLineNo">479</span>  }<a name="line.479"></a>
-<span class="sourceLineNo">480</span><a name="line.480"></a>
-<span class="sourceLineNo">481</span>  @Override<a name="line.481"></a>
-<span class="sourceLineNo">482</span>  public void onRegionSplitReverted(HRegionInfo hri) throws IOException {<a name="line.482"></a>
-<span class="sourceLineNo">483</span>    if (enabled) {<a name="line.483"></a>
-<span class="sourceLineNo">484</span>      this.namespaceQuotaManager.removeRegionFromNamespaceUsage(hri);<a name="line.484"></a>
-<span class="sourceLineNo">485</span>    }<a name="line.485"></a>
-<span class="sourceLineNo">486</span>  }<a name="line.486"></a>
-<span class="sourceLineNo">487</span>}<a name="line.487"></a>
-<span class="sourceLineNo">488</span><a name="line.488"></a>
+<span class="sourceLineNo">464</span>    masterServices.getMasterProcedureExecutor()<a name="line.464"></a>
+<span class="sourceLineNo">465</span>      .submitProcedure(new CreateTableProcedure(<a name="line.465"></a>
+<span class="sourceLineNo">466</span>          masterServices.getMasterProcedureExecutor().getEnvironment(),<a name="line.466"></a>
+<span class="sourceLineNo">467</span>          QuotaUtil.QUOTA_TABLE_DESC,<a name="line.467"></a>
+<span class="sourceLineNo">468</span>          newRegions));<a name="line.468"></a>
+<span class="sourceLineNo">469</span>  }<a name="line.469"></a>
+<span class="sourceLineNo">470</span><a name="line.470"></a>
+<span class="sourceLineNo">471</span>  private static class NamedLock&lt;T&gt; {<a name="line.471"></a>
+<span class="sourceLineNo">472</span>    private HashSet&lt;T&gt; locks = new HashSet&lt;T&gt;();<a name="line.472"></a>
+<span class="sourceLineNo">473</span><a name="line.473"></a>
+<span class="sourceLineNo">474</span>    public void lock(final T name) throws InterruptedException {<a name="line.474"></a>
+<span class="sourceLineNo">475</span>      synchronized (locks) {<a name="line.475"></a>
+<span class="sourceLineNo">476</span>        while (locks.contains(name)) {<a name="line.476"></a>
+<span class="sourceLineNo">477</span>          locks.wait();<a name="line.477"></a>
+<span class="sourceLineNo">478</span>        }<a name="line.478"></a>
+<span class="sourceLineNo">479</span>        locks.add(name);<a name="line.479"></a>
+<span class="sourceLineNo">480</span>      }<a name="line.480"></a>
+<span class="sourceLineNo">481</span>    }<a name="line.481"></a>
+<span class="sourceLineNo">482</span><a name="line.482"></a>
+<span class="sourceLineNo">483</span>    public void unlock(final T name) {<a name="line.483"></a>
+<span class="sourceLineNo">484</span>      synchronized (locks) {<a name="line.484"></a>
+<span class="sourceLineNo">485</span>        locks.remove(name);<a name="line.485"></a>
+<span class="sourceLineNo">486</span>        locks.notifyAll();<a name="line.486"></a>
+<span class="sourceLineNo">487</span>      }<a name="line.487"></a>
+<span class="sourceLineNo">488</span>    }<a name="line.488"></a>
+<span class="sourceLineNo">489</span>  }<a name="line.489"></a>
+<span class="sourceLineNo">490</span><a name="line.490"></a>
+<span class="sourceLineNo">491</span>  @Override<a name="line.491"></a>
+<span class="sourceLineNo">492</span>  public void onRegionSplitReverted(HRegionInfo hri) throws IOException {<a name="line.492"></a>
+<span class="sourceLineNo">493</span>    if (enabled) {<a name="line.493"></a>
+<span class="sourceLineNo">494</span>      this.namespaceQuotaManager.removeRegionFromNamespaceUsage(hri);<a name="line.494"></a>
+<span class="sourceLineNo">495</span>    }<a name="line.495"></a>
+<span class="sourceLineNo">496</span>  }<a name="line.496"></a>
+<span class="sourceLineNo">497</span>}<a name="line.497"></a>
+<span class="sourceLineNo">498</span><a name="line.498"></a>
 
 
 


Mime
View raw message