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