View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.regionserver;
19  
20  import java.io.IOException;
21  import java.util.Collection;
22  import java.util.List;
23  import java.util.Map;
24  
25  import org.apache.hadoop.hbase.Cell;
26  import org.apache.hadoop.hbase.HBaseInterfaceAudience;
27  import org.apache.hadoop.hbase.HDFSBlocksDistribution;
28  import org.apache.hadoop.hbase.HRegionInfo;
29  import org.apache.hadoop.hbase.HTableDescriptor;
30  import org.apache.hadoop.hbase.classification.InterfaceAudience;
31  import org.apache.hadoop.hbase.classification.InterfaceStability;
32  import org.apache.hadoop.hbase.client.Append;
33  import org.apache.hadoop.hbase.client.Delete;
34  import org.apache.hadoop.hbase.client.Get;
35  import org.apache.hadoop.hbase.client.Increment;
36  import org.apache.hadoop.hbase.client.IsolationLevel;
37  import org.apache.hadoop.hbase.client.Mutation;
38  import org.apache.hadoop.hbase.client.Put;
39  import org.apache.hadoop.hbase.client.Result;
40  import org.apache.hadoop.hbase.client.RowMutations;
41  import org.apache.hadoop.hbase.client.Scan;
42  import org.apache.hadoop.hbase.conf.ConfigurationObserver;
43  import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException;
44  import org.apache.hadoop.hbase.filter.ByteArrayComparable;
45  import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
46  import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState;
47  import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceCall;
48  import org.apache.hadoop.hbase.util.Pair;
49  import org.apache.hadoop.hbase.wal.WALSplitter.MutationReplay;
50  
51  import com.google.common.annotations.VisibleForTesting;
52  import com.google.protobuf.Message;
53  import com.google.protobuf.RpcController;
54  import com.google.protobuf.Service;
55  
56  /**
57   * Regions store data for a certain region of a table.  It stores all columns
58   * for each row. A given table consists of one or more Regions.
59   *
60   * <p>An Region is defined by its table and its key extent.
61   *
62   * <p>Locking at the Region level serves only one purpose: preventing the
63   * region from being closed (and consequently split) while other operations
64   * are ongoing. Each row level operation obtains both a row lock and a region
65   * read lock for the duration of the operation. While a scanner is being
66   * constructed, getScanner holds a read lock. If the scanner is successfully
67   * constructed, it holds a read lock until it is closed. A close takes out a
68   * write lock and consequently will block for ongoing operations and will block
69   * new operations from starting while the close is in progress.
70   */
71  @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
72  @InterfaceStability.Evolving
73  public interface Region extends ConfigurationObserver {
74  
75    ///////////////////////////////////////////////////////////////////////////
76    // Region state
77  
78    /** @return region information for this region */
79    HRegionInfo getRegionInfo();
80  
81    /** @return table descriptor for this region */
82    HTableDescriptor getTableDesc();
83  
84    /** @return true if region is available (not closed and not closing) */
85    boolean isAvailable();
86  
87    /** @return true if region is closed */
88    boolean isClosed();
89  
90    /** @return True if closing process has started */
91    boolean isClosing();
92  
93    /** @return True if region is in recovering state */
94    boolean isRecovering();
95  
96    /** @return True if region is read only */
97    boolean isReadOnly();
98  
99    /**
100    * Return the list of Stores managed by this region
101    * <p>Use with caution.  Exposed for use of fixup utilities.
102    * @return a list of the Stores managed by this region
103    */
104   List<Store> getStores();
105 
106   /**
107    * Return the Store for the given family
108    * <p>Use with caution.  Exposed for use of fixup utilities.
109    * @return the Store for the given family
110    */
111   Store getStore(byte[] family);
112 
113   /** @return list of store file names for the given families */
114   List<String> getStoreFileList(byte [][] columns);
115 
116   /**
117    * Check the region's underlying store files, open the files that have not
118    * been opened yet, and remove the store file readers for store files no
119    * longer available.
120    * @throws IOException
121    */
122   boolean refreshStoreFiles() throws IOException;
123 
124   /** @return the latest sequence number that was read from storage when this region was opened */
125   long getOpenSeqNum();
126 
127   /** @return the max sequence id of flushed data on this region; no edit in memory will have
128    * a sequence id that is less that what is returned here.
129    */
130   long getMaxFlushedSeqId();
131 
132   /** @return the oldest flushed sequence id for the given family; can be beyond
133    * {@link #getMaxFlushedSeqId()} in case where we've flushed a subset of a regions column
134    * families
135    * @deprecated Since version 1.2.0. Exposes too much about our internals; shutting it down.
136    * Do not use.
137    */
138   @VisibleForTesting
139   @Deprecated
140   public long getOldestSeqIdOfStore(byte[] familyName);
141 
142   /**
143    * This can be used to determine the last time all files of this region were major compacted.
144    * @param majorCompactionOnly Only consider HFile that are the result of major compaction
145    * @return the timestamp of the oldest HFile for all stores of this region
146    */
147   long getOldestHfileTs(boolean majorCompactionOnly) throws IOException;
148 
149   /**
150    * @return map of column family names to max sequence id that was read from storage when this
151    * region was opened
152    */
153   public Map<byte[], Long> getMaxStoreSeqId();
154 
155   /** @return true if loading column families on demand by default */
156   boolean isLoadingCfsOnDemandDefault();
157 
158   /** @return readpoint considering given IsolationLevel */
159   long getReadpoint(IsolationLevel isolationLevel);
160 
161   /**
162    * @return The earliest time a store in the region was flushed. All
163    *         other stores in the region would have been flushed either at, or
164    *         after this time.
165    */
166   long getEarliestFlushTimeForAllStores();
167 
168   ///////////////////////////////////////////////////////////////////////////
169   // Metrics
170 
171   /** @return read requests count for this region */
172   long getReadRequestsCount();
173 
174   /**
175    * Update the read request count for this region
176    * @param i increment
177    */
178   void updateReadRequestsCount(long i);
179 
180   /** @return write request count for this region */
181   long getWriteRequestsCount();
182 
183   /**
184    * Update the write request count for this region
185    * @param i increment
186    */
187   void updateWriteRequestsCount(long i);
188 
189   /** @return memstore size for this region, in bytes */
190   long getMemstoreSize();
191 
192   /** @return the number of mutations processed bypassing the WAL */
193   long getNumMutationsWithoutWAL();
194 
195   /** @return the size of data processed bypassing the WAL, in bytes */
196   long getDataInMemoryWithoutWAL();
197 
198   /** @return the number of blocked requests */
199   long getBlockedRequestsCount();
200 
201   /** @return the number of checkAndMutate guards that passed */
202   long getCheckAndMutateChecksPassed();
203 
204   /** @return the number of failed checkAndMutate guards */
205   long getCheckAndMutateChecksFailed();
206 
207   /** @return the MetricsRegion for this region */
208   MetricsRegion getMetrics();
209 
210   /** @return the block distribution for all Stores managed by this region */
211   HDFSBlocksDistribution getHDFSBlocksDistribution();
212 
213   ///////////////////////////////////////////////////////////////////////////
214   // Locking
215 
216   // Region read locks
217 
218   /**
219    * Operation enum is used in {@link Region#startRegionOperation} to provide context for
220    * various checks before any region operation begins.
221    */
222   enum Operation {
223     ANY, GET, PUT, DELETE, SCAN, APPEND, INCREMENT, SPLIT_REGION, MERGE_REGION, BATCH_MUTATE,
224     REPLAY_BATCH_MUTATE, COMPACT_REGION, REPLAY_EVENT, SNAPSHOT
225   }
226 
227   /**
228    * This method needs to be called before any public call that reads or
229    * modifies data.
230    * Acquires a read lock and checks if the region is closing or closed.
231    * <p>{@link #closeRegionOperation} MUST then always be called after
232    * the operation has completed, whether it succeeded or failed.
233    * @throws IOException
234    */
235   void startRegionOperation() throws IOException;
236 
237   /**
238    * This method needs to be called before any public call that reads or
239    * modifies data.
240    * Acquires a read lock and checks if the region is closing or closed.
241    * <p>{@link #closeRegionOperation} MUST then always be called after
242    * the operation has completed, whether it succeeded or failed.
243    * @param op The operation is about to be taken on the region
244    * @throws IOException
245    */
246   void startRegionOperation(Operation op) throws IOException;
247 
248   /**
249    * Closes the region operation lock.
250    * @throws IOException
251    */
252   void closeRegionOperation() throws IOException;
253 
254   // Row write locks
255 
256   /**
257    * Row lock held by a given thread.
258    * One thread may acquire multiple locks on the same row simultaneously.
259    * The locks must be released by calling release() from the same thread.
260    */
261   public interface RowLock {
262     /**
263      * Release the given lock.  If there are no remaining locks held by the current thread
264      * then unlock the row and allow other threads to acquire the lock.
265      * @throws IllegalArgumentException if called by a different thread than the lock owning
266      *     thread
267      */
268     void release();
269   }
270 
271   /**
272    * Tries to acquire a lock on the given row.
273    * @param readlock if true, will block until the lock is available.
274    *        Otherwise, just tries to obtain the lock and returns
275    *        false if unavailable.
276    * @return the row lock if acquired,
277    *   null if waitForLock was false and the lock was not acquired
278    * @throws IOException if waitForLock was true and the lock could not be acquired after waiting
279    */
280   RowLock getRowLock(byte[] row, boolean readlock) throws IOException;
281 
282   /**
283    * If the given list of row locks is not null, releases all locks.
284    */
285   void releaseRowLocks(List<RowLock> rowLocks);
286 
287   ///////////////////////////////////////////////////////////////////////////
288   // Region operations
289 
290   /**
291    * Perform one or more append operations on a row.
292    * @param append
293    * @param nonceGroup
294    * @param nonce
295    * @return result of the operation
296    * @throws IOException
297    */
298   Result append(Append append, long nonceGroup, long nonce) throws IOException;
299 
300   /**
301    * Perform a batch of mutations.
302    * <p>
303    * Note this supports only Put and Delete mutations and will ignore other types passed.
304    * @param mutations the list of mutations
305    * @param nonceGroup
306    * @param nonce
307    * @return an array of OperationStatus which internally contains the
308    *         OperationStatusCode and the exceptionMessage if any.
309    * @throws IOException
310    */
311   OperationStatus[] batchMutate(Mutation[] mutations, long nonceGroup, long nonce)
312       throws IOException;
313 
314   /**
315    * Replay a batch of mutations.
316    * @param mutations mutations to replay.
317    * @param replaySeqId
318    * @return an array of OperationStatus which internally contains the
319    *         OperationStatusCode and the exceptionMessage if any.
320    * @throws IOException
321    */
322    OperationStatus[] batchReplay(MutationReplay[] mutations, long replaySeqId) throws IOException;
323 
324   /**
325    * Atomically checks if a row/family/qualifier value matches the expected val
326    * If it does, it performs the row mutations.  If the passed value is null, t
327    * is for the lack of column (ie: non-existence)
328    * @param row to check
329    * @param family column family to check
330    * @param qualifier column qualifier to check
331    * @param compareOp the comparison operator
332    * @param comparator
333    * @param mutation
334    * @param writeToWAL
335    * @return true if mutation was applied, false otherwise
336    * @throws IOException
337    */
338   boolean checkAndMutate(byte [] row, byte [] family, byte [] qualifier, CompareOp compareOp,
339       ByteArrayComparable comparator, Mutation mutation, boolean writeToWAL) throws IOException;
340 
341   /**
342    * Atomically checks if a row/family/qualifier value matches the expected val
343    * If it does, it performs the row mutations.  If the passed value is null, t
344    * is for the lack of column (ie: non-existence)
345    * @param row to check
346    * @param family column family to check
347    * @param qualifier column qualifier to check
348    * @param compareOp the comparison operator
349    * @param comparator
350    * @param mutations
351    * @param writeToWAL
352    * @return true if mutation was applied, false otherwise
353    * @throws IOException
354    */
355   boolean checkAndRowMutate(byte [] row, byte [] family, byte [] qualifier, CompareOp compareOp,
356       ByteArrayComparable comparator, RowMutations mutations, boolean writeToWAL)
357       throws IOException;
358 
359   /**
360    * Deletes the specified cells/row.
361    * @param delete
362    * @throws IOException
363    */
364   void delete(Delete delete) throws IOException;
365 
366   /**
367    * Do a get based on the get parameter.
368    * @param get query parameters
369    * @return result of the operation
370    */
371   Result get(Get get) throws IOException;
372 
373   /**
374    * Do a get based on the get parameter.
375    * @param get query parameters
376    * @param withCoprocessor invoke coprocessor or not. We don't want to
377    * always invoke cp.
378    * @return list of cells resulting from the operation
379    */
380   List<Cell> get(Get get, boolean withCoprocessor) throws IOException;
381 
382   /**
383    * Do a get for duplicate non-idempotent operation.
384    * @param get query parameters.
385    * @param withCoprocessor
386    * @param nonceGroup Nonce group.
387    * @param nonce Nonce.
388    * @return list of cells resulting from the operation
389    * @throws IOException
390    */
391   List<Cell> get(Get get, boolean withCoprocessor, long nonceGroup, long nonce) throws IOException;
392 
393   /**
394    * Return all the data for the row that matches <i>row</i> exactly,
395    * or the one that immediately preceeds it, at or immediately before
396    * <i>ts</i>.
397    * @param row
398    * @param family
399    * @return result of the operation
400    * @throws IOException
401    */
402   Result getClosestRowBefore(byte[] row, byte[] family) throws IOException;
403 
404   /**
405    * Return an iterator that scans over the HRegion, returning the indicated
406    * columns and rows specified by the {@link Scan}.
407    * <p>
408    * This Iterator must be closed by the caller.
409    *
410    * @param scan configured {@link Scan}
411    * @return RegionScanner
412    * @throws IOException read exceptions
413    */
414   RegionScanner getScanner(Scan scan) throws IOException;
415 
416   /**
417    * Return an iterator that scans over the HRegion, returning the indicated columns and rows
418    * specified by the {@link Scan}. The scanner will also include the additional scanners passed
419    * along with the scanners for the specified Scan instance. Should be careful with the usage to
420    * pass additional scanners only within this Region
421    * <p>
422    * This Iterator must be closed by the caller.
423    *
424    * @param scan configured {@link Scan}
425    * @param additionalScanners Any additional scanners to be used
426    * @return RegionScanner
427    * @throws IOException read exceptions
428    */
429   RegionScanner getScanner(Scan scan, List<KeyValueScanner> additionalScanners) throws IOException;
430 
431   /**
432    * Perform one or more increment operations on a row.
433    * @param increment
434    * @param nonceGroup
435    * @param nonce
436    * @return result of the operation
437    * @throws IOException
438    */
439   Result increment(Increment increment, long nonceGroup, long nonce) throws IOException;
440 
441   /**
442    * Performs multiple mutations atomically on a single row. Currently
443    * {@link Put} and {@link Delete} are supported.
444    *
445    * @param mutations object that specifies the set of mutations to perform atomically
446    * @throws IOException
447    */
448   void mutateRow(RowMutations mutations) throws IOException;
449 
450   /**
451    * Perform atomic mutations within the region.
452    *
453    * @param mutations The list of mutations to perform.
454    * <code>mutations</code> can contain operations for multiple rows.
455    * Caller has to ensure that all rows are contained in this region.
456    * @param rowsToLock Rows to lock
457    * @param nonceGroup Optional nonce group of the operation (client Id)
458    * @param nonce Optional nonce of the operation (unique random id to ensure "more idempotence")
459    * If multiple rows are locked care should be taken that
460    * <code>rowsToLock</code> is sorted in order to avoid deadlocks.
461    * @throws IOException
462    */
463   void mutateRowsWithLocks(Collection<Mutation> mutations, Collection<byte[]> rowsToLock,
464       long nonceGroup, long nonce) throws IOException;
465 
466   /**
467    * Performs atomic multiple reads and writes on a given row.
468    *
469    * @param processor The object defines the reads and writes to a row.
470    */
471   void processRowsWithLocks(RowProcessor<?,?> processor) throws IOException;
472 
473   /**
474    * Performs atomic multiple reads and writes on a given row.
475    *
476    * @param processor The object defines the reads and writes to a row.
477    * @param nonceGroup Optional nonce group of the operation (client Id)
478    * @param nonce Optional nonce of the operation (unique random id to ensure "more idempotence")
479    */
480   void processRowsWithLocks(RowProcessor<?,?> processor, long nonceGroup, long nonce)
481       throws IOException;
482 
483   /**
484    * Performs atomic multiple reads and writes on a given row.
485    *
486    * @param processor The object defines the reads and writes to a row.
487    * @param timeout The timeout of the processor.process() execution
488    *                Use a negative number to switch off the time bound
489    * @param nonceGroup Optional nonce group of the operation (client Id)
490    * @param nonce Optional nonce of the operation (unique random id to ensure "more idempotence")
491    */
492   void processRowsWithLocks(RowProcessor<?,?> processor, long timeout, long nonceGroup, long nonce)
493       throws IOException;
494 
495   /**
496    * Puts some data in the table.
497    * @param put
498    * @throws IOException
499    */
500   void put(Put put) throws IOException;
501 
502   /**
503    * Listener class to enable callers of
504    * bulkLoadHFile() to perform any necessary
505    * pre/post processing of a given bulkload call
506    */
507   interface BulkLoadListener {
508 
509     /**
510      * Called before an HFile is actually loaded
511      * @param family family being loaded to
512      * @param srcPath path of HFile
513      * @return final path to be used for actual loading
514      * @throws IOException
515      */
516     String prepareBulkLoad(byte[] family, String srcPath) throws IOException;
517 
518     /**
519      * Called after a successful HFile load
520      * @param family family being loaded to
521      * @param srcPath path of HFile
522      * @throws IOException
523      */
524     void doneBulkLoad(byte[] family, String srcPath) throws IOException;
525 
526     /**
527      * Called after a failed HFile load
528      * @param family family being loaded to
529      * @param srcPath path of HFile
530      * @throws IOException
531      */
532     void failedBulkLoad(byte[] family, String srcPath) throws IOException;
533   }
534 
535   /**
536    * Attempts to atomically load a group of hfiles.  This is critical for loading
537    * rows with multiple column families atomically.
538    *
539    * @param familyPaths List of Pair&lt;byte[] column family, String hfilePath&gt;
540    * @param bulkLoadListener Internal hooks enabling massaging/preparation of a
541    * file about to be bulk loaded
542    * @param assignSeqId
543    * @return true if successful, false if failed recoverably
544    * @throws IOException if failed unrecoverably.
545    */
546   boolean bulkLoadHFiles(Collection<Pair<byte[], String>> familyPaths, boolean assignSeqId,
547       BulkLoadListener bulkLoadListener) throws IOException;
548 
549   ///////////////////////////////////////////////////////////////////////////
550   // Coprocessors
551 
552   /** @return the coprocessor host */
553   RegionCoprocessorHost getCoprocessorHost();
554 
555   /**
556    * Executes a single protocol buffer coprocessor endpoint {@link Service} method using
557    * the registered protocol handlers.  {@link Service} implementations must be registered via the
558    * {@link Region#registerService(com.google.protobuf.Service)}
559    * method before they are available.
560    *
561    * @param controller an {@code RpcContoller} implementation to pass to the invoked service
562    * @param call a {@code CoprocessorServiceCall} instance identifying the service, method,
563    *     and parameters for the method invocation
564    * @return a protocol buffer {@code Message} instance containing the method's result
565    * @throws IOException if no registered service handler is found or an error
566    *     occurs during the invocation
567    * @see org.apache.hadoop.hbase.regionserver.Region#registerService(com.google.protobuf.Service)
568    */
569   Message execService(RpcController controller, CoprocessorServiceCall call) throws IOException;
570 
571   /**
572    * Registers a new protocol buffer {@link Service} subclass as a coprocessor endpoint to
573    * be available for handling
574    * {@link Region#execService(com.google.protobuf.RpcController,
575    *    org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceCall)}} calls.
576    *
577    * <p>
578    * Only a single instance may be registered per region for a given {@link Service} subclass (the
579    * instances are keyed on {@link com.google.protobuf.Descriptors.ServiceDescriptor#getFullName()}.
580    * After the first registration, subsequent calls with the same service name will fail with
581    * a return value of {@code false}.
582    * </p>
583    * @param instance the {@code Service} subclass instance to expose as a coprocessor endpoint
584    * @return {@code true} if the registration was successful, {@code false}
585    * otherwise
586    */
587   boolean registerService(Service instance);
588 
589   ///////////////////////////////////////////////////////////////////////////
590   // RowMutation processor support
591 
592   /**
593    * Check the collection of families for validity.
594    * @param families
595    * @throws NoSuchColumnFamilyException
596    */
597   void checkFamilies(Collection<byte[]> families) throws NoSuchColumnFamilyException;
598 
599   /**
600    * Check the collection of families for valid timestamps
601    * @param familyMap
602    * @param now current timestamp
603    * @throws FailedSanityCheckException
604    */
605   void checkTimestamps(Map<byte[], List<Cell>> familyMap, long now)
606       throws FailedSanityCheckException;
607 
608   /**
609    * Prepare a delete for a row mutation processor
610    * @param delete The passed delete is modified by this method. WARNING!
611    * @throws IOException
612    */
613   void prepareDelete(Delete delete) throws IOException;
614 
615   /**
616    * Set up correct timestamps in the KVs in Delete object.
617    * <p>Caller should have the row and region locks.
618    * @param mutation
619    * @param familyCellMap
620    * @param now
621    * @throws IOException
622    */
623   void prepareDeleteTimestamps(Mutation mutation, Map<byte[], List<Cell>> familyCellMap,
624       byte[] now) throws IOException;
625 
626   /**
627    * Replace any cell timestamps set to HConstants#LATEST_TIMESTAMP with the
628    * provided current timestamp.
629    * @param values
630    * @param now
631    */
632   void updateCellTimestamps(final Iterable<List<Cell>> values, final byte[] now)
633       throws IOException;
634 
635   ///////////////////////////////////////////////////////////////////////////
636   // Flushes, compactions, splits, etc.
637   // Wizards only, please
638 
639   interface FlushResult {
640     enum Result {
641       FLUSHED_NO_COMPACTION_NEEDED,
642       FLUSHED_COMPACTION_NEEDED,
643       // Special case where a flush didn't run because there's nothing in the memstores. Used when
644       // bulk loading to know when we can still load even if a flush didn't happen.
645       CANNOT_FLUSH_MEMSTORE_EMPTY,
646       CANNOT_FLUSH
647     }
648 
649     /** @return the detailed result code */
650     Result getResult();
651 
652     /** @return true if the memstores were flushed, else false */
653     boolean isFlushSucceeded();
654 
655     /** @return True if the flush requested a compaction, else false */
656     boolean isCompactionNeeded();
657   }
658 
659   /**
660    * Flush the cache.
661    *
662    * <p>When this method is called the cache will be flushed unless:
663    * <ol>
664    *   <li>the cache is empty</li>
665    *   <li>the region is closed.</li>
666    *   <li>a flush is already in progress</li>
667    *   <li>writes are disabled</li>
668    * </ol>
669    *
670    * <p>This method may block for some time, so it should not be called from a
671    * time-sensitive thread.
672    * @param force whether we want to force a flush of all stores
673    * @return FlushResult indicating whether the flush was successful or not and if
674    * the region needs compacting
675    *
676    * @throws IOException general io exceptions
677    * because a snapshot was not properly persisted.
678    */
679   FlushResult flush(boolean force) throws IOException;
680 
681   /**
682    * Synchronously compact all stores in the region.
683    * <p>This operation could block for a long time, so don't call it from a
684    * time-sensitive thread.
685    * <p>Note that no locks are taken to prevent possible conflicts between
686    * compaction and splitting activities. The regionserver does not normally compact
687    * and split in parallel. However by calling this method you may introduce
688    * unexpected and unhandled concurrency. Don't do this unless you know what
689    * you are doing.
690    *
691    * @param majorCompaction True to force a major compaction regardless of thresholds
692    * @throws IOException
693    */
694   void compact(final boolean majorCompaction) throws IOException;
695 
696   /**
697    * Trigger major compaction on all stores in the region.
698    * <p>
699    * Compaction will be performed asynchronously to this call by the RegionServer's
700    * CompactSplitThread. See also {@link Store#triggerMajorCompaction()}
701    * @throws IOException
702    */
703   void triggerMajorCompaction() throws IOException;
704 
705   /**
706    * @return if a given region is in compaction now.
707    */
708   CompactionState getCompactionState();
709 
710   /** Wait for all current flushes and compactions of the region to complete */
711   void waitForFlushesAndCompactions();
712 
713 }