hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [01/51] [partial] hbase-site git commit: Published site at 7c1fad4992a169a35b4457e6f4afcb30d04406e9.
Date Fri, 31 Aug 2018 14:47:31 GMT
Repository: hbase-site
Updated Branches:
  refs/heads/asf-site 424d7e416 -> 74f60271d


http://git-wip-us.apache.org/repos/asf/hbase-site/blob/74f60271/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BulkLoadListener.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BulkLoadListener.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BulkLoadListener.html
index a8cb7c4..8ec6dad 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BulkLoadListener.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegion.BulkLoadListener.html
@@ -2831,5851 +2831,5852 @@
 <span class="sourceLineNo">2823</span>    status.setStatus(msg);<a name="line.2823"></a>
 <span class="sourceLineNo">2824</span><a name="line.2824"></a>
 <span class="sourceLineNo">2825</span>    if (rsServices != null &amp;&amp; rsServices.getMetrics() != null) {<a name="line.2825"></a>
-<span class="sourceLineNo">2826</span>      rsServices.getMetrics().updateFlush(time - startTime,<a name="line.2826"></a>
-<span class="sourceLineNo">2827</span>          mss.getDataSize(), flushedOutputFileSize);<a name="line.2827"></a>
-<span class="sourceLineNo">2828</span>    }<a name="line.2828"></a>
-<span class="sourceLineNo">2829</span><a name="line.2829"></a>
-<span class="sourceLineNo">2830</span>    return new FlushResultImpl(compactionRequested ?<a name="line.2830"></a>
-<span class="sourceLineNo">2831</span>        FlushResult.Result.FLUSHED_COMPACTION_NEEDED :<a name="line.2831"></a>
-<span class="sourceLineNo">2832</span>          FlushResult.Result.FLUSHED_NO_COMPACTION_NEEDED, flushOpSeqId);<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>  /**<a name="line.2835"></a>
-<span class="sourceLineNo">2836</span>   * Method to safely get the next sequence number.<a name="line.2836"></a>
-<span class="sourceLineNo">2837</span>   * @return Next sequence number unassociated with any actual edit.<a name="line.2837"></a>
-<span class="sourceLineNo">2838</span>   * @throws IOException<a name="line.2838"></a>
-<span class="sourceLineNo">2839</span>   */<a name="line.2839"></a>
-<span class="sourceLineNo">2840</span>  @VisibleForTesting<a name="line.2840"></a>
-<span class="sourceLineNo">2841</span>  protected long getNextSequenceId(final WAL wal) throws IOException {<a name="line.2841"></a>
-<span class="sourceLineNo">2842</span>    WriteEntry we = mvcc.begin();<a name="line.2842"></a>
-<span class="sourceLineNo">2843</span>    mvcc.completeAndWait(we);<a name="line.2843"></a>
-<span class="sourceLineNo">2844</span>    return we.getWriteNumber();<a name="line.2844"></a>
-<span class="sourceLineNo">2845</span>  }<a name="line.2845"></a>
-<span class="sourceLineNo">2846</span><a name="line.2846"></a>
-<span class="sourceLineNo">2847</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.2847"></a>
-<span class="sourceLineNo">2848</span>  // get() methods for client use.<a name="line.2848"></a>
-<span class="sourceLineNo">2849</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.2849"></a>
-<span class="sourceLineNo">2850</span><a name="line.2850"></a>
-<span class="sourceLineNo">2851</span>  @Override<a name="line.2851"></a>
-<span class="sourceLineNo">2852</span>  public RegionScannerImpl getScanner(Scan scan) throws IOException {<a name="line.2852"></a>
-<span class="sourceLineNo">2853</span>   return getScanner(scan, null);<a name="line.2853"></a>
-<span class="sourceLineNo">2854</span>  }<a name="line.2854"></a>
-<span class="sourceLineNo">2855</span><a name="line.2855"></a>
-<span class="sourceLineNo">2856</span>  @Override<a name="line.2856"></a>
-<span class="sourceLineNo">2857</span>  public RegionScannerImpl getScanner(Scan scan, List&lt;KeyValueScanner&gt; additionalScanners)<a name="line.2857"></a>
-<span class="sourceLineNo">2858</span>      throws IOException {<a name="line.2858"></a>
-<span class="sourceLineNo">2859</span>    return getScanner(scan, additionalScanners, HConstants.NO_NONCE, HConstants.NO_NONCE);<a name="line.2859"></a>
-<span class="sourceLineNo">2860</span>  }<a name="line.2860"></a>
-<span class="sourceLineNo">2861</span><a name="line.2861"></a>
-<span class="sourceLineNo">2862</span>  private RegionScannerImpl getScanner(Scan scan, List&lt;KeyValueScanner&gt; additionalScanners,<a name="line.2862"></a>
-<span class="sourceLineNo">2863</span>      long nonceGroup, long nonce) throws IOException {<a name="line.2863"></a>
-<span class="sourceLineNo">2864</span>    startRegionOperation(Operation.SCAN);<a name="line.2864"></a>
-<span class="sourceLineNo">2865</span>    try {<a name="line.2865"></a>
-<span class="sourceLineNo">2866</span>      // Verify families are all valid<a name="line.2866"></a>
-<span class="sourceLineNo">2867</span>      if (!scan.hasFamilies()) {<a name="line.2867"></a>
-<span class="sourceLineNo">2868</span>        // Adding all families to scanner<a name="line.2868"></a>
-<span class="sourceLineNo">2869</span>        for (byte[] family : this.htableDescriptor.getColumnFamilyNames()) {<a name="line.2869"></a>
-<span class="sourceLineNo">2870</span>          scan.addFamily(family);<a name="line.2870"></a>
-<span class="sourceLineNo">2871</span>        }<a name="line.2871"></a>
-<span class="sourceLineNo">2872</span>      } else {<a name="line.2872"></a>
-<span class="sourceLineNo">2873</span>        for (byte[] family : scan.getFamilyMap().keySet()) {<a name="line.2873"></a>
-<span class="sourceLineNo">2874</span>          checkFamily(family);<a name="line.2874"></a>
-<span class="sourceLineNo">2875</span>        }<a name="line.2875"></a>
-<span class="sourceLineNo">2876</span>      }<a name="line.2876"></a>
-<span class="sourceLineNo">2877</span>      return instantiateRegionScanner(scan, additionalScanners, nonceGroup, nonce);<a name="line.2877"></a>
-<span class="sourceLineNo">2878</span>    } finally {<a name="line.2878"></a>
-<span class="sourceLineNo">2879</span>      closeRegionOperation(Operation.SCAN);<a name="line.2879"></a>
-<span class="sourceLineNo">2880</span>    }<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>  protected RegionScanner instantiateRegionScanner(Scan scan,<a name="line.2883"></a>
-<span class="sourceLineNo">2884</span>      List&lt;KeyValueScanner&gt; additionalScanners) throws IOException {<a name="line.2884"></a>
-<span class="sourceLineNo">2885</span>    return instantiateRegionScanner(scan, additionalScanners, HConstants.NO_NONCE,<a name="line.2885"></a>
-<span class="sourceLineNo">2886</span>      HConstants.NO_NONCE);<a name="line.2886"></a>
-<span class="sourceLineNo">2887</span>  }<a name="line.2887"></a>
-<span class="sourceLineNo">2888</span><a name="line.2888"></a>
-<span class="sourceLineNo">2889</span>  protected RegionScannerImpl instantiateRegionScanner(Scan scan,<a name="line.2889"></a>
-<span class="sourceLineNo">2890</span>      List&lt;KeyValueScanner&gt; additionalScanners, long nonceGroup, long nonce) throws IOException {<a name="line.2890"></a>
-<span class="sourceLineNo">2891</span>    if (scan.isReversed()) {<a name="line.2891"></a>
-<span class="sourceLineNo">2892</span>      if (scan.getFilter() != null) {<a name="line.2892"></a>
-<span class="sourceLineNo">2893</span>        scan.getFilter().setReversed(true);<a name="line.2893"></a>
-<span class="sourceLineNo">2894</span>      }<a name="line.2894"></a>
-<span class="sourceLineNo">2895</span>      return new ReversedRegionScannerImpl(scan, additionalScanners, this);<a name="line.2895"></a>
-<span class="sourceLineNo">2896</span>    }<a name="line.2896"></a>
-<span class="sourceLineNo">2897</span>    return new RegionScannerImpl(scan, additionalScanners, this, nonceGroup, nonce);<a name="line.2897"></a>
-<span class="sourceLineNo">2898</span>  }<a name="line.2898"></a>
-<span class="sourceLineNo">2899</span><a name="line.2899"></a>
-<span class="sourceLineNo">2900</span>  /**<a name="line.2900"></a>
-<span class="sourceLineNo">2901</span>   * Prepare a delete for a row mutation processor<a name="line.2901"></a>
-<span class="sourceLineNo">2902</span>   * @param delete The passed delete is modified by this method. WARNING!<a name="line.2902"></a>
-<span class="sourceLineNo">2903</span>   * @throws IOException<a name="line.2903"></a>
-<span class="sourceLineNo">2904</span>   */<a name="line.2904"></a>
-<span class="sourceLineNo">2905</span>  public void prepareDelete(Delete delete) throws IOException {<a name="line.2905"></a>
-<span class="sourceLineNo">2906</span>    // Check to see if this is a deleteRow insert<a name="line.2906"></a>
-<span class="sourceLineNo">2907</span>    if(delete.getFamilyCellMap().isEmpty()){<a name="line.2907"></a>
-<span class="sourceLineNo">2908</span>      for(byte [] family : this.htableDescriptor.getColumnFamilyNames()){<a name="line.2908"></a>
-<span class="sourceLineNo">2909</span>        // Don't eat the timestamp<a name="line.2909"></a>
-<span class="sourceLineNo">2910</span>        delete.addFamily(family, delete.getTimestamp());<a name="line.2910"></a>
-<span class="sourceLineNo">2911</span>      }<a name="line.2911"></a>
-<span class="sourceLineNo">2912</span>    } else {<a name="line.2912"></a>
-<span class="sourceLineNo">2913</span>      for(byte [] family : delete.getFamilyCellMap().keySet()) {<a name="line.2913"></a>
-<span class="sourceLineNo">2914</span>        if(family == null) {<a name="line.2914"></a>
-<span class="sourceLineNo">2915</span>          throw new NoSuchColumnFamilyException("Empty family is invalid");<a name="line.2915"></a>
-<span class="sourceLineNo">2916</span>        }<a name="line.2916"></a>
-<span class="sourceLineNo">2917</span>        checkFamily(family);<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><a name="line.2921"></a>
-<span class="sourceLineNo">2922</span>  @Override<a name="line.2922"></a>
-<span class="sourceLineNo">2923</span>  public void delete(Delete delete) throws IOException {<a name="line.2923"></a>
-<span class="sourceLineNo">2924</span>    checkReadOnly();<a name="line.2924"></a>
-<span class="sourceLineNo">2925</span>    checkResources();<a name="line.2925"></a>
-<span class="sourceLineNo">2926</span>    startRegionOperation(Operation.DELETE);<a name="line.2926"></a>
-<span class="sourceLineNo">2927</span>    try {<a name="line.2927"></a>
-<span class="sourceLineNo">2928</span>      // All edits for the given row (across all column families) must happen atomically.<a name="line.2928"></a>
-<span class="sourceLineNo">2929</span>      doBatchMutate(delete);<a name="line.2929"></a>
-<span class="sourceLineNo">2930</span>    } finally {<a name="line.2930"></a>
-<span class="sourceLineNo">2931</span>      closeRegionOperation(Operation.DELETE);<a name="line.2931"></a>
-<span class="sourceLineNo">2932</span>    }<a name="line.2932"></a>
-<span class="sourceLineNo">2933</span>  }<a name="line.2933"></a>
-<span class="sourceLineNo">2934</span><a name="line.2934"></a>
-<span class="sourceLineNo">2935</span>  /**<a name="line.2935"></a>
-<span class="sourceLineNo">2936</span>   * Row needed by below method.<a name="line.2936"></a>
-<span class="sourceLineNo">2937</span>   */<a name="line.2937"></a>
-<span class="sourceLineNo">2938</span>  private static final byte [] FOR_UNIT_TESTS_ONLY = Bytes.toBytes("ForUnitTestsOnly");<a name="line.2938"></a>
-<span class="sourceLineNo">2939</span><a name="line.2939"></a>
-<span class="sourceLineNo">2940</span>  /**<a name="line.2940"></a>
-<span class="sourceLineNo">2941</span>   * This is used only by unit tests. Not required to be a public API.<a name="line.2941"></a>
-<span class="sourceLineNo">2942</span>   * @param familyMap map of family to edits for the given family.<a name="line.2942"></a>
-<span class="sourceLineNo">2943</span>   * @throws IOException<a name="line.2943"></a>
-<span class="sourceLineNo">2944</span>   */<a name="line.2944"></a>
-<span class="sourceLineNo">2945</span>  void delete(NavigableMap&lt;byte[], List&lt;Cell&gt;&gt; familyMap,<a name="line.2945"></a>
-<span class="sourceLineNo">2946</span>      Durability durability) throws IOException {<a name="line.2946"></a>
-<span class="sourceLineNo">2947</span>    Delete delete = new Delete(FOR_UNIT_TESTS_ONLY);<a name="line.2947"></a>
-<span class="sourceLineNo">2948</span>    delete.setFamilyCellMap(familyMap);<a name="line.2948"></a>
-<span class="sourceLineNo">2949</span>    delete.setDurability(durability);<a name="line.2949"></a>
-<span class="sourceLineNo">2950</span>    doBatchMutate(delete);<a name="line.2950"></a>
-<span class="sourceLineNo">2951</span>  }<a name="line.2951"></a>
-<span class="sourceLineNo">2952</span><a name="line.2952"></a>
-<span class="sourceLineNo">2953</span>  /**<a name="line.2953"></a>
-<span class="sourceLineNo">2954</span>   * Set up correct timestamps in the KVs in Delete object.<a name="line.2954"></a>
-<span class="sourceLineNo">2955</span>   * &lt;p&gt;Caller should have the row and region locks.<a name="line.2955"></a>
-<span class="sourceLineNo">2956</span>   * @param mutation<a name="line.2956"></a>
-<span class="sourceLineNo">2957</span>   * @param familyMap<a name="line.2957"></a>
-<span class="sourceLineNo">2958</span>   * @param byteNow<a name="line.2958"></a>
-<span class="sourceLineNo">2959</span>   * @throws IOException<a name="line.2959"></a>
-<span class="sourceLineNo">2960</span>   */<a name="line.2960"></a>
-<span class="sourceLineNo">2961</span>  public void prepareDeleteTimestamps(Mutation mutation, Map&lt;byte[], List&lt;Cell&gt;&gt; familyMap,<a name="line.2961"></a>
-<span class="sourceLineNo">2962</span>      byte[] byteNow) throws IOException {<a name="line.2962"></a>
-<span class="sourceLineNo">2963</span>    for (Map.Entry&lt;byte[], List&lt;Cell&gt;&gt; e : familyMap.entrySet()) {<a name="line.2963"></a>
-<span class="sourceLineNo">2964</span><a name="line.2964"></a>
-<span class="sourceLineNo">2965</span>      byte[] family = e.getKey();<a name="line.2965"></a>
-<span class="sourceLineNo">2966</span>      List&lt;Cell&gt; cells = e.getValue();<a name="line.2966"></a>
-<span class="sourceLineNo">2967</span>      assert cells instanceof RandomAccess;<a name="line.2967"></a>
-<span class="sourceLineNo">2968</span><a name="line.2968"></a>
-<span class="sourceLineNo">2969</span>      Map&lt;byte[], Integer&gt; kvCount = new TreeMap&lt;&gt;(Bytes.BYTES_COMPARATOR);<a name="line.2969"></a>
-<span class="sourceLineNo">2970</span>      int listSize = cells.size();<a name="line.2970"></a>
-<span class="sourceLineNo">2971</span>      for (int i=0; i &lt; listSize; i++) {<a name="line.2971"></a>
-<span class="sourceLineNo">2972</span>        Cell cell = cells.get(i);<a name="line.2972"></a>
-<span class="sourceLineNo">2973</span>        //  Check if time is LATEST, change to time of most recent addition if so<a name="line.2973"></a>
-<span class="sourceLineNo">2974</span>        //  This is expensive.<a name="line.2974"></a>
-<span class="sourceLineNo">2975</span>        if (cell.getTimestamp() == HConstants.LATEST_TIMESTAMP<a name="line.2975"></a>
-<span class="sourceLineNo">2976</span>            &amp;&amp; PrivateCellUtil.isDeleteType(cell)) {<a name="line.2976"></a>
-<span class="sourceLineNo">2977</span>          byte[] qual = CellUtil.cloneQualifier(cell);<a name="line.2977"></a>
-<span class="sourceLineNo">2978</span><a name="line.2978"></a>
-<span class="sourceLineNo">2979</span>          Integer count = kvCount.get(qual);<a name="line.2979"></a>
-<span class="sourceLineNo">2980</span>          if (count == null) {<a name="line.2980"></a>
-<span class="sourceLineNo">2981</span>            kvCount.put(qual, 1);<a name="line.2981"></a>
-<span class="sourceLineNo">2982</span>          } else {<a name="line.2982"></a>
-<span class="sourceLineNo">2983</span>            kvCount.put(qual, count + 1);<a name="line.2983"></a>
-<span class="sourceLineNo">2984</span>          }<a name="line.2984"></a>
-<span class="sourceLineNo">2985</span>          count = kvCount.get(qual);<a name="line.2985"></a>
-<span class="sourceLineNo">2986</span><a name="line.2986"></a>
-<span class="sourceLineNo">2987</span>          Get get = new Get(CellUtil.cloneRow(cell));<a name="line.2987"></a>
-<span class="sourceLineNo">2988</span>          get.setMaxVersions(count);<a name="line.2988"></a>
-<span class="sourceLineNo">2989</span>          get.addColumn(family, qual);<a name="line.2989"></a>
-<span class="sourceLineNo">2990</span>          if (coprocessorHost != null) {<a name="line.2990"></a>
-<span class="sourceLineNo">2991</span>            if (!coprocessorHost.prePrepareTimeStampForDeleteVersion(mutation, cell,<a name="line.2991"></a>
-<span class="sourceLineNo">2992</span>                byteNow, get)) {<a name="line.2992"></a>
-<span class="sourceLineNo">2993</span>              updateDeleteLatestVersionTimestamp(cell, get, count, byteNow);<a name="line.2993"></a>
-<span class="sourceLineNo">2994</span>            }<a name="line.2994"></a>
-<span class="sourceLineNo">2995</span>          } else {<a name="line.2995"></a>
-<span class="sourceLineNo">2996</span>            updateDeleteLatestVersionTimestamp(cell, get, count, byteNow);<a name="line.2996"></a>
-<span class="sourceLineNo">2997</span>          }<a name="line.2997"></a>
-<span class="sourceLineNo">2998</span>        } else {<a name="line.2998"></a>
-<span class="sourceLineNo">2999</span>          PrivateCellUtil.updateLatestStamp(cell, byteNow);<a name="line.2999"></a>
-<span class="sourceLineNo">3000</span>        }<a name="line.3000"></a>
-<span class="sourceLineNo">3001</span>      }<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><a name="line.3004"></a>
-<span class="sourceLineNo">3005</span>  void updateDeleteLatestVersionTimestamp(Cell cell, Get get, int count, byte[] byteNow)<a name="line.3005"></a>
-<span class="sourceLineNo">3006</span>      throws IOException {<a name="line.3006"></a>
-<span class="sourceLineNo">3007</span>    List&lt;Cell&gt; result = get(get, false);<a name="line.3007"></a>
-<span class="sourceLineNo">3008</span><a name="line.3008"></a>
-<span class="sourceLineNo">3009</span>    if (result.size() &lt; count) {<a name="line.3009"></a>
-<span class="sourceLineNo">3010</span>      // Nothing to delete<a name="line.3010"></a>
-<span class="sourceLineNo">3011</span>      PrivateCellUtil.updateLatestStamp(cell, byteNow);<a name="line.3011"></a>
-<span class="sourceLineNo">3012</span>      return;<a name="line.3012"></a>
-<span class="sourceLineNo">3013</span>    }<a name="line.3013"></a>
-<span class="sourceLineNo">3014</span>    if (result.size() &gt; count) {<a name="line.3014"></a>
-<span class="sourceLineNo">3015</span>      throw new RuntimeException("Unexpected size: " + result.size());<a name="line.3015"></a>
-<span class="sourceLineNo">3016</span>    }<a name="line.3016"></a>
-<span class="sourceLineNo">3017</span>    Cell getCell = result.get(count - 1);<a name="line.3017"></a>
-<span class="sourceLineNo">3018</span>    PrivateCellUtil.setTimestamp(cell, getCell.getTimestamp());<a name="line.3018"></a>
-<span class="sourceLineNo">3019</span>  }<a name="line.3019"></a>
-<span class="sourceLineNo">3020</span><a name="line.3020"></a>
-<span class="sourceLineNo">3021</span>  @Override<a name="line.3021"></a>
-<span class="sourceLineNo">3022</span>  public void put(Put put) throws IOException {<a name="line.3022"></a>
-<span class="sourceLineNo">3023</span>    checkReadOnly();<a name="line.3023"></a>
-<span class="sourceLineNo">3024</span><a name="line.3024"></a>
-<span class="sourceLineNo">3025</span>    // Do a rough check that we have resources to accept a write.  The check is<a name="line.3025"></a>
-<span class="sourceLineNo">3026</span>    // 'rough' in that between the resource check and the call to obtain a<a name="line.3026"></a>
-<span class="sourceLineNo">3027</span>    // read lock, resources may run out.  For now, the thought is that this<a name="line.3027"></a>
-<span class="sourceLineNo">3028</span>    // will be extremely rare; we'll deal with it when it happens.<a name="line.3028"></a>
-<span class="sourceLineNo">3029</span>    checkResources();<a name="line.3029"></a>
-<span class="sourceLineNo">3030</span>    startRegionOperation(Operation.PUT);<a name="line.3030"></a>
-<span class="sourceLineNo">3031</span>    try {<a name="line.3031"></a>
-<span class="sourceLineNo">3032</span>      // All edits for the given row (across all column families) must happen atomically.<a name="line.3032"></a>
-<span class="sourceLineNo">3033</span>      doBatchMutate(put);<a name="line.3033"></a>
-<span class="sourceLineNo">3034</span>    } finally {<a name="line.3034"></a>
-<span class="sourceLineNo">3035</span>      closeRegionOperation(Operation.PUT);<a name="line.3035"></a>
-<span class="sourceLineNo">3036</span>    }<a name="line.3036"></a>
-<span class="sourceLineNo">3037</span>  }<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>   * Class that tracks the progress of a batch operations, accumulating status codes and tracking<a name="line.3040"></a>
-<span class="sourceLineNo">3041</span>   * the index at which processing is proceeding. These batch operations may get split into<a name="line.3041"></a>
-<span class="sourceLineNo">3042</span>   * mini-batches for processing.<a name="line.3042"></a>
-<span class="sourceLineNo">3043</span>   */<a name="line.3043"></a>
-<span class="sourceLineNo">3044</span>  private abstract static class BatchOperation&lt;T&gt; {<a name="line.3044"></a>
-<span class="sourceLineNo">3045</span>    protected final T[] operations;<a name="line.3045"></a>
-<span class="sourceLineNo">3046</span>    protected final OperationStatus[] retCodeDetails;<a name="line.3046"></a>
-<span class="sourceLineNo">3047</span>    protected final WALEdit[] walEditsFromCoprocessors;<a name="line.3047"></a>
-<span class="sourceLineNo">3048</span>    // reference family cell maps directly so coprocessors can mutate them if desired<a name="line.3048"></a>
-<span class="sourceLineNo">3049</span>    protected final Map&lt;byte[], List&lt;Cell&gt;&gt;[] familyCellMaps;<a name="line.3049"></a>
-<span class="sourceLineNo">3050</span><a name="line.3050"></a>
-<span class="sourceLineNo">3051</span>    protected final HRegion region;<a name="line.3051"></a>
-<span class="sourceLineNo">3052</span>    protected int nextIndexToProcess = 0;<a name="line.3052"></a>
-<span class="sourceLineNo">3053</span>    protected final ObservedExceptionsInBatch observedExceptions;<a name="line.3053"></a>
-<span class="sourceLineNo">3054</span>    //Durability of the batch (highest durability of all operations)<a name="line.3054"></a>
-<span class="sourceLineNo">3055</span>    protected Durability durability;<a name="line.3055"></a>
-<span class="sourceLineNo">3056</span>    protected boolean atomic = false;<a name="line.3056"></a>
-<span class="sourceLineNo">3057</span><a name="line.3057"></a>
-<span class="sourceLineNo">3058</span>    public BatchOperation(final HRegion region, T[] operations) {<a name="line.3058"></a>
-<span class="sourceLineNo">3059</span>      this.operations = operations;<a name="line.3059"></a>
-<span class="sourceLineNo">3060</span>      this.retCodeDetails = new OperationStatus[operations.length];<a name="line.3060"></a>
-<span class="sourceLineNo">3061</span>      Arrays.fill(this.retCodeDetails, OperationStatus.NOT_RUN);<a name="line.3061"></a>
-<span class="sourceLineNo">3062</span>      this.walEditsFromCoprocessors = new WALEdit[operations.length];<a name="line.3062"></a>
-<span class="sourceLineNo">3063</span>      familyCellMaps = new Map[operations.length];<a name="line.3063"></a>
-<span class="sourceLineNo">3064</span><a name="line.3064"></a>
-<span class="sourceLineNo">3065</span>      this.region = region;<a name="line.3065"></a>
-<span class="sourceLineNo">3066</span>      observedExceptions = new ObservedExceptionsInBatch();<a name="line.3066"></a>
-<span class="sourceLineNo">3067</span>      durability = Durability.USE_DEFAULT;<a name="line.3067"></a>
-<span class="sourceLineNo">3068</span>    }<a name="line.3068"></a>
-<span class="sourceLineNo">3069</span><a name="line.3069"></a>
-<span class="sourceLineNo">3070</span>    /**<a name="line.3070"></a>
-<span class="sourceLineNo">3071</span>     * Visitor interface for batch operations<a name="line.3071"></a>
-<span class="sourceLineNo">3072</span>     */<a name="line.3072"></a>
-<span class="sourceLineNo">3073</span>    @FunctionalInterface<a name="line.3073"></a>
-<span class="sourceLineNo">3074</span>    public interface Visitor {<a name="line.3074"></a>
-<span class="sourceLineNo">3075</span>      /**<a name="line.3075"></a>
-<span class="sourceLineNo">3076</span>       * @param index operation index<a name="line.3076"></a>
-<span class="sourceLineNo">3077</span>       * @return If true continue visiting remaining entries, break otherwise<a name="line.3077"></a>
-<span class="sourceLineNo">3078</span>       */<a name="line.3078"></a>
-<span class="sourceLineNo">3079</span>      boolean visit(int index) throws IOException;<a name="line.3079"></a>
-<span class="sourceLineNo">3080</span>    }<a name="line.3080"></a>
-<span class="sourceLineNo">3081</span><a name="line.3081"></a>
-<span class="sourceLineNo">3082</span>    /**<a name="line.3082"></a>
-<span class="sourceLineNo">3083</span>     * Helper method for visiting pending/ all batch operations<a name="line.3083"></a>
-<span class="sourceLineNo">3084</span>     */<a name="line.3084"></a>
-<span class="sourceLineNo">3085</span>    public void visitBatchOperations(boolean pendingOnly, int lastIndexExclusive, Visitor visitor)<a name="line.3085"></a>
-<span class="sourceLineNo">3086</span>        throws IOException {<a name="line.3086"></a>
-<span class="sourceLineNo">3087</span>      assert lastIndexExclusive &lt;= this.size();<a name="line.3087"></a>
-<span class="sourceLineNo">3088</span>      for (int i = nextIndexToProcess; i &lt; lastIndexExclusive; i++) {<a name="line.3088"></a>
-<span class="sourceLineNo">3089</span>        if (!pendingOnly || isOperationPending(i)) {<a name="line.3089"></a>
-<span class="sourceLineNo">3090</span>          if (!visitor.visit(i)) {<a name="line.3090"></a>
-<span class="sourceLineNo">3091</span>            break;<a name="line.3091"></a>
-<span class="sourceLineNo">3092</span>          }<a name="line.3092"></a>
-<span class="sourceLineNo">3093</span>        }<a name="line.3093"></a>
-<span class="sourceLineNo">3094</span>      }<a name="line.3094"></a>
-<span class="sourceLineNo">3095</span>    }<a name="line.3095"></a>
-<span class="sourceLineNo">3096</span><a name="line.3096"></a>
-<span class="sourceLineNo">3097</span>    public abstract Mutation getMutation(int index);<a name="line.3097"></a>
-<span class="sourceLineNo">3098</span><a name="line.3098"></a>
-<span class="sourceLineNo">3099</span>    public abstract long getNonceGroup(int index);<a name="line.3099"></a>
-<span class="sourceLineNo">3100</span><a name="line.3100"></a>
-<span class="sourceLineNo">3101</span>    public abstract long getNonce(int index);<a name="line.3101"></a>
-<span class="sourceLineNo">3102</span><a name="line.3102"></a>
-<span class="sourceLineNo">3103</span>    /**<a name="line.3103"></a>
-<span class="sourceLineNo">3104</span>     * This method is potentially expensive and useful mostly for non-replay CP path.<a name="line.3104"></a>
-<span class="sourceLineNo">3105</span>     */<a name="line.3105"></a>
-<span class="sourceLineNo">3106</span>    public abstract Mutation[] getMutationsForCoprocs();<a name="line.3106"></a>
-<span class="sourceLineNo">3107</span><a name="line.3107"></a>
-<span class="sourceLineNo">3108</span>    public abstract boolean isInReplay();<a name="line.3108"></a>
-<span class="sourceLineNo">3109</span><a name="line.3109"></a>
-<span class="sourceLineNo">3110</span>    public abstract long getOrigLogSeqNum();<a name="line.3110"></a>
-<span class="sourceLineNo">3111</span><a name="line.3111"></a>
-<span class="sourceLineNo">3112</span>    public abstract void startRegionOperation() throws IOException;<a name="line.3112"></a>
-<span class="sourceLineNo">3113</span><a name="line.3113"></a>
-<span class="sourceLineNo">3114</span>    public abstract void closeRegionOperation() throws IOException;<a name="line.3114"></a>
-<span class="sourceLineNo">3115</span><a name="line.3115"></a>
-<span class="sourceLineNo">3116</span>    /**<a name="line.3116"></a>
-<span class="sourceLineNo">3117</span>     * Validates each mutation and prepares a batch for write. If necessary (non-replay case), runs<a name="line.3117"></a>
-<span class="sourceLineNo">3118</span>     * CP prePut()/ preDelete() hooks for all mutations in a batch. This is intended to operate on<a name="line.3118"></a>
-<span class="sourceLineNo">3119</span>     * entire batch and will be called from outside of class to check and prepare batch. This can<a name="line.3119"></a>
-<span class="sourceLineNo">3120</span>     * be implemented by calling helper method {@link #checkAndPrepareMutation(int, long)} in a<a name="line.3120"></a>
-<span class="sourceLineNo">3121</span>     * 'for' loop over mutations.<a name="line.3121"></a>
-<span class="sourceLineNo">3122</span>     */<a name="line.3122"></a>
-<span class="sourceLineNo">3123</span>    public abstract void checkAndPrepare() throws IOException;<a name="line.3123"></a>
-<span class="sourceLineNo">3124</span><a name="line.3124"></a>
-<span class="sourceLineNo">3125</span>    /**<a name="line.3125"></a>
-<span class="sourceLineNo">3126</span>     * Implement any Put request specific check and prepare logic here. Please refer to<a name="line.3126"></a>
-<span class="sourceLineNo">3127</span>     * {@link #checkAndPrepareMutation(Mutation, long)} for how its used.<a name="line.3127"></a>
-<span class="sourceLineNo">3128</span>     */<a name="line.3128"></a>
-<span class="sourceLineNo">3129</span>    protected abstract void checkAndPreparePut(final Put p) throws IOException;<a name="line.3129"></a>
-<span class="sourceLineNo">3130</span><a name="line.3130"></a>
-<span class="sourceLineNo">3131</span>    /**<a name="line.3131"></a>
-<span class="sourceLineNo">3132</span>     * If necessary, calls preBatchMutate() CP hook for a mini-batch and updates metrics, cell<a name="line.3132"></a>
-<span class="sourceLineNo">3133</span>     * count, tags and timestamp for all cells of all operations in a mini-batch.<a name="line.3133"></a>
-<span class="sourceLineNo">3134</span>     */<a name="line.3134"></a>
-<span class="sourceLineNo">3135</span>    public abstract void prepareMiniBatchOperations(MiniBatchOperationInProgress&lt;Mutation&gt;<a name="line.3135"></a>
-<span class="sourceLineNo">3136</span>        miniBatchOp, long timestamp, final List&lt;RowLock&gt; acquiredRowLocks) throws IOException;<a name="line.3136"></a>
-<span class="sourceLineNo">3137</span><a name="line.3137"></a>
-<span class="sourceLineNo">3138</span>    /**<a name="line.3138"></a>
-<span class="sourceLineNo">3139</span>     * Write mini-batch operations to MemStore<a name="line.3139"></a>
-<span class="sourceLineNo">3140</span>     */<a name="line.3140"></a>
-<span class="sourceLineNo">3141</span>    public abstract WriteEntry writeMiniBatchOperationsToMemStore(<a name="line.3141"></a>
-<span class="sourceLineNo">3142</span>        final MiniBatchOperationInProgress&lt;Mutation&gt; miniBatchOp, final WriteEntry writeEntry)<a name="line.3142"></a>
-<span class="sourceLineNo">3143</span>        throws IOException;<a name="line.3143"></a>
-<span class="sourceLineNo">3144</span><a name="line.3144"></a>
-<span class="sourceLineNo">3145</span>    protected void writeMiniBatchOperationsToMemStore(<a name="line.3145"></a>
-<span class="sourceLineNo">3146</span>        final MiniBatchOperationInProgress&lt;Mutation&gt; miniBatchOp, final long writeNumber)<a name="line.3146"></a>
-<span class="sourceLineNo">3147</span>        throws IOException {<a name="line.3147"></a>
-<span class="sourceLineNo">3148</span>      MemStoreSizing memStoreAccounting = new NonThreadSafeMemStoreSizing();<a name="line.3148"></a>
-<span class="sourceLineNo">3149</span>      visitBatchOperations(true, miniBatchOp.getLastIndexExclusive(), (int index) -&gt; {<a name="line.3149"></a>
-<span class="sourceLineNo">3150</span>        // We need to update the sequence id for following reasons.<a name="line.3150"></a>
-<span class="sourceLineNo">3151</span>        // 1) If the op is in replay mode, FSWALEntry#stampRegionSequenceId won't stamp sequence id.<a name="line.3151"></a>
-<span class="sourceLineNo">3152</span>        // 2) If no WAL, FSWALEntry won't be used<a name="line.3152"></a>
-<span class="sourceLineNo">3153</span>        // we use durability of the original mutation for the mutation passed by CP.<a name="line.3153"></a>
-<span class="sourceLineNo">3154</span>        if (isInReplay() || getMutation(index).getDurability() == Durability.SKIP_WAL) {<a name="line.3154"></a>
-<span class="sourceLineNo">3155</span>          region.updateSequenceId(familyCellMaps[index].values(), writeNumber);<a name="line.3155"></a>
-<span class="sourceLineNo">3156</span>        }<a name="line.3156"></a>
-<span class="sourceLineNo">3157</span>        applyFamilyMapToMemStore(familyCellMaps[index], memStoreAccounting);<a name="line.3157"></a>
-<span class="sourceLineNo">3158</span>        return true;<a name="line.3158"></a>
-<span class="sourceLineNo">3159</span>      });<a name="line.3159"></a>
-<span class="sourceLineNo">3160</span>      // update memStore size<a name="line.3160"></a>
-<span class="sourceLineNo">3161</span>      region.incMemStoreSize(memStoreAccounting.getDataSize(), memStoreAccounting.getHeapSize(),<a name="line.3161"></a>
-<span class="sourceLineNo">3162</span>          memStoreAccounting.getOffHeapSize());<a name="line.3162"></a>
-<span class="sourceLineNo">3163</span>    }<a name="line.3163"></a>
-<span class="sourceLineNo">3164</span><a name="line.3164"></a>
-<span class="sourceLineNo">3165</span>    public boolean isDone() {<a name="line.3165"></a>
-<span class="sourceLineNo">3166</span>      return nextIndexToProcess == operations.length;<a name="line.3166"></a>
-<span class="sourceLineNo">3167</span>    }<a name="line.3167"></a>
-<span class="sourceLineNo">3168</span><a name="line.3168"></a>
-<span class="sourceLineNo">3169</span>    public int size() {<a name="line.3169"></a>
-<span class="sourceLineNo">3170</span>      return operations.length;<a name="line.3170"></a>
-<span class="sourceLineNo">3171</span>    }<a name="line.3171"></a>
-<span class="sourceLineNo">3172</span><a name="line.3172"></a>
-<span class="sourceLineNo">3173</span>    public boolean isOperationPending(int index) {<a name="line.3173"></a>
-<span class="sourceLineNo">3174</span>      return retCodeDetails[index].getOperationStatusCode() == OperationStatusCode.NOT_RUN;<a name="line.3174"></a>
-<span class="sourceLineNo">3175</span>    }<a name="line.3175"></a>
-<span class="sourceLineNo">3176</span><a name="line.3176"></a>
-<span class="sourceLineNo">3177</span>    public List&lt;UUID&gt; getClusterIds() {<a name="line.3177"></a>
-<span class="sourceLineNo">3178</span>      assert size() != 0;<a name="line.3178"></a>
-<span class="sourceLineNo">3179</span>      return getMutation(0).getClusterIds();<a name="line.3179"></a>
-<span class="sourceLineNo">3180</span>    }<a name="line.3180"></a>
-<span class="sourceLineNo">3181</span><a name="line.3181"></a>
-<span class="sourceLineNo">3182</span>    boolean isAtomic() {<a name="line.3182"></a>
-<span class="sourceLineNo">3183</span>      return atomic;<a name="line.3183"></a>
-<span class="sourceLineNo">3184</span>    }<a name="line.3184"></a>
-<span class="sourceLineNo">3185</span><a name="line.3185"></a>
-<span class="sourceLineNo">3186</span>    /**<a name="line.3186"></a>
-<span class="sourceLineNo">3187</span>     * Helper method that checks and prepares only one mutation. This can be used to implement<a name="line.3187"></a>
-<span class="sourceLineNo">3188</span>     * {@link #checkAndPrepare()} for entire Batch.<a name="line.3188"></a>
-<span class="sourceLineNo">3189</span>     * NOTE: As CP prePut()/ preDelete() hooks may modify mutations, this method should be called<a name="line.3189"></a>
-<span class="sourceLineNo">3190</span>     * after prePut()/ preDelete() CP hooks are run for the mutation<a name="line.3190"></a>
-<span class="sourceLineNo">3191</span>     */<a name="line.3191"></a>
-<span class="sourceLineNo">3192</span>    protected void checkAndPrepareMutation(Mutation mutation, final long timestamp)<a name="line.3192"></a>
-<span class="sourceLineNo">3193</span>        throws IOException {<a name="line.3193"></a>
-<span class="sourceLineNo">3194</span>      region.checkRow(mutation.getRow(), "batchMutate");<a name="line.3194"></a>
-<span class="sourceLineNo">3195</span>      if (mutation instanceof Put) {<a name="line.3195"></a>
-<span class="sourceLineNo">3196</span>        // Check the families in the put. If bad, skip this one.<a name="line.3196"></a>
-<span class="sourceLineNo">3197</span>        checkAndPreparePut((Put) mutation);<a name="line.3197"></a>
-<span class="sourceLineNo">3198</span>        region.checkTimestamps(mutation.getFamilyCellMap(), timestamp);<a name="line.3198"></a>
-<span class="sourceLineNo">3199</span>      } else {<a name="line.3199"></a>
-<span class="sourceLineNo">3200</span>        region.prepareDelete((Delete) mutation);<a name="line.3200"></a>
-<span class="sourceLineNo">3201</span>      }<a name="line.3201"></a>
-<span class="sourceLineNo">3202</span>    }<a name="line.3202"></a>
-<span class="sourceLineNo">3203</span><a name="line.3203"></a>
-<span class="sourceLineNo">3204</span>    protected void checkAndPrepareMutation(int index, long timestamp) throws IOException {<a name="line.3204"></a>
-<span class="sourceLineNo">3205</span>      Mutation mutation = getMutation(index);<a name="line.3205"></a>
-<span class="sourceLineNo">3206</span>      try {<a name="line.3206"></a>
-<span class="sourceLineNo">3207</span>        this.checkAndPrepareMutation(mutation, timestamp);<a name="line.3207"></a>
-<span class="sourceLineNo">3208</span><a name="line.3208"></a>
-<span class="sourceLineNo">3209</span>        // store the family map reference to allow for mutations<a name="line.3209"></a>
-<span class="sourceLineNo">3210</span>        familyCellMaps[index] = mutation.getFamilyCellMap();<a name="line.3210"></a>
-<span class="sourceLineNo">3211</span>        // store durability for the batch (highest durability of all operations in the batch)<a name="line.3211"></a>
-<span class="sourceLineNo">3212</span>        Durability tmpDur = region.getEffectiveDurability(mutation.getDurability());<a name="line.3212"></a>
-<span class="sourceLineNo">3213</span>        if (tmpDur.ordinal() &gt; durability.ordinal()) {<a name="line.3213"></a>
-<span class="sourceLineNo">3214</span>          durability = tmpDur;<a name="line.3214"></a>
-<span class="sourceLineNo">3215</span>        }<a name="line.3215"></a>
-<span class="sourceLineNo">3216</span>      } catch (NoSuchColumnFamilyException nscfe) {<a name="line.3216"></a>
-<span class="sourceLineNo">3217</span>        final String msg = "No such column family in batch mutation. ";<a name="line.3217"></a>
-<span class="sourceLineNo">3218</span>        if (observedExceptions.hasSeenNoSuchFamily()) {<a name="line.3218"></a>
-<span class="sourceLineNo">3219</span>          LOG.warn(msg + nscfe.getMessage());<a name="line.3219"></a>
-<span class="sourceLineNo">3220</span>        } else {<a name="line.3220"></a>
-<span class="sourceLineNo">3221</span>          LOG.warn(msg, nscfe);<a name="line.3221"></a>
-<span class="sourceLineNo">3222</span>          observedExceptions.sawNoSuchFamily();<a name="line.3222"></a>
-<span class="sourceLineNo">3223</span>        }<a name="line.3223"></a>
-<span class="sourceLineNo">3224</span>        retCodeDetails[index] = new OperationStatus(<a name="line.3224"></a>
-<span class="sourceLineNo">3225</span>            OperationStatusCode.BAD_FAMILY, nscfe.getMessage());<a name="line.3225"></a>
-<span class="sourceLineNo">3226</span>        if (isAtomic()) { // fail, atomic means all or none<a name="line.3226"></a>
-<span class="sourceLineNo">3227</span>          throw nscfe;<a name="line.3227"></a>
-<span class="sourceLineNo">3228</span>        }<a name="line.3228"></a>
-<span class="sourceLineNo">3229</span>      } catch (FailedSanityCheckException fsce) {<a name="line.3229"></a>
-<span class="sourceLineNo">3230</span>        final String msg = "Batch Mutation did not pass sanity check. ";<a name="line.3230"></a>
-<span class="sourceLineNo">3231</span>        if (observedExceptions.hasSeenFailedSanityCheck()) {<a name="line.3231"></a>
-<span class="sourceLineNo">3232</span>          LOG.warn(msg + fsce.getMessage());<a name="line.3232"></a>
-<span class="sourceLineNo">3233</span>        } else {<a name="line.3233"></a>
-<span class="sourceLineNo">3234</span>          LOG.warn(msg, fsce);<a name="line.3234"></a>
-<span class="sourceLineNo">3235</span>          observedExceptions.sawFailedSanityCheck();<a name="line.3235"></a>
-<span class="sourceLineNo">3236</span>        }<a name="line.3236"></a>
-<span class="sourceLineNo">3237</span>        retCodeDetails[index] = new OperationStatus(<a name="line.3237"></a>
-<span class="sourceLineNo">3238</span>            OperationStatusCode.SANITY_CHECK_FAILURE, fsce.getMessage());<a name="line.3238"></a>
-<span class="sourceLineNo">3239</span>        if (isAtomic()) {<a name="line.3239"></a>
-<span class="sourceLineNo">3240</span>          throw fsce;<a name="line.3240"></a>
-<span class="sourceLineNo">3241</span>        }<a name="line.3241"></a>
-<span class="sourceLineNo">3242</span>      } catch (WrongRegionException we) {<a name="line.3242"></a>
-<span class="sourceLineNo">3243</span>        final String msg = "Batch mutation had a row that does not belong to this region. ";<a name="line.3243"></a>
-<span class="sourceLineNo">3244</span>        if (observedExceptions.hasSeenWrongRegion()) {<a name="line.3244"></a>
-<span class="sourceLineNo">3245</span>          LOG.warn(msg + we.getMessage());<a name="line.3245"></a>
-<span class="sourceLineNo">3246</span>        } else {<a name="line.3246"></a>
-<span class="sourceLineNo">3247</span>          LOG.warn(msg, we);<a name="line.3247"></a>
-<span class="sourceLineNo">3248</span>          observedExceptions.sawWrongRegion();<a name="line.3248"></a>
-<span class="sourceLineNo">3249</span>        }<a name="line.3249"></a>
-<span class="sourceLineNo">3250</span>        retCodeDetails[index] = new OperationStatus(<a name="line.3250"></a>
-<span class="sourceLineNo">3251</span>            OperationStatusCode.SANITY_CHECK_FAILURE, we.getMessage());<a name="line.3251"></a>
-<span class="sourceLineNo">3252</span>        if (isAtomic()) {<a name="line.3252"></a>
-<span class="sourceLineNo">3253</span>          throw we;<a name="line.3253"></a>
-<span class="sourceLineNo">3254</span>        }<a name="line.3254"></a>
-<span class="sourceLineNo">3255</span>      }<a name="line.3255"></a>
-<span class="sourceLineNo">3256</span>    }<a name="line.3256"></a>
-<span class="sourceLineNo">3257</span><a name="line.3257"></a>
-<span class="sourceLineNo">3258</span>    /**<a name="line.3258"></a>
-<span class="sourceLineNo">3259</span>     * Creates Mini-batch of all operations [nextIndexToProcess, lastIndexExclusive) for which<a name="line.3259"></a>
-<span class="sourceLineNo">3260</span>     * a row lock can be acquired. All mutations with locked rows are considered to be<a name="line.3260"></a>
-<span class="sourceLineNo">3261</span>     * In-progress operations and hence the name {@link MiniBatchOperationInProgress}. Mini batch<a name="line.3261"></a>
-<span class="sourceLineNo">3262</span>     * is window over {@link BatchOperation} and contains contiguous pending operations.<a name="line.3262"></a>
-<span class="sourceLineNo">3263</span>     *<a name="line.3263"></a>
-<span class="sourceLineNo">3264</span>     * @param acquiredRowLocks keeps track of rowLocks acquired.<a name="line.3264"></a>
-<span class="sourceLineNo">3265</span>     */<a name="line.3265"></a>
-<span class="sourceLineNo">3266</span>    public MiniBatchOperationInProgress&lt;Mutation&gt; lockRowsAndBuildMiniBatch(<a name="line.3266"></a>
-<span class="sourceLineNo">3267</span>        List&lt;RowLock&gt; acquiredRowLocks) throws IOException {<a name="line.3267"></a>
-<span class="sourceLineNo">3268</span>      int readyToWriteCount = 0;<a name="line.3268"></a>
-<span class="sourceLineNo">3269</span>      int lastIndexExclusive = 0;<a name="line.3269"></a>
-<span class="sourceLineNo">3270</span>      RowLock prevRowLock = null;<a name="line.3270"></a>
-<span class="sourceLineNo">3271</span>      for (; lastIndexExclusive &lt; size(); lastIndexExclusive++) {<a name="line.3271"></a>
-<span class="sourceLineNo">3272</span>        // It reaches the miniBatchSize, stop here and process the miniBatch<a name="line.3272"></a>
-<span class="sourceLineNo">3273</span>        // This only applies to non-atomic batch operations.<a name="line.3273"></a>
-<span class="sourceLineNo">3274</span>        if (!isAtomic() &amp;&amp; (readyToWriteCount == region.miniBatchSize)) {<a name="line.3274"></a>
-<span class="sourceLineNo">3275</span>          break;<a name="line.3275"></a>
-<span class="sourceLineNo">3276</span>        }<a name="line.3276"></a>
-<span class="sourceLineNo">3277</span><a name="line.3277"></a>
-<span class="sourceLineNo">3278</span>        if (!isOperationPending(lastIndexExclusive)) {<a name="line.3278"></a>
-<span class="sourceLineNo">3279</span>          continue;<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>        // HBASE-19389 Limit concurrency of put with dense (hundreds) columns to avoid exhausting<a name="line.3282"></a>
-<span class="sourceLineNo">3283</span>        // RS handlers, covering both MutationBatchOperation and ReplayBatchOperation<a name="line.3283"></a>
-<span class="sourceLineNo">3284</span>        // The BAD_FAMILY/SANITY_CHECK_FAILURE cases are handled in checkAndPrepare phase and won't<a name="line.3284"></a>
-<span class="sourceLineNo">3285</span>        // pass the isOperationPending check<a name="line.3285"></a>
-<span class="sourceLineNo">3286</span>        Map&lt;byte[], List&lt;Cell&gt;&gt; curFamilyCellMap =<a name="line.3286"></a>
-<span class="sourceLineNo">3287</span>            getMutation(lastIndexExclusive).getFamilyCellMap();<a name="line.3287"></a>
-<span class="sourceLineNo">3288</span>        try {<a name="line.3288"></a>
-<span class="sourceLineNo">3289</span>          // start the protector before acquiring row lock considering performance, and will finish<a name="line.3289"></a>
-<span class="sourceLineNo">3290</span>          // it when encountering exception<a name="line.3290"></a>
-<span class="sourceLineNo">3291</span>          region.storeHotnessProtector.start(curFamilyCellMap);<a name="line.3291"></a>
-<span class="sourceLineNo">3292</span>        } catch (RegionTooBusyException rtbe) {<a name="line.3292"></a>
-<span class="sourceLineNo">3293</span>          region.storeHotnessProtector.finish(curFamilyCellMap);<a name="line.3293"></a>
-<span class="sourceLineNo">3294</span>          if (isAtomic()) {<a name="line.3294"></a>
-<span class="sourceLineNo">3295</span>            throw rtbe;<a name="line.3295"></a>
-<span class="sourceLineNo">3296</span>          }<a name="line.3296"></a>
-<span class="sourceLineNo">3297</span>          retCodeDetails[lastIndexExclusive] =<a name="line.3297"></a>
-<span class="sourceLineNo">3298</span>              new OperationStatus(OperationStatusCode.STORE_TOO_BUSY, rtbe.getMessage());<a name="line.3298"></a>
-<span class="sourceLineNo">3299</span>          continue;<a name="line.3299"></a>
-<span class="sourceLineNo">3300</span>        }<a name="line.3300"></a>
-<span class="sourceLineNo">3301</span><a name="line.3301"></a>
-<span class="sourceLineNo">3302</span>        Mutation mutation = getMutation(lastIndexExclusive);<a name="line.3302"></a>
-<span class="sourceLineNo">3303</span>        // If we haven't got any rows in our batch, we should block to get the next one.<a name="line.3303"></a>
-<span class="sourceLineNo">3304</span>        RowLock rowLock = null;<a name="line.3304"></a>
-<span class="sourceLineNo">3305</span>        boolean throwException = false;<a name="line.3305"></a>
-<span class="sourceLineNo">3306</span>        try {<a name="line.3306"></a>
-<span class="sourceLineNo">3307</span>          // if atomic then get exclusive lock, else shared lock<a name="line.3307"></a>
-<span class="sourceLineNo">3308</span>          rowLock = region.getRowLockInternal(mutation.getRow(), !isAtomic(), prevRowLock);<a name="line.3308"></a>
-<span class="sourceLineNo">3309</span>        } catch (TimeoutIOException | InterruptedIOException e) {<a name="line.3309"></a>
-<span class="sourceLineNo">3310</span>          // NOTE: We will retry when other exceptions, but we should stop if we receive<a name="line.3310"></a>
-<span class="sourceLineNo">3311</span>          // TimeoutIOException or InterruptedIOException as operation has timed out or<a name="line.3311"></a>
-<span class="sourceLineNo">3312</span>          // interrupted respectively.<a name="line.3312"></a>
-<span class="sourceLineNo">3313</span>          throwException = true;<a name="line.3313"></a>
-<span class="sourceLineNo">3314</span>          throw e;<a name="line.3314"></a>
-<span class="sourceLineNo">3315</span>        } catch (IOException ioe) {<a name="line.3315"></a>
-<span class="sourceLineNo">3316</span>          LOG.warn("Failed getting lock, row=" + Bytes.toStringBinary(mutation.getRow()), ioe);<a name="line.3316"></a>
-<span class="sourceLineNo">3317</span>          if (isAtomic()) { // fail, atomic means all or none<a name="line.3317"></a>
-<span class="sourceLineNo">3318</span>            throwException = true;<a name="line.3318"></a>
-<span class="sourceLineNo">3319</span>            throw ioe;<a name="line.3319"></a>
-<span class="sourceLineNo">3320</span>          }<a name="line.3320"></a>
-<span class="sourceLineNo">3321</span>        } catch (Throwable throwable) {<a name="line.3321"></a>
-<span class="sourceLineNo">3322</span>          throwException = true;<a name="line.3322"></a>
-<span class="sourceLineNo">3323</span>          throw throwable;<a name="line.3323"></a>
-<span class="sourceLineNo">3324</span>        } finally {<a name="line.3324"></a>
-<span class="sourceLineNo">3325</span>          if (throwException) {<a name="line.3325"></a>
-<span class="sourceLineNo">3326</span>            region.storeHotnessProtector.finish(curFamilyCellMap);<a name="line.3326"></a>
-<span class="sourceLineNo">3327</span>          }<a name="line.3327"></a>
-<span class="sourceLineNo">3328</span>        }<a name="line.3328"></a>
-<span class="sourceLineNo">3329</span>        if (rowLock == null) {<a name="line.3329"></a>
-<span class="sourceLineNo">3330</span>          // We failed to grab another lock<a name="line.3330"></a>
-<span class="sourceLineNo">3331</span>          if (isAtomic()) {<a name="line.3331"></a>
-<span class="sourceLineNo">3332</span>            region.storeHotnessProtector.finish(curFamilyCellMap);<a name="line.3332"></a>
-<span class="sourceLineNo">3333</span>            throw new IOException("Can't apply all operations atomically!");<a name="line.3333"></a>
-<span class="sourceLineNo">3334</span>          }<a name="line.3334"></a>
-<span class="sourceLineNo">3335</span>          break; // Stop acquiring more rows for this batch<a name="line.3335"></a>
-<span class="sourceLineNo">3336</span>        } else {<a name="line.3336"></a>
-<span class="sourceLineNo">3337</span>          if (rowLock != prevRowLock) {<a name="line.3337"></a>
-<span class="sourceLineNo">3338</span>            // It is a different row now, add this to the acquiredRowLocks and<a name="line.3338"></a>
-<span class="sourceLineNo">3339</span>            // set prevRowLock to the new returned rowLock<a name="line.3339"></a>
-<span class="sourceLineNo">3340</span>            acquiredRowLocks.add(rowLock);<a name="line.3340"></a>
-<span class="sourceLineNo">3341</span>            prevRowLock = rowLock;<a name="line.3341"></a>
-<span class="sourceLineNo">3342</span>          }<a name="line.3342"></a>
-<span class="sourceLineNo">3343</span>        }<a name="line.3343"></a>
-<span class="sourceLineNo">3344</span><a name="line.3344"></a>
-<span class="sourceLineNo">3345</span>        readyToWriteCount++;<a name="line.3345"></a>
-<span class="sourceLineNo">3346</span>      }<a name="line.3346"></a>
-<span class="sourceLineNo">3347</span>      return createMiniBatch(lastIndexExclusive, readyToWriteCount);<a name="line.3347"></a>
-<span class="sourceLineNo">3348</span>    }<a name="line.3348"></a>
-<span class="sourceLineNo">3349</span><a name="line.3349"></a>
-<span class="sourceLineNo">3350</span>    protected MiniBatchOperationInProgress&lt;Mutation&gt; createMiniBatch(final int lastIndexExclusive,<a name="line.3350"></a>
-<span class="sourceLineNo">3351</span>        final int readyToWriteCount) {<a name="line.3351"></a>
-<span class="sourceLineNo">3352</span>      return new MiniBatchOperationInProgress&lt;&gt;(getMutationsForCoprocs(), retCodeDetails,<a name="line.3352"></a>
-<span class="sourceLineNo">3353</span>          walEditsFromCoprocessors, nextIndexToProcess, lastIndexExclusive, readyToWriteCount);<a name="line.3353"></a>
-<span class="sourceLineNo">3354</span>    }<a name="line.3354"></a>
-<span class="sourceLineNo">3355</span><a name="line.3355"></a>
-<span class="sourceLineNo">3356</span>    /**<a name="line.3356"></a>
-<span class="sourceLineNo">3357</span>     * Builds separate WALEdit per nonce by applying input mutations. If WALEdits from CP are<a name="line.3357"></a>
-<span class="sourceLineNo">3358</span>     * present, they are merged to result WALEdit.<a name="line.3358"></a>
-<span class="sourceLineNo">3359</span>     */<a name="line.3359"></a>
-<span class="sourceLineNo">3360</span>    public List&lt;Pair&lt;NonceKey, WALEdit&gt;&gt; buildWALEdits(<a name="line.3360"></a>
-<span class="sourceLineNo">3361</span>        final MiniBatchOperationInProgress&lt;Mutation&gt; miniBatchOp) throws IOException {<a name="line.3361"></a>
-<span class="sourceLineNo">3362</span>      List&lt;Pair&lt;NonceKey, WALEdit&gt;&gt; walEdits = new ArrayList&lt;&gt;();<a name="line.3362"></a>
-<span class="sourceLineNo">3363</span><a name="line.3363"></a>
-<span class="sourceLineNo">3364</span>      visitBatchOperations(true, nextIndexToProcess + miniBatchOp.size(), new Visitor() {<a name="line.3364"></a>
-<span class="sourceLineNo">3365</span>        private Pair&lt;NonceKey, WALEdit&gt; curWALEditForNonce;<a name="line.3365"></a>
-<span class="sourceLineNo">3366</span><a name="line.3366"></a>
-<span class="sourceLineNo">3367</span>        @Override<a name="line.3367"></a>
-<span class="sourceLineNo">3368</span>        public boolean visit(int index) throws IOException {<a name="line.3368"></a>
-<span class="sourceLineNo">3369</span>          Mutation m = getMutation(index);<a name="line.3369"></a>
-<span class="sourceLineNo">3370</span>          // we use durability of the original mutation for the mutation passed by CP.<a name="line.3370"></a>
-<span class="sourceLineNo">3371</span>          if (region.getEffectiveDurability(m.getDurability()) == Durability.SKIP_WAL) {<a name="line.3371"></a>
-<span class="sourceLineNo">3372</span>            region.recordMutationWithoutWal(m.getFamilyCellMap());<a name="line.3372"></a>
-<span class="sourceLineNo">3373</span>            return true;<a name="line.3373"></a>
-<span class="sourceLineNo">3374</span>          }<a name="line.3374"></a>
-<span class="sourceLineNo">3375</span><a name="line.3375"></a>
-<span class="sourceLineNo">3376</span>          // the batch may contain multiple nonce keys (replay case). If so, write WALEdit for each.<a name="line.3376"></a>
-<span class="sourceLineNo">3377</span>          // Given how nonce keys are originally written, these should be contiguous.<a name="line.3377"></a>
-<span class="sourceLineNo">3378</span>          // They don't have to be, it will still work, just write more WALEdits than needed.<a name="line.3378"></a>
-<span class="sourceLineNo">3379</span>          long nonceGroup = getNonceGroup(index);<a name="line.3379"></a>
-<span class="sourceLineNo">3380</span>          long nonce = getNonce(index);<a name="line.3380"></a>
-<span class="sourceLineNo">3381</span>          if (curWALEditForNonce == null ||<a name="line.3381"></a>
-<span class="sourceLineNo">3382</span>              curWALEditForNonce.getFirst().getNonceGroup() != nonceGroup ||<a name="line.3382"></a>
-<span class="sourceLineNo">3383</span>              curWALEditForNonce.getFirst().getNonce() != nonce) {<a name="line.3383"></a>
-<span class="sourceLineNo">3384</span>            curWALEditForNonce = new Pair&lt;&gt;(new NonceKey(nonceGroup, nonce),<a name="line.3384"></a>
-<span class="sourceLineNo">3385</span>                new WALEdit(miniBatchOp.getCellCount(), isInReplay()));<a name="line.3385"></a>
-<span class="sourceLineNo">3386</span>            walEdits.add(curWALEditForNonce);<a name="line.3386"></a>
-<span class="sourceLineNo">3387</span>          }<a name="line.3387"></a>
-<span class="sourceLineNo">3388</span>          WALEdit walEdit = curWALEditForNonce.getSecond();<a name="line.3388"></a>
-<span class="sourceLineNo">3389</span><a name="line.3389"></a>
-<span class="sourceLineNo">3390</span>          // Add WAL edits from CPs.<a name="line.3390"></a>
-<span class="sourceLineNo">3391</span>          WALEdit fromCP = walEditsFromCoprocessors[index];<a name="line.3391"></a>
-<span class="sourceLineNo">3392</span>          if (fromCP != null) {<a name="line.3392"></a>
-<span class="sourceLineNo">3393</span>            for (Cell cell : fromCP.getCells()) {<a name="line.3393"></a>
-<span class="sourceLineNo">3394</span>              walEdit.add(cell);<a name="line.3394"></a>
-<span class="sourceLineNo">3395</span>            }<a name="line.3395"></a>
-<span class="sourceLineNo">3396</span>          }<a name="line.3396"></a>
-<span class="sourceLineNo">3397</span>          walEdit.add(familyCellMaps[index]);<a name="line.3397"></a>
-<span class="sourceLineNo">3398</span><a name="line.3398"></a>
-<span class="sourceLineNo">3399</span>          return true;<a name="line.3399"></a>
-<span class="sourceLineNo">3400</span>        }<a name="line.3400"></a>
-<span class="sourceLineNo">3401</span>      });<a name="line.3401"></a>
-<span class="sourceLineNo">3402</span>      return walEdits;<a name="line.3402"></a>
-<span class="sourceLineNo">3403</span>    }<a name="line.3403"></a>
-<span class="sourceLineNo">3404</span><a name="line.3404"></a>
-<span class="sourceLineNo">3405</span>    /**<a name="line.3405"></a>
-<span class="sourceLineNo">3406</span>     * This method completes mini-batch operations by calling postBatchMutate() CP hook (if<a name="line.3406"></a>
-<span class="sourceLineNo">3407</span>     * required) and completing mvcc.<a name="line.3407"></a>
-<span class="sourceLineNo">3408</span>     */<a name="line.3408"></a>
-<span class="sourceLineNo">3409</span>    public void completeMiniBatchOperations(<a name="line.3409"></a>
-<span class="sourceLineNo">3410</span>        final MiniBatchOperationInProgress&lt;Mutation&gt; miniBatchOp, final WriteEntry writeEntry)<a name="line.3410"></a>
-<span class="sourceLineNo">3411</span>        throws IOException {<a name="line.3411"></a>
-<span class="sourceLineNo">3412</span>      if (writeEntry != null) {<a name="line.3412"></a>
-<span class="sourceLineNo">3413</span>        region.mvcc.completeAndWait(writeEntry);<a name="line.3413"></a>
-<span class="sourceLineNo">3414</span>      }<a name="line.3414"></a>
-<span class="sourceLineNo">3415</span>    }<a name="line.3415"></a>
-<span class="sourceLineNo">3416</span><a name="line.3416"></a>
-<span class="sourceLineNo">3417</span>    public void doPostOpCleanupForMiniBatch(<a name="line.3417"></a>
-<span class="sourceLineNo">3418</span>        final MiniBatchOperationInProgress&lt;Mutation&gt; miniBatchOp, final WALEdit walEdit,<a name="line.3418"></a>
-<span class="sourceLineNo">3419</span>        boolean success) throws IOException {<a name="line.3419"></a>
-<span class="sourceLineNo">3420</span>      doFinishHotnessProtector(miniBatchOp);<a name="line.3420"></a>
-<span class="sourceLineNo">3421</span>    }<a name="line.3421"></a>
-<span class="sourceLineNo">3422</span><a name="line.3422"></a>
-<span class="sourceLineNo">3423</span>    private void doFinishHotnessProtector(<a name="line.3423"></a>
-<span class="sourceLineNo">3424</span>        final MiniBatchOperationInProgress&lt;Mutation&gt; miniBatchOp) {<a name="line.3424"></a>
-<span class="sourceLineNo">3425</span>      // check and return if the protector is not enabled<a name="line.3425"></a>
-<span class="sourceLineNo">3426</span>      if (!region.storeHotnessProtector.isEnable()) {<a name="line.3426"></a>
-<span class="sourceLineNo">3427</span>        return;<a name="line.3427"></a>
-<span class="sourceLineNo">3428</span>      }<a name="line.3428"></a>
-<span class="sourceLineNo">3429</span>      // miniBatchOp is null, if and only if lockRowsAndBuildMiniBatch throwing exception.<a name="line.3429"></a>
-<span class="sourceLineNo">3430</span>      // This case was handled.<a name="line.3430"></a>
-<span class="sourceLineNo">3431</span>      if (miniBatchOp == null) {<a name="line.3431"></a>
-<span class="sourceLineNo">3432</span>        return;<a name="line.3432"></a>
-<span class="sourceLineNo">3433</span>      }<a name="line.3433"></a>
-<span class="sourceLineNo">3434</span><a name="line.3434"></a>
-<span class="sourceLineNo">3435</span>      final int finalLastIndexExclusive = miniBatchOp.getLastIndexExclusive();<a name="line.3435"></a>
-<span class="sourceLineNo">3436</span><a name="line.3436"></a>
-<span class="sourceLineNo">3437</span>      for (int i = nextIndexToProcess; i &lt; finalLastIndexExclusive; i++) {<a name="line.3437"></a>
-<span class="sourceLineNo">3438</span>        switch (retCodeDetails[i].getOperationStatusCode()) {<a name="line.3438"></a>
-<span class="sourceLineNo">3439</span>          case SUCCESS:<a name="line.3439"></a>
-<span class="sourceLineNo">3440</span>          case FAILURE:<a name="line.3440"></a>
-<span class="sourceLineNo">3441</span>            region.storeHotnessProtector.finish(getMutation(i).getFamilyCellMap());<a name="line.3441"></a>
-<span class="sourceLineNo">3442</span>            break;<a name="line.3442"></a>
-<span class="sourceLineNo">3443</span>          default:<a name="line.3443"></a>
-<span class="sourceLineNo">3444</span>            // do nothing<a name="line.3444"></a>
-<span class="sourceLineNo">3445</span>            // We won't start the protector for NOT_RUN/BAD_FAMILY/SANITY_CHECK_FAILURE and the<a name="line.3445"></a>
-<span class="sourceLineNo">3446</span>            // STORE_TOO_BUSY case is handled in StoreHotnessProtector#start<a name="line.3446"></a>
-<span class="sourceLineNo">3447</span>            break;<a name="line.3447"></a>
-<span class="sourceLineNo">3448</span>        }<a name="line.3448"></a>
-<span class="sourceLineNo">3449</span>      }<a name="line.3449"></a>
-<span class="sourceLineNo">3450</span>    }<a name="line.3450"></a>
-<span class="sourceLineNo">3451</span><a name="line.3451"></a>
-<span class="sourceLineNo">3452</span>    /**<a name="line.3452"></a>
-<span class="sourceLineNo">3453</span>     * Atomically apply the given map of family-&gt;edits to the memstore.<a name="line.3453"></a>
-<span class="sourceLineNo">3454</span>     * This handles the consistency control on its own, but the caller<a name="line.3454"></a>
-<span class="sourceLineNo">3455</span>     * should already have locked updatesLock.readLock(). This also does<a name="line.3455"></a>
-<span class="sourceLineNo">3456</span>     * &lt;b&gt;not&lt;/b&gt; check the families for validity.<a name="line.3456"></a>
-<span class="sourceLineNo">3457</span>     *<a name="line.3457"></a>
-<span class="sourceLineNo">3458</span>     * @param familyMap Map of Cells by family<a name="line.3458"></a>
-<span class="sourceLineNo">3459</span>     */<a name="line.3459"></a>
-<span class="sourceLineNo">3460</span>    protected void applyFamilyMapToMemStore(Map&lt;byte[], List&lt;Cell&gt;&gt; familyMap,<a name="line.3460"></a>
-<span class="sourceLineNo">3461</span>        MemStoreSizing memstoreAccounting) throws IOException {<a name="line.3461"></a>
-<span class="sourceLineNo">3462</span>      for (Map.Entry&lt;byte[], List&lt;Cell&gt;&gt; e : familyMap.entrySet()) {<a name="line.3462"></a>
-<span class="sourceLineNo">3463</span>        byte[] family = e.getKey();<a name="line.3463"></a>
-<span class="sourceLineNo">3464</span>        List&lt;Cell&gt; cells = e.getValue();<a name="line.3464"></a>
-<span class="sourceLineNo">3465</span>        assert cells instanceof RandomAccess;<a name="line.3465"></a>
-<span class="sourceLineNo">3466</span>        region.applyToMemStore(region.getStore(family), cells, false, memstoreAccounting);<a name="line.3466"></a>
-<span class="sourceLineNo">3467</span>      }<a name="line.3467"></a>
-<span class="sourceLineNo">3468</span>    }<a name="line.3468"></a>
-<span class="sourceLineNo">3469</span>  }<a name="line.3469"></a>
-<span class="sourceLineNo">3470</span><a name="line.3470"></a>
+<span class="sourceLineNo">2826</span>      rsServices.getMetrics().updateFlush(getTableDescriptor().getTableName().getNameAsString(),<a name="line.2826"></a>
+<span class="sourceLineNo">2827</span>          time - startTime,<a name="line.2827"></a>
+<span class="sourceLineNo">2828</span>          mss.getDataSize(), flushedOutputFileSize);<a name="line.2828"></a>
+<span class="sourceLineNo">2829</span>    }<a name="line.2829"></a>
+<span class="sourceLineNo">2830</span><a name="line.2830"></a>
+<span class="sourceLineNo">2831</span>    return new FlushResultImpl(compactionRequested ?<a name="line.2831"></a>
+<span class="sourceLineNo">2832</span>        FlushResult.Result.FLUSHED_COMPACTION_NEEDED :<a name="line.2832"></a>
+<span class="sourceLineNo">2833</span>          FlushResult.Result.FLUSHED_NO_COMPACTION_NEEDED, flushOpSeqId);<a name="line.2833"></a>
+<span class="sourceLineNo">2834</span>  }<a name="line.2834"></a>
+<span class="sourceLineNo">2835</span><a name="line.2835"></a>
+<span class="sourceLineNo">2836</span>  /**<a name="line.2836"></a>
+<span class="sourceLineNo">2837</span>   * Method to safely get the next sequence number.<a name="line.2837"></a>
+<span class="sourceLineNo">2838</span>   * @return Next sequence number unassociated with any actual edit.<a name="line.2838"></a>
+<span class="sourceLineNo">2839</span>   * @throws IOException<a name="line.2839"></a>
+<span class="sourceLineNo">2840</span>   */<a name="line.2840"></a>
+<span class="sourceLineNo">2841</span>  @VisibleForTesting<a name="line.2841"></a>
+<span class="sourceLineNo">2842</span>  protected long getNextSequenceId(final WAL wal) throws IOException {<a name="line.2842"></a>
+<span class="sourceLineNo">2843</span>    WriteEntry we = mvcc.begin();<a name="line.2843"></a>
+<span class="sourceLineNo">2844</span>    mvcc.completeAndWait(we);<a name="line.2844"></a>
+<span class="sourceLineNo">2845</span>    return we.getWriteNumber();<a name="line.2845"></a>
+<span class="sourceLineNo">2846</span>  }<a name="line.2846"></a>
+<span class="sourceLineNo">2847</span><a name="line.2847"></a>
+<span class="sourceLineNo">2848</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.2848"></a>
+<span class="sourceLineNo">2849</span>  // get() methods for client use.<a name="line.2849"></a>
+<span class="sourceLineNo">2850</span>  //////////////////////////////////////////////////////////////////////////////<a name="line.2850"></a>
+<span class="sourceLineNo">2851</span><a name="line.2851"></a>
+<span class="sourceLineNo">2852</span>  @Override<a name="line.2852"></a>
+<span class="sourceLineNo">2853</span>  public RegionScannerImpl getScanner(Scan scan) throws IOException {<a name="line.2853"></a>
+<span class="sourceLineNo">2854</span>   return getScanner(scan, null);<a name="line.2854"></a>
+<span class="sourceLineNo">2855</span>  }<a name="line.2855"></a>
+<span class="sourceLineNo">2856</span><a name="line.2856"></a>
+<span class="sourceLineNo">2857</span>  @Override<a name="line.2857"></a>
+<span class="sourceLineNo">2858</span>  public RegionScannerImpl getScanner(Scan scan, List&lt;KeyValueScanner&gt; additionalScanners)<a name="line.2858"></a>
+<span class="sourceLineNo">2859</span>      throws IOException {<a name="line.2859"></a>
+<span class="sourceLineNo">2860</span>    return getScanner(scan, additionalScanners, HConstants.NO_NONCE, HConstants.NO_NONCE);<a name="line.2860"></a>
+<span class="sourceLineNo">2861</span>  }<a name="line.2861"></a>
+<span class="sourceLineNo">2862</span><a name="line.2862"></a>
+<span class="sourceLineNo">2863</span>  private RegionScannerImpl getScanner(Scan scan, List&lt;KeyValueScanner&gt; additionalScanners,<a name="line.2863"></a>
+<span class="sourceLineNo">2864</span>      long nonceGroup, long nonce) throws IOException {<a name="line.2864"></a>
+<span class="sourceLineNo">2865</span>    startRegionOperation(Operation.SCAN);<a name="line.2865"></a>
+<span class="sourceLineNo">2866</span>    try {<a name="line.2866"></a>
+<span class="sourceLineNo">2867</span>      // Verify families are all valid<a name="line.2867"></a>
+<span class="sourceLineNo">2868</span>      if (!scan.hasFamilies()) {<a name="line.2868"></a>
+<span class="sourceLineNo">2869</span>        // Adding all families to scanner<a name="line.2869"></a>
+<span class="sourceLineNo">2870</span>        for (byte[] family : this.htableDescriptor.getColumnFamilyNames()) {<a name="line.2870"></a>
+<span class="sourceLineNo">2871</span>          scan.addFamily(family);<a name="line.2871"></a>
+<span class="sourceLineNo">2872</span>        }<a name="line.2872"></a>
+<span class="sourceLineNo">2873</span>      } else {<a name="line.2873"></a>
+<span class="sourceLineNo">2874</span>        for (byte[] family : scan.getFamilyMap().keySet()) {<a name="line.2874"></a>
+<span class="sourceLineNo">2875</span>          checkFamily(family);<a name="line.2875"></a>
+<span class="sourceLineNo">2876</span>        }<a name="line.2876"></a>
+<span class="sourceLineNo">2877</span>      }<a name="line.2877"></a>
+<span class="sourceLineNo">2878</span>      return instantiateRegionScanner(scan, additionalScanners, nonceGroup, nonce);<a name="line.2878"></a>
+<span class="sourceLineNo">2879</span>    } finally {<a name="line.2879"></a>
+<span class="sourceLineNo">2880</span>      closeRegionOperation(Operation.SCAN);<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>  protected RegionScanner instantiateRegionScanner(Scan scan,<a name="line.2884"></a>
+<span class="sourceLineNo">2885</span>      List&lt;KeyValueScanner&gt; additionalScanners) throws IOException {<a name="line.2885"></a>
+<span class="sourceLineNo">2886</span>    return instantiateRegionScanner(scan, additionalScanners, HConstants.NO_NONCE,<a name="line.2886"></a>
+<span class="sourceLineNo">2887</span>      HConstants.NO_NONCE);<a name="line.2887"></a>
+<span class="sourceLineNo">2888</span>  }<a name="line.2888"></a>
+<span class="sourceLineNo">2889</span><a name="line.2889"></a>
+<span class="sourceLineNo">2890</span>  protected RegionScannerImpl instantiateRegionScanner(Scan scan,<a name="line.2890"></a>
+<span class="sourceLineNo">2891</span>      List&lt;KeyValueScanner&gt; additionalScanners, long nonceGroup, long nonce) throws IOException {<a name="line.2891"></a>
+<span class="sourceLineNo">2892</span>    if (scan.isReversed()) {<a name="line.2892"></a>
+<span class="sourceLineNo">2893</span>      if (scan.getFilter() != null) {<a name="line.2893"></a>
+<span class="sourceLineNo">2894</span>        scan.getFilter().setReversed(true);<a name="line.2894"></a>
+<span class="sourceLineNo">2895</span>      }<a name="line.2895"></a>
+<span class="sourceLineNo">2896</span>      return new ReversedRegionScannerImpl(scan, additionalScanners, this);<a name="line.2896"></a>
+<span class="sourceLineNo">2897</span>    }<a name="line.2897"></a>
+<span class="sourceLineNo">2898</span>    return new RegionScannerImpl(scan, additionalScanners, this, nonceGroup, nonce);<a name="line.2898"></a>
+<span class="sourceLineNo">2899</span>  }<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>   * Prepare a delete for a row mutation processor<a name="line.2902"></a>
+<span class="sourceLineNo">2903</span>   * @param delete The passed delete is modified by this method. WARNING!<a name="line.2903"></a>
+<span class="sourceLineNo">2904</span>   * @throws IOException<a name="line.2904"></a>
+<span class="sourceLineNo">2905</span>   */<a name="line.2905"></a>
+<span class="sourceLineNo">2906</span>  public void prepareDelete(Delete delete) throws IOException {<a name="line.2906"></a>
+<span class="sourceLineNo">2907</span>    // Check to see if this is a deleteRow insert<a name="line.2907"></a>
+<span class="sourceLineNo">2908</span>    if(delete.getFamilyCellMap().isEmpty()){<a name="line.2908"></a>
+<span class="sourceLineNo">2909</span>      for(byte [] family : this.htableDescriptor.getColumnFamilyNames()){<a name="line.2909"></a>
+<span class="sourceLineNo">2910</span>        // Don't eat the timestamp<a name="line.2910"></a>
+<span class="sourceLineNo">2911</span>        delete.addFamily(family, delete.getTimestamp());<a name="line.2911"></a>
+<span class="sourceLineNo">2912</span>      }<a name="line.2912"></a>
+<span class="sourceLineNo">2913</span>    } else {<a name="line.2913"></a>
+<span class="sourceLineNo">2914</span>      for(byte [] family : delete.getFamilyCellMap().keySet()) {<a name="line.2914"></a>
+<span class="sourceLineNo">2915</span>        if(family == null) {<a name="line.2915"></a>
+<span class="sourceLineNo">2916</span>          throw new NoSuchColumnFamilyException("Empty family is invalid");<a name="line.2916"></a>
+<span class="sourceLineNo">2917</span>        }<a name="line.2917"></a>
+<span class="sourceLineNo">2918</span>        checkFamily(family);<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>  }<a name="line.2921"></a>
+<span class="sourceLineNo">2922</span><a name="line.2922"></a>
+<span class="sourceLineNo">2923</span>  @Override<a name="line.2923"></a>
+<span class="sourceLineNo">2924</span>  public void delete(Delete delete) throws IOException {<a name="line.2924"></a>
+<span class="sourceLineNo">2925</span>    checkReadOnly();<a name="line.2925"></a>
+<span class="sourceLineNo">2926</span>    checkResources();<a name="line.2926"></a>
+<span class="sourceLineNo">2927</span>    startRegionOperation(Operation.DELETE);<a name="line.2927"></a>
+<span class="sourceLineNo">2928</span>    try {<a name="line.2928"></a>
+<span class="sourceLineNo">2929</span>      // All edits for the given row (across all column families) must happen atomically.<a name="line.2929"></a>
+<span class="sourceLineNo">2930</span>      doBatchMutate(delete);<a name="line.2930"></a>
+<span class="sourceLineNo">2931</span>    } finally {<a name="line.2931"></a>
+<span class="sourceLineNo">2932</span>      closeRegionOperation(Operation.DELETE);<a name="line.2932"></a>
+<span class="sourceLineNo">2933</span>    }<a name="line.2933"></a>
+<span class="sourceLineNo">2934</span>  }<a name="line.2934"></a>
+<span class="sourceLineNo">2935</span><a name="line.2935"></a>
+<span class="sourceLineNo">2936</span>  /**<a name="line.2936"></a>
+<span class="sourceLineNo">2937</span>   * Row needed by below method.<a name="line.2937"></a>
+<span class="sourceLineNo">2938</span>   */<a name="line.2938"></a>
+<span class="sourceLineNo">2939</span>  private static final byte [] FOR_UNIT_TESTS_ONLY = Bytes.toBytes("ForUnitTestsOnly");<a name="line.2939"></a>
+<span class="sourceLineNo">2940</span><a name="line.2940"></a>
+<span class="sourceLineNo">2941</span>  /**<a name="line.2941"></a>
+<span class="sourceLineNo">2942</span>   * This is used only by unit tests. Not required to be a public API.<a name="line.2942"></a>
+<span class="sourceLineNo">2943</span>   * @param familyMap map of family to edits for the given family.<a name="line.2943"></a>
+<span class="sourceLineNo">2944</span>   * @throws IOException<a name="line.2944"></a>
+<span class="sourceLineNo">2945</span>   */<a name="line.2945"></a>
+<span class="sourceLineNo">2946</span>  void delete(NavigableMap&lt;byte[], List&lt;Cell&gt;&gt; familyMap,<a name="line.2946"></a>
+<span class="sourceLineNo">2947</span>      Durability durability) throws IOException {<a name="line.2947"></a>
+<span class="sourceLineNo">2948</span>    Delete delete = new Delete(FOR_UNIT_TESTS_ONLY);<a name="line.2948"></a>
+<span class="sourceLineNo">2949</span>    delete.setFamilyCellMap(familyMap);<a name="line.2949"></a>
+<span class="sourceLineNo">2950</span>    delete.setDurability(durability);<a name="line.2950"></a>
+<span class="sourceLineNo">2951</span>    doBatchMutate(delete);<a name="line.2951"></a>
+<span class="sourceLineNo">2952</span>  }<a name="line.2952"></a>
+<span class="sourceLineNo">2953</span><a name="line.2953"></a>
+<span class="sourceLineNo">2954</span>  /**<a name="line.2954"></a>
+<span class="sourceLineNo">2955</span>   * Set up correct timestamps in the KVs in Delete object.<a name="line.2955"></a>
+<span class="sourceLineNo">2956</span>   * &lt;p&gt;Caller should have the row and region locks.<a name="line.2956"></a>
+<span class="sourceLineNo">2957</span>   * @param mutation<a name="line.2957"></a>
+<span class="sourceLineNo">2958</span>   * @param familyMap<a name="line.2958"></a>
+<span class="sourceLineNo">2959</span>   * @param byteNow<a name="line.2959"></a>
+<span class="sourceLineNo">2960</span>   * @throws IOException<a name="line.2960"></a>
+<span class="sourceLineNo">2961</span>   */<a name="line.2961"></a>
+<span class="sourceLineNo">2962</span>  public void prepareDeleteTimestamps(Mutation mutation, Map&lt;byte[], List&lt;Cell&gt;&gt; familyMap,<a name="line.2962"></a>
+<span class="sourceLineNo">2963</span>      byte[] byteNow) throws IOException {<a name="line.2963"></a>
+<span class="sourceLineNo">2964</span>    for (Map.Entry&lt;byte[], List&lt;Cell&gt;&gt; e : familyMap.entrySet()) {<a name="line.2964"></a>
+<span class="sourceLineNo">2965</span><a name="line.2965"></a>
+<span class="sourceLineNo">2966</span>      byte[] family = e.getKey();<a name="line.2966"></a>
+<span class="sourceLineNo">2967</span>      List&lt;Cell&gt; cells = e.getValue();<a name="line.2967"></a>
+<span class="sourceLineNo">2968</span>      assert cells instanceof RandomAccess;<a name="line.2968"></a>
+<span class="sourceLineNo">2969</span><a name="line.2969"></a>
+<span class="sourceLineNo">2970</span>      Map&lt;byte[], Integer&gt; kvCount = new TreeMap&lt;&gt;(Bytes.BYTES_COMPARATOR);<a name="line.2970"></a>
+<span class="sourceLineNo">2971</span>      int listSize = cells.size();<a name="line.2971"></a>
+<span class="sourceLineNo">2972</span>      for (int i=0; i &lt; listSize; i++) {<a name="line.2972"></a>
+<span class="sourceLineNo">2973</span>        Cell cell = cells.get(i);<a name="line.2973"></a>
+<span class="sourceLineNo">2974</span>        //  Check if time is LATEST, change to time of most recent addition if so<a name="line.2974"></a>
+<span class="sourceLineNo">2975</span>        //  This is expensive.<a name="line.2975"></a>
+<span class="sourceLineNo">2976</span>        if (cell.getTimestamp() == HConstants.LATEST_TIMESTAMP<a name="line.2976"></a>
+<span class="sourceLineNo">2977</span>            &amp;&amp; PrivateCellUtil.isDeleteType(cell)) {<a name="line.2977"></a>
+<span class="sourceLineNo">2978</span>          byte[] qual = CellUtil.cloneQualifier(cell);<a name="line.2978"></a>
+<span class="sourceLineNo">2979</span><a name="line.2979"></a>
+<span class="sourceLineNo">2980</span>          Integer count = kvCount.get(qual);<a name="line.2980"></a>
+<span class="sourceLineNo">2981</span>          if (count == null) {<a name="line.2981"></a>
+<span class="sourceLineNo">2982</span>            kvCount.put(qual, 1);<a name="line.2982"></a>
+<span class="sourceLineNo">2983</span>          } else {<a name="line.2983"></a>
+<span class="sourceLineNo">2984</span>            kvCount.put(qual, count + 1);<a name="line.2984"></a>
+<span class="sourceLineNo">2985</span>          }<a name="line.2985"></a>
+<span class="sourceLineNo">2986</span>          count = kvCount.get(qual);<a name="line.2986"></a>
+<span class="sourceLineNo">2987</span><a name="line.2987"></a>
+<span class="sourceLineNo">2988</span>          Get get = new Get(CellUtil.cloneRow(cell));<a name="line.2988"></a>
+<span class="sourceLineNo">2989</span>          get.setMaxVersions(count);<a name="line.2989"></a>
+<span class="sourceLineNo">2990</span>          get.addColumn(family, qual);<a name="line.2990"></a>
+<span class="sourceLineNo">2991</span>          if (coprocessorHost != null) {<a name="line.2991"></a>
+<span class="sourceLineNo">2992</span>            if (!coprocessorHost.prePrepareTimeStampForDeleteVersion(mutation, cell,<a name="line.2992"></a>
+<span class="sourceLineNo">2993</span>                byteNow, get)) {<a name="line.2993"></a>
+<span class="sourceLineNo">2994</span>              updateDeleteLatestVersionTimestamp(cell, get, count, byteNow);<a name="line.2994"></a>
+<span class="sourceLineNo">2995</span>            }<a name="line.2995"></a>
+<span class="sourceLineNo">2996</span>          } else {<a name="line.2996"></a>
+<span class="sourceLineNo">2997</span>            updateDeleteLatestVersionTimestamp(cell, get, count, byteNow);<a name="line.2997"></a>
+<span class="sourceLineNo">2998</span>          }<a name="line.2998"></a>
+<span class="sourceLineNo">2999</span>        } else {<a name="line.2999"></a>
+<span class="sourceLineNo">3000</span>          PrivateCellUtil.updateLatestStamp(cell, byteNow);<a name="line.3000"></a>
+<span class="sourceLineNo">3001</span>        }<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>  }<a name="line.3004"></a>
+<span class="sourceLineNo">3005</span><a name="line.3005"></a>
+<span class="sourceLineNo">3006</span>  void updateDeleteLatestVersionTimestamp(Cell cell, Get get, int count, byte[] byteNow)<a name="line.3006"></a>
+<span class="sourceLineNo">3007</span>      throws IOException {<a name="line.3007"></a>
+<span class="sourceLineNo">3008</span>    List&lt;Cell&gt; result = get(get, false);<a name="line.3008"></a>
+<span class="sourceLineNo">3009</span><a name="line.3009"></a>
+<span class="sourceLineNo">3010</span>    if (result.size() &lt; count) {<a name="line.3010"></a>
+<span class="sourceLineNo">3011</span>      // Nothing to delete<a name="line.3011"></a>
+<span class="sourceLineNo">3012</span>      PrivateCellUtil.updateLatestStamp(cell, byteNow);<a name="line.3012"></a>
+<span class="sourceLineNo">3013</span>      return;<a name="line.3013"></a>
+<span class="sourceLineNo">3014</span>    }<a name="line.3014"></a>
+<span class="sourceLineNo">3015</span>    if (result.size() &gt; count) {<a name="line.3015"></a>
+<span class="sourceLineNo">3016</span>      throw new RuntimeException("Unexpected size: " + result.size());<a name="line.3016"></a>
+<span class="sourceLineNo">3017</span>    }<a name="line.3017"></a>
+<span class="sourceLineNo">3018</span>    Cell getCell = result.get(count - 1);<a name="line.3018"></a>
+<span class="sourceLineNo">3019</span>    PrivateCellUtil.setTimestamp(cell, getCell.getTimestamp());<a name="line.3019"></a>
+<span class="sourceLineNo">3020</span>  }<a name="line.3020"></a>
+<span class="sourceLineNo">3021</span><a name="line.3021"></a>
+<span class="sourceLineNo">3022</span>  @Override<a name="line.3022"></a>
+<span class="sourceLineNo">3023</span>  public void put(Put put) throws IOException {<a name="line.3023"></a>
+<span class="sourceLineNo">3024</span>    checkReadOnly();<a name="line.3024"></a>
+<span class="sourceLineNo">3025</span><a name="line.3025"></a>
+<span class="sourceLineNo">3026</span>    // Do a rough check that we have resources to accept a write.  The check is<a name="line.3026"></a>
+<span class="sourceLineNo">3027</span>    // 'rough' in that between the resource check and the call to obtain a<a name="line.3027"></a>
+<span class="sourceLineNo">3028</span>    // read lock, resources may run out.  For now, the thought is that this<a name="line.3028"></a>
+<span class="sourceLineNo">3029</span>    // will be extremely rare; we'll deal with it when it happens.<a name="line.3029"></a>
+<span class="sourceLineNo">3030</span>    checkResources();<a name="line.3030"></a>
+<span class="sourceLineNo">3031</span>    startRegionOperation(Operation.PUT);<a name="line.3031"></a>
+<span class="sourceLineNo">3032</span>    try {<a name="line.3032"></a>
+<span class="sourceLineNo">3033</span>      // All edits for the given row (across all column families) must happen atomically.<a name="line.3033"></a>
+<span class="sourceLineNo">3034</span>      doBatchMutate(put);<a name="line.3034"></a>
+<span class="sourceLineNo">3035</span>    } finally {<a name="line.3035"></a>
+<span class="sourceLineNo">3036</span>      closeRegionOperation(Operation.PUT);<a name="line.3036"></a>
+<span class="sourceLineNo">3037</span>    }<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>  /**<a name="line.3040"></a>
+<span class="sourceLineNo">3041</span>   * Class that tracks the progress of a batch operations, accumulating status codes and tracking<a name="line.3041"></a>
+<span class="sourceLineNo">3042</span>   * the index at which processing is proceeding. These batch operations may get split into<a name="line.3042"></a>
+<span class="sourceLineNo">3043</span>   * mini-batches for processing.<a name="line.3043"></a>
+<span class="sourceLineNo">3044</span>   */<a name="line.3044"></a>
+<span class="sourceLineNo">3045</span>  private abstract static class BatchOperation&lt;T&gt; {<a name="line.3045"></a>
+<span class="sourceLineNo">3046</span>    protected final T[] operations;<a name="line.3046"></a>
+<span class="sourceLineNo">3047</span>    protected final OperationStatus[] retCodeDetails;<a name="line.3047"></a>
+<span class="sourceLineNo">3048</span>    protected final WALEdit[] walEditsFromCoprocessors;<a name="line.3048"></a>
+<span class="sourceLineNo">3049</span>    // reference family cell maps directly so coprocessors can mutate them if desired<a name="line.3049"></a>
+<span class="sourceLineNo">3050</span>    protected final Map&lt;byte[], List&lt;Cell&gt;&gt;[] familyCellMaps;<a name="line.3050"></a>
+<span class="sourceLineNo">3051</span><a name="line.3051"></a>
+<span class="sourceLineNo">3052</span>    protected final HRegion region;<a name="line.3052"></a>
+<span class="sourceLineNo">3053</span>    protected int nextIndexToProcess = 0;<a name="line.3053"></a>
+<span class="sourceLineNo">3054</span>    protected final ObservedExceptionsInBatch observedExceptions;<a name="line.3054"></a>
+<span class="sourceLineNo">3055</span

<TRUNCATED>

Mime
View raw message