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