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  default CompletableFuture<Boolean> balance(boolean forcible) {
1397    return balance(BalanceRequest.newBuilder().setIgnoreRegionsInTransition(forcible).build())
1398      .thenApply(BalanceResponse::isBalancerRan);
1399  }
1400
1401  /**
1402   * Invoke the balancer with the given balance request. The BalanceRequest defines how the balancer
1403   * will run. See {@link BalanceRequest} for more details.
1404   * @param request defines how the balancer should run
1405   * @return {@link BalanceResponse} with details about the results of the invocation.
1406   */
1407  CompletableFuture<BalanceResponse> balance(BalanceRequest request);
1408
1409  /**
1410   * Query the current state of the balancer.
1411   * @return true if the balance switch is on, false otherwise. The return value will be wrapped by
1412   *         a {@link CompletableFuture}.
1413   */
1414  CompletableFuture<Boolean> isBalancerEnabled();
1415
1416  /**
1417   * Set region normalizer on/off.
1418   * @param on whether normalizer should be on or off
1419   * @return Previous normalizer value wrapped by a {@link CompletableFuture}
1420   */
1421  CompletableFuture<Boolean> normalizerSwitch(boolean on);
1422
1423  /**
1424   * Query the current state of the region normalizer
1425   * @return true if region normalizer is on, false otherwise. The return value will be wrapped by a
1426   *         {@link CompletableFuture}
1427   */
1428  CompletableFuture<Boolean> isNormalizerEnabled();
1429
1430  /**
1431   * Invoke region normalizer. Can NOT run for various reasons. Check logs.
1432   * @return true if region normalizer ran, false otherwise. The return value will be wrapped by a
1433   *         {@link CompletableFuture}
1434   */
1435  default CompletableFuture<Boolean> normalize() {
1436    return normalize(new NormalizeTableFilterParams.Builder().build());
1437  }
1438
1439  /**
1440   * Invoke region normalizer. Can NOT run for various reasons. Check logs.
1441   * @param ntfp limit to tables matching the specified filter.
1442   * @return true if region normalizer ran, false otherwise. The return value will be wrapped by a
1443   *         {@link CompletableFuture}
1444   */
1445  CompletableFuture<Boolean> normalize(NormalizeTableFilterParams ntfp);
1446
1447  /**
1448   * Turn the cleaner chore on/off.
1449   * @return Previous cleaner state wrapped by a {@link CompletableFuture}
1450   */
1451  CompletableFuture<Boolean> cleanerChoreSwitch(boolean on);
1452
1453  /**
1454   * Query the current state of the cleaner chore.
1455   * @return true if cleaner chore is on, false otherwise. The return value will be wrapped by a
1456   *         {@link CompletableFuture}
1457   */
1458  CompletableFuture<Boolean> isCleanerChoreEnabled();
1459
1460  /**
1461   * Ask for cleaner chore to run.
1462   * @return true if cleaner chore ran, false otherwise. The return value will be wrapped by a
1463   *         {@link CompletableFuture}
1464   */
1465  CompletableFuture<Boolean> runCleanerChore();
1466
1467  /**
1468   * Turn the catalog janitor on/off.
1469   * @return the previous state wrapped by a {@link CompletableFuture}
1470   */
1471  CompletableFuture<Boolean> catalogJanitorSwitch(boolean on);
1472
1473  /**
1474   * Query on the catalog janitor state.
1475   * @return true if the catalog janitor is on, false otherwise. The return value will be wrapped by
1476   *         a {@link CompletableFuture}
1477   */
1478  CompletableFuture<Boolean> isCatalogJanitorEnabled();
1479
1480  /**
1481   * Ask for a scan of the catalog table.
1482   * @return the number of entries cleaned. The return value will be wrapped by a
1483   *         {@link CompletableFuture}
1484   */
1485  CompletableFuture<Integer> runCatalogJanitor();
1486
1487  /**
1488   * Execute the given coprocessor call on the master.
1489   * <p>
1490   * The {@code stubMaker} is just a delegation to the {@code newStub} call. Usually it is only a
1491   * one line lambda expression, like:
1492   *
1493   * <pre>
1494   * channel -&gt; xxxService.newStub(channel)
1495   * </pre>
1496   *
1497   * @param stubMaker a delegation to the actual {@code newStub} call.
1498   * @param callable  a delegation to the actual protobuf rpc call. See the comment of
1499   *                  {@link ServiceCaller} for more details.
1500   * @param <S>       the type of the asynchronous stub
1501   * @param <R>       the type of the return value
1502   * @return the return value of the protobuf rpc call, wrapped by a {@link CompletableFuture}.
1503   * @see ServiceCaller
1504   */
1505  <S, R> CompletableFuture<R> coprocessorService(Function<RpcChannel, S> stubMaker,
1506    ServiceCaller<S, R> callable);
1507
1508  /**
1509   * Execute the given coprocessor call on the given region server.
1510   * <p>
1511   * The {@code stubMaker} is just a delegation to the {@code newStub} call. Usually it is only a
1512   * one line lambda expression, like:
1513   *
1514   * <pre>
1515   * channel -&gt; xxxService.newStub(channel)
1516   * </pre>
1517   *
1518   * @param stubMaker  a delegation to the actual {@code newStub} call.
1519   * @param callable   a delegation to the actual protobuf rpc call. See the comment of
1520   *                   {@link ServiceCaller} for more details.
1521   * @param serverName the given region server
1522   * @param <S>        the type of the asynchronous stub
1523   * @param <R>        the type of the return value
1524   * @return the return value of the protobuf rpc call, wrapped by a {@link CompletableFuture}.
1525   * @see ServiceCaller
1526   */
1527  <S, R> CompletableFuture<R> coprocessorService(Function<RpcChannel, S> stubMaker,
1528    ServiceCaller<S, R> callable, ServerName serverName);
1529
1530  /**
1531   * List all the dead region servers.
1532   */
1533  default CompletableFuture<List<ServerName>> listDeadServers() {
1534    return this.getClusterMetrics(EnumSet.of(Option.DEAD_SERVERS))
1535      .thenApply(ClusterMetrics::getDeadServerNames);
1536  }
1537
1538  /**
1539   * List all the unknown region servers.
1540   */
1541  default CompletableFuture<List<ServerName>> listUnknownServers() {
1542    return this.getClusterMetrics(EnumSet.of(Option.UNKNOWN_SERVERS))
1543      .thenApply(ClusterMetrics::getUnknownServerNames);
1544  }
1545
1546  /**
1547   * Clear dead region servers from master.
1548   * @param servers list of dead region servers.
1549   * @return - returns a list of servers that not cleared wrapped by a {@link CompletableFuture}.
1550   */
1551  CompletableFuture<List<ServerName>> clearDeadServers(final List<ServerName> servers);
1552
1553  /**
1554   * Clear all the blocks corresponding to this table from BlockCache. For expert-admins. Calling
1555   * this API will drop all the cached blocks specific to a table from BlockCache. This can
1556   * significantly impact the query performance as the subsequent queries will have to retrieve the
1557   * blocks from underlying filesystem.
1558   * @param tableName table to clear block cache
1559   * @return CacheEvictionStats related to the eviction wrapped by a {@link CompletableFuture}.
1560   */
1561  CompletableFuture<CacheEvictionStats> clearBlockCache(final TableName tableName);
1562
1563  /**
1564   * Create a new table by cloning the existent table schema.
1565   * @param tableName      name of the table to be cloned
1566   * @param newTableName   name of the new table where the table will be created
1567   * @param preserveSplits True if the splits should be preserved
1568   */
1569  CompletableFuture<Void> cloneTableSchema(final TableName tableName, final TableName newTableName,
1570    final boolean preserveSplits);
1571
1572  /**
1573   * Turn the compaction on or off. Disabling compactions will also interrupt any currently ongoing
1574   * compactions. This state is ephemeral. The setting will be lost on restart. Compaction can also
1575   * be enabled/disabled by modifying configuration hbase.regionserver.compaction.enabled in
1576   * hbase-site.xml.
1577   * @param switchState     Set to <code>true</code> to enable, <code>false</code> to disable.
1578   * @param serverNamesList list of region servers.
1579   * @return Previous compaction states for region servers
1580   */
1581  CompletableFuture<Map<ServerName, Boolean>> compactionSwitch(boolean switchState,
1582    List<String> serverNamesList);
1583
1584  /**
1585   * Switch the rpc throttle enabled state.
1586   * @param enable Set to <code>true</code> to enable, <code>false</code> to disable.
1587   * @return Previous rpc throttle enabled value
1588   */
1589  CompletableFuture<Boolean> switchRpcThrottle(boolean enable);
1590
1591  /**
1592   * Get if the rpc throttle is enabled.
1593   * @return True if rpc throttle is enabled
1594   */
1595  CompletableFuture<Boolean> isRpcThrottleEnabled();
1596
1597  /**
1598   * Switch the exceed throttle quota. If enabled, user/table/namespace throttle quota can be
1599   * exceeded if region server has availble quota.
1600   * @param enable Set to <code>true</code> to enable, <code>false</code> to disable.
1601   * @return Previous exceed throttle enabled value
1602   */
1603  CompletableFuture<Boolean> exceedThrottleQuotaSwitch(boolean enable);
1604
1605  /**
1606   * Fetches the table sizes on the filesystem as tracked by the HBase Master.
1607   */
1608  CompletableFuture<Map<TableName, Long>> getSpaceQuotaTableSizes();
1609
1610  /**
1611   * Fetches the observed {@link SpaceQuotaSnapshotView}s observed by a RegionServer.
1612   */
1613  CompletableFuture<? extends Map<TableName, ? extends SpaceQuotaSnapshotView>>
1614    getRegionServerSpaceQuotaSnapshots(ServerName serverName);
1615
1616  /**
1617   * Returns the Master's view of a quota on the given {@code namespace} or null if the Master has
1618   * no quota information on that namespace.
1619   */
1620  CompletableFuture<? extends SpaceQuotaSnapshotView>
1621    getCurrentSpaceQuotaSnapshot(String namespace);
1622
1623  /**
1624   * Returns the Master's view of a quota on the given {@code tableName} or null if the Master has
1625   * no quota information on that table.
1626   */
1627  CompletableFuture<? extends SpaceQuotaSnapshotView>
1628    getCurrentSpaceQuotaSnapshot(TableName tableName);
1629
1630  /**
1631   * Grants user specific permissions
1632   * @param userPermission           user name and the specific permission
1633   * @param mergeExistingPermissions If set to false, later granted permissions will override
1634   *                                 previous granted permissions. otherwise, it'll merge with
1635   *                                 previous granted permissions.
1636   */
1637  CompletableFuture<Void> grant(UserPermission userPermission, boolean mergeExistingPermissions);
1638
1639  /**
1640   * Revokes user specific permissions
1641   * @param userPermission user name and the specific permission
1642   */
1643  CompletableFuture<Void> revoke(UserPermission userPermission);
1644
1645  /**
1646   * Get the global/namespace/table permissions for user
1647   * @param getUserPermissionsRequest A request contains which user, global, namespace or table
1648   *                                  permissions needed
1649   * @return The user and permission list
1650   */
1651  CompletableFuture<List<UserPermission>>
1652    getUserPermissions(GetUserPermissionsRequest getUserPermissionsRequest);
1653
1654  /**
1655   * Check if the user has specific permissions
1656   * @param userName    the user name
1657   * @param permissions the specific permission list
1658   * @return True if user has the specific permissions
1659   */
1660  CompletableFuture<List<Boolean>> hasUserPermissions(String userName,
1661    List<Permission> permissions);
1662
1663  /**
1664   * Check if call user has specific permissions
1665   * @param permissions the specific permission list
1666   * @return True if user has the specific permissions
1667   */
1668  default CompletableFuture<List<Boolean>> hasUserPermissions(List<Permission> permissions) {
1669    return hasUserPermissions(null, permissions);
1670  }
1671
1672  /**
1673   * Turn on or off the auto snapshot cleanup based on TTL.
1674   * <p/>
1675   * Notice that, the method itself is always non-blocking, which means it will always return
1676   * immediately. The {@code sync} parameter only effects when will we complete the returned
1677   * {@link CompletableFuture}.
1678   * @param on   Set to <code>true</code> to enable, <code>false</code> to disable.
1679   * @param sync If <code>true</code>, it waits until current snapshot cleanup is completed, if
1680   *             outstanding.
1681   * @return Previous auto snapshot cleanup value wrapped by a {@link CompletableFuture}.
1682   */
1683  CompletableFuture<Boolean> snapshotCleanupSwitch(boolean on, boolean sync);
1684
1685  /**
1686   * Query the current state of the auto snapshot cleanup based on TTL.
1687   * @return true if the auto snapshot cleanup is enabled, false otherwise. The return value will be
1688   *         wrapped by a {@link CompletableFuture}.
1689   */
1690  CompletableFuture<Boolean> isSnapshotCleanupEnabled();
1691
1692  /**
1693   * Retrieves online slow RPC logs from the provided list of RegionServers
1694   * @param serverNames    Server names to get slowlog responses from
1695   * @param logQueryFilter filter to be used if provided
1696   * @return Online slowlog response list. The return value wrapped by a {@link CompletableFuture}
1697   * @deprecated since 2.4.0 and will be removed in 4.0.0. Use
1698   *             {@link #getLogEntries(Set, String, ServerType, int, Map)} instead.
1699   */
1700  @Deprecated
1701  default CompletableFuture<List<OnlineLogRecord>>
1702    getSlowLogResponses(final Set<ServerName> serverNames, final LogQueryFilter logQueryFilter) {
1703    String logType;
1704    if (LogQueryFilter.Type.LARGE_LOG.equals(logQueryFilter.getType())) {
1705      logType = "LARGE_LOG";
1706    } else {
1707      logType = "SLOW_LOG";
1708    }
1709    Map<String, Object> filterParams = new HashMap<>();
1710    filterParams.put("regionName", logQueryFilter.getRegionName());
1711    filterParams.put("clientAddress", logQueryFilter.getClientAddress());
1712    filterParams.put("tableName", logQueryFilter.getTableName());
1713    filterParams.put("userName", logQueryFilter.getUserName());
1714    filterParams.put("filterByOperator", logQueryFilter.getFilterByOperator().toString());
1715    CompletableFuture<List<LogEntry>> logEntries = getLogEntries(serverNames, logType,
1716      ServerType.REGION_SERVER, logQueryFilter.getLimit(), filterParams);
1717    return logEntries.thenApply(logEntryList -> logEntryList.stream()
1718      .map(logEntry -> (OnlineLogRecord) logEntry).collect(Collectors.toList()));
1719  }
1720
1721  /**
1722   * Clears online slow RPC logs from the provided list of RegionServers
1723   * @param serverNames Set of Server names to clean slowlog responses from
1724   * @return List of booleans representing if online slowlog response buffer is cleaned from each
1725   *         RegionServer. The return value wrapped by a {@link CompletableFuture}
1726   */
1727  CompletableFuture<List<Boolean>> clearSlowLogResponses(final Set<ServerName> serverNames);
1728
1729  /**
1730   * Creates a new RegionServer group with the given name
1731   * @param groupName the name of the group
1732   */
1733  CompletableFuture<Void> addRSGroup(String groupName);
1734
1735  /**
1736   * Get group info for the given group name
1737   * @param groupName the group name
1738   * @return group info
1739   */
1740  CompletableFuture<RSGroupInfo> getRSGroup(String groupName);
1741
1742  /**
1743   * Get group info for the given hostPort
1744   * @param hostPort HostPort to get RSGroupInfo for
1745   */
1746  CompletableFuture<RSGroupInfo> getRSGroup(Address hostPort);
1747
1748  /**
1749   * Get group info for the given table
1750   * @param tableName table name to get RSGroupInfo for
1751   */
1752  CompletableFuture<RSGroupInfo> getRSGroup(TableName tableName);
1753
1754  /**
1755   * Lists current set of RegionServer groups
1756   */
1757  CompletableFuture<List<RSGroupInfo>> listRSGroups();
1758
1759  /**
1760   * Get all tables in this RegionServer group.
1761   * @param groupName the group name
1762   * @see #getConfiguredNamespacesAndTablesInRSGroup(String)
1763   */
1764  CompletableFuture<List<TableName>> listTablesInRSGroup(String groupName);
1765
1766  /**
1767   * Get the namespaces and tables which have this RegionServer group in descriptor.
1768   * <p/>
1769   * The difference between this method and {@link #listTablesInRSGroup(String)} is that, this
1770   * method will not include the table which is actually in this RegionServr group but without the
1771   * RegionServer group configuration in its {@link TableDescriptor}. For example, we have a group
1772   * 'A', and we make namespace 'nsA' in this group, then all the tables under this namespace will
1773   * in the group 'A', but this method will not return these tables but only the namespace 'nsA',
1774   * while the {@link #listTablesInRSGroup(String)} will return all these tables.
1775   * @param groupName the group name
1776   * @see #listTablesInRSGroup(String)
1777   */
1778  CompletableFuture<Pair<List<String>, List<TableName>>>
1779    getConfiguredNamespacesAndTablesInRSGroup(String groupName);
1780
1781  /**
1782   * Remove RegionServer group associated with the given name
1783   * @param groupName the group name
1784   */
1785  CompletableFuture<Void> removeRSGroup(String groupName);
1786
1787  /**
1788   * Remove decommissioned servers from group 1. Sometimes we may find the server aborted due to
1789   * some hardware failure and we must offline the server for repairing. Or we need to move some
1790   * servers to join other clusters. So we need to remove these servers from the group. 2.
1791   * Dead/recovering/live servers will be disallowed.
1792   * @param servers set of servers to remove
1793   */
1794  CompletableFuture<Void> removeServersFromRSGroup(Set<Address> servers);
1795
1796  /**
1797   * Move given set of servers to the specified target RegionServer group
1798   * @param servers   set of servers to move
1799   * @param groupName the group to move servers to
1800   */
1801  CompletableFuture<Void> moveServersToRSGroup(Set<Address> servers, String groupName);
1802
1803  /**
1804   * Set the RegionServer group for tables
1805   * @param tables    tables to set group for
1806   * @param groupName group name for tables
1807   */
1808  CompletableFuture<Void> setRSGroup(Set<TableName> tables, String groupName);
1809
1810  /**
1811   * Balance regions in the given RegionServer group
1812   * @param groupName the group name
1813   * @return BalanceResponse details about the balancer run
1814   */
1815  default CompletableFuture<BalanceResponse> balanceRSGroup(String groupName) {
1816    return balanceRSGroup(groupName, BalanceRequest.defaultInstance());
1817  }
1818
1819  /**
1820   * Balance regions in the given RegionServer group
1821   * @param groupName the group name
1822   * @param request   options to define how the balancer should run
1823   * @return BalanceResponse details about the balancer run
1824   */
1825  CompletableFuture<BalanceResponse> balanceRSGroup(String groupName, BalanceRequest request);
1826
1827  /**
1828   * Rename rsgroup
1829   * @param oldName old rsgroup name
1830   * @param newName new rsgroup name
1831   */
1832  CompletableFuture<Void> renameRSGroup(String oldName, String newName);
1833
1834  /**
1835   * Update RSGroup configuration
1836   * @param groupName     the group name
1837   * @param configuration new configuration of the group name to be set
1838   */
1839  CompletableFuture<Void> updateRSGroupConfig(String groupName, Map<String, String> configuration);
1840
1841  /**
1842   * Retrieve recent online records from HMaster / RegionServers. Examples include slow/large RPC
1843   * logs, balancer decisions by master.
1844   * @param serverNames  servers to retrieve records from, useful in case of records maintained by
1845   *                     RegionServer as we can select specific server. In case of
1846   *                     servertype=MASTER, logs will only come from the currently active master.
1847   * @param logType      string representing type of log records
1848   * @param serverType   enum for server type: HMaster or RegionServer
1849   * @param limit        put a limit to list of records that server should send in response
1850   * @param filterParams additional filter params
1851   */
1852  CompletableFuture<List<LogEntry>> getLogEntries(Set<ServerName> serverNames, String logType,
1853    ServerType serverType, int limit, Map<String, Object> filterParams);
1854
1855  /**
1856   * Flush master local region
1857   */
1858  CompletableFuture<Void> flushMasterStore();
1859
1860  /**
1861   * Get the list of cached files
1862   */
1863  CompletableFuture<List<String>> getCachedFilesList(ServerName serverName);
1864}