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