hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [16/51] [partial] hbase-site git commit: Published site at .
Date Tue, 28 Nov 2017 15:18:00 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/b9722a17/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BatchOperation.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BatchOperation.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BatchOperation.html
index 29ea7b3..6ed75c9 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BatchOperation.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BatchOperation.html
@@ -1313,7093 +1313,7082 @@
 <span class="sourceLineNo">1305</span><a name="line.1305"></a>
 <span class="sourceLineNo">1306</span>  @Override<a name="line.1306"></a>
 <span class="sourceLineNo">1307</span>  public boolean isSplittable() {<a name="line.1307"></a>
-<span class="sourceLineNo">1308</span>    boolean result = isAvailable() &amp;&amp; !hasReferences();<a name="line.1308"></a>
-<span class="sourceLineNo">1309</span>    LOG.info("ASKED IF SPLITTABLE " + result + " " + getRegionInfo().getShortNameToLog(),<a name="line.1309"></a>
-<span class="sourceLineNo">1310</span>      new Throwable("LOGGING: REMOVE"));<a name="line.1310"></a>
-<span class="sourceLineNo">1311</span>    // REMOVE BELOW!!!!<a name="line.1311"></a>
-<span class="sourceLineNo">1312</span>    LOG.info("DEBUG LIST ALL FILES");<a name="line.1312"></a>
-<span class="sourceLineNo">1313</span>    for (HStore store : this.stores.values()) {<a name="line.1313"></a>
-<span class="sourceLineNo">1314</span>      LOG.info("store " + store.getColumnFamilyName());<a name="line.1314"></a>
-<span class="sourceLineNo">1315</span>      for (HStoreFile sf : store.getStorefiles()) {<a name="line.1315"></a>
-<span class="sourceLineNo">1316</span>        LOG.info(sf.toStringDetailed());<a name="line.1316"></a>
-<span class="sourceLineNo">1317</span>      }<a name="line.1317"></a>
-<span class="sourceLineNo">1318</span>    }<a name="line.1318"></a>
-<span class="sourceLineNo">1319</span>    return result;<a name="line.1319"></a>
-<span class="sourceLineNo">1320</span>  }<a name="line.1320"></a>
-<span class="sourceLineNo">1321</span><a name="line.1321"></a>
-<span class="sourceLineNo">1322</span>  @Override<a name="line.1322"></a>
-<span class="sourceLineNo">1323</span>  public boolean isMergeable() {<a name="line.1323"></a>
-<span class="sourceLineNo">1324</span>    if (!isAvailable()) {<a name="line.1324"></a>
-<span class="sourceLineNo">1325</span>      LOG.debug("Region " + this<a name="line.1325"></a>
-<span class="sourceLineNo">1326</span>          + " is not mergeable because it is closing or closed");<a name="line.1326"></a>
-<span class="sourceLineNo">1327</span>      return false;<a name="line.1327"></a>
-<span class="sourceLineNo">1328</span>    }<a name="line.1328"></a>
-<span class="sourceLineNo">1329</span>    if (hasReferences()) {<a name="line.1329"></a>
-<span class="sourceLineNo">1330</span>      LOG.debug("Region " + this<a name="line.1330"></a>
-<span class="sourceLineNo">1331</span>          + " is not mergeable because it has references");<a name="line.1331"></a>
-<span class="sourceLineNo">1332</span>      return false;<a name="line.1332"></a>
-<span class="sourceLineNo">1333</span>    }<a name="line.1333"></a>
-<span class="sourceLineNo">1334</span><a name="line.1334"></a>
-<span class="sourceLineNo">1335</span>    return true;<a name="line.1335"></a>
+<span class="sourceLineNo">1308</span>    return isAvailable() &amp;&amp; !hasReferences();<a name="line.1308"></a>
+<span class="sourceLineNo">1309</span>  }<a name="line.1309"></a>
+<span class="sourceLineNo">1310</span><a name="line.1310"></a>
+<span class="sourceLineNo">1311</span>  @Override<a name="line.1311"></a>
+<span class="sourceLineNo">1312</span>  public boolean isMergeable() {<a name="line.1312"></a>
+<span class="sourceLineNo">1313</span>    if (!isAvailable()) {<a name="line.1313"></a>
+<span class="sourceLineNo">1314</span>      LOG.debug("Region " + this<a name="line.1314"></a>
+<span class="sourceLineNo">1315</span>          + " is not mergeable because it is closing or closed");<a name="line.1315"></a>
+<span class="sourceLineNo">1316</span>      return false;<a name="line.1316"></a>
+<span class="sourceLineNo">1317</span>    }<a name="line.1317"></a>
+<span class="sourceLineNo">1318</span>    if (hasReferences()) {<a name="line.1318"></a>
+<span class="sourceLineNo">1319</span>      LOG.debug("Region " + this<a name="line.1319"></a>
+<span class="sourceLineNo">1320</span>          + " is not mergeable because it has references");<a name="line.1320"></a>
+<span class="sourceLineNo">1321</span>      return false;<a name="line.1321"></a>
+<span class="sourceLineNo">1322</span>    }<a name="line.1322"></a>
+<span class="sourceLineNo">1323</span><a name="line.1323"></a>
+<span class="sourceLineNo">1324</span>    return true;<a name="line.1324"></a>
+<span class="sourceLineNo">1325</span>  }<a name="line.1325"></a>
+<span class="sourceLineNo">1326</span><a name="line.1326"></a>
+<span class="sourceLineNo">1327</span>  public boolean areWritesEnabled() {<a name="line.1327"></a>
+<span class="sourceLineNo">1328</span>    synchronized(this.writestate) {<a name="line.1328"></a>
+<span class="sourceLineNo">1329</span>      return this.writestate.writesEnabled;<a name="line.1329"></a>
+<span class="sourceLineNo">1330</span>    }<a name="line.1330"></a>
+<span class="sourceLineNo">1331</span>  }<a name="line.1331"></a>
+<span class="sourceLineNo">1332</span><a name="line.1332"></a>
+<span class="sourceLineNo">1333</span>  @VisibleForTesting<a name="line.1333"></a>
+<span class="sourceLineNo">1334</span>  public MultiVersionConcurrencyControl getMVCC() {<a name="line.1334"></a>
+<span class="sourceLineNo">1335</span>    return mvcc;<a name="line.1335"></a>
 <span class="sourceLineNo">1336</span>  }<a name="line.1336"></a>
 <span class="sourceLineNo">1337</span><a name="line.1337"></a>
-<span class="sourceLineNo">1338</span>  public boolean areWritesEnabled() {<a name="line.1338"></a>
-<span class="sourceLineNo">1339</span>    synchronized(this.writestate) {<a name="line.1339"></a>
-<span class="sourceLineNo">1340</span>      return this.writestate.writesEnabled;<a name="line.1340"></a>
-<span class="sourceLineNo">1341</span>    }<a name="line.1341"></a>
-<span class="sourceLineNo">1342</span>  }<a name="line.1342"></a>
-<span class="sourceLineNo">1343</span><a name="line.1343"></a>
-<span class="sourceLineNo">1344</span>  @VisibleForTesting<a name="line.1344"></a>
-<span class="sourceLineNo">1345</span>  public MultiVersionConcurrencyControl getMVCC() {<a name="line.1345"></a>
-<span class="sourceLineNo">1346</span>    return mvcc;<a name="line.1346"></a>
-<span class="sourceLineNo">1347</span>  }<a name="line.1347"></a>
-<span class="sourceLineNo">1348</span><a name="line.1348"></a>
-<span class="sourceLineNo">1349</span>  @Override<a name="line.1349"></a>
-<span class="sourceLineNo">1350</span>  public long getMaxFlushedSeqId() {<a name="line.1350"></a>
-<span class="sourceLineNo">1351</span>    return maxFlushedSeqId;<a name="line.1351"></a>
+<span class="sourceLineNo">1338</span>  @Override<a name="line.1338"></a>
+<span class="sourceLineNo">1339</span>  public long getMaxFlushedSeqId() {<a name="line.1339"></a>
+<span class="sourceLineNo">1340</span>    return maxFlushedSeqId;<a name="line.1340"></a>
+<span class="sourceLineNo">1341</span>  }<a name="line.1341"></a>
+<span class="sourceLineNo">1342</span><a name="line.1342"></a>
+<span class="sourceLineNo">1343</span>  /**<a name="line.1343"></a>
+<span class="sourceLineNo">1344</span>   * @return readpoint considering given IsolationLevel. Pass {@code null} for default<a name="line.1344"></a>
+<span class="sourceLineNo">1345</span>   */<a name="line.1345"></a>
+<span class="sourceLineNo">1346</span>  public long getReadPoint(IsolationLevel isolationLevel) {<a name="line.1346"></a>
+<span class="sourceLineNo">1347</span>    if (isolationLevel != null &amp;&amp; isolationLevel == IsolationLevel.READ_UNCOMMITTED) {<a name="line.1347"></a>
+<span class="sourceLineNo">1348</span>      // This scan can read even uncommitted transactions<a name="line.1348"></a>
+<span class="sourceLineNo">1349</span>      return Long.MAX_VALUE;<a name="line.1349"></a>
+<span class="sourceLineNo">1350</span>    }<a name="line.1350"></a>
+<span class="sourceLineNo">1351</span>    return mvcc.getReadPoint();<a name="line.1351"></a>
 <span class="sourceLineNo">1352</span>  }<a name="line.1352"></a>
 <span class="sourceLineNo">1353</span><a name="line.1353"></a>
-<span class="sourceLineNo">1354</span>  /**<a name="line.1354"></a>
-<span class="sourceLineNo">1355</span>   * @return readpoint considering given IsolationLevel. Pass {@code null} for default<a name="line.1355"></a>
-<span class="sourceLineNo">1356</span>   */<a name="line.1356"></a>
-<span class="sourceLineNo">1357</span>  public long getReadPoint(IsolationLevel isolationLevel) {<a name="line.1357"></a>
-<span class="sourceLineNo">1358</span>    if (isolationLevel != null &amp;&amp; isolationLevel == IsolationLevel.READ_UNCOMMITTED) {<a name="line.1358"></a>
-<span class="sourceLineNo">1359</span>      // This scan can read even uncommitted transactions<a name="line.1359"></a>
-<span class="sourceLineNo">1360</span>      return Long.MAX_VALUE;<a name="line.1360"></a>
-<span class="sourceLineNo">1361</span>    }<a name="line.1361"></a>
-<span class="sourceLineNo">1362</span>    return mvcc.getReadPoint();<a name="line.1362"></a>
-<span class="sourceLineNo">1363</span>  }<a name="line.1363"></a>
-<span class="sourceLineNo">1364</span><a name="line.1364"></a>
-<span class="sourceLineNo">1365</span>  public boolean isLoadingCfsOnDemandDefault() {<a name="line.1365"></a>
-<span class="sourceLineNo">1366</span>    return this.isLoadingCfsOnDemandDefault;<a name="line.1366"></a>
-<span class="sourceLineNo">1367</span>  }<a name="line.1367"></a>
-<span class="sourceLineNo">1368</span><a name="line.1368"></a>
-<span class="sourceLineNo">1369</span>  /**<a name="line.1369"></a>
-<span class="sourceLineNo">1370</span>   * Close down this HRegion.  Flush the cache, shut down each HStore, don't<a name="line.1370"></a>
-<span class="sourceLineNo">1371</span>   * service any more calls.<a name="line.1371"></a>
-<span class="sourceLineNo">1372</span>   *<a name="line.1372"></a>
-<span class="sourceLineNo">1373</span>   * &lt;p&gt;This method could take some time to execute, so don't call it from a<a name="line.1373"></a>
-<span class="sourceLineNo">1374</span>   * time-sensitive thread.<a name="line.1374"></a>
-<span class="sourceLineNo">1375</span>   *<a name="line.1375"></a>
-<span class="sourceLineNo">1376</span>   * @return Vector of all the storage files that the HRegion's component<a name="line.1376"></a>
-<span class="sourceLineNo">1377</span>   * HStores make use of.  It's a list of all StoreFile objects. Returns empty<a name="line.1377"></a>
-<span class="sourceLineNo">1378</span>   * vector if already closed and null if judged that it should not close.<a name="line.1378"></a>
-<span class="sourceLineNo">1379</span>   *<a name="line.1379"></a>
-<span class="sourceLineNo">1380</span>   * @throws IOException e<a name="line.1380"></a>
-<span class="sourceLineNo">1381</span>   * @throws DroppedSnapshotException Thrown when replay of wal is required<a name="line.1381"></a>
-<span class="sourceLineNo">1382</span>   * because a Snapshot was not properly persisted. The region is put in closing mode, and the<a name="line.1382"></a>
-<span class="sourceLineNo">1383</span>   * caller MUST abort after this.<a name="line.1383"></a>
-<span class="sourceLineNo">1384</span>   */<a name="line.1384"></a>
-<span class="sourceLineNo">1385</span>  public Map&lt;byte[], List&lt;HStoreFile&gt;&gt; close() throws IOException {<a name="line.1385"></a>
-<span class="sourceLineNo">1386</span>    return close(false);<a name="line.1386"></a>
-<span class="sourceLineNo">1387</span>  }<a name="line.1387"></a>
-<span class="sourceLineNo">1388</span><a name="line.1388"></a>
-<span class="sourceLineNo">1389</span>  private final Object closeLock = new Object();<a name="line.1389"></a>
-<span class="sourceLineNo">1390</span><a name="line.1390"></a>
-<span class="sourceLineNo">1391</span>  /** Conf key for the periodic flush interval */<a name="line.1391"></a>
-<span class="sourceLineNo">1392</span>  public static final String MEMSTORE_PERIODIC_FLUSH_INTERVAL =<a name="line.1392"></a>
-<span class="sourceLineNo">1393</span>      "hbase.regionserver.optionalcacheflushinterval";<a name="line.1393"></a>
-<span class="sourceLineNo">1394</span>  /** Default interval for the memstore flush */<a name="line.1394"></a>
-<span class="sourceLineNo">1395</span>  public static final int DEFAULT_CACHE_FLUSH_INTERVAL = 3600000;<a name="line.1395"></a>
-<span class="sourceLineNo">1396</span>  /** Default interval for System tables memstore flush */<a name="line.1396"></a>
-<span class="sourceLineNo">1397</span>  public static final int SYSTEM_CACHE_FLUSH_INTERVAL = 300000; // 5 minutes<a name="line.1397"></a>
-<span class="sourceLineNo">1398</span><a name="line.1398"></a>
-<span class="sourceLineNo">1399</span>  /** Conf key to force a flush if there are already enough changes for one region in memstore */<a name="line.1399"></a>
-<span class="sourceLineNo">1400</span>  public static final String MEMSTORE_FLUSH_PER_CHANGES =<a name="line.1400"></a>
-<span class="sourceLineNo">1401</span>      "hbase.regionserver.flush.per.changes";<a name="line.1401"></a>
-<span class="sourceLineNo">1402</span>  public static final long DEFAULT_FLUSH_PER_CHANGES = 30000000; // 30 millions<a name="line.1402"></a>
-<span class="sourceLineNo">1403</span>  /**<a name="line.1403"></a>
-<span class="sourceLineNo">1404</span>   * The following MAX_FLUSH_PER_CHANGES is large enough because each KeyValue has 20+ bytes<a name="line.1404"></a>
-<span class="sourceLineNo">1405</span>   * overhead. Therefore, even 1G empty KVs occupy at least 20GB memstore size for a single region<a name="line.1405"></a>
-<span class="sourceLineNo">1406</span>   */<a name="line.1406"></a>
-<span class="sourceLineNo">1407</span>  public static final long MAX_FLUSH_PER_CHANGES = 1000000000; // 1G<a name="line.1407"></a>
-<span class="sourceLineNo">1408</span><a name="line.1408"></a>
-<span class="sourceLineNo">1409</span>  /**<a name="line.1409"></a>
-<span class="sourceLineNo">1410</span>   * Close down this HRegion.  Flush the cache unless abort parameter is true,<a name="line.1410"></a>
-<span class="sourceLineNo">1411</span>   * Shut down each HStore, don't service any more calls.<a name="line.1411"></a>
-<span class="sourceLineNo">1412</span>   *<a name="line.1412"></a>
-<span class="sourceLineNo">1413</span>   * This method could take some time to execute, so don't call it from a<a name="line.1413"></a>
-<span class="sourceLineNo">1414</span>   * time-sensitive thread.<a name="line.1414"></a>
-<span class="sourceLineNo">1415</span>   *<a name="line.1415"></a>
-<span class="sourceLineNo">1416</span>   * @param abort true if server is aborting (only during testing)<a name="line.1416"></a>
-<span class="sourceLineNo">1417</span>   * @return Vector of all the storage files that the HRegion's component<a name="line.1417"></a>
-<span class="sourceLineNo">1418</span>   * HStores make use of.  It's a list of StoreFile objects.  Can be null if<a name="line.1418"></a>
-<span class="sourceLineNo">1419</span>   * we are not to close at this time or we are already closed.<a name="line.1419"></a>
-<span class="sourceLineNo">1420</span>   *<a name="line.1420"></a>
-<span class="sourceLineNo">1421</span>   * @throws IOException e<a name="line.1421"></a>
-<span class="sourceLineNo">1422</span>   * @throws DroppedSnapshotException Thrown when replay of wal is required<a name="line.1422"></a>
-<span class="sourceLineNo">1423</span>   * because a Snapshot was not properly persisted. The region is put in closing mode, and the<a name="line.1423"></a>
-<span class="sourceLineNo">1424</span>   * caller MUST abort after this.<a name="line.1424"></a>
-<span class="sourceLineNo">1425</span>   */<a name="line.1425"></a>
-<span class="sourceLineNo">1426</span>  public Map&lt;byte[], List&lt;HStoreFile&gt;&gt; close(boolean abort) throws IOException {<a name="line.1426"></a>
-<span class="sourceLineNo">1427</span>    // Only allow one thread to close at a time. Serialize them so dual<a name="line.1427"></a>
-<span class="sourceLineNo">1428</span>    // threads attempting to close will run up against each other.<a name="line.1428"></a>
-<span class="sourceLineNo">1429</span>    MonitoredTask status = TaskMonitor.get().createStatus(<a name="line.1429"></a>
-<span class="sourceLineNo">1430</span>        "Closing region " + this +<a name="line.1430"></a>
-<span class="sourceLineNo">1431</span>        (abort ? " due to abort" : ""));<a name="line.1431"></a>
-<span class="sourceLineNo">1432</span><a name="line.1432"></a>
-<span class="sourceLineNo">1433</span>    status.setStatus("Waiting for close lock");<a name="line.1433"></a>
-<span class="sourceLineNo">1434</span>    try {<a name="line.1434"></a>
-<span class="sourceLineNo">1435</span>      synchronized (closeLock) {<a name="line.1435"></a>
-<span class="sourceLineNo">1436</span>        return doClose(abort, status);<a name="line.1436"></a>
-<span class="sourceLineNo">1437</span>      }<a name="line.1437"></a>
-<span class="sourceLineNo">1438</span>    } finally {<a name="line.1438"></a>
-<span class="sourceLineNo">1439</span>      status.cleanup();<a name="line.1439"></a>
-<span class="sourceLineNo">1440</span>    }<a name="line.1440"></a>
-<span class="sourceLineNo">1441</span>  }<a name="line.1441"></a>
-<span class="sourceLineNo">1442</span><a name="line.1442"></a>
-<span class="sourceLineNo">1443</span>  /**<a name="line.1443"></a>
-<span class="sourceLineNo">1444</span>   * Exposed for some very specific unit tests.<a name="line.1444"></a>
-<span class="sourceLineNo">1445</span>   */<a name="line.1445"></a>
-<span class="sourceLineNo">1446</span>  @VisibleForTesting<a name="line.1446"></a>
-<span class="sourceLineNo">1447</span>  public void setClosing(boolean closing) {<a name="line.1447"></a>
-<span class="sourceLineNo">1448</span>    this.closing.set(closing);<a name="line.1448"></a>
+<span class="sourceLineNo">1354</span>  public boolean isLoadingCfsOnDemandDefault() {<a name="line.1354"></a>
+<span class="sourceLineNo">1355</span>    return this.isLoadingCfsOnDemandDefault;<a name="line.1355"></a>
+<span class="sourceLineNo">1356</span>  }<a name="line.1356"></a>
+<span class="sourceLineNo">1357</span><a name="line.1357"></a>
+<span class="sourceLineNo">1358</span>  /**<a name="line.1358"></a>
+<span class="sourceLineNo">1359</span>   * Close down this HRegion.  Flush the cache, shut down each HStore, don't<a name="line.1359"></a>
+<span class="sourceLineNo">1360</span>   * service any more calls.<a name="line.1360"></a>
+<span class="sourceLineNo">1361</span>   *<a name="line.1361"></a>
+<span class="sourceLineNo">1362</span>   * &lt;p&gt;This method could take some time to execute, so don't call it from a<a name="line.1362"></a>
+<span class="sourceLineNo">1363</span>   * time-sensitive thread.<a name="line.1363"></a>
+<span class="sourceLineNo">1364</span>   *<a name="line.1364"></a>
+<span class="sourceLineNo">1365</span>   * @return Vector of all the storage files that the HRegion's component<a name="line.1365"></a>
+<span class="sourceLineNo">1366</span>   * HStores make use of.  It's a list of all StoreFile objects. Returns empty<a name="line.1366"></a>
+<span class="sourceLineNo">1367</span>   * vector if already closed and null if judged that it should not close.<a name="line.1367"></a>
+<span class="sourceLineNo">1368</span>   *<a name="line.1368"></a>
+<span class="sourceLineNo">1369</span>   * @throws IOException e<a name="line.1369"></a>
+<span class="sourceLineNo">1370</span>   * @throws DroppedSnapshotException Thrown when replay of wal is required<a name="line.1370"></a>
+<span class="sourceLineNo">1371</span>   * because a Snapshot was not properly persisted. The region is put in closing mode, and the<a name="line.1371"></a>
+<span class="sourceLineNo">1372</span>   * caller MUST abort after this.<a name="line.1372"></a>
+<span class="sourceLineNo">1373</span>   */<a name="line.1373"></a>
+<span class="sourceLineNo">1374</span>  public Map&lt;byte[], List&lt;HStoreFile&gt;&gt; close() throws IOException {<a name="line.1374"></a>
+<span class="sourceLineNo">1375</span>    return close(false);<a name="line.1375"></a>
+<span class="sourceLineNo">1376</span>  }<a name="line.1376"></a>
+<span class="sourceLineNo">1377</span><a name="line.1377"></a>
+<span class="sourceLineNo">1378</span>  private final Object closeLock = new Object();<a name="line.1378"></a>
+<span class="sourceLineNo">1379</span><a name="line.1379"></a>
+<span class="sourceLineNo">1380</span>  /** Conf key for the periodic flush interval */<a name="line.1380"></a>
+<span class="sourceLineNo">1381</span>  public static final String MEMSTORE_PERIODIC_FLUSH_INTERVAL =<a name="line.1381"></a>
+<span class="sourceLineNo">1382</span>      "hbase.regionserver.optionalcacheflushinterval";<a name="line.1382"></a>
+<span class="sourceLineNo">1383</span>  /** Default interval for the memstore flush */<a name="line.1383"></a>
+<span class="sourceLineNo">1384</span>  public static final int DEFAULT_CACHE_FLUSH_INTERVAL = 3600000;<a name="line.1384"></a>
+<span class="sourceLineNo">1385</span>  /** Default interval for System tables memstore flush */<a name="line.1385"></a>
+<span class="sourceLineNo">1386</span>  public static final int SYSTEM_CACHE_FLUSH_INTERVAL = 300000; // 5 minutes<a name="line.1386"></a>
+<span class="sourceLineNo">1387</span><a name="line.1387"></a>
+<span class="sourceLineNo">1388</span>  /** Conf key to force a flush if there are already enough changes for one region in memstore */<a name="line.1388"></a>
+<span class="sourceLineNo">1389</span>  public static final String MEMSTORE_FLUSH_PER_CHANGES =<a name="line.1389"></a>
+<span class="sourceLineNo">1390</span>      "hbase.regionserver.flush.per.changes";<a name="line.1390"></a>
+<span class="sourceLineNo">1391</span>  public static final long DEFAULT_FLUSH_PER_CHANGES = 30000000; // 30 millions<a name="line.1391"></a>
+<span class="sourceLineNo">1392</span>  /**<a name="line.1392"></a>
+<span class="sourceLineNo">1393</span>   * The following MAX_FLUSH_PER_CHANGES is large enough because each KeyValue has 20+ bytes<a name="line.1393"></a>
+<span class="sourceLineNo">1394</span>   * overhead. Therefore, even 1G empty KVs occupy at least 20GB memstore size for a single region<a name="line.1394"></a>
+<span class="sourceLineNo">1395</span>   */<a name="line.1395"></a>
+<span class="sourceLineNo">1396</span>  public static final long MAX_FLUSH_PER_CHANGES = 1000000000; // 1G<a name="line.1396"></a>
+<span class="sourceLineNo">1397</span><a name="line.1397"></a>
+<span class="sourceLineNo">1398</span>  /**<a name="line.1398"></a>
+<span class="sourceLineNo">1399</span>   * Close down this HRegion.  Flush the cache unless abort parameter is true,<a name="line.1399"></a>
+<span class="sourceLineNo">1400</span>   * Shut down each HStore, don't service any more calls.<a name="line.1400"></a>
+<span class="sourceLineNo">1401</span>   *<a name="line.1401"></a>
+<span class="sourceLineNo">1402</span>   * This method could take some time to execute, so don't call it from a<a name="line.1402"></a>
+<span class="sourceLineNo">1403</span>   * time-sensitive thread.<a name="line.1403"></a>
+<span class="sourceLineNo">1404</span>   *<a name="line.1404"></a>
+<span class="sourceLineNo">1405</span>   * @param abort true if server is aborting (only during testing)<a name="line.1405"></a>
+<span class="sourceLineNo">1406</span>   * @return Vector of all the storage files that the HRegion's component<a name="line.1406"></a>
+<span class="sourceLineNo">1407</span>   * HStores make use of.  It's a list of StoreFile objects.  Can be null if<a name="line.1407"></a>
+<span class="sourceLineNo">1408</span>   * we are not to close at this time or we are already closed.<a name="line.1408"></a>
+<span class="sourceLineNo">1409</span>   *<a name="line.1409"></a>
+<span class="sourceLineNo">1410</span>   * @throws IOException e<a name="line.1410"></a>
+<span class="sourceLineNo">1411</span>   * @throws DroppedSnapshotException Thrown when replay of wal is required<a name="line.1411"></a>
+<span class="sourceLineNo">1412</span>   * because a Snapshot was not properly persisted. The region is put in closing mode, and the<a name="line.1412"></a>
+<span class="sourceLineNo">1413</span>   * caller MUST abort after this.<a name="line.1413"></a>
+<span class="sourceLineNo">1414</span>   */<a name="line.1414"></a>
+<span class="sourceLineNo">1415</span>  public Map&lt;byte[], List&lt;HStoreFile&gt;&gt; close(boolean abort) throws IOException {<a name="line.1415"></a>
+<span class="sourceLineNo">1416</span>    // Only allow one thread to close at a time. Serialize them so dual<a name="line.1416"></a>
+<span class="sourceLineNo">1417</span>    // threads attempting to close will run up against each other.<a name="line.1417"></a>
+<span class="sourceLineNo">1418</span>    MonitoredTask status = TaskMonitor.get().createStatus(<a name="line.1418"></a>
+<span class="sourceLineNo">1419</span>        "Closing region " + this +<a name="line.1419"></a>
+<span class="sourceLineNo">1420</span>        (abort ? " due to abort" : ""));<a name="line.1420"></a>
+<span class="sourceLineNo">1421</span><a name="line.1421"></a>
+<span class="sourceLineNo">1422</span>    status.setStatus("Waiting for close lock");<a name="line.1422"></a>
+<span class="sourceLineNo">1423</span>    try {<a name="line.1423"></a>
+<span class="sourceLineNo">1424</span>      synchronized (closeLock) {<a name="line.1424"></a>
+<span class="sourceLineNo">1425</span>        return doClose(abort, status);<a name="line.1425"></a>
+<span class="sourceLineNo">1426</span>      }<a name="line.1426"></a>
+<span class="sourceLineNo">1427</span>    } finally {<a name="line.1427"></a>
+<span class="sourceLineNo">1428</span>      status.cleanup();<a name="line.1428"></a>
+<span class="sourceLineNo">1429</span>    }<a name="line.1429"></a>
+<span class="sourceLineNo">1430</span>  }<a name="line.1430"></a>
+<span class="sourceLineNo">1431</span><a name="line.1431"></a>
+<span class="sourceLineNo">1432</span>  /**<a name="line.1432"></a>
+<span class="sourceLineNo">1433</span>   * Exposed for some very specific unit tests.<a name="line.1433"></a>
+<span class="sourceLineNo">1434</span>   */<a name="line.1434"></a>
+<span class="sourceLineNo">1435</span>  @VisibleForTesting<a name="line.1435"></a>
+<span class="sourceLineNo">1436</span>  public void setClosing(boolean closing) {<a name="line.1436"></a>
+<span class="sourceLineNo">1437</span>    this.closing.set(closing);<a name="line.1437"></a>
+<span class="sourceLineNo">1438</span>  }<a name="line.1438"></a>
+<span class="sourceLineNo">1439</span><a name="line.1439"></a>
+<span class="sourceLineNo">1440</span>  /**<a name="line.1440"></a>
+<span class="sourceLineNo">1441</span>   * The {@link HRegion#doClose} will block forever if someone tries proving the dead lock via the unit test.<a name="line.1441"></a>
+<span class="sourceLineNo">1442</span>   * Instead of blocking, the {@link HRegion#doClose} will throw exception if you set the timeout.<a name="line.1442"></a>
+<span class="sourceLineNo">1443</span>   * @param timeoutForWriteLock the second time to wait for the write lock in {@link HRegion#doClose}<a name="line.1443"></a>
+<span class="sourceLineNo">1444</span>   */<a name="line.1444"></a>
+<span class="sourceLineNo">1445</span>  @VisibleForTesting<a name="line.1445"></a>
+<span class="sourceLineNo">1446</span>  public void setTimeoutForWriteLock(long timeoutForWriteLock) {<a name="line.1446"></a>
+<span class="sourceLineNo">1447</span>    assert timeoutForWriteLock &gt;= 0;<a name="line.1447"></a>
+<span class="sourceLineNo">1448</span>    this.timeoutForWriteLock = timeoutForWriteLock;<a name="line.1448"></a>
 <span class="sourceLineNo">1449</span>  }<a name="line.1449"></a>
 <span class="sourceLineNo">1450</span><a name="line.1450"></a>
-<span class="sourceLineNo">1451</span>  /**<a name="line.1451"></a>
-<span class="sourceLineNo">1452</span>   * The {@link HRegion#doClose} will block forever if someone tries proving the dead lock via the unit test.<a name="line.1452"></a>
-<span class="sourceLineNo">1453</span>   * Instead of blocking, the {@link HRegion#doClose} will throw exception if you set the timeout.<a name="line.1453"></a>
-<span class="sourceLineNo">1454</span>   * @param timeoutForWriteLock the second time to wait for the write lock in {@link HRegion#doClose}<a name="line.1454"></a>
-<span class="sourceLineNo">1455</span>   */<a name="line.1455"></a>
-<span class="sourceLineNo">1456</span>  @VisibleForTesting<a name="line.1456"></a>
-<span class="sourceLineNo">1457</span>  public void setTimeoutForWriteLock(long timeoutForWriteLock) {<a name="line.1457"></a>
-<span class="sourceLineNo">1458</span>    assert timeoutForWriteLock &gt;= 0;<a name="line.1458"></a>
-<span class="sourceLineNo">1459</span>    this.timeoutForWriteLock = timeoutForWriteLock;<a name="line.1459"></a>
-<span class="sourceLineNo">1460</span>  }<a name="line.1460"></a>
-<span class="sourceLineNo">1461</span><a name="line.1461"></a>
-<span class="sourceLineNo">1462</span>  @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="UL_UNRELEASED_LOCK_EXCEPTION_PATH",<a name="line.1462"></a>
-<span class="sourceLineNo">1463</span>      justification="I think FindBugs is confused")<a name="line.1463"></a>
-<span class="sourceLineNo">1464</span>  private Map&lt;byte[], List&lt;HStoreFile&gt;&gt; doClose(boolean abort, MonitoredTask status)<a name="line.1464"></a>
-<span class="sourceLineNo">1465</span>      throws IOException {<a name="line.1465"></a>
-<span class="sourceLineNo">1466</span>    if (isClosed()) {<a name="line.1466"></a>
-<span class="sourceLineNo">1467</span>      LOG.warn("Region " + this + " already closed");<a name="line.1467"></a>
-<span class="sourceLineNo">1468</span>      return null;<a name="line.1468"></a>
-<span class="sourceLineNo">1469</span>    }<a name="line.1469"></a>
-<span class="sourceLineNo">1470</span><a name="line.1470"></a>
-<span class="sourceLineNo">1471</span>    if (coprocessorHost != null) {<a name="line.1471"></a>
-<span class="sourceLineNo">1472</span>      status.setStatus("Running coprocessor pre-close hooks");<a name="line.1472"></a>
-<span class="sourceLineNo">1473</span>      this.coprocessorHost.preClose(abort);<a name="line.1473"></a>
-<span class="sourceLineNo">1474</span>    }<a name="line.1474"></a>
-<span class="sourceLineNo">1475</span>    status.setStatus("Disabling compacts and flushes for region");<a name="line.1475"></a>
-<span class="sourceLineNo">1476</span>    boolean canFlush = true;<a name="line.1476"></a>
-<span class="sourceLineNo">1477</span>    synchronized (writestate) {<a name="line.1477"></a>
-<span class="sourceLineNo">1478</span>      // Disable compacting and flushing by background threads for this<a name="line.1478"></a>
-<span class="sourceLineNo">1479</span>      // region.<a name="line.1479"></a>
-<span class="sourceLineNo">1480</span>      canFlush = !writestate.readOnly;<a name="line.1480"></a>
-<span class="sourceLineNo">1481</span>      writestate.writesEnabled = false;<a name="line.1481"></a>
-<span class="sourceLineNo">1482</span>      LOG.debug("Closing " + this + ": disabling compactions &amp; flushes");<a name="line.1482"></a>
-<span class="sourceLineNo">1483</span>      waitForFlushesAndCompactions();<a name="line.1483"></a>
-<span class="sourceLineNo">1484</span>    }<a name="line.1484"></a>
-<span class="sourceLineNo">1485</span>    // If we were not just flushing, is it worth doing a preflush...one<a name="line.1485"></a>
-<span class="sourceLineNo">1486</span>    // that will clear out of the bulk of the memstore before we put up<a name="line.1486"></a>
-<span class="sourceLineNo">1487</span>    // the close flag?<a name="line.1487"></a>
-<span class="sourceLineNo">1488</span>    if (!abort &amp;&amp; worthPreFlushing() &amp;&amp; canFlush) {<a name="line.1488"></a>
-<span class="sourceLineNo">1489</span>      status.setStatus("Pre-flushing region before close");<a name="line.1489"></a>
-<span class="sourceLineNo">1490</span>      LOG.info("Running close preflush of " + this);<a name="line.1490"></a>
-<span class="sourceLineNo">1491</span>      try {<a name="line.1491"></a>
-<span class="sourceLineNo">1492</span>        internalFlushcache(status);<a name="line.1492"></a>
-<span class="sourceLineNo">1493</span>      } catch (IOException ioe) {<a name="line.1493"></a>
-<span class="sourceLineNo">1494</span>        // Failed to flush the region. Keep going.<a name="line.1494"></a>
-<span class="sourceLineNo">1495</span>        status.setStatus("Failed pre-flush " + this + "; " + ioe.getMessage());<a name="line.1495"></a>
-<span class="sourceLineNo">1496</span>      }<a name="line.1496"></a>
-<span class="sourceLineNo">1497</span>    }<a name="line.1497"></a>
-<span class="sourceLineNo">1498</span><a name="line.1498"></a>
-<span class="sourceLineNo">1499</span>    if (timeoutForWriteLock == null<a name="line.1499"></a>
-<span class="sourceLineNo">1500</span>        || timeoutForWriteLock == Long.MAX_VALUE) {<a name="line.1500"></a>
-<span class="sourceLineNo">1501</span>      // block waiting for the lock for closing<a name="line.1501"></a>
-<span class="sourceLineNo">1502</span>      lock.writeLock().lock(); // FindBugs: Complains UL_UNRELEASED_LOCK_EXCEPTION_PATH but seems fine<a name="line.1502"></a>
-<span class="sourceLineNo">1503</span>    } else {<a name="line.1503"></a>
-<span class="sourceLineNo">1504</span>      try {<a name="line.1504"></a>
-<span class="sourceLineNo">1505</span>        boolean succeed = lock.writeLock().tryLock(timeoutForWriteLock, TimeUnit.SECONDS);<a name="line.1505"></a>
-<span class="sourceLineNo">1506</span>        if (!succeed) {<a name="line.1506"></a>
-<span class="sourceLineNo">1507</span>          throw new IOException("Failed to get write lock when closing region");<a name="line.1507"></a>
-<span class="sourceLineNo">1508</span>        }<a name="line.1508"></a>
-<span class="sourceLineNo">1509</span>      } catch (InterruptedException e) {<a name="line.1509"></a>
-<span class="sourceLineNo">1510</span>        throw (InterruptedIOException) new InterruptedIOException().initCause(e);<a name="line.1510"></a>
-<span class="sourceLineNo">1511</span>      }<a name="line.1511"></a>
-<span class="sourceLineNo">1512</span>    }<a name="line.1512"></a>
-<span class="sourceLineNo">1513</span>    this.closing.set(true);<a name="line.1513"></a>
-<span class="sourceLineNo">1514</span>    status.setStatus("Disabling writes for close");<a name="line.1514"></a>
-<span class="sourceLineNo">1515</span>    try {<a name="line.1515"></a>
-<span class="sourceLineNo">1516</span>      if (this.isClosed()) {<a name="line.1516"></a>
-<span class="sourceLineNo">1517</span>        status.abort("Already got closed by another process");<a name="line.1517"></a>
-<span class="sourceLineNo">1518</span>        // SplitTransaction handles the null<a name="line.1518"></a>
-<span class="sourceLineNo">1519</span>        return null;<a name="line.1519"></a>
-<span class="sourceLineNo">1520</span>      }<a name="line.1520"></a>
-<span class="sourceLineNo">1521</span>      LOG.debug("Updates disabled for region " + this);<a name="line.1521"></a>
-<span class="sourceLineNo">1522</span>      // Don't flush the cache if we are aborting<a name="line.1522"></a>
-<span class="sourceLineNo">1523</span>      if (!abort &amp;&amp; canFlush) {<a name="line.1523"></a>
-<span class="sourceLineNo">1524</span>        int failedfFlushCount = 0;<a name="line.1524"></a>
-<span class="sourceLineNo">1525</span>        int flushCount = 0;<a name="line.1525"></a>
-<span class="sourceLineNo">1526</span>        long tmp = 0;<a name="line.1526"></a>
-<span class="sourceLineNo">1527</span>        long remainingSize = this.memstoreDataSize.get();<a name="line.1527"></a>
-<span class="sourceLineNo">1528</span>        while (remainingSize &gt; 0) {<a name="line.1528"></a>
-<span class="sourceLineNo">1529</span>          try {<a name="line.1529"></a>
-<span class="sourceLineNo">1530</span>            internalFlushcache(status);<a name="line.1530"></a>
-<span class="sourceLineNo">1531</span>            if(flushCount &gt;0) {<a name="line.1531"></a>
-<span class="sourceLineNo">1532</span>              LOG.info("Running extra flush, " + flushCount +<a name="line.1532"></a>
-<span class="sourceLineNo">1533</span>                  " (carrying snapshot?) " + this);<a name="line.1533"></a>
-<span class="sourceLineNo">1534</span>            }<a name="line.1534"></a>
-<span class="sourceLineNo">1535</span>            flushCount++;<a name="line.1535"></a>
-<span class="sourceLineNo">1536</span>            tmp = this.memstoreDataSize.get();<a name="line.1536"></a>
-<span class="sourceLineNo">1537</span>            if (tmp &gt;= remainingSize) {<a name="line.1537"></a>
-<span class="sourceLineNo">1538</span>              failedfFlushCount++;<a name="line.1538"></a>
-<span class="sourceLineNo">1539</span>            }<a name="line.1539"></a>
-<span class="sourceLineNo">1540</span>            remainingSize = tmp;<a name="line.1540"></a>
-<span class="sourceLineNo">1541</span>            if (failedfFlushCount &gt; 5) {<a name="line.1541"></a>
-<span class="sourceLineNo">1542</span>              // If we failed 5 times and are unable to clear memory, abort<a name="line.1542"></a>
-<span class="sourceLineNo">1543</span>              // so we do not lose data<a name="line.1543"></a>
-<span class="sourceLineNo">1544</span>              throw new DroppedSnapshotException("Failed clearing memory after " +<a name="line.1544"></a>
-<span class="sourceLineNo">1545</span>                  flushCount + " attempts on region: " +<a name="line.1545"></a>
-<span class="sourceLineNo">1546</span>                  Bytes.toStringBinary(getRegionInfo().getRegionName()));<a name="line.1546"></a>
-<span class="sourceLineNo">1547</span>            }<a name="line.1547"></a>
-<span class="sourceLineNo">1548</span>          } catch (IOException ioe) {<a name="line.1548"></a>
-<span class="sourceLineNo">1549</span>            status.setStatus("Failed flush " + this + ", putting online again");<a name="line.1549"></a>
-<span class="sourceLineNo">1550</span>            synchronized (writestate) {<a name="line.1550"></a>
-<span class="sourceLineNo">1551</span>              writestate.writesEnabled = true;<a name="line.1551"></a>
-<span class="sourceLineNo">1552</span>            }<a name="line.1552"></a>
-<span class="sourceLineNo">1553</span>            // Have to throw to upper layers.  I can't abort server from here.<a name="line.1553"></a>
-<span class="sourceLineNo">1554</span>            throw ioe;<a name="line.1554"></a>
-<span class="sourceLineNo">1555</span>          }<a name="line.1555"></a>
-<span class="sourceLineNo">1556</span>        }<a name="line.1556"></a>
-<span class="sourceLineNo">1557</span>      }<a name="line.1557"></a>
-<span class="sourceLineNo">1558</span><a name="line.1558"></a>
-<span class="sourceLineNo">1559</span>      Map&lt;byte[], List&lt;HStoreFile&gt;&gt; result = new TreeMap&lt;&gt;(Bytes.BYTES_COMPARATOR);<a name="line.1559"></a>
-<span class="sourceLineNo">1560</span>      if (!stores.isEmpty()) {<a name="line.1560"></a>
-<span class="sourceLineNo">1561</span>        // initialize the thread pool for closing stores in parallel.<a name="line.1561"></a>
-<span class="sourceLineNo">1562</span>        ThreadPoolExecutor storeCloserThreadPool =<a name="line.1562"></a>
-<span class="sourceLineNo">1563</span>          getStoreOpenAndCloseThreadPool("StoreCloserThread-" +<a name="line.1563"></a>
-<span class="sourceLineNo">1564</span>            getRegionInfo().getRegionNameAsString());<a name="line.1564"></a>
-<span class="sourceLineNo">1565</span>        CompletionService&lt;Pair&lt;byte[], Collection&lt;HStoreFile&gt;&gt;&gt; completionService =<a name="line.1565"></a>
-<span class="sourceLineNo">1566</span>          new ExecutorCompletionService&lt;&gt;(storeCloserThreadPool);<a name="line.1566"></a>
-<span class="sourceLineNo">1567</span><a name="line.1567"></a>
-<span class="sourceLineNo">1568</span>        // close each store in parallel<a name="line.1568"></a>
-<span class="sourceLineNo">1569</span>        for (HStore store : stores.values()) {<a name="line.1569"></a>
-<span class="sourceLineNo">1570</span>          MemStoreSize flushableSize = store.getFlushableSize();<a name="line.1570"></a>
-<span class="sourceLineNo">1571</span>          if (!(abort || flushableSize.getDataSize() == 0 || writestate.readOnly)) {<a name="line.1571"></a>
-<span class="sourceLineNo">1572</span>            if (getRegionServerServices() != null) {<a name="line.1572"></a>
-<span class="sourceLineNo">1573</span>              getRegionServerServices().abort("Assertion failed while closing store "<a name="line.1573"></a>
-<span class="sourceLineNo">1574</span>                + getRegionInfo().getRegionNameAsString() + " " + store<a name="line.1574"></a>
-<span class="sourceLineNo">1575</span>                + ". flushableSize expected=0, actual= " + flushableSize<a name="line.1575"></a>
-<span class="sourceLineNo">1576</span>                + ". Current memstoreSize=" + getMemStoreSize() + ". Maybe a coprocessor "<a name="line.1576"></a>
-<span class="sourceLineNo">1577</span>                + "operation failed and left the memstore in a partially updated state.", null);<a name="line.1577"></a>
-<span class="sourceLineNo">1578</span>            }<a name="line.1578"></a>
-<span class="sourceLineNo">1579</span>          }<a name="line.1579"></a>
-<span class="sourceLineNo">1580</span>          completionService<a name="line.1580"></a>
-<span class="sourceLineNo">1581</span>              .submit(new Callable&lt;Pair&lt;byte[], Collection&lt;HStoreFile&gt;&gt;&gt;() {<a name="line.1581"></a>
-<span class="sourceLineNo">1582</span>                @Override<a name="line.1582"></a>
-<span class="sourceLineNo">1583</span>                public Pair&lt;byte[], Collection&lt;HStoreFile&gt;&gt; call() throws IOException {<a name="line.1583"></a>
-<span class="sourceLineNo">1584</span>                  return new Pair&lt;&gt;(store.getColumnFamilyDescriptor().getName(), store.close());<a name="line.1584"></a>
-<span class="sourceLineNo">1585</span>                }<a name="line.1585"></a>
-<span class="sourceLineNo">1586</span>              });<a name="line.1586"></a>
-<span class="sourceLineNo">1587</span>        }<a name="line.1587"></a>
-<span class="sourceLineNo">1588</span>        try {<a name="line.1588"></a>
-<span class="sourceLineNo">1589</span>          for (int i = 0; i &lt; stores.size(); i++) {<a name="line.1589"></a>
-<span class="sourceLineNo">1590</span>            Future&lt;Pair&lt;byte[], Collection&lt;HStoreFile&gt;&gt;&gt; future = completionService.take();<a name="line.1590"></a>
-<span class="sourceLineNo">1591</span>            Pair&lt;byte[], Collection&lt;HStoreFile&gt;&gt; storeFiles = future.get();<a name="line.1591"></a>
-<span class="sourceLineNo">1592</span>            List&lt;HStoreFile&gt; familyFiles = result.get(storeFiles.getFirst());<a name="line.1592"></a>
-<span class="sourceLineNo">1593</span>            if (familyFiles == null) {<a name="line.1593"></a>
-<span class="sourceLineNo">1594</span>              familyFiles = new ArrayList&lt;&gt;();<a name="line.1594"></a>
-<span class="sourceLineNo">1595</span>              result.put(storeFiles.getFirst(), familyFiles);<a name="line.1595"></a>
-<span class="sourceLineNo">1596</span>            }<a name="line.1596"></a>
-<span class="sourceLineNo">1597</span>            familyFiles.addAll(storeFiles.getSecond());<a name="line.1597"></a>
-<span class="sourceLineNo">1598</span>          }<a name="line.1598"></a>
-<span class="sourceLineNo">1599</span>        } catch (InterruptedException e) {<a name="line.1599"></a>
-<span class="sourceLineNo">1600</span>          throw (InterruptedIOException)new InterruptedIOException().initCause(e);<a name="line.1600"></a>
-<span class="sourceLineNo">1601</span>        } catch (ExecutionException e) {<a name="line.1601"></a>
-<span class="sourceLineNo">1602</span>          Throwable cause = e.getCause();<a name="line.1602"></a>
-<span class="sourceLineNo">1603</span>          if (cause instanceof IOException) {<a name="line.1603"></a>
-<span class="sourceLineNo">1604</span>            throw (IOException) cause;<a name="line.1604"></a>
-<span class="sourceLineNo">1605</span>          }<a name="line.1605"></a>
-<span class="sourceLineNo">1606</span>          throw new IOException(cause);<a name="line.1606"></a>
-<span class="sourceLineNo">1607</span>        } finally {<a name="line.1607"></a>
-<span class="sourceLineNo">1608</span>          storeCloserThreadPool.shutdownNow();<a name="line.1608"></a>
-<span class="sourceLineNo">1609</span>        }<a name="line.1609"></a>
-<span class="sourceLineNo">1610</span>      }<a name="line.1610"></a>
-<span class="sourceLineNo">1611</span><a name="line.1611"></a>
-<span class="sourceLineNo">1612</span>      status.setStatus("Writing region close event to WAL");<a name="line.1612"></a>
-<span class="sourceLineNo">1613</span>      if (!abort &amp;&amp; wal != null &amp;&amp; getRegionServerServices() != null &amp;&amp; !writestate.readOnly) {<a name="line.1613"></a>
-<span class="sourceLineNo">1614</span>        writeRegionCloseMarker(wal);<a name="line.1614"></a>
+<span class="sourceLineNo">1451</span>  @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="UL_UNRELEASED_LOCK_EXCEPTION_PATH",<a name="line.1451"></a>
+<span class="sourceLineNo">1452</span>      justification="I think FindBugs is confused")<a name="line.1452"></a>
+<span class="sourceLineNo">1453</span>  private Map&lt;byte[], List&lt;HStoreFile&gt;&gt; doClose(boolean abort, MonitoredTask status)<a name="line.1453"></a>
+<span class="sourceLineNo">1454</span>      throws IOException {<a name="line.1454"></a>
+<span class="sourceLineNo">1455</span>    if (isClosed()) {<a name="line.1455"></a>
+<span class="sourceLineNo">1456</span>      LOG.warn("Region " + this + " already closed");<a name="line.1456"></a>
+<span class="sourceLineNo">1457</span>      return null;<a name="line.1457"></a>
+<span class="sourceLineNo">1458</span>    }<a name="line.1458"></a>
+<span class="sourceLineNo">1459</span><a name="line.1459"></a>
+<span class="sourceLineNo">1460</span>    if (coprocessorHost != null) {<a name="line.1460"></a>
+<span class="sourceLineNo">1461</span>      status.setStatus("Running coprocessor pre-close hooks");<a name="line.1461"></a>
+<span class="sourceLineNo">1462</span>      this.coprocessorHost.preClose(abort);<a name="line.1462"></a>
+<span class="sourceLineNo">1463</span>    }<a name="line.1463"></a>
+<span class="sourceLineNo">1464</span>    status.setStatus("Disabling compacts and flushes for region");<a name="line.1464"></a>
+<span class="sourceLineNo">1465</span>    boolean canFlush = true;<a name="line.1465"></a>
+<span class="sourceLineNo">1466</span>    synchronized (writestate) {<a name="line.1466"></a>
+<span class="sourceLineNo">1467</span>      // Disable compacting and flushing by background threads for this<a name="line.1467"></a>
+<span class="sourceLineNo">1468</span>      // region.<a name="line.1468"></a>
+<span class="sourceLineNo">1469</span>      canFlush = !writestate.readOnly;<a name="line.1469"></a>
+<span class="sourceLineNo">1470</span>      writestate.writesEnabled = false;<a name="line.1470"></a>
+<span class="sourceLineNo">1471</span>      LOG.debug("Closing " + this + ": disabling compactions &amp; flushes");<a name="line.1471"></a>
+<span class="sourceLineNo">1472</span>      waitForFlushesAndCompactions();<a name="line.1472"></a>
+<span class="sourceLineNo">1473</span>    }<a name="line.1473"></a>
+<span class="sourceLineNo">1474</span>    // If we were not just flushing, is it worth doing a preflush...one<a name="line.1474"></a>
+<span class="sourceLineNo">1475</span>    // that will clear out of the bulk of the memstore before we put up<a name="line.1475"></a>
+<span class="sourceLineNo">1476</span>    // the close flag?<a name="line.1476"></a>
+<span class="sourceLineNo">1477</span>    if (!abort &amp;&amp; worthPreFlushing() &amp;&amp; canFlush) {<a name="line.1477"></a>
+<span class="sourceLineNo">1478</span>      status.setStatus("Pre-flushing region before close");<a name="line.1478"></a>
+<span class="sourceLineNo">1479</span>      LOG.info("Running close preflush of " + this);<a name="line.1479"></a>
+<span class="sourceLineNo">1480</span>      try {<a name="line.1480"></a>
+<span class="sourceLineNo">1481</span>        internalFlushcache(status);<a name="line.1481"></a>
+<span class="sourceLineNo">1482</span>      } catch (IOException ioe) {<a name="line.1482"></a>
+<span class="sourceLineNo">1483</span>        // Failed to flush the region. Keep going.<a name="line.1483"></a>
+<span class="sourceLineNo">1484</span>        status.setStatus("Failed pre-flush " + this + "; " + ioe.getMessage());<a name="line.1484"></a>
+<span class="sourceLineNo">1485</span>      }<a name="line.1485"></a>
+<span class="sourceLineNo">1486</span>    }<a name="line.1486"></a>
+<span class="sourceLineNo">1487</span><a name="line.1487"></a>
+<span class="sourceLineNo">1488</span>    if (timeoutForWriteLock == null<a name="line.1488"></a>
+<span class="sourceLineNo">1489</span>        || timeoutForWriteLock == Long.MAX_VALUE) {<a name="line.1489"></a>
+<span class="sourceLineNo">1490</span>      // block waiting for the lock for closing<a name="line.1490"></a>
+<span class="sourceLineNo">1491</span>      lock.writeLock().lock(); // FindBugs: Complains UL_UNRELEASED_LOCK_EXCEPTION_PATH but seems fine<a name="line.1491"></a>
+<span class="sourceLineNo">1492</span>    } else {<a name="line.1492"></a>
+<span class="sourceLineNo">1493</span>      try {<a name="line.1493"></a>
+<span class="sourceLineNo">1494</span>        boolean succeed = lock.writeLock().tryLock(timeoutForWriteLock, TimeUnit.SECONDS);<a name="line.1494"></a>
+<span class="sourceLineNo">1495</span>        if (!succeed) {<a name="line.1495"></a>
+<span class="sourceLineNo">1496</span>          throw new IOException("Failed to get write lock when closing region");<a name="line.1496"></a>
+<span class="sourceLineNo">1497</span>        }<a name="line.1497"></a>
+<span class="sourceLineNo">1498</span>      } catch (InterruptedException e) {<a name="line.1498"></a>
+<span class="sourceLineNo">1499</span>        throw (InterruptedIOException) new InterruptedIOException().initCause(e);<a name="line.1499"></a>
+<span class="sourceLineNo">1500</span>      }<a name="line.1500"></a>
+<span class="sourceLineNo">1501</span>    }<a name="line.1501"></a>
+<span class="sourceLineNo">1502</span>    this.closing.set(true);<a name="line.1502"></a>
+<span class="sourceLineNo">1503</span>    status.setStatus("Disabling writes for close");<a name="line.1503"></a>
+<span class="sourceLineNo">1504</span>    try {<a name="line.1504"></a>
+<span class="sourceLineNo">1505</span>      if (this.isClosed()) {<a name="line.1505"></a>
+<span class="sourceLineNo">1506</span>        status.abort("Already got closed by another process");<a name="line.1506"></a>
+<span class="sourceLineNo">1507</span>        // SplitTransaction handles the null<a name="line.1507"></a>
+<span class="sourceLineNo">1508</span>        return null;<a name="line.1508"></a>
+<span class="sourceLineNo">1509</span>      }<a name="line.1509"></a>
+<span class="sourceLineNo">1510</span>      LOG.debug("Updates disabled for region " + this);<a name="line.1510"></a>
+<span class="sourceLineNo">1511</span>      // Don't flush the cache if we are aborting<a name="line.1511"></a>
+<span class="sourceLineNo">1512</span>      if (!abort &amp;&amp; canFlush) {<a name="line.1512"></a>
+<span class="sourceLineNo">1513</span>        int failedfFlushCount = 0;<a name="line.1513"></a>
+<span class="sourceLineNo">1514</span>        int flushCount = 0;<a name="line.1514"></a>
+<span class="sourceLineNo">1515</span>        long tmp = 0;<a name="line.1515"></a>
+<span class="sourceLineNo">1516</span>        long remainingSize = this.memstoreDataSize.get();<a name="line.1516"></a>
+<span class="sourceLineNo">1517</span>        while (remainingSize &gt; 0) {<a name="line.1517"></a>
+<span class="sourceLineNo">1518</span>          try {<a name="line.1518"></a>
+<span class="sourceLineNo">1519</span>            internalFlushcache(status);<a name="line.1519"></a>
+<span class="sourceLineNo">1520</span>            if(flushCount &gt;0) {<a name="line.1520"></a>
+<span class="sourceLineNo">1521</span>              LOG.info("Running extra flush, " + flushCount +<a name="line.1521"></a>
+<span class="sourceLineNo">1522</span>                  " (carrying snapshot?) " + this);<a name="line.1522"></a>
+<span class="sourceLineNo">1523</span>            }<a name="line.1523"></a>
+<span class="sourceLineNo">1524</span>            flushCount++;<a name="line.1524"></a>
+<span class="sourceLineNo">1525</span>            tmp = this.memstoreDataSize.get();<a name="line.1525"></a>
+<span class="sourceLineNo">1526</span>            if (tmp &gt;= remainingSize) {<a name="line.1526"></a>
+<span class="sourceLineNo">1527</span>              failedfFlushCount++;<a name="line.1527"></a>
+<span class="sourceLineNo">1528</span>            }<a name="line.1528"></a>
+<span class="sourceLineNo">1529</span>            remainingSize = tmp;<a name="line.1529"></a>
+<span class="sourceLineNo">1530</span>            if (failedfFlushCount &gt; 5) {<a name="line.1530"></a>
+<span class="sourceLineNo">1531</span>              // If we failed 5 times and are unable to clear memory, abort<a name="line.1531"></a>
+<span class="sourceLineNo">1532</span>              // so we do not lose data<a name="line.1532"></a>
+<span class="sourceLineNo">1533</span>              throw new DroppedSnapshotException("Failed clearing memory after " +<a name="line.1533"></a>
+<span class="sourceLineNo">1534</span>                  flushCount + " attempts on region: " +<a name="line.1534"></a>
+<span class="sourceLineNo">1535</span>                  Bytes.toStringBinary(getRegionInfo().getRegionName()));<a name="line.1535"></a>
+<span class="sourceLineNo">1536</span>            }<a name="line.1536"></a>
+<span class="sourceLineNo">1537</span>          } catch (IOException ioe) {<a name="line.1537"></a>
+<span class="sourceLineNo">1538</span>            status.setStatus("Failed flush " + this + ", putting online again");<a name="line.1538"></a>
+<span class="sourceLineNo">1539</span>            synchronized (writestate) {<a name="line.1539"></a>
+<span class="sourceLineNo">1540</span>              writestate.writesEnabled = true;<a name="line.1540"></a>
+<span class="sourceLineNo">1541</span>            }<a name="line.1541"></a>
+<span class="sourceLineNo">1542</span>            // Have to throw to upper layers.  I can't abort server from here.<a name="line.1542"></a>
+<span class="sourceLineNo">1543</span>            throw ioe;<a name="line.1543"></a>
+<span class="sourceLineNo">1544</span>          }<a name="line.1544"></a>
+<span class="sourceLineNo">1545</span>        }<a name="line.1545"></a>
+<span class="sourceLineNo">1546</span>      }<a name="line.1546"></a>
+<span class="sourceLineNo">1547</span><a name="line.1547"></a>
+<span class="sourceLineNo">1548</span>      Map&lt;byte[], List&lt;HStoreFile&gt;&gt; result = new TreeMap&lt;&gt;(Bytes.BYTES_COMPARATOR);<a name="line.1548"></a>
+<span class="sourceLineNo">1549</span>      if (!stores.isEmpty()) {<a name="line.1549"></a>
+<span class="sourceLineNo">1550</span>        // initialize the thread pool for closing stores in parallel.<a name="line.1550"></a>
+<span class="sourceLineNo">1551</span>        ThreadPoolExecutor storeCloserThreadPool =<a name="line.1551"></a>
+<span class="sourceLineNo">1552</span>          getStoreOpenAndCloseThreadPool("StoreCloserThread-" +<a name="line.1552"></a>
+<span class="sourceLineNo">1553</span>            getRegionInfo().getRegionNameAsString());<a name="line.1553"></a>
+<span class="sourceLineNo">1554</span>        CompletionService&lt;Pair&lt;byte[], Collection&lt;HStoreFile&gt;&gt;&gt; completionService =<a name="line.1554"></a>
+<span class="sourceLineNo">1555</span>          new ExecutorCompletionService&lt;&gt;(storeCloserThreadPool);<a name="line.1555"></a>
+<span class="sourceLineNo">1556</span><a name="line.1556"></a>
+<span class="sourceLineNo">1557</span>        // close each store in parallel<a name="line.1557"></a>
+<span class="sourceLineNo">1558</span>        for (HStore store : stores.values()) {<a name="line.1558"></a>
+<span class="sourceLineNo">1559</span>          MemStoreSize flushableSize = store.getFlushableSize();<a name="line.1559"></a>
+<span class="sourceLineNo">1560</span>          if (!(abort || flushableSize.getDataSize() == 0 || writestate.readOnly)) {<a name="line.1560"></a>
+<span class="sourceLineNo">1561</span>            if (getRegionServerServices() != null) {<a name="line.1561"></a>
+<span class="sourceLineNo">1562</span>              getRegionServerServices().abort("Assertion failed while closing store "<a name="line.1562"></a>
+<span class="sourceLineNo">1563</span>                + getRegionInfo().getRegionNameAsString() + " " + store<a name="line.1563"></a>
+<span class="sourceLineNo">1564</span>                + ". flushableSize expected=0, actual= " + flushableSize<a name="line.1564"></a>
+<span class="sourceLineNo">1565</span>                + ". Current memstoreSize=" + getMemStoreSize() + ". Maybe a coprocessor "<a name="line.1565"></a>
+<span class="sourceLineNo">1566</span>                + "operation failed and left the memstore in a partially updated state.", null);<a name="line.1566"></a>
+<span class="sourceLineNo">1567</span>            }<a name="line.1567"></a>
+<span class="sourceLineNo">1568</span>          }<a name="line.1568"></a>
+<span class="sourceLineNo">1569</span>          completionService<a name="line.1569"></a>
+<span class="sourceLineNo">1570</span>              .submit(new Callable&lt;Pair&lt;byte[], Collection&lt;HStoreFile&gt;&gt;&gt;() {<a name="line.1570"></a>
+<span class="sourceLineNo">1571</span>                @Override<a name="line.1571"></a>
+<span class="sourceLineNo">1572</span>                public Pair&lt;byte[], Collection&lt;HStoreFile&gt;&gt; call() throws IOException {<a name="line.1572"></a>
+<span class="sourceLineNo">1573</span>                  return new Pair&lt;&gt;(store.getColumnFamilyDescriptor().getName(), store.close());<a name="line.1573"></a>
+<span class="sourceLineNo">1574</span>                }<a name="line.1574"></a>
+<span class="sourceLineNo">1575</span>              });<a name="line.1575"></a>
+<span class="sourceLineNo">1576</span>        }<a name="line.1576"></a>
+<span class="sourceLineNo">1577</span>        try {<a name="line.1577"></a>
+<span class="sourceLineNo">1578</span>          for (int i = 0; i &lt; stores.size(); i++) {<a name="line.1578"></a>
+<span class="sourceLineNo">1579</span>            Future&lt;Pair&lt;byte[], Collection&lt;HStoreFile&gt;&gt;&gt; future = completionService.take();<a name="line.1579"></a>
+<span class="sourceLineNo">1580</span>            Pair&lt;byte[], Collection&lt;HStoreFile&gt;&gt; storeFiles = future.get();<a name="line.1580"></a>
+<span class="sourceLineNo">1581</span>            List&lt;HStoreFile&gt; familyFiles = result.get(storeFiles.getFirst());<a name="line.1581"></a>
+<span class="sourceLineNo">1582</span>            if (familyFiles == null) {<a name="line.1582"></a>
+<span class="sourceLineNo">1583</span>              familyFiles = new ArrayList&lt;&gt;();<a name="line.1583"></a>
+<span class="sourceLineNo">1584</span>              result.put(storeFiles.getFirst(), familyFiles);<a name="line.1584"></a>
+<span class="sourceLineNo">1585</span>            }<a name="line.1585"></a>
+<span class="sourceLineNo">1586</span>            familyFiles.addAll(storeFiles.getSecond());<a name="line.1586"></a>
+<span class="sourceLineNo">1587</span>          }<a name="line.1587"></a>
+<span class="sourceLineNo">1588</span>        } catch (InterruptedException e) {<a name="line.1588"></a>
+<span class="sourceLineNo">1589</span>          throw (InterruptedIOException)new InterruptedIOException().initCause(e);<a name="line.1589"></a>
+<span class="sourceLineNo">1590</span>        } catch (ExecutionException e) {<a name="line.1590"></a>
+<span class="sourceLineNo">1591</span>          Throwable cause = e.getCause();<a name="line.1591"></a>
+<span class="sourceLineNo">1592</span>          if (cause instanceof IOException) {<a name="line.1592"></a>
+<span class="sourceLineNo">1593</span>            throw (IOException) cause;<a name="line.1593"></a>
+<span class="sourceLineNo">1594</span>          }<a name="line.1594"></a>
+<span class="sourceLineNo">1595</span>          throw new IOException(cause);<a name="line.1595"></a>
+<span class="sourceLineNo">1596</span>        } finally {<a name="line.1596"></a>
+<span class="sourceLineNo">1597</span>          storeCloserThreadPool.shutdownNow();<a name="line.1597"></a>
+<span class="sourceLineNo">1598</span>        }<a name="line.1598"></a>
+<span class="sourceLineNo">1599</span>      }<a name="line.1599"></a>
+<span class="sourceLineNo">1600</span><a name="line.1600"></a>
+<span class="sourceLineNo">1601</span>      status.setStatus("Writing region close event to WAL");<a name="line.1601"></a>
+<span class="sourceLineNo">1602</span>      if (!abort &amp;&amp; wal != null &amp;&amp; getRegionServerServices() != null &amp;&amp; !writestate.readOnly) {<a name="line.1602"></a>
+<span class="sourceLineNo">1603</span>        writeRegionCloseMarker(wal);<a name="line.1603"></a>
+<span class="sourceLineNo">1604</span>      }<a name="line.1604"></a>
+<span class="sourceLineNo">1605</span><a name="line.1605"></a>
+<span class="sourceLineNo">1606</span>      this.closed.set(true);<a name="line.1606"></a>
+<span class="sourceLineNo">1607</span>      if (!canFlush) {<a name="line.1607"></a>
+<span class="sourceLineNo">1608</span>        this.decrMemStoreSize(new MemStoreSizing(memstoreDataSize.get(), getMemStoreHeapSize()));<a name="line.1608"></a>
+<span class="sourceLineNo">1609</span>      } else if (memstoreDataSize.get() != 0) {<a name="line.1609"></a>
+<span class="sourceLineNo">1610</span>        LOG.error("Memstore size is " + memstoreDataSize.get());<a name="line.1610"></a>
+<span class="sourceLineNo">1611</span>      }<a name="line.1611"></a>
+<span class="sourceLineNo">1612</span>      if (coprocessorHost != null) {<a name="line.1612"></a>
+<span class="sourceLineNo">1613</span>        status.setStatus("Running coprocessor post-close hooks");<a name="line.1613"></a>
+<span class="sourceLineNo">1614</span>        this.coprocessorHost.postClose(abort);<a name="line.1614"></a>
 <span class="sourceLineNo">1615</span>      }<a name="line.1615"></a>
-<span class="sourceLineNo">1616</span><a name="line.1616"></a>
-<span class="sourceLineNo">1617</span>      this.closed.set(true);<a name="line.1617"></a>
-<span class="sourceLineNo">1618</span>      if (!canFlush) {<a name="line.1618"></a>
-<span class="sourceLineNo">1619</span>        this.decrMemStoreSize(new MemStoreSizing(memstoreDataSize.get(), getMemStoreHeapSize()));<a name="line.1619"></a>
-<span class="sourceLineNo">1620</span>      } else if (memstoreDataSize.get() != 0) {<a name="line.1620"></a>
-<span class="sourceLineNo">1621</span>        LOG.error("Memstore size is " + memstoreDataSize.get());<a name="line.1621"></a>
-<span class="sourceLineNo">1622</span>      }<a name="line.1622"></a>
-<span class="sourceLineNo">1623</span>      if (coprocessorHost != null) {<a name="line.1623"></a>
-<span class="sourceLineNo">1624</span>        status.setStatus("Running coprocessor post-close hooks");<a name="line.1624"></a>
-<span class="sourceLineNo">1625</span>        this.coprocessorHost.postClose(abort);<a name="line.1625"></a>
-<span class="sourceLineNo">1626</span>      }<a name="line.1626"></a>
-<span class="sourceLineNo">1627</span>      if (this.metricsRegion != null) {<a name="line.1627"></a>
-<span class="sourceLineNo">1628</span>        this.metricsRegion.close();<a name="line.1628"></a>
-<span class="sourceLineNo">1629</span>      }<a name="line.1629"></a>
-<span class="sourceLineNo">1630</span>      if (this.metricsRegionWrapper != null) {<a name="line.1630"></a>
-<span class="sourceLineNo">1631</span>        Closeables.close(this.metricsRegionWrapper, true);<a name="line.1631"></a>
-<span class="sourceLineNo">1632</span>      }<a name="line.1632"></a>
-<span class="sourceLineNo">1633</span>      status.markComplete("Closed");<a name="line.1633"></a>
-<span class="sourceLineNo">1634</span>      LOG.info("Closed " + this);<a name="line.1634"></a>
-<span class="sourceLineNo">1635</span>      return result;<a name="line.1635"></a>
-<span class="sourceLineNo">1636</span>    } finally {<a name="line.1636"></a>
-<span class="sourceLineNo">1637</span>      lock.writeLock().unlock();<a name="line.1637"></a>
-<span class="sourceLineNo">1638</span>    }<a name="line.1638"></a>
-<span class="sourceLineNo">1639</span>  }<a name="line.1639"></a>
-<span class="sourceLineNo">1640</span><a name="line.1640"></a>
-<span class="sourceLineNo">1641</span>  private long getMemStoreHeapSize() {<a name="line.1641"></a>
-<span class="sourceLineNo">1642</span>    return stores.values().stream().mapToLong(s -&gt; s.getMemStoreSize().getHeapSize()).sum();<a name="line.1642"></a>
-<span class="sourceLineNo">1643</span>  }<a name="line.1643"></a>
-<span class="sourceLineNo">1644</span><a name="line.1644"></a>
-<span class="sourceLineNo">1645</span>  /** Wait for all current flushes and compactions of the region to complete */<a name="line.1645"></a>
-<span class="sourceLineNo">1646</span>  // TODO HBASE-18906. Check the usage (if any) in Phoenix and expose this or give alternate way for<a name="line.1646"></a>
-<span class="sourceLineNo">1647</span>  // Phoenix needs.<a name="line.1647"></a>
-<span class="sourceLineNo">1648</span>  public void waitForFlushesAndCompactions() {<a name="line.1648"></a>
-<span class="sourceLineNo">1649</span>    synchronized (writestate) {<a name="line.1649"></a>
-<span class="sourceLineNo">1650</span>      if (this.writestate.readOnly) {<a name="line.1650"></a>
-<span class="sourceLineNo">1651</span>        // we should not wait for replayed flushed if we are read only (for example in case the<a name="line.1651"></a>
-<span class="sourceLineNo">1652</span>        // region is a secondary replica).<a name="line.1652"></a>
-<span class="sourceLineNo">1653</span>        return;<a name="line.1653"></a>
-<span class="sourceLineNo">1654</span>      }<a name="line.1654"></a>
-<span class="sourceLineNo">1655</span>      boolean interrupted = false;<a name="line.1655"></a>
-<span class="sourceLineNo">1656</span>      try {<a name="line.1656"></a>
-<span class="sourceLineNo">1657</span>        while (writestate.compacting.get() &gt; 0 || writestate.flushing) {<a name="line.1657"></a>
-<span class="sourceLineNo">1658</span>          LOG.debug("waiting for " + writestate.compacting + " compactions"<a name="line.1658"></a>
-<span class="sourceLineNo">1659</span>            + (writestate.flushing ? " &amp; cache flush" : "") + " to complete for region " + this);<a name="line.1659"></a>
-<span class="sourceLineNo">1660</span>          try {<a name="line.1660"></a>
-<span class="sourceLineNo">1661</span>            writestate.wait();<a name="line.1661"></a>
-<span class="sourceLineNo">1662</span>          } catch (InterruptedException iex) {<a name="line.1662"></a>
-<span class="sourceLineNo">1663</span>            // essentially ignore and propagate the interrupt back up<a name="line.1663"></a>
-<span class="sourceLineNo">1664</span>            LOG.warn("Interrupted while waiting");<a name="line.1664"></a>
-<span class="sourceLineNo">1665</span>            interrupted = true;<a name="line.1665"></a>
-<span class="sourceLineNo">1666</span>            break;<a name="line.1666"></a>
-<span class="sourceLineNo">1667</span>          }<a name="line.1667"></a>
-<span class="sourceLineNo">1668</span>        }<a name="line.1668"></a>
-<span class="sourceLineNo">1669</span>      } finally {<a name="line.1669"></a>
-<span class="sourceLineNo">1670</span>        if (interrupted) {<a name="line.1670"></a>
-<span class="sourceLineNo">1671</span>          Thread.currentThread().interrupt();<a name="line.1671"></a>
-<span class="sourceLineNo">1672</span>        }<a name="line.1672"></a>
-<span class="sourceLineNo">1673</span>      }<a name="line.1673"></a>
-<span class="sourceLineNo">1674</span>    }<a name="line.1674"></a>
-<span class="sourceLineNo">1675</span>  }<a name="line.1675"></a>
-<span class="sourceLineNo">1676</span><a name="line.1676"></a>
-<span class="sourceLineNo">1677</span>  /**<a name="line.1677"></a>
-<span class="sourceLineNo">1678</span>   * Wait for all current flushes of the region to complete<a name="line.1678"></a>
-<span class="sourceLineNo">1679</span>   */<a name="line.1679"></a>
-<span class="sourceLineNo">1680</span>  public void waitForFlushes() {<a name="line.1680"></a>
-<span class="sourceLineNo">1681</span>    waitForFlushes(0);// Unbound wait<a name="line.1681"></a>
-<span class="sourceLineNo">1682</span>  }<a name="line.1682"></a>
-<span class="sourceLineNo">1683</span><a name="line.1683"></a>
-<span class="sourceLineNo">1684</span>  @Override<a name="line.1684"></a>
-<span class="sourceLineNo">1685</span>  public boolean waitForFlushes(long timeout) {<a name="line.1685"></a>
-<span class="sourceLineNo">1686</span>    synchronized (writestate) {<a name="line.1686"></a>
-<span class="sourceLineNo">1687</span>      if (this.writestate.readOnly) {<a name="line.1687"></a>
-<span class="sourceLineNo">1688</span>        // we should not wait for replayed flushed if we are read only (for example in case the<a name="line.1688"></a>
-<span class="sourceLineNo">1689</span>        // region is a secondary replica).<a name="line.1689"></a>
-<span class="sourceLineNo">1690</span>        return true;<a name="line.1690"></a>
-<span class="sourceLineNo">1691</span>      }<a name="line.1691"></a>
-<span class="sourceLineNo">1692</span>      if (!writestate.flushing) return true;<a name="line.1692"></a>
-<span class="sourceLineNo">1693</span>      long start = System.currentTimeMillis();<a name="line.1693"></a>
-<span class="sourceLineNo">1694</span>      long duration = 0;<a name="line.1694"></a>
-<span class="sourceLineNo">1695</span>      boolean interrupted = false;<a name="line.1695"></a>
-<span class="sourceLineNo">1696</span>      LOG.debug("waiting for cache flush to complete for region " + this);<a name="line.1696"></a>
-<span class="sourceLineNo">1697</span>      try {<a name="line.1697"></a>
-<span class="sourceLineNo">1698</span>        while (writestate.flushing) {<a name="line.1698"></a>
-<span class="sourceLineNo">1699</span>          if (timeout &gt; 0 &amp;&amp; duration &gt;= timeout) break;<a name="line.1699"></a>
-<span class="sourceLineNo">1700</span>          try {<a name="line.1700"></a>
-<span class="sourceLineNo">1701</span>            long toWait = timeout == 0 ? 0 : (timeout - duration);<a name="line.1701"></a>
-<span class="sourceLineNo">1702</span>            writestate.wait(toWait);<a name="line.1702"></a>
-<span class="sourceLineNo">1703</span>          } catch (InterruptedException iex) {<a name="line.1703"></a>
-<span class="sourceLineNo">1704</span>            // essentially ignore and propagate the interrupt back up<a name="line.1704"></a>
-<span class="sourceLineNo">1705</span>            LOG.warn("Interrupted while waiting");<a name="line.1705"></a>
-<span class="sourceLineNo">1706</span>            interrupted = true;<a name="line.1706"></a>
-<span class="sourceLineNo">1707</span>            break;<a name="line.1707"></a>
-<span class="sourceLineNo">1708</span>          } finally {<a name="line.1708"></a>
-<span class="sourceLineNo">1709</span>            duration = System.currentTimeMillis() - start;<a name="line.1709"></a>
-<span class="sourceLineNo">1710</span>          }<a name="line.1710"></a>
-<span class="sourceLineNo">1711</span>        }<a name="line.1711"></a>
-<span class="sourceLineNo">1712</span>      } finally {<a name="line.1712"></a>
-<span class="sourceLineNo">1713</span>        if (interrupted) {<a name="line.1713"></a>
-<span class="sourceLineNo">1714</span>          Thread.currentThread().interrupt();<a name="line.1714"></a>
-<span class="sourceLineNo">1715</span>        }<a name="line.1715"></a>
-<span class="sourceLineNo">1716</span>      }<a name="line.1716"></a>
-<span class="sourceLineNo">1717</span>      LOG.debug("Waited " + duration + " ms for flush to complete");<a name="line.1717"></a>
-<span class="sourceLineNo">1718</span>      return !(writestate.flushing);<a name="line.1718"></a>
-<span class="sourceLineNo">1719</span>    }<a name="line.1719"></a>
-<span class="sourceLineNo">1720</span>  }<a name="line.1720"></a>
-<span class="sourceLineNo">1721</span><a name="line.1721"></a>
-<span class="sourceLineNo">1722</span>  protected ThreadPoolExecutor getStoreOpenAndCloseThreadPool(<a name="line.1722"></a>
-<span class="sourceLineNo">1723</span>      final String threadNamePrefix) {<a name="line.1723"></a>
-<span class="sourceLineNo">1724</span>    int numStores = Math.max(1, this.htableDescriptor.getColumnFamilyCount());<a name="line.1724"></a>
-<span class="sourceLineNo">1725</span>    int maxThreads = Math.min(numStores,<a name="line.1725"></a>
-<span class="sourceLineNo">1726</span>        conf.getInt(HConstants.HSTORE_OPEN_AND_CLOSE_THREADS_MAX,<a name="line.1726"></a>
-<span class="sourceLineNo">1727</span>            HConstants.DEFAULT_HSTORE_OPEN_AND_CLOSE_THREADS_MAX));<a name="line.1727"></a>
-<span class="sourceLineNo">1728</span>    return getOpenAndCloseThreadPool(maxThreads, threadNamePrefix);<a name="line.1728"></a>
-<span class="sourceLineNo">1729</span>  }<a name="line.1729"></a>
-<span class="sourceLineNo">1730</span><a name="line.1730"></a>
-<span class="sourceLineNo">1731</span>  protected ThreadPoolExecutor getStoreFileOpenAndCloseThreadPool(<a name="line.1731"></a>
-<span class="sourceLineNo">1732</span>      final String threadNamePrefix) {<a name="line.1732"></a>
-<span class="sourceLineNo">1733</span>    int numStores = Math.max(1, this.htableDescriptor.getColumnFamilyCount());<a name="line.1733"></a>
-<span class="sourceLineNo">1734</span>    int maxThreads = Math.max(1,<a name="line.1734"></a>
-<span class="sourceLineNo">1735</span>        conf.getInt(HConstants.HSTORE_OPEN_AND_CLOSE_THREADS_MAX,<a name="line.1735"></a>
-<span class="sourceLineNo">1736</span>            HConstants.DEFAULT_HSTORE_OPEN_AND_CLOSE_THREADS_MAX)<a name="line.1736"></a>
-<span class="sourceLineNo">1737</span>            / numStores);<a name="line.1737"></a>
-<span class="sourceLineNo">1738</span>    return getOpenAndCloseThreadPool(maxThreads, threadNamePrefix);<a name="line.1738"></a>
-<span class="sourceLineNo">1739</span>  }<a name="line.1739"></a>
-<span class="sourceLineNo">1740</span><a name="line.1740"></a>
-<span class="sourceLineNo">1741</span>  static ThreadPoolExecutor getOpenAndCloseThreadPool(int maxThreads,<a name="line.1741"></a>
-<span class="sourceLineNo">1742</span>      final String threadNamePrefix) {<a name="line.1742"></a>
-<span class="sourceLineNo">1743</span>    return Threads.getBoundedCachedThreadPool(maxThreads, 30L, TimeUnit.SECONDS,<a name="line.1743"></a>
-<span class="sourceLineNo">1744</span>      new ThreadFactory() {<a name="line.1744"></a>
-<span class="sourceLineNo">1745</span>        private int count = 1;<a name="line.1745"></a>
-<span class="sourceLineNo">1746</span><a name="line.1746"></a>
-<span class="sourceLineNo">1747</span>        @Override<a name="line.1747"></a>
-<span class="sourceLineNo">1748</span>        public Thread newThread(Runnable r) {<a name="line.1748"></a>
-<span class="sourceLineNo">1749</span>          return new Thread(r, threadNamePrefix + "-" + count++);<a name="line.1749"></a>
-<span class="sourceLineNo">1750</span>        }<a name="line.1750"></a>
-<span class="sourceLineNo">1751</span>      });<a name="line.1751"></a>
-<span class="sourceLineNo">1752</span>  }<a name="line.1752"></a>
-<span class="sourceLineNo">1753</span><a name="line.1753"></a>
-<span class="sourceLineNo">1754</span>   /**<a name="line.1754"></a>
-<span class="sourceLineNo">1755</span>    * @return True if its worth doing a flush before we put up the close flag.<a name="line.1755"></a>
-<span class="sourceLineNo">1756</span>    */<a name="line.1756"></a>
-<span class="sourceLineNo">1757</span>  private boolean worthPreFlushing() {<a name="line.1757"></a>
-<span class="sourceLineNo">1758</span>    return this.memstoreDataSize.get() &gt;<a name="line.1758"></a>
-<span class="sourceLineNo">1759</span>      this.conf.getLong("hbase.hregion.preclose.flush.size", 1024 * 1024 * 5);<a name="line.1759"></a>
-<span class="sourceLineNo">1760</span>  }<a name="line.1760"></a>
-<span class="sourceLineNo">1761</span><a name="line.1761"></a>
-<span class="sourceLineNo">1762</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.1762"></a>
-<span class="sourceLineNo">1763</span>  // HRegion accessors<a name="line.1763"></a>
-<span class="sourceLineNo">1764</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.1764"></a>
-<span class="sourceLineNo">1765</span><a name="line.1765"></a>
-<span class="sourceLineNo">1766</span>  @Override<a name="line.1766"></a>
-<span class="sourceLineNo">1767</span>  public TableDescriptor getTableDescriptor() {<a name="line.1767"></a>
-<span class="sourceLineNo">1768</span>    return this.htableDescriptor;<a name="line.1768"></a>
-<span class="sourceLineNo">1769</span>  }<a name="line.1769"></a>
-<span class="sourceLineNo">1770</span><a name="line.1770"></a>
-<span class="sourceLineNo">1771</span>  @VisibleForTesting<a name="line.1771"></a>
-<span class="sourceLineNo">1772</span>  void setTableDescriptor(TableDescriptor desc) {<a name="line.1772"></a>
-<span class="sourceLineNo">1773</span>    htableDescriptor = desc;<a name="line.1773"></a>
-<span class="sourceLineNo">1774</span>  }<a name="line.1774"></a>
-<span class="sourceLineNo">1775</span><a name="line.1775"></a>
-<span class="sourceLineNo">1776</span>  /** @return WAL in use for this region */<a name="line.1776"></a>
-<span class="sourceLineNo">1777</span>  public WAL getWAL() {<a name="line.1777"></a>
-<span class="sourceLineNo">1778</span>    return this.wal;<a name="line.1778"></a>
-<span class="sourceLineNo">1779</span>  }<a name="line.1779"></a>
-<span class="sourceLineNo">1780</span><a name="line.1780"></a>
-<span class="sourceLineNo">1781</span>  /**<a name="line.1781"></a>
-<span class="sourceLineNo">1782</span>   * @return split policy for this region.<a name="line.1782"></a>
+<span class="sourceLineNo">1616</span>      if (this.metricsRegion != null) {<a name="line.1616"></a>
+<span class="sourceLineNo">1617</span>        this.metricsRegion.close();<a name="line.1617"></a>
+<span class="sourceLineNo">1618</span>      }<a name="line.1618"></a>
+<span class="sourceLineNo">1619</span>      if (this.metricsRegionWrapper != null) {<a name="line.1619"></a>
+<span class="sourceLineNo">1620</span>        Closeables.close(this.metricsRegionWrapper, true);<a name="line.1620"></a>
+<span class="sourceLineNo">1621</span>      }<a name="line.1621"></a>
+<span class="sourceLineNo">1622</span>      status.markComplete("Closed");<a name="line.1622"></a>
+<span class="sourceLineNo">1623</span>      LOG.info("Closed " + this);<a name="line.1623"></a>
+<span class="sourceLineNo">1624</span>      return result;<a name="line.1624"></a>
+<span class="sourceLineNo">1625</span>    } finally {<a name="line.1625"></a>
+<span class="sourceLineNo">1626</span>      lock.writeLock().unlock();<a name="line.1626"></a>
+<span class="sourceLineNo">1627</span>    }<a name="line.1627"></a>
+<span class="sourceLineNo">1628</span>  }<a name="line.1628"></a>
+<span class="sourceLineNo">1629</span><a name="line.1629"></a>
+<span class="sourceLineNo">1630</span>  private long getMemStoreHeapSize() {<a name="line.1630"></a>
+<span class="sourceLineNo">1631</span>    return stores.values().stream().mapToLong(s -&gt; s.getMemStoreSize().getHeapSize()).sum();<a name="line.1631"></a>
+<span class="sourceLineNo">1632</span>  }<a name="line.1632"></a>
+<span class="sourceLineNo">1633</span><a name="line.1633"></a>
+<span class="sourceLineNo">1634</span>  /** Wait for all current flushes and compactions of the region to complete */<a name="line.1634"></a>
+<span class="sourceLineNo">1635</span>  // TODO HBASE-18906. Check the usage (if any) in Phoenix and expose this or give alternate way for<a name="line.1635"></a>
+<span class="sourceLineNo">1636</span>  // Phoenix needs.<a name="line.1636"></a>
+<span class="sourceLineNo">1637</span>  public void waitForFlushesAndCompactions() {<a name="line.1637"></a>
+<span class="sourceLineNo">1638</span>    synchronized (writestate) {<a name="line.1638"></a>
+<span class="sourceLineNo">1639</span>      if (this.writestate.readOnly) {<a name="line.1639"></a>
+<span class="sourceLineNo">1640</span>        // we should not wait for replayed flushed if we are read only (for example in case the<a name="line.1640"></a>
+<span class="sourceLineNo">1641</span>        // region is a secondary replica).<a name="line.1641"></a>
+<span class="sourceLineNo">1642</span>        return;<a name="line.1642"></a>
+<span class="sourceLineNo">1643</span>      }<a name="line.1643"></a>
+<span class="sourceLineNo">1644</span>      boolean interrupted = false;<a name="line.1644"></a>
+<span class="sourceLineNo">1645</span>      try {<a name="line.1645"></a>
+<span class="sourceLineNo">1646</span>        while (writestate.compacting.get() &gt; 0 || writestate.flushing) {<a name="line.1646"></a>
+<span class="sourceLineNo">1647</span>          LOG.debug("waiting for " + writestate.compacting + " compactions"<a name="line.1647"></a>
+<span class="sourceLineNo">1648</span>            + (writestate.flushing ? " &amp; cache flush" : "") + " to complete for region " + this);<a name="line.1648"></a>
+<span class="sourceLineNo">1649</span>          try {<a name="line.1649"></a>
+<span class="sourceLineNo">1650</span>            writestate.wait();<a name="line.1650"></a>
+<span class="sourceLineNo">1651</span>          } catch (InterruptedException iex) {<a name="line.1651"></a>
+<span class="sourceLineNo">1652</span>            // essentially ignore and propagate the interrupt back up<a name="line.1652"></a>
+<span class="sourceLineNo">1653</span>            LOG.warn("Interrupted while waiting");<a name="line.1653"></a>
+<span class="sourceLineNo">1654</span>            interrupted = true;<a name="line.1654"></a>
+<span class="sourceLineNo">1655</span>            break;<a name="line.1655"></a>
+<span class="sourceLineNo">1656</span>          }<a name="line.1656"></a>
+<span class="sourceLineNo">1657</span>        }<a name="line.1657"></a>
+<span class="sourceLineNo">1658</span>      } finally {<a name="line.1658"></a>
+<span class="sourceLineNo">1659</span>        if (interrupted) {<a name="line.1659"></a>
+<span class="sourceLineNo">1660</span>          Thread.currentThread().interrupt();<a name="line.1660"></a>
+<span class="sourceLineNo">1661</span>        }<a name="line.1661"></a>
+<span class="sourceLineNo">1662</span>      }<a name="line.1662"></a>
+<span class="sourceLineNo">1663</span>    }<a name="line.1663"></a>
+<span class="sourceLineNo">1664</span>  }<a name="line.1664"></a>
+<span class="sourceLineNo">1665</span><a name="line.1665"></a>
+<span class="sourceLineNo">1666</span>  /**<a name="line.1666"></a>
+<span class="sourceLineNo">1667</span>   * Wait for all current flushes of the region to complete<a name="line.1667"></a>
+<span class="sourceLineNo">1668</span>   */<a name="line.1668"></a>
+<span class="sourceLineNo">1669</span>  public void waitForFlushes() {<a name="line.1669"></a>
+<span class="sourceLineNo">1670</span>    waitForFlushes(0);// Unbound wait<a name="line.1670"></a>
+<span class="sourceLineNo">1671</span>  }<a name="line.1671"></a>
+<span class="sourceLineNo">1672</span><a name="line.1672"></a>
+<span class="sourceLineNo">1673</span>  @Override<a name="line.1673"></a>
+<span class="sourceLineNo">1674</span>  public boolean waitForFlushes(long timeout) {<a name="line.1674"></a>
+<span class="sourceLineNo">1675</span>    synchronized (writestate) {<a name="line.1675"></a>
+<span class="sourceLineNo">1676</span>      if (this.writestate.readOnly) {<a name="line.1676"></a>
+<span class="sourceLineNo">1677</span>        // we should not wait for replayed flushed if we are read only (for example in case the<a name="line.1677"></a>
+<span class="sourceLineNo">1678</span>        // region is a secondary replica).<a name="line.1678"></a>
+<span class="sourceLineNo">1679</span>        return true;<a name="line.1679"></a>
+<span class="sourceLineNo">1680</span>      }<a name="line.1680"></a>
+<span class="sourceLineNo">1681</span>      if (!writestate.flushing) return true;<a name="line.1681"></a>
+<span class="sourceLineNo">1682</span>      long start = System.currentTimeMillis();<a name="line.1682"></a>
+<span class="sourceLineNo">1683</span>      long duration = 0;<a name="line.1683"></a>
+<span class="sourceLineNo">1684</span>      boolean interrupted = false;<a name="line.1684"></a>
+<span class="sourceLineNo">1685</span>      LOG.debug("waiting for cache flush to complete for region " + this);<a name="line.1685"></a>
+<span class="sourceLineNo">1686</span>      try {<a name="line.1686"></a>
+<span class="sourceLineNo">1687</span>        while (writestate.flushing) {<a name="line.1687"></a>
+<span class="sourceLineNo">1688</span>          if (timeout &gt; 0 &amp;&amp; duration &gt;= timeout) break;<a name="line.1688"></a>
+<span class="sourceLineNo">1689</span>          try {<a name="line.1689"></a>
+<span class="sourceLineNo">1690</span>            long toWait = timeout == 0 ? 0 : (timeout - duration);<a name="line.1690"></a>
+<span class="sourceLineNo">1691</span>            writestate.wait(toWait);<a name="line.1691"></a>
+<span class="sourceLineNo">1692</span>          } catch (InterruptedException iex) {<a name="line.1692"></a>
+<span class="sourceLineNo">1693</span>            // essentially ignore and propagate the interrupt back up<a name="line.1693"></a>
+<span class="sourceLineNo">1694</span>            LOG.warn("Interrupted while waiting");<a name="line.1694"></a>
+<span class="sourceLineNo">1695</span>            interrupted = true;<a name="line.1695"></a>
+<span class="sourceLineNo">1696</span>            break;<a name="line.1696"></a>
+<span class="sourceLineNo">1697</span>          } finally {<a name="line.1697"></a>
+<span class="sourceLineNo">1698</span>            duration = System.currentTimeMillis() - start;<a name="line.1698"></a>
+<span class="sourceLineNo">1699</span>          }<a name="line.1699"></a>
+<span class="sourceLineNo">1700</span>        }<a name="line.1700"></a>
+<span class="sourceLineNo">1701</span>      } finally {<a name="line.1701"></a>
+<span class="sourceLineNo">1702</span>        if (interrupted) {<a name="line.1702"></a>
+<span class="sourceLineNo">1703</span>          Thread.currentThread().interrupt();<a name="line.1703"></a>
+<span class="sourceLineNo">1704</span>        }<a name="line.1704"></a>
+<span class="sourceLineNo">1705</span>      }<a name="line.1705"></a>
+<span class="sourceLineNo">1706</span>      LOG.debug("Waited " + duration + " ms for flush to complete");<a name="line.1706"></a>
+<span class="sourceLineNo">1707</span>      return !(writestate.flushing);<a name="line.1707"></a>
+<span class="sourceLineNo">1708</span>    }<a name="line.1708"></a>
+<span class="sourceLineNo">1709</span>  }<a name="line.1709"></a>
+<span class="sourceLineNo">1710</span><a name="line.1710"></a>
+<span class="sourceLineNo">1711</span>  protected ThreadPoolExecutor getStoreOpenAndCloseThreadPool(<a name="line.1711"></a>
+<span class="sourceLineNo">1712</span>      final String threadNamePrefix) {<a name="line.1712"></a>
+<span class="sourceLineNo">1713</span>    int numStores = Math.max(1, this.htableDescriptor.getColumnFamilyCount());<a name="line.1713"></a>
+<span class="sourceLineNo">1714</sp

<TRUNCATED>

Mime
View raw message