View Javadoc

1   /**
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  package org.apache.hadoop.hbase.client;
20  
21  import java.io.Closeable;
22  import java.io.IOException;
23  import java.util.List;
24  import java.util.Map;
25  import java.util.concurrent.Future;
26  import java.util.regex.Pattern;
27  
28  import org.apache.hadoop.conf.Configuration;
29  import org.apache.hadoop.hbase.Abortable;
30  import org.apache.hadoop.hbase.ClusterStatus;
31  import org.apache.hadoop.hbase.HColumnDescriptor;
32  import org.apache.hadoop.hbase.HRegionInfo;
33  import org.apache.hadoop.hbase.HTableDescriptor;
34  import org.apache.hadoop.hbase.NamespaceDescriptor;
35  import org.apache.hadoop.hbase.ProcedureInfo;
36  import org.apache.hadoop.hbase.ServerName;
37  import org.apache.hadoop.hbase.TableExistsException;
38  import org.apache.hadoop.hbase.TableName;
39  import org.apache.hadoop.hbase.TableNotFoundException;
40  import org.apache.hadoop.hbase.classification.InterfaceAudience;
41  import org.apache.hadoop.hbase.classification.InterfaceStability;
42  import org.apache.hadoop.hbase.client.security.SecurityCapability;
43  import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
44  import org.apache.hadoop.hbase.protobuf.generated.AdminProtos;
45  import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
46  import org.apache.hadoop.hbase.protobuf.generated.MasterProtos;
47  import org.apache.hadoop.hbase.quotas.QuotaFilter;
48  import org.apache.hadoop.hbase.quotas.QuotaRetriever;
49  import org.apache.hadoop.hbase.quotas.QuotaSettings;
50  import org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException;
51  import org.apache.hadoop.hbase.snapshot.HBaseSnapshotException;
52  import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException;
53  import org.apache.hadoop.hbase.snapshot.SnapshotCreationException;
54  import org.apache.hadoop.hbase.snapshot.UnknownSnapshotException;
55  import org.apache.hadoop.hbase.util.Pair;
56  
57  /**
58   * The administrative API for HBase. Obtain an instance from an {@link Connection#getAdmin()} and
59   * call {@link #close()} afterwards.
60   * <p>Admin can be used to create, drop, list, enable and disable tables, add and drop table
61   * column families and other administrative operations.
62   *
63   * @see ConnectionFactory
64   * @see Connection
65   * @see Table
66   * @since 0.99.0
67   */
68  @InterfaceAudience.Public
69  @InterfaceStability.Evolving
70  public interface Admin extends Abortable, Closeable {
71    int getOperationTimeout();
72  
73    @Override
74    void abort(String why, Throwable e);
75  
76    @Override
77    boolean isAborted();
78  
79    /**
80     * @return Connection used by this object.
81     */
82    Connection getConnection();
83  
84    /**
85     * @param tableName Table to check.
86     * @return True if table exists already.
87     * @throws IOException
88     */
89    boolean tableExists(final TableName tableName) throws IOException;
90  
91    /**
92     * List all the userspace tables.
93     *
94     * @return - returns an array of HTableDescriptors
95     * @throws IOException if a remote or network exception occurs
96     */
97    HTableDescriptor[] listTables() throws IOException;
98  
99    /**
100    * List all the userspace tables matching the given pattern.
101    *
102    * @param pattern The compiled regular expression to match against
103    * @return - returns an array of HTableDescriptors
104    * @throws IOException if a remote or network exception occurs
105    * @see #listTables()
106    */
107   HTableDescriptor[] listTables(Pattern pattern) throws IOException;
108 
109   /**
110    * List all the userspace tables matching the given regular expression.
111    *
112    * @param regex The regular expression to match against
113    * @return - returns an array of HTableDescriptors
114    * @throws IOException if a remote or network exception occurs
115    * @see #listTables(java.util.regex.Pattern)
116    */
117   HTableDescriptor[] listTables(String regex) throws IOException;
118 
119   /**
120    * List all the tables matching the given pattern.
121    *
122    * @param pattern The compiled regular expression to match against
123    * @param includeSysTables False to match only against userspace tables
124    * @return - returns an array of HTableDescriptors
125    * @throws IOException if a remote or network exception occurs
126    * @see #listTables()
127    */
128   HTableDescriptor[] listTables(Pattern pattern, boolean includeSysTables)
129       throws IOException;
130 
131   /**
132    * List all the tables matching the given pattern.
133    *
134    * @param regex The regular expression to match against
135    * @param includeSysTables False to match only against userspace tables
136    * @return - returns an array of HTableDescriptors
137    * @throws IOException if a remote or network exception occurs
138    * @see #listTables(java.util.regex.Pattern, boolean)
139    */
140   HTableDescriptor[] listTables(String regex, boolean includeSysTables)
141       throws IOException;
142 
143   /**
144    * List all of the names of userspace tables.
145    *
146    * @return TableName[] table names
147    * @throws IOException if a remote or network exception occurs
148    */
149   TableName[] listTableNames() throws IOException;
150 
151   /**
152    * List all of the names of userspace tables.
153    * @param pattern The regular expression to match against
154    * @return TableName[] table names
155    * @throws IOException if a remote or network exception occurs
156    */
157   TableName[] listTableNames(Pattern pattern) throws IOException;
158 
159   /**
160    * List all of the names of userspace tables.
161    * @param regex The regular expression to match against
162    * @return TableName[] table names
163    * @throws IOException if a remote or network exception occurs
164    */
165   TableName[] listTableNames(String regex) throws IOException;
166 
167   /**
168    * List all of the names of userspace tables.
169    * @param pattern The regular expression to match against
170    * @param includeSysTables False to match only against userspace tables
171    * @return TableName[] table names
172    * @throws IOException if a remote or network exception occurs
173    */
174   TableName[] listTableNames(final Pattern pattern, final boolean includeSysTables)
175       throws IOException;
176 
177   /**
178    * List all of the names of userspace tables.
179    * @param regex The regular expression to match against
180    * @param includeSysTables False to match only against userspace tables
181    * @return TableName[] table names
182    * @throws IOException if a remote or network exception occurs
183    */
184   TableName[] listTableNames(final String regex, final boolean includeSysTables)
185       throws IOException;
186 
187   /**
188    * Method for getting the tableDescriptor
189    *
190    * @param tableName as a {@link TableName}
191    * @return the tableDescriptor
192    * @throws org.apache.hadoop.hbase.TableNotFoundException
193    * @throws IOException if a remote or network exception occurs
194    */
195   HTableDescriptor getTableDescriptor(final TableName tableName)
196       throws TableNotFoundException, IOException;
197 
198   /**
199    * Creates a new table. Synchronous operation.
200    *
201    * @param desc table descriptor for table
202    * @throws IllegalArgumentException if the table name is reserved
203    * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running
204    * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent
205    * threads, the table may have been created between test-for-existence and attempt-at-creation).
206    * @throws IOException if a remote or network exception occurs
207    */
208   void createTable(HTableDescriptor desc) throws IOException;
209 
210   /**
211    * Creates a new table with the specified number of regions.  The start key specified will become
212    * the end key of the first region of the table, and the end key specified will become the start
213    * key of the last region of the table (the first region has a null start key and the last region
214    * has a null end key). BigInteger math will be used to divide the key range specified into enough
215    * segments to make the required number of total regions. Synchronous operation.
216    *
217    * @param desc table descriptor for table
218    * @param startKey beginning of key range
219    * @param endKey end of key range
220    * @param numRegions the total number of regions to create
221    * @throws IllegalArgumentException if the table name is reserved
222    * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running
223    * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent
224    * threads, the table may have been created between test-for-existence and attempt-at-creation).
225    * @throws IOException
226    */
227   void createTable(HTableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions)
228       throws IOException;
229 
230   /**
231    * Creates a new table with an initial set of empty regions defined by the specified split keys.
232    * The total number of regions created will be the number of split keys plus one. Synchronous
233    * operation. Note : Avoid passing empty split key.
234    *
235    * @param desc table descriptor for table
236    * @param splitKeys array of split keys for the initial regions of the table
237    * @throws IllegalArgumentException if the table name is reserved, if the split keys are repeated
238    * and if the split key has empty byte array.
239    * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running
240    * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent
241    * threads, the table may have been created between test-for-existence and attempt-at-creation).
242    * @throws IOException
243    */
244   void createTable(final HTableDescriptor desc, byte[][] splitKeys) throws IOException;
245 
246   /**
247    * Creates a new table but does not block and wait for it to come online.
248    * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
249    * It may throw ExecutionException if there was an error while executing the operation
250    * or TimeoutException in case the wait timeout was not long enough to allow the
251    * operation to complete.
252    * Throws IllegalArgumentException Bad table name, if the split keys
253    *    are repeated and if the split key has empty byte array.
254    *
255    * @param desc table descriptor for table
256    * @param splitKeys keys to check if the table has been created with all split keys
257    * @throws IOException if a remote or network exception occurs
258    * @return the result of the async creation. You can use Future.get(long, TimeUnit)
259    *    to wait on the operation to complete.
260    */
261   Future<Void> createTableAsync(final HTableDescriptor desc, final byte[][] splitKeys)
262       throws IOException;
263 
264   /**
265    * Deletes a table. Synchronous operation.
266    *
267    * @param tableName name of table to delete
268    * @throws IOException if a remote or network exception occurs
269    */
270   void deleteTable(final TableName tableName) throws IOException;
271 
272   /**
273    * Deletes the table but does not block and wait for it be completely removed.
274    * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
275    * It may throw ExecutionException if there was an error while executing the operation
276    * or TimeoutException in case the wait timeout was not long enough to allow the
277    * operation to complete.
278    *
279    * @param tableName name of table to delete
280    * @throws IOException if a remote or network exception occurs
281    * @return the result of the async delete. You can use Future.get(long, TimeUnit)
282    *    to wait on the operation to complete.
283    */
284   Future<Void> deleteTableAsync(TableName tableName) throws IOException;
285 
286   /**
287    * Deletes tables matching the passed in pattern and wait on completion. Warning: Use this method
288    * carefully, there is no prompting and the effect is immediate. Consider using {@link
289    * #listTables(java.lang.String)} and {@link #deleteTable(org.apache.hadoop.hbase.TableName)}
290    *
291    * @param regex The regular expression to match table names against
292    * @return Table descriptors for tables that couldn't be deleted
293    * @throws IOException
294    * @see #deleteTables(java.util.regex.Pattern)
295    * @see #deleteTable(org.apache.hadoop.hbase.TableName)
296    */
297   HTableDescriptor[] deleteTables(String regex) throws IOException;
298 
299   /**
300    * Delete tables matching the passed in pattern and wait on completion. Warning: Use this method
301    * carefully, there is no prompting and the effect is immediate. Consider using {@link
302    * #listTables(java.util.regex.Pattern) } and
303    * {@link #deleteTable(org.apache.hadoop.hbase.TableName)}
304    *
305    * @param pattern The pattern to match table names against
306    * @return Table descriptors for tables that couldn't be deleted
307    * @throws IOException
308    */
309   HTableDescriptor[] deleteTables(Pattern pattern) throws IOException;
310 
311   /**
312    * Truncate a table.
313    * Synchronous operation.
314    *
315    * @param tableName name of table to truncate
316    * @param preserveSplits True if the splits should be preserved
317    * @throws IOException if a remote or network exception occurs
318    */
319   public void truncateTable(final TableName tableName, final boolean preserveSplits)
320       throws IOException;
321 
322   /**
323    * Truncate the table but does not block and wait for it be completely enabled. You can use
324    * Future.get(long, TimeUnit) to wait on the operation to complete. It may throw
325    * ExecutionException if there was an error while executing the operation or TimeoutException in
326    * case the wait timeout was not long enough to allow the operation to complete.
327    * @param tableName name of table to delete
328    * @param preserveSplits true if the splits should be preserved
329    * @throws IOException if a remote or network exception occurs
330    * @return the result of the async truncate. You can use Future.get(long, TimeUnit) to wait on the
331    *         operation to complete.
332    */
333   Future<Void> truncateTableAsync(final TableName tableName, final boolean preserveSplits)
334       throws IOException;
335 
336   /**
337    * Enable a table.  May timeout.  Use {@link #enableTableAsync(org.apache.hadoop.hbase.TableName)}
338    * and {@link #isTableEnabled(org.apache.hadoop.hbase.TableName)} instead. The table has to be in
339    * disabled state for it to be enabled.
340    *
341    * @param tableName name of the table
342    * @throws IOException if a remote or network exception occurs There could be couple types of
343    * IOException TableNotFoundException means the table doesn't exist. TableNotDisabledException
344    * means the table isn't in disabled state.
345    * @see #isTableEnabled(org.apache.hadoop.hbase.TableName)
346    * @see #disableTable(org.apache.hadoop.hbase.TableName)
347    * @see #enableTableAsync(org.apache.hadoop.hbase.TableName)
348    */
349   void enableTable(final TableName tableName) throws IOException;
350 
351   /**
352    * Enable the table but does not block and wait for it be completely enabled.
353    * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
354    * It may throw ExecutionException if there was an error while executing the operation
355    * or TimeoutException in case the wait timeout was not long enough to allow the
356    * operation to complete.
357    *
358    * @param tableName name of table to delete
359    * @throws IOException if a remote or network exception occurs
360    * @return the result of the async enable. You can use Future.get(long, TimeUnit)
361    *    to wait on the operation to complete.
362    */
363   Future<Void> enableTableAsync(final TableName tableName) throws IOException;
364 
365   /**
366    * Enable tables matching the passed in pattern and wait on completion. Warning: Use this method
367    * carefully, there is no prompting and the effect is immediate. Consider using {@link
368    * #listTables(java.lang.String)} and {@link #enableTable(org.apache.hadoop.hbase.TableName)}
369    *
370    * @param regex The regular expression to match table names against
371    * @throws IOException
372    * @see #enableTables(java.util.regex.Pattern)
373    * @see #enableTable(org.apache.hadoop.hbase.TableName)
374    */
375   HTableDescriptor[] enableTables(String regex) throws IOException;
376 
377   /**
378    * Enable tables matching the passed in pattern and wait on completion. Warning: Use this method
379    * carefully, there is no prompting and the effect is immediate. Consider using {@link
380    * #listTables(java.util.regex.Pattern) } and
381    * {@link #enableTable(org.apache.hadoop.hbase.TableName)}
382    *
383    * @param pattern The pattern to match table names against
384    * @throws IOException
385    */
386   HTableDescriptor[] enableTables(Pattern pattern) throws IOException;
387 
388   /**
389    * Disable the table but does not block and wait for it be completely disabled.
390    * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
391    * It may throw ExecutionException if there was an error while executing the operation
392    * or TimeoutException in case the wait timeout was not long enough to allow the
393    * operation to complete.
394    *
395    * @param tableName name of table to delete
396    * @throws IOException if a remote or network exception occurs
397    * @return the result of the async disable. You can use Future.get(long, TimeUnit)
398    *    to wait on the operation to complete.
399    */
400   Future<Void> disableTableAsync(final TableName tableName) throws IOException;
401 
402   /**
403    * Disable table and wait on completion.  May timeout eventually.  Use {@link
404    * #disableTableAsync(org.apache.hadoop.hbase.TableName)} and
405    * {@link #isTableDisabled(org.apache.hadoop.hbase.TableName)} instead. The table has to be in
406    * enabled state for it to be disabled.
407    *
408    * @param tableName
409    * @throws IOException There could be couple types of IOException TableNotFoundException means the
410    * table doesn't exist. TableNotEnabledException means the table isn't in enabled state.
411    */
412   void disableTable(final TableName tableName) throws IOException;
413 
414   /**
415    * Disable tables matching the passed in pattern and wait on completion. Warning: Use this method
416    * carefully, there is no prompting and the effect is immediate. Consider using {@link
417    * #listTables(java.lang.String)} and {@link #disableTable(org.apache.hadoop.hbase.TableName)}
418    *
419    * @param regex The regular expression to match table names against
420    * @return Table descriptors for tables that couldn't be disabled
421    * @throws IOException
422    * @see #disableTables(java.util.regex.Pattern)
423    * @see #disableTable(org.apache.hadoop.hbase.TableName)
424    */
425   HTableDescriptor[] disableTables(String regex) throws IOException;
426 
427   /**
428    * Disable tables matching the passed in pattern and wait on completion. Warning: Use this method
429    * carefully, there is no prompting and the effect is immediate. Consider using {@link
430    * #listTables(java.util.regex.Pattern) } and
431    * {@link #disableTable(org.apache.hadoop.hbase.TableName)}
432    *
433    * @param pattern The pattern to match table names against
434    * @return Table descriptors for tables that couldn't be disabled
435    * @throws IOException
436    */
437   HTableDescriptor[] disableTables(Pattern pattern) throws IOException;
438 
439   /**
440    * @param tableName name of table to check
441    * @return true if table is on-line
442    * @throws IOException if a remote or network exception occurs
443    */
444   boolean isTableEnabled(TableName tableName) throws IOException;
445 
446   /**
447    * @param tableName name of table to check
448    * @return true if table is off-line
449    * @throws IOException if a remote or network exception occurs
450    */
451   boolean isTableDisabled(TableName tableName) throws IOException;
452 
453   /**
454    * @param tableName name of table to check
455    * @return true if all regions of the table are available
456    * @throws IOException if a remote or network exception occurs
457    */
458   boolean isTableAvailable(TableName tableName) throws IOException;
459 
460   /**
461    * Use this api to check if the table has been created with the specified number of splitkeys
462    * which was used while creating the given table. Note : If this api is used after a table's
463    * region gets splitted, the api may return false.
464    *
465    * @param tableName name of table to check
466    * @param splitKeys keys to check if the table has been created with all split keys
467    * @throws IOException if a remote or network excpetion occurs
468    */
469   boolean isTableAvailable(TableName tableName, byte[][] splitKeys) throws IOException;
470 
471   /**
472    * Get the status of alter command - indicates how many regions have received the updated schema
473    * Asynchronous operation.
474    *
475    * @param tableName TableName instance
476    * @return Pair indicating the number of regions updated Pair.getFirst() is the regions that are
477    * yet to be updated Pair.getSecond() is the total number of regions of the table
478    * @throws IOException if a remote or network exception occurs
479    */
480   Pair<Integer, Integer> getAlterStatus(final TableName tableName) throws IOException;
481 
482   /**
483    * Get the status of alter command - indicates how many regions have received the updated schema
484    * Asynchronous operation.
485    *
486    * @param tableName name of the table to get the status of
487    * @return Pair indicating the number of regions updated Pair.getFirst() is the regions that are
488    * yet to be updated Pair.getSecond() is the total number of regions of the table
489    * @throws IOException if a remote or network exception occurs
490    * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #getAlterStatus(TableName)}
491    *     instead.
492    */
493   @Deprecated
494   Pair<Integer, Integer> getAlterStatus(final byte[] tableName) throws IOException;
495 
496   /**
497    * Add a column family to an existing table. Asynchronous operation.
498    *
499    * @param tableName name of the table to add column family to
500    * @param columnFamily column family descriptor of column family to be added
501    * @throws IOException if a remote or network exception occurs
502    * @deprecated As of release 2.0.0.
503    *             (<a href="https://issues.apache.org/jira/browse/HBASE-1989">HBASE-1989</a>).
504    *             This will be removed in HBase 3.0.0.
505    *             Use {@link #addColumnFamily(TableName, HColumnDescriptor)}.
506    */
507   @Deprecated
508   void addColumn(final TableName tableName, final HColumnDescriptor columnFamily)
509     throws IOException;
510 
511   /**
512    * Add a column family to an existing table. Asynchronous operation.
513    * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
514    * It may throw ExecutionException if there was an error while executing the operation
515    * or TimeoutException in case the wait timeout was not long enough to allow the
516    * operation to complete.
517    *
518    * @param tableName name of the table to add column family to
519    * @param columnFamily column family descriptor of column family to be added
520    * @throws IOException if a remote or network exception occurs
521    * @return the result of the async add column family. You can use Future.get(long, TimeUnit) to
522    *         wait on the operation to complete.
523    */
524   Future<Void> addColumnFamily(final TableName tableName, final HColumnDescriptor columnFamily)
525       throws IOException;
526 
527   /**
528    * Delete a column family from a table. Asynchronous operation.
529    *
530    * @param tableName name of table
531    * @param columnFamily name of column family to be deleted
532    * @throws IOException if a remote or network exception occurs
533    * @deprecated As of release 2.0.0.
534    *             (<a href="https://issues.apache.org/jira/browse/HBASE-1989">HBASE-1989</a>).
535    *             This will be removed in HBase 3.0.0.
536    *             Use {@link #deleteColumnFamily(TableName, byte[])}}.
537    */
538   @Deprecated
539   void deleteColumn(final TableName tableName, final byte[] columnFamily) throws IOException;
540 
541   /**
542    * Delete a column family from a table. Asynchronous operation.
543    * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
544    * It may throw ExecutionException if there was an error while executing the operation
545    * or TimeoutException in case the wait timeout was not long enough to allow the
546    * operation to complete.
547    *
548    * @param tableName name of table
549    * @param columnFamily name of column family to be deleted
550    * @throws IOException if a remote or network exception occurs
551    * @return the result of the async delete column family. You can use Future.get(long, TimeUnit) to
552    *         wait on the operation to complete.
553    */
554   Future<Void> deleteColumnFamily(final TableName tableName, final byte[] columnFamily)
555       throws IOException;
556 
557   /**
558    * Modify an existing column family on a table. Asynchronous operation.
559    * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
560    * It may throw ExecutionException if there was an error while executing the operation
561    * or TimeoutException in case the wait timeout was not long enough to allow the
562    * operation to complete.
563    *
564    * @param tableName name of table
565    * @param columnFamily new column family descriptor to use
566    * @throws IOException if a remote or network exception occurs
567    * @deprecated As of release 2.0.0.
568    *             (<a href="https://issues.apache.org/jira/browse/HBASE-1989">HBASE-1989</a>).
569    *             This will be removed in HBase 3.0.0.
570    *             Use {@link #modifyColumnFamily(TableName, HColumnDescriptor)}.
571    */
572   @Deprecated
573   void modifyColumn(final TableName tableName, final HColumnDescriptor columnFamily)
574       throws IOException;
575 
576   /**
577    * Modify an existing column family on a table. Asynchronous operation.
578    *
579    * @param tableName name of table
580    * @param columnFamily new column family descriptor to use
581    * @throws IOException if a remote or network exception occurs
582    * @return the result of the async modify column family. You can use Future.get(long, TimeUnit) to
583    *         wait on the operation to complete.
584    */
585   Future<Void> modifyColumnFamily(final TableName tableName, final HColumnDescriptor columnFamily)
586       throws IOException;
587 
588 
589   /**
590    * Close a region. For expert-admins.  Runs close on the regionserver.  The master will not be
591    * informed of the close.
592    *
593    * @param regionname region name to close
594    * @param serverName If supplied, we'll use this location rather than the one currently in
595    * <code>hbase:meta</code>
596    * @throws IOException if a remote or network exception occurs
597    */
598   void closeRegion(final String regionname, final String serverName) throws IOException;
599 
600   /**
601    * Close a region.  For expert-admins  Runs close on the regionserver.  The master will not be
602    * informed of the close.
603    *
604    * @param regionname region name to close
605    * @param serverName The servername of the regionserver.  If passed null we will use servername
606    * found in the hbase:meta table. A server name is made of host, port and startcode.  Here is an
607    * example: <code> host187.example.com,60020,1289493121758</code>
608    * @throws IOException if a remote or network exception occurs
609    */
610   void closeRegion(final byte[] regionname, final String serverName) throws IOException;
611 
612   /**
613    * For expert-admins. Runs close on the regionserver. Closes a region based on the encoded region
614    * name. The region server name is mandatory. If the servername is provided then based on the
615    * online regions in the specified regionserver the specified region will be closed. The master
616    * will not be informed of the close. Note that the regionname is the encoded regionname.
617    *
618    * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name
619    * suffix: e.g. if regionname is
620    * <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>,
621    * then the encoded region name is: <code>527db22f95c8a9e0116f0cc13c680396</code>.
622    * @param serverName The servername of the regionserver. A server name is made of host, port and
623    * startcode. This is mandatory. Here is an example:
624    * <code> host187.example.com,60020,1289493121758</code>
625    * @return true if the region was closed, false if not.
626    * @throws IOException if a remote or network exception occurs
627    */
628   boolean closeRegionWithEncodedRegionName(final String encodedRegionName, final String serverName)
629       throws IOException;
630 
631   /**
632    * Close a region.  For expert-admins  Runs close on the regionserver.  The master will not be
633    * informed of the close.
634    *
635    * @param sn
636    * @param hri
637    * @throws IOException
638    */
639   void closeRegion(final ServerName sn, final HRegionInfo hri) throws IOException;
640 
641   /**
642    * Get all the online regions on a region server.
643    */
644   List<HRegionInfo> getOnlineRegions(final ServerName sn) throws IOException;
645 
646   /**
647    * Flush a table. Synchronous operation.
648    *
649    * @param tableName table to flush
650    * @throws IOException if a remote or network exception occurs
651    */
652   void flush(final TableName tableName) throws IOException;
653 
654   /**
655    * Flush an individual region. Synchronous operation.
656    *
657    * @param regionName region to flush
658    * @throws IOException if a remote or network exception occurs
659    */
660   void flushRegion(final byte[] regionName) throws IOException;
661 
662   /**
663    * Compact a table. Asynchronous operation.
664    *
665    * @param tableName table to compact
666    * @throws IOException if a remote or network exception occurs
667    */
668   void compact(final TableName tableName) throws IOException;
669 
670   /**
671    * Compact an individual region. Asynchronous operation.
672    *
673    * @param regionName region to compact
674    * @throws IOException if a remote or network exception occurs
675    */
676   void compactRegion(final byte[] regionName) throws IOException;
677 
678   /**
679    * Compact a column family within a table. Asynchronous operation.
680    *
681    * @param tableName table to compact
682    * @param columnFamily column family within a table
683    * @throws IOException if a remote or network exception occurs
684    */
685   void compact(final TableName tableName, final byte[] columnFamily)
686     throws IOException;
687 
688   /**
689    * Compact a column family within a region. Asynchronous operation.
690    *
691    * @param regionName region to compact
692    * @param columnFamily column family within a region
693    * @throws IOException if a remote or network exception occurs
694    */
695   void compactRegion(final byte[] regionName, final byte[] columnFamily)
696     throws IOException;
697 
698   /**
699    * Major compact a table. Asynchronous operation.
700    *
701    * @param tableName table to major compact
702    * @throws IOException if a remote or network exception occurs
703    */
704   void majorCompact(TableName tableName) throws IOException;
705 
706   /**
707    * Major compact a table or an individual region. Asynchronous operation.
708    *
709    * @param regionName region to major compact
710    * @throws IOException if a remote or network exception occurs
711    */
712   void majorCompactRegion(final byte[] regionName) throws IOException;
713 
714   /**
715    * Major compact a column family within a table. Asynchronous operation.
716    *
717    * @param tableName table to major compact
718    * @param columnFamily column family within a table
719    * @throws IOException if a remote or network exception occurs
720    */
721   void majorCompact(TableName tableName, final byte[] columnFamily)
722     throws IOException;
723 
724   /**
725    * Major compact a column family within region. Asynchronous operation.
726    *
727    * @param regionName egion to major compact
728    * @param columnFamily column family within a region
729    * @throws IOException if a remote or network exception occurs
730    */
731   void majorCompactRegion(final byte[] regionName, final byte[] columnFamily)
732     throws IOException;
733 
734   /**
735    * Compact all regions on the region server
736    * @param sn the region server name
737    * @param major if it's major compaction
738    * @throws IOException
739    * @throws InterruptedException
740    */
741   public void compactRegionServer(final ServerName sn, boolean major)
742     throws IOException, InterruptedException;
743 
744   /**
745    * Move the region <code>r</code> to <code>dest</code>.
746    *
747    * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name
748    * suffix: e.g. if regionname is
749    * <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>,
750    * then the encoded region name is: <code>527db22f95c8a9e0116f0cc13c680396</code>.
751    * @param destServerName The servername of the destination regionserver.  If passed the empty byte
752    * array we'll assign to a random server.  A server name is made of host, port and startcode.
753    * Here is an example: <code> host187.example.com,60020,1289493121758</code>
754    * @throws IOException if we can't find a region named
755    * <code>encodedRegionName</code>
756    */
757   void move(final byte[] encodedRegionName, final byte[] destServerName)
758       throws IOException;
759 
760   /**
761    * @param regionName Region name to assign.
762    */
763   void assign(final byte[] regionName)
764       throws IOException;
765 
766   /**
767    * Unassign a region from current hosting regionserver.  Region will then be assigned to a
768    * regionserver chosen at random.  Region could be reassigned back to the same server.  Use {@link
769    * #move(byte[], byte[])} if you want to control the region movement.
770    *
771    * @param regionName Region to unassign. Will clear any existing RegionPlan if one found.
772    * @param force If true, force unassign (Will remove region from regions-in-transition too if
773    * present. If results in double assignment use hbck -fix to resolve. To be used by experts).
774    */
775   void unassign(final byte[] regionName, final boolean force)
776       throws IOException;
777 
778   /**
779    * Offline specified region from master's in-memory state. It will not attempt to reassign the
780    * region as in unassign. This API can be used when a region not served by any region server and
781    * still online as per Master's in memory state. If this API is incorrectly used on active region
782    * then master will loose track of that region. This is a special method that should be used by
783    * experts or hbck.
784    *
785    * @param regionName Region to offline.
786    * @throws IOException
787    */
788   void offline(final byte[] regionName) throws IOException;
789 
790   /**
791    * Turn the load balancer on or off.
792    *
793    * @param synchronous If true, it waits until current balance() call, if outstanding, to return.
794    * @return Previous balancer value
795    */
796   boolean setBalancerRunning(final boolean on, final boolean synchronous)
797       throws IOException;
798 
799   /**
800    * Invoke the balancer.  Will run the balancer and if regions to move, it will go ahead and do the
801    * reassignments.  Can NOT run for various reasons.  Check logs.
802    *
803    * @return True if balancer ran, false otherwise.
804    */
805   boolean balancer() throws IOException;
806 
807   /**
808    * Invoke the balancer.  Will run the balancer and if regions to move, it will
809    * go ahead and do the reassignments. If there is region in transition, force parameter of true
810    * would still run balancer. Can *not* run for other reasons.  Check
811    * logs.
812    * @param force whether we should force balance even if there is region in transition
813    * @return True if balancer ran, false otherwise.
814    */
815   boolean balancer(boolean force) throws IOException;
816 
817   /**
818    * Query the current state of the balancer
819    *
820    * @return true if the balancer is enabled, false otherwise.
821    */
822   boolean isBalancerEnabled() throws IOException;
823 
824   /**
825    * Invoke region normalizer. Can NOT run for various reasons.  Check logs.
826    *
827    * @return True if region normalizer ran, false otherwise.
828    */
829   boolean normalize() throws IOException;
830 
831   /**
832    * Query the current state of the region normalizer
833    *
834    * @return true if region normalizer is enabled, false otherwise.
835    */
836   boolean isNormalizerEnabled() throws IOException;
837 
838   /**
839    * Turn region normalizer on or off.
840    *
841    * @return Previous normalizer value
842    */
843   boolean setNormalizerRunning(final boolean on)
844     throws IOException;
845 
846   /**
847    * Enable/Disable the catalog janitor
848    *
849    * @param enable if true enables the catalog janitor
850    * @return the previous state
851    */
852   boolean enableCatalogJanitor(boolean enable) throws IOException;
853 
854   /**
855    * Ask for a scan of the catalog table
856    *
857    * @return the number of entries cleaned
858    */
859   int runCatalogScan() throws IOException;
860 
861   /**
862    * Query on the catalog janitor state (Enabled/Disabled?)
863    *
864    */
865   boolean isCatalogJanitorEnabled() throws IOException;
866 
867   /**
868    * Merge two regions. Asynchronous operation.
869    *
870    * @param nameOfRegionA encoded or full name of region a
871    * @param nameOfRegionB encoded or full name of region b
872    * @param forcible true if do a compulsory merge, otherwise we will only merge two adjacent
873    * regions
874    * @throws IOException
875    */
876   void mergeRegions(final byte[] nameOfRegionA, final byte[] nameOfRegionB,
877       final boolean forcible) throws IOException;
878 
879   /**
880    * Split a table. Asynchronous operation.
881    *
882    * @param tableName table to split
883    * @throws IOException if a remote or network exception occurs
884    */
885   void split(final TableName tableName) throws IOException;
886 
887   /**
888    * Split an individual region. Asynchronous operation.
889    *
890    * @param regionName region to split
891    * @throws IOException if a remote or network exception occurs
892    */
893   void splitRegion(final byte[] regionName) throws IOException;
894 
895   /**
896    * Split a table. Asynchronous operation.
897    *
898    * @param tableName table to split
899    * @param splitPoint the explicit position to split on
900    * @throws IOException if a remote or network exception occurs
901    */
902   void split(final TableName tableName, final byte[] splitPoint)
903     throws IOException;
904 
905   /**
906    * Split an individual region. Asynchronous operation.
907    *
908    * @param regionName region to split
909    * @param splitPoint the explicit position to split on
910    * @throws IOException if a remote or network exception occurs
911    */
912   void splitRegion(final byte[] regionName, final byte[] splitPoint)
913     throws IOException;
914 
915   /**
916    * Modify an existing table, more IRB friendly version. Asynchronous operation.  This means that
917    * it may be a while before your schema change is updated across all of the table.
918    * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
919    * It may throw ExecutionException if there was an error while executing the operation
920    * or TimeoutException in case the wait timeout was not long enough to allow the
921    * operation to complete.
922    *
923    * @param tableName name of table.
924    * @param htd modified description of the table
925    * @throws IOException if a remote or network exception occurs
926    * @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the
927    *     operation to complete
928    */
929   Future<Void> modifyTable(final TableName tableName, final HTableDescriptor htd)
930       throws IOException;
931 
932   /**
933    * Shuts down the HBase cluster
934    *
935    * @throws IOException if a remote or network exception occurs
936    */
937   void shutdown() throws IOException;
938 
939   /**
940    * Shuts down the current HBase master only. Does not shutdown the cluster.
941    *
942    * @throws IOException if a remote or network exception occurs
943    * @see #shutdown()
944    */
945   void stopMaster() throws IOException;
946 
947   /**
948    * Stop the designated regionserver
949    *
950    * @param hostnamePort Hostname and port delimited by a <code>:</code> as in
951    * <code>example.org:1234</code>
952    * @throws IOException if a remote or network exception occurs
953    */
954   void stopRegionServer(final String hostnamePort) throws IOException;
955 
956   /**
957    * @return cluster status
958    * @throws IOException if a remote or network exception occurs
959    */
960   ClusterStatus getClusterStatus() throws IOException;
961 
962   /**
963    * @return Configuration used by the instance.
964    */
965   Configuration getConfiguration();
966 
967   /**
968    * Create a new namespace. Blocks until namespace has been successfully created or an exception
969    * is thrown.
970    *
971    * @param descriptor descriptor which describes the new namespace
972    */
973   void createNamespace(final NamespaceDescriptor descriptor)
974   throws IOException;
975 
976   /**
977    * Create a new namespace
978    *
979    * @param descriptor descriptor which describes the new namespace
980    * @return the result of the async create namespace operation. Use Future.get(long, TimeUnit) to
981    *  wait on the operation to complete.
982    */
983   Future<Void> createNamespaceAsync(final NamespaceDescriptor descriptor)
984   throws IOException;
985 
986   /**
987    * Modify an existing namespace.  Blocks until namespace has been successfully modified or an
988    * exception is thrown.
989    *
990    * @param descriptor descriptor which describes the new namespace
991    */
992   void modifyNamespace(final NamespaceDescriptor descriptor)
993   throws IOException;
994 
995   /**
996    * Modify an existing namespace
997    *
998    * @param descriptor descriptor which describes the new namespace
999    * @return the result of the async modify namespace operation. Use Future.get(long, TimeUnit) to
1000    *  wait on the operation to complete.
1001    */
1002   Future<Void> modifyNamespaceAsync(final NamespaceDescriptor descriptor)
1003   throws IOException;
1004 
1005   /**
1006    * Delete an existing namespace. Only empty namespaces (no tables) can be removed.
1007    * Blocks until namespace has been successfully deleted or an
1008    * exception is thrown.
1009    *
1010    * @param name namespace name
1011    */
1012   void deleteNamespace(final String name) throws IOException;
1013 
1014   /**
1015    * Delete an existing namespace. Only empty namespaces (no tables) can be removed.
1016    *
1017    * @param name namespace name
1018    * @return the result of the async delete namespace operation. Use Future.get(long, TimeUnit) to
1019    *  wait on the operation to complete.
1020    */
1021   Future<Void> deleteNamespaceAsync(final String name) throws IOException;
1022 
1023   /**
1024    * Get a namespace descriptor by name
1025    *
1026    * @param name name of namespace descriptor
1027    * @return A descriptor
1028    */
1029   NamespaceDescriptor getNamespaceDescriptor(final String name)
1030   throws IOException;
1031 
1032   /**
1033    * List available namespace descriptors
1034    *
1035    * @return List of descriptors
1036    */
1037   NamespaceDescriptor[] listNamespaceDescriptors()
1038   throws IOException;
1039 
1040   /**
1041    * Get list of table descriptors by namespace
1042    *
1043    * @param name namespace name
1044    * @return A descriptor
1045    * @throws IOException
1046    */
1047   HTableDescriptor[] listTableDescriptorsByNamespace(final String name)
1048       throws IOException;
1049 
1050   /**
1051    * Get list of table names by namespace
1052    *
1053    * @param name namespace name
1054    * @return The list of table names in the namespace
1055    * @throws IOException
1056    */
1057   TableName[] listTableNamesByNamespace(final String name)
1058       throws IOException;
1059 
1060   /**
1061    * Get the regions of a given table.
1062    *
1063    * @param tableName the name of the table
1064    * @return List of {@link HRegionInfo}.
1065    * @throws IOException
1066    */
1067   List<HRegionInfo> getTableRegions(final TableName tableName)
1068     throws IOException;
1069 
1070   @Override
1071   void close() throws IOException;
1072 
1073   /**
1074    * Get tableDescriptors
1075    *
1076    * @param tableNames List of table names
1077    * @return HTD[] the tableDescriptor
1078    * @throws IOException if a remote or network exception occurs
1079    */
1080   HTableDescriptor[] getTableDescriptorsByTableName(List<TableName> tableNames)
1081     throws IOException;
1082 
1083   /**
1084    * Get tableDescriptors
1085    *
1086    * @param names List of table names
1087    * @return HTD[] the tableDescriptor
1088    * @throws IOException if a remote or network exception occurs
1089    */
1090   HTableDescriptor[] getTableDescriptors(List<String> names)
1091     throws IOException;
1092 
1093   /**
1094    * abort a procedure
1095    * @param procId ID of the procedure to abort
1096    * @param mayInterruptIfRunning if the proc completed at least one step, should it be aborted?
1097    * @return true if aborted, false if procedure already completed or does not exist
1098    * @throws IOException
1099    */
1100   boolean abortProcedure(
1101       final long procId,
1102       final boolean mayInterruptIfRunning) throws IOException;
1103 
1104   /**
1105    * Abort a procedure but does not block and wait for it be completely removed.
1106    * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
1107    * It may throw ExecutionException if there was an error while executing the operation
1108    * or TimeoutException in case the wait timeout was not long enough to allow the
1109    * operation to complete.
1110    *
1111    * @param procId ID of the procedure to abort
1112    * @param mayInterruptIfRunning if the proc completed at least one step, should it be aborted?
1113    * @return true if aborted, false if procedure already completed or does not exist
1114    * @throws IOException
1115    */
1116   Future<Boolean> abortProcedureAsync(
1117     final long procId,
1118     final boolean mayInterruptIfRunning) throws IOException;
1119 
1120   /**
1121    * List procedures
1122    * @return procedure list
1123    * @throws IOException
1124    */
1125   ProcedureInfo[] listProcedures()
1126       throws IOException;
1127 
1128   /**
1129    * Roll the log writer. I.e. for filesystem based write ahead logs, start writing to a new file.
1130    *
1131    * Note that the actual rolling of the log writer is asynchronous and may not be complete when
1132    * this method returns. As a side effect of this call, the named region server may schedule
1133    * store flushes at the request of the wal.
1134    *
1135    * @param serverName The servername of the regionserver.
1136    * @throws IOException if a remote or network exception occurs
1137    * @throws org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException
1138    */
1139   void rollWALWriter(ServerName serverName) throws IOException, FailedLogCloseException;
1140 
1141   /**
1142    * Helper delegage to getClusterStatus().getMasterCoprocessors().
1143    * @return an array of master coprocessors
1144    * @see org.apache.hadoop.hbase.ClusterStatus#getMasterCoprocessors()
1145    */
1146   String[] getMasterCoprocessors() throws IOException;
1147 
1148   /**
1149    * Get the current compaction state of a table. It could be in a major compaction, a minor
1150    * compaction, both, or none.
1151    *
1152    * @param tableName table to examine
1153    * @return the current compaction state
1154    * @throws IOException if a remote or network exception occurs
1155    */
1156   AdminProtos.GetRegionInfoResponse.CompactionState getCompactionState(final TableName tableName)
1157     throws IOException;
1158 
1159   /**
1160    * Get the current compaction state of region. It could be in a major compaction, a minor
1161    * compaction, both, or none.
1162    *
1163    * @param regionName region to examine
1164    * @return the current compaction state
1165    * @throws IOException if a remote or network exception occurs
1166    */
1167   AdminProtos.GetRegionInfoResponse.CompactionState getCompactionStateForRegion(
1168     final byte[] regionName) throws IOException;
1169 
1170   /**
1171    * Get the timestamp of the last major compaction for the passed table
1172    *
1173    * The timestamp of the oldest HFile resulting from a major compaction of that table,
1174    * or 0 if no such HFile could be found.
1175    *
1176    * @param tableName table to examine
1177    * @return the last major compaction timestamp or 0
1178    * @throws IOException if a remote or network exception occurs
1179    */
1180   long getLastMajorCompactionTimestamp(final TableName tableName)
1181     throws IOException;
1182 
1183   /**
1184    * Get the timestamp of the last major compaction for the passed region.
1185    *
1186    * The timestamp of the oldest HFile resulting from a major compaction of that region,
1187    * or 0 if no such HFile could be found.
1188    *
1189    * @param regionName region to examine
1190    * @return the last major compaction timestamp or 0
1191    * @throws IOException if a remote or network exception occurs
1192    */
1193   long getLastMajorCompactionTimestampForRegion(final byte[] regionName)
1194       throws IOException;
1195 
1196   /**
1197    * Take a snapshot for the given table. If the table is enabled, a FLUSH-type snapshot will be
1198    * taken. If the table is disabled, an offline snapshot is taken. Snapshots are considered unique
1199    * based on <b>the name of the snapshot</b>. Attempts to take a snapshot with the same name (even
1200    * a different type or with different parameters) will fail with a {@link
1201    * org.apache.hadoop.hbase.snapshot.SnapshotCreationException} indicating the duplicate naming.
1202    * Snapshot names follow the same naming constraints as tables in HBase. See {@link
1203    * org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}.
1204    *
1205    * @param snapshotName name of the snapshot to be created
1206    * @param tableName name of the table for which snapshot is created
1207    * @throws IOException if a remote or network exception occurs
1208    * @throws org.apache.hadoop.hbase.snapshot.SnapshotCreationException if snapshot creation failed
1209    * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
1210    */
1211   void snapshot(final String snapshotName, final TableName tableName)
1212       throws IOException, SnapshotCreationException, IllegalArgumentException;
1213 
1214   /**
1215    * Create a timestamp consistent snapshot for the given table. Snapshots are considered unique
1216    * based on <b>the name of the snapshot</b>. Attempts to take a snapshot with the same name (even
1217    * different type or with different parameters) will fail with a {@link SnapshotCreationException}
1218    * indicating the duplicate naming. Snapshot names follow the same naming constraints as tables in
1219    * HBase.
1220    *
1221    * @param snapshotName name of the snapshot to be created
1222    * @param tableName name of the table for which snapshot is created
1223    * @throws IOException if a remote or network exception occurs
1224    * @throws SnapshotCreationException if snapshot creation failed
1225    * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
1226    */
1227   void snapshot(final byte[] snapshotName, final TableName tableName)
1228       throws IOException, SnapshotCreationException, IllegalArgumentException;
1229 
1230   /**
1231    * Create typed snapshot of the table. Snapshots are considered unique based on <b>the name of the
1232    * snapshot</b>. Attempts to take a snapshot with the same name (even a different type or with
1233    * different parameters) will fail with a {@link SnapshotCreationException} indicating the
1234    * duplicate naming. Snapshot names follow the same naming constraints as tables in HBase. See
1235    * {@link org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}.
1236    *
1237    * @param snapshotName name to give the snapshot on the filesystem. Must be unique from all other
1238    * snapshots stored on the cluster
1239    * @param tableName name of the table to snapshot
1240    * @param type type of snapshot to take
1241    * @throws IOException we fail to reach the master
1242    * @throws SnapshotCreationException if snapshot creation failed
1243    * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
1244    */
1245   void snapshot(final String snapshotName,
1246       final TableName tableName,
1247       HBaseProtos.SnapshotDescription.Type type) throws IOException, SnapshotCreationException,
1248       IllegalArgumentException;
1249 
1250   /**
1251    * Take a snapshot and wait for the server to complete that snapshot (blocking). Only a single
1252    * snapshot should be taken at a time for an instance of HBase, or results may be undefined (you
1253    * can tell multiple HBase clusters to snapshot at the same time, but only one at a time for a
1254    * single cluster). Snapshots are considered unique based on <b>the name of the snapshot</b>.
1255    * Attempts to take a snapshot with the same name (even a different type or with different
1256    * parameters) will fail with a {@link SnapshotCreationException} indicating the duplicate naming.
1257    * Snapshot names follow the same naming constraints as tables in HBase. See {@link
1258    * org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}. You should probably
1259    * use {@link #snapshot(String, org.apache.hadoop.hbase.TableName)} or
1260    * {@link #snapshot(byte[], org.apache.hadoop.hbase.TableName)} unless you are sure about the type
1261    * of snapshot that you want to take.
1262    *
1263    * @param snapshot snapshot to take
1264    * @throws IOException or we lose contact with the master.
1265    * @throws SnapshotCreationException if snapshot failed to be taken
1266    * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
1267    */
1268   void snapshot(HBaseProtos.SnapshotDescription snapshot)
1269       throws IOException, SnapshotCreationException, IllegalArgumentException;
1270 
1271   /**
1272    * Take a snapshot without waiting for the server to complete that snapshot (asynchronous) Only a
1273    * single snapshot should be taken at a time, or results may be undefined.
1274    *
1275    * @param snapshot snapshot to take
1276    * @return response from the server indicating the max time to wait for the snapshot
1277    * @throws IOException if the snapshot did not succeed or we lose contact with the master.
1278    * @throws SnapshotCreationException if snapshot creation failed
1279    * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
1280    */
1281   MasterProtos.SnapshotResponse takeSnapshotAsync(HBaseProtos.SnapshotDescription snapshot)
1282       throws IOException, SnapshotCreationException;
1283 
1284   /**
1285    * Check the current state of the passed snapshot. There are three possible states: <ol>
1286    * <li>running - returns <tt>false</tt></li> <li>finished - returns <tt>true</tt></li>
1287    * <li>finished with error - throws the exception that caused the snapshot to fail</li> </ol> The
1288    * cluster only knows about the most recent snapshot. Therefore, if another snapshot has been
1289    * run/started since the snapshot your are checking, you will recieve an {@link
1290    * org.apache.hadoop.hbase.snapshot.UnknownSnapshotException}.
1291    *
1292    * @param snapshot description of the snapshot to check
1293    * @return <tt>true</tt> if the snapshot is completed, <tt>false</tt> if the snapshot is still
1294    * running
1295    * @throws IOException if we have a network issue
1296    * @throws org.apache.hadoop.hbase.snapshot.HBaseSnapshotException if the snapshot failed
1297    * @throws org.apache.hadoop.hbase.snapshot.UnknownSnapshotException if the requested snapshot is
1298    * unknown
1299    */
1300   boolean isSnapshotFinished(final HBaseProtos.SnapshotDescription snapshot)
1301       throws IOException, HBaseSnapshotException, UnknownSnapshotException;
1302 
1303   /**
1304    * Restore the specified snapshot on the original table. (The table must be disabled) If the
1305    * "hbase.snapshot.restore.take.failsafe.snapshot" configuration property is set to true, a
1306    * snapshot of the current table is taken before executing the restore operation. In case of
1307    * restore failure, the failsafe snapshot will be restored. If the restore completes without
1308    * problem the failsafe snapshot is deleted.
1309    *
1310    * @param snapshotName name of the snapshot to restore
1311    * @throws IOException if a remote or network exception occurs
1312    * @throws org.apache.hadoop.hbase.snapshot.RestoreSnapshotException if snapshot failed to be
1313    * restored
1314    * @throws IllegalArgumentException if the restore request is formatted incorrectly
1315    */
1316   void restoreSnapshot(final byte[] snapshotName) throws IOException, RestoreSnapshotException;
1317 
1318   /**
1319    * Restore the specified snapshot on the original table. (The table must be disabled) If the
1320    * "hbase.snapshot.restore.take.failsafe.snapshot" configuration property is set to true, a
1321    * snapshot of the current table is taken before executing the restore operation. In case of
1322    * restore failure, the failsafe snapshot will be restored. If the restore completes without
1323    * problem the failsafe snapshot is deleted.
1324    *
1325    * @param snapshotName name of the snapshot to restore
1326    * @throws IOException if a remote or network exception occurs
1327    * @throws RestoreSnapshotException if snapshot failed to be restored
1328    * @throws IllegalArgumentException if the restore request is formatted incorrectly
1329    */
1330   void restoreSnapshot(final String snapshotName) throws IOException, RestoreSnapshotException;
1331 
1332   /**
1333    * Restore the specified snapshot on the original table. (The table must be disabled) If
1334    * 'takeFailSafeSnapshot' is set to true, a snapshot of the current table is taken before
1335    * executing the restore operation. In case of restore failure, the failsafe snapshot will be
1336    * restored. If the restore completes without problem the failsafe snapshot is deleted. The
1337    * failsafe snapshot name is configurable by using the property
1338    * "hbase.snapshot.restore.failsafe.name".
1339    *
1340    * @param snapshotName name of the snapshot to restore
1341    * @param takeFailSafeSnapshot true if the failsafe snapshot should be taken
1342    * @throws IOException if a remote or network exception occurs
1343    * @throws RestoreSnapshotException if snapshot failed to be restored
1344    * @throws IllegalArgumentException if the restore request is formatted incorrectly
1345    */
1346   void restoreSnapshot(final byte[] snapshotName, final boolean takeFailSafeSnapshot)
1347       throws IOException, RestoreSnapshotException;
1348 
1349   /**
1350    * Restore the specified snapshot on the original table. (The table must be disabled) If
1351    * 'takeFailSafeSnapshot' is set to true, a snapshot of the current table is taken before
1352    * executing the restore operation. In case of restore failure, the failsafe snapshot will be
1353    * restored. If the restore completes without problem the failsafe snapshot is deleted. The
1354    * failsafe snapshot name is configurable by using the property
1355    * "hbase.snapshot.restore.failsafe.name".
1356    *
1357    * @param snapshotName name of the snapshot to restore
1358    * @param takeFailSafeSnapshot true if the failsafe snapshot should be taken
1359    * @throws IOException if a remote or network exception occurs
1360    * @throws RestoreSnapshotException if snapshot failed to be restored
1361    * @throws IllegalArgumentException if the restore request is formatted incorrectly
1362    */
1363   void restoreSnapshot(final String snapshotName, boolean takeFailSafeSnapshot)
1364       throws IOException, RestoreSnapshotException;
1365 
1366   /**
1367    * Create a new table by cloning the snapshot content.
1368    *
1369    * @param snapshotName name of the snapshot to be cloned
1370    * @param tableName name of the table where the snapshot will be restored
1371    * @throws IOException if a remote or network exception occurs
1372    * @throws TableExistsException if table to be created already exists
1373    * @throws RestoreSnapshotException if snapshot failed to be cloned
1374    * @throws IllegalArgumentException if the specified table has not a valid name
1375    */
1376   void cloneSnapshot(final byte[] snapshotName, final TableName tableName)
1377       throws IOException, TableExistsException, RestoreSnapshotException;
1378 
1379   /**
1380    * Create a new table by cloning the snapshot content.
1381    *
1382    * @param snapshotName name of the snapshot to be cloned
1383    * @param tableName name of the table where the snapshot will be restored
1384    * @throws IOException if a remote or network exception occurs
1385    * @throws TableExistsException if table to be created already exists
1386    * @throws RestoreSnapshotException if snapshot failed to be cloned
1387    * @throws IllegalArgumentException if the specified table has not a valid name
1388    */
1389   void cloneSnapshot(final String snapshotName, final TableName tableName)
1390       throws IOException, TableExistsException, RestoreSnapshotException;
1391 
1392   /**
1393    * Execute a distributed procedure on a cluster.
1394    *
1395    * @param signature A distributed procedure is uniquely identified by its signature (default the
1396    * root ZK node name of the procedure).
1397    * @param instance The instance name of the procedure. For some procedures, this parameter is
1398    * optional.
1399    * @param props Property/Value pairs of properties passing to the procedure
1400    * @throws IOException
1401    */
1402   void execProcedure(String signature, String instance, Map<String, String> props)
1403       throws IOException;
1404 
1405   /**
1406    * Execute a distributed procedure on a cluster.
1407    *
1408    * @param signature A distributed procedure is uniquely identified by its signature (default the
1409    * root ZK node name of the procedure).
1410    * @param instance The instance name of the procedure. For some procedures, this parameter is
1411    * optional.
1412    * @param props Property/Value pairs of properties passing to the procedure
1413    * @return data returned after procedure execution. null if no return data.
1414    * @throws IOException
1415    */
1416   byte[] execProcedureWithRet(String signature, String instance, Map<String, String> props)
1417       throws IOException;
1418 
1419   /**
1420    * Check the current state of the specified procedure. There are three possible states: <ol>
1421    * <li>running - returns <tt>false</tt></li> <li>finished - returns <tt>true</tt></li>
1422    * <li>finished with error - throws the exception that caused the procedure to fail</li> </ol>
1423    *
1424    * @param signature The signature that uniquely identifies a procedure
1425    * @param instance The instance name of the procedure
1426    * @param props Property/Value pairs of properties passing to the procedure
1427    * @return true if the specified procedure is finished successfully, false if it is still running
1428    * @throws IOException if the specified procedure finished with error
1429    */
1430   boolean isProcedureFinished(String signature, String instance, Map<String, String> props)
1431       throws IOException;
1432 
1433   /**
1434    * List completed snapshots.
1435    *
1436    * @return a list of snapshot descriptors for completed snapshots
1437    * @throws IOException if a network error occurs
1438    */
1439   List<HBaseProtos.SnapshotDescription> listSnapshots() throws IOException;
1440 
1441   /**
1442    * List all the completed snapshots matching the given regular expression.
1443    *
1444    * @param regex The regular expression to match against
1445    * @return - returns a List of SnapshotDescription
1446    * @throws IOException if a remote or network exception occurs
1447    */
1448   List<HBaseProtos.SnapshotDescription> listSnapshots(String regex) throws IOException;
1449 
1450   /**
1451    * List all the completed snapshots matching the given pattern.
1452    *
1453    * @param pattern The compiled regular expression to match against
1454    * @return - returns a List of SnapshotDescription
1455    * @throws IOException if a remote or network exception occurs
1456    */
1457   List<HBaseProtos.SnapshotDescription> listSnapshots(Pattern pattern) throws IOException;
1458 
1459   /**
1460    * List all the completed snapshots matching the given table name regular expression and snapshot
1461    * name regular expression.
1462    * @param tableNameRegex The table name regular expression to match against
1463    * @param snapshotNameRegex The snapshot name regular expression to match against
1464    * @return - returns a List of completed SnapshotDescription
1465    * @throws IOException if a remote or network exception occurs
1466    */
1467   List<HBaseProtos.SnapshotDescription> listTableSnapshots(String tableNameRegex,
1468       String snapshotNameRegex) throws IOException;
1469 
1470   /**
1471    * List all the completed snapshots matching the given table name regular expression and snapshot
1472    * name regular expression.
1473    * @param tableNamePattern The compiled table name regular expression to match against
1474    * @param snapshotNamePattern The compiled snapshot name regular expression to match against
1475    * @return - returns a List of completed SnapshotDescription
1476    * @throws IOException if a remote or network exception occurs
1477    */
1478   List<HBaseProtos.SnapshotDescription> listTableSnapshots(Pattern tableNamePattern,
1479       Pattern snapshotNamePattern) throws IOException;
1480 
1481   /**
1482    * Delete an existing snapshot.
1483    *
1484    * @param snapshotName name of the snapshot
1485    * @throws IOException if a remote or network exception occurs
1486    */
1487   void deleteSnapshot(final byte[] snapshotName) throws IOException;
1488 
1489   /**
1490    * Delete an existing snapshot.
1491    *
1492    * @param snapshotName name of the snapshot
1493    * @throws IOException if a remote or network exception occurs
1494    */
1495   void deleteSnapshot(final String snapshotName) throws IOException;
1496 
1497   /**
1498    * Delete existing snapshots whose names match the pattern passed.
1499    *
1500    * @param regex The regular expression to match against
1501    * @throws IOException if a remote or network exception occurs
1502    */
1503   void deleteSnapshots(final String regex) throws IOException;
1504 
1505   /**
1506    * Delete existing snapshots whose names match the pattern passed.
1507    *
1508    * @param pattern pattern for names of the snapshot to match
1509    * @throws IOException if a remote or network exception occurs
1510    */
1511   void deleteSnapshots(final Pattern pattern) throws IOException;
1512 
1513   /**
1514    * Delete all existing snapshots matching the given table name regular expression and snapshot
1515    * name regular expression.
1516    * @param tableNameRegex The table name regular expression to match against
1517    * @param snapshotNameRegex The snapshot name regular expression to match against
1518    * @throws IOException if a remote or network exception occurs
1519    */
1520   void deleteTableSnapshots(String tableNameRegex, String snapshotNameRegex) throws IOException;
1521 
1522   /**
1523    * Delete all existing snapshots matching the given table name regular expression and snapshot
1524    * name regular expression.
1525    * @param tableNamePattern The compiled table name regular expression to match against
1526    * @param snapshotNamePattern The compiled snapshot name regular expression to match against
1527    * @throws IOException if a remote or network exception occurs
1528    */
1529   void deleteTableSnapshots(Pattern tableNamePattern, Pattern snapshotNamePattern)
1530       throws IOException;
1531 
1532   /**
1533    * Apply the new quota settings.
1534    *
1535    * @param quota the quota settings
1536    * @throws IOException if a remote or network exception occurs
1537    */
1538   void setQuota(final QuotaSettings quota) throws IOException;
1539 
1540   /**
1541    * Return a QuotaRetriever to list the quotas based on the filter.
1542    *
1543    * @param filter the quota settings filter
1544    * @return the quota retriever
1545    * @throws IOException if a remote or network exception occurs
1546    */
1547   QuotaRetriever getQuotaRetriever(final QuotaFilter filter) throws IOException;
1548 
1549   /**
1550    * Creates and returns a {@link com.google.protobuf.RpcChannel} instance connected to the active
1551    * master. <p> The obtained {@link com.google.protobuf.RpcChannel} instance can be used to access
1552    * a published coprocessor {@link com.google.protobuf.Service} using standard protobuf service
1553    * invocations: </p> <div style="background-color: #cccccc; padding: 2px">
1554    * <blockquote><pre>
1555    * CoprocessorRpcChannel channel = myAdmin.coprocessorService();
1556    * MyService.BlockingInterface service = MyService.newBlockingStub(channel);
1557    * MyCallRequest request = MyCallRequest.newBuilder()
1558    *     ...
1559    *     .build();
1560    * MyCallResponse response = service.myCall(null, request);
1561    * </pre></blockquote></div>
1562    *
1563    * @return A MasterCoprocessorRpcChannel instance
1564    */
1565   CoprocessorRpcChannel coprocessorService();
1566 
1567 
1568   /**
1569    * Creates and returns a {@link com.google.protobuf.RpcChannel} instance
1570    * connected to the passed region server.
1571    *
1572    * <p>
1573    * The obtained {@link com.google.protobuf.RpcChannel} instance can be used to access a published
1574    * coprocessor {@link com.google.protobuf.Service} using standard protobuf service invocations:
1575    * </p>
1576    *
1577    * <div style="background-color: #cccccc; padding: 2px">
1578    * <blockquote><pre>
1579    * CoprocessorRpcChannel channel = myAdmin.coprocessorService(serverName);
1580    * MyService.BlockingInterface service = MyService.newBlockingStub(channel);
1581    * MyCallRequest request = MyCallRequest.newBuilder()
1582    *     ...
1583    *     .build();
1584    * MyCallResponse response = service.myCall(null, request);
1585    * </pre></blockquote></div>
1586    *
1587    * @param sn the server name to which the endpoint call is made
1588    * @return A RegionServerCoprocessorRpcChannel instance
1589    */
1590   CoprocessorRpcChannel coprocessorService(ServerName sn);
1591 
1592 
1593   /**
1594    * Update the configuration and trigger an online config change
1595    * on the regionserver
1596    * @param server : The server whose config needs to be updated.
1597    * @throws IOException
1598    */
1599   void updateConfiguration(ServerName server) throws IOException;
1600 
1601 
1602   /**
1603    * Update the configuration and trigger an online config change
1604    * on all the regionservers
1605    * @throws IOException
1606    */
1607   void updateConfiguration() throws IOException;
1608 
1609   /**
1610    * Get the info port of the current master if one is available.
1611    * @return master info port
1612    * @throws IOException
1613    */
1614   public int getMasterInfoPort() throws IOException;
1615 
1616   /**
1617    * Compact a table. Asynchronous operation.
1618    *
1619    * @param tableName table to compact
1620    * @param compactType {@link org.apache.hadoop.hbase.client.Admin.CompactType}
1621    * @throws IOException
1622    * @throws InterruptedException
1623    */
1624   void compact(final TableName tableName, CompactType compactType)
1625     throws IOException, InterruptedException;
1626 
1627   /**
1628    * Compact a column family within a table. Asynchronous operation.
1629    *
1630    * @param tableName table to compact
1631    * @param columnFamily column family within a table
1632    * @param compactType {@link org.apache.hadoop.hbase.client.Admin.CompactType}
1633    * @throws IOException if not a mob column family or if a remote or network exception occurs
1634    * @throws InterruptedException
1635    */
1636   void compact(final TableName tableName, final byte[] columnFamily, CompactType compactType)
1637     throws IOException, InterruptedException;
1638 
1639   /**
1640    * Major compact a table. Asynchronous operation.
1641    *
1642    * @param tableName table to compact
1643    * @param compactType {@link org.apache.hadoop.hbase.client.Admin.CompactType}
1644    * @throws IOException
1645    * @throws InterruptedException
1646    */
1647   void majorCompact(final TableName tableName, CompactType compactType)
1648     throws IOException, InterruptedException;
1649 
1650   /**
1651    * Major compact a column family within a table. Asynchronous operation.
1652    *
1653    * @param tableName table to compact
1654    * @param columnFamily column family within a table
1655    * @param compactType {@link org.apache.hadoop.hbase.client.Admin.CompactType}
1656    * @throws IOException if not a mob column family or if a remote or network exception occurs
1657    * @throws InterruptedException
1658    */
1659   void majorCompact(final TableName tableName, final byte[] columnFamily, CompactType compactType)
1660     throws IOException, InterruptedException;
1661 
1662   /**
1663    * Get the current compaction state of a table. It could be in a compaction, or none.
1664    *
1665    * @param tableName table to examine
1666    * @param compactType {@link org.apache.hadoop.hbase.client.Admin.CompactType}
1667    * @return the current compaction state
1668    * @throws IOException if a remote or network exception occurs
1669    */
1670   AdminProtos.GetRegionInfoResponse.CompactionState getCompactionState(final TableName tableName,
1671     CompactType compactType) throws IOException;
1672 
1673   /**
1674    * Return the set of supported security capabilities.
1675    * @throws IOException
1676    * @throws UnsupportedOperationException
1677    */
1678   List<SecurityCapability> getSecurityCapabilities() throws IOException;
1679 
1680   /**
1681    * Currently, there are only two compact types:
1682    * {@code NORMAL} means do store files compaction;
1683    * {@code MOB} means do mob files compaction.
1684    * */
1685 
1686   @InterfaceAudience.Public
1687   @InterfaceStability.Unstable
1688   public enum CompactType {
1689 
1690     NORMAL    (0),
1691     MOB       (1);
1692 
1693     CompactType(int value) {}
1694   }
1695 }