001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.client;
019
020import java.io.Closeable;
021import java.io.IOException;
022import java.util.Collection;
023import java.util.EnumSet;
024import java.util.List;
025import java.util.Map;
026import java.util.Set;
027import java.util.concurrent.Future;
028import java.util.regex.Pattern;
029import org.apache.hadoop.conf.Configuration;
030import org.apache.hadoop.hbase.Abortable;
031import org.apache.hadoop.hbase.CacheEvictionStats;
032import org.apache.hadoop.hbase.ClusterMetrics;
033import org.apache.hadoop.hbase.ClusterMetrics.Option;
034import org.apache.hadoop.hbase.ClusterStatus;
035import org.apache.hadoop.hbase.HRegionInfo;
036import org.apache.hadoop.hbase.HTableDescriptor;
037import org.apache.hadoop.hbase.NamespaceDescriptor;
038import org.apache.hadoop.hbase.NamespaceNotFoundException;
039import org.apache.hadoop.hbase.RegionMetrics;
040import org.apache.hadoop.hbase.ServerName;
041import org.apache.hadoop.hbase.TableExistsException;
042import org.apache.hadoop.hbase.TableName;
043import org.apache.hadoop.hbase.TableNotFoundException;
044import org.apache.hadoop.hbase.client.replication.TableCFs;
045import org.apache.hadoop.hbase.client.security.SecurityCapability;
046import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
047import org.apache.hadoop.hbase.quotas.QuotaFilter;
048import org.apache.hadoop.hbase.quotas.QuotaRetriever;
049import org.apache.hadoop.hbase.quotas.QuotaSettings;
050import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshotView;
051import org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException;
052import org.apache.hadoop.hbase.replication.ReplicationException;
053import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
054import org.apache.hadoop.hbase.replication.ReplicationPeerDescription;
055import org.apache.hadoop.hbase.security.access.GetUserPermissionsRequest;
056import org.apache.hadoop.hbase.security.access.Permission;
057import org.apache.hadoop.hbase.security.access.UserPermission;
058import org.apache.hadoop.hbase.snapshot.HBaseSnapshotException;
059import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException;
060import org.apache.hadoop.hbase.snapshot.SnapshotCreationException;
061import org.apache.hadoop.hbase.snapshot.UnknownSnapshotException;
062import org.apache.hadoop.hbase.util.Bytes;
063import org.apache.hadoop.hbase.util.Pair;
064import org.apache.yetus.audience.InterfaceAudience;
065
066/**
067 * The administrative API for HBase. Obtain an instance from {@link Connection#getAdmin()} and
068 * call {@link #close()} when done.
069 * <p>Admin can be used to create, drop, list, enable and disable and otherwise modify tables,
070 * as well as perform other administrative operations.
071 *
072 * @see ConnectionFactory
073 * @see Connection
074 * @see Table
075 * @since 0.99.0
076 */
077@InterfaceAudience.Public
078public interface Admin extends Abortable, Closeable {
079  int getOperationTimeout();
080
081  @Override
082  void abort(String why, Throwable e);
083
084  @Override
085  boolean isAborted();
086
087  /**
088   * @return Connection used by this object.
089   */
090  Connection getConnection();
091
092  /**
093   * @param tableName Table to check.
094   * @return <code>true</code> if table exists already.
095   * @throws IOException
096   */
097  boolean tableExists(TableName tableName) throws IOException;
098
099  /**
100   * List all the userspace tables.
101   *
102   * @return an array of read-only HTableDescriptors
103   * @throws IOException if a remote or network exception occurs
104   * @deprecated since 2.0 version and will be removed in 3.0 version.
105   *             Use {@link #listTableDescriptors()}.
106   * @see #listTableDescriptors()
107   */
108  @Deprecated
109  HTableDescriptor[] listTables() throws IOException;
110
111  /**
112   * List all the userspace tables.
113   *
114   * @return a list of TableDescriptors
115   * @throws IOException if a remote or network exception occurs
116   */
117  List<TableDescriptor> listTableDescriptors() throws IOException;
118
119  /**
120   * List all the userspace tables that match the given pattern.
121   *
122   * @param pattern The compiled regular expression to match against
123   * @return an array of read-only HTableDescriptors
124   * @throws IOException if a remote or network exception occurs
125   * @see #listTables()
126   * @deprecated since 2.0 version and will be removed in 3.0 version.
127   *             Use {@link #listTableDescriptors(java.util.regex.Pattern)}.
128   * @see #listTableDescriptors(Pattern)
129   */
130  @Deprecated
131  HTableDescriptor[] listTables(Pattern pattern) throws IOException;
132
133  /**
134   * List all the userspace tables that match the given pattern.
135   *
136   * @param pattern The compiled regular expression to match against
137   * @return a list of TableDescriptors
138   * @throws IOException if a remote or network exception occurs
139   * @see #listTables()
140   */
141  List<TableDescriptor> listTableDescriptors(Pattern pattern) throws IOException;
142
143  /**
144   * List all the userspace tables matching the given regular expression.
145   *
146   * @param regex The regular expression to match against
147   * @return a list of read-only HTableDescriptors
148   * @throws IOException if a remote or network exception occurs
149   * @see #listTableDescriptors(Pattern)
150   * @deprecated since 2.0 version and will be removed in 3.0 version. Use
151   *             {@link #listTableDescriptors(Pattern)} instead.
152   */
153  @Deprecated
154  HTableDescriptor[] listTables(String regex) throws IOException;
155
156  /**
157   * List all the tables matching the given pattern.
158   *
159   * @param pattern The compiled regular expression to match against
160   * @param includeSysTables <code>false</code> to match only against userspace tables
161   * @return an array of read-only HTableDescriptors
162   * @throws IOException if a remote or network exception occurs
163   * @see #listTables()
164   * @deprecated since 2.0 version and will be removed in 3.0 version.
165   *             Use {@link #listTableDescriptors(java.util.regex.Pattern, boolean)}.
166   * @see #listTableDescriptors(java.util.regex.Pattern, boolean)
167   */
168  @Deprecated
169  HTableDescriptor[] listTables(Pattern pattern, boolean includeSysTables)
170      throws IOException;
171
172  /**
173   * List all the tables matching the given pattern.
174   *
175   * @param pattern The compiled regular expression to match against
176   * @param includeSysTables <code>false</code> to match only against userspace tables
177   * @return a list of TableDescriptors
178   * @throws IOException if a remote or network exception occurs
179   * @see #listTables()
180   */
181  List<TableDescriptor> listTableDescriptors(Pattern pattern, boolean includeSysTables)
182      throws IOException;
183
184  /**
185   * List all the tables matching the given pattern.
186   *
187   * @param regex The regular expression to match against
188   * @param includeSysTables <code>false</code> to match only against userspace tables
189   * @return an array of read-only HTableDescriptors
190   * @throws IOException if a remote or network exception occurs
191   * @see #listTables(java.util.regex.Pattern, boolean)
192   * @deprecated since 2.0 version and will be removed in 3.0 version.
193   *             Use {@link #listTableDescriptors(Pattern, boolean)}.
194   */
195  @Deprecated
196  HTableDescriptor[] listTables(String regex, boolean includeSysTables)
197      throws IOException;
198
199  /**
200   * List all of the names of userspace tables.
201   *
202   * @return TableName[] table names
203   * @throws IOException if a remote or network exception occurs
204   */
205  TableName[] listTableNames() throws IOException;
206
207  /**
208   * List all of the names of userspace tables.
209   * @param pattern The regular expression to match against
210   * @return array of table names
211   * @throws IOException if a remote or network exception occurs
212   */
213  TableName[] listTableNames(Pattern pattern) throws IOException;
214
215  /**
216   * List all of the names of userspace tables.
217   * @param regex The regular expression to match against
218   * @return TableName[] table names
219   * @throws IOException if a remote or network exception occurs
220   * @deprecated since 2.0 version and will be removed in 3.0 version. Use
221   *             {@link #listTableNames(Pattern)} instead.
222   */
223  @Deprecated
224  TableName[] listTableNames(String regex) throws IOException;
225
226  /**
227   * List all of the names of userspace tables.
228   * @param pattern The regular expression to match against
229   * @param includeSysTables <code>false</code> to match only against userspace tables
230   * @return TableName[] table names
231   * @throws IOException if a remote or network exception occurs
232   */
233  TableName[] listTableNames(Pattern pattern, boolean includeSysTables)
234      throws IOException;
235
236  /**
237   * List all of the names of userspace tables.
238   * @param regex The regular expression to match against
239   * @param includeSysTables <code>false</code> to match only against userspace tables
240   * @return TableName[] table names
241   * @throws IOException if a remote or network exception occurs
242   * @deprecated since 2.0 version and will be removed in 3.0 version. Use
243   *             {@link #listTableNames(Pattern, boolean)} instead.
244   */
245  @Deprecated
246  TableName[] listTableNames(String regex, boolean includeSysTables)
247      throws IOException;
248
249  /**
250   * Get a table descriptor.
251   *
252   * @param tableName as a {@link TableName}
253   * @return the read-only tableDescriptor
254   * @throws org.apache.hadoop.hbase.TableNotFoundException
255   * @throws IOException if a remote or network exception occurs
256   * @deprecated since 2.0 version and will be removed in 3.0 version.
257   *             Use {@link #getDescriptor(TableName)}.
258   */
259  @Deprecated
260  HTableDescriptor getTableDescriptor(TableName tableName)
261      throws TableNotFoundException, IOException;
262
263  /**
264   * Get a table descriptor.
265   *
266   * @param tableName as a {@link TableName}
267   * @return the tableDescriptor
268   * @throws org.apache.hadoop.hbase.TableNotFoundException
269   * @throws IOException if a remote or network exception occurs
270   */
271  TableDescriptor getDescriptor(TableName tableName)
272      throws TableNotFoundException, IOException;
273
274  /**
275   * Creates a new table. Synchronous operation.
276   *
277   * @param desc table descriptor for table
278   * @throws IllegalArgumentException if the table name is reserved
279   * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running
280   * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent
281   * threads, the table may have been created between test-for-existence and attempt-at-creation).
282   * @throws IOException if a remote or network exception occurs
283   */
284  void createTable(TableDescriptor desc) throws IOException;
285
286  /**
287   * Creates a new table with the specified number of regions.  The start key specified will become
288   * the end key of the first region of the table, and the end key specified will become the start
289   * key of the last region of the table (the first region has a null start key and the last region
290   * has a null end key). BigInteger math will be used to divide the key range specified into enough
291   * segments to make the required number of total regions. Synchronous operation.
292   *
293   * @param desc table descriptor for table
294   * @param startKey beginning of key range
295   * @param endKey end of key range
296   * @param numRegions the total number of regions to create
297   * @throws IllegalArgumentException if the table name is reserved
298   * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running
299   * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent
300   * threads, the table may have been created between test-for-existence and attempt-at-creation).
301   */
302  void createTable(TableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions)
303      throws IOException;
304
305  /**
306   * Creates a new table with an initial set of empty regions defined by the specified split keys.
307   * The total number of regions created will be the number of split keys plus one. Synchronous
308   * operation. Note : Avoid passing empty split key.
309   *
310   * @param desc table descriptor for table
311   * @param splitKeys array of split keys for the initial regions of the table
312   * @throws IllegalArgumentException if the table name is reserved, if the split keys are repeated
313   * and if the split key has empty byte array.
314   * @throws org.apache.hadoop.hbase.MasterNotRunningException if master is not running
315   * @throws org.apache.hadoop.hbase.TableExistsException if table already exists (If concurrent
316   * threads, the table may have been created between test-for-existence and attempt-at-creation).
317   * @throws IOException
318   */
319  void createTable(TableDescriptor desc, byte[][] splitKeys) throws IOException;
320
321  /**
322   * Creates a new table but does not block and wait for it to come online. You can use
323   * Future.get(long, TimeUnit) to wait on the operation to complete. It may throw
324   * ExecutionException if there was an error while executing the operation or TimeoutException in
325   * case the wait timeout was not long enough to allow the operation to complete.
326   * <p/>
327   * Throws IllegalArgumentException Bad table name, if the split keys are repeated and if the split
328   * key has empty byte array.
329   * @param desc table descriptor for table
330   * @throws IOException if a remote or network exception occurs
331   * @return the result of the async creation. You can use Future.get(long, TimeUnit) to wait on the
332   *         operation to complete.
333   */
334  Future<Void> createTableAsync(TableDescriptor desc) throws IOException;
335
336  /**
337   * Creates a new table but does not block and wait for it to come online. You can use
338   * Future.get(long, TimeUnit) to wait on the operation to complete. It may throw
339   * ExecutionException if there was an error while executing the operation or TimeoutException in
340   * case the wait timeout was not long enough to allow the operation to complete.
341   * <p/>
342   * Throws IllegalArgumentException Bad table name, if the split keys are repeated and if the split
343   * key has empty byte array.
344   * @param desc table descriptor for table
345   * @param splitKeys keys to check if the table has been created with all split keys
346   * @throws IOException if a remote or network exception occurs
347   * @return the result of the async creation. You can use Future.get(long, TimeUnit) to wait on the
348   *         operation to complete.
349   */
350  Future<Void> createTableAsync(TableDescriptor desc, byte[][] splitKeys) throws IOException;
351
352  /**
353   * Deletes a table. Synchronous operation.
354   *
355   * @param tableName name of table to delete
356   * @throws IOException if a remote or network exception occurs
357   */
358  void deleteTable(TableName tableName) throws IOException;
359
360  /**
361   * Deletes the table but does not block and wait for it to be completely removed.
362   * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
363   * It may throw ExecutionException if there was an error while executing the operation
364   * or TimeoutException in case the wait timeout was not long enough to allow the
365   * operation to complete.
366   *
367   * @param tableName name of table to delete
368   * @throws IOException if a remote or network exception occurs
369   * @return the result of the async delete. You can use Future.get(long, TimeUnit)
370   *    to wait on the operation to complete.
371   */
372  Future<Void> deleteTableAsync(TableName tableName) throws IOException;
373
374  /**
375   * Deletes tables matching the passed in pattern and wait on completion. Warning: Use this method
376   * carefully, there is no prompting and the effect is immediate. Consider using {@link
377   * #listTableDescriptors(Pattern)}
378   * and {@link #deleteTable(org.apache.hadoop.hbase.TableName)}
379   *
380   * @param regex The regular expression to match table names against
381   * @return Table descriptors for tables that couldn't be deleted.
382   *         The return htds are read-only
383   * @throws IOException
384   * @see #deleteTables(java.util.regex.Pattern)
385   * @see #deleteTable(org.apache.hadoop.hbase.TableName)
386   * @deprecated since 2.0 version and will be removed in 3.0 version
387   *             This is just a trivial helper method without any magic.
388   *             Consider using {@link #listTableDescriptors(Pattern)}
389   *             and {@link #deleteTable(TableName)}
390   */
391  @Deprecated
392  HTableDescriptor[] deleteTables(String regex) throws IOException;
393
394  /**
395   * Delete tables matching the passed in pattern and wait on completion. Warning: Use this method
396   * carefully, there is no prompting and the effect is immediate. Consider using {@link
397   * #listTableDescriptors(java.util.regex.Pattern)} and
398   * {@link #deleteTable(org.apache.hadoop.hbase.TableName)}
399   *
400   * @param pattern The pattern to match table names against
401   * @return Table descriptors for tables that couldn't be deleted
402   *         The return htds are read-only
403   * @throws IOException
404   * @deprecated since 2.0 version and will be removed in 3.0 version
405   *             This is just a trivial helper method without any magic.
406   *             Consider using {@link #listTableDescriptors(java.util.regex.Pattern)}
407   *             and {@link #deleteTable(TableName)}
408   */
409  @Deprecated
410  HTableDescriptor[] deleteTables(Pattern pattern) throws IOException;
411
412  /**
413   * Truncate a table.
414   * Synchronous operation.
415   *
416   * @param tableName name of table to truncate
417   * @param preserveSplits <code>true</code> if the splits should be preserved
418   * @throws IOException if a remote or network exception occurs
419   */
420  void truncateTable(TableName tableName, boolean preserveSplits)
421      throws IOException;
422
423  /**
424   * Truncate the table but does not block and wait for it to be completely enabled. You can use
425   * Future.get(long, TimeUnit) to wait on the operation to complete. It may throw
426   * ExecutionException if there was an error while executing the operation or TimeoutException in
427   * case the wait timeout was not long enough to allow the operation to complete.
428   * @param tableName name of table to delete
429   * @param preserveSplits <code>true</code> if the splits should be preserved
430   * @throws IOException if a remote or network exception occurs
431   * @return the result of the async truncate. You can use Future.get(long, TimeUnit) to wait on the
432   *         operation to complete.
433   */
434  Future<Void> truncateTableAsync(TableName tableName, boolean preserveSplits)
435      throws IOException;
436
437  /**
438   * Enable a table.  May timeout.  Use {@link #enableTableAsync(org.apache.hadoop.hbase.TableName)}
439   * and {@link #isTableEnabled(org.apache.hadoop.hbase.TableName)} instead. The table has to be in
440   * disabled state for it to be enabled.
441   *
442   * @param tableName name of the table
443   * @throws IOException if a remote or network exception occurs There could be couple types of
444   * IOException TableNotFoundException means the table doesn't exist. TableNotDisabledException
445   * means the table isn't in disabled state.
446   * @see #isTableEnabled(org.apache.hadoop.hbase.TableName)
447   * @see #disableTable(org.apache.hadoop.hbase.TableName)
448   * @see #enableTableAsync(org.apache.hadoop.hbase.TableName)
449   */
450  void enableTable(TableName tableName) throws IOException;
451
452  /**
453   * Enable the table but does not block and wait for it to be completely enabled.
454   * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
455   * It may throw ExecutionException if there was an error while executing the operation
456   * or TimeoutException in case the wait timeout was not long enough to allow the
457   * operation to complete.
458   *
459   * @param tableName name of table to delete
460   * @throws IOException if a remote or network exception occurs
461   * @return the result of the async enable. You can use Future.get(long, TimeUnit)
462   *    to wait on the operation to complete.
463   */
464  Future<Void> enableTableAsync(TableName tableName) throws IOException;
465
466  /**
467   * Enable tables matching the passed in pattern and wait on completion. Warning: Use this method
468   * carefully, there is no prompting and the effect is immediate. Consider using {@link
469   * #listTableDescriptors(Pattern)} and {@link #enableTable(org.apache.hadoop.hbase.TableName)}
470   *
471   * @param regex The regular expression to match table names against
472   * @throws IOException
473   * @return Table descriptors for tables that couldn't be enabled.
474   *         The return HTDs are read-only.
475   * @see #enableTables(java.util.regex.Pattern)
476   * @see #enableTable(org.apache.hadoop.hbase.TableName)
477   * @deprecated since 2.0 version and will be removed in 3.0 version
478   *             This is just a trivial helper method without any magic.
479   *             Consider using {@link #listTableDescriptors(Pattern)}
480   *             and {@link #enableTable(org.apache.hadoop.hbase.TableName)}
481   */
482  @Deprecated
483  HTableDescriptor[] enableTables(String regex) throws IOException;
484
485  /**
486   * Enable tables matching the passed in pattern and wait on completion. Warning: Use this method
487   * carefully, there is no prompting and the effect is immediate. Consider using {@link
488   * #listTableDescriptors(java.util.regex.Pattern)} and
489   * {@link #enableTable(org.apache.hadoop.hbase.TableName)}
490   *
491   * @param pattern The pattern to match table names against
492   * @throws IOException
493   * @return Table descriptors for tables that couldn't be enabled.
494   *         The return HTDs are read-only.
495   * @deprecated since 2.0 version and will be removed in 3.0 version
496   *             This is just a trivial helper method without any magic.
497   *             Consider using {@link #listTableDescriptors(java.util.regex.Pattern)}
498   *             and {@link #enableTable(org.apache.hadoop.hbase.TableName)}
499   */
500  @Deprecated
501  HTableDescriptor[] enableTables(Pattern pattern) throws IOException;
502
503  /**
504   * Disable the table but does not block and wait for it to be completely disabled.
505   * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
506   * It may throw ExecutionException if there was an error while executing the operation
507   * or TimeoutException in case the wait timeout was not long enough to allow the
508   * operation to complete.
509   *
510   * @param tableName name of table to delete
511   * @throws IOException if a remote or network exception occurs
512   * @return the result of the async disable. You can use Future.get(long, TimeUnit)
513   *    to wait on the operation to complete.
514   */
515  Future<Void> disableTableAsync(TableName tableName) throws IOException;
516
517  /**
518   * Disable table and wait on completion.  May timeout eventually.  Use {@link
519   * #disableTableAsync(org.apache.hadoop.hbase.TableName)} and
520   * {@link #isTableDisabled(org.apache.hadoop.hbase.TableName)} instead. The table has to be in
521   * enabled state for it to be disabled.
522   *
523   * @param tableName
524   * @throws IOException There could be couple types of IOException TableNotFoundException means the
525   * table doesn't exist. TableNotEnabledException means the table isn't in enabled state.
526   */
527  void disableTable(TableName tableName) throws IOException;
528
529  /**
530   * Disable tables matching the passed in pattern and wait on completion. Warning: Use this method
531   * carefully, there is no prompting and the effect is immediate. Consider using {@link
532   * #listTableDescriptors(Pattern)} and {@link #disableTable(org.apache.hadoop.hbase.TableName)}
533   *
534   * @param regex The regular expression to match table names against
535   * @return Table descriptors for tables that couldn't be disabled
536   *         The return htds are read-only
537   * @throws IOException
538   * @see #disableTables(java.util.regex.Pattern)
539   * @see #disableTable(org.apache.hadoop.hbase.TableName)
540   * @deprecated since 2.0 version and will be removed in 3.0 version
541   *             This is just a trivial helper method without any magic.
542   *             Consider using {@link #listTableDescriptors(Pattern)}
543   *             and {@link #disableTable(org.apache.hadoop.hbase.TableName)}
544   */
545  @Deprecated
546  HTableDescriptor[] disableTables(String regex) throws IOException;
547
548  /**
549   * Disable tables matching the passed in pattern and wait on completion. Warning: Use this method
550   * carefully, there is no prompting and the effect is immediate. Consider using {@link
551   * #listTableDescriptors(java.util.regex.Pattern)} and
552   * {@link #disableTable(org.apache.hadoop.hbase.TableName)}
553   *
554   * @param pattern The pattern to match table names against
555   * @return Table descriptors for tables that couldn't be disabled
556   *         The return htds are read-only
557   * @throws IOException
558   * @deprecated since 2.0 version and will be removed in 3.0 version
559   *             This is just a trivial helper method without any magic.
560   *             Consider using {@link #listTableDescriptors(java.util.regex.Pattern)}
561   *             and {@link #disableTable(org.apache.hadoop.hbase.TableName)}
562   */
563  @Deprecated
564  HTableDescriptor[] disableTables(Pattern pattern) throws IOException;
565
566  /**
567   * @param tableName name of table to check
568   * @return <code>true</code> if table is on-line
569   * @throws IOException if a remote or network exception occurs
570   */
571  boolean isTableEnabled(TableName tableName) throws IOException;
572
573  /**
574   * @param tableName name of table to check
575   * @return <code>true</code> if table is off-line
576   * @throws IOException if a remote or network exception occurs
577   */
578  boolean isTableDisabled(TableName tableName) throws IOException;
579
580  /**
581   * @param tableName name of table to check
582   * @return <code>true</code> if all regions of the table are available
583   * @throws IOException if a remote or network exception occurs
584   */
585  boolean isTableAvailable(TableName tableName) throws IOException;
586
587  /**
588   * Use this api to check if the table has been created with the specified number of splitkeys
589   * which was used while creating the given table. Note : If this api is used after a table's
590   * region gets splitted, the api may return <code>false</code>.
591   *
592   * @param tableName name of table to check
593   * @param splitKeys keys to check if the table has been created with all split keys
594   * @throws IOException if a remote or network excpetion occurs
595   * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #isTableAvailable(TableName)}
596   */
597  @Deprecated
598  boolean isTableAvailable(TableName tableName, byte[][] splitKeys) throws IOException;
599
600  /**
601   * Get the status of an <code>alter</code> (a.k.a <code>modify</code>) command - indicates how
602   * many regions have received the updated schema Asynchronous operation.
603   *
604   * @param tableName TableName instance
605   * @return Pair indicating the number of regions updated Pair.getFirst() is the regions that are
606   * yet to be updated Pair.getSecond() is the total number of regions of the table
607   * @throws IOException if a remote or network exception occurs
608   * @deprecated Since 2.0.0. Will be removed in 3.0.0. No longer needed now you get a Future
609   * on an operation.
610   */
611  @Deprecated
612  Pair<Integer, Integer> getAlterStatus(TableName tableName) throws IOException;
613
614  /**
615   * Get the status of <code>alter</code> (a.k.a <code>modify</code>) command - indicates how many
616   * regions have received the updated schema Asynchronous operation.
617   *
618   * @param tableName name of the table to get the status of
619   * @return Pair indicating the number of regions updated Pair.getFirst() is the regions that are
620   * yet to be updated Pair.getSecond() is the total number of regions of the table
621   * @throws IOException if a remote or network exception occurs
622   * @deprecated Since 2.0.0. Will be removed in 3.0.0. No longer needed now you get a Future
623   * on an operation.
624   */
625  @Deprecated
626  Pair<Integer, Integer> getAlterStatus(byte[] tableName) throws IOException;
627
628  /**
629   * Add a column family to an existing table. Synchronous operation.
630   * Use {@link #addColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it
631   * returns a {@link Future} from which you can learn whether success or failure.
632   *
633   * @param tableName name of the table to add column family to
634   * @param columnFamily column family descriptor of column family to be added
635   * @throws IOException if a remote or network exception occurs
636   * @deprecated As of release 2.0.0.
637   *             This will be removed in HBase 3.0.0.
638   *             Use {@link #addColumnFamily(TableName, ColumnFamilyDescriptor)}.
639   */
640  @Deprecated
641  default void addColumn(TableName tableName, ColumnFamilyDescriptor columnFamily)
642    throws IOException {
643    addColumnFamily(tableName, columnFamily);
644  }
645
646  /**
647   * Add a column family to an existing table. Synchronous operation.
648   * Use {@link #addColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it
649   * returns a {@link Future} from which you can learn whether success or failure.
650   *
651   * @param tableName name of the table to add column family to
652   * @param columnFamily column family descriptor of column family to be added
653   * @throws IOException if a remote or network exception occurs
654   */
655  void addColumnFamily(TableName tableName, ColumnFamilyDescriptor columnFamily)
656    throws IOException;
657
658  /**
659   * Add a column family to an existing table. Asynchronous operation.
660   * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
661   * It may throw ExecutionException if there was an error while executing the operation
662   * or TimeoutException in case the wait timeout was not long enough to allow the
663   * operation to complete.
664   *
665   * @param tableName name of the table to add column family to
666   * @param columnFamily column family descriptor of column family to be added
667   * @throws IOException if a remote or network exception occurs
668   * @return the result of the async add column family. You can use Future.get(long, TimeUnit) to
669   *         wait on the operation to complete.
670   */
671  Future<Void> addColumnFamilyAsync(TableName tableName, ColumnFamilyDescriptor columnFamily)
672      throws IOException;
673
674  /**
675   * Delete a column family from a table. Synchronous operation.
676   *  Use {@link #deleteColumnFamily(TableName, byte[])} instead because it
677   * returns a {@link Future} from which you can learn whether success or failure.
678   *
679   * @param tableName name of table
680   * @param columnFamily name of column family to be deleted
681   * @throws IOException if a remote or network exception occurs
682   * @deprecated As of release 2.0.0.
683   *             This will be removed in HBase 3.0.0.
684   *             Use {@link #deleteColumnFamily(TableName, byte[])}}.
685   */
686  @Deprecated
687  void deleteColumn(TableName tableName, byte[] columnFamily) throws IOException;
688
689  /**
690   * Delete a column family from a table. Synchronous operation.
691   * Use {@link #deleteColumnFamily(TableName, byte[])} instead because it
692   * returns a {@link Future} from which you can learn whether success or failure.
693   * @param tableName name of table
694   * @param columnFamily name of column family to be deleted
695   * @throws IOException if a remote or network exception occurs
696   */
697  void deleteColumnFamily(TableName tableName, byte[] columnFamily) throws IOException;
698
699  /**
700   * Delete a column family from a table. Asynchronous operation.
701   * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
702   * It may throw ExecutionException if there was an error while executing the operation
703   * or TimeoutException in case the wait timeout was not long enough to allow the
704   * operation to complete.
705   *
706   * @param tableName name of table
707   * @param columnFamily name of column family to be deleted
708   * @throws IOException if a remote or network exception occurs
709   * @return the result of the async delete column family. You can use Future.get(long, TimeUnit) to
710   *         wait on the operation to complete.
711   */
712  Future<Void> deleteColumnFamilyAsync(TableName tableName, byte[] columnFamily)
713      throws IOException;
714
715  /**
716   * Modify an existing column family on a table. Synchronous operation.
717   * Use {@link #modifyColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it
718   * returns a {@link Future} from which you can learn whether success or failure.
719   * @param tableName name of table
720   * @param columnFamily new column family descriptor to use
721   * @throws IOException if a remote or network exception occurs
722   * @deprecated As of release 2.0.0.
723   *             This will be removed in HBase 3.0.0.
724   *             Use {@link #modifyColumnFamily(TableName, ColumnFamilyDescriptor)}.
725   */
726  @Deprecated
727  default void modifyColumn(TableName tableName, ColumnFamilyDescriptor columnFamily)
728      throws IOException {
729    modifyColumnFamily(tableName, columnFamily);
730  }
731
732  /**
733   * Modify an existing column family on a table. Synchronous operation.
734   * Use {@link #modifyColumnFamilyAsync(TableName, ColumnFamilyDescriptor)} instead because it
735   * returns a {@link Future} from which you can learn whether success or failure.
736   * @param tableName name of table
737   * @param columnFamily new column family descriptor to use
738   * @throws IOException if a remote or network exception occurs
739   */
740  void modifyColumnFamily(TableName tableName, ColumnFamilyDescriptor columnFamily)
741      throws IOException;
742
743  /**
744   * Modify an existing column family on a table. Asynchronous operation.
745   * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
746   * It may throw ExecutionException if there was an error while executing the operation
747   * or TimeoutException in case the wait timeout was not long enough to allow the
748   * operation to complete.
749   *
750   * @param tableName name of table
751   * @param columnFamily new column family descriptor to use
752   * @throws IOException if a remote or network exception occurs
753   * @return the result of the async modify column family. You can use Future.get(long, TimeUnit) to
754   *         wait on the operation to complete.
755   */
756  Future<Void> modifyColumnFamilyAsync(TableName tableName, ColumnFamilyDescriptor columnFamily)
757      throws IOException;
758
759  /**
760   * Uses {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins.
761   *
762   * @param regionname region name to close
763   * @param serverName Deprecated. Not used.
764   * @throws IOException if a remote or network exception occurs
765   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
766   *             Use {@link #unassign(byte[], boolean)}.
767   */
768  @Deprecated
769  void closeRegion(String regionname, String serverName) throws IOException;
770
771  /**
772   * Uses {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins.
773   *
774   * @param regionname region name to close
775   * @param serverName Deprecated. Not used.
776   * @throws IOException if a remote or network exception occurs
777   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
778   *             Use {@link #unassign(byte[], boolean)}.
779   */
780  @Deprecated
781  void closeRegion(byte[] regionname, String serverName) throws IOException;
782
783  /**
784   * Uses {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins.
785   *
786   * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name
787   * suffix: e.g. if regionname is
788   * <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>,
789   * then the encoded region name is: <code>527db22f95c8a9e0116f0cc13c680396</code>.
790   * @param serverName Deprecated. Not used.
791   * @return Deprecated. Returns <code>true</code> always.
792   * @throws IOException if a remote or network exception occurs
793   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
794   *             Use {@link #unassign(byte[], boolean)}.
795   */
796  @Deprecated
797  boolean closeRegionWithEncodedRegionName(String encodedRegionName, String serverName)
798      throws IOException;
799
800  /**
801   * Used {@link #unassign(byte[], boolean)} to unassign the region. For expert-admins.
802   *
803   * @param sn Deprecated. Not used.
804   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
805   *             (<a href="https://issues.apache.org/jira/browse/HBASE-18231">HBASE-18231</a>).
806   *             Use {@link #unassign(byte[], boolean)}.
807   */
808  @Deprecated
809  void closeRegion(final ServerName sn, final HRegionInfo hri) throws IOException;
810
811  /**
812   * Get all the online regions on a region server.
813   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
814   *             (<a href="https://issues.apache.org/jira/browse/HBASE-17980">HBASE-17980</a>).
815   *             Use {@link #getRegions(ServerName sn)}.
816   */
817  @Deprecated
818  List<HRegionInfo> getOnlineRegions(ServerName sn) throws IOException;
819
820  /**
821   * Get all the online regions on a region server.
822   *
823   * @return List of {@link RegionInfo}
824   * @throws java.io.IOException
825   */
826  List<RegionInfo> getRegions(ServerName serverName) throws IOException;
827
828  /**
829   * Flush a table. Synchronous operation.
830   *
831   * @param tableName table to flush
832   * @throws IOException if a remote or network exception occurs
833   */
834  void flush(TableName tableName) throws IOException;
835
836  /**
837   * Flush an individual region. Synchronous operation.
838   *
839   * @param regionName region to flush
840   * @throws IOException if a remote or network exception occurs
841   */
842  void flushRegion(byte[] regionName) throws IOException;
843
844  /**
845   * Flush all regions on the region server. Synchronous operation.
846   * @param serverName the region server name to flush
847   * @throws IOException if a remote or network exception occurs
848   */
849  void flushRegionServer(ServerName serverName) throws IOException;
850
851  /**
852   * Compact a table. Asynchronous operation in that this method requests that a
853   * Compaction run and then it returns. It does not wait on the completion of Compaction
854   * (it can take a while).
855   *
856   * @param tableName table to compact
857   * @throws IOException if a remote or network exception occurs
858   */
859  void compact(TableName tableName) throws IOException;
860
861  /**
862   * Compact an individual region. Asynchronous operation in that this method requests that a
863   * Compaction run and then it returns. It does not wait on the completion of Compaction
864   * (it can take a while).
865   *
866   * @param regionName region to compact
867   * @throws IOException if a remote or network exception occurs
868   */
869  void compactRegion(byte[] regionName) throws IOException;
870
871  /**
872   * Compact a column family within a table. Asynchronous operation in that this method requests
873   * that a Compaction run and then it returns. It does not wait on the completion of Compaction
874   * (it can take a while).
875   *
876   * @param tableName table to compact
877   * @param columnFamily column family within a table
878   * @throws IOException if a remote or network exception occurs
879   */
880  void compact(TableName tableName, byte[] columnFamily)
881    throws IOException;
882
883  /**
884   * Compact a column family within a region. Asynchronous operation in that this method requests
885   * that a Compaction run and then it returns. It does not wait on the completion of Compaction
886   * (it can take a while).
887   *
888   * @param regionName region to compact
889   * @param columnFamily column family within a region
890   * @throws IOException if a remote or network exception occurs
891   */
892  void compactRegion(byte[] regionName, byte[] columnFamily)
893    throws IOException;
894
895  /**
896   * Compact a table.  Asynchronous operation in that this method requests that a
897   * Compaction run and then it returns. It does not wait on the completion of Compaction
898   * (it can take a while).
899   *
900   * @param tableName table to compact
901   * @param compactType {@link org.apache.hadoop.hbase.client.CompactType}
902   * @throws IOException if a remote or network exception occurs
903   * @throws InterruptedException
904   */
905  void compact(TableName tableName, CompactType compactType)
906    throws IOException, InterruptedException;
907
908  /**
909   * Compact a column family within a table.  Asynchronous operation in that this method
910   * requests that a Compaction run and then it returns. It does not wait on the
911   * completion of Compaction (it can take a while).
912   *
913   * @param tableName table to compact
914   * @param columnFamily column family within a table
915   * @param compactType {@link org.apache.hadoop.hbase.client.CompactType}
916   * @throws IOException if not a mob column family or if a remote or network exception occurs
917   * @throws InterruptedException
918   */
919  void compact(TableName tableName, byte[] columnFamily, CompactType compactType)
920    throws IOException, InterruptedException;
921
922  /**
923   * Major compact a table. Asynchronous operation in that this method requests
924   * that a Compaction run and then it returns. It does not wait on the completion of Compaction
925   * (it can take a while).
926   *
927   * @param tableName table to major compact
928   * @throws IOException if a remote or network exception occurs
929   */
930  void majorCompact(TableName tableName) throws IOException;
931
932  /**
933   * Major compact a table or an individual region. Asynchronous operation in that this method requests
934   * that a Compaction run and then it returns. It does not wait on the completion of Compaction
935   * (it can take a while).
936   *
937   * @param regionName region to major compact
938   * @throws IOException if a remote or network exception occurs
939   */
940  void majorCompactRegion(byte[] regionName) throws IOException;
941
942  /**
943   * Major compact a column family within a table. Asynchronous operation in that this method requests
944   * that a Compaction run and then it returns. It does not wait on the completion of Compaction
945   * (it can take a while).
946   *
947   * @param tableName table to major compact
948   * @param columnFamily column family within a table
949   * @throws IOException if a remote or network exception occurs
950   */
951  void majorCompact(TableName tableName, byte[] columnFamily)
952    throws IOException;
953
954  /**
955   * Major compact a column family within region. Asynchronous operation in that this method requests
956   * that a Compaction run and then it returns. It does not wait on the completion of Compaction
957   * (it can take a while).
958   *
959   * @param regionName egion to major compact
960   * @param columnFamily column family within a region
961   * @throws IOException if a remote or network exception occurs
962   */
963  void majorCompactRegion(byte[] regionName, byte[] columnFamily)
964    throws IOException;
965
966  /**
967   * Major compact a table.  Asynchronous operation in that this method requests that a
968   * Compaction run and then it returns. It does not wait on the completion of Compaction
969   * (it can take a while).
970   *
971   * @param tableName table to compact
972   * @param compactType {@link org.apache.hadoop.hbase.client.CompactType}
973   * @throws IOException if a remote or network exception occurs
974   * @throws InterruptedException
975   */
976  void majorCompact(TableName tableName, CompactType compactType)
977    throws IOException, InterruptedException;
978
979  /**
980   * Major compact a column family within a table.  Asynchronous operation in that this method requests that a
981   * Compaction run and then it returns. It does not wait on the completion of Compaction
982   * (it can take a while).
983   *
984   * @param tableName table to compact
985   * @param columnFamily column family within a table
986   * @param compactType {@link org.apache.hadoop.hbase.client.CompactType}
987   * @throws IOException if not a mob column family or if a remote or network exception occurs
988   * @throws InterruptedException
989   */
990  void majorCompact(TableName tableName, byte[] columnFamily, CompactType compactType)
991    throws IOException, InterruptedException;
992
993  /**
994   * Compact all regions on the region server. Asynchronous operation in that this method requests
995   * that a Compaction run and then it returns. It does not wait on the completion of Compaction (it
996   * can take a while).
997   * @param sn the region server name
998   * @param major if it's major compaction
999   * @throws IOException if a remote or network exception occurs
1000   * @throws InterruptedException
1001   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. Use
1002   *             {@link #compactRegionServer(ServerName)} or
1003   *             {@link #majorCompactRegionServer(ServerName)}.
1004   */
1005  @Deprecated
1006  default void compactRegionServer(ServerName sn, boolean major) throws IOException,
1007      InterruptedException {
1008    if (major) {
1009      majorCompactRegionServer(sn);
1010    } else {
1011      compactRegionServer(sn);
1012    }
1013  }
1014
1015  /**
1016   * Turn the compaction on or off. Disabling compactions will also interrupt any currently ongoing
1017   * compactions. This state is ephemeral. The setting will be lost on restart. Compaction
1018   * can also be enabled/disabled by modifying configuration hbase.regionserver.compaction.enabled
1019   * in hbase-site.xml.
1020   *
1021   * @param switchState     Set to <code>true</code> to enable, <code>false</code> to disable.
1022   * @param serverNamesList list of region servers.
1023   * @return Previous compaction states for region servers
1024   */
1025  Map<ServerName, Boolean> compactionSwitch(boolean switchState, List<String> serverNamesList)
1026      throws IOException;
1027
1028  /**
1029   * Compact all regions on the region server. Asynchronous operation in that this method requests
1030   * that a Compaction run and then it returns. It does not wait on the completion of Compaction (it
1031   * can take a while).
1032   * @param serverName the region server name
1033   * @throws IOException if a remote or network exception occurs
1034   */
1035  void compactRegionServer(ServerName serverName) throws IOException;
1036
1037  /**
1038   * Major compact all regions on the region server. Asynchronous operation in that this method
1039   * requests that a Compaction run and then it returns. It does not wait on the completion of
1040   * Compaction (it can take a while).
1041   * @param serverName the region server name
1042   * @throws IOException if a remote or network exception occurs
1043   */
1044  void majorCompactRegionServer(ServerName serverName) throws IOException;
1045
1046  /**
1047   * Move the region <code>encodedRegionName</code> to a random server.
1048   * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name
1049   *          suffix: e.g. if regionname is
1050   *          <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>,
1051   *          then the encoded region name is: <code>527db22f95c8a9e0116f0cc13c680396</code>.
1052   * @throws IOException if we can't find a region named <code>encodedRegionName</code>
1053   */
1054  void move(byte[] encodedRegionName) throws IOException;
1055
1056  /**
1057   * Move the region <code>rencodedRegionName</code> to <code>destServerName</code>.
1058   * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name
1059   *          suffix: e.g. if regionname is
1060   *          <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>,
1061   *          then the encoded region name is: <code>527db22f95c8a9e0116f0cc13c680396</code>.
1062   * @param destServerName The servername of the destination regionserver. If passed the empty byte
1063   *          array we'll assign to a random server. A server name is made of host, port and
1064   *          startcode. Here is an example: <code> host187.example.com,60020,1289493121758</code>
1065   * @throws IOException if we can't find a region named <code>encodedRegionName</code>
1066   * @deprecated since 2.2.0 and will be removed in 4.0.0. Use {@link #move(byte[], ServerName)}
1067   *   instead. And if you want to move the region to a random server, please use
1068   *   {@link #move(byte[])}.
1069   * @see <a href="https://issues.apache.org/jira/browse/HBASE-22108">HBASE-22108</a>
1070   */
1071  @Deprecated
1072  default void move(byte[] encodedRegionName, byte[] destServerName) throws IOException {
1073    if (destServerName == null || destServerName.length == 0) {
1074      move(encodedRegionName);
1075    } else {
1076      move(encodedRegionName, ServerName.valueOf(Bytes.toString(destServerName)));
1077    }
1078  }
1079
1080  /**
1081   * Move the region <code>rencodedRegionName</code> to <code>destServerName</code>.
1082   * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name
1083   *          suffix: e.g. if regionname is
1084   *          <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>,
1085   *          then the encoded region name is: <code>527db22f95c8a9e0116f0cc13c680396</code>.
1086   * @param destServerName The servername of the destination regionserver. A server name is made of
1087   *          host, port and startcode. Here is an example:
1088   *          <code> host187.example.com,60020,1289493121758</code>
1089   * @throws IOException if we can't find a region named <code>encodedRegionName</code>
1090   */
1091  void move(byte[] encodedRegionName, ServerName destServerName) throws IOException;
1092
1093  /**
1094   * Assign a Region.
1095   * @param regionName Region name to assign.
1096   */
1097  void assign(byte[] regionName) throws IOException;
1098
1099  /**
1100   * Unassign a region from current hosting regionserver.  Region will then be assigned to a
1101   * regionserver chosen at random.  Region could be reassigned back to the same server.  Use {@link
1102   * #move(byte[], ServerName)} if you want to control the region movement.
1103   *
1104   * @param regionName Region to unassign. Will clear any existing RegionPlan if one found.
1105   * @param force If <code>true</code>, force unassign (Will remove region from regions-in-transition too if
1106   * present. If results in double assignment use hbck -fix to resolve. To be used by experts).
1107   */
1108  void unassign(byte[] regionName, boolean force)
1109      throws IOException;
1110
1111  /**
1112   * Offline specified region from master's in-memory state. It will not attempt to reassign the
1113   * region as in unassign. This API can be used when a region not served by any region server and
1114   * still online as per Master's in memory state. If this API is incorrectly used on active region
1115   * then master will loose track of that region. This is a special method that should be used by
1116   * experts or hbck.
1117   *
1118   * @param regionName Region to offline.
1119   * @throws IOException
1120   */
1121  void offline(byte[] regionName) throws IOException;
1122
1123  /**
1124   * Turn the load balancer on or off.
1125   *
1126   * @param synchronous If <code>true</code>, it waits until current balance() call, if
1127   * outstanding, to return.
1128   * @return Previous balancer value
1129   * @deprecated Since 2.0.0. Will be removed in 3.0.0.
1130   * Use {@link #balancerSwitch(boolean, boolean)} instead.
1131   */
1132  @Deprecated
1133  default boolean setBalancerRunning(boolean on, boolean synchronous) throws IOException {
1134    return balancerSwitch(on, synchronous);
1135  }
1136
1137  /**
1138   * Turn the load balancer on or off.
1139   * @param onOrOff Set to <code>true</code> to enable, <code>false</code> to disable.
1140   * @param synchronous If <code>true</code>, it waits until current balance() call, if
1141   * outstanding, to return.
1142   * @return Previous balancer value
1143   */
1144  boolean balancerSwitch(boolean onOrOff, boolean synchronous)
1145  throws IOException;
1146
1147  /**
1148   * Invoke the balancer.  Will run the balancer and if regions to move, it will go ahead and do the
1149   * reassignments.  Can NOT run for various reasons.  Check logs.
1150   *
1151   * @return <code>true</code> if balancer ran, <code>false</code> otherwise.
1152   * @deprecated Since 2.0.0. Will be removed in 3.0.0.
1153   * Use {@link #balance()} instead.
1154   */
1155  @Deprecated
1156  default boolean balancer() throws IOException {
1157    return balance();
1158  }
1159
1160  /**
1161   * Invoke the balancer.  Will run the balancer and if regions to move, it will go ahead and do the
1162   * reassignments.  Can NOT run for various reasons.  Check logs.
1163   *
1164   * @return <code>true</code> if balancer ran, <code>false</code> otherwise.
1165   */
1166  boolean balance() throws IOException;
1167
1168  /**
1169   * Invoke the balancer.  Will run the balancer and if regions to move, it will
1170   * go ahead and do the reassignments. If there is region in transition, force parameter of true
1171   * would still run balancer. Can *not* run for other reasons.  Check
1172   * logs.
1173   * @param force whether we should force balance even if there is region in transition
1174   * @return <code>true</code> if balancer ran, <code>false</code> otherwise.
1175   * @deprecated Since 2.0.0. Will be removed in 3.0.0.
1176   * Use {@link #balance(boolean)} instead.
1177   */
1178  @Deprecated
1179  default boolean balancer(boolean force) throws IOException {
1180    return balance(force);
1181  }
1182
1183  /**
1184   * Invoke the balancer.  Will run the balancer and if regions to move, it will
1185   * go ahead and do the reassignments. If there is region in transition, force parameter of true
1186   * would still run balancer. Can *not* run for other reasons.  Check
1187   * logs.
1188   * @param force whether we should force balance even if there is region in transition
1189   * @return <code>true</code> if balancer ran, <code>false</code> otherwise.
1190   */
1191  boolean balance(boolean force) throws IOException;
1192
1193  /**
1194   * Query the current state of the balancer.
1195   *
1196   * @return <code>true</code> if the balancer is enabled, <code>false</code> otherwise.
1197   */
1198  boolean isBalancerEnabled() throws IOException;
1199
1200  /**
1201   * Clear all the blocks corresponding to this table from BlockCache. For expert-admins.
1202   * Calling this API will drop all the cached blocks specific to a table from BlockCache.
1203   * This can significantly impact the query performance as the subsequent queries will
1204   * have to retrieve the blocks from underlying filesystem.
1205   *
1206   * @param tableName table to clear block cache
1207   * @return CacheEvictionStats related to the eviction
1208   * @throws IOException if a remote or network exception occurs
1209   */
1210  CacheEvictionStats clearBlockCache(final TableName tableName) throws IOException;
1211
1212  /**
1213   * Invoke region normalizer. Can NOT run for various reasons.  Check logs.
1214   *
1215   * @return <code>true</code> if region normalizer ran, <code>false</code> otherwise.
1216   */
1217  boolean normalize() throws IOException;
1218
1219  /**
1220   * Query the current state of the region normalizer.
1221   *
1222   * @return <code>true</code> if region normalizer is enabled, <code>false</code> otherwise.
1223   */
1224  boolean isNormalizerEnabled() throws IOException;
1225
1226  /**
1227   * Turn region normalizer on or off.
1228   *
1229   * @return Previous normalizer value
1230   * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #normalizerSwitch(boolean)}}
1231   * instead.
1232   */
1233  @Deprecated
1234  default boolean setNormalizerRunning(boolean on) throws IOException {
1235    return normalizerSwitch(on);
1236  }
1237
1238  /**
1239   * Turn region normalizer on or off.
1240   *
1241   * @return Previous normalizer value
1242   */
1243  boolean normalizerSwitch (boolean on) throws IOException;
1244
1245  /**
1246   * Enable/Disable the catalog janitor.
1247   *
1248   * @param enable if <code>true</code> enables the catalog janitor
1249   * @return the previous state
1250   * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #catalogJanitorSwitch(boolean)}}
1251   * instead.
1252   */
1253  @Deprecated
1254  default boolean enableCatalogJanitor(boolean enable) throws IOException {
1255    return catalogJanitorSwitch(enable);
1256  }
1257
1258  /**
1259   * Enable/Disable the catalog janitor/
1260   *
1261   * @param onOrOff if <code>true</code> enables the catalog janitor
1262   * @return the previous state
1263   */
1264  boolean catalogJanitorSwitch(boolean onOrOff) throws IOException;
1265
1266  /**
1267   * Ask for a scan of the catalog table.
1268   *
1269   * @return the number of entries cleaned
1270   * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #runCatalogJanitor()}}
1271   * instead.
1272   */
1273  @Deprecated
1274  default int runCatalogScan() throws IOException {
1275    return runCatalogJanitor();
1276  }
1277
1278  /**
1279   * Ask for a scan of the catalog table.
1280   *
1281   * @return the number of entries cleaned
1282   */
1283  int runCatalogJanitor() throws IOException;
1284
1285  /**
1286   * Query on the catalog janitor state (Enabled/Disabled?).
1287   *
1288   */
1289  boolean isCatalogJanitorEnabled() throws IOException;
1290
1291  /**
1292   * Enable/Disable the cleaner chore.
1293   *
1294   * @param on if <code>true</code> enables the cleaner chore
1295   * @return the previous state
1296   * @throws IOException
1297   * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #cleanerChoreSwitch(boolean)}}
1298   * instead.
1299   */
1300  @Deprecated
1301  default boolean setCleanerChoreRunning(boolean on) throws IOException {
1302    return cleanerChoreSwitch(on);
1303  }
1304
1305  /**
1306   * Enable/Disable the cleaner chore.
1307   *
1308   * @param onOrOff if <code>true</code> enables the cleaner chore
1309   * @return the previous state
1310   * @throws IOException
1311   */
1312  boolean cleanerChoreSwitch(boolean onOrOff) throws IOException;
1313
1314  /**
1315   * Ask for cleaner chore to run.
1316   *
1317   * @return <code>true</code> if cleaner chore ran, <code>false</code> otherwise
1318   * @throws IOException
1319   */
1320  boolean runCleanerChore() throws IOException;
1321
1322  /**
1323   * Query on the cleaner chore state (Enabled/Disabled?).
1324   *
1325   * @throws IOException
1326   */
1327  boolean isCleanerChoreEnabled() throws IOException;
1328
1329  /**
1330   * Merge two regions. Asynchronous operation.
1331   *
1332   * @param nameOfRegionA encoded or full name of region a
1333   * @param nameOfRegionB encoded or full name of region b
1334   * @param forcible <code>true</code> if do a compulsory merge, otherwise we will only merge two
1335   * adjacent regions
1336   * @throws IOException
1337   * @deprecated Since 2.0. Will be removed in 3.0. Use
1338   *     {@link #mergeRegionsAsync(byte[], byte[], boolean)} instead.
1339   */
1340  @Deprecated
1341  void mergeRegions(byte[] nameOfRegionA, byte[] nameOfRegionB,
1342      boolean forcible) throws IOException;
1343
1344
1345  /**
1346   * Merge two regions. Asynchronous operation.
1347   * @param nameOfRegionA encoded or full name of region a
1348   * @param nameOfRegionB encoded or full name of region b
1349   * @param forcible <code>true</code> if do a compulsory merge, otherwise we will only merge two
1350   *          adjacent regions
1351   */
1352  default Future<Void> mergeRegionsAsync(byte[] nameOfRegionA, byte[] nameOfRegionB,
1353      boolean forcible) throws IOException {
1354    byte[][] nameofRegionsToMerge = new byte[2][];
1355    nameofRegionsToMerge[0] = nameOfRegionA;
1356    nameofRegionsToMerge[1] = nameOfRegionB;
1357    return mergeRegionsAsync(nameofRegionsToMerge, forcible);
1358  }
1359
1360  /**
1361   * Merge multiple regions (>=2). Asynchronous operation.
1362   * @param nameofRegionsToMerge encoded or full name of daughter regions
1363   * @param forcible <code>true</code> if do a compulsory merge, otherwise we will only merge
1364   *          adjacent regions
1365   */
1366  Future<Void> mergeRegionsAsync(byte[][] nameofRegionsToMerge, boolean forcible)
1367      throws IOException;
1368
1369  /**
1370   * Split a table. The method will execute split action for each region in table.
1371   * Asynchronous operation.
1372   * @param tableName table to split
1373   * @throws IOException if a remote or network exception occurs
1374   */
1375  void split(TableName tableName) throws IOException;
1376
1377  /**
1378   * Split an individual region. Asynchronous operation.
1379   *
1380   * @param regionName region to split
1381   * @throws IOException if a remote or network exception occurs
1382   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
1383   *             Use {@link #splitRegionAsync(byte[], byte[])}.
1384   */
1385  @Deprecated
1386  void splitRegion(byte[] regionName) throws IOException;
1387
1388  /**
1389   * Split a table. Asynchronous operation.
1390   *
1391   * @param tableName table to split
1392   * @param splitPoint the explicit position to split on
1393   * @throws IOException if a remote or network exception occurs
1394   */
1395  void split(TableName tableName, byte[] splitPoint)
1396    throws IOException;
1397
1398  /**
1399   * Split an individual region. Asynchronous operation.
1400   *
1401   * @param regionName region to split
1402   * @param splitPoint the explicit position to split on
1403   * @throws IOException if a remote or network exception occurs
1404   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
1405   *             Use {@link #splitRegionAsync(byte[], byte[])}.
1406   */
1407  @Deprecated
1408  void splitRegion(byte[] regionName, byte[] splitPoint)
1409    throws IOException;
1410
1411  /**
1412   * Split an individual region. Asynchronous operation.
1413   * @param regionName region to split
1414   * @throws IOException if a remote or network exception occurs
1415   */
1416  Future<Void> splitRegionAsync(byte[] regionName) throws IOException;
1417
1418  /**
1419   * Split an individual region. Asynchronous operation.
1420   * @param regionName region to split
1421   * @param splitPoint the explicit position to split on
1422   * @throws IOException if a remote or network exception occurs
1423   */
1424  Future<Void> splitRegionAsync(byte[] regionName, byte[] splitPoint)
1425    throws IOException;
1426
1427  /**
1428   * Modify an existing table, more IRB friendly version.
1429   *
1430   * @param tableName name of table.
1431   * @param td modified description of the table
1432   * @throws IOException if a remote or network exception occurs
1433   * @deprecated since 2.0 version and will be removed in 3.0 version.
1434   *             use {@link #modifyTable(TableDescriptor)}
1435   */
1436  @Deprecated
1437  void modifyTable(TableName tableName, TableDescriptor td)
1438      throws IOException;
1439
1440  /**
1441   * Modify an existing table, more IRB friendly version.
1442   * @param td modified description of the table
1443   * @throws IOException if a remote or network exception occurs
1444   */
1445  void modifyTable(TableDescriptor td) throws IOException;
1446
1447  /**
1448   * Modify an existing table, more IRB friendly version. Asynchronous operation.  This means that
1449   * it may be a while before your schema change is updated across all of the table.
1450   * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
1451   * It may throw ExecutionException if there was an error while executing the operation
1452   * or TimeoutException in case the wait timeout was not long enough to allow the
1453   * operation to complete.
1454   *
1455   * @param tableName name of table.
1456   * @param td modified description of the table
1457   * @throws IOException if a remote or network exception occurs
1458   * @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the
1459   *     operation to complete
1460   * @deprecated since 2.0 version and will be removed in 3.0 version.
1461   *             use {@link #modifyTableAsync(TableDescriptor)}
1462   */
1463  @Deprecated
1464  Future<Void> modifyTableAsync(TableName tableName, TableDescriptor td)
1465      throws IOException;
1466
1467  /**
1468   * Modify an existing table, more IRB (ruby) friendly version. Asynchronous operation. This means that
1469   * it may be a while before your schema change is updated across all of the table.
1470   * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
1471   * It may throw ExecutionException if there was an error while executing the operation
1472   * or TimeoutException in case the wait timeout was not long enough to allow the
1473   * operation to complete.
1474   *
1475   * @param td description of the table
1476   * @throws IOException if a remote or network exception occurs
1477   * @return the result of the async modify. You can use Future.get(long, TimeUnit) to wait on the
1478   *     operation to complete
1479   */
1480  Future<Void> modifyTableAsync(TableDescriptor td)
1481      throws IOException;
1482
1483  /**
1484   * <p>
1485   * Shuts down the HBase cluster.
1486   * </p>
1487   * <p>
1488   * Notice that, a success shutdown call may ends with an error since the remote server has already
1489   * been shutdown.
1490   * </p>
1491   * @throws IOException if a remote or network exception occurs
1492   */
1493  void shutdown() throws IOException;
1494
1495  /**
1496   * <p>
1497   * Shuts down the current HBase master only. Does not shutdown the cluster.
1498   * </p>
1499   * <p>
1500   * Notice that, a success stopMaster call may ends with an error since the remote server has
1501   * already been shutdown.
1502   * </p>
1503   * @throws IOException if a remote or network exception occurs
1504   * @see #shutdown()
1505   */
1506  void stopMaster() throws IOException;
1507
1508  /**
1509   * Check whether Master is in maintenance mode.
1510   *
1511   * @throws IOException if a remote or network exception occurs
1512   */
1513  boolean isMasterInMaintenanceMode()  throws IOException;
1514
1515  /**
1516   * Stop the designated regionserver.
1517   *
1518   * @param hostnamePort Hostname and port delimited by a <code>:</code> as in
1519   * <code>example.org:1234</code>
1520   * @throws IOException if a remote or network exception occurs
1521   */
1522  void stopRegionServer(String hostnamePort) throws IOException;
1523
1524  /**
1525   * Get whole cluster status, containing status about:
1526   * <pre>
1527   * hbase version
1528   * cluster id
1529   * primary/backup master(s)
1530   * master's coprocessors
1531   * live/dead regionservers
1532   * balancer
1533   * regions in transition
1534   * </pre>
1535   * @return cluster status
1536   * @throws IOException if a remote or network exception occurs
1537   * @deprecated since 2.0 version and will be removed in 3.0 version.
1538   *             use {@link #getClusterMetrics()}
1539   */
1540  @Deprecated
1541  default ClusterStatus getClusterStatus() throws IOException {
1542    return new ClusterStatus(getClusterMetrics());
1543  }
1544
1545  /**
1546   * Get whole cluster metrics, containing status about:
1547   * <pre>
1548   * hbase version
1549   * cluster id
1550   * primary/backup master(s)
1551   * master's coprocessors
1552   * live/dead regionservers
1553   * balancer
1554   * regions in transition
1555   * </pre>
1556   * @return cluster metrics
1557   * @throws IOException if a remote or network exception occurs
1558   */
1559  default ClusterMetrics getClusterMetrics() throws IOException {
1560    return getClusterMetrics(EnumSet.allOf(ClusterMetrics.Option.class));
1561  }
1562
1563  /**
1564   * Get cluster status with a set of {@link Option} to get desired status.
1565   * @return cluster status
1566   * @throws IOException if a remote or network exception occurs
1567   */
1568  ClusterMetrics getClusterMetrics(EnumSet<Option> options) throws IOException;
1569
1570  /**
1571   * @return current master server name
1572   * @throws IOException if a remote or network exception occurs
1573   */
1574  default ServerName getMaster() throws IOException {
1575    return getClusterMetrics(EnumSet.of(Option.MASTER)).getMasterName();
1576  }
1577
1578  /**
1579   * @return current backup master list
1580   * @throws IOException if a remote or network exception occurs
1581   */
1582  default Collection<ServerName> getBackupMasters() throws IOException {
1583    return getClusterMetrics(EnumSet.of(Option.BACKUP_MASTERS)).getBackupMasterNames();
1584  }
1585
1586  /**
1587   * @return current live region servers list
1588   * @throws IOException if a remote or network exception occurs
1589   */
1590  default Collection<ServerName> getRegionServers() throws IOException {
1591    return getClusterMetrics(EnumSet.of(Option.SERVERS_NAME)).getServersName();
1592  }
1593
1594  /**
1595   * Get {@link RegionMetrics} of all regions hosted on a regionserver.
1596   *
1597   * @param serverName region server from which {@link RegionMetrics} is required.
1598   * @return a {@link RegionMetrics} list of all regions hosted on a region server
1599   * @throws IOException if a remote or network exception occurs
1600   */
1601  default List<RegionMetrics> getRegionMetrics(ServerName serverName) throws IOException {
1602    return getRegionMetrics(serverName, null);
1603  }
1604
1605  /**
1606   * Get {@link RegionMetrics} of all regions hosted on a regionserver for a table.
1607   *
1608   * @param serverName region server from which {@link RegionMetrics} is required.
1609   * @param tableName get {@link RegionMetrics} of regions belonging to the table
1610   * @return region metrics map of all regions of a table hosted on a region server
1611   * @throws IOException if a remote or network exception occurs
1612   */
1613  List<RegionMetrics> getRegionMetrics(ServerName serverName,
1614    TableName tableName) throws IOException;
1615
1616  /**
1617   * @return Configuration used by the instance.
1618   */
1619  Configuration getConfiguration();
1620
1621  /**
1622   * Create a new namespace. Blocks until namespace has been successfully created or an exception
1623   * is thrown.
1624   *
1625   * @param descriptor descriptor which describes the new namespace.
1626   */
1627  void createNamespace(NamespaceDescriptor descriptor)
1628  throws IOException;
1629
1630  /**
1631   * Create a new namespace.
1632   *
1633   * @param descriptor descriptor which describes the new namespace
1634   * @return the result of the async create namespace operation. Use Future.get(long, TimeUnit) to
1635   *  wait on the operation to complete.
1636   */
1637  Future<Void> createNamespaceAsync(NamespaceDescriptor descriptor)
1638  throws IOException;
1639
1640  /**
1641   * Modify an existing namespace.  Blocks until namespace has been successfully modified or an
1642   * exception is thrown.
1643   *
1644   * @param descriptor descriptor which describes the new namespace
1645   */
1646  void modifyNamespace(NamespaceDescriptor descriptor)
1647  throws IOException;
1648
1649  /**
1650   * Modify an existing namespace.
1651   *
1652   * @param descriptor descriptor which describes the new namespace
1653   * @return the result of the async modify namespace operation. Use Future.get(long, TimeUnit) to
1654   *  wait on the operation to complete.
1655   */
1656  Future<Void> modifyNamespaceAsync(NamespaceDescriptor descriptor)
1657  throws IOException;
1658
1659  /**
1660   * Delete an existing namespace. Only empty namespaces (no tables) can be removed.
1661   * Blocks until namespace has been successfully deleted or an
1662   * exception is thrown.
1663   *
1664   * @param name namespace name
1665   */
1666  void deleteNamespace(String name) throws IOException;
1667
1668  /**
1669   * Delete an existing namespace. Only empty namespaces (no tables) can be removed.
1670   *
1671   * @param name namespace name
1672   * @return the result of the async delete namespace operation. Use Future.get(long, TimeUnit) to
1673   *  wait on the operation to complete.
1674   */
1675  Future<Void> deleteNamespaceAsync(String name) throws IOException;
1676
1677  /**
1678   * Get a namespace descriptor by name.
1679   *
1680   * @param name name of namespace descriptor
1681   * @return A descriptor
1682   * @throws org.apache.hadoop.hbase.NamespaceNotFoundException
1683   * @throws IOException if a remote or network exception occurs
1684   */
1685  NamespaceDescriptor getNamespaceDescriptor(String name)
1686  throws NamespaceNotFoundException, IOException;
1687
1688  /**
1689   * List available namespace descriptors.
1690   *
1691   * @return List of descriptors
1692   */
1693  NamespaceDescriptor[] listNamespaceDescriptors()
1694  throws IOException;
1695
1696  /**
1697   * Get list of table descriptors by namespace.
1698   *
1699   * @param name namespace name
1700   * @return HTD[] the read-only tableDescriptors
1701   * @throws IOException
1702   * @deprecated since 2.0 version and will be removed in 3.0 version.
1703   *             use {@link #listTableDescriptorsByNamespace(byte[])}
1704   */
1705  @Deprecated
1706  HTableDescriptor[] listTableDescriptorsByNamespace(String name)
1707      throws IOException;
1708
1709  /**
1710   * Get list of table descriptors by namespace.
1711   *
1712   * @param name namespace name
1713   * @return returns a list of TableDescriptors
1714   * @throws IOException
1715   */
1716  List<TableDescriptor> listTableDescriptorsByNamespace(byte[] name)
1717      throws IOException;
1718
1719  /**
1720   * Get list of table names by namespace.
1721   *
1722   * @param name namespace name
1723   * @return The list of table names in the namespace
1724   * @throws IOException
1725   */
1726  TableName[] listTableNamesByNamespace(String name)
1727      throws IOException;
1728
1729  /**
1730   * Get the regions of a given table.
1731   *
1732   * @param tableName the name of the table
1733   * @return List of {@link HRegionInfo}.
1734   * @throws IOException
1735   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
1736   *             (<a href="https://issues.apache.org/jira/browse/HBASE-17980">HBASE-17980</a>).
1737   *             Use {@link #getRegions(TableName)}.
1738   */
1739  @Deprecated
1740  List<HRegionInfo> getTableRegions(TableName tableName)
1741    throws IOException;
1742
1743  /**
1744   * Get the regions of a given table.
1745   *
1746   * @param tableName the name of the table
1747   * @return List of {@link RegionInfo}.
1748   * @throws IOException
1749   */
1750  List<RegionInfo> getRegions(TableName tableName) throws IOException;
1751
1752  @Override
1753  void close() throws IOException;
1754
1755  /**
1756   * Get tableDescriptors.
1757   *
1758   * @param tableNames List of table names
1759   * @return HTD[] the read-only tableDescriptors
1760   * @throws IOException if a remote or network exception occurs
1761   * @deprecated since 2.0 version and will be removed in 3.0 version.
1762   *             use {@link #listTableDescriptors(List)}
1763   */
1764  @Deprecated
1765  HTableDescriptor[] getTableDescriptorsByTableName(List<TableName> tableNames)
1766    throws IOException;
1767
1768  /**
1769   * Get tableDescriptors.
1770   *
1771   * @param tableNames List of table names
1772   * @return returns a list of TableDescriptors
1773   * @throws IOException if a remote or network exception occurs
1774   */
1775  List<TableDescriptor> listTableDescriptors(List<TableName> tableNames)
1776    throws IOException;
1777
1778  /**
1779   * Get tableDescriptors.
1780   *
1781   * @param names List of table names
1782   * @return HTD[] the read-only tableDescriptors
1783   * @throws IOException if a remote or network exception occurs
1784   * @deprecated since 2.0 version and will be removed in 3.0 version.
1785   *             use {@link #listTableDescriptors(List)}
1786   */
1787  @Deprecated
1788  HTableDescriptor[] getTableDescriptors(List<String> names)
1789    throws IOException;
1790
1791  /**
1792   * Abort a procedure.
1793   * Do not use. Usually it is ignored but if not, it can do more damage than good. See hbck2.
1794   * @param procId ID of the procedure to abort
1795   * @param mayInterruptIfRunning if the proc completed at least one step, should it be aborted?
1796   * @return <code>true</code> if aborted, <code>false</code> if procedure already completed or does
1797   *         not exist
1798   * @throws IOException if a remote or network exception occurs
1799   * @deprecated since 2.1.1 and will be removed in 4.0.0.
1800   * @see <a href="https://issues.apache.org/jira/browse/HBASE-21223">HBASE-21223</a>
1801   */
1802  @Deprecated
1803  boolean abortProcedure(
1804      long procId,
1805      boolean mayInterruptIfRunning) throws IOException;
1806
1807  /**
1808   * Abort a procedure but does not block and wait for completion.
1809   * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
1810   * It may throw ExecutionException if there was an error while executing the operation
1811   * or TimeoutException in case the wait timeout was not long enough to allow the
1812   * operation to complete.
1813   * Do not use. Usually it is ignored but if not, it can do more damage than good. See hbck2.
1814   *
1815   * @param procId ID of the procedure to abort
1816   * @param mayInterruptIfRunning if the proc completed at least one step, should it be aborted?
1817   * @return <code>true</code> if aborted, <code>false</code> if procedure already completed or does not exist
1818   * @throws IOException if a remote or network exception occurs
1819   * @deprecated since 2.1.1 and will be removed in 4.0.0.
1820   * @see <a href="https://issues.apache.org/jira/browse/HBASE-21223">HBASE-21223</a>
1821   */
1822  @Deprecated
1823  Future<Boolean> abortProcedureAsync(
1824    long procId,
1825    boolean mayInterruptIfRunning) throws IOException;
1826
1827  /**
1828   * Get procedures.
1829   * @return procedure list in JSON
1830   * @throws IOException
1831   */
1832  String getProcedures() throws IOException;
1833
1834  /**
1835   * Get locks.
1836   * @return lock list in JSON
1837   * @throws IOException if a remote or network exception occurs
1838   */
1839  String getLocks() throws IOException;
1840
1841  /**
1842   * Roll the log writer. I.e. for filesystem based write ahead logs, start writing to a new file.
1843   *
1844   * Note that the actual rolling of the log writer is asynchronous and may not be complete when
1845   * this method returns. As a side effect of this call, the named region server may schedule
1846   * store flushes at the request of the wal.
1847   *
1848   * @param serverName The servername of the regionserver.
1849   * @throws IOException if a remote or network exception occurs
1850   * @throws org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException
1851   */
1852  void rollWALWriter(ServerName serverName) throws IOException, FailedLogCloseException;
1853
1854  /**
1855   * Helper that delegates to getClusterMetrics().getMasterCoprocessorNames().
1856   * @return an array of master coprocessors
1857   * @see org.apache.hadoop.hbase.ClusterMetrics#getMasterCoprocessorNames()
1858   * @deprecated since 2.0 version and will be removed in 3.0 version.
1859   *             use {@link #getMasterCoprocessorNames()}
1860   */
1861  @Deprecated
1862  default String[] getMasterCoprocessors() throws IOException {
1863    return getMasterCoprocessorNames().stream().toArray(size -> new String[size]);
1864  }
1865
1866  /**
1867   * Helper that delegates to getClusterMetrics().getMasterCoprocessorNames().
1868   * @return an array of master coprocessors
1869   * @see org.apache.hadoop.hbase.ClusterMetrics#getMasterCoprocessorNames()
1870   */
1871  default List<String> getMasterCoprocessorNames() throws IOException {
1872    return getClusterMetrics(EnumSet.of(Option.MASTER_COPROCESSORS))
1873      .getMasterCoprocessorNames();
1874  }
1875
1876  /**
1877   * Get the current compaction state of a table. It could be in a major compaction, a minor
1878   * compaction, both, or none.
1879   *
1880   * @param tableName table to examine
1881   * @return the current compaction state
1882   * @throws IOException if a remote or network exception occurs
1883   */
1884  CompactionState getCompactionState(TableName tableName) throws IOException;
1885
1886  /**
1887   * Get the current compaction state of a table. It could be in a compaction, or none.
1888   *
1889   * @param tableName table to examine
1890   * @param compactType {@link org.apache.hadoop.hbase.client.CompactType}
1891   * @return the current compaction state
1892   * @throws IOException if a remote or network exception occurs
1893   */
1894  CompactionState getCompactionState(TableName tableName,
1895    CompactType compactType) throws IOException;
1896
1897  /**
1898   * Get the current compaction state of region. It could be in a major compaction, a minor
1899   * compaction, both, or none.
1900   *
1901   * @param regionName region to examine
1902   * @return the current compaction state
1903   * @throws IOException if a remote or network exception occurs
1904   */
1905  CompactionState getCompactionStateForRegion(byte[] regionName) throws IOException;
1906
1907  /**
1908   * Get the timestamp of the last major compaction for the passed table
1909   *
1910   * The timestamp of the oldest HFile resulting from a major compaction of that table,
1911   * or 0 if no such HFile could be found.
1912   *
1913   * @param tableName table to examine
1914   * @return the last major compaction timestamp or 0
1915   * @throws IOException if a remote or network exception occurs
1916   */
1917  long getLastMajorCompactionTimestamp(TableName tableName) throws IOException;
1918
1919  /**
1920   * Get the timestamp of the last major compaction for the passed region.
1921   *
1922   * The timestamp of the oldest HFile resulting from a major compaction of that region,
1923   * or 0 if no such HFile could be found.
1924   *
1925   * @param regionName region to examine
1926   * @return the last major compaction timestamp or 0
1927   * @throws IOException if a remote or network exception occurs
1928   */
1929  long getLastMajorCompactionTimestampForRegion(byte[] regionName) throws IOException;
1930
1931  /**
1932   * Take a snapshot for the given table. If the table is enabled, a FLUSH-type snapshot will be
1933   * taken. If the table is disabled, an offline snapshot is taken. Snapshots are considered unique
1934   * based on <b>the name of the snapshot</b>. Attempts to take a snapshot with the same name (even
1935   * a different type or with different parameters) will fail with a {@link
1936   * org.apache.hadoop.hbase.snapshot.SnapshotCreationException} indicating the duplicate naming.
1937   * Snapshot names follow the same naming constraints as tables in HBase. See {@link
1938   * org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}.
1939   *
1940   * @param snapshotName name of the snapshot to be created
1941   * @param tableName name of the table for which snapshot is created
1942   * @throws IOException if a remote or network exception occurs
1943   * @throws org.apache.hadoop.hbase.snapshot.SnapshotCreationException if snapshot creation failed
1944   * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
1945   */
1946  void snapshot(String snapshotName, TableName tableName)
1947      throws IOException, SnapshotCreationException, IllegalArgumentException;
1948
1949  /**
1950   * Create a timestamp consistent snapshot for the given table. Snapshots are considered unique
1951   * based on <b>the name of the snapshot</b>. Attempts to take a snapshot with the same name (even
1952   * different type or with different parameters) will fail with a {@link SnapshotCreationException}
1953   * indicating the duplicate naming. Snapshot names follow the same naming constraints as tables in
1954   * HBase.
1955   *
1956   * @param snapshotName name of the snapshot to be created
1957   * @param tableName name of the table for which snapshot is created
1958   * @throws IOException if a remote or network exception occurs
1959   * @throws SnapshotCreationException if snapshot creation failed
1960   * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
1961   */
1962  void snapshot(byte[] snapshotName, TableName tableName)
1963      throws IOException, SnapshotCreationException, IllegalArgumentException;
1964
1965  /**
1966   * Create typed snapshot of the table. Snapshots are considered unique based on <b>the name of the
1967   * snapshot</b>. Attempts to take a snapshot with the same name (even a different type or with
1968   * different parameters) will fail with a {@link SnapshotCreationException} indicating the
1969   * duplicate naming. Snapshot names follow the same naming constraints as tables in HBase. See
1970   * {@link org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}.
1971   *
1972   * @param snapshotName name to give the snapshot on the filesystem. Must be unique from all other
1973   * snapshots stored on the cluster
1974   * @param tableName name of the table to snapshot
1975   * @param type type of snapshot to take
1976   * @throws IOException we fail to reach the master
1977   * @throws SnapshotCreationException if snapshot creation failed
1978   * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
1979   */
1980  void snapshot(String snapshotName,
1981      TableName tableName,
1982      SnapshotType type) throws IOException, SnapshotCreationException,
1983      IllegalArgumentException;
1984
1985  /**
1986   * Create typed snapshot of the table. Snapshots are considered unique based on <b>the name of the
1987   * snapshot</b>. Snapshots are taken sequentially even when requested concurrently, across
1988   * all tables. Attempts to take a snapshot with the same name (even a different type or with
1989   * different parameters) will fail with a {@link SnapshotCreationException} indicating the
1990   * duplicate naming. Snapshot names follow the same naming constraints as tables in HBase. See
1991   * {@link org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}.
1992   * Snapshot can live with ttl seconds.
1993   *
1994   * @param snapshotName  name to give the snapshot on the filesystem. Must be unique from all other
1995   *                      snapshots stored on the cluster
1996   * @param tableName     name of the table to snapshot
1997   * @param type          type of snapshot to take
1998   * @param snapshotProps snapshot additional properties e.g. TTL
1999   * @throws IOException               we fail to reach the master
2000   * @throws SnapshotCreationException if snapshot creation failed
2001   * @throws IllegalArgumentException  if the snapshot request is formatted incorrectly
2002   */
2003  default void snapshot(String snapshotName, TableName tableName, SnapshotType type,
2004    Map<String, Object> snapshotProps) throws IOException,
2005    SnapshotCreationException, IllegalArgumentException {
2006    snapshot(new SnapshotDescription(snapshotName, tableName, type, snapshotProps));
2007  }
2008
2009  /**
2010   * Create typed snapshot of the table. Snapshots are considered unique based on <b>the name of the
2011   * snapshot</b>. Snapshots are taken sequentially even when requested concurrently, across
2012   * all tables. Attempts to take a snapshot with the same name (even a different type or with
2013   * different parameters) will fail with a {@link SnapshotCreationException} indicating the
2014   * duplicate naming. Snapshot names follow the same naming constraints as tables in HBase. See
2015   * {@link org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}.
2016   * Snapshot can live with ttl seconds.
2017   *
2018   * @param snapshotName  name to give the snapshot on the filesystem. Must be unique from all other
2019   *                      snapshots stored on the cluster
2020   * @param tableName     name of the table to snapshot
2021   * @param snapshotProps snapshot additional properties e.g. TTL
2022   * @throws IOException               we fail to reach the master
2023   * @throws SnapshotCreationException if snapshot creation failed
2024   * @throws IllegalArgumentException  if the snapshot request is formatted incorrectly
2025   */
2026  default void snapshot(String snapshotName, TableName tableName,
2027    Map<String, Object> snapshotProps) throws IOException,
2028    SnapshotCreationException, IllegalArgumentException {
2029    snapshot(new SnapshotDescription(snapshotName, tableName, SnapshotType.FLUSH, snapshotProps));
2030  }
2031
2032  /**
2033   * Take a snapshot and wait for the server to complete that snapshot (blocking). Only a single
2034   * snapshot should be taken at a time for an instance of HBase, or results may be undefined (you
2035   * can tell multiple HBase clusters to snapshot at the same time, but only one at a time for a
2036   * single cluster). Snapshots are considered unique based on <b>the name of the snapshot</b>.
2037   * Attempts to take a snapshot with the same name (even a different type or with different
2038   * parameters) will fail with a {@link SnapshotCreationException} indicating the duplicate naming.
2039   * Snapshot names follow the same naming constraints as tables in HBase. See {@link
2040   * org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}. You should probably
2041   * use {@link #snapshot(String, org.apache.hadoop.hbase.TableName)} or
2042   * {@link #snapshot(byte[], org.apache.hadoop.hbase.TableName)} unless you are sure about the type
2043   * of snapshot that you want to take.
2044   *
2045   * @param snapshot snapshot to take
2046   * @throws IOException or we lose contact with the master.
2047   * @throws SnapshotCreationException if snapshot failed to be taken
2048   * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
2049   */
2050  void snapshot(SnapshotDescription snapshot)
2051      throws IOException, SnapshotCreationException, IllegalArgumentException;
2052
2053  /**
2054   * Take a snapshot without waiting for the server to complete that snapshot (asynchronous) Only a
2055   * single snapshot should be taken at a time, or results may be undefined.
2056   *
2057   * @param snapshot snapshot to take
2058   * @throws IOException if the snapshot did not succeed or we lose contact with the master.
2059   * @throws SnapshotCreationException if snapshot creation failed
2060   * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
2061   * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use
2062   * {@link #snapshotAsync(SnapshotDescription)} instead.
2063   */
2064  @Deprecated
2065  default void takeSnapshotAsync(SnapshotDescription snapshot)
2066  throws IOException, SnapshotCreationException {
2067    snapshotAsync(snapshot);
2068  }
2069
2070  /**
2071   * Take a snapshot without waiting for the server to complete that snapshot (asynchronous) Only a
2072   * single snapshot should be taken at a time, or results may be undefined.
2073   *
2074   * @param snapshot snapshot to take
2075   * @throws IOException if the snapshot did not succeed or we lose contact with the master.
2076   * @throws SnapshotCreationException if snapshot creation failed
2077   * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
2078   */
2079  void snapshotAsync(SnapshotDescription snapshot) throws IOException, SnapshotCreationException;
2080
2081  /**
2082   * Check the current state of the passed snapshot. There are three possible states: <ol>
2083   * <li>running - returns <tt>false</tt></li> <li>finished - returns <tt>true</tt></li>
2084   * <li>finished with error - throws the exception that caused the snapshot to fail</li> </ol> The
2085   * cluster only knows about the most recent snapshot. Therefore, if another snapshot has been
2086   * run/started since the snapshot you are checking, you will receive an {@link
2087   * org.apache.hadoop.hbase.snapshot.UnknownSnapshotException}.
2088   *
2089   * @param snapshot description of the snapshot to check
2090   * @return <tt>true</tt> if the snapshot is completed, <tt>false</tt> if the snapshot is still
2091   * running
2092   * @throws IOException if we have a network issue
2093   * @throws org.apache.hadoop.hbase.snapshot.HBaseSnapshotException if the snapshot failed
2094   * @throws org.apache.hadoop.hbase.snapshot.UnknownSnapshotException if the requested snapshot is
2095   * unknown
2096   */
2097  boolean isSnapshotFinished(SnapshotDescription snapshot)
2098      throws IOException, HBaseSnapshotException, UnknownSnapshotException;
2099
2100  /**
2101   * Restore the specified snapshot on the original table. (The table must be disabled) If the
2102   * "hbase.snapshot.restore.take.failsafe.snapshot" configuration property is set to <code>true</code>, a
2103   * snapshot of the current table is taken before executing the restore operation. In case of
2104   * restore failure, the failsafe snapshot will be restored. If the restore completes without
2105   * problem the failsafe snapshot is deleted.
2106   *
2107   * @param snapshotName name of the snapshot to restore
2108   * @throws IOException if a remote or network exception occurs
2109   * @throws org.apache.hadoop.hbase.snapshot.RestoreSnapshotException if snapshot failed to be
2110   * restored
2111   * @throws IllegalArgumentException if the restore request is formatted incorrectly
2112   */
2113  void restoreSnapshot(byte[] snapshotName) throws IOException, RestoreSnapshotException;
2114
2115  /**
2116   * Restore the specified snapshot on the original table. (The table must be disabled) If the
2117   * "hbase.snapshot.restore.take.failsafe.snapshot" configuration property is set to <code>true</code>, a
2118   * snapshot of the current table is taken before executing the restore operation. In case of
2119   * restore failure, the failsafe snapshot will be restored. If the restore completes without
2120   * problem the failsafe snapshot is deleted.
2121   *
2122   * @param snapshotName name of the snapshot to restore
2123   * @throws IOException if a remote or network exception occurs
2124   * @throws RestoreSnapshotException if snapshot failed to be restored
2125   * @throws IllegalArgumentException if the restore request is formatted incorrectly
2126   */
2127  void restoreSnapshot(String snapshotName) throws IOException, RestoreSnapshotException;
2128
2129  /**
2130   * Restore the specified snapshot on the original table. (The table must be disabled) If the
2131   * "hbase.snapshot.restore.take.failsafe.snapshot" configuration property is set to <code>true</code>, a
2132   * snapshot of the current table is taken before executing the restore operation. In case of
2133   * restore failure, the failsafe snapshot will be restored. If the restore completes without
2134   * problem the failsafe snapshot is deleted.
2135   *
2136   * @param snapshotName name of the snapshot to restore
2137   * @throws IOException if a remote or network exception occurs
2138   * @throws RestoreSnapshotException if snapshot failed to be restored
2139   * @return the result of the async restore snapshot. You can use Future.get(long, TimeUnit)
2140   *    to wait on the operation to complete.
2141   */
2142  Future<Void> restoreSnapshotAsync(String snapshotName)
2143      throws IOException, RestoreSnapshotException;
2144
2145  /**
2146   * Restore the specified snapshot on the original table. (The table must be disabled) If
2147   * 'takeFailSafeSnapshot' is set to <code>true</code>, a snapshot of the current table is taken before
2148   * executing the restore operation. In case of restore failure, the failsafe snapshot will be
2149   * restored. If the restore completes without problem the failsafe snapshot is deleted. The
2150   * failsafe snapshot name is configurable by using the property
2151   * "hbase.snapshot.restore.failsafe.name".
2152   *
2153   * @param snapshotName name of the snapshot to restore
2154   * @param takeFailSafeSnapshot <code>true</code> if the failsafe snapshot should be taken
2155   * @throws IOException if a remote or network exception occurs
2156   * @throws RestoreSnapshotException if snapshot failed to be restored
2157   * @throws IllegalArgumentException if the restore request is formatted incorrectly
2158   */
2159  void restoreSnapshot(byte[] snapshotName, boolean takeFailSafeSnapshot)
2160      throws IOException, RestoreSnapshotException;
2161
2162  /**
2163   * Restore the specified snapshot on the original table. (The table must be disabled) If
2164   * 'takeFailSafeSnapshot' is set to <code>true</code>, a snapshot of the current table is taken before
2165   * executing the restore operation. In case of restore failure, the failsafe snapshot will be
2166   * restored. If the restore completes without problem the failsafe snapshot is deleted. The
2167   * failsafe snapshot name is configurable by using the property
2168   * "hbase.snapshot.restore.failsafe.name".
2169   *
2170   * @param snapshotName name of the snapshot to restore
2171   * @param takeFailSafeSnapshot <code>true</code> if the failsafe snapshot should be taken
2172   * @throws IOException if a remote or network exception occurs
2173   * @throws RestoreSnapshotException if snapshot failed to be restored
2174   * @throws IllegalArgumentException if the restore request is formatted incorrectly
2175   */
2176  void restoreSnapshot(String snapshotName, boolean takeFailSafeSnapshot)
2177      throws IOException, RestoreSnapshotException;
2178
2179  /**
2180   * Restore the specified snapshot on the original table. (The table must be disabled) If
2181   * 'takeFailSafeSnapshot' is set to <code>true</code>, a snapshot of the current table is taken before
2182   * executing the restore operation. In case of restore failure, the failsafe snapshot will be
2183   * restored. If the restore completes without problem the failsafe snapshot is deleted. The
2184   * failsafe snapshot name is configurable by using the property
2185   * "hbase.snapshot.restore.failsafe.name".
2186   * @param snapshotName name of the snapshot to restore
2187   * @param takeFailSafeSnapshot <code>true</code> if the failsafe snapshot should be taken
2188   * @param restoreAcl <code>true</code> to restore acl of snapshot
2189   * @throws IOException if a remote or network exception occurs
2190   * @throws RestoreSnapshotException if snapshot failed to be restored
2191   * @throws IllegalArgumentException if the restore request is formatted incorrectly
2192   */
2193  void restoreSnapshot(String snapshotName, boolean takeFailSafeSnapshot,
2194      boolean restoreAcl) throws IOException, RestoreSnapshotException;
2195
2196  /**
2197   * Create a new table by cloning the snapshot content.
2198   *
2199   * @param snapshotName name of the snapshot to be cloned
2200   * @param tableName name of the table where the snapshot will be restored
2201   * @throws IOException if a remote or network exception occurs
2202   * @throws TableExistsException if table to be created already exists
2203   * @throws RestoreSnapshotException if snapshot failed to be cloned
2204   * @throws IllegalArgumentException if the specified table has not a valid name
2205   */
2206  void cloneSnapshot(byte[] snapshotName, TableName tableName)
2207      throws IOException, TableExistsException, RestoreSnapshotException;
2208
2209  /**
2210   * Create a new table by cloning the snapshot content.
2211   * @param snapshotName name of the snapshot to be cloned
2212   * @param tableName name of the table where the snapshot will be restored
2213   * @param restoreAcl <code>true</code> to clone acl into newly created table
2214   * @throws IOException if a remote or network exception occurs
2215   * @throws TableExistsException if table to be created already exists
2216   * @throws RestoreSnapshotException if snapshot failed to be cloned
2217   * @throws IllegalArgumentException if the specified table has not a valid name
2218   */
2219  void cloneSnapshot(String snapshotName, TableName tableName, boolean restoreAcl)
2220      throws IOException, TableExistsException, RestoreSnapshotException;
2221
2222  /**
2223   * Create a new table by cloning the snapshot content.
2224   *
2225   * @param snapshotName name of the snapshot to be cloned
2226   * @param tableName name of the table where the snapshot will be restored
2227   * @throws IOException if a remote or network exception occurs
2228   * @throws TableExistsException if table to be created already exists
2229   * @throws RestoreSnapshotException if snapshot failed to be cloned
2230   * @throws IllegalArgumentException if the specified table has not a valid name
2231   */
2232  void cloneSnapshot(String snapshotName, TableName tableName)
2233      throws IOException, TableExistsException, RestoreSnapshotException;
2234
2235  /**
2236   * Create a new table by cloning the snapshot content, but does not block
2237   * and wait for it to be completely cloned.
2238   * You can use Future.get(long, TimeUnit) to wait on the operation to complete.
2239   * It may throw ExecutionException if there was an error while executing the operation
2240   * or TimeoutException in case the wait timeout was not long enough to allow the
2241   * operation to complete.
2242   *
2243   * @param snapshotName name of the snapshot to be cloned
2244   * @param tableName name of the table where the snapshot will be restored
2245   * @throws IOException if a remote or network exception occurs
2246   * @throws TableExistsException if table to be cloned already exists
2247   * @return the result of the async clone snapshot. You can use Future.get(long, TimeUnit)
2248   *    to wait on the operation to complete.
2249   */
2250  Future<Void> cloneSnapshotAsync(String snapshotName, TableName tableName)
2251      throws IOException, TableExistsException;
2252
2253  /**
2254   * Execute a distributed procedure on a cluster.
2255   *
2256   * @param signature A distributed procedure is uniquely identified by its signature (default the
2257   * root ZK node name of the procedure).
2258   * @param instance The instance name of the procedure. For some procedures, this parameter is
2259   * optional.
2260   * @param props Property/Value pairs of properties passing to the procedure
2261   * @throws IOException
2262   */
2263  void execProcedure(String signature, String instance, Map<String, String> props)
2264      throws IOException;
2265
2266  /**
2267   * Execute a distributed procedure on a cluster.
2268   *
2269   * @param signature A distributed procedure is uniquely identified by its signature (default the
2270   * root ZK node name of the procedure).
2271   * @param instance The instance name of the procedure. For some procedures, this parameter is
2272   * optional.
2273   * @param props Property/Value pairs of properties passing to the procedure
2274   * @return data returned after procedure execution. null if no return data.
2275   * @throws IOException
2276   * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use
2277   * {@link #execProcedureWithReturn(String, String, Map)} } instead.
2278   */
2279  @Deprecated
2280  default byte[] execProcedureWithRet(String signature, String instance, Map<String, String> props)
2281      throws IOException {
2282    return execProcedureWithReturn(signature, instance, props);
2283  }
2284
2285  /**
2286   * Execute a distributed procedure on a cluster.
2287   *
2288   * @param signature A distributed procedure is uniquely identified by its signature (default the
2289   * root ZK node name of the procedure).
2290   * @param instance The instance name of the procedure. For some procedures, this parameter is
2291   * optional.
2292   * @param props Property/Value pairs of properties passing to the procedure
2293   * @return data returned after procedure execution. null if no return data.
2294   * @throws IOException
2295   */
2296  byte[] execProcedureWithReturn(String signature, String instance, Map<String, String> props)
2297  throws IOException;
2298
2299  /**
2300   * Check the current state of the specified procedure. There are three possible states: <ol>
2301   * <li>running - returns <tt>false</tt></li> <li>finished - returns <tt>true</tt></li>
2302   * <li>finished with error - throws the exception that caused the procedure to fail</li> </ol>
2303   *
2304   * @param signature The signature that uniquely identifies a procedure
2305   * @param instance The instance name of the procedure
2306   * @param props Property/Value pairs of properties passing to the procedure
2307   * @return <code>true</code> if the specified procedure is finished successfully, <code>false</code> if it is still running
2308   * @throws IOException if the specified procedure finished with error
2309   */
2310  boolean isProcedureFinished(String signature, String instance, Map<String, String> props)
2311      throws IOException;
2312
2313  /**
2314   * List completed snapshots.
2315   *
2316   * @return a list of snapshot descriptors for completed snapshots
2317   * @throws IOException if a network error occurs
2318   */
2319  List<SnapshotDescription> listSnapshots() throws IOException;
2320
2321  /**
2322   * List all the completed snapshots matching the given regular expression.
2323   *
2324   * @param regex The regular expression to match against
2325   * @return list of SnapshotDescription
2326   * @throws IOException if a remote or network exception occurs
2327   * @deprecated since 2.0 version and will be removed in 3.0 version.
2328   *             Use {@link #listSnapshots(Pattern)} instead.
2329   */
2330  @Deprecated
2331  List<SnapshotDescription> listSnapshots(String regex) throws IOException;
2332
2333  /**
2334   * List all the completed snapshots matching the given pattern.
2335   *
2336   * @param pattern The compiled regular expression to match against
2337   * @return list of SnapshotDescription
2338   * @throws IOException if a remote or network exception occurs
2339   */
2340  List<SnapshotDescription> listSnapshots(Pattern pattern) throws IOException;
2341
2342  /**
2343   * List all the completed snapshots matching the given table name regular expression and snapshot
2344   * name regular expression.
2345   * @param tableNameRegex The table name regular expression to match against
2346   * @param snapshotNameRegex The snapshot name regular expression to match against
2347   * @return list of completed SnapshotDescription
2348   * @throws IOException if a remote or network exception occurs
2349   * @deprecated since 2.0 version and will be removed in 3.0 version.
2350   *             Use {@link #listTableSnapshots(Pattern, Pattern)} instead.
2351   */
2352  @Deprecated
2353  List<SnapshotDescription> listTableSnapshots(String tableNameRegex,
2354      String snapshotNameRegex) throws IOException;
2355
2356  /**
2357   * List all the completed snapshots matching the given table name regular expression and snapshot
2358   * name regular expression.
2359   * @param tableNamePattern The compiled table name regular expression to match against
2360   * @param snapshotNamePattern The compiled snapshot name regular expression to match against
2361   * @return list of completed SnapshotDescription
2362   * @throws IOException if a remote or network exception occurs
2363   */
2364  List<SnapshotDescription> listTableSnapshots(Pattern tableNamePattern,
2365      Pattern snapshotNamePattern) throws IOException;
2366
2367  /**
2368   * Delete an existing snapshot.
2369   *
2370   * @param snapshotName name of the snapshot
2371   * @throws IOException if a remote or network exception occurs
2372   */
2373  void deleteSnapshot(byte[] snapshotName) throws IOException;
2374
2375  /**
2376   * Delete an existing snapshot.
2377   *
2378   * @param snapshotName name of the snapshot
2379   * @throws IOException if a remote or network exception occurs
2380   */
2381  void deleteSnapshot(String snapshotName) throws IOException;
2382
2383  /**
2384   * Delete existing snapshots whose names match the pattern passed.
2385   *
2386   * @param regex The regular expression to match against
2387   * @throws IOException if a remote or network exception occurs
2388   * @deprecated since 2.0 version and will be removed in 3.0 version.
2389   *             Use {@link #deleteSnapshots(Pattern)} instead.
2390   */
2391  @Deprecated
2392  void deleteSnapshots(String regex) throws IOException;
2393
2394  /**
2395   * Delete existing snapshots whose names match the pattern passed.
2396   *
2397   * @param pattern pattern for names of the snapshot to match
2398   * @throws IOException if a remote or network exception occurs
2399   */
2400  void deleteSnapshots(Pattern pattern) throws IOException;
2401
2402  /**
2403   * Delete all existing snapshots matching the given table name regular expression and snapshot
2404   * name regular expression.
2405   * @param tableNameRegex The table name regular expression to match against
2406   * @param snapshotNameRegex The snapshot name regular expression to match against
2407   * @throws IOException if a remote or network exception occurs
2408   * @deprecated since 2.0 version and will be removed in 3.0 version.
2409   *             Use {@link #deleteTableSnapshots(Pattern, Pattern)} instead.
2410   */
2411  @Deprecated
2412  void deleteTableSnapshots(String tableNameRegex, String snapshotNameRegex) throws IOException;
2413
2414  /**
2415   * Delete all existing snapshots matching the given table name regular expression and snapshot
2416   * name regular expression.
2417   * @param tableNamePattern The compiled table name regular expression to match against
2418   * @param snapshotNamePattern The compiled snapshot name regular expression to match against
2419   * @throws IOException if a remote or network exception occurs
2420   */
2421  void deleteTableSnapshots(Pattern tableNamePattern, Pattern snapshotNamePattern)
2422      throws IOException;
2423
2424  /**
2425   * Apply the new quota settings.
2426   *
2427   * @param quota the quota settings
2428   * @throws IOException if a remote or network exception occurs
2429   */
2430  void setQuota(QuotaSettings quota) throws IOException;
2431
2432  /**
2433   * Return a QuotaRetriever to list the quotas based on the filter.
2434   * @param filter the quota settings filter
2435   * @return the quota retriever
2436   * @throws IOException if a remote or network exception occurs
2437   * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #getQuota(QuotaFilter)}.
2438   */
2439  @Deprecated
2440  QuotaRetriever getQuotaRetriever(QuotaFilter filter) throws IOException;
2441
2442  /**
2443   * List the quotas based on the filter.
2444   * @param filter the quota settings filter
2445   * @return the QuotaSetting list
2446   * @throws IOException if a remote or network exception occurs
2447   */
2448  List<QuotaSettings> getQuota(QuotaFilter filter) throws IOException;
2449
2450  /**
2451   * Creates and returns a {@link com.google.protobuf.RpcChannel} instance connected to the active
2452   * master. <p> The obtained {@link com.google.protobuf.RpcChannel} instance can be used to access
2453   * a published coprocessor {@link com.google.protobuf.Service} using standard protobuf service
2454   * invocations: </p> <div style="background-color: #cccccc; padding: 2px">
2455   * <blockquote><pre>
2456   * CoprocessorRpcChannel channel = myAdmin.coprocessorService();
2457   * MyService.BlockingInterface service = MyService.newBlockingStub(channel);
2458   * MyCallRequest request = MyCallRequest.newBuilder()
2459   *     ...
2460   *     .build();
2461   * MyCallResponse response = service.myCall(null, request);
2462   * </pre></blockquote></div>
2463   *
2464   * @return A MasterCoprocessorRpcChannel instance
2465   */
2466  CoprocessorRpcChannel coprocessorService();
2467
2468
2469  /**
2470   * Creates and returns a {@link com.google.protobuf.RpcChannel} instance
2471   * connected to the passed region server.
2472   *
2473   * <p>
2474   * The obtained {@link com.google.protobuf.RpcChannel} instance can be used to access a published
2475   * coprocessor {@link com.google.protobuf.Service} using standard protobuf service invocations:
2476   * </p>
2477   *
2478   * <div style="background-color: #cccccc; padding: 2px">
2479   * <blockquote><pre>
2480   * CoprocessorRpcChannel channel = myAdmin.coprocessorService(serverName);
2481   * MyService.BlockingInterface service = MyService.newBlockingStub(channel);
2482   * MyCallRequest request = MyCallRequest.newBuilder()
2483   *     ...
2484   *     .build();
2485   * MyCallResponse response = service.myCall(null, request);
2486   * </pre></blockquote></div>
2487   *
2488   * @param serverName the server name to which the endpoint call is made
2489   * @return A RegionServerCoprocessorRpcChannel instance
2490   */
2491  CoprocessorRpcChannel coprocessorService(ServerName serverName);
2492
2493
2494  /**
2495   * Update the configuration and trigger an online config change
2496   * on the regionserver.
2497   * @param server : The server whose config needs to be updated.
2498   * @throws IOException
2499   */
2500  void updateConfiguration(ServerName server) throws IOException;
2501
2502
2503  /**
2504   * Update the configuration and trigger an online config change
2505   * on all the regionservers.
2506   * @throws IOException
2507   */
2508  void updateConfiguration() throws IOException;
2509
2510  /**
2511   * Get the info port of the current master if one is available.
2512   * @return master info port
2513   * @throws IOException
2514   */
2515  default int getMasterInfoPort() throws IOException {
2516    return getClusterMetrics(EnumSet.of(Option.MASTER_INFO_PORT)).getMasterInfoPort();
2517  }
2518
2519  /**
2520   * Return the set of supported security capabilities.
2521   * @throws IOException
2522   * @throws UnsupportedOperationException
2523   */
2524  List<SecurityCapability> getSecurityCapabilities() throws IOException;
2525
2526  /**
2527   * Turn the Split or Merge switches on or off.
2528   * @param enabled enabled or not
2529   * @param synchronous If <code>true</code>, it waits until current split() call, if outstanding,
2530   *          to return.
2531   * @param switchTypes switchType list {@link MasterSwitchType}
2532   * @return Previous switch value array
2533   * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #splitSwitch(boolean, boolean)}
2534   *             or {@link #mergeSwitch(boolean, boolean)} instead.
2535   */
2536  @Deprecated
2537  default boolean[] setSplitOrMergeEnabled(boolean enabled, boolean synchronous,
2538      MasterSwitchType... switchTypes) throws IOException {
2539    boolean[] preValues = new boolean[switchTypes.length];
2540    for (int i = 0; i < switchTypes.length; i++) {
2541      switch (switchTypes[i]) {
2542        case SPLIT:
2543          preValues[i] = splitSwitch(enabled, synchronous);
2544          break;
2545        case MERGE:
2546          preValues[i] = mergeSwitch(enabled, synchronous);
2547          break;
2548        default:
2549          throw new UnsupportedOperationException("Unsupported switch type:" + switchTypes[i]);
2550      }
2551    }
2552    return preValues;
2553  }
2554
2555  /**
2556   * Turn the split switch on or off.
2557   * @param enabled enabled or not
2558   * @param synchronous If <code>true</code>, it waits until current split() call, if outstanding,
2559   *          to return.
2560   * @return Previous switch value
2561   */
2562  boolean splitSwitch(boolean enabled, boolean synchronous) throws IOException;
2563
2564  /**
2565   * Turn the merge switch on or off.
2566   * @param enabled enabled or not
2567   * @param synchronous If <code>true</code>, it waits until current merge() call, if outstanding,
2568   *          to return.
2569   * @return Previous switch value
2570   */
2571  boolean mergeSwitch(boolean enabled, boolean synchronous) throws IOException;
2572
2573  /**
2574   * Query the current state of the switch.
2575   *
2576   * @return <code>true</code> if the switch is enabled, <code>false</code> otherwise.
2577   * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use
2578   * {@link #isSplitEnabled()} or {@link #isMergeEnabled()} instead.
2579   */
2580  @Deprecated
2581  default boolean isSplitOrMergeEnabled(MasterSwitchType switchType) throws IOException {
2582    switch (switchType) {
2583      case SPLIT:
2584        return isSplitEnabled();
2585      case MERGE:
2586        return isMergeEnabled();
2587      default:
2588        break;
2589    }
2590    throw new UnsupportedOperationException("Unsupported switch type:" + switchType);
2591  }
2592
2593  /**
2594   * Query the current state of the split switch.
2595   * @return <code>true</code> if the switch is enabled, <code>false</code> otherwise.
2596   */
2597  boolean isSplitEnabled() throws IOException;
2598
2599  /**
2600   * Query the current state of the merge switch.
2601   * @return <code>true</code> if the switch is enabled, <code>false</code> otherwise.
2602   */
2603  boolean isMergeEnabled() throws IOException;
2604
2605  /**
2606   * Add a new replication peer for replicating data to slave cluster.
2607   * @param peerId a short name that identifies the peer
2608   * @param peerConfig configuration for the replication peer
2609   * @throws IOException if a remote or network exception occurs
2610   */
2611  default void addReplicationPeer(String peerId, ReplicationPeerConfig peerConfig)
2612      throws IOException {
2613    addReplicationPeer(peerId, peerConfig, true);
2614  }
2615
2616  /**
2617   * Add a new replication peer for replicating data to slave cluster.
2618   * @param peerId a short name that identifies the peer
2619   * @param peerConfig configuration for the replication peer
2620   * @param enabled peer state, true if ENABLED and false if DISABLED
2621   * @throws IOException if a remote or network exception occurs
2622   */
2623  void addReplicationPeer(String peerId, ReplicationPeerConfig peerConfig, boolean enabled)
2624      throws IOException;
2625
2626  /**
2627   * Add a new replication peer but does not block and wait for it.
2628   * <p>
2629   * You can use Future.get(long, TimeUnit) to wait on the operation to complete. It may throw
2630   * ExecutionException if there was an error while executing the operation or TimeoutException in
2631   * case the wait timeout was not long enough to allow the operation to complete.
2632   * @param peerId a short name that identifies the peer
2633   * @param peerConfig configuration for the replication peer
2634   * @return the result of the async operation
2635   * @throws IOException IOException if a remote or network exception occurs
2636   */
2637  default Future<Void> addReplicationPeerAsync(String peerId, ReplicationPeerConfig peerConfig)
2638      throws IOException {
2639    return addReplicationPeerAsync(peerId, peerConfig, true);
2640  }
2641
2642  /**
2643   * Add a new replication peer but does not block and wait for it.
2644   * <p>
2645   * You can use Future.get(long, TimeUnit) to wait on the operation to complete. It may throw
2646   * ExecutionException if there was an error while executing the operation or TimeoutException in
2647   * case the wait timeout was not long enough to allow the operation to complete.
2648   * @param peerId a short name that identifies the peer
2649   * @param peerConfig configuration for the replication peer
2650   * @param enabled peer state, true if ENABLED and false if DISABLED
2651   * @return the result of the async operation
2652   * @throws IOException IOException if a remote or network exception occurs
2653   */
2654  Future<Void> addReplicationPeerAsync(String peerId, ReplicationPeerConfig peerConfig,
2655      boolean enabled) throws IOException;
2656
2657  /**
2658   * Remove a peer and stop the replication.
2659   * @param peerId a short name that identifies the peer
2660   * @throws IOException if a remote or network exception occurs
2661   */
2662  void removeReplicationPeer(String peerId) throws IOException;
2663
2664  /**
2665   * Remove a replication peer but does not block and wait for it.
2666   * <p>
2667   * You can use Future.get(long, TimeUnit) to wait on the operation to complete. It may throw
2668   * ExecutionException if there was an error while executing the operation or TimeoutException in
2669   * case the wait timeout was not long enough to allow the operation to complete.
2670   * @param peerId a short name that identifies the peer
2671   * @return the result of the async operation
2672   * @throws IOException IOException if a remote or network exception occurs
2673   */
2674  Future<Void> removeReplicationPeerAsync(String peerId) throws IOException;
2675
2676  /**
2677   * Restart the replication stream to the specified peer.
2678   * @param peerId a short name that identifies the peer
2679   * @throws IOException if a remote or network exception occurs
2680   */
2681  void enableReplicationPeer(String peerId) throws IOException;
2682
2683  /**
2684   * Enable a replication peer but does not block and wait for it.
2685   * <p>
2686   * You can use Future.get(long, TimeUnit) to wait on the operation to complete. It may throw
2687   * ExecutionException if there was an error while executing the operation or TimeoutException in
2688   * case the wait timeout was not long enough to allow the operation to complete.
2689   * @param peerId a short name that identifies the peer
2690   * @return the result of the async operation
2691   * @throws IOException IOException if a remote or network exception occurs
2692   */
2693  Future<Void> enableReplicationPeerAsync(String peerId) throws IOException;
2694
2695  /**
2696   * Stop the replication stream to the specified peer.
2697   * @param peerId a short name that identifies the peer
2698   * @throws IOException if a remote or network exception occurs
2699   */
2700  void disableReplicationPeer(String peerId) throws IOException;
2701
2702  /**
2703   * Disable a replication peer but does not block and wait for it.
2704   * <p>
2705   * You can use Future.get(long, TimeUnit) to wait on the operation to complete. It may throw
2706   * ExecutionException if there was an error while executing the operation or TimeoutException in
2707   * case the wait timeout was not long enough to allow the operation to complete.
2708   * @param peerId a short name that identifies the peer
2709   * @return the result of the async operation
2710   * @throws IOException IOException if a remote or network exception occurs
2711   */
2712  Future<Void> disableReplicationPeerAsync(String peerId) throws IOException;
2713
2714  /**
2715   * Returns the configured ReplicationPeerConfig for the specified peer.
2716   * @param peerId a short name that identifies the peer
2717   * @return ReplicationPeerConfig for the peer
2718   * @throws IOException if a remote or network exception occurs
2719   */
2720  ReplicationPeerConfig getReplicationPeerConfig(String peerId) throws IOException;
2721
2722  /**
2723   * Update the peerConfig for the specified peer.
2724   * @param peerId a short name that identifies the peer
2725   * @param peerConfig new config for the replication peer
2726   * @throws IOException if a remote or network exception occurs
2727   */
2728  void updateReplicationPeerConfig(String peerId,
2729      ReplicationPeerConfig peerConfig) throws IOException;
2730
2731  /**
2732   * Update the peerConfig for the specified peer but does not block and wait for it.
2733   * <p>
2734   * You can use Future.get(long, TimeUnit) to wait on the operation to complete. It may throw
2735   * ExecutionException if there was an error while executing the operation or TimeoutException in
2736   * case the wait timeout was not long enough to allow the operation to complete.
2737   * @param peerId a short name that identifies the peer
2738   * @param peerConfig new config for the replication peer
2739   * @return the result of the async operation
2740   * @throws IOException IOException if a remote or network exception occurs
2741   */
2742  Future<Void> updateReplicationPeerConfigAsync(String peerId, ReplicationPeerConfig peerConfig)
2743      throws IOException;
2744
2745  /**
2746   * Append the replicable table column family config from the specified peer.
2747   * @param id a short that identifies the cluster
2748   * @param tableCfs A map from tableName to column family names
2749   * @throws ReplicationException if tableCfs has conflict with existing config
2750   * @throws IOException if a remote or network exception occurs
2751   */
2752  void appendReplicationPeerTableCFs(String id,
2753      Map<TableName, List<String>> tableCfs)
2754      throws ReplicationException, IOException;
2755
2756  /**
2757   * Remove some table-cfs from config of the specified peer.
2758   * @param id a short name that identifies the cluster
2759   * @param tableCfs A map from tableName to column family names
2760   * @throws ReplicationException if tableCfs has conflict with existing config
2761   * @throws IOException if a remote or network exception occurs
2762   */
2763  void removeReplicationPeerTableCFs(String id,
2764      Map<TableName, List<String>> tableCfs)
2765      throws ReplicationException, IOException;
2766
2767  /**
2768   * Return a list of replication peers.
2769   * @return a list of replication peers description
2770   * @throws IOException if a remote or network exception occurs
2771   */
2772  List<ReplicationPeerDescription> listReplicationPeers() throws IOException;
2773
2774  /**
2775   * Return a list of replication peers.
2776   * @param pattern The compiled regular expression to match peer id
2777   * @return a list of replication peers description
2778   * @throws IOException if a remote or network exception occurs
2779   */
2780  List<ReplicationPeerDescription> listReplicationPeers(Pattern pattern) throws IOException;
2781
2782  /**
2783   * Mark region server(s) as decommissioned to prevent additional regions from getting
2784   * assigned to them. Optionally unload the regions on the servers. If there are multiple servers
2785   * to be decommissioned, decommissioning them at the same time can prevent wasteful region
2786   * movements. Region unloading is asynchronous.
2787   * @param servers The list of servers to decommission.
2788   * @param offload True to offload the regions from the decommissioned servers
2789   */
2790  void decommissionRegionServers(List<ServerName> servers, boolean offload) throws IOException;
2791
2792  /**
2793   * List region servers marked as decommissioned, which can not be assigned regions.
2794   * @return List of decommissioned region servers.
2795   */
2796  List<ServerName> listDecommissionedRegionServers() throws IOException;
2797
2798  /**
2799   * Remove decommission marker from a region server to allow regions assignments.
2800   * Load regions onto the server if a list of regions is given. Region loading is
2801   * asynchronous.
2802   * @param server The server to recommission.
2803   * @param encodedRegionNames Regions to load onto the server.
2804   */
2805  void recommissionRegionServer(ServerName server, List<byte[]> encodedRegionNames)
2806      throws IOException;
2807
2808  /**
2809   * Find all table and column families that are replicated from this cluster
2810   * @return the replicated table-cfs list of this cluster.
2811   */
2812  List<TableCFs> listReplicatedTableCFs() throws IOException;
2813
2814  /**
2815   * Enable a table's replication switch.
2816   * @param tableName name of the table
2817   * @throws IOException if a remote or network exception occurs
2818   */
2819  void enableTableReplication(TableName tableName) throws IOException;
2820
2821  /**
2822   * Disable a table's replication switch.
2823   * @param tableName name of the table
2824   * @throws IOException if a remote or network exception occurs
2825   */
2826  void disableTableReplication(TableName tableName) throws IOException;
2827
2828  /**
2829   * Clear compacting queues on a regionserver.
2830   * @param serverName the region server name
2831   * @param queues the set of queue name
2832   * @throws IOException if a remote or network exception occurs
2833   * @throws InterruptedException
2834   */
2835  void clearCompactionQueues(ServerName serverName, Set<String> queues)
2836    throws IOException, InterruptedException;
2837
2838  /**
2839   * List dead region servers.
2840   * @return List of dead region servers.
2841   */
2842  default List<ServerName> listDeadServers() throws IOException {
2843    return getClusterMetrics(EnumSet.of(Option.DEAD_SERVERS)).getDeadServerNames();
2844  }
2845
2846  /**
2847   * Clear dead region servers from master.
2848   * @param servers list of dead region servers.
2849   * @throws IOException if a remote or network exception occurs
2850   * @return List of servers that are not cleared
2851   */
2852  List<ServerName> clearDeadServers(final List<ServerName> servers) throws IOException;
2853
2854  /**
2855   * Create a new table by cloning the existent table schema.
2856   *
2857   * @param tableName name of the table to be cloned
2858   * @param newTableName name of the new table where the table will be created
2859   * @param preserveSplits True if the splits should be preserved
2860   * @throws IOException if a remote or network exception occurs
2861   */
2862  void cloneTableSchema(final TableName tableName, final TableName newTableName,
2863      final boolean preserveSplits) throws IOException;
2864
2865  /**
2866   * Switch the rpc throttle enable state.
2867   * @param enable Set to <code>true</code> to enable, <code>false</code> to disable.
2868   * @return Previous rpc throttle enabled value
2869   */
2870  boolean switchRpcThrottle(final boolean enable) throws IOException;
2871
2872  /**
2873   * Get if the rpc throttle is enabled.
2874   * @return True if rpc throttle is enabled
2875   */
2876  boolean isRpcThrottleEnabled() throws IOException;
2877
2878  /**
2879   * Switch the exceed throttle quota. If enabled, user/table/namespace throttle quota
2880   * can be exceeded if region server has availble quota.
2881   * @param enable Set to <code>true</code> to enable, <code>false</code> to disable.
2882   * @return Previous exceed throttle enabled value
2883   */
2884  boolean exceedThrottleQuotaSwitch(final boolean enable) throws IOException;
2885
2886  /**
2887   * Fetches the table sizes on the filesystem as tracked by the HBase Master.
2888   */
2889  Map<TableName, Long> getSpaceQuotaTableSizes() throws IOException;
2890
2891  /**
2892   * Fetches the observed {@link SpaceQuotaSnapshotView}s observed by a RegionServer.
2893   */
2894  Map<TableName, ? extends SpaceQuotaSnapshotView> getRegionServerSpaceQuotaSnapshots(
2895      ServerName serverName) throws IOException;
2896
2897  /**
2898   * Returns the Master's view of a quota on the given {@code namespace} or null if the Master has
2899   * no quota information on that namespace.
2900   */
2901  SpaceQuotaSnapshotView getCurrentSpaceQuotaSnapshot(String namespace) throws IOException;
2902
2903  /**
2904   * Returns the Master's view of a quota on the given {@code tableName} or null if the Master has
2905   * no quota information on that table.
2906   */
2907  SpaceQuotaSnapshotView getCurrentSpaceQuotaSnapshot(TableName tableName) throws IOException;
2908
2909  /**
2910   * Grants user specific permissions
2911   * @param userPermission user name and the specific permission
2912   * @param mergeExistingPermissions If set to false, later granted permissions will override
2913   *          previous granted permissions. otherwise, it'll merge with previous granted
2914   *          permissions.
2915   * @throws IOException if a remote or network exception occurs
2916   */
2917  void grant(UserPermission userPermission, boolean mergeExistingPermissions) throws IOException;
2918
2919  /**
2920   * Revokes user specific permissions
2921   * @param userPermission user name and the specific permission
2922   * @throws IOException if a remote or network exception occurs
2923   */
2924  void revoke(UserPermission userPermission) throws IOException;
2925
2926  /**
2927   * Get the global/namespace/table permissions for user
2928   * @param getUserPermissionsRequest A request contains which user, global, namespace or table
2929   *          permissions needed
2930   * @return The user and permission list
2931   * @throws IOException if a remote or network exception occurs
2932   */
2933  List<UserPermission> getUserPermissions(GetUserPermissionsRequest getUserPermissionsRequest)
2934      throws IOException;
2935
2936  /**
2937   * Check if the user has specific permissions
2938   * @param userName the user name
2939   * @param permissions the specific permission list
2940   * @return True if user has the specific permissions
2941   * @throws IOException if a remote or network exception occurs
2942   */
2943  List<Boolean> hasUserPermissions(String userName, List<Permission> permissions)
2944      throws IOException;
2945
2946  /**
2947   * Check if call user has specific permissions
2948   * @param permissions the specific permission list
2949   * @return True if user has the specific permissions
2950   * @throws IOException if a remote or network exception occurs
2951   */
2952  default List<Boolean> hasUserPermissions(List<Permission> permissions) throws IOException {
2953    return hasUserPermissions(null, permissions);
2954  }
2955}