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 static org.apache.hadoop.hbase.util.FutureUtils.addListener;
021
022import java.io.IOException;
023import java.util.Arrays;
024import java.util.Collection;
025import java.util.EnumSet;
026import java.util.HashMap;
027import java.util.List;
028import java.util.Map;
029import java.util.Optional;
030import java.util.Set;
031import java.util.concurrent.CompletableFuture;
032import java.util.function.Function;
033import java.util.regex.Pattern;
034import java.util.stream.Collectors;
035import org.apache.hadoop.hbase.CacheEvictionStats;
036import org.apache.hadoop.hbase.ClusterMetrics;
037import org.apache.hadoop.hbase.ClusterMetrics.Option;
038import org.apache.hadoop.hbase.NamespaceDescriptor;
039import org.apache.hadoop.hbase.RegionMetrics;
040import org.apache.hadoop.hbase.ServerName;
041import org.apache.hadoop.hbase.TableName;
042import org.apache.hadoop.hbase.client.replication.TableCFs;
043import org.apache.hadoop.hbase.client.security.SecurityCapability;
044import org.apache.hadoop.hbase.net.Address;
045import org.apache.hadoop.hbase.quotas.QuotaFilter;
046import org.apache.hadoop.hbase.quotas.QuotaSettings;
047import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshotView;
048import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
049import org.apache.hadoop.hbase.replication.ReplicationPeerDescription;
050import org.apache.hadoop.hbase.replication.SyncReplicationState;
051import org.apache.hadoop.hbase.rsgroup.RSGroupInfo;
052import org.apache.hadoop.hbase.security.access.GetUserPermissionsRequest;
053import org.apache.hadoop.hbase.security.access.Permission;
054import org.apache.hadoop.hbase.security.access.UserPermission;
055import org.apache.hadoop.hbase.util.Pair;
056import org.apache.yetus.audience.InterfaceAudience;
057
058import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList;
059import org.apache.hbase.thirdparty.com.google.protobuf.RpcChannel;
060
061/**
062 * The asynchronous administrative API for HBase.
063 * @since 2.0.0
064 */
065@InterfaceAudience.Public
066public interface AsyncAdmin {
067
068  /**
069   * Check if a table exists.
070   * @param tableName Table to check.
071   * @return True if table exists already. The return value will be wrapped by a
072   *         {@link CompletableFuture}.
073   */
074  CompletableFuture<Boolean> tableExists(TableName tableName);
075
076  /**
077   * List all the userspace tables.
078   * @return - returns a list of TableDescriptors wrapped by a {@link CompletableFuture}.
079   */
080  default CompletableFuture<List<TableDescriptor>> listTableDescriptors() {
081    return listTableDescriptors(false);
082  }
083
084  /**
085   * List all the tables.
086   * @param includeSysTables False to match only against userspace tables
087   * @return - returns a list of TableDescriptors wrapped by a {@link CompletableFuture}.
088   */
089  CompletableFuture<List<TableDescriptor>> listTableDescriptors(boolean includeSysTables);
090
091  /**
092   * List all the tables matching the given pattern.
093   * @param pattern          The compiled regular expression to match against
094   * @param includeSysTables False to match only against userspace tables
095   * @return - returns a list of TableDescriptors wrapped by a {@link CompletableFuture}.
096   */
097  CompletableFuture<List<TableDescriptor>> listTableDescriptors(Pattern pattern,
098    boolean includeSysTables);
099
100  /**
101   * List specific tables including system tables.
102   * @param tableNames the table list to match against
103   * @return - returns a list of TableDescriptors wrapped by a {@link CompletableFuture}.
104   */
105  CompletableFuture<List<TableDescriptor>> listTableDescriptors(List<TableName> tableNames);
106
107  /**
108   * Get list of table descriptors by namespace.
109   * @param name namespace name
110   * @return returns a list of TableDescriptors wrapped by a {@link CompletableFuture}.
111   */
112  CompletableFuture<List<TableDescriptor>> listTableDescriptorsByNamespace(String name);
113
114  /**
115   * List all enabled or disabled table descriptors
116   * @param isEnabled is true means return enabled table descriptors, false means return disabled
117   *                  table descriptors
118   * @return a list of table names wrapped by a {@link CompletableFuture}.
119   */
120  CompletableFuture<List<TableDescriptor>> listTableDescriptorsByState(boolean isEnabled);
121
122  /**
123   * List all of the names of userspace tables.
124   * @return a list of table names wrapped by a {@link CompletableFuture}.
125   * @see #listTableNames(Pattern, boolean)
126   */
127  default CompletableFuture<List<TableName>> listTableNames() {
128    return listTableNames(false);
129  }
130
131  /**
132   * List all of the names of tables.
133   * @param includeSysTables False to match only against userspace tables
134   * @return a list of table names wrapped by a {@link CompletableFuture}.
135   */
136  CompletableFuture<List<TableName>> listTableNames(boolean includeSysTables);
137
138  /**
139   * List all of the names of userspace tables.
140   * @param pattern          The regular expression to match against
141   * @param includeSysTables False to match only against userspace tables
142   * @return a list of table names wrapped by a {@link CompletableFuture}.
143   */
144  CompletableFuture<List<TableName>> listTableNames(Pattern pattern, boolean includeSysTables);
145
146  /**
147   * List all enabled or disabled table names
148   * @param isEnabled is true means return enabled table names, false means return disabled table
149   *                  names
150   * @return a list of table names wrapped by a {@link CompletableFuture}.
151   */
152  CompletableFuture<List<TableName>> listTableNamesByState(boolean isEnabled);
153
154  /**
155   * Get list of table names by namespace.
156   * @param name namespace name
157   * @return The list of table names in the namespace wrapped by a {@link CompletableFuture}.
158   */
159  CompletableFuture<List<TableName>> listTableNamesByNamespace(String name);
160
161  /**
162   * Method for getting the tableDescriptor
163   * @param tableName as a {@link TableName}
164   * @return the read-only tableDescriptor wrapped by a {@link CompletableFuture}.
165   */
166  CompletableFuture<TableDescriptor> getDescriptor(TableName tableName);
167
168  /**
169   * Creates a new table.
170   * @param desc table descriptor for table
171   */
172  CompletableFuture<Void> createTable(TableDescriptor desc);
173
174  /**
175   * Creates a new table with the specified number of regions. The start key specified will become
176   * the end key of the first region of the table, and the end key specified will become the start
177   * key of the last region of the table (the first region has a null start key and the last region
178   * has a null end key). BigInteger math will be used to divide the key range specified into enough
179   * segments to make the required number of total regions.
180   * @param desc       table descriptor for table
181   * @param startKey   beginning of key range
182   * @param endKey     end of key range
183   * @param numRegions the total number of regions to create
184   */
185  CompletableFuture<Void> createTable(TableDescriptor desc, byte[] startKey, byte[] endKey,
186    int numRegions);
187
188  /**
189   * Creates a new table with an initial set of empty regions defined by the specified split keys.
190   * The total number of regions created will be the number of split keys plus one. Note : Avoid
191   * passing empty split key.
192   * @param desc      table descriptor for table
193   * @param splitKeys array of split keys for the initial regions of the table
194   */
195  CompletableFuture<Void> createTable(TableDescriptor desc, byte[][] splitKeys);
196
197  /**
198   * Modify an existing table, more IRB friendly version.
199   * @param desc modified description of the table
200   */
201  default CompletableFuture<Void> modifyTable(TableDescriptor desc) {
202    return modifyTable(desc, true);
203  }
204
205  /**
206   * Modify an existing table, more IRB friendly version.
207   * @param desc          description of the table
208   * @param reopenRegions By default, 'modifyTable' reopens all regions, potentially causing a RIT
209   *                      (Region In Transition) storm in large tables. If set to 'false', regions
210   *                      will remain unaware of the modification until they are individually
211   *                      reopened. Please note that this may temporarily result in configuration
212   *                      inconsistencies among regions.
213   */
214  CompletableFuture<Void> modifyTable(TableDescriptor desc, boolean reopenRegions);
215
216  /**
217   * Change the store file tracker of the given table.
218   * @param tableName the table you want to change
219   * @param dstSFT    the destination store file tracker
220   */
221  CompletableFuture<Void> modifyTableStoreFileTracker(TableName tableName, String dstSFT);
222
223  /**
224   * Deletes a table.
225   * @param tableName name of table to delete
226   */
227  CompletableFuture<Void> deleteTable(TableName tableName);
228
229  /**
230   * Truncate a table.
231   * @param tableName      name of table to truncate
232   * @param preserveSplits True if the splits should be preserved
233   */
234  CompletableFuture<Void> truncateTable(TableName tableName, boolean preserveSplits);
235
236  /**
237   * Enable a table. The table has to be in disabled state for it to be enabled.
238   * @param tableName name of the table
239   */
240  CompletableFuture<Void> enableTable(TableName tableName);
241
242  /**
243   * Disable a table. The table has to be in enabled state for it to be disabled.
244   */
245  CompletableFuture<Void> disableTable(TableName tableName);
246
247  /**
248   * Check if a table is enabled.
249   * @param tableName name of table to check
250   * @return true if table is on-line. The return value will be wrapped by a
251   *         {@link CompletableFuture}.
252   */
253  CompletableFuture<Boolean> isTableEnabled(TableName tableName);
254
255  /**
256   * Check if a table is disabled.
257   * @param tableName name of table to check
258   * @return true if table is off-line. The return value will be wrapped by a
259   *         {@link CompletableFuture}.
260   */
261  CompletableFuture<Boolean> isTableDisabled(TableName tableName);
262
263  /**
264   * Check if a table is available.
265   * @param tableName name of table to check
266   * @return true if all regions of the table are available. The return value will be wrapped by a
267   *         {@link CompletableFuture}.
268   */
269  CompletableFuture<Boolean> isTableAvailable(TableName tableName);
270
271  /**
272   * Add a column family to an existing table.
273   * @param tableName    name of the table to add column family to
274   * @param columnFamily column family descriptor of column family to be added
275   */
276  CompletableFuture<Void> addColumnFamily(TableName tableName, ColumnFamilyDescriptor columnFamily);
277
278  /**
279   * Delete a column family from a table.
280   * @param tableName    name of table
281   * @param columnFamily name of column family to be deleted
282   */
283  CompletableFuture<Void> deleteColumnFamily(TableName tableName, byte[] columnFamily);
284
285  /**
286   * Modify an existing column family on a table.
287   * @param tableName    name of table
288   * @param columnFamily new column family descriptor to use
289   */
290  CompletableFuture<Void> modifyColumnFamily(TableName tableName,
291    ColumnFamilyDescriptor columnFamily);
292
293  /**
294   * Change the store file tracker of the given table's given family.
295   * @param tableName the table you want to change
296   * @param family    the family you want to change
297   * @param dstSFT    the destination store file tracker
298   */
299  CompletableFuture<Void> modifyColumnFamilyStoreFileTracker(TableName tableName, byte[] family,
300    String dstSFT);
301
302  /**
303   * Create a new namespace.
304   * @param descriptor descriptor which describes the new namespace
305   */
306  CompletableFuture<Void> createNamespace(NamespaceDescriptor descriptor);
307
308  /**
309   * Modify an existing namespace.
310   * @param descriptor descriptor which describes the new namespace
311   */
312  CompletableFuture<Void> modifyNamespace(NamespaceDescriptor descriptor);
313
314  /**
315   * Delete an existing namespace. Only empty namespaces (no tables) can be removed.
316   * @param name namespace name
317   */
318  CompletableFuture<Void> deleteNamespace(String name);
319
320  /**
321   * Get a namespace descriptor by name
322   * @param name name of namespace descriptor
323   * @return A descriptor wrapped by a {@link CompletableFuture}.
324   */
325  CompletableFuture<NamespaceDescriptor> getNamespaceDescriptor(String name);
326
327  /**
328   * List available namespaces
329   * @return List of namespaces wrapped by a {@link CompletableFuture}.
330   */
331  CompletableFuture<List<String>> listNamespaces();
332
333  /**
334   * List available namespace descriptors
335   * @return List of descriptors wrapped by a {@link CompletableFuture}.
336   */
337  CompletableFuture<List<NamespaceDescriptor>> listNamespaceDescriptors();
338
339  /**
340   * Get all the online regions on a region server.
341   */
342  CompletableFuture<List<RegionInfo>> getRegions(ServerName serverName);
343
344  /**
345   * Get the regions of a given table.
346   */
347  CompletableFuture<List<RegionInfo>> getRegions(TableName tableName);
348
349  /**
350   * Flush a table.
351   * @param tableName table to flush
352   */
353  CompletableFuture<Void> flush(TableName tableName);
354
355  /**
356   * Flush the specified column family stores on all regions of the passed table. This runs as a
357   * synchronous operation.
358   * @param tableName    table to flush
359   * @param columnFamily column family within a table
360   */
361  CompletableFuture<Void> flush(TableName tableName, byte[] columnFamily);
362
363  /**
364   * Flush the specified column family stores on all regions of the passed table. This runs as a
365   * synchronous operation.
366   * @param tableName      table to flush
367   * @param columnFamilies column families within a table
368   */
369  CompletableFuture<Void> flush(TableName tableName, List<byte[]> columnFamilies);
370
371  /**
372   * Flush an individual region.
373   * @param regionName region to flush
374   */
375  CompletableFuture<Void> flushRegion(byte[] regionName);
376
377  /**
378   * Flush a column family within a region.
379   * @param regionName   region to flush
380   * @param columnFamily column family within a region. If not present, flush the region's all
381   *                     column families.
382   */
383  CompletableFuture<Void> flushRegion(byte[] regionName, byte[] columnFamily);
384
385  /**
386   * Flush all region on the region server.
387   * @param serverName server to flush
388   */
389  CompletableFuture<Void> flushRegionServer(ServerName serverName);
390
391  /**
392   * Compact a table. When the returned CompletableFuture is done, it only means the compact request
393   * was sent to HBase and may need some time to finish the compact operation. Throws
394   * {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found.
395   * @param tableName table to compact
396   */
397  default CompletableFuture<Void> compact(TableName tableName) {
398    return compact(tableName, CompactType.NORMAL);
399  }
400
401  /**
402   * Compact a column family within a table. When the returned CompletableFuture is done, it only
403   * means the compact request was sent to HBase and may need some time to finish the compact
404   * operation. Throws {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found.
405   * @param tableName    table to compact
406   * @param columnFamily column family within a table. If not present, compact the table's all
407   *                     column families.
408   */
409  default CompletableFuture<Void> compact(TableName tableName, byte[] columnFamily) {
410    return compact(tableName, columnFamily, CompactType.NORMAL);
411  }
412
413  /**
414   * Compact a table. When the returned CompletableFuture is done, it only means the compact request
415   * was sent to HBase and may need some time to finish the compact operation. Throws
416   * {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found for normal compaction
417   * type.
418   * @param tableName   table to compact
419   * @param compactType {@link org.apache.hadoop.hbase.client.CompactType}
420   */
421  CompletableFuture<Void> compact(TableName tableName, CompactType compactType);
422
423  /**
424   * Compact a column family within a table. When the returned CompletableFuture is done, it only
425   * means the compact request was sent to HBase and may need some time to finish the compact
426   * operation. Throws {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found for
427   * normal compaction type.
428   * @param tableName    table to compact
429   * @param columnFamily column family within a table
430   * @param compactType  {@link org.apache.hadoop.hbase.client.CompactType}
431   */
432  CompletableFuture<Void> compact(TableName tableName, byte[] columnFamily,
433    CompactType compactType);
434
435  /**
436   * Compact an individual region. When the returned CompletableFuture is done, it only means the
437   * compact request was sent to HBase and may need some time to finish the compact operation.
438   * @param regionName region to compact
439   */
440  CompletableFuture<Void> compactRegion(byte[] regionName);
441
442  /**
443   * Compact a column family within a region. When the returned CompletableFuture is done, it only
444   * means the compact request was sent to HBase and may need some time to finish the compact
445   * operation.
446   * @param regionName   region to compact
447   * @param columnFamily column family within a region. If not present, compact the region's all
448   *                     column families.
449   */
450  CompletableFuture<Void> compactRegion(byte[] regionName, byte[] columnFamily);
451
452  /**
453   * Major compact a table. When the returned CompletableFuture is done, it only means the compact
454   * request was sent to HBase and may need some time to finish the compact operation. Throws
455   * {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found.
456   * @param tableName table to major compact
457   */
458  default CompletableFuture<Void> majorCompact(TableName tableName) {
459    return majorCompact(tableName, CompactType.NORMAL);
460  }
461
462  /**
463   * Major compact a column family within a table. When the returned CompletableFuture is done, it
464   * only means the compact request was sent to HBase and may need some time to finish the compact
465   * operation. Throws {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found for
466   * normal compaction. type.
467   * @param tableName    table to major compact
468   * @param columnFamily column family within a table. If not present, major compact the table's all
469   *                     column families.
470   */
471  default CompletableFuture<Void> majorCompact(TableName tableName, byte[] columnFamily) {
472    return majorCompact(tableName, columnFamily, CompactType.NORMAL);
473  }
474
475  /**
476   * Major compact a table. When the returned CompletableFuture is done, it only means the compact
477   * request was sent to HBase and may need some time to finish the compact operation. Throws
478   * {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found for normal compaction
479   * type.
480   * @param tableName   table to major compact
481   * @param compactType {@link org.apache.hadoop.hbase.client.CompactType}
482   */
483  CompletableFuture<Void> majorCompact(TableName tableName, CompactType compactType);
484
485  /**
486   * Major compact a column family within a table. When the returned CompletableFuture is done, it
487   * only means the compact request was sent to HBase and may need some time to finish the compact
488   * operation. Throws {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found.
489   * @param tableName    table to major compact
490   * @param columnFamily column family within a table. If not present, major compact the table's all
491   *                     column families.
492   * @param compactType  {@link org.apache.hadoop.hbase.client.CompactType}
493   */
494  CompletableFuture<Void> majorCompact(TableName tableName, byte[] columnFamily,
495    CompactType compactType);
496
497  /**
498   * Major compact a region. When the returned CompletableFuture is done, it only means the compact
499   * request was sent to HBase and may need some time to finish the compact operation.
500   * @param regionName region to major compact
501   */
502  CompletableFuture<Void> majorCompactRegion(byte[] regionName);
503
504  /**
505   * Major compact a column family within region. When the returned CompletableFuture is done, it
506   * only means the compact request was sent to HBase and may need some time to finish the compact
507   * operation.
508   * @param regionName   region to major compact
509   * @param columnFamily column family within a region. If not present, major compact the region's
510   *                     all column families.
511   */
512  CompletableFuture<Void> majorCompactRegion(byte[] regionName, byte[] columnFamily);
513
514  /**
515   * Compact all regions on the region server.
516   * @param serverName the region server name
517   */
518  CompletableFuture<Void> compactRegionServer(ServerName serverName);
519
520  /**
521   * Compact all regions on the region server.
522   * @param serverName the region server name
523   */
524  CompletableFuture<Void> majorCompactRegionServer(ServerName serverName);
525
526  /**
527   * Turn the Merge switch on or off.
528   * @param enabled enabled or not
529   * @return Previous switch value wrapped by a {@link CompletableFuture}
530   */
531  default CompletableFuture<Boolean> mergeSwitch(boolean enabled) {
532    return mergeSwitch(enabled, false);
533  }
534
535  /**
536   * Turn the Merge switch on or off.
537   * <p/>
538   * Notice that, the method itself is always non-blocking, which means it will always return
539   * immediately. The {@code drainMerges} parameter only effects when will we complete the returned
540   * {@link CompletableFuture}.
541   * @param enabled     enabled or not
542   * @param drainMerges If <code>true</code>, it waits until current merge() call, if outstanding,
543   *                    to return.
544   * @return Previous switch value wrapped by a {@link CompletableFuture}
545   */
546  CompletableFuture<Boolean> mergeSwitch(boolean enabled, boolean drainMerges);
547
548  /**
549   * Query the current state of the Merge switch.
550   * @return true if the switch is on, false otherwise. The return value will be wrapped by a
551   *         {@link CompletableFuture}
552   */
553  CompletableFuture<Boolean> isMergeEnabled();
554
555  /**
556   * Turn the Split switch on or off.
557   * @param enabled enabled or not
558   * @return Previous switch value wrapped by a {@link CompletableFuture}
559   */
560  default CompletableFuture<Boolean> splitSwitch(boolean enabled) {
561    return splitSwitch(enabled, false);
562  }
563
564  /**
565   * Turn the Split switch on or off.
566   * <p/>
567   * Notice that, the method itself is always non-blocking, which means it will always return
568   * immediately. The {@code drainSplits} parameter only effects when will we complete the returned
569   * {@link CompletableFuture}.
570   * @param enabled     enabled or not
571   * @param drainSplits If <code>true</code>, it waits until current split() call, if outstanding,
572   *                    to return.
573   * @return Previous switch value wrapped by a {@link CompletableFuture}
574   */
575  CompletableFuture<Boolean> splitSwitch(boolean enabled, boolean drainSplits);
576
577  /**
578   * Query the current state of the Split switch.
579   * @return true if the switch is on, false otherwise. The return value will be wrapped by a
580   *         {@link CompletableFuture}
581   */
582  CompletableFuture<Boolean> isSplitEnabled();
583
584  /**
585   * Merge two regions.
586   * @param nameOfRegionA encoded or full name of region a
587   * @param nameOfRegionB encoded or full name of region b
588   * @param forcible      true if do a compulsory merge, otherwise we will only merge two adjacent
589   *                      regions
590   * @deprecated since 2.3.0 and will be removed in 4.0.0.Use {@link #mergeRegions(List, boolean)}
591   *             instead.
592   */
593  @Deprecated
594  default CompletableFuture<Void> mergeRegions(byte[] nameOfRegionA, byte[] nameOfRegionB,
595    boolean forcible) {
596    return mergeRegions(Arrays.asList(nameOfRegionA, nameOfRegionB), forcible);
597  }
598
599  /**
600   * Merge multiple regions (>=2).
601   * @param nameOfRegionsToMerge encoded or full name of daughter regions
602   * @param forcible             true if do a compulsory merge, otherwise we will only merge two
603   *                             adjacent regions
604   */
605  CompletableFuture<Void> mergeRegions(List<byte[]> nameOfRegionsToMerge, boolean forcible);
606
607  /**
608   * Split a table. The method will execute split action for each region in table.
609   * @param tableName table to split
610   */
611  CompletableFuture<Void> split(TableName tableName);
612
613  /**
614   * Split an individual region.
615   * @param regionName region to split
616   */
617  CompletableFuture<Void> splitRegion(byte[] regionName);
618
619  /**
620   * Split a table.
621   * @param tableName  table to split
622   * @param splitPoint the explicit position to split on
623   */
624  CompletableFuture<Void> split(TableName tableName, byte[] splitPoint);
625
626  /**
627   * Split an individual region.
628   * @param regionName region to split
629   * @param splitPoint the explicit position to split on. If not present, it will decide by region
630   *                   server.
631   */
632  CompletableFuture<Void> splitRegion(byte[] regionName, byte[] splitPoint);
633
634  /**
635   * Truncate an individual region.
636   * @param regionName region to truncate
637   */
638  CompletableFuture<Void> truncateRegion(byte[] regionName);
639
640  /**
641   * Assign an individual region.
642   * @param regionName Encoded or full name of region to assign.
643   */
644  CompletableFuture<Void> assign(byte[] regionName);
645
646  /**
647   * Unassign a region from current hosting regionserver. Region will then be assigned to a
648   * regionserver chosen at random. Region could be reassigned back to the same server. Use
649   * {@link #move(byte[], ServerName)} if you want to control the region movement.
650   * @param regionName Encoded or full name of region to unassign.
651   */
652  CompletableFuture<Void> unassign(byte[] regionName);
653
654  /**
655   * Unassign a region from current hosting regionserver. Region will then be assigned to a
656   * regionserver chosen at random. Region could be reassigned back to the same server. Use
657   * {@link #move(byte[], ServerName)} if you want to control the region movement.
658   * @param regionName Encoded or full name of region to unassign. Will clear any existing
659   *                   RegionPlan if one found.
660   * @param forcible   If true, force unassign (Will remove region from regions-in-transition too if
661   *                   present. If results in double assignment use hbck -fix to resolve. To be used
662   *                   by experts).
663   * @deprecated since 2.4.0 and will be removed in 4.0.0. Use {@link #unassign(byte[])} instead.
664   * @see <a href="https://issues.apache.org/jira/browse/HBASE-24875">HBASE-24875</a>
665   */
666  @Deprecated
667  default CompletableFuture<Void> unassign(byte[] regionName, boolean forcible) {
668    return unassign(regionName);
669  }
670
671  /**
672   * Offline specified region from master's in-memory state. It will not attempt to reassign the
673   * region as in unassign. This API can be used when a region not served by any region server and
674   * still online as per Master's in memory state. If this API is incorrectly used on active region
675   * then master will loose track of that region. This is a special method that should be used by
676   * experts or hbck.
677   * @param regionName Encoded or full name of region to offline
678   */
679  CompletableFuture<Void> offline(byte[] regionName);
680
681  /**
682   * Move the region <code>r</code> to a random server.
683   * @param regionName Encoded or full name of region to move.
684   */
685  CompletableFuture<Void> move(byte[] regionName);
686
687  /**
688   * Move the region <code>r</code> to <code>dest</code>.
689   * @param regionName     Encoded or full name of region to move.
690   * @param destServerName The servername of the destination regionserver. If not present, we'll
691   *                       assign to a random server. A server name is made of host, port and
692   *                       startcode. Here is an example:
693   *                       <code> host187.example.com,60020,1289493121758</code>
694   */
695  CompletableFuture<Void> move(byte[] regionName, ServerName destServerName);
696
697  /**
698   * Apply the new quota settings.
699   * @param quota the quota settings
700   */
701  CompletableFuture<Void> setQuota(QuotaSettings quota);
702
703  /**
704   * List the quotas based on the filter.
705   * @param filter the quota settings filter
706   * @return the QuotaSetting list, which wrapped by a CompletableFuture.
707   */
708  CompletableFuture<List<QuotaSettings>> getQuota(QuotaFilter filter);
709
710  /**
711   * Add a new replication peer for replicating data to slave cluster
712   * @param peerId     a short name that identifies the peer
713   * @param peerConfig configuration for the replication slave cluster
714   */
715  default CompletableFuture<Void> addReplicationPeer(String peerId,
716    ReplicationPeerConfig peerConfig) {
717    return addReplicationPeer(peerId, peerConfig, true);
718  }
719
720  /**
721   * Add a new replication peer for replicating data to slave cluster
722   * @param peerId     a short name that identifies the peer
723   * @param peerConfig configuration for the replication slave cluster
724   * @param enabled    peer state, true if ENABLED and false if DISABLED
725   */
726  CompletableFuture<Void> addReplicationPeer(String peerId, ReplicationPeerConfig peerConfig,
727    boolean enabled);
728
729  /**
730   * Remove a peer and stop the replication
731   * @param peerId a short name that identifies the peer
732   */
733  CompletableFuture<Void> removeReplicationPeer(String peerId);
734
735  /**
736   * Restart the replication stream to the specified peer
737   * @param peerId a short name that identifies the peer
738   */
739  CompletableFuture<Void> enableReplicationPeer(String peerId);
740
741  /**
742   * Stop the replication stream to the specified peer
743   * @param peerId a short name that identifies the peer
744   */
745  CompletableFuture<Void> disableReplicationPeer(String peerId);
746
747  /**
748   * Returns the configured ReplicationPeerConfig for the specified peer
749   * @param peerId a short name that identifies the peer
750   * @return ReplicationPeerConfig for the peer wrapped by a {@link CompletableFuture}.
751   */
752  CompletableFuture<ReplicationPeerConfig> getReplicationPeerConfig(String peerId);
753
754  /**
755   * Update the peerConfig for the specified peer
756   * @param peerId     a short name that identifies the peer
757   * @param peerConfig new config for the peer
758   */
759  CompletableFuture<Void> updateReplicationPeerConfig(String peerId,
760    ReplicationPeerConfig peerConfig);
761
762  /**
763   * Transit current cluster to a new state in a synchronous replication peer.
764   * @param peerId a short name that identifies the peer
765   * @param state  a new state of current cluster
766   */
767  CompletableFuture<Void> transitReplicationPeerSyncReplicationState(String peerId,
768    SyncReplicationState state);
769
770  /**
771   * Get the current cluster state in a synchronous replication peer.
772   * @param peerId a short name that identifies the peer
773   * @return the current cluster state wrapped by a {@link CompletableFuture}.
774   */
775  default CompletableFuture<SyncReplicationState>
776    getReplicationPeerSyncReplicationState(String peerId) {
777    CompletableFuture<SyncReplicationState> future = new CompletableFuture<>();
778    addListener(listReplicationPeers(Pattern.compile(peerId)), (peers, error) -> {
779      if (error != null) {
780        future.completeExceptionally(error);
781      } else if (peers.isEmpty() || !peers.get(0).getPeerId().equals(peerId)) {
782        future
783          .completeExceptionally(new IOException("Replication peer " + peerId + " does not exist"));
784      } else {
785        future.complete(peers.get(0).getSyncReplicationState());
786      }
787    });
788    return future;
789  }
790
791  /**
792   * Append the replicable table-cf config of the specified peer
793   * @param peerId   a short that identifies the cluster
794   * @param tableCfs A map from tableName to column family names
795   */
796  CompletableFuture<Void> appendReplicationPeerTableCFs(String peerId,
797    Map<TableName, List<String>> tableCfs);
798
799  /**
800   * Remove some table-cfs from config of the specified peer
801   * @param peerId   a short name that identifies the cluster
802   * @param tableCfs A map from tableName to column family names
803   */
804  CompletableFuture<Void> removeReplicationPeerTableCFs(String peerId,
805    Map<TableName, List<String>> tableCfs);
806
807  /**
808   * Return a list of replication peers.
809   * @return a list of replication peers description. The return value will be wrapped by a
810   *         {@link CompletableFuture}.
811   */
812  CompletableFuture<List<ReplicationPeerDescription>> listReplicationPeers();
813
814  /**
815   * Return a list of replication peers.
816   * @param pattern The compiled regular expression to match peer id
817   * @return a list of replication peers description. The return value will be wrapped by a
818   *         {@link CompletableFuture}.
819   */
820  CompletableFuture<List<ReplicationPeerDescription>> listReplicationPeers(Pattern pattern);
821
822  /**
823   * Find all table and column families that are replicated from this cluster
824   * @return the replicated table-cfs list of this cluster. The return value will be wrapped by a
825   *         {@link CompletableFuture}.
826   */
827  CompletableFuture<List<TableCFs>> listReplicatedTableCFs();
828
829  /**
830   * Enable a table's replication switch.
831   * @param tableName name of the table
832   */
833  CompletableFuture<Void> enableTableReplication(TableName tableName);
834
835  /**
836   * Disable a table's replication switch.
837   * @param tableName name of the table
838   */
839  CompletableFuture<Void> disableTableReplication(TableName tableName);
840
841  /**
842   * Check if a replication peer is enabled.
843   * @param peerId id of replication peer to check
844   * @return true if replication peer is enabled. The return value will be wrapped by a
845   *         {@link CompletableFuture}
846   */
847  CompletableFuture<Boolean> isReplicationPeerEnabled(String peerId);
848
849  /**
850   * Enable or disable replication peer modification.
851   * <p/>
852   * This is especially useful when you want to change the replication peer storage.
853   * @param on {@code true} means enable, otherwise disable
854   * @return the previous enable/disable state wrapped by a {@link CompletableFuture}
855   */
856  default CompletableFuture<Boolean> replicationPeerModificationSwitch(boolean on) {
857    return replicationPeerModificationSwitch(on, false);
858  }
859
860  /**
861   * Enable or disable replication peer modification.
862   * <p/>
863   * This is especially useful when you want to change the replication peer storage.
864   * @param on              {@code true} means enable, otherwise disable
865   * @param drainProcedures if {@code true}, will wait until all the running replication peer
866   *                        modification procedures finish
867   * @return the previous enable/disable state wrapped by a {@link CompletableFuture}
868   */
869  CompletableFuture<Boolean> replicationPeerModificationSwitch(boolean on, boolean drainProcedures);
870
871  /**
872   * Check whether replication peer modification is enabled.
873   * @return {@code true} if modification is enabled, otherwise {@code false}, wrapped by a
874   *         {@link CompletableFuture}
875   */
876  CompletableFuture<Boolean> isReplicationPeerModificationEnabled();
877
878  /**
879   * Take a snapshot for the given table. If the table is enabled, a FLUSH-type snapshot will be
880   * taken. If the table is disabled, an offline snapshot is taken. Snapshots are taken sequentially
881   * even when requested concurrently, across all tables. Snapshots are considered unique based on
882   * <b>the name of the snapshot</b>. Attempts to take a snapshot with the same name (even a
883   * different type or with different parameters) will fail with a
884   * {@link org.apache.hadoop.hbase.snapshot.SnapshotCreationException} indicating the duplicate
885   * naming. Snapshot names follow the same naming constraints as tables in HBase. See
886   * {@link org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}.
887   * @param snapshotName name of the snapshot to be created
888   * @param tableName    name of the table for which snapshot is created
889   */
890  default CompletableFuture<Void> snapshot(String snapshotName, TableName tableName) {
891    return snapshot(snapshotName, tableName, SnapshotType.FLUSH);
892  }
893
894  /**
895   * Create typed snapshot of the table. Snapshots are considered unique based on <b>the name of the
896   * snapshot</b>. Snapshots are taken sequentially even when requested concurrently, across all
897   * tables. Attempts to take a snapshot with the same name (even a different type or with different
898   * parameters) will fail with a {@link org.apache.hadoop.hbase.snapshot.SnapshotCreationException}
899   * indicating the duplicate naming. Snapshot names follow the same naming constraints as tables in
900   * HBase. See {@link org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}.
901   * @param snapshotName name to give the snapshot on the filesystem. Must be unique from all other
902   *                     snapshots stored on the cluster
903   * @param tableName    name of the table to snapshot
904   * @param type         type of snapshot to take
905   */
906  default CompletableFuture<Void> snapshot(String snapshotName, TableName tableName,
907    SnapshotType type) {
908    return snapshot(new SnapshotDescription(snapshotName, tableName, type));
909  }
910
911  /**
912   * Take a snapshot and wait for the server to complete that snapshot asynchronously. Snapshots are
913   * taken sequentially even when requested concurrently, across all tables. Snapshots are
914   * considered unique based on <b>the name of the snapshot</b>. Attempts to take a snapshot with
915   * the same name (even a different type or with different parameters) will fail with a
916   * {@link org.apache.hadoop.hbase.snapshot.SnapshotCreationException} indicating the duplicate
917   * naming. Snapshot names follow the same naming constraints as tables in HBase. See
918   * {@link org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}. You should
919   * probably use {@link #snapshot(String, org.apache.hadoop.hbase.TableName)} unless you are sure
920   * about the type of snapshot that you want to take.
921   * @param snapshot snapshot to take
922   */
923  CompletableFuture<Void> snapshot(SnapshotDescription snapshot);
924
925  /**
926   * Check the current state of the passed snapshot. There are three possible states:
927   * <ol>
928   * <li>running - returns <tt>false</tt></li>
929   * <li>finished - returns <tt>true</tt></li>
930   * <li>finished with error - throws the exception that caused the snapshot to fail</li>
931   * </ol>
932   * The cluster only knows about the most recent snapshot. Therefore, if another snapshot has been
933   * run/started since the snapshot you are checking, you will receive an
934   * {@link org.apache.hadoop.hbase.snapshot.UnknownSnapshotException}.
935   * @param snapshot description of the snapshot to check
936   * @return <tt>true</tt> if the snapshot is completed, <tt>false</tt> if the snapshot is still
937   *         running
938   */
939  CompletableFuture<Boolean> isSnapshotFinished(SnapshotDescription snapshot);
940
941  /**
942   * Restore the specified snapshot on the original table. (The table must be disabled) If the
943   * "hbase.snapshot.restore.take.failsafe.snapshot" configuration property is set to true, a
944   * snapshot of the current table is taken before executing the restore operation. In case of
945   * restore failure, the failsafe snapshot will be restored. If the restore completes without
946   * problem the failsafe snapshot is deleted.
947   * @param snapshotName name of the snapshot to restore
948   */
949  CompletableFuture<Void> restoreSnapshot(String snapshotName);
950
951  /**
952   * Restore the specified snapshot on the original table. (The table must be disabled) If
953   * 'takeFailSafeSnapshot' is set to true, a snapshot of the current table is taken before
954   * executing the restore operation. In case of restore failure, the failsafe snapshot will be
955   * restored. If the restore completes without problem the failsafe snapshot is deleted. The
956   * failsafe snapshot name is configurable by using the property
957   * "hbase.snapshot.restore.failsafe.name".
958   * @param snapshotName         name of the snapshot to restore
959   * @param takeFailSafeSnapshot true if the failsafe snapshot should be taken
960   */
961  default CompletableFuture<Void> restoreSnapshot(String snapshotName,
962    boolean takeFailSafeSnapshot) {
963    return restoreSnapshot(snapshotName, takeFailSafeSnapshot, false);
964  }
965
966  /**
967   * Restore the specified snapshot on the original table. (The table must be disabled) If
968   * 'takeFailSafeSnapshot' is set to true, a snapshot of the current table is taken before
969   * executing the restore operation. In case of restore failure, the failsafe snapshot will be
970   * restored. If the restore completes without problem the failsafe snapshot is deleted. The
971   * failsafe snapshot name is configurable by using the property
972   * "hbase.snapshot.restore.failsafe.name".
973   * @param snapshotName         name of the snapshot to restore
974   * @param takeFailSafeSnapshot true if the failsafe snapshot should be taken
975   * @param restoreAcl           <code>true</code> to restore acl of snapshot
976   */
977  CompletableFuture<Void> restoreSnapshot(String snapshotName, boolean takeFailSafeSnapshot,
978    boolean restoreAcl);
979
980  /**
981   * Create a new table by cloning the snapshot content.
982   * @param snapshotName name of the snapshot to be cloned
983   * @param tableName    name of the table where the snapshot will be restored
984   */
985  default CompletableFuture<Void> cloneSnapshot(String snapshotName, TableName tableName) {
986    return cloneSnapshot(snapshotName, tableName, false);
987  }
988
989  /**
990   * Create a new table by cloning the snapshot content.
991   * @param snapshotName name of the snapshot to be cloned
992   * @param tableName    name of the table where the snapshot will be restored
993   * @param restoreAcl   <code>true</code> to restore acl of snapshot
994   */
995  default CompletableFuture<Void> cloneSnapshot(String snapshotName, TableName tableName,
996    boolean restoreAcl) {
997    return cloneSnapshot(snapshotName, tableName, restoreAcl, null);
998  }
999
1000  /**
1001   * Create a new table by cloning the snapshot content.
1002   * @param snapshotName name of the snapshot to be cloned
1003   * @param tableName    name of the table where the snapshot will be restored
1004   * @param restoreAcl   <code>true</code> to restore acl of snapshot
1005   * @param customSFT    specify the StroreFileTracker used for the table
1006   */
1007  CompletableFuture<Void> cloneSnapshot(String snapshotName, TableName tableName,
1008    boolean restoreAcl, String customSFT);
1009
1010  /**
1011   * List completed snapshots.
1012   * @return a list of snapshot descriptors for completed snapshots wrapped by a
1013   *         {@link CompletableFuture}
1014   */
1015  CompletableFuture<List<SnapshotDescription>> listSnapshots();
1016
1017  /**
1018   * List all the completed snapshots matching the given pattern.
1019   * @param pattern The compiled regular expression to match against
1020   * @return - returns a List of SnapshotDescription wrapped by a {@link CompletableFuture}
1021   */
1022  CompletableFuture<List<SnapshotDescription>> listSnapshots(Pattern pattern);
1023
1024  /**
1025   * List all the completed snapshots matching the given table name pattern.
1026   * @param tableNamePattern The compiled table name regular expression to match against
1027   * @return - returns a List of completed SnapshotDescription wrapped by a
1028   *         {@link CompletableFuture}
1029   */
1030  CompletableFuture<List<SnapshotDescription>> listTableSnapshots(Pattern tableNamePattern);
1031
1032  /**
1033   * List all the completed snapshots matching the given table name regular expression and snapshot
1034   * name regular expression.
1035   * @param tableNamePattern    The compiled table name regular expression to match against
1036   * @param snapshotNamePattern The compiled snapshot name regular expression to match against
1037   * @return - returns a List of completed SnapshotDescription wrapped by a
1038   *         {@link CompletableFuture}
1039   */
1040  CompletableFuture<List<SnapshotDescription>> listTableSnapshots(Pattern tableNamePattern,
1041    Pattern snapshotNamePattern);
1042
1043  /**
1044   * Delete an existing snapshot.
1045   * @param snapshotName name of the snapshot
1046   */
1047  CompletableFuture<Void> deleteSnapshot(String snapshotName);
1048
1049  /**
1050   * Delete all existing snapshots.
1051   */
1052  CompletableFuture<Void> deleteSnapshots();
1053
1054  /**
1055   * Delete existing snapshots whose names match the pattern passed.
1056   * @param pattern pattern for names of the snapshot to match
1057   */
1058  CompletableFuture<Void> deleteSnapshots(Pattern pattern);
1059
1060  /**
1061   * Delete all existing snapshots matching the given table name pattern.
1062   * @param tableNamePattern The compiled table name regular expression to match against
1063   */
1064  CompletableFuture<Void> deleteTableSnapshots(Pattern tableNamePattern);
1065
1066  /**
1067   * Delete all existing snapshots matching the given table name regular expression and snapshot
1068   * name regular expression.
1069   * @param tableNamePattern    The compiled table name regular expression to match against
1070   * @param snapshotNamePattern The compiled snapshot name regular expression to match against
1071   */
1072  CompletableFuture<Void> deleteTableSnapshots(Pattern tableNamePattern,
1073    Pattern snapshotNamePattern);
1074
1075  /**
1076   * Execute a distributed procedure on a cluster.
1077   * @param signature A distributed procedure is uniquely identified by its signature (default the
1078   *                  root ZK node name of the procedure).
1079   * @param instance  The instance name of the procedure. For some procedures, this parameter is
1080   *                  optional.
1081   * @param props     Property/Value pairs of properties passing to the procedure
1082   */
1083  CompletableFuture<Void> execProcedure(String signature, String instance,
1084    Map<String, String> props);
1085
1086  /**
1087   * Execute a distributed procedure on a cluster.
1088   * @param signature A distributed procedure is uniquely identified by its signature (default the
1089   *                  root ZK node name of the procedure).
1090   * @param instance  The instance name of the procedure. For some procedures, this parameter is
1091   *                  optional.
1092   * @param props     Property/Value pairs of properties passing to the procedure
1093   * @return data returned after procedure execution. null if no return data.
1094   */
1095  CompletableFuture<byte[]> execProcedureWithReturn(String signature, String instance,
1096    Map<String, String> props);
1097
1098  /**
1099   * Check the current state of the specified procedure. There are three possible states:
1100   * <ol>
1101   * <li>running - returns <tt>false</tt></li>
1102   * <li>finished - returns <tt>true</tt></li>
1103   * <li>finished with error - throws the exception that caused the procedure to fail</li>
1104   * </ol>
1105   * @param signature The signature that uniquely identifies a procedure
1106   * @param instance  The instance name of the procedure
1107   * @param props     Property/Value pairs of properties passing to the procedure
1108   * @return true if the specified procedure is finished successfully, false if it is still running.
1109   *         The value is wrapped by {@link CompletableFuture}
1110   */
1111  CompletableFuture<Boolean> isProcedureFinished(String signature, String instance,
1112    Map<String, String> props);
1113
1114  /**
1115   * Abort a procedure Do not use. Usually it is ignored but if not, it can do more damage than
1116   * good. See hbck2.
1117   * @param procId                ID of the procedure to abort
1118   * @param mayInterruptIfRunning if the proc completed at least one step, should it be aborted?
1119   * @return true if aborted, false if procedure already completed or does not exist. the value is
1120   *         wrapped by {@link CompletableFuture}
1121   * @deprecated since 2.1.1 and will be removed in 4.0.0.
1122   * @see <a href="https://issues.apache.org/jira/browse/HBASE-21223">HBASE-21223</a>
1123   */
1124  @Deprecated
1125  CompletableFuture<Boolean> abortProcedure(long procId, boolean mayInterruptIfRunning);
1126
1127  /**
1128   * List procedures
1129   * @return procedure list JSON wrapped by {@link CompletableFuture}
1130   */
1131  CompletableFuture<String> getProcedures();
1132
1133  /**
1134   * List locks.
1135   * @return lock list JSON wrapped by {@link CompletableFuture}
1136   */
1137  CompletableFuture<String> getLocks();
1138
1139  /**
1140   * Mark region server(s) as decommissioned to prevent additional regions from getting assigned to
1141   * them. Optionally unload the regions on the servers. If there are multiple servers to be
1142   * decommissioned, decommissioning them at the same time can prevent wasteful region movements.
1143   * Region unloading is asynchronous.
1144   * @param servers The list of servers to decommission.
1145   * @param offload True to offload the regions from the decommissioned servers
1146   */
1147  CompletableFuture<Void> decommissionRegionServers(List<ServerName> servers, boolean offload);
1148
1149  /**
1150   * List region servers marked as decommissioned, which can not be assigned regions.
1151   * @return List of decommissioned region servers wrapped by {@link CompletableFuture}
1152   */
1153  CompletableFuture<List<ServerName>> listDecommissionedRegionServers();
1154
1155  /**
1156   * Remove decommission marker from a region server to allow regions assignments. Load regions onto
1157   * the server if a list of regions is given. Region loading is asynchronous.
1158   * @param server             The server to recommission.
1159   * @param encodedRegionNames Regions to load onto the server.
1160   */
1161  CompletableFuture<Void> recommissionRegionServer(ServerName server,
1162    List<byte[]> encodedRegionNames);
1163
1164  /** Returns cluster status wrapped by {@link CompletableFuture} */
1165  CompletableFuture<ClusterMetrics> getClusterMetrics();
1166
1167  /** Returns cluster status wrapped by {@link CompletableFuture} */
1168  CompletableFuture<ClusterMetrics> getClusterMetrics(EnumSet<Option> options);
1169
1170  /** Returns current master server name wrapped by {@link CompletableFuture} */
1171  default CompletableFuture<ServerName> getMaster() {
1172    return getClusterMetrics(EnumSet.of(Option.MASTER)).thenApply(ClusterMetrics::getMasterName);
1173  }
1174
1175  /** Returns current backup master list wrapped by {@link CompletableFuture} */
1176  default CompletableFuture<Collection<ServerName>> getBackupMasters() {
1177    return getClusterMetrics(EnumSet.of(Option.BACKUP_MASTERS))
1178      .thenApply(ClusterMetrics::getBackupMasterNames);
1179  }
1180
1181  /** Returns current live region servers list wrapped by {@link CompletableFuture} */
1182  default CompletableFuture<Collection<ServerName>> getRegionServers() {
1183    return getClusterMetrics(EnumSet.of(Option.SERVERS_NAME))
1184      .thenApply(ClusterMetrics::getServersName);
1185  }
1186
1187  default CompletableFuture<Collection<ServerName>>
1188    getRegionServers(boolean excludeDecommissionedRS) {
1189    CompletableFuture<Collection<ServerName>> future = new CompletableFuture<>();
1190    addListener(
1191      getClusterMetrics(EnumSet.of(Option.SERVERS_NAME)).thenApply(ClusterMetrics::getServersName),
1192      (allServers, err) -> {
1193        if (err != null) {
1194          future.completeExceptionally(err);
1195        } else {
1196          if (!excludeDecommissionedRS) {
1197            future.complete(allServers);
1198          } else {
1199            addListener(listDecommissionedRegionServers(), (decomServers, decomErr) -> {
1200              if (decomErr != null) {
1201                future.completeExceptionally(decomErr);
1202              } else {
1203                future.complete(allServers.stream().filter(s -> !decomServers.contains(s))
1204                  .collect(ImmutableList.toImmutableList()));
1205              }
1206            });
1207          }
1208        }
1209      });
1210    return future;
1211  }
1212
1213  /** Returns a list of master coprocessors wrapped by {@link CompletableFuture} */
1214  default CompletableFuture<List<String>> getMasterCoprocessorNames() {
1215    return getClusterMetrics(EnumSet.of(Option.MASTER_COPROCESSORS))
1216      .thenApply(ClusterMetrics::getMasterCoprocessorNames);
1217  }
1218
1219  /**
1220   * Get the info port of the current master if one is available.
1221   * @return master info port
1222   */
1223  default CompletableFuture<Integer> getMasterInfoPort() {
1224    return getClusterMetrics(EnumSet.of(Option.MASTER_INFO_PORT))
1225      .thenApply(ClusterMetrics::getMasterInfoPort);
1226  }
1227
1228  /**
1229   * Shuts down the HBase cluster.
1230   */
1231  CompletableFuture<Void> shutdown();
1232
1233  /**
1234   * Shuts down the current HBase master only.
1235   */
1236  CompletableFuture<Void> stopMaster();
1237
1238  /**
1239   * Stop the designated regionserver.
1240   */
1241  CompletableFuture<Void> stopRegionServer(ServerName serverName);
1242
1243  /**
1244   * Update the configuration and trigger an online config change on the regionserver.
1245   * @param serverName : The server whose config needs to be updated.
1246   */
1247  CompletableFuture<Void> updateConfiguration(ServerName serverName);
1248
1249  /**
1250   * Update the configuration and trigger an online config change on all the masters and
1251   * regionservers.
1252   */
1253  CompletableFuture<Void> updateConfiguration();
1254
1255  /**
1256   * Update the configuration and trigger an online config change on all the regionservers in the
1257   * RSGroup.
1258   * @param groupName the group name
1259   */
1260  CompletableFuture<Void> updateConfiguration(String groupName);
1261
1262  /**
1263   * Roll the log writer. I.e. for filesystem based write ahead logs, start writing to a new file.
1264   * <p>
1265   * When the returned CompletableFuture is done, it only means the rollWALWriter request was sent
1266   * to the region server and may need some time to finish the rollWALWriter operation. As a side
1267   * effect of this call, the named region server may schedule store flushes at the request of the
1268   * wal.
1269   * @param serverName The servername of the region server.
1270   */
1271  CompletableFuture<Void> rollWALWriter(ServerName serverName);
1272
1273  /**
1274   * Clear compacting queues on a region server.
1275   * @param serverName The servername of the region server.
1276   * @param queues     the set of queue name
1277   */
1278  CompletableFuture<Void> clearCompactionQueues(ServerName serverName, Set<String> queues);
1279
1280  /**
1281   * Get a list of {@link RegionMetrics} of all regions hosted on a region server.
1282   * @return list of {@link RegionMetrics} wrapped by {@link CompletableFuture}
1283   */
1284  CompletableFuture<List<RegionMetrics>> getRegionMetrics(ServerName serverName);
1285
1286  /**
1287   * Get a list of {@link RegionMetrics} of all regions hosted on a region server for a table.
1288   * @return a list of {@link RegionMetrics} wrapped by {@link CompletableFuture}
1289   */
1290  CompletableFuture<List<RegionMetrics>> getRegionMetrics(ServerName serverName,
1291    TableName tableName);
1292
1293  /**
1294   * Check whether master is in maintenance mode
1295   * @return true if master is in maintenance mode, false otherwise. The return value will be
1296   *         wrapped by a {@link CompletableFuture}
1297   */
1298  CompletableFuture<Boolean> isMasterInMaintenanceMode();
1299
1300  /**
1301   * Get the current compaction state of a table. It could be in a major compaction, a minor
1302   * compaction, both, or none.
1303   * @param tableName table to examine
1304   * @return the current compaction state wrapped by a {@link CompletableFuture}
1305   */
1306  default CompletableFuture<CompactionState> getCompactionState(TableName tableName) {
1307    return getCompactionState(tableName, CompactType.NORMAL);
1308  }
1309
1310  /**
1311   * Get the current compaction state of a table. It could be in a major compaction, a minor
1312   * compaction, both, or none.
1313   * @param tableName   table to examine
1314   * @param compactType {@link org.apache.hadoop.hbase.client.CompactType}
1315   * @return the current compaction state wrapped by a {@link CompletableFuture}
1316   */
1317  CompletableFuture<CompactionState> getCompactionState(TableName tableName,
1318    CompactType compactType);
1319
1320  /**
1321   * Get the current compaction state of region. It could be in a major compaction, a minor
1322   * compaction, both, or none.
1323   * @param regionName region to examine
1324   * @return the current compaction state wrapped by a {@link CompletableFuture}
1325   */
1326  CompletableFuture<CompactionState> getCompactionStateForRegion(byte[] regionName);
1327
1328  /**
1329   * Get the timestamp of the last major compaction for the passed table.
1330   * <p>
1331   * The timestamp of the oldest HFile resulting from a major compaction of that table, or not
1332   * present if no such HFile could be found.
1333   * @param tableName table to examine
1334   * @return the last major compaction timestamp wrapped by a {@link CompletableFuture}
1335   */
1336  CompletableFuture<Optional<Long>> getLastMajorCompactionTimestamp(TableName tableName);
1337
1338  /**
1339   * Get the timestamp of the last major compaction for the passed region.
1340   * <p>
1341   * The timestamp of the oldest HFile resulting from a major compaction of that region, or not
1342   * present if no such HFile could be found.
1343   * @param regionName region to examine
1344   * @return the last major compaction timestamp wrapped by a {@link CompletableFuture}
1345   */
1346  CompletableFuture<Optional<Long>> getLastMajorCompactionTimestampForRegion(byte[] regionName);
1347
1348  /**
1349   * Returns the list of supported security capabilities. The return value will be wrapped by a
1350   * {@link CompletableFuture}.
1351   */
1352  CompletableFuture<List<SecurityCapability>> getSecurityCapabilities();
1353
1354  /**
1355   * Turn the load balancer on or off.
1356   * @param on Set to <code>true</code> to enable, <code>false</code> to disable.
1357   * @return Previous balancer value wrapped by a {@link CompletableFuture}.
1358   */
1359  default CompletableFuture<Boolean> balancerSwitch(boolean on) {
1360    return balancerSwitch(on, false);
1361  }
1362
1363  /**
1364   * Turn the load balancer on or off.
1365   * <p/>
1366   * Notice that, the method itself is always non-blocking, which means it will always return
1367   * immediately. The {@code drainRITs} parameter only effects when will we complete the returned
1368   * {@link CompletableFuture}.
1369   * @param on        Set to <code>true</code> to enable, <code>false</code> to disable.
1370   * @param drainRITs If <code>true</code>, it waits until current balance() call, if outstanding,
1371   *                  to return.
1372   * @return Previous balancer value wrapped by a {@link CompletableFuture}.
1373   */
1374  CompletableFuture<Boolean> balancerSwitch(boolean on, boolean drainRITs);
1375
1376  /**
1377   * Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the
1378   * reassignments. Can NOT run for various reasons. Check logs.
1379   * @return True if balancer ran, false otherwise. The return value will be wrapped by a
1380   *         {@link CompletableFuture}.
1381   */
1382  default CompletableFuture<Boolean> balance() {
1383    return balance(BalanceRequest.defaultInstance()).thenApply(BalanceResponse::isBalancerRan);
1384  }
1385
1386  /**
1387   * Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the
1388   * reassignments. If there is region in transition, force parameter of true would still run
1389   * balancer. Can *not* run for other reasons. Check logs.
1390   * @param forcible whether we should force balance even if there is region in transition.
1391   * @return True if balancer ran, false otherwise. The return value will be wrapped by a
1392   *         {@link CompletableFuture}.
1393   * @deprecated Since 2.5.0. Will be removed in 4.0.0. Use {@link #balance(BalanceRequest)}
1394   *             instead.
1395   */
1396  @Deprecated
1397  default CompletableFuture<Boolean> balance(boolean forcible) {
1398    return balance(BalanceRequest.newBuilder().setIgnoreRegionsInTransition(forcible).build())
1399      .thenApply(BalanceResponse::isBalancerRan);
1400  }
1401
1402  /**
1403   * Invoke the balancer with the given balance request. The BalanceRequest defines how the balancer
1404   * will run. See {@link BalanceRequest} for more details.
1405   * @param request defines how the balancer should run
1406   * @return {@link BalanceResponse} with details about the results of the invocation.
1407   */
1408  CompletableFuture<BalanceResponse> balance(BalanceRequest request);
1409
1410  /**
1411   * Query the current state of the balancer.
1412   * @return true if the balance switch is on, false otherwise. The return value will be wrapped by
1413   *         a {@link CompletableFuture}.
1414   */
1415  CompletableFuture<Boolean> isBalancerEnabled();
1416
1417  /**
1418   * Set region normalizer on/off.
1419   * @param on whether normalizer should be on or off
1420   * @return Previous normalizer value wrapped by a {@link CompletableFuture}
1421   */
1422  CompletableFuture<Boolean> normalizerSwitch(boolean on);
1423
1424  /**
1425   * Query the current state of the region normalizer
1426   * @return true if region normalizer is on, false otherwise. The return value will be wrapped by a
1427   *         {@link CompletableFuture}
1428   */
1429  CompletableFuture<Boolean> isNormalizerEnabled();
1430
1431  /**
1432   * Invoke region normalizer. Can NOT run for various reasons. Check logs.
1433   * @return true if region normalizer ran, false otherwise. The return value will be wrapped by a
1434   *         {@link CompletableFuture}
1435   */
1436  default CompletableFuture<Boolean> normalize() {
1437    return normalize(new NormalizeTableFilterParams.Builder().build());
1438  }
1439
1440  /**
1441   * Invoke region normalizer. Can NOT run for various reasons. Check logs.
1442   * @param ntfp limit to tables matching the specified filter.
1443   * @return true if region normalizer ran, false otherwise. The return value will be wrapped by a
1444   *         {@link CompletableFuture}
1445   */
1446  CompletableFuture<Boolean> normalize(NormalizeTableFilterParams ntfp);
1447
1448  /**
1449   * Turn the cleaner chore on/off.
1450   * @return Previous cleaner state wrapped by a {@link CompletableFuture}
1451   */
1452  CompletableFuture<Boolean> cleanerChoreSwitch(boolean on);
1453
1454  /**
1455   * Query the current state of the cleaner chore.
1456   * @return true if cleaner chore is on, false otherwise. The return value will be wrapped by a
1457   *         {@link CompletableFuture}
1458   */
1459  CompletableFuture<Boolean> isCleanerChoreEnabled();
1460
1461  /**
1462   * Ask for cleaner chore to run.
1463   * @return true if cleaner chore ran, false otherwise. The return value will be wrapped by a
1464   *         {@link CompletableFuture}
1465   */
1466  CompletableFuture<Boolean> runCleanerChore();
1467
1468  /**
1469   * Turn the catalog janitor on/off.
1470   * @return the previous state wrapped by a {@link CompletableFuture}
1471   */
1472  CompletableFuture<Boolean> catalogJanitorSwitch(boolean on);
1473
1474  /**
1475   * Query on the catalog janitor state.
1476   * @return true if the catalog janitor is on, false otherwise. The return value will be wrapped by
1477   *         a {@link CompletableFuture}
1478   */
1479  CompletableFuture<Boolean> isCatalogJanitorEnabled();
1480
1481  /**
1482   * Ask for a scan of the catalog table.
1483   * @return the number of entries cleaned. The return value will be wrapped by a
1484   *         {@link CompletableFuture}
1485   */
1486  CompletableFuture<Integer> runCatalogJanitor();
1487
1488  /**
1489   * Execute the given coprocessor call on the master.
1490   * <p>
1491   * The {@code stubMaker} is just a delegation to the {@code newStub} call. Usually it is only a
1492   * one line lambda expression, like:
1493   *
1494   * <pre>
1495   * channel -&gt; xxxService.newStub(channel)
1496   * </pre>
1497   *
1498   * @param stubMaker a delegation to the actual {@code newStub} call.
1499   * @param callable  a delegation to the actual protobuf rpc call. See the comment of
1500   *                  {@link ServiceCaller} for more details.
1501   * @param <S>       the type of the asynchronous stub
1502   * @param <R>       the type of the return value
1503   * @return the return value of the protobuf rpc call, wrapped by a {@link CompletableFuture}.
1504   * @see ServiceCaller
1505   */
1506  <S, R> CompletableFuture<R> coprocessorService(Function<RpcChannel, S> stubMaker,
1507    ServiceCaller<S, R> callable);
1508
1509  /**
1510   * Execute the given coprocessor call on the given region server.
1511   * <p>
1512   * The {@code stubMaker} is just a delegation to the {@code newStub} call. Usually it is only a
1513   * one line lambda expression, like:
1514   *
1515   * <pre>
1516   * channel -&gt; xxxService.newStub(channel)
1517   * </pre>
1518   *
1519   * @param stubMaker  a delegation to the actual {@code newStub} call.
1520   * @param callable   a delegation to the actual protobuf rpc call. See the comment of
1521   *                   {@link ServiceCaller} for more details.
1522   * @param serverName the given region server
1523   * @param <S>        the type of the asynchronous stub
1524   * @param <R>        the type of the return value
1525   * @return the return value of the protobuf rpc call, wrapped by a {@link CompletableFuture}.
1526   * @see ServiceCaller
1527   */
1528  <S, R> CompletableFuture<R> coprocessorService(Function<RpcChannel, S> stubMaker,
1529    ServiceCaller<S, R> callable, ServerName serverName);
1530
1531  /**
1532   * List all the dead region servers.
1533   */
1534  default CompletableFuture<List<ServerName>> listDeadServers() {
1535    return this.getClusterMetrics(EnumSet.of(Option.DEAD_SERVERS))
1536      .thenApply(ClusterMetrics::getDeadServerNames);
1537  }
1538
1539  /**
1540   * List all the unknown region servers.
1541   */
1542  default CompletableFuture<List<ServerName>> listUnknownServers() {
1543    return this.getClusterMetrics(EnumSet.of(Option.UNKNOWN_SERVERS))
1544      .thenApply(ClusterMetrics::getUnknownServerNames);
1545  }
1546
1547  /**
1548   * Clear dead region servers from master.
1549   * @param servers list of dead region servers.
1550   * @return - returns a list of servers that not cleared wrapped by a {@link CompletableFuture}.
1551   */
1552  CompletableFuture<List<ServerName>> clearDeadServers(final List<ServerName> servers);
1553
1554  /**
1555   * Clear all the blocks corresponding to this table from BlockCache. For expert-admins. Calling
1556   * this API will drop all the cached blocks specific to a table from BlockCache. This can
1557   * significantly impact the query performance as the subsequent queries will have to retrieve the
1558   * blocks from underlying filesystem.
1559   * @param tableName table to clear block cache
1560   * @return CacheEvictionStats related to the eviction wrapped by a {@link CompletableFuture}.
1561   */
1562  CompletableFuture<CacheEvictionStats> clearBlockCache(final TableName tableName);
1563
1564  /**
1565   * Create a new table by cloning the existent table schema.
1566   * @param tableName      name of the table to be cloned
1567   * @param newTableName   name of the new table where the table will be created
1568   * @param preserveSplits True if the splits should be preserved
1569   */
1570  CompletableFuture<Void> cloneTableSchema(final TableName tableName, final TableName newTableName,
1571    final boolean preserveSplits);
1572
1573  /**
1574   * Turn the compaction on or off. Disabling compactions will also interrupt any currently ongoing
1575   * compactions. This state is ephemeral. The setting will be lost on restart. Compaction can also
1576   * be enabled/disabled by modifying configuration hbase.regionserver.compaction.enabled in
1577   * hbase-site.xml.
1578   * @param switchState     Set to <code>true</code> to enable, <code>false</code> to disable.
1579   * @param serverNamesList list of region servers.
1580   * @return Previous compaction states for region servers
1581   */
1582  CompletableFuture<Map<ServerName, Boolean>> compactionSwitch(boolean switchState,
1583    List<String> serverNamesList);
1584
1585  /**
1586   * Switch the rpc throttle enabled state.
1587   * @param enable Set to <code>true</code> to enable, <code>false</code> to disable.
1588   * @return Previous rpc throttle enabled value
1589   */
1590  CompletableFuture<Boolean> switchRpcThrottle(boolean enable);
1591
1592  /**
1593   * Get if the rpc throttle is enabled.
1594   * @return True if rpc throttle is enabled
1595   */
1596  CompletableFuture<Boolean> isRpcThrottleEnabled();
1597
1598  /**
1599   * Switch the exceed throttle quota. If enabled, user/table/namespace throttle quota can be
1600   * exceeded if region server has availble quota.
1601   * @param enable Set to <code>true</code> to enable, <code>false</code> to disable.
1602   * @return Previous exceed throttle enabled value
1603   */
1604  CompletableFuture<Boolean> exceedThrottleQuotaSwitch(boolean enable);
1605
1606  /**
1607   * Fetches the table sizes on the filesystem as tracked by the HBase Master.
1608   */
1609  CompletableFuture<Map<TableName, Long>> getSpaceQuotaTableSizes();
1610
1611  /**
1612   * Fetches the observed {@link SpaceQuotaSnapshotView}s observed by a RegionServer.
1613   */
1614  CompletableFuture<? extends Map<TableName, ? extends SpaceQuotaSnapshotView>>
1615    getRegionServerSpaceQuotaSnapshots(ServerName serverName);
1616
1617  /**
1618   * Returns the Master's view of a quota on the given {@code namespace} or null if the Master has
1619   * no quota information on that namespace.
1620   */
1621  CompletableFuture<? extends SpaceQuotaSnapshotView>
1622    getCurrentSpaceQuotaSnapshot(String namespace);
1623
1624  /**
1625   * Returns the Master's view of a quota on the given {@code tableName} or null if the Master has
1626   * no quota information on that table.
1627   */
1628  CompletableFuture<? extends SpaceQuotaSnapshotView>
1629    getCurrentSpaceQuotaSnapshot(TableName tableName);
1630
1631  /**
1632   * Grants user specific permissions
1633   * @param userPermission           user name and the specific permission
1634   * @param mergeExistingPermissions If set to false, later granted permissions will override
1635   *                                 previous granted permissions. otherwise, it'll merge with
1636   *                                 previous granted permissions.
1637   */
1638  CompletableFuture<Void> grant(UserPermission userPermission, boolean mergeExistingPermissions);
1639
1640  /**
1641   * Revokes user specific permissions
1642   * @param userPermission user name and the specific permission
1643   */
1644  CompletableFuture<Void> revoke(UserPermission userPermission);
1645
1646  /**
1647   * Get the global/namespace/table permissions for user
1648   * @param getUserPermissionsRequest A request contains which user, global, namespace or table
1649   *                                  permissions needed
1650   * @return The user and permission list
1651   */
1652  CompletableFuture<List<UserPermission>>
1653    getUserPermissions(GetUserPermissionsRequest getUserPermissionsRequest);
1654
1655  /**
1656   * Check if the user has specific permissions
1657   * @param userName    the user name
1658   * @param permissions the specific permission list
1659   * @return True if user has the specific permissions
1660   */
1661  CompletableFuture<List<Boolean>> hasUserPermissions(String userName,
1662    List<Permission> permissions);
1663
1664  /**
1665   * Check if call user has specific permissions
1666   * @param permissions the specific permission list
1667   * @return True if user has the specific permissions
1668   */
1669  default CompletableFuture<List<Boolean>> hasUserPermissions(List<Permission> permissions) {
1670    return hasUserPermissions(null, permissions);
1671  }
1672
1673  /**
1674   * Turn on or off the auto snapshot cleanup based on TTL.
1675   * <p/>
1676   * Notice that, the method itself is always non-blocking, which means it will always return
1677   * immediately. The {@code sync} parameter only effects when will we complete the returned
1678   * {@link CompletableFuture}.
1679   * @param on   Set to <code>true</code> to enable, <code>false</code> to disable.
1680   * @param sync If <code>true</code>, it waits until current snapshot cleanup is completed, if
1681   *             outstanding.
1682   * @return Previous auto snapshot cleanup value wrapped by a {@link CompletableFuture}.
1683   */
1684  CompletableFuture<Boolean> snapshotCleanupSwitch(boolean on, boolean sync);
1685
1686  /**
1687   * Query the current state of the auto snapshot cleanup based on TTL.
1688   * @return true if the auto snapshot cleanup is enabled, false otherwise. The return value will be
1689   *         wrapped by a {@link CompletableFuture}.
1690   */
1691  CompletableFuture<Boolean> isSnapshotCleanupEnabled();
1692
1693  /**
1694   * Retrieves online slow RPC logs from the provided list of RegionServers
1695   * @param serverNames    Server names to get slowlog responses from
1696   * @param logQueryFilter filter to be used if provided
1697   * @return Online slowlog response list. The return value wrapped by a {@link CompletableFuture}
1698   * @deprecated since 2.4.0 and will be removed in 4.0.0. Use
1699   *             {@link #getLogEntries(Set, String, ServerType, int, Map)} instead.
1700   */
1701  @Deprecated
1702  default CompletableFuture<List<OnlineLogRecord>>
1703    getSlowLogResponses(final Set<ServerName> serverNames, final LogQueryFilter logQueryFilter) {
1704    String logType;
1705    if (LogQueryFilter.Type.LARGE_LOG.equals(logQueryFilter.getType())) {
1706      logType = "LARGE_LOG";
1707    } else {
1708      logType = "SLOW_LOG";
1709    }
1710    Map<String, Object> filterParams = new HashMap<>();
1711    filterParams.put("regionName", logQueryFilter.getRegionName());
1712    filterParams.put("clientAddress", logQueryFilter.getClientAddress());
1713    filterParams.put("tableName", logQueryFilter.getTableName());
1714    filterParams.put("userName", logQueryFilter.getUserName());
1715    filterParams.put("filterByOperator", logQueryFilter.getFilterByOperator().toString());
1716    CompletableFuture<List<LogEntry>> logEntries = getLogEntries(serverNames, logType,
1717      ServerType.REGION_SERVER, logQueryFilter.getLimit(), filterParams);
1718    return logEntries.thenApply(logEntryList -> logEntryList.stream()
1719      .map(logEntry -> (OnlineLogRecord) logEntry).collect(Collectors.toList()));
1720  }
1721
1722  /**
1723   * Clears online slow RPC logs from the provided list of RegionServers
1724   * @param serverNames Set of Server names to clean slowlog responses from
1725   * @return List of booleans representing if online slowlog response buffer is cleaned from each
1726   *         RegionServer. The return value wrapped by a {@link CompletableFuture}
1727   */
1728  CompletableFuture<List<Boolean>> clearSlowLogResponses(final Set<ServerName> serverNames);
1729
1730  /**
1731   * Creates a new RegionServer group with the given name
1732   * @param groupName the name of the group
1733   */
1734  CompletableFuture<Void> addRSGroup(String groupName);
1735
1736  /**
1737   * Get group info for the given group name
1738   * @param groupName the group name
1739   * @return group info
1740   */
1741  CompletableFuture<RSGroupInfo> getRSGroup(String groupName);
1742
1743  /**
1744   * Get group info for the given hostPort
1745   * @param hostPort HostPort to get RSGroupInfo for
1746   */
1747  CompletableFuture<RSGroupInfo> getRSGroup(Address hostPort);
1748
1749  /**
1750   * Get group info for the given table
1751   * @param tableName table name to get RSGroupInfo for
1752   */
1753  CompletableFuture<RSGroupInfo> getRSGroup(TableName tableName);
1754
1755  /**
1756   * Lists current set of RegionServer groups
1757   */
1758  CompletableFuture<List<RSGroupInfo>> listRSGroups();
1759
1760  /**
1761   * Get all tables in this RegionServer group.
1762   * @param groupName the group name
1763   * @see #getConfiguredNamespacesAndTablesInRSGroup(String)
1764   */
1765  CompletableFuture<List<TableName>> listTablesInRSGroup(String groupName);
1766
1767  /**
1768   * Get the namespaces and tables which have this RegionServer group in descriptor.
1769   * <p/>
1770   * The difference between this method and {@link #listTablesInRSGroup(String)} is that, this
1771   * method will not include the table which is actually in this RegionServr group but without the
1772   * RegionServer group configuration in its {@link TableDescriptor}. For example, we have a group
1773   * 'A', and we make namespace 'nsA' in this group, then all the tables under this namespace will
1774   * in the group 'A', but this method will not return these tables but only the namespace 'nsA',
1775   * while the {@link #listTablesInRSGroup(String)} will return all these tables.
1776   * @param groupName the group name
1777   * @see #listTablesInRSGroup(String)
1778   */
1779  CompletableFuture<Pair<List<String>, List<TableName>>>
1780    getConfiguredNamespacesAndTablesInRSGroup(String groupName);
1781
1782  /**
1783   * Remove RegionServer group associated with the given name
1784   * @param groupName the group name
1785   */
1786  CompletableFuture<Void> removeRSGroup(String groupName);
1787
1788  /**
1789   * Remove decommissioned servers from group 1. Sometimes we may find the server aborted due to
1790   * some hardware failure and we must offline the server for repairing. Or we need to move some
1791   * servers to join other clusters. So we need to remove these servers from the group. 2.
1792   * Dead/recovering/live servers will be disallowed.
1793   * @param servers set of servers to remove
1794   */
1795  CompletableFuture<Void> removeServersFromRSGroup(Set<Address> servers);
1796
1797  /**
1798   * Move given set of servers to the specified target RegionServer group
1799   * @param servers   set of servers to move
1800   * @param groupName the group to move servers to
1801   */
1802  CompletableFuture<Void> moveServersToRSGroup(Set<Address> servers, String groupName);
1803
1804  /**
1805   * Set the RegionServer group for tables
1806   * @param tables    tables to set group for
1807   * @param groupName group name for tables
1808   */
1809  CompletableFuture<Void> setRSGroup(Set<TableName> tables, String groupName);
1810
1811  /**
1812   * Balance regions in the given RegionServer group
1813   * @param groupName the group name
1814   * @return BalanceResponse details about the balancer run
1815   */
1816  default CompletableFuture<BalanceResponse> balanceRSGroup(String groupName) {
1817    return balanceRSGroup(groupName, BalanceRequest.defaultInstance());
1818  }
1819
1820  /**
1821   * Balance regions in the given RegionServer group
1822   * @param groupName the group name
1823   * @param request   options to define how the balancer should run
1824   * @return BalanceResponse details about the balancer run
1825   */
1826  CompletableFuture<BalanceResponse> balanceRSGroup(String groupName, BalanceRequest request);
1827
1828  /**
1829   * Rename rsgroup
1830   * @param oldName old rsgroup name
1831   * @param newName new rsgroup name
1832   */
1833  CompletableFuture<Void> renameRSGroup(String oldName, String newName);
1834
1835  /**
1836   * Update RSGroup configuration
1837   * @param groupName     the group name
1838   * @param configuration new configuration of the group name to be set
1839   */
1840  CompletableFuture<Void> updateRSGroupConfig(String groupName, Map<String, String> configuration);
1841
1842  /**
1843   * Retrieve recent online records from HMaster / RegionServers. Examples include slow/large RPC
1844   * logs, balancer decisions by master.
1845   * @param serverNames  servers to retrieve records from, useful in case of records maintained by
1846   *                     RegionServer as we can select specific server. In case of
1847   *                     servertype=MASTER, logs will only come from the currently active master.
1848   * @param logType      string representing type of log records
1849   * @param serverType   enum for server type: HMaster or RegionServer
1850   * @param limit        put a limit to list of records that server should send in response
1851   * @param filterParams additional filter params
1852   */
1853  CompletableFuture<List<LogEntry>> getLogEntries(Set<ServerName> serverNames, String logType,
1854    ServerType serverType, int limit, Map<String, Object> filterParams);
1855
1856  /**
1857   * Flush master local region
1858   */
1859  CompletableFuture<Void> flushMasterStore();
1860
1861  /**
1862   * Get the list of cached files
1863   */
1864  CompletableFuture<List<String>> getCachedFilesList(ServerName serverName);
1865}