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