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