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