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