hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [25/51] [partial] hbase-site git commit: Published site at .
Date Sun, 03 Dec 2017 15:18:35 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/c54c242b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.MutationBatchOperation.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.MutationBatchOperation.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.MutationBatchOperation.html
index 3edfbef..9707b2c 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.MutationBatchOperation.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.MutationBatchOperation.html
@@ -2459,5936 +2459,5935 @@
 <span class="sourceLineNo">2451</span>      }<a name="line.2451"></a>
 <span class="sourceLineNo">2452</span><a name="line.2452"></a>
 <span class="sourceLineNo">2453</span>      for (HStore s : storesToFlush) {<a name="line.2453"></a>
-<span class="sourceLineNo">2454</span>        MemStoreSize flushableSize = s.getFlushableSize();<a name="line.2454"></a>
-<span class="sourceLineNo">2455</span>        totalSizeOfFlushableStores.incMemStoreSize(flushableSize);<a name="line.2455"></a>
-<span class="sourceLineNo">2456</span>        storeFlushCtxs.put(s.getColumnFamilyDescriptor().getName(),<a name="line.2456"></a>
-<span class="sourceLineNo">2457</span>          s.createFlushContext(flushOpSeqId, tracker));<a name="line.2457"></a>
-<span class="sourceLineNo">2458</span>        // for writing stores to WAL<a name="line.2458"></a>
-<span class="sourceLineNo">2459</span>        committedFiles.put(s.getColumnFamilyDescriptor().getName(), null);<a name="line.2459"></a>
-<span class="sourceLineNo">2460</span>        storeFlushableSize.put(s.getColumnFamilyDescriptor().getName(), flushableSize);<a name="line.2460"></a>
-<span class="sourceLineNo">2461</span>      }<a name="line.2461"></a>
-<span class="sourceLineNo">2462</span><a name="line.2462"></a>
-<span class="sourceLineNo">2463</span>      // write the snapshot start to WAL<a name="line.2463"></a>
-<span class="sourceLineNo">2464</span>      if (wal != null &amp;&amp; !writestate.readOnly) {<a name="line.2464"></a>
-<span class="sourceLineNo">2465</span>        FlushDescriptor desc = ProtobufUtil.toFlushDescriptor(FlushAction.START_FLUSH,<a name="line.2465"></a>
-<span class="sourceLineNo">2466</span>            getRegionInfo(), flushOpSeqId, committedFiles);<a name="line.2466"></a>
-<span class="sourceLineNo">2467</span>        // No sync. Sync is below where no updates lock and we do FlushAction.COMMIT_FLUSH<a name="line.2467"></a>
-<span class="sourceLineNo">2468</span>        WALUtil.writeFlushMarker(wal, this.getReplicationScope(), getRegionInfo(), desc, false,<a name="line.2468"></a>
-<span class="sourceLineNo">2469</span>            mvcc);<a name="line.2469"></a>
-<span class="sourceLineNo">2470</span>      }<a name="line.2470"></a>
-<span class="sourceLineNo">2471</span><a name="line.2471"></a>
-<span class="sourceLineNo">2472</span>      // Prepare flush (take a snapshot)<a name="line.2472"></a>
-<span class="sourceLineNo">2473</span>      for (StoreFlushContext flush : storeFlushCtxs.values()) {<a name="line.2473"></a>
-<span class="sourceLineNo">2474</span>        flush.prepare();<a name="line.2474"></a>
-<span class="sourceLineNo">2475</span>      }<a name="line.2475"></a>
-<span class="sourceLineNo">2476</span>    } catch (IOException ex) {<a name="line.2476"></a>
-<span class="sourceLineNo">2477</span>      doAbortFlushToWAL(wal, flushOpSeqId, committedFiles);<a name="line.2477"></a>
-<span class="sourceLineNo">2478</span>      throw ex;<a name="line.2478"></a>
-<span class="sourceLineNo">2479</span>    } finally {<a name="line.2479"></a>
-<span class="sourceLineNo">2480</span>      this.updatesLock.writeLock().unlock();<a name="line.2480"></a>
-<span class="sourceLineNo">2481</span>    }<a name="line.2481"></a>
-<span class="sourceLineNo">2482</span>    String s = "Finished memstore snapshotting " + this + ", syncing WAL and waiting on mvcc, " +<a name="line.2482"></a>
-<span class="sourceLineNo">2483</span>        "flushsize=" + totalSizeOfFlushableStores;<a name="line.2483"></a>
-<span class="sourceLineNo">2484</span>    status.setStatus(s);<a name="line.2484"></a>
-<span class="sourceLineNo">2485</span>    doSyncOfUnflushedWALChanges(wal, getRegionInfo());<a name="line.2485"></a>
-<span class="sourceLineNo">2486</span>    return new PrepareFlushResult(storeFlushCtxs, committedFiles, storeFlushableSize, startTime,<a name="line.2486"></a>
-<span class="sourceLineNo">2487</span>        flushOpSeqId, flushedSeqId, totalSizeOfFlushableStores);<a name="line.2487"></a>
-<span class="sourceLineNo">2488</span>  }<a name="line.2488"></a>
-<span class="sourceLineNo">2489</span><a name="line.2489"></a>
-<span class="sourceLineNo">2490</span>  /**<a name="line.2490"></a>
-<span class="sourceLineNo">2491</span>   * Utility method broken out of internalPrepareFlushCache so that method is smaller.<a name="line.2491"></a>
-<span class="sourceLineNo">2492</span>   */<a name="line.2492"></a>
-<span class="sourceLineNo">2493</span>  private void logFatLineOnFlush(Collection&lt;HStore&gt; storesToFlush, long sequenceId) {<a name="line.2493"></a>
-<span class="sourceLineNo">2494</span>    if (!LOG.isInfoEnabled()) {<a name="line.2494"></a>
-<span class="sourceLineNo">2495</span>      return;<a name="line.2495"></a>
-<span class="sourceLineNo">2496</span>    }<a name="line.2496"></a>
-<span class="sourceLineNo">2497</span>    // Log a fat line detailing what is being flushed.<a name="line.2497"></a>
-<span class="sourceLineNo">2498</span>    StringBuilder perCfExtras = null;<a name="line.2498"></a>
-<span class="sourceLineNo">2499</span>    if (!isAllFamilies(storesToFlush)) {<a name="line.2499"></a>
-<span class="sourceLineNo">2500</span>      perCfExtras = new StringBuilder();<a name="line.2500"></a>
-<span class="sourceLineNo">2501</span>      for (HStore store: storesToFlush) {<a name="line.2501"></a>
-<span class="sourceLineNo">2502</span>        perCfExtras.append("; ").append(store.getColumnFamilyName());<a name="line.2502"></a>
-<span class="sourceLineNo">2503</span>        perCfExtras.append("=")<a name="line.2503"></a>
-<span class="sourceLineNo">2504</span>            .append(StringUtils.byteDesc(store.getFlushableSize().getDataSize()));<a name="line.2504"></a>
-<span class="sourceLineNo">2505</span>      }<a name="line.2505"></a>
-<span class="sourceLineNo">2506</span>    }<a name="line.2506"></a>
-<span class="sourceLineNo">2507</span>    LOG.info("Flushing " + + storesToFlush.size() + "/" + stores.size() +<a name="line.2507"></a>
-<span class="sourceLineNo">2508</span>        " column families, memstore=" + StringUtils.byteDesc(this.memstoreDataSize.get()) +<a name="line.2508"></a>
-<span class="sourceLineNo">2509</span>        ((perCfExtras != null &amp;&amp; perCfExtras.length() &gt; 0)? perCfExtras.toString(): "") +<a name="line.2509"></a>
-<span class="sourceLineNo">2510</span>        ((wal != null) ? "" : "; WAL is null, using passed sequenceid=" + sequenceId));<a name="line.2510"></a>
-<span class="sourceLineNo">2511</span>  }<a name="line.2511"></a>
-<span class="sourceLineNo">2512</span><a name="line.2512"></a>
-<span class="sourceLineNo">2513</span>  private void doAbortFlushToWAL(final WAL wal, final long flushOpSeqId,<a name="line.2513"></a>
-<span class="sourceLineNo">2514</span>      final Map&lt;byte[], List&lt;Path&gt;&gt; committedFiles) {<a name="line.2514"></a>
-<span class="sourceLineNo">2515</span>    if (wal == null) return;<a name="line.2515"></a>
-<span class="sourceLineNo">2516</span>    try {<a name="line.2516"></a>
-<span class="sourceLineNo">2517</span>      FlushDescriptor desc = ProtobufUtil.toFlushDescriptor(FlushAction.ABORT_FLUSH,<a name="line.2517"></a>
-<span class="sourceLineNo">2518</span>          getRegionInfo(), flushOpSeqId, committedFiles);<a name="line.2518"></a>
-<span class="sourceLineNo">2519</span>      WALUtil.writeFlushMarker(wal, this.getReplicationScope(), getRegionInfo(), desc, false,<a name="line.2519"></a>
-<span class="sourceLineNo">2520</span>          mvcc);<a name="line.2520"></a>
-<span class="sourceLineNo">2521</span>    } catch (Throwable t) {<a name="line.2521"></a>
-<span class="sourceLineNo">2522</span>      LOG.warn("Received unexpected exception trying to write ABORT_FLUSH marker to WAL:" +<a name="line.2522"></a>
-<span class="sourceLineNo">2523</span>          StringUtils.stringifyException(t));<a name="line.2523"></a>
-<span class="sourceLineNo">2524</span>      // ignore this since we will be aborting the RS with DSE.<a name="line.2524"></a>
-<span class="sourceLineNo">2525</span>    }<a name="line.2525"></a>
-<span class="sourceLineNo">2526</span>    // we have called wal.startCacheFlush(), now we have to abort it<a name="line.2526"></a>
-<span class="sourceLineNo">2527</span>    wal.abortCacheFlush(this.getRegionInfo().getEncodedNameAsBytes());<a name="line.2527"></a>
-<span class="sourceLineNo">2528</span>  }<a name="line.2528"></a>
-<span class="sourceLineNo">2529</span><a name="line.2529"></a>
-<span class="sourceLineNo">2530</span>  /**<a name="line.2530"></a>
-<span class="sourceLineNo">2531</span>   * Sync unflushed WAL changes. See HBASE-8208 for details<a name="line.2531"></a>
-<span class="sourceLineNo">2532</span>   */<a name="line.2532"></a>
-<span class="sourceLineNo">2533</span>  private static void doSyncOfUnflushedWALChanges(final WAL wal, final RegionInfo hri)<a name="line.2533"></a>
-<span class="sourceLineNo">2534</span>  throws IOException {<a name="line.2534"></a>
-<span class="sourceLineNo">2535</span>    if (wal == null) {<a name="line.2535"></a>
-<span class="sourceLineNo">2536</span>      return;<a name="line.2536"></a>
-<span class="sourceLineNo">2537</span>    }<a name="line.2537"></a>
-<span class="sourceLineNo">2538</span>    try {<a name="line.2538"></a>
-<span class="sourceLineNo">2539</span>      wal.sync(); // ensure that flush marker is sync'ed<a name="line.2539"></a>
-<span class="sourceLineNo">2540</span>    } catch (IOException ioe) {<a name="line.2540"></a>
-<span class="sourceLineNo">2541</span>      wal.abortCacheFlush(hri.getEncodedNameAsBytes());<a name="line.2541"></a>
-<span class="sourceLineNo">2542</span>      throw ioe;<a name="line.2542"></a>
-<span class="sourceLineNo">2543</span>    }<a name="line.2543"></a>
-<span class="sourceLineNo">2544</span>  }<a name="line.2544"></a>
-<span class="sourceLineNo">2545</span><a name="line.2545"></a>
-<span class="sourceLineNo">2546</span>  /**<a name="line.2546"></a>
-<span class="sourceLineNo">2547</span>   * @return True if passed Set is all families in the region.<a name="line.2547"></a>
-<span class="sourceLineNo">2548</span>   */<a name="line.2548"></a>
-<span class="sourceLineNo">2549</span>  private boolean isAllFamilies(Collection&lt;HStore&gt; families) {<a name="line.2549"></a>
-<span class="sourceLineNo">2550</span>    return families == null || this.stores.size() == families.size();<a name="line.2550"></a>
-<span class="sourceLineNo">2551</span>  }<a name="line.2551"></a>
-<span class="sourceLineNo">2552</span><a name="line.2552"></a>
-<span class="sourceLineNo">2553</span>  /**<a name="line.2553"></a>
-<span class="sourceLineNo">2554</span>   * Writes a marker to WAL indicating a flush is requested but cannot be complete due to various<a name="line.2554"></a>
-<span class="sourceLineNo">2555</span>   * reasons. Ignores exceptions from WAL. Returns whether the write succeeded.<a name="line.2555"></a>
-<span class="sourceLineNo">2556</span>   * @param wal<a name="line.2556"></a>
-<span class="sourceLineNo">2557</span>   * @return whether WAL write was successful<a name="line.2557"></a>
-<span class="sourceLineNo">2558</span>   */<a name="line.2558"></a>
-<span class="sourceLineNo">2559</span>  private boolean writeFlushRequestMarkerToWAL(WAL wal, boolean writeFlushWalMarker) {<a name="line.2559"></a>
-<span class="sourceLineNo">2560</span>    if (writeFlushWalMarker &amp;&amp; wal != null &amp;&amp; !writestate.readOnly) {<a name="line.2560"></a>
-<span class="sourceLineNo">2561</span>      FlushDescriptor desc = ProtobufUtil.toFlushDescriptor(FlushAction.CANNOT_FLUSH,<a name="line.2561"></a>
-<span class="sourceLineNo">2562</span>        getRegionInfo(), -1, new TreeMap&lt;&gt;(Bytes.BYTES_COMPARATOR));<a name="line.2562"></a>
-<span class="sourceLineNo">2563</span>      try {<a name="line.2563"></a>
-<span class="sourceLineNo">2564</span>        WALUtil.writeFlushMarker(wal, this.getReplicationScope(), getRegionInfo(), desc, true,<a name="line.2564"></a>
-<span class="sourceLineNo">2565</span>            mvcc);<a name="line.2565"></a>
-<span class="sourceLineNo">2566</span>        return true;<a name="line.2566"></a>
-<span class="sourceLineNo">2567</span>      } catch (IOException e) {<a name="line.2567"></a>
-<span class="sourceLineNo">2568</span>        LOG.warn(getRegionInfo().getEncodedName() + " : "<a name="line.2568"></a>
-<span class="sourceLineNo">2569</span>            + "Received exception while trying to write the flush request to wal", e);<a name="line.2569"></a>
-<span class="sourceLineNo">2570</span>      }<a name="line.2570"></a>
-<span class="sourceLineNo">2571</span>    }<a name="line.2571"></a>
-<span class="sourceLineNo">2572</span>    return false;<a name="line.2572"></a>
-<span class="sourceLineNo">2573</span>  }<a name="line.2573"></a>
-<span class="sourceLineNo">2574</span><a name="line.2574"></a>
-<span class="sourceLineNo">2575</span>  @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="NN_NAKED_NOTIFY",<a name="line.2575"></a>
-<span class="sourceLineNo">2576</span>      justification="Intentional; notify is about completed flush")<a name="line.2576"></a>
-<span class="sourceLineNo">2577</span>  protected FlushResultImpl internalFlushCacheAndCommit(WAL wal, MonitoredTask status,<a name="line.2577"></a>
-<span class="sourceLineNo">2578</span>      PrepareFlushResult prepareResult, Collection&lt;HStore&gt; storesToFlush) throws IOException {<a name="line.2578"></a>
-<span class="sourceLineNo">2579</span>    // prepare flush context is carried via PrepareFlushResult<a name="line.2579"></a>
-<span class="sourceLineNo">2580</span>    TreeMap&lt;byte[], StoreFlushContext&gt; storeFlushCtxs = prepareResult.storeFlushCtxs;<a name="line.2580"></a>
-<span class="sourceLineNo">2581</span>    TreeMap&lt;byte[], List&lt;Path&gt;&gt; committedFiles = prepareResult.committedFiles;<a name="line.2581"></a>
-<span class="sourceLineNo">2582</span>    long startTime = prepareResult.startTime;<a name="line.2582"></a>
-<span class="sourceLineNo">2583</span>    long flushOpSeqId = prepareResult.flushOpSeqId;<a name="line.2583"></a>
-<span class="sourceLineNo">2584</span>    long flushedSeqId = prepareResult.flushedSeqId;<a name="line.2584"></a>
-<span class="sourceLineNo">2585</span><a name="line.2585"></a>
-<span class="sourceLineNo">2586</span>    String s = "Flushing stores of " + this;<a name="line.2586"></a>
-<span class="sourceLineNo">2587</span>    status.setStatus(s);<a name="line.2587"></a>
-<span class="sourceLineNo">2588</span>    if (LOG.isTraceEnabled()) LOG.trace(s);<a name="line.2588"></a>
-<span class="sourceLineNo">2589</span><a name="line.2589"></a>
-<span class="sourceLineNo">2590</span>    // Any failure from here on out will be catastrophic requiring server<a name="line.2590"></a>
-<span class="sourceLineNo">2591</span>    // restart so wal content can be replayed and put back into the memstore.<a name="line.2591"></a>
-<span class="sourceLineNo">2592</span>    // Otherwise, the snapshot content while backed up in the wal, it will not<a name="line.2592"></a>
-<span class="sourceLineNo">2593</span>    // be part of the current running servers state.<a name="line.2593"></a>
-<span class="sourceLineNo">2594</span>    boolean compactionRequested = false;<a name="line.2594"></a>
-<span class="sourceLineNo">2595</span>    long flushedOutputFileSize = 0;<a name="line.2595"></a>
-<span class="sourceLineNo">2596</span>    try {<a name="line.2596"></a>
-<span class="sourceLineNo">2597</span>      // A.  Flush memstore to all the HStores.<a name="line.2597"></a>
-<span class="sourceLineNo">2598</span>      // Keep running vector of all store files that includes both old and the<a name="line.2598"></a>
-<span class="sourceLineNo">2599</span>      // just-made new flush store file. The new flushed file is still in the<a name="line.2599"></a>
-<span class="sourceLineNo">2600</span>      // tmp directory.<a name="line.2600"></a>
-<span class="sourceLineNo">2601</span><a name="line.2601"></a>
-<span class="sourceLineNo">2602</span>      for (StoreFlushContext flush : storeFlushCtxs.values()) {<a name="line.2602"></a>
-<span class="sourceLineNo">2603</span>        flush.flushCache(status);<a name="line.2603"></a>
-<span class="sourceLineNo">2604</span>      }<a name="line.2604"></a>
-<span class="sourceLineNo">2605</span><a name="line.2605"></a>
-<span class="sourceLineNo">2606</span>      // Switch snapshot (in memstore) -&gt; new hfile (thus causing<a name="line.2606"></a>
-<span class="sourceLineNo">2607</span>      // all the store scanners to reset/reseek).<a name="line.2607"></a>
-<span class="sourceLineNo">2608</span>      Iterator&lt;HStore&gt; it = storesToFlush.iterator();<a name="line.2608"></a>
-<span class="sourceLineNo">2609</span>      // stores.values() and storeFlushCtxs have same order<a name="line.2609"></a>
-<span class="sourceLineNo">2610</span>      for (StoreFlushContext flush : storeFlushCtxs.values()) {<a name="line.2610"></a>
-<span class="sourceLineNo">2611</span>        boolean needsCompaction = flush.commit(status);<a name="line.2611"></a>
-<span class="sourceLineNo">2612</span>        if (needsCompaction) {<a name="line.2612"></a>
-<span class="sourceLineNo">2613</span>          compactionRequested = true;<a name="line.2613"></a>
-<span class="sourceLineNo">2614</span>        }<a name="line.2614"></a>
-<span class="sourceLineNo">2615</span>        byte[] storeName = it.next().getColumnFamilyDescriptor().getName();<a name="line.2615"></a>
-<span class="sourceLineNo">2616</span>        List&lt;Path&gt; storeCommittedFiles = flush.getCommittedFiles();<a name="line.2616"></a>
-<span class="sourceLineNo">2617</span>        committedFiles.put(storeName, storeCommittedFiles);<a name="line.2617"></a>
-<span class="sourceLineNo">2618</span>        // Flush committed no files, indicating flush is empty or flush was canceled<a name="line.2618"></a>
-<span class="sourceLineNo">2619</span>        if (storeCommittedFiles == null || storeCommittedFiles.isEmpty()) {<a name="line.2619"></a>
-<span class="sourceLineNo">2620</span>          MemStoreSize storeFlushableSize = prepareResult.storeFlushableSize.get(storeName);<a name="line.2620"></a>
-<span class="sourceLineNo">2621</span>          prepareResult.totalFlushableSize.decMemStoreSize(storeFlushableSize);<a name="line.2621"></a>
-<span class="sourceLineNo">2622</span>        }<a name="line.2622"></a>
-<span class="sourceLineNo">2623</span>        flushedOutputFileSize += flush.getOutputFileSize();<a name="line.2623"></a>
-<span class="sourceLineNo">2624</span>      }<a name="line.2624"></a>
-<span class="sourceLineNo">2625</span>      storeFlushCtxs.clear();<a name="line.2625"></a>
-<span class="sourceLineNo">2626</span><a name="line.2626"></a>
-<span class="sourceLineNo">2627</span>      // Set down the memstore size by amount of flush.<a name="line.2627"></a>
-<span class="sourceLineNo">2628</span>      this.decrMemStoreSize(prepareResult.totalFlushableSize);<a name="line.2628"></a>
-<span class="sourceLineNo">2629</span><a name="line.2629"></a>
-<span class="sourceLineNo">2630</span>      if (wal != null) {<a name="line.2630"></a>
-<span class="sourceLineNo">2631</span>        // write flush marker to WAL. If fail, we should throw DroppedSnapshotException<a name="line.2631"></a>
-<span class="sourceLineNo">2632</span>        FlushDescriptor desc = ProtobufUtil.toFlushDescriptor(FlushAction.COMMIT_FLUSH,<a name="line.2632"></a>
-<span class="sourceLineNo">2633</span>          getRegionInfo(), flushOpSeqId, committedFiles);<a name="line.2633"></a>
-<span class="sourceLineNo">2634</span>        WALUtil.writeFlushMarker(wal, this.getReplicationScope(), getRegionInfo(), desc, true,<a name="line.2634"></a>
-<span class="sourceLineNo">2635</span>            mvcc);<a name="line.2635"></a>
-<span class="sourceLineNo">2636</span>      }<a name="line.2636"></a>
-<span class="sourceLineNo">2637</span>    } catch (Throwable t) {<a name="line.2637"></a>
-<span class="sourceLineNo">2638</span>      // An exception here means that the snapshot was not persisted.<a name="line.2638"></a>
-<span class="sourceLineNo">2639</span>      // The wal needs to be replayed so its content is restored to memstore.<a name="line.2639"></a>
-<span class="sourceLineNo">2640</span>      // Currently, only a server restart will do this.<a name="line.2640"></a>
-<span class="sourceLineNo">2641</span>      // We used to only catch IOEs but its possible that we'd get other<a name="line.2641"></a>
-<span class="sourceLineNo">2642</span>      // exceptions -- e.g. HBASE-659 was about an NPE -- so now we catch<a name="line.2642"></a>
-<span class="sourceLineNo">2643</span>      // all and sundry.<a name="line.2643"></a>
-<span class="sourceLineNo">2644</span>      if (wal != null) {<a name="line.2644"></a>
-<span class="sourceLineNo">2645</span>        try {<a name="line.2645"></a>
-<span class="sourceLineNo">2646</span>          FlushDescriptor desc = ProtobufUtil.toFlushDescriptor(FlushAction.ABORT_FLUSH,<a name="line.2646"></a>
-<span class="sourceLineNo">2647</span>            getRegionInfo(), flushOpSeqId, committedFiles);<a name="line.2647"></a>
-<span class="sourceLineNo">2648</span>          WALUtil.writeFlushMarker(wal, this.replicationScope, getRegionInfo(), desc, false, mvcc);<a name="line.2648"></a>
-<span class="sourceLineNo">2649</span>        } catch (Throwable ex) {<a name="line.2649"></a>
-<span class="sourceLineNo">2650</span>          LOG.warn(getRegionInfo().getEncodedName() + " : "<a name="line.2650"></a>
-<span class="sourceLineNo">2651</span>              + "failed writing ABORT_FLUSH marker to WAL", ex);<a name="line.2651"></a>
-<span class="sourceLineNo">2652</span>          // ignore this since we will be aborting the RS with DSE.<a name="line.2652"></a>
-<span class="sourceLineNo">2653</span>        }<a name="line.2653"></a>
-<span class="sourceLineNo">2654</span>        wal.abortCacheFlush(this.getRegionInfo().getEncodedNameAsBytes());<a name="line.2654"></a>
-<span class="sourceLineNo">2655</span>      }<a name="line.2655"></a>
-<span class="sourceLineNo">2656</span>      DroppedSnapshotException dse = new DroppedSnapshotException("region: " +<a name="line.2656"></a>
-<span class="sourceLineNo">2657</span>          Bytes.toStringBinary(getRegionInfo().getRegionName()));<a name="line.2657"></a>
-<span class="sourceLineNo">2658</span>      dse.initCause(t);<a name="line.2658"></a>
-<span class="sourceLineNo">2659</span>      status.abort("Flush failed: " + StringUtils.stringifyException(t));<a name="line.2659"></a>
-<span class="sourceLineNo">2660</span><a name="line.2660"></a>
-<span class="sourceLineNo">2661</span>      // Callers for flushcache() should catch DroppedSnapshotException and abort the region server.<a name="line.2661"></a>
-<span class="sourceLineNo">2662</span>      // However, since we may have the region read lock, we cannot call close(true) here since<a name="line.2662"></a>
-<span class="sourceLineNo">2663</span>      // we cannot promote to a write lock. Instead we are setting closing so that all other region<a name="line.2663"></a>
-<span class="sourceLineNo">2664</span>      // operations except for close will be rejected.<a name="line.2664"></a>
-<span class="sourceLineNo">2665</span>      this.closing.set(true);<a name="line.2665"></a>
-<span class="sourceLineNo">2666</span><a name="line.2666"></a>
-<span class="sourceLineNo">2667</span>      if (rsServices != null) {<a name="line.2667"></a>
-<span class="sourceLineNo">2668</span>        // This is a safeguard against the case where the caller fails to explicitly handle aborting<a name="line.2668"></a>
-<span class="sourceLineNo">2669</span>        rsServices.abort("Replay of WAL required. Forcing server shutdown", dse);<a name="line.2669"></a>
-<span class="sourceLineNo">2670</span>      }<a name="line.2670"></a>
-<span class="sourceLineNo">2671</span><a name="line.2671"></a>
-<span class="sourceLineNo">2672</span>      throw dse;<a name="line.2672"></a>
-<span class="sourceLineNo">2673</span>    }<a name="line.2673"></a>
-<span class="sourceLineNo">2674</span><a name="line.2674"></a>
-<span class="sourceLineNo">2675</span>    // If we get to here, the HStores have been written.<a name="line.2675"></a>
-<span class="sourceLineNo">2676</span>    if (wal != null) {<a name="line.2676"></a>
-<span class="sourceLineNo">2677</span>      wal.completeCacheFlush(this.getRegionInfo().getEncodedNameAsBytes());<a name="line.2677"></a>
-<span class="sourceLineNo">2678</span>    }<a name="line.2678"></a>
-<span class="sourceLineNo">2679</span><a name="line.2679"></a>
-<span class="sourceLineNo">2680</span>    // Record latest flush time<a name="line.2680"></a>
-<span class="sourceLineNo">2681</span>    for (HStore store: storesToFlush) {<a name="line.2681"></a>
-<span class="sourceLineNo">2682</span>      this.lastStoreFlushTimeMap.put(store, startTime);<a name="line.2682"></a>
-<span class="sourceLineNo">2683</span>    }<a name="line.2683"></a>
-<span class="sourceLineNo">2684</span><a name="line.2684"></a>
-<span class="sourceLineNo">2685</span>    this.maxFlushedSeqId = flushedSeqId;<a name="line.2685"></a>
-<span class="sourceLineNo">2686</span>    this.lastFlushOpSeqId = flushOpSeqId;<a name="line.2686"></a>
-<span class="sourceLineNo">2687</span><a name="line.2687"></a>
-<span class="sourceLineNo">2688</span>    // C. Finally notify anyone waiting on memstore to clear:<a name="line.2688"></a>
-<span class="sourceLineNo">2689</span>    // e.g. checkResources().<a name="line.2689"></a>
-<span class="sourceLineNo">2690</span>    synchronized (this) {<a name="line.2690"></a>
-<span class="sourceLineNo">2691</span>      notifyAll(); // FindBugs NN_NAKED_NOTIFY<a name="line.2691"></a>
-<span class="sourceLineNo">2692</span>    }<a name="line.2692"></a>
-<span class="sourceLineNo">2693</span><a name="line.2693"></a>
-<span class="sourceLineNo">2694</span>    long time = EnvironmentEdgeManager.currentTime() - startTime;<a name="line.2694"></a>
-<span class="sourceLineNo">2695</span>    long memstoresize = this.memstoreDataSize.get();<a name="line.2695"></a>
-<span class="sourceLineNo">2696</span>    String msg = "Finished memstore flush of ~"<a name="line.2696"></a>
-<span class="sourceLineNo">2697</span>        + StringUtils.byteDesc(prepareResult.totalFlushableSize.getDataSize()) + "/"<a name="line.2697"></a>
-<span class="sourceLineNo">2698</span>        + prepareResult.totalFlushableSize.getDataSize() + ", currentsize="<a name="line.2698"></a>
-<span class="sourceLineNo">2699</span>        + StringUtils.byteDesc(memstoresize) + "/" + memstoresize<a name="line.2699"></a>
-<span class="sourceLineNo">2700</span>        + " for region " + this + " in " + time + "ms, sequenceid="<a name="line.2700"></a>
-<span class="sourceLineNo">2701</span>        + flushOpSeqId +  ", compaction requested=" + compactionRequested<a name="line.2701"></a>
-<span class="sourceLineNo">2702</span>        + ((wal == null) ? "; wal=null" : "");<a name="line.2702"></a>
-<span class="sourceLineNo">2703</span>    LOG.info(msg);<a name="line.2703"></a>
-<span class="sourceLineNo">2704</span>    status.setStatus(msg);<a name="line.2704"></a>
-<span class="sourceLineNo">2705</span><a name="line.2705"></a>
-<span class="sourceLineNo">2706</span>    if (rsServices != null &amp;&amp; rsServices.getMetrics() != null) {<a name="line.2706"></a>
-<span class="sourceLineNo">2707</span>      rsServices.getMetrics().updateFlush(time - startTime,<a name="line.2707"></a>
-<span class="sourceLineNo">2708</span>          prepareResult.totalFlushableSize.getDataSize(), flushedOutputFileSize);<a name="line.2708"></a>
-<span class="sourceLineNo">2709</span>    }<a name="line.2709"></a>
-<span class="sourceLineNo">2710</span><a name="line.2710"></a>
-<span class="sourceLineNo">2711</span>    return new FlushResultImpl(compactionRequested ?<a name="line.2711"></a>
-<span class="sourceLineNo">2712</span>        FlushResult.Result.FLUSHED_COMPACTION_NEEDED :<a name="line.2712"></a>
-<span class="sourceLineNo">2713</span>          FlushResult.Result.FLUSHED_NO_COMPACTION_NEEDED, flushOpSeqId);<a name="line.2713"></a>
-<span class="sourceLineNo">2714</span>  }<a name="line.2714"></a>
-<span class="sourceLineNo">2715</span><a name="line.2715"></a>
-<span class="sourceLineNo">2716</span>  /**<a name="line.2716"></a>
-<span class="sourceLineNo">2717</span>   * Method to safely get the next sequence number.<a name="line.2717"></a>
-<span class="sourceLineNo">2718</span>   * @return Next sequence number unassociated with any actual edit.<a name="line.2718"></a>
-<span class="sourceLineNo">2719</span>   * @throws IOException<a name="line.2719"></a>
-<span class="sourceLineNo">2720</span>   */<a name="line.2720"></a>
-<span class="sourceLineNo">2721</span>  @VisibleForTesting<a name="line.2721"></a>
-<span class="sourceLineNo">2722</span>  protected long getNextSequenceId(final WAL wal) throws IOException {<a name="line.2722"></a>
-<span class="sourceLineNo">2723</span>    WriteEntry we = mvcc.begin();<a name="line.2723"></a>
-<span class="sourceLineNo">2724</span>    mvcc.completeAndWait(we);<a name="line.2724"></a>
-<span class="sourceLineNo">2725</span>    return we.getWriteNumber();<a name="line.2725"></a>
-<span class="sourceLineNo">2726</span>  }<a name="line.2726"></a>
-<span class="sourceLineNo">2727</span><a name="line.2727"></a>
-<span class="sourceLineNo">2728</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.2728"></a>
-<span class="sourceLineNo">2729</span>  // get() methods for client use.<a name="line.2729"></a>
-<span class="sourceLineNo">2730</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.2730"></a>
-<span class="sourceLineNo">2731</span><a name="line.2731"></a>
-<span class="sourceLineNo">2732</span>  @Override<a name="line.2732"></a>
-<span class="sourceLineNo">2733</span>  public RegionScannerImpl getScanner(Scan scan) throws IOException {<a name="line.2733"></a>
-<span class="sourceLineNo">2734</span>   return getScanner(scan, null);<a name="line.2734"></a>
-<span class="sourceLineNo">2735</span>  }<a name="line.2735"></a>
-<span class="sourceLineNo">2736</span><a name="line.2736"></a>
-<span class="sourceLineNo">2737</span>  @Override<a name="line.2737"></a>
-<span class="sourceLineNo">2738</span>  public RegionScannerImpl getScanner(Scan scan, List&lt;KeyValueScanner&gt; additionalScanners)<a name="line.2738"></a>
-<span class="sourceLineNo">2739</span>      throws IOException {<a name="line.2739"></a>
-<span class="sourceLineNo">2740</span>    return getScanner(scan, additionalScanners, HConstants.NO_NONCE, HConstants.NO_NONCE);<a name="line.2740"></a>
-<span class="sourceLineNo">2741</span>  }<a name="line.2741"></a>
-<span class="sourceLineNo">2742</span><a name="line.2742"></a>
-<span class="sourceLineNo">2743</span>  private RegionScannerImpl getScanner(Scan scan, List&lt;KeyValueScanner&gt; additionalScanners,<a name="line.2743"></a>
-<span class="sourceLineNo">2744</span>      long nonceGroup, long nonce) throws IOException {<a name="line.2744"></a>
-<span class="sourceLineNo">2745</span>    startRegionOperation(Operation.SCAN);<a name="line.2745"></a>
-<span class="sourceLineNo">2746</span>    try {<a name="line.2746"></a>
-<span class="sourceLineNo">2747</span>      // Verify families are all valid<a name="line.2747"></a>
-<span class="sourceLineNo">2748</span>      if (!scan.hasFamilies()) {<a name="line.2748"></a>
-<span class="sourceLineNo">2749</span>        // Adding all families to scanner<a name="line.2749"></a>
-<span class="sourceLineNo">2750</span>        for (byte[] family : this.htableDescriptor.getColumnFamilyNames()) {<a name="line.2750"></a>
-<span class="sourceLineNo">2751</span>          scan.addFamily(family);<a name="line.2751"></a>
-<span class="sourceLineNo">2752</span>        }<a name="line.2752"></a>
-<span class="sourceLineNo">2753</span>      } else {<a name="line.2753"></a>
-<span class="sourceLineNo">2754</span>        for (byte[] family : scan.getFamilyMap().keySet()) {<a name="line.2754"></a>
-<span class="sourceLineNo">2755</span>          checkFamily(family);<a name="line.2755"></a>
-<span class="sourceLineNo">2756</span>        }<a name="line.2756"></a>
-<span class="sourceLineNo">2757</span>      }<a name="line.2757"></a>
-<span class="sourceLineNo">2758</span>      return instantiateRegionScanner(scan, additionalScanners, nonceGroup, nonce);<a name="line.2758"></a>
-<span class="sourceLineNo">2759</span>    } finally {<a name="line.2759"></a>
-<span class="sourceLineNo">2760</span>      closeRegionOperation(Operation.SCAN);<a name="line.2760"></a>
-<span class="sourceLineNo">2761</span>    }<a name="line.2761"></a>
-<span class="sourceLineNo">2762</span>  }<a name="line.2762"></a>
-<span class="sourceLineNo">2763</span><a name="line.2763"></a>
-<span class="sourceLineNo">2764</span>  protected RegionScanner instantiateRegionScanner(Scan scan,<a name="line.2764"></a>
-<span class="sourceLineNo">2765</span>      List&lt;KeyValueScanner&gt; additionalScanners) throws IOException {<a name="line.2765"></a>
-<span class="sourceLineNo">2766</span>    return instantiateRegionScanner(scan, additionalScanners, HConstants.NO_NONCE,<a name="line.2766"></a>
-<span class="sourceLineNo">2767</span>      HConstants.NO_NONCE);<a name="line.2767"></a>
-<span class="sourceLineNo">2768</span>  }<a name="line.2768"></a>
-<span class="sourceLineNo">2769</span><a name="line.2769"></a>
-<span class="sourceLineNo">2770</span>  protected RegionScannerImpl instantiateRegionScanner(Scan scan,<a name="line.2770"></a>
-<span class="sourceLineNo">2771</span>      List&lt;KeyValueScanner&gt; additionalScanners, long nonceGroup, long nonce) throws IOException {<a name="line.2771"></a>
-<span class="sourceLineNo">2772</span>    if (scan.isReversed()) {<a name="line.2772"></a>
-<span class="sourceLineNo">2773</span>      if (scan.getFilter() != null) {<a name="line.2773"></a>
-<span class="sourceLineNo">2774</span>        scan.getFilter().setReversed(true);<a name="line.2774"></a>
-<span class="sourceLineNo">2775</span>      }<a name="line.2775"></a>
-<span class="sourceLineNo">2776</span>      return new ReversedRegionScannerImpl(scan, additionalScanners, this);<a name="line.2776"></a>
-<span class="sourceLineNo">2777</span>    }<a name="line.2777"></a>
-<span class="sourceLineNo">2778</span>    return new RegionScannerImpl(scan, additionalScanners, this, nonceGroup, nonce);<a name="line.2778"></a>
-<span class="sourceLineNo">2779</span>  }<a name="line.2779"></a>
-<span class="sourceLineNo">2780</span><a name="line.2780"></a>
-<span class="sourceLineNo">2781</span>  /**<a name="line.2781"></a>
-<span class="sourceLineNo">2782</span>   * Prepare a delete for a row mutation processor<a name="line.2782"></a>
-<span class="sourceLineNo">2783</span>   * @param delete The passed delete is modified by this method. WARNING!<a name="line.2783"></a>
-<span class="sourceLineNo">2784</span>   * @throws IOException<a name="line.2784"></a>
-<span class="sourceLineNo">2785</span>   */<a name="line.2785"></a>
-<span class="sourceLineNo">2786</span>  public void prepareDelete(Delete delete) throws IOException {<a name="line.2786"></a>
-<span class="sourceLineNo">2787</span>    // Check to see if this is a deleteRow insert<a name="line.2787"></a>
-<span class="sourceLineNo">2788</span>    if(delete.getFamilyCellMap().isEmpty()){<a name="line.2788"></a>
-<span class="sourceLineNo">2789</span>      for(byte [] family : this.htableDescriptor.getColumnFamilyNames()){<a name="line.2789"></a>
-<span class="sourceLineNo">2790</span>        // Don't eat the timestamp<a name="line.2790"></a>
-<span class="sourceLineNo">2791</span>        delete.addFamily(family, delete.getTimeStamp());<a name="line.2791"></a>
-<span class="sourceLineNo">2792</span>      }<a name="line.2792"></a>
-<span class="sourceLineNo">2793</span>    } else {<a name="line.2793"></a>
-<span class="sourceLineNo">2794</span>      for(byte [] family : delete.getFamilyCellMap().keySet()) {<a name="line.2794"></a>
-<span class="sourceLineNo">2795</span>        if(family == null) {<a name="line.2795"></a>
-<span class="sourceLineNo">2796</span>          throw new NoSuchColumnFamilyException("Empty family is invalid");<a name="line.2796"></a>
-<span class="sourceLineNo">2797</span>        }<a name="line.2797"></a>
-<span class="sourceLineNo">2798</span>        checkFamily(family);<a name="line.2798"></a>
-<span class="sourceLineNo">2799</span>      }<a name="line.2799"></a>
-<span class="sourceLineNo">2800</span>    }<a name="line.2800"></a>
-<span class="sourceLineNo">2801</span>  }<a name="line.2801"></a>
-<span class="sourceLineNo">2802</span><a name="line.2802"></a>
-<span class="sourceLineNo">2803</span>  @Override<a name="line.2803"></a>
-<span class="sourceLineNo">2804</span>  public void delete(Delete delete) throws IOException {<a name="line.2804"></a>
-<span class="sourceLineNo">2805</span>    checkReadOnly();<a name="line.2805"></a>
-<span class="sourceLineNo">2806</span>    checkResources();<a name="line.2806"></a>
-<span class="sourceLineNo">2807</span>    startRegionOperation(Operation.DELETE);<a name="line.2807"></a>
-<span class="sourceLineNo">2808</span>    try {<a name="line.2808"></a>
-<span class="sourceLineNo">2809</span>      // All edits for the given row (across all column families) must happen atomically.<a name="line.2809"></a>
-<span class="sourceLineNo">2810</span>      doBatchMutate(delete);<a name="line.2810"></a>
-<span class="sourceLineNo">2811</span>    } finally {<a name="line.2811"></a>
-<span class="sourceLineNo">2812</span>      closeRegionOperation(Operation.DELETE);<a name="line.2812"></a>
-<span class="sourceLineNo">2813</span>    }<a name="line.2813"></a>
-<span class="sourceLineNo">2814</span>  }<a name="line.2814"></a>
-<span class="sourceLineNo">2815</span><a name="line.2815"></a>
-<span class="sourceLineNo">2816</span>  /**<a name="line.2816"></a>
-<span class="sourceLineNo">2817</span>   * Row needed by below method.<a name="line.2817"></a>
-<span class="sourceLineNo">2818</span>   */<a name="line.2818"></a>
-<span class="sourceLineNo">2819</span>  private static final byte [] FOR_UNIT_TESTS_ONLY = Bytes.toBytes("ForUnitTestsOnly");<a name="line.2819"></a>
-<span class="sourceLineNo">2820</span><a name="line.2820"></a>
-<span class="sourceLineNo">2821</span>  /**<a name="line.2821"></a>
-<span class="sourceLineNo">2822</span>   * This is used only by unit tests. Not required to be a public API.<a name="line.2822"></a>
-<span class="sourceLineNo">2823</span>   * @param familyMap map of family to edits for the given family.<a name="line.2823"></a>
-<span class="sourceLineNo">2824</span>   * @throws IOException<a name="line.2824"></a>
-<span class="sourceLineNo">2825</span>   */<a name="line.2825"></a>
-<span class="sourceLineNo">2826</span>  void delete(NavigableMap&lt;byte[], List&lt;Cell&gt;&gt; familyMap,<a name="line.2826"></a>
-<span class="sourceLineNo">2827</span>      Durability durability) throws IOException {<a name="line.2827"></a>
-<span class="sourceLineNo">2828</span>    Delete delete = new Delete(FOR_UNIT_TESTS_ONLY);<a name="line.2828"></a>
-<span class="sourceLineNo">2829</span>    delete.setFamilyCellMap(familyMap);<a name="line.2829"></a>
-<span class="sourceLineNo">2830</span>    delete.setDurability(durability);<a name="line.2830"></a>
-<span class="sourceLineNo">2831</span>    doBatchMutate(delete);<a name="line.2831"></a>
-<span class="sourceLineNo">2832</span>  }<a name="line.2832"></a>
-<span class="sourceLineNo">2833</span><a name="line.2833"></a>
-<span class="sourceLineNo">2834</span>  /**<a name="line.2834"></a>
-<span class="sourceLineNo">2835</span>   * Set up correct timestamps in the KVs in Delete object.<a name="line.2835"></a>
-<span class="sourceLineNo">2836</span>   * &lt;p&gt;Caller should have the row and region locks.<a name="line.2836"></a>
-<span class="sourceLineNo">2837</span>   * @param mutation<a name="line.2837"></a>
-<span class="sourceLineNo">2838</span>   * @param familyMap<a name="line.2838"></a>
-<span class="sourceLineNo">2839</span>   * @param byteNow<a name="line.2839"></a>
-<span class="sourceLineNo">2840</span>   * @throws IOException<a name="line.2840"></a>
-<span class="sourceLineNo">2841</span>   */<a name="line.2841"></a>
-<span class="sourceLineNo">2842</span>  public void prepareDeleteTimestamps(Mutation mutation, Map&lt;byte[], List&lt;Cell&gt;&gt; familyMap,<a name="line.2842"></a>
-<span class="sourceLineNo">2843</span>      byte[] byteNow) throws IOException {<a name="line.2843"></a>
-<span class="sourceLineNo">2844</span>    for (Map.Entry&lt;byte[], List&lt;Cell&gt;&gt; e : familyMap.entrySet()) {<a name="line.2844"></a>
-<span class="sourceLineNo">2845</span><a name="line.2845"></a>
-<span class="sourceLineNo">2846</span>      byte[] family = e.getKey();<a name="line.2846"></a>
-<span class="sourceLineNo">2847</span>      List&lt;Cell&gt; cells = e.getValue();<a name="line.2847"></a>
-<span class="sourceLineNo">2848</span>      assert cells instanceof RandomAccess;<a name="line.2848"></a>
-<span class="sourceLineNo">2849</span><a name="line.2849"></a>
-<span class="sourceLineNo">2850</span>      Map&lt;byte[], Integer&gt; kvCount = new TreeMap&lt;&gt;(Bytes.BYTES_COMPARATOR);<a name="line.2850"></a>
-<span class="sourceLineNo">2851</span>      int listSize = cells.size();<a name="line.2851"></a>
-<span class="sourceLineNo">2852</span>      for (int i=0; i &lt; listSize; i++) {<a name="line.2852"></a>
-<span class="sourceLineNo">2853</span>        Cell cell = cells.get(i);<a name="line.2853"></a>
-<span class="sourceLineNo">2854</span>        //  Check if time is LATEST, change to time of most recent addition if so<a name="line.2854"></a>
-<span class="sourceLineNo">2855</span>        //  This is expensive.<a name="line.2855"></a>
-<span class="sourceLineNo">2856</span>        if (cell.getTimestamp() == HConstants.LATEST_TIMESTAMP<a name="line.2856"></a>
-<span class="sourceLineNo">2857</span>            &amp;&amp; PrivateCellUtil.isDeleteType(cell)) {<a name="line.2857"></a>
-<span class="sourceLineNo">2858</span>          byte[] qual = CellUtil.cloneQualifier(cell);<a name="line.2858"></a>
-<span class="sourceLineNo">2859</span><a name="line.2859"></a>
-<span class="sourceLineNo">2860</span>          Integer count = kvCount.get(qual);<a name="line.2860"></a>
-<span class="sourceLineNo">2861</span>          if (count == null) {<a name="line.2861"></a>
-<span class="sourceLineNo">2862</span>            kvCount.put(qual, 1);<a name="line.2862"></a>
-<span class="sourceLineNo">2863</span>          } else {<a name="line.2863"></a>
-<span class="sourceLineNo">2864</span>            kvCount.put(qual, count + 1);<a name="line.2864"></a>
-<span class="sourceLineNo">2865</span>          }<a name="line.2865"></a>
-<span class="sourceLineNo">2866</span>          count = kvCount.get(qual);<a name="line.2866"></a>
-<span class="sourceLineNo">2867</span><a name="line.2867"></a>
-<span class="sourceLineNo">2868</span>          Get get = new Get(CellUtil.cloneRow(cell));<a name="line.2868"></a>
-<span class="sourceLineNo">2869</span>          get.setMaxVersions(count);<a name="line.2869"></a>
-<span class="sourceLineNo">2870</span>          get.addColumn(family, qual);<a name="line.2870"></a>
-<span class="sourceLineNo">2871</span>          if (coprocessorHost != null) {<a name="line.2871"></a>
-<span class="sourceLineNo">2872</span>            if (!coprocessorHost.prePrepareTimeStampForDeleteVersion(mutation, cell,<a name="line.2872"></a>
-<span class="sourceLineNo">2873</span>                byteNow, get)) {<a name="line.2873"></a>
-<span class="sourceLineNo">2874</span>              updateDeleteLatestVersionTimeStamp(cell, get, count, byteNow);<a name="line.2874"></a>
-<span class="sourceLineNo">2875</span>            }<a name="line.2875"></a>
-<span class="sourceLineNo">2876</span>          } else {<a name="line.2876"></a>
-<span class="sourceLineNo">2877</span>            updateDeleteLatestVersionTimeStamp(cell, get, count, byteNow);<a name="line.2877"></a>
-<span class="sourceLineNo">2878</span>          }<a name="line.2878"></a>
-<span class="sourceLineNo">2879</span>        } else {<a name="line.2879"></a>
-<span class="sourceLineNo">2880</span>          PrivateCellUtil.updateLatestStamp(cell, byteNow, 0);<a name="line.2880"></a>
-<span class="sourceLineNo">2881</span>        }<a name="line.2881"></a>
-<span class="sourceLineNo">2882</span>      }<a name="line.2882"></a>
-<span class="sourceLineNo">2883</span>    }<a name="line.2883"></a>
-<span class="sourceLineNo">2884</span>  }<a name="line.2884"></a>
-<span class="sourceLineNo">2885</span><a name="line.2885"></a>
-<span class="sourceLineNo">2886</span>  void updateDeleteLatestVersionTimeStamp(Cell cell, Get get, int count, byte[] byteNow)<a name="line.2886"></a>
-<span class="sourceLineNo">2887</span>      throws IOException {<a name="line.2887"></a>
-<span class="sourceLineNo">2888</span>    List&lt;Cell&gt; result = get(get, false);<a name="line.2888"></a>
-<span class="sourceLineNo">2889</span><a name="line.2889"></a>
-<span class="sourceLineNo">2890</span>    if (result.size() &lt; count) {<a name="line.2890"></a>
-<span class="sourceLineNo">2891</span>      // Nothing to delete<a name="line.2891"></a>
-<span class="sourceLineNo">2892</span>      PrivateCellUtil.updateLatestStamp(cell, byteNow, 0);<a name="line.2892"></a>
-<span class="sourceLineNo">2893</span>      return;<a name="line.2893"></a>
-<span class="sourceLineNo">2894</span>    }<a name="line.2894"></a>
-<span class="sourceLineNo">2895</span>    if (result.size() &gt; count) {<a name="line.2895"></a>
-<span class="sourceLineNo">2896</span>      throw new RuntimeException("Unexpected size: " + result.size());<a name="line.2896"></a>
-<span class="sourceLineNo">2897</span>    }<a name="line.2897"></a>
-<span class="sourceLineNo">2898</span>    Cell getCell = result.get(count - 1);<a name="line.2898"></a>
-<span class="sourceLineNo">2899</span>    PrivateCellUtil.setTimestamp(cell, getCell.getTimestamp());<a name="line.2899"></a>
-<span class="sourceLineNo">2900</span>  }<a name="line.2900"></a>
-<span class="sourceLineNo">2901</span><a name="line.2901"></a>
-<span class="sourceLineNo">2902</span>  @Override<a name="line.2902"></a>
-<span class="sourceLineNo">2903</span>  public void put(Put put) throws IOException {<a name="line.2903"></a>
-<span class="sourceLineNo">2904</span>    checkReadOnly();<a name="line.2904"></a>
-<span class="sourceLineNo">2905</span><a name="line.2905"></a>
-<span class="sourceLineNo">2906</span>    // Do a rough check that we have resources to accept a write.  The check is<a name="line.2906"></a>
-<span class="sourceLineNo">2907</span>    // 'rough' in that between the resource check and the call to obtain a<a name="line.2907"></a>
-<span class="sourceLineNo">2908</span>    // read lock, resources may run out.  For now, the thought is that this<a name="line.2908"></a>
-<span class="sourceLineNo">2909</span>    // will be extremely rare; we'll deal with it when it happens.<a name="line.2909"></a>
-<span class="sourceLineNo">2910</span>    checkResources();<a name="line.2910"></a>
-<span class="sourceLineNo">2911</span>    startRegionOperation(Operation.PUT);<a name="line.2911"></a>
-<span class="sourceLineNo">2912</span>    try {<a name="line.2912"></a>
-<span class="sourceLineNo">2913</span>      // All edits for the given row (across all column families) must happen atomically.<a name="line.2913"></a>
-<span class="sourceLineNo">2914</span>      doBatchMutate(put);<a name="line.2914"></a>
-<span class="sourceLineNo">2915</span>    } finally {<a name="line.2915"></a>
-<span class="sourceLineNo">2916</span>      closeRegionOperation(Operation.PUT);<a name="line.2916"></a>
-<span class="sourceLineNo">2917</span>    }<a name="line.2917"></a>
-<span class="sourceLineNo">2918</span>  }<a name="line.2918"></a>
-<span class="sourceLineNo">2919</span><a name="line.2919"></a>
-<span class="sourceLineNo">2920</span>  /**<a name="line.2920"></a>
-<span class="sourceLineNo">2921</span>   * Class that tracks the progress of a batch operations, accumulating status codes and tracking<a name="line.2921"></a>
-<span class="sourceLineNo">2922</span>   * the index at which processing is proceeding. These batch operations may get split into<a name="line.2922"></a>
-<span class="sourceLineNo">2923</span>   * mini-batches for processing.<a name="line.2923"></a>
-<span class="sourceLineNo">2924</span>   */<a name="line.2924"></a>
-<span class="sourceLineNo">2925</span>  private abstract static class BatchOperation&lt;T&gt; {<a name="line.2925"></a>
-<span class="sourceLineNo">2926</span>    protected final T[] operations;<a name="line.2926"></a>
-<span class="sourceLineNo">2927</span>    protected final OperationStatus[] retCodeDetails;<a name="line.2927"></a>
-<span class="sourceLineNo">2928</span>    protected final WALEdit[] walEditsFromCoprocessors;<a name="line.2928"></a>
-<span class="sourceLineNo">2929</span>    // reference family cell maps directly so coprocessors can mutate them if desired<a name="line.2929"></a>
-<span class="sourceLineNo">2930</span>    protected final Map&lt;byte[], List&lt;Cell&gt;&gt;[] familyCellMaps;<a name="line.2930"></a>
-<span class="sourceLineNo">2931</span><a name="line.2931"></a>
-<span class="sourceLineNo">2932</span>    protected final HRegion region;<a name="line.2932"></a>
-<span class="sourceLineNo">2933</span>    protected int nextIndexToProcess = 0;<a name="line.2933"></a>
-<span class="sourceLineNo">2934</span>    protected final ObservedExceptionsInBatch observedExceptions;<a name="line.2934"></a>
-<span class="sourceLineNo">2935</span>    //Durability of the batch (highest durability of all operations)<a name="line.2935"></a>
-<span class="sourceLineNo">2936</span>    protected Durability durability;<a name="line.2936"></a>
-<span class="sourceLineNo">2937</span>    protected boolean atomic = false;<a name="line.2937"></a>
-<span class="sourceLineNo">2938</span><a name="line.2938"></a>
-<span class="sourceLineNo">2939</span>    public BatchOperation(final HRegion region, T[] operations) {<a name="line.2939"></a>
-<span class="sourceLineNo">2940</span>      this.operations = operations;<a name="line.2940"></a>
-<span class="sourceLineNo">2941</span>      this.retCodeDetails = new OperationStatus[operations.length];<a name="line.2941"></a>
-<span class="sourceLineNo">2942</span>      Arrays.fill(this.retCodeDetails, OperationStatus.NOT_RUN);<a name="line.2942"></a>
-<span class="sourceLineNo">2943</span>      this.walEditsFromCoprocessors = new WALEdit[operations.length];<a name="line.2943"></a>
-<span class="sourceLineNo">2944</span>      familyCellMaps = new Map[operations.length];<a name="line.2944"></a>
-<span class="sourceLineNo">2945</span><a name="line.2945"></a>
-<span class="sourceLineNo">2946</span>      this.region = region;<a name="line.2946"></a>
-<span class="sourceLineNo">2947</span>      observedExceptions = new ObservedExceptionsInBatch();<a name="line.2947"></a>
-<span class="sourceLineNo">2948</span>      durability = Durability.USE_DEFAULT;<a name="line.2948"></a>
-<span class="sourceLineNo">2949</span>    }<a name="line.2949"></a>
-<span class="sourceLineNo">2950</span><a name="line.2950"></a>
-<span class="sourceLineNo">2951</span>    /**<a name="line.2951"></a>
-<span class="sourceLineNo">2952</span>     * Visitor interface for batch operations<a name="line.2952"></a>
-<span class="sourceLineNo">2953</span>     */<a name="line.2953"></a>
-<span class="sourceLineNo">2954</span>    @FunctionalInterface<a name="line.2954"></a>
-<span class="sourceLineNo">2955</span>    public interface Visitor {<a name="line.2955"></a>
-<span class="sourceLineNo">2956</span>      /**<a name="line.2956"></a>
-<span class="sourceLineNo">2957</span>       * @param index operation index<a name="line.2957"></a>
-<span class="sourceLineNo">2958</span>       * @return If true continue visiting remaining entries, break otherwise<a name="line.2958"></a>
-<span class="sourceLineNo">2959</span>       */<a name="line.2959"></a>
-<span class="sourceLineNo">2960</span>      boolean visit(int index) throws IOException;<a name="line.2960"></a>
-<span class="sourceLineNo">2961</span>    }<a name="line.2961"></a>
-<span class="sourceLineNo">2962</span><a name="line.2962"></a>
-<span class="sourceLineNo">2963</span>    /**<a name="line.2963"></a>
-<span class="sourceLineNo">2964</span>     * Helper method for visiting pending/ all batch operations<a name="line.2964"></a>
-<span class="sourceLineNo">2965</span>     */<a name="line.2965"></a>
-<span class="sourceLineNo">2966</span>    public void visitBatchOperations(boolean pendingOnly, int lastIndexExclusive, Visitor visitor)<a name="line.2966"></a>
-<span class="sourceLineNo">2967</span>        throws IOException {<a name="line.2967"></a>
-<span class="sourceLineNo">2968</span>      assert lastIndexExclusive &lt;= this.size();<a name="line.2968"></a>
-<span class="sourceLineNo">2969</span>      for (int i = nextIndexToProcess; i &lt; lastIndexExclusive; i++) {<a name="line.2969"></a>
-<span class="sourceLineNo">2970</span>        if (!pendingOnly || isOperationPending(i)) {<a name="line.2970"></a>
-<span class="sourceLineNo">2971</span>          if (!visitor.visit(i)) {<a name="line.2971"></a>
-<span class="sourceLineNo">2972</span>            break;<a name="line.2972"></a>
-<span class="sourceLineNo">2973</span>          }<a name="line.2973"></a>
-<span class="sourceLineNo">2974</span>        }<a name="line.2974"></a>
-<span class="sourceLineNo">2975</span>      }<a name="line.2975"></a>
-<span class="sourceLineNo">2976</span>    }<a name="line.2976"></a>
-<span class="sourceLineNo">2977</span><a name="line.2977"></a>
-<span class="sourceLineNo">2978</span>    public abstract Mutation getMutation(int index);<a name="line.2978"></a>
-<span class="sourceLineNo">2979</span>    public abstract long getNonceGroup(int index);<a name="line.2979"></a>
-<span class="sourceLineNo">2980</span>    public abstract long getNonce(int index);<a name="line.2980"></a>
-<span class="sourceLineNo">2981</span>    /** This method is potentially expensive and useful mostly for non-replay CP path. */<a name="line.2981"></a>
-<span class="sourceLineNo">2982</span>    public abstract Mutation[] getMutationsForCoprocs();<a name="line.2982"></a>
-<span class="sourceLineNo">2983</span>    public abstract boolean isInReplay();<a name="line.2983"></a>
-<span class="sourceLineNo">2984</span>    public abstract long getOrigLogSeqNum();<a name="line.2984"></a>
-<span class="sourceLineNo">2985</span>    public abstract void startRegionOperation() throws IOException;<a name="line.2985"></a>
-<span class="sourceLineNo">2986</span>    public abstract void closeRegionOperation() throws IOException;<a name="line.2986"></a>
-<span class="sourceLineNo">2987</span><a name="line.2987"></a>
-<span class="sourceLineNo">2988</span>    /**<a name="line.2988"></a>
-<span class="sourceLineNo">2989</span>     * Validates each mutation and prepares a batch for write. If necessary (non-replay case), runs<a name="line.2989"></a>
-<span class="sourceLineNo">2990</span>     * CP prePut()/ preDelete() hooks for all mutations in a batch. This is intended to operate on<a name="line.2990"></a>
-<span class="sourceLineNo">2991</span>     * entire batch and will be called from outside of class to check and prepare batch. This can<a name="line.2991"></a>
-<span class="sourceLineNo">2992</span>     * be implemented by calling helper method {@link #checkAndPrepareMutation(int, long)} in a<a name="line.2992"></a>
-<span class="sourceLineNo">2993</span>     * 'for' loop over mutations.<a name="line.2993"></a>
-<span class="sourceLineNo">2994</span>     */<a name="line.2994"></a>
-<span class="sourceLineNo">2995</span>    public abstract void checkAndPrepare() throws IOException;<a name="line.2995"></a>
-<span class="sourceLineNo">2996</span><a name="line.2996"></a>
-<span class="sourceLineNo">2997</span>    /**<a name="line.2997"></a>
-<span class="sourceLineNo">2998</span>     * Implement any Put request specific check and prepare logic here. Please refer to<a name="line.2998"></a>
-<span class="sourceLineNo">2999</span>     * {@link #checkAndPrepareMutation(Mutation, long)} for how its used.<a name="line.2999"></a>
-<span class="sourceLineNo">3000</span>     */<a name="line.3000"></a>
-<span class="sourceLineNo">3001</span>    protected abstract void checkAndPreparePut(final Put p) throws IOException;<a name="line.3001"></a>
-<span class="sourceLineNo">3002</span><a name="line.3002"></a>
-<span class="sourceLineNo">3003</span>    /**<a name="line.3003"></a>
-<span class="sourceLineNo">3004</span>     *  If necessary, calls preBatchMutate() CP hook for a mini-batch and updates metrics, cell<a name="line.3004"></a>
-<span class="sourceLineNo">3005</span>     *  count, tags and timestamp for all cells of all operations in a mini-batch.<a name="line.3005"></a>
-<span class="sourceLineNo">3006</span>     */<a name="line.3006"></a>
-<span class="sourceLineNo">3007</span>    public abstract void prepareMiniBatchOperations(MiniBatchOperationInProgress&lt;Mutation&gt;<a name="line.3007"></a>
-<span class="sourceLineNo">3008</span>        miniBatchOp, long timestamp, final List&lt;RowLock&gt; acquiredRowLocks) throws IOException;<a name="line.3008"></a>
-<span class="sourceLineNo">3009</span><a name="line.3009"></a>
-<span class="sourceLineNo">3010</span>    /**<a name="line.3010"></a>
-<span class="sourceLineNo">3011</span>     * Write mini-batch operations to MemStore<a name="line.3011"></a>
-<span class="sourceLineNo">3012</span>     */<a name="line.3012"></a>
-<span class="sourceLineNo">3013</span>    public abstract WriteEntry writeMiniBatchOperationsToMemStore(<a name="line.3013"></a>
-<span class="sourceLineNo">3014</span>        final MiniBatchOperationInProgress&lt;Mutation&gt; miniBatchOp, final WriteEntry writeEntry)<a name="line.3014"></a>
-<span class="sourceLineNo">3015</span>        throws IOException;<a name="line.3015"></a>
-<span class="sourceLineNo">3016</span><a name="line.3016"></a>
-<span class="sourceLineNo">3017</span>    protected void writeMiniBatchOperationsToMemStore(<a name="line.3017"></a>
-<span class="sourceLineNo">3018</span>        final MiniBatchOperationInProgress&lt;Mutation&gt; miniBatchOp, final long writeNumber)<a name="line.3018"></a>
-<span class="sourceLineNo">3019</span>        throws IOException {<a name="line.3019"></a>
-<span class="sourceLineNo">3020</span>      MemStoreSizing memStoreAccounting = new MemStoreSizing();<a name="line.3020"></a>
-<span class="sourceLineNo">3021</span>      visitBatchOperations(true, miniBatchOp.getLastIndexExclusive(), (int index) -&gt; {<a name="line.3021"></a>
-<span class="sourceLineNo">3022</span>        // We need to update the sequence id for following reasons.<a name="line.3022"></a>
-<span class="sourceLineNo">3023</span>        // 1) If the op is in replay mode, FSWALEntry#stampRegionSequenceId won't stamp sequence id.<a name="line.3023"></a>
-<span class="sourceLineNo">3024</span>        // 2) If no WAL, FSWALEntry won't be used<a name="line.3024"></a>
-<span class="sourceLineNo">3025</span>        // we use durability of the original mutation for the mutation passed by CP.<a name="line.3025"></a>
-<span class="sourceLineNo">3026</span>        if (isInReplay() || getMutation(index).getDurability() == Durability.SKIP_WAL) {<a name="line.3026"></a>
-<span class="sourceLineNo">3027</span>          region.updateSequenceId(familyCellMaps[index].values(), writeNumber);<a name="line.3027"></a>
-<span class="sourceLineNo">3028</span>        }<a name="line.3028"></a>
-<span class="sourceLineNo">3029</span>        applyFamilyMapToMemStore(familyCellMaps[index], memStoreAccounting);<a name="line.3029"></a>
-<span class="sourceLineNo">3030</span>        return true;<a name="line.3030"></a>
-<span class="sourceLineNo">3031</span>      });<a name="line.3031"></a>
-<span class="sourceLineNo">3032</span>      // update memStore size<a name="line.3032"></a>
-<span class="sourceLineNo">3033</span>      region.addAndGetMemStoreSize(memStoreAccounting);<a name="line.3033"></a>
-<span class="sourceLineNo">3034</span>    }<a name="line.3034"></a>
-<span class="sourceLineNo">3035</span><a name="line.3035"></a>
-<span class="sourceLineNo">3036</span>    public boolean isDone() {<a name="line.3036"></a>
-<span class="sourceLineNo">3037</span>      return nextIndexToProcess == operations.length;<a name="line.3037"></a>
-<span class="sourceLineNo">3038</span>    }<a name="line.3038"></a>
-<span class="sourceLineNo">3039</span><a name="line.3039"></a>
-<span class="sourceLineNo">3040</span>    public int size() {<a name="line.3040"></a>
-<span class="sourceLineNo">3041</span>      return operations.length;<a name="line.3041"></a>
-<span class="sourceLineNo">3042</span>    }<a name="line.3042"></a>
-<span class="sourceLineNo">3043</span><a name="line.3043"></a>
-<span class="sourceLineNo">3044</span>    public boolean isOperationPending(int index) {<a name="line.3044"></a>
-<span class="sourceLineNo">3045</span>      return retCodeDetails[index].getOperationStatusCode() == OperationStatusCode.NOT_RUN;<a name="line.3045"></a>
-<span class="sourceLineNo">3046</span>    }<a name="line.3046"></a>
-<span class="sourceLineNo">3047</span><a name="line.3047"></a>
-<span class="sourceLineNo">3048</span>    public List&lt;UUID&gt; getClusterIds() {<a name="line.3048"></a>
-<span class="sourceLineNo">3049</span>      assert size() != 0;<a name="line.3049"></a>
-<span class="sourceLineNo">3050</span>      return getMutation(0).getClusterIds();<a name="line.3050"></a>
-<span class="sourceLineNo">3051</span>    }<a name="line.3051"></a>
-<span class="sourceLineNo">3052</span><a name="line.3052"></a>
-<span class="sourceLineNo">3053</span>    boolean isAtomic() {<a name="line.3053"></a>
-<span class="sourceLineNo">3054</span>      return atomic;<a name="line.3054"></a>
-<span class="sourceLineNo">3055</span>    }<a name="line.3055"></a>
-<span class="sourceLineNo">3056</span><a name="line.3056"></a>
-<span class="sourceLineNo">3057</span>    /**<a name="line.3057"></a>
-<span class="sourceLineNo">3058</span>     * Helper method that checks and prepares only one mutation. This can be used to implement<a name="line.3058"></a>
-<span class="sourceLineNo">3059</span>     * {@link #checkAndPrepare()} for entire Batch.<a name="line.3059"></a>
-<span class="sourceLineNo">3060</span>     * NOTE: As CP prePut()/ preDelete() hooks may modify mutations, this method should be called<a name="line.3060"></a>
-<span class="sourceLineNo">3061</span>     * after prePut()/ preDelete() CP hooks are run for the mutation<a name="line.3061"></a>
-<span class="sourceLineNo">3062</span>     */<a name="line.3062"></a>
-<span class="sourceLineNo">3063</span>    protected void checkAndPrepareMutation(Mutation mutation, final long timestamp)<a name="line.3063"></a>
-<span class="sourceLineNo">3064</span>        throws IOException {<a name="line.3064"></a>
-<span class="sourceLineNo">3065</span>      region.checkRow(mutation.getRow(), "batchMutate");<a name="line.3065"></a>
-<span class="sourceLineNo">3066</span>      if (mutation instanceof Put) {<a name="line.3066"></a>
-<span class="sourceLineNo">3067</span>        // Check the families in the put. If bad, skip this one.<a name="line.3067"></a>
-<span class="sourceLineNo">3068</span>        checkAndPreparePut((Put) mutation);<a name="line.3068"></a>
-<span class="sourceLineNo">3069</span>        region.checkTimestamps(mutation.getFamilyCellMap(), timestamp);<a name="line.3069"></a>
-<span class="sourceLineNo">3070</span>      } else {<a name="line.3070"></a>
-<span class="sourceLineNo">3071</span>        region.prepareDelete((Delete) mutation);<a name="line.3071"></a>
-<span class="sourceLineNo">3072</span>      }<a name="line.3072"></a>
-<span class="sourceLineNo">3073</span>    }<a name="line.3073"></a>
-<span class="sourceLineNo">3074</span><a name="line.3074"></a>
-<span class="sourceLineNo">3075</span>    protected void checkAndPrepareMutation(int index, long timestamp) throws IOException {<a name="line.3075"></a>
-<span class="sourceLineNo">3076</span>      Mutation mutation = getMutation(index);<a name="line.3076"></a>
-<span class="sourceLineNo">3077</span>      try {<a name="line.3077"></a>
-<span class="sourceLineNo">3078</span>        this.checkAndPrepareMutation(mutation, timestamp);<a name="line.3078"></a>
-<span class="sourceLineNo">3079</span><a name="line.3079"></a>
-<span class="sourceLineNo">3080</span>        // store the family map reference to allow for mutations<a name="line.3080"></a>
-<span class="sourceLineNo">3081</span>        familyCellMaps[index] = mutation.getFamilyCellMap();<a name="line.3081"></a>
-<span class="sourceLineNo">3082</span>        // store durability for the batch (highest durability of all operations in the batch)<a name="line.3082"></a>
-<span class="sourceLineNo">3083</span>        Durability tmpDur = region.getEffectiveDurability(mutation.getDurability());<a name="line.3083"></a>
-<span class="sourceLineNo">3084</span>        if (tmpDur.ordinal() &gt; durability.ordinal()) {<a name="line.3084"></a>
-<span class="sourceLineNo">3085</span>          durability = tmpDur;<a name="line.3085"></a>
-<span class="sourceLineNo">3086</span>        }<a name="line.3086"></a>
-<span class="sourceLineNo">3087</span>      } catch (NoSuchColumnFamilyException nscfe) {<a name="line.3087"></a>
-<span class="sourceLineNo">3088</span>        final String msg = "No such column family in batch mutation. ";<a name="line.3088"></a>
-<span class="sourceLineNo">3089</span>        if (observedExceptions.hasSeenNoSuchFamily()) {<a name="line.3089"></a>
-<span class="sourceLineNo">3090</span>          LOG.warn(msg + nscfe.getMessage());<a name="line.3090"></a>
-<span class="sourceLineNo">3091</span>        } else {<a name="line.3091"></a>
-<span class="sourceLineNo">3092</span>          LOG.warn(msg, nscfe);<a name="line.3092"></a>
-<span class="sourceLineNo">3093</span>          observedExceptions.sawNoSuchFamily();<a name="line.3093"></a>
-<span class="sourceLineNo">3094</span>        }<a name="line.3094"></a>
-<span class="sourceLineNo">3095</span>        retCodeDetails[index] = new OperationStatus(<a name="line.3095"></a>
-<span class="sourceLineNo">3096</span>            OperationStatusCode.BAD_FAMILY, nscfe.getMessage());<a name="line.3096"></a>
-<span class="sourceLineNo">3097</span>        if (isAtomic()) { // fail, atomic means all or none<a name="line.3097"></a>
-<span class="sourceLineNo">3098</span>          throw nscfe;<a name="line.3098"></a>
-<span class="sourceLineNo">3099</span>        }<a name="line.3099"></a>
-<span class="sourceLineNo">3100</span>      } catch (FailedSanityCheckException fsce) {<a name="line.3100"></a>
-<span class="sourceLineNo">3101</span>        final String msg = "Batch Mutation did not pass sanity check. ";<a name="line.3101"></a>
-<span class="sourceLineNo">3102</span>        if (observedExceptions.hasSeenFailedSanityCheck()) {<a name="line.3102"></a>
-<span class="sourceLineNo">3103</span>          LOG.warn(msg + fsce.getMessage());<a name="line.3103"></a>
-<span class="sourceLineNo">3104</span>        } else {<a name="line.3104"></a>
-<span class="sourceLineNo">3105</span>          LOG.warn(msg, fsce);<a name="line.3105"></a>
-<span class="sourceLineNo">3106</span>          observedExceptions.sawFailedSanityCheck();<a name="line.3106"></a>
-<span class="sourceLineNo">3107</span>        }<a name="line.3107"></a>
-<span class="sourceLineNo">3108</span>        retCodeDetails[index] = new OperationStatus(<a name="line.3108"></a>
-<span class="sourceLineNo">3109</span>            OperationStatusCode.SANITY_CHECK_FAILURE, fsce.getMessage());<a name="line.3109"></a>
-<span class="sourceLineNo">3110</span>        if (isAtomic()) {<a name="line.3110"></a>
-<span class="sourceLineNo">3111</span>          throw fsce;<a name="line.3111"></a>
-<span class="sourceLineNo">3112</span>        }<a name="line.3112"></a>
-<span class="sourceLineNo">3113</span>      } catch (WrongRegionException we) {<a name="line.3113"></a>
-<span class="sourceLineNo">3114</span>        final String msg = "Batch mutation had a row that does not belong to this region. ";<a name="line.3114"></a>
-<span class="sourceLineNo">3115</span>        if (observedExceptions.hasSeenWrongRegion()) {<a name="line.3115"></a>
-<span class="sourceLineNo">3116</span>          LOG.warn(msg + we.getMessage());<a name="line.3116"></a>
-<span class="sourceLineNo">3117</span>        } else {<a name="line.3117"></a>
-<span class="sourceLineNo">3118</span>          LOG.warn(msg, we);<a name="line.3118"></a>
-<span class="sourceLineNo">3119</span>          observedExceptions.sawWrongRegion();<a name="line.3119"></a>
-<span class="sourceLineNo">3120</span>        }<a name="line.3120"></a>
-<span class="sourceLineNo">3121</span>        retCodeDetails[index] = new OperationStatus(<a name="line.3121"></a>
-<span class="sourceLineNo">3122</span>            OperationStatusCode.SANITY_CHECK_FAILURE, we.getMessage());<a name="line.3122"></a>
-<span class="sourceLineNo">3123</span>        if (isAtomic()) {<a name="line.3123"></a>
-<span class="sourceLineNo">3124</span>          throw we;<a name="line.3124"></a>
-<span class="sourceLineNo">3125</span>        }<a name="line.3125"></a>
-<span class="sourceLineNo">3126</span>      }<a name="line.3126"></a>
-<span class="sourceLineNo">3127</span>    }<a name="line.3127"></a>
-<span class="sourceLineNo">3128</span><a name="line.3128"></a>
-<span class="sourceLineNo">3129</span>    /**<a name="line.3129"></a>
-<span class="sourceLineNo">3130</span>     * Creates Mini-batch of all operations [nextIndexToProcess, lastIndexExclusive) for which<a name="line.3130"></a>
-<span class="sourceLineNo">3131</span>     * a row lock can be acquired. All mutations with locked rows are considered to be<a name="line.3131"></a>
-<span class="sourceLineNo">3132</span>     * In-progress operations and hence the name {@link MiniBatchOperationInProgress}. Mini batch<a name="line.3132"></a>
-<span class="sourceLineNo">3133</span>     * is window over {@link BatchOperation} and contains contiguous pending operations.<a name="line.3133"></a>
-<span class="sourceLineNo">3134</span>     *<a name="line.3134"></a>
-<span class="sourceLineNo">3135</span>     * @param acquiredRowLocks keeps track of rowLocks acquired.<a name="line.3135"></a>
-<span class="sourceLineNo">3136</span>     */<a name="line.3136"></a>
-<span class="sourceLineNo">3137</span>    public MiniBatchOperationInProgress&lt;Mutation&gt; lockRowsAndBuildMiniBatch(<a name="line.3137"></a>
-<span class="sourceLineNo">3138</span>        List&lt;RowLock&gt; acquiredRowLocks) throws IOException {<a name="line.3138"></a>
-<span class="sourceLineNo">3139</span>      int readyToWriteCount = 0;<a name="line.3139"></a>
-<span class="sourceLineNo">3140</span>      int lastIndexExclusive = 0;<a name="line.3140"></a>
-<span class="sourceLineNo">3141</span>      for (; lastIndexExclusive &lt; size(); lastIndexExclusive++) {<a name="line.3141"></a>
-<span class="sourceLineNo">3142</span>        if (!isOperationPending(lastIndexExclusive)) {<a name="line.3142"></a>
-<span class="sourceLineNo">3143</span>          continue;<a name="line.3143"></a>
-<span class="sourceLineNo">3144</span>        }<a name="line.3144"></a>
-<span class="sourceLineNo">3145</span>        Mutation mutation = getMutation(lastIndexExclusive);<a name="line.3145"></a>
-<span class="sourceLineNo">3146</span>        // If we haven't got any rows in our batch, we should block to get the next one.<a name="line.3146"></a>
-<span class="sourceLineNo">3147</span>        RowLock rowLock = null;<a name="line.3147"></a>
-<span class="sourceLineNo">3148</span>        try {<a name="line.3148"></a>
-<span class="sourceLineNo">3149</span>          // if atomic then get exclusive lock, else shared lock<a name="line.3149"></a>
-<span class="sourceLineNo">3150</span>          rowLock = region.getRowLockInternal(mutation.getRow(), !isAtomic());<a name="line.3150"></a>
-<span class="sourceLineNo">3151</span>        } catch (TimeoutIOException e) {<a name="line.3151"></a>
-<span class="sourceLineNo">3152</span>          // We will retry when other exceptions, but we should stop if we timeout .<a name="line.3152"></a>
-<span class="sourceLineNo">3153</span>          throw e;<a name="line.3153"></a>
-<span class="sourceLineNo">3154</span>        } catch (IOException ioe) {<a name="line.3154"></a>
-<span class="sourceLineNo">3155</span>          LOG.warn("Failed getting lock, row=" + Bytes.toStringBinary(mutation.getRow()), ioe);<a name="line.3155"></a>
-<span class="sourceLineNo">3156</span>          if (isAtomic()) { // fail, atomic means all or none<a name="line.3156"></a>
-<span class="sourceLineNo">3157</span>            throw ioe;<a name="line.3157"></a>
-<span class="sourceLineNo">3158</span>          }<a name="line.3158"></a>
-<span class="sourceLineNo">3159</span>        }<a name="line.3159"></a>
-<span class="sourceLineNo">3160</span>        if (rowLock == null) {<a name="line.3160"></a>
-<span class="sourceLineNo">3161</span>          // We failed to grab another lock<a name="line.3161"></a>
-<span class="sourceLineNo">3162</span>          if (isAtomic()) {<a name="line.3162"></a>
-<span class="sourceLineNo">3163</span>            throw new IOException("Can't apply all operations atomically!");<a name="line.3163"></a>
-<span class="sourceLineNo">3164</span>          }<a name="line.3164"></a>
-<span class="sourceLineNo">3165</span>          break; // Stop acquiring more rows for this batch<a name="line.3165"></a>
-<span class="sourceLineNo">3166</span>        } else {<a name="line.3166"></a>
-<span class="sourceLineNo">3167</span>          acquiredRowLocks.add(rowLock);<a name="line.3167"></a>
-<span class="sourceLineNo">3168</span>        }<a name="line.3168"></a>
-<span class="sourceLineNo">3169</span>        readyToWriteCount++;<a name="line.3169"></a>
-<span class="sourceLineNo">3170</span>      }<a name="line.3170"></a>
-<span class="sourceLineNo">3171</span>      return createMiniBatch(lastIndexExclusive, readyToWriteCount);<a name="line.3171"></a>
-<span class="sourceLineNo">3172</span>    }<a name="line.3172"></a>
-<span class="sourceLineNo">3173</span><a name="line.3173"></a>
-<span class="sourceLineNo">3174</span>    protected MiniBatchOperationInProgress&lt;Mutation&gt; createMiniBatch(final int lastIndexExclusive,<a name="line.3174"></a>
-<span class="sourceLineNo">3175</span>        final int readyToWriteCount) {<a name="line.3175"></a>
-<span class="sourceLineNo">3176</span>      return new MiniBatchOperationInProgress&lt;&gt;(getMutationsForCoprocs(), retCodeDetails,<a name="line.3176"></a>
-<span class="sourceLineNo">3177</span>          walEditsFromCoprocessors, nextIndexToProcess, lastIndexExclusive, readyToWriteCount);<a name="line.3177"></a>
-<span class="sourceLineNo">3178</span>    }<a name="line.3178"></a>
-<span class="sourceLineNo">3179</span><a name="line.3179"></a>
-<span class="sourceLineNo">3180</span>    /**<a name="line.3180"></a>
-<span class="sourceLineNo">3181</span>     * Builds separate WALEdit per nonce by applying input mutations. If WALEdits from CP are<a name="line.3181"></a>
-<span class="sourceLineNo">3182</span>     * present, they are merged to result WALEdit.<a name="line.3182"></a>
-<span class="sourceLineNo">3183</span>     */<a name="line.3183"></a>
-<span class="sourceLineNo">3184</span>    public List&lt;Pair&lt;NonceKey, WALEdit&gt;&gt; buildWALEdits(<a name="line.3184"></a>
-<span class="sourceLineNo">3185</span>        final MiniBatchOperationInProgress&lt;Mutation&gt; miniBatchOp) throws IOException {<a name="line.3185"></a>
-<span class="sourceLineNo">3186</span>      List&lt;Pair&lt;NonceKey, WALEdit&gt;&gt; walEdits = new ArrayList&lt;&gt;();<a name="line.3186"></a>
-<span class="sourceLineNo">3187</span><a name="line.3187"></a>
-<span class="sourceLineNo">3188</span>      visitBatchOperations(true, nextIndexToProcess + miniBatchOp.size(), new Visitor() {<a name="line.3188"></a>
-<span class="sourceLineNo">3189</span>        private Pair&lt;NonceKey, WALEdit&gt; curWALEditForNonce;<a name="line.3189"></a>
-<span class="sourceLineNo">3190</span>        @Override<a name="line.3190"></a>
-<span class="sourceLineNo">3191</span>        public boolean visit(int index) throws IOException {<a name="line.3191"></a>
-<span class="sourceLineNo">3192</span>          Mutation m = getMutation(index);<a name="line.3192"></a>
-<span class="sourceLineNo">3193</span>          // we use durability of the original mutation for the mutation passed by CP.<a name="line.3193"></a>
-<span class="sourceLineNo">3194</span>          if (region.getEffectiveDurability(m.getDurability()) == Durability.SKIP_WAL) {<a name="line.3194"></a>
-<span class="sourceLineNo">3195</span>            region.recordMutationWithoutWal(m.getFamilyCellMap());<a name="line.3195"></a>
-<span class="sourceLineNo">3196</span>            return true;<a name="line.3196"></a>
-<span class="sourceLineNo">3197</span>          }<a name="line.3197"></a>
-<span class="sourceLineNo">3198</span><a name="line.3198"></a>
-<span class="sourceLineNo">3199</span>          // the batch may contain multiple nonce keys (replay case). If so, write WALEdit for each.<a name="line.3199"></a>
-<span class="sourceLineNo">3200</span>          // Given how nonce keys are originally written, these should be contiguous.<a name="line.3200"></a>
-<span class="sourceLineNo">3201</span>          // They don't have to be, it will still work, just write more WALEdits than needed.<a name="line.3201"></a>
-<span class="sourceLineNo">3202</span>          long nonceGroup = getNonceGroup(index);<a name="line.3202"></a>
-<span class="sourceLineNo">3203</span>          long nonce = getNonce(index);<a name="line.3203"></a>
-<span class="sourceLineNo">3204</span>          if (curWALEditForNonce == null ||<a name="line.3204"></a>
-<span class="sourceLineNo">3205</span>              curWALEditForNonce.getFirst().getNonceGroup() != nonceGroup ||<a name="line.3205"></a>
-<span class="sourceLineNo">3206</span>              curWALEditForNonce.getFirst().getNonce() != nonce) {<a name="line.3206"></a>
-<span class="sourceLineNo">3207</span>            curWALEditForNonce = new Pair&lt;&gt;(new NonceKey(nonceGroup, nonce),<a name="line.3207"></a>
-<span class="sourceLineNo">3208</span>                new WALEdit(miniBatchOp.getCellCount(), isInReplay()));<a name="line.3208"></a>
-<span class="sourceLineNo">3209</span>            walEdits.add(curWALEditForNonce);<a name="line.3209"></a>
-<span class="sourceLineNo">3210</span>          }<a name="line.3210"></a>
-<span class="sourceLineNo">3211</span>          WALEdit walEdit = curWALEditForNonce.getSecond();<a name="line.3211"></a>
-<span class="sourceLineNo">3212</span><a name="line.3212"></a>
-<span class="sourceLineNo">3213</span>          // Add WAL edits by CP<a name="line.3213"></a>
-<span class="sourceLineNo">3214</span>          WALEdit fromCP = walEditsFromCoprocessors[index];<a name="line.3214"></a>
-<span class="sourceLineNo">3215</span>          if (fromCP != null) {<a name="line.3215"></a>
-<span class="sourceLineNo">3216</span>            for (Cell cell : fromCP.getCells()) {<a name="line.3216"></a>
-<span class="sourceLineNo">3217</span>              walEdit.add(cell);<a name="line.3217"></a>
-<span class="sourceLineNo">3218</span>            }<a name="line.3218"></a>
-<span class="sourceLineNo">3219</span>          }<a name="line.3219"></a>
-<span class="sourceLineNo">3220</span>          addFamilyMapToWALEdit(familyCellMaps[index], walEdit);<a name="line.3220"></a>
-<span class="sourceLineNo">3221</span><a name="line.3221"></a>
-<span class="sourceLineNo">3222</span>          return true;<a name="line.3222"></a>
-<span class="sourceLineNo">3223</span>        }<a name="line.3223"></a>
-<span class="sourceLineNo">3224</span>      });<a name="line.3224"></a>
-<span class="sourceLineNo">3225</span>      return walEdits;<a name="line.3225"></a>
-<span class="sourceLineNo">3226</span>    }<a name="line.3226"></a>
-<span class="sourceLineNo">3227</span><a name="line.3227"></a>
-<span class="sourceLineNo">3228</span>    /**<a name="line.3228"></a>
-<span class="sourceLineNo">3229</span>     * This method completes mini-batch operations by calling postBatchMutate() CP hook (if<a name="line.3229"></a>
-<span class="sourceLineNo">3230</span>     * required) and completing mvcc.<a name="line.3230"></a>
-<span class="sourceLineNo">3231</span>     */<a name="line.3231"></a>
-<span class="sourceLineNo">3232</span>    public void completeMiniBatchOperations(<a name="line.3232"></a>
-<span class="sourceLineNo">3233</span>        final MiniBatchOperationInProgress&lt;Mutation&gt; miniBatchOp, final WriteEntry writeEntry)<a name="line.3233"></a>
-<span class="sourceLineNo">3234</span>        throws IOException {<a name="line.3234"></a>
-<span class="sourceLineNo">3235</span>      if (writeEntry != null) {<a name="line.3235"></a>
-<span class="sourceLineNo">3236</span>        region.mvcc.completeAndWait(writeEntry);<a name="line.3236"></a>
-<span class="sourceLineNo">3237</span>      }<a name="line.3237"></a>
-<span class="sourceLineNo">3238</span>    }<a name="line.3238"></a>
-<span class="sourceLineNo">3239</span><a name="line.3239"></a>
-<span class="sourceLineNo">3240</span>    public void doPostOpCleanupForMiniBatch(<a name="line.3240"></a>
-<span class="sourceLineNo">3241</span>        final MiniBatchOperationInProgress&lt;Mutation&gt; miniBatchOp, final WALEdit walEdit,<a name="line.3241"></a>
-<span class="sourceLineNo">3242</span>        boolean success) throws IOException {}<a name="line.3242"></a>
-<span class="sourceLineNo">3243</span><a name="line.3243"></a>
-<span class="sourceLineNo">3244</span>    /**<a name="line.3244"></a>
-<span class="sourceLineNo">3245</span>     * Atomically apply the given map of family-&gt;edits to the memstore.<a name="line.3245"></a>
-<span class="sourceLineNo">3246</span>     * This handles the consistency control on its own, but the caller<a name="line.3246"></a>
-<span class="sourceLineNo">3247</span>     * should already have locked updatesLock.readLock(). This also does<a name="line.3247"></a>
-<span class="sourceLineNo">3248</span>     * &lt;b&gt;not&lt;/b&gt; check the families for validity.<a name="line.3248"></a>
-<span class="sourceLineNo">3249</span>     *<a name="line.3249"></a>
-<span class="sourceLineNo">3250</span>     * @param familyMap Map of Cells by family<a name="line.3250"></a>
-<span class="sourceLineNo">3251</span>     */<a name="line.3251"></a>
-<span class="sourceLineNo">3252</span>    protected void applyFamilyMapToMemStore(Map&lt;byte[], List&lt;Cell&gt;&gt; familyMap,<a name="line.3252"></a>
-<span class="sourceLineNo">3253</span>        MemStoreSizing memstoreAccounting) throws IOException {<a name="line.3253"></a>
-<span class="sourceLineNo">3254</span>      for (Map.Entry&lt;byte[], List&lt;Cell&gt;&gt; e : familyMap.entrySet()) {<a name="line.3254"></a>
-<span class="sourceLineNo">3255</span>        byte[] family = e.getKey();<a name="line.3255"></a>
-<span class="sourceLineNo">3256</span>        List&lt;Cell&gt; cells = e.getValue();<a name="line.3256"></a>
-<span class="sourceLineNo">3257</span>        assert cells instanceof RandomAccess;<a name="line.3257"></a>
-<span class="sourceLineNo">3258</span>        region.applyToMemStore(region.getStore(family), cells, false, memstoreAccounting);<a name="line.3258"></a>
-<span class="sourceLineNo">3259</span>      }<a name="line.3259"></a>
-<span class="sourceLineNo">3260</span>    }<a name="line.3260"></a>
-<span class="sourceLineNo">3261</span><a name="line.3261"></a>
-<span class="sourceLineNo">3262</span>    /**<a name="line.3262"></a>
-<span class="sourceLineNo">3263</span>     * Append the given map of family-&gt;edits to a WALEdit data structure.<a name="line.3263"></a>
-<span class="sourceLineNo">3264</span>     * This does not write to the WAL itself.<a name="line.3264"></a>
-<span class="sourceLineNo">3265</span>     * @param familyMap map of family-&gt;edits<a name="line.3265"></a>
-<span class="sourceLineNo">3266</span>     * @param walEdit the destination entry to append into<a name="line.3266"></a>
-<span class="sourceLineNo">3267</span>     */<a name="line.3267"></a>
-<span class="sourceLineNo">3268</span>    private void addFamilyMapToWALEdit(Map&lt;byte[], List&lt;Cell&gt;&gt; familyMap,<a name="line.3268"></a>
-<span class="sourceLineNo">3269</span>        WALEdit walEdit) {<a name="line.3269"></a>
-<span class="sourceLineNo">3270</span>      for (List&lt;Cell&gt; edits : familyMap.values()) {<a name="line.3270"></a>
-<span class="sourceLineNo">3271</span>        // Optimization: 'foreach' loop is not used. See:<a name="line.3271"></a>
-<span class="sourceLineNo">3272</span>        // HBASE-12023 HRegion.applyFamilyMapToMemstore creates too many iterator objects<a name="line.3272"></a>
-<span class="sourceLineNo">3273</span>        assert edits instanceof RandomAccess;<a name="line.3273"></a>
-<span class="sourceLineNo">3274</span>        int listSize = edits.size();<a name="line.3274"></a>
-<span class="sourceLineNo">3275</span>        for (int i=0; i &lt; listSize; i++) {<a name="line.3275"></a>
-<span class="sourceLineNo">3276</span>          Cell cell = edits.get(i);<a name="line.3276"></a>
-<span class="sourceLineNo">3277</span>          walEdit.add(cell);<a name="line.3277"></a>
-<span class="sourceLineNo">3278</span>        }<a name="line.3278"></a>
-<span class="sourceLineNo">3279</span>      }<a name="line.3279"></a>
-<span class="sourceLineNo">3280</span>    }<a name="line.3280"></a>
-<span class="sourceLineNo">3281</span>  }<a name="line.3281"></a>
-<span class="sourceLineNo">3282</span><a name="line.3282"></a>
-<span class="sourceLineNo">3283</span>  /**<a name="line.3283"></a>
-<span class="sourceLineNo">3284</span>   * Batch of mutation operations. Base class is shared with {@link ReplayBatchOperation} as most<a name="line.3284"></a>
-<span class="sourceLineNo">3285</span>   * of the logic is same.<a name="line.3285"></a>
-<span class="sourceLineNo">3286</span>   */<a name="line.3286"></a>
-<span class="sourceLineNo">3287</span>  static class MutationBatchOperation extends BatchOperation&lt;Mutation&gt; {<a name="line.3287"></a>
-<span class="sourceLineNo">3288</span>    private long nonceGroup;<a name="line.3288"></a>
-<span class="sourceLineNo">3289</span>    private long nonce;<a name="line.3289"></a>
-<span class="sourceLineNo">3290</span>    public MutationBatchOperation(final HRegion region, Mutation[] operations, boolean atomic,<a name="line.3290"></a>
-<span class="sourceLineNo">3291</span>        long nonceGroup, long nonce) {<a name="line.3291"></a>
-<span class="sourceLineNo">3292</span>      super(region, operations);<a name="line.3292"></a>
-<span class="sourceLineNo">3293</span>      this.atomic = atomic;<a name="line.3293"></a>
-<span class="sourceLineNo">3294</span>      this.nonceGroup = nonceGroup;<a name="line.3294"></a>
-<span class="sourceLineNo">3295</span>      this.nonce = nonce;<a name="line.3295"></a>
-<span class="sourceLineNo">3296</span>    }<a name="line.3296"></a>
-<span class="sourceLineNo">3297</span><a name="line.3297"></a>
-<span class="sourceLineNo">3298</span>    @Override<a name="line.3298"></a>
-<span class="sourceLineNo">3299</span>    public Mutation getMutation(int index) {<a name="line.3299"></a>
-<span class="sourceLineNo">3300</span>      return this.operations[index];<a name="line.3300"></a>
-<span class="sourceLineNo">3301</span>    }<a name="line.3301"></a>
-<span class="sourceLineNo">3302</span><a name="line.3302"></a>
-<span class="sourceLineNo">3303</span>    @Override<a name="line.3303"></a>
-<span class="sourceLineNo">3304</span>    public long getNonceGroup(int index) {<a name="line.3304"></a>
-<span class="sourceLineNo">3305</span>      return nonceGroup;<a name="line.3305"></a>
-<span class="sourceLineNo">3306</span>    }<a name="line.3306"></a>
-<span class="sourceLineNo">3307</

<TRUNCATED>

Mime
View raw message