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