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