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 com.google.protobuf.RpcChannel; 021import java.util.Arrays; 022import java.util.Collection; 023import java.util.EnumSet; 024import java.util.List; 025import java.util.Map; 026import java.util.Optional; 027import java.util.Set; 028import java.util.concurrent.CompletableFuture; 029import java.util.function.Function; 030import java.util.regex.Pattern; 031import org.apache.hadoop.hbase.CacheEvictionStats; 032import org.apache.hadoop.hbase.ClusterMetrics; 033import org.apache.hadoop.hbase.ClusterMetrics.Option; 034import org.apache.hadoop.hbase.NamespaceDescriptor; 035import org.apache.hadoop.hbase.RegionMetrics; 036import org.apache.hadoop.hbase.ServerName; 037import org.apache.hadoop.hbase.TableName; 038import org.apache.hadoop.hbase.client.replication.TableCFs; 039import org.apache.hadoop.hbase.client.security.SecurityCapability; 040import org.apache.hadoop.hbase.quotas.QuotaFilter; 041import org.apache.hadoop.hbase.quotas.QuotaSettings; 042import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshotView; 043import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; 044import org.apache.hadoop.hbase.replication.ReplicationPeerDescription; 045import org.apache.hadoop.hbase.security.access.GetUserPermissionsRequest; 046import org.apache.hadoop.hbase.security.access.Permission; 047import org.apache.hadoop.hbase.security.access.UserPermission; 048import org.apache.yetus.audience.InterfaceAudience; 049 050/** 051 * The asynchronous administrative API for HBase. 052 * @since 2.0.0 053 */ 054@InterfaceAudience.Public 055public interface AsyncAdmin { 056 057 /** 058 * @param tableName Table to check. 059 * @return True if table exists already. The return value will be wrapped by a 060 * {@link CompletableFuture}. 061 */ 062 CompletableFuture<Boolean> tableExists(TableName tableName); 063 064 /** 065 * List all the userspace tables. 066 * @return - returns a list of TableDescriptors wrapped by a {@link CompletableFuture}. 067 */ 068 default CompletableFuture<List<TableDescriptor>> listTableDescriptors() { 069 return listTableDescriptors(false); 070 } 071 072 /** 073 * List all the tables. 074 * @param includeSysTables False to match only against userspace tables 075 * @return - returns a list of TableDescriptors wrapped by a {@link CompletableFuture}. 076 */ 077 CompletableFuture<List<TableDescriptor>> listTableDescriptors(boolean includeSysTables); 078 079 /** 080 * List all the tables matching the given pattern. 081 * @param pattern The compiled regular expression to match against 082 * @param includeSysTables False to match only against userspace tables 083 * @return - returns a list of TableDescriptors wrapped by a {@link CompletableFuture}. 084 */ 085 CompletableFuture<List<TableDescriptor>> listTableDescriptors(Pattern pattern, 086 boolean includeSysTables); 087 088 /** 089 * List specific tables including system tables. 090 * @param tableNames the table list to match against 091 * @return - returns a list of TableDescriptors wrapped by a {@link CompletableFuture}. 092 */ 093 CompletableFuture<List<TableDescriptor>> listTableDescriptors(List<TableName> tableNames); 094 095 /** 096 * Get list of table descriptors by namespace. 097 * @param name namespace name 098 * @return returns a list of TableDescriptors wrapped by a {@link CompletableFuture}. 099 */ 100 CompletableFuture<List<TableDescriptor>> listTableDescriptorsByNamespace(String name); 101 102 /** 103 * List all of the names of userspace tables. 104 * @return a list of table names wrapped by a {@link CompletableFuture}. 105 * @see #listTableNames(Pattern, boolean) 106 */ 107 default CompletableFuture<List<TableName>> listTableNames() { 108 return listTableNames(false); 109 } 110 111 /** 112 * List all of the names of tables. 113 * @param includeSysTables False to match only against userspace tables 114 * @return a list of table names wrapped by a {@link CompletableFuture}. 115 */ 116 CompletableFuture<List<TableName>> listTableNames(boolean includeSysTables); 117 118 /** 119 * List all of the names of userspace tables. 120 * @param pattern The regular expression to match against 121 * @param includeSysTables False to match only against userspace tables 122 * @return a list of table names wrapped by a {@link CompletableFuture}. 123 */ 124 CompletableFuture<List<TableName>> listTableNames(Pattern pattern, boolean includeSysTables); 125 126 /** 127 * Get list of table names by namespace. 128 * @param name namespace name 129 * @return The list of table names in the namespace wrapped by a {@link CompletableFuture}. 130 */ 131 CompletableFuture<List<TableName>> listTableNamesByNamespace(String name); 132 133 /** 134 * Method for getting the tableDescriptor 135 * @param tableName as a {@link TableName} 136 * @return the read-only tableDescriptor wrapped by a {@link CompletableFuture}. 137 */ 138 CompletableFuture<TableDescriptor> getDescriptor(TableName tableName); 139 140 /** 141 * Creates a new table. 142 * @param desc table descriptor for table 143 */ 144 CompletableFuture<Void> createTable(TableDescriptor desc); 145 146 /** 147 * Creates a new table with the specified number of regions. The start key specified will become 148 * the end key of the first region of the table, and the end key specified will become the start 149 * key of the last region of the table (the first region has a null start key and the last region 150 * has a null end key). BigInteger math will be used to divide the key range specified into enough 151 * segments to make the required number of total regions. 152 * @param desc table descriptor for table 153 * @param startKey beginning of key range 154 * @param endKey end of key range 155 * @param numRegions the total number of regions to create 156 */ 157 CompletableFuture<Void> createTable(TableDescriptor desc, byte[] startKey, byte[] endKey, 158 int numRegions); 159 160 /** 161 * Creates a new table with an initial set of empty regions defined by the specified split keys. 162 * The total number of regions created will be the number of split keys plus one. 163 * Note : Avoid passing empty split key. 164 * @param desc table descriptor for table 165 * @param splitKeys array of split keys for the initial regions of the table 166 */ 167 CompletableFuture<Void> createTable(TableDescriptor desc, byte[][] splitKeys); 168 169 /** 170 * Modify an existing table, more IRB friendly version. 171 * @param desc modified description of the table 172 */ 173 CompletableFuture<Void> modifyTable(TableDescriptor desc); 174 175 /** 176 * Deletes a table. 177 * @param tableName name of table to delete 178 */ 179 CompletableFuture<Void> deleteTable(TableName tableName); 180 181 /** 182 * Truncate a table. 183 * @param tableName name of table to truncate 184 * @param preserveSplits True if the splits should be preserved 185 */ 186 CompletableFuture<Void> truncateTable(TableName tableName, boolean preserveSplits); 187 188 /** 189 * Enable a table. The table has to be in disabled state for it to be enabled. 190 * @param tableName name of the table 191 */ 192 CompletableFuture<Void> enableTable(TableName tableName); 193 194 /** 195 * Disable a table. The table has to be in enabled state for it to be disabled. 196 * @param tableName 197 */ 198 CompletableFuture<Void> disableTable(TableName tableName); 199 200 /** 201 * @param tableName name of table to check 202 * @return true if table is on-line. The return value will be wrapped by a 203 * {@link CompletableFuture}. 204 */ 205 CompletableFuture<Boolean> isTableEnabled(TableName tableName); 206 207 /** 208 * @param tableName name of table to check 209 * @return true if table is off-line. The return value will be wrapped by a 210 * {@link CompletableFuture}. 211 */ 212 CompletableFuture<Boolean> isTableDisabled(TableName tableName); 213 214 /** 215 * @param tableName name of table to check 216 * @return true if all regions of the table are available. The return value will be wrapped by a 217 * {@link CompletableFuture}. 218 */ 219 CompletableFuture<Boolean> isTableAvailable(TableName tableName); 220 221 /** 222 * Use this api to check if the table has been created with the specified number of splitkeys 223 * which was used while creating the given table. Note : If this api is used after a table's 224 * region gets splitted, the api may return false. The return value will be wrapped by a 225 * {@link CompletableFuture}. 226 * @param tableName name of table to check 227 * @param splitKeys keys to check if the table has been created with all split keys 228 * @deprecated Since 2.2.0. Will be removed in 3.0.0. Use {@link #isTableAvailable(TableName)} 229 */ 230 @Deprecated 231 CompletableFuture<Boolean> isTableAvailable(TableName tableName, byte[][] splitKeys); 232 233 /** 234 * Add a column family to an existing table. 235 * @param tableName name of the table to add column family to 236 * @param columnFamily column family descriptor of column family to be added 237 */ 238 CompletableFuture<Void> addColumnFamily(TableName tableName, 239 ColumnFamilyDescriptor columnFamily); 240 241 /** 242 * Delete a column family from a table. 243 * @param tableName name of table 244 * @param columnFamily name of column family to be deleted 245 */ 246 CompletableFuture<Void> deleteColumnFamily(TableName tableName, byte[] columnFamily); 247 248 /** 249 * Modify an existing column family on a table. 250 * @param tableName name of table 251 * @param columnFamily new column family descriptor to use 252 */ 253 CompletableFuture<Void> modifyColumnFamily(TableName tableName, 254 ColumnFamilyDescriptor columnFamily); 255 256 /** 257 * Create a new namespace. 258 * @param descriptor descriptor which describes the new namespace 259 */ 260 CompletableFuture<Void> createNamespace(NamespaceDescriptor descriptor); 261 262 /** 263 * Modify an existing namespace. 264 * @param descriptor descriptor which describes the new namespace 265 */ 266 CompletableFuture<Void> modifyNamespace(NamespaceDescriptor descriptor); 267 268 /** 269 * Delete an existing namespace. Only empty namespaces (no tables) can be removed. 270 * @param name namespace name 271 */ 272 CompletableFuture<Void> deleteNamespace(String name); 273 274 /** 275 * Get a namespace descriptor by name 276 * @param name name of namespace descriptor 277 * @return A descriptor wrapped by a {@link CompletableFuture}. 278 */ 279 CompletableFuture<NamespaceDescriptor> getNamespaceDescriptor(String name); 280 281 /** 282 * List available namespace descriptors 283 * @return List of descriptors wrapped by a {@link CompletableFuture}. 284 */ 285 CompletableFuture<List<NamespaceDescriptor>> listNamespaceDescriptors(); 286 287 /** 288 * Get all the online regions on a region server. 289 */ 290 CompletableFuture<List<RegionInfo>> getRegions(ServerName serverName); 291 292 /** 293 * Get the regions of a given table. 294 */ 295 CompletableFuture<List<RegionInfo>> getRegions(TableName tableName); 296 297 /** 298 * Flush a table. 299 * @param tableName table to flush 300 */ 301 CompletableFuture<Void> flush(TableName tableName); 302 303 /** 304 * Flush an individual region. 305 * @param regionName region to flush 306 */ 307 CompletableFuture<Void> flushRegion(byte[] regionName); 308 309 /** 310 * Flush all region on the region server. 311 * @param serverName server to flush 312 */ 313 CompletableFuture<Void> flushRegionServer(ServerName serverName); 314 315 /** 316 * Compact a table. When the returned CompletableFuture is done, it only means the compact request 317 * was sent to HBase and may need some time to finish the compact operation. 318 * Throws {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found. 319 * @param tableName table to compact 320 */ 321 default CompletableFuture<Void> compact(TableName tableName) { 322 return compact(tableName, CompactType.NORMAL); 323 } 324 325 /** 326 * Compact a column family within a table. When the returned CompletableFuture is done, it only 327 * means the compact request was sent to HBase and may need some time to finish the compact 328 * operation. 329 * Throws {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found. 330 * @param tableName table to compact 331 * @param columnFamily column family within a table. If not present, compact the table's all 332 * column families. 333 */ 334 default CompletableFuture<Void> compact(TableName tableName, byte[] columnFamily) { 335 return compact(tableName, columnFamily, CompactType.NORMAL); 336 } 337 338 /** 339 * Compact a table. When the returned CompletableFuture is done, it only means the compact request 340 * was sent to HBase and may need some time to finish the compact operation. 341 * Throws {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found for 342 * normal compaction type. 343 * @param tableName table to compact 344 * @param compactType {@link org.apache.hadoop.hbase.client.CompactType} 345 */ 346 CompletableFuture<Void> compact(TableName tableName, CompactType compactType); 347 348 /** 349 * Compact a column family within a table. When the returned CompletableFuture is done, it only 350 * means the compact request was sent to HBase and may need some time to finish the compact 351 * operation. 352 * Throws {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found for 353 * normal compaction type. 354 * @param tableName table to compact 355 * @param columnFamily column family within a table 356 * @param compactType {@link org.apache.hadoop.hbase.client.CompactType} 357 */ 358 CompletableFuture<Void> compact(TableName tableName, byte[] columnFamily, 359 CompactType compactType); 360 361 /** 362 * Compact an individual region. When the returned CompletableFuture is done, it only means the 363 * compact request was sent to HBase and may need some time to finish the compact operation. 364 * @param regionName region to compact 365 */ 366 CompletableFuture<Void> compactRegion(byte[] regionName); 367 368 /** 369 * Compact a column family within a region. When the returned CompletableFuture is done, it only 370 * means the compact request was sent to HBase and may need some time to finish the compact 371 * operation. 372 * @param regionName region to compact 373 * @param columnFamily column family within a region. If not present, compact the region's all 374 * column families. 375 */ 376 CompletableFuture<Void> compactRegion(byte[] regionName, byte[] columnFamily); 377 378 /** 379 * Major compact a table. When the returned CompletableFuture is done, it only means the compact 380 * request was sent to HBase and may need some time to finish the compact operation. 381 * Throws {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found. 382 * @param tableName table to major compact 383 */ 384 default CompletableFuture<Void> majorCompact(TableName tableName) { 385 return majorCompact(tableName, CompactType.NORMAL); 386 } 387 388 /** 389 * Major compact a column family within a table. When the returned CompletableFuture is done, it 390 * only means the compact request was sent to HBase and may need some time to finish the compact 391 * operation. 392 * Throws {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found for 393 * normal compaction. type. 394 * @param tableName table to major compact 395 * @param columnFamily column family within a table. If not present, major compact the table's all 396 * column families. 397 */ 398 default CompletableFuture<Void> majorCompact(TableName tableName, byte[] columnFamily) { 399 return majorCompact(tableName, columnFamily, CompactType.NORMAL); 400 } 401 402 /** 403 * Major compact a table. When the returned CompletableFuture is done, it only means the compact 404 * request was sent to HBase and may need some time to finish the compact operation. 405 * Throws {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found for 406 * normal compaction type. 407 * @param tableName table to major compact 408 * @param compactType {@link org.apache.hadoop.hbase.client.CompactType} 409 */ 410 CompletableFuture<Void> majorCompact(TableName tableName, CompactType compactType); 411 412 /** 413 * Major compact a column family within a table. When the returned CompletableFuture is done, it 414 * only means the compact request was sent to HBase and may need some time to finish the compact 415 * operation. 416 * Throws {@link org.apache.hadoop.hbase.TableNotFoundException} if table not found. 417 * @param tableName table to major compact 418 * @param columnFamily column family within a table. If not present, major compact the table's all 419 * column families. 420 * @param compactType {@link org.apache.hadoop.hbase.client.CompactType} 421 */ 422 CompletableFuture<Void> majorCompact(TableName tableName, byte[] columnFamily, 423 CompactType compactType); 424 425 /** 426 * Major compact a region. When the returned CompletableFuture is done, it only means the compact 427 * request was sent to HBase and may need some time to finish the compact operation. 428 * @param regionName region to major compact 429 */ 430 CompletableFuture<Void> majorCompactRegion(byte[] regionName); 431 432 /** 433 * Major compact a column family within region. When the returned CompletableFuture is done, it 434 * only means the compact request was sent to HBase and may need some time to finish the compact 435 * operation. 436 * @param regionName region to major compact 437 * @param columnFamily column family within a region. If not present, major compact the region's 438 * all column families. 439 */ 440 CompletableFuture<Void> majorCompactRegion(byte[] regionName, byte[] columnFamily); 441 442 /** 443 * Compact all regions on the region server. 444 * @param serverName the region server name 445 */ 446 CompletableFuture<Void> compactRegionServer(ServerName serverName); 447 448 /** 449 * Compact all regions on the region server. 450 * @param serverName the region server name 451 */ 452 CompletableFuture<Void> majorCompactRegionServer(ServerName serverName); 453 454 /** 455 * Turn the Merge switch on or off. 456 * @param enabled enabled or not 457 * @return Previous switch value wrapped by a {@link CompletableFuture} 458 */ 459 default CompletableFuture<Boolean> mergeSwitch(boolean enabled) { 460 return mergeSwitch(enabled, false); 461 } 462 463 /** 464 * Turn the Merge switch on or off. 465 * <p/> 466 * Notice that, the method itself is always non-blocking, which means it will always return 467 * immediately. The {@code drainMerges} parameter only effects when will we complete the returned 468 * {@link CompletableFuture}. 469 * @param enabled enabled or not 470 * @param drainMerges If <code>true</code>, it waits until current merge() call, if outstanding, 471 * to return. 472 * @return Previous switch value wrapped by a {@link CompletableFuture} 473 */ 474 CompletableFuture<Boolean> mergeSwitch(boolean enabled, boolean drainMerges); 475 476 /** 477 * Query the current state of the Merge switch. 478 * @return true if the switch is on, false otherwise. The return value will be wrapped by a 479 * {@link CompletableFuture} 480 */ 481 CompletableFuture<Boolean> isMergeEnabled(); 482 483 /** 484 * Turn the Split switch on or off. 485 * @param enabled enabled or not 486 * @return Previous switch value wrapped by a {@link CompletableFuture} 487 */ 488 default CompletableFuture<Boolean> splitSwitch(boolean enabled) { 489 return splitSwitch(enabled, false); 490 } 491 492 /** 493 * Turn the Split switch on or off. 494 * <p/> 495 * Notice that, the method itself is always non-blocking, which means it will always return 496 * immediately. The {@code drainSplits} parameter only effects when will we complete the returned 497 * {@link CompletableFuture}. 498 * @param enabled enabled or not 499 * @param drainSplits If <code>true</code>, it waits until current split() call, if outstanding, 500 * to return. 501 * @return Previous switch value wrapped by a {@link CompletableFuture} 502 */ 503 CompletableFuture<Boolean> splitSwitch(boolean enabled, boolean drainSplits); 504 505 /** 506 * Query the current state of the Split switch. 507 * @return true if the switch is on, false otherwise. The return value will be wrapped by a 508 * {@link CompletableFuture} 509 */ 510 CompletableFuture<Boolean> isSplitEnabled(); 511 512 /** 513 * Merge two regions. 514 * @param nameOfRegionA encoded or full name of region a 515 * @param nameOfRegionB encoded or full name of region b 516 * @param forcible true if do a compulsory merge, otherwise we will only merge two adjacent 517 * regions 518 */ 519 default CompletableFuture<Void> mergeRegions(byte[] nameOfRegionA, byte[] nameOfRegionB, 520 boolean forcible) { 521 return mergeRegions(Arrays.asList(nameOfRegionA, nameOfRegionB), forcible); 522 } 523 524 /** 525 * Merge regions. 526 * <p/> 527 * You may get a {@code DoNotRetryIOException} if you pass more than two regions in but the master 528 * does not support merging more than two regions. At least till 2.2.0, we still only support 529 * merging two regions. 530 * @param nameOfRegionsToMerge encoded or full name of daughter regions 531 * @param forcible true if do a compulsory merge, otherwise we will only merge two adjacent 532 * regions 533 */ 534 CompletableFuture<Void> mergeRegions(List<byte[]> nameOfRegionsToMerge, boolean forcible); 535 536 /** 537 * Split a table. The method will execute split action for each region in table. 538 * @param tableName table to split 539 */ 540 CompletableFuture<Void> split(TableName tableName); 541 542 /** 543 * Split an individual region. 544 * @param regionName region to split 545 */ 546 CompletableFuture<Void> splitRegion(byte[] regionName); 547 548 /** 549 * Split a table. 550 * @param tableName table to split 551 * @param splitPoint the explicit position to split on 552 */ 553 CompletableFuture<Void> split(TableName tableName, byte[] splitPoint); 554 555 /** 556 * Split an individual region. 557 * @param regionName region to split 558 * @param splitPoint the explicit position to split on. If not present, it will decide by region 559 * server. 560 */ 561 CompletableFuture<Void> splitRegion(byte[] regionName, byte[] splitPoint); 562 563 /** 564 * @param regionName Encoded or full name of region to assign. 565 */ 566 CompletableFuture<Void> assign(byte[] regionName); 567 568 /** 569 * Unassign a region from current hosting regionserver. Region will then be assigned to a 570 * regionserver chosen at random. Region could be reassigned back to the same server. Use 571 * {@link #move(byte[], ServerName)} if you want to control the region movement. 572 * @param regionName Encoded or full name of region to unassign. Will clear any existing 573 * RegionPlan if one found. 574 * @param forcible If true, force unassign (Will remove region from regions-in-transition too if 575 * present. If results in double assignment use hbck -fix to resolve. To be used by 576 * experts). 577 */ 578 CompletableFuture<Void> unassign(byte[] regionName, boolean forcible); 579 580 /** 581 * Offline specified region from master's in-memory state. It will not attempt to reassign the 582 * region as in unassign. This API can be used when a region not served by any region server and 583 * still online as per Master's in memory state. If this API is incorrectly used on active region 584 * then master will loose track of that region. This is a special method that should be used by 585 * experts or hbck. 586 * @param regionName Encoded or full name of region to offline 587 */ 588 CompletableFuture<Void> offline(byte[] regionName); 589 590 /** 591 * Move the region <code>r</code> to a random server. 592 * @param regionName Encoded or full name of region to move. 593 */ 594 CompletableFuture<Void> move(byte[] regionName); 595 596 /** 597 * Move the region <code>r</code> to <code>dest</code>. 598 * @param regionName Encoded or full name of region to move. 599 * @param destServerName The servername of the destination regionserver. If not present, we'll 600 * assign to a random server. A server name is made of host, port and startcode. Here is 601 * an example: <code> host187.example.com,60020,1289493121758</code> 602 */ 603 CompletableFuture<Void> move(byte[] regionName, ServerName destServerName); 604 605 /** 606 * Apply the new quota settings. 607 * @param quota the quota settings 608 */ 609 CompletableFuture<Void> setQuota(QuotaSettings quota); 610 611 /** 612 * List the quotas based on the filter. 613 * @param filter the quota settings filter 614 * @return the QuotaSetting list, which wrapped by a CompletableFuture. 615 */ 616 CompletableFuture<List<QuotaSettings>> getQuota(QuotaFilter filter); 617 618 /** 619 * Add a new replication peer for replicating data to slave cluster 620 * @param peerId a short name that identifies the peer 621 * @param peerConfig configuration for the replication slave cluster 622 */ 623 default CompletableFuture<Void> addReplicationPeer(String peerId, 624 ReplicationPeerConfig peerConfig) { 625 return addReplicationPeer(peerId, peerConfig, true); 626 } 627 628 /** 629 * Add a new replication peer for replicating data to slave cluster 630 * @param peerId a short name that identifies the peer 631 * @param peerConfig configuration for the replication slave cluster 632 * @param enabled peer state, true if ENABLED and false if DISABLED 633 */ 634 CompletableFuture<Void> addReplicationPeer(String peerId, 635 ReplicationPeerConfig peerConfig, boolean enabled); 636 637 /** 638 * Remove a peer and stop the replication 639 * @param peerId a short name that identifies the peer 640 */ 641 CompletableFuture<Void> removeReplicationPeer(String peerId); 642 643 /** 644 * Restart the replication stream to the specified peer 645 * @param peerId a short name that identifies the peer 646 */ 647 CompletableFuture<Void> enableReplicationPeer(String peerId); 648 649 /** 650 * Stop the replication stream to the specified peer 651 * @param peerId a short name that identifies the peer 652 */ 653 CompletableFuture<Void> disableReplicationPeer(String peerId); 654 655 /** 656 * Returns the configured ReplicationPeerConfig for the specified peer 657 * @param peerId a short name that identifies the peer 658 * @return ReplicationPeerConfig for the peer wrapped by a {@link CompletableFuture}. 659 */ 660 CompletableFuture<ReplicationPeerConfig> getReplicationPeerConfig(String peerId); 661 662 /** 663 * Update the peerConfig for the specified peer 664 * @param peerId a short name that identifies the peer 665 * @param peerConfig new config for the peer 666 */ 667 CompletableFuture<Void> updateReplicationPeerConfig(String peerId, 668 ReplicationPeerConfig peerConfig); 669 670 /** 671 * Append the replicable table-cf config of the specified peer 672 * @param peerId a short that identifies the cluster 673 * @param tableCfs A map from tableName to column family names 674 */ 675 CompletableFuture<Void> appendReplicationPeerTableCFs(String peerId, 676 Map<TableName, List<String>> tableCfs); 677 678 /** 679 * Remove some table-cfs from config of the specified peer 680 * @param peerId a short name that identifies the cluster 681 * @param tableCfs A map from tableName to column family names 682 */ 683 CompletableFuture<Void> removeReplicationPeerTableCFs(String peerId, 684 Map<TableName, List<String>> tableCfs); 685 686 /** 687 * Return a list of replication peers. 688 * @return a list of replication peers description. The return value will be wrapped by a 689 * {@link CompletableFuture}. 690 */ 691 CompletableFuture<List<ReplicationPeerDescription>> listReplicationPeers(); 692 693 /** 694 * Return a list of replication peers. 695 * @param pattern The compiled regular expression to match peer id 696 * @return a list of replication peers description. The return value will be wrapped by a 697 * {@link CompletableFuture}. 698 */ 699 CompletableFuture<List<ReplicationPeerDescription>> listReplicationPeers(Pattern pattern); 700 701 /** 702 * Find all table and column families that are replicated from this cluster 703 * @return the replicated table-cfs list of this cluster. The return value will be wrapped by a 704 * {@link CompletableFuture}. 705 */ 706 CompletableFuture<List<TableCFs>> listReplicatedTableCFs(); 707 708 /** 709 * Enable a table's replication switch. 710 * @param tableName name of the table 711 */ 712 CompletableFuture<Void> enableTableReplication(TableName tableName); 713 714 /** 715 * Disable a table's replication switch. 716 * @param tableName name of the table 717 */ 718 CompletableFuture<Void> disableTableReplication(TableName tableName); 719 720 /** 721 * Take a snapshot for the given table. If the table is enabled, a FLUSH-type snapshot will be 722 * taken. If the table is disabled, an offline snapshot is taken. Snapshots are considered unique 723 * based on <b>the name of the snapshot</b>. Attempts to take a snapshot with the same name (even 724 * a different type or with different parameters) will fail with a 725 * {@link org.apache.hadoop.hbase.snapshot.SnapshotCreationException} indicating the duplicate 726 * naming. Snapshot names follow the same naming constraints as tables in HBase. See 727 * {@link org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}. 728 * @param snapshotName name of the snapshot to be created 729 * @param tableName name of the table for which snapshot is created 730 */ 731 default CompletableFuture<Void> snapshot(String snapshotName, TableName tableName) { 732 return snapshot(snapshotName, tableName, SnapshotType.FLUSH); 733 } 734 735 /** 736 * Create typed snapshot of the table. Snapshots are considered unique based on <b>the name of the 737 * snapshot</b>. Attempts to take a snapshot with the same name (even a different type or with 738 * different parameters) will fail with a 739 * {@link org.apache.hadoop.hbase.snapshot.SnapshotCreationException} indicating the duplicate 740 * naming. Snapshot names follow the same naming constraints as tables in HBase. See 741 * {@link org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}. 742 * @param snapshotName name to give the snapshot on the filesystem. Must be unique from all other 743 * snapshots stored on the cluster 744 * @param tableName name of the table to snapshot 745 * @param type type of snapshot to take 746 */ 747 default CompletableFuture<Void> snapshot(String snapshotName, TableName tableName, 748 SnapshotType type) { 749 return snapshot(new SnapshotDescription(snapshotName, tableName, type)); 750 } 751 752 /** 753 * Take a snapshot and wait for the server to complete that snapshot asynchronously. Only a single 754 * snapshot should be taken at a time for an instance of HBase, or results may be undefined (you 755 * can tell multiple HBase clusters to snapshot at the same time, but only one at a time for a 756 * single cluster). Snapshots are considered unique based on <b>the name of the snapshot</b>. 757 * Attempts to take a snapshot with the same name (even a different type or with different 758 * parameters) will fail with a {@link org.apache.hadoop.hbase.snapshot.SnapshotCreationException} 759 * indicating the duplicate naming. Snapshot names follow the same naming constraints as tables in 760 * HBase. See {@link org.apache.hadoop.hbase.TableName#isLegalFullyQualifiedTableName(byte[])}. 761 * You should probably use {@link #snapshot(String, org.apache.hadoop.hbase.TableName)} unless you 762 * are sure about the type of snapshot that you want to take. 763 * @param snapshot snapshot to take 764 */ 765 CompletableFuture<Void> snapshot(SnapshotDescription snapshot); 766 767 /** 768 * Check the current state of the passed snapshot. There are three possible states: 769 * <ol> 770 * <li>running - returns <tt>false</tt></li> 771 * <li>finished - returns <tt>true</tt></li> 772 * <li>finished with error - throws the exception that caused the snapshot to fail</li> 773 * </ol> 774 * The cluster only knows about the most recent snapshot. Therefore, if another snapshot has been 775 * run/started since the snapshot you are checking, you will receive an 776 * {@link org.apache.hadoop.hbase.snapshot.UnknownSnapshotException}. 777 * @param snapshot description of the snapshot to check 778 * @return <tt>true</tt> if the snapshot is completed, <tt>false</tt> if the snapshot is still 779 * running 780 */ 781 CompletableFuture<Boolean> isSnapshotFinished(SnapshotDescription snapshot); 782 783 /** 784 * Restore the specified snapshot on the original table. (The table must be disabled) If the 785 * "hbase.snapshot.restore.take.failsafe.snapshot" configuration property is set to true, a 786 * snapshot of the current table is taken before executing the restore operation. In case of 787 * restore failure, the failsafe snapshot will be restored. If the restore completes without 788 * problem the failsafe snapshot is deleted. 789 * @param snapshotName name of the snapshot to restore 790 */ 791 CompletableFuture<Void> restoreSnapshot(String snapshotName); 792 793 /** 794 * Restore the specified snapshot on the original table. (The table must be disabled) If 795 * 'takeFailSafeSnapshot' is set to true, a snapshot of the current table is taken before 796 * executing the restore operation. In case of restore failure, the failsafe snapshot will be 797 * restored. If the restore completes without problem the failsafe snapshot is deleted. The 798 * failsafe snapshot name is configurable by using the property 799 * "hbase.snapshot.restore.failsafe.name". 800 * @param snapshotName name of the snapshot to restore 801 * @param takeFailSafeSnapshot true if the failsafe snapshot should be taken 802 */ 803 default CompletableFuture<Void> restoreSnapshot(String snapshotName, 804 boolean takeFailSafeSnapshot) { 805 return restoreSnapshot(snapshotName, takeFailSafeSnapshot, false); 806 } 807 808 /** 809 * Restore the specified snapshot on the original table. (The table must be disabled) If 810 * 'takeFailSafeSnapshot' is set to true, a snapshot of the current table is taken before 811 * executing the restore operation. In case of restore failure, the failsafe snapshot will be 812 * restored. If the restore completes without problem the failsafe snapshot is deleted. The 813 * failsafe snapshot name is configurable by using the property 814 * "hbase.snapshot.restore.failsafe.name". 815 * @param snapshotName name of the snapshot to restore 816 * @param takeFailSafeSnapshot true if the failsafe snapshot should be taken 817 * @param restoreAcl <code>true</code> to restore acl of snapshot 818 */ 819 CompletableFuture<Void> restoreSnapshot(String snapshotName, boolean takeFailSafeSnapshot, 820 boolean restoreAcl); 821 822 /** 823 * Create a new table by cloning the snapshot content. 824 * @param snapshotName name of the snapshot to be cloned 825 * @param tableName name of the table where the snapshot will be restored 826 */ 827 default CompletableFuture<Void> cloneSnapshot(String snapshotName, TableName tableName) { 828 return cloneSnapshot(snapshotName, tableName, false); 829 } 830 831 /** 832 * Create a new table by cloning the snapshot content. 833 * @param snapshotName name of the snapshot to be cloned 834 * @param tableName name of the table where the snapshot will be restored 835 * @param restoreAcl <code>true</code> to restore acl of snapshot 836 */ 837 CompletableFuture<Void> cloneSnapshot(String snapshotName, TableName tableName, 838 boolean restoreAcl); 839 840 /** 841 * List completed snapshots. 842 * @return a list of snapshot descriptors for completed snapshots wrapped by a 843 * {@link CompletableFuture} 844 */ 845 CompletableFuture<List<SnapshotDescription>> listSnapshots(); 846 847 /** 848 * List all the completed snapshots matching the given pattern. 849 * @param pattern The compiled regular expression to match against 850 * @return - returns a List of SnapshotDescription wrapped by a {@link CompletableFuture} 851 */ 852 CompletableFuture<List<SnapshotDescription>> listSnapshots(Pattern pattern); 853 854 /** 855 * List all the completed snapshots matching the given table name pattern. 856 * @param tableNamePattern The compiled table name regular expression to match against 857 * @return - returns a List of completed SnapshotDescription wrapped by a 858 * {@link CompletableFuture} 859 */ 860 CompletableFuture<List<SnapshotDescription>> listTableSnapshots(Pattern tableNamePattern); 861 862 /** 863 * List all the completed snapshots matching the given table name regular expression and snapshot 864 * name regular expression. 865 * @param tableNamePattern The compiled table name regular expression to match against 866 * @param snapshotNamePattern The compiled snapshot name regular expression to match against 867 * @return - returns a List of completed SnapshotDescription wrapped by a 868 * {@link CompletableFuture} 869 */ 870 CompletableFuture<List<SnapshotDescription>> listTableSnapshots(Pattern tableNamePattern, 871 Pattern snapshotNamePattern); 872 873 /** 874 * Delete an existing snapshot. 875 * @param snapshotName name of the snapshot 876 */ 877 CompletableFuture<Void> deleteSnapshot(String snapshotName); 878 879 /** 880 * Delete all existing snapshots. 881 */ 882 CompletableFuture<Void> deleteSnapshots(); 883 884 /** 885 * Delete existing snapshots whose names match the pattern passed. 886 * @param pattern pattern for names of the snapshot to match 887 */ 888 CompletableFuture<Void> deleteSnapshots(Pattern pattern); 889 890 /** 891 * Delete all existing snapshots matching the given table name pattern. 892 * @param tableNamePattern The compiled table name regular expression to match against 893 */ 894 CompletableFuture<Void> deleteTableSnapshots(Pattern tableNamePattern); 895 896 /** 897 * Delete all existing snapshots matching the given table name regular expression and snapshot 898 * name regular expression. 899 * @param tableNamePattern The compiled table name regular expression to match against 900 * @param snapshotNamePattern The compiled snapshot name regular expression to match against 901 */ 902 CompletableFuture<Void> deleteTableSnapshots(Pattern tableNamePattern, 903 Pattern snapshotNamePattern); 904 905 /** 906 * Execute a distributed procedure on a cluster. 907 * @param signature A distributed procedure is uniquely identified by its signature (default the 908 * root ZK node name of the procedure). 909 * @param instance The instance name of the procedure. For some procedures, this parameter is 910 * optional. 911 * @param props Property/Value pairs of properties passing to the procedure 912 */ 913 CompletableFuture<Void> execProcedure(String signature, String instance, 914 Map<String, String> props); 915 916 /** 917 * Execute a distributed procedure on a cluster. 918 * @param signature A distributed procedure is uniquely identified by its signature (default the 919 * root ZK node name of the procedure). 920 * @param instance The instance name of the procedure. For some procedures, this parameter is 921 * optional. 922 * @param props Property/Value pairs of properties passing to the procedure 923 * @return data returned after procedure execution. null if no return data. 924 */ 925 CompletableFuture<byte[]> execProcedureWithReturn(String signature, String instance, 926 Map<String, String> props); 927 928 /** 929 * Check the current state of the specified procedure. There are three possible states: 930 * <ol> 931 * <li>running - returns <tt>false</tt></li> 932 * <li>finished - returns <tt>true</tt></li> 933 * <li>finished with error - throws the exception that caused the procedure to fail</li> 934 * </ol> 935 * @param signature The signature that uniquely identifies a procedure 936 * @param instance The instance name of the procedure 937 * @param props Property/Value pairs of properties passing to the procedure 938 * @return true if the specified procedure is finished successfully, false if it is still running. 939 * The value is wrapped by {@link CompletableFuture} 940 */ 941 CompletableFuture<Boolean> isProcedureFinished(String signature, String instance, 942 Map<String, String> props); 943 944 /** 945 * Abort a procedure 946 * Do not use. Usually it is ignored but if not, it can do more damage than good. See hbck2. 947 * @param procId ID of the procedure to abort 948 * @param mayInterruptIfRunning if the proc completed at least one step, should it be aborted? 949 * @return true if aborted, false if procedure already completed or does not exist. the value is 950 * wrapped by {@link CompletableFuture} 951 * @deprecated since 2.1.1 and will be removed in 4.0.0. 952 * @see <a href="https://issues.apache.org/jira/browse/HBASE-21223">HBASE-21223</a> 953 */ 954 @Deprecated 955 CompletableFuture<Boolean> abortProcedure(long procId, boolean mayInterruptIfRunning); 956 957 /** 958 * List procedures 959 * @return procedure list JSON wrapped by {@link CompletableFuture} 960 */ 961 CompletableFuture<String> getProcedures(); 962 963 /** 964 * List locks. 965 * @return lock list JSON wrapped by {@link CompletableFuture} 966 */ 967 CompletableFuture<String> getLocks(); 968 969 /** 970 * Mark region server(s) as decommissioned to prevent additional regions from getting 971 * assigned to them. Optionally unload the regions on the servers. If there are multiple servers 972 * to be decommissioned, decommissioning them at the same time can prevent wasteful region 973 * movements. Region unloading is asynchronous. 974 * @param servers The list of servers to decommission. 975 * @param offload True to offload the regions from the decommissioned servers 976 */ 977 CompletableFuture<Void> decommissionRegionServers(List<ServerName> servers, boolean offload); 978 979 /** 980 * List region servers marked as decommissioned, which can not be assigned regions. 981 * @return List of decommissioned region servers wrapped by {@link CompletableFuture} 982 */ 983 CompletableFuture<List<ServerName>> listDecommissionedRegionServers(); 984 985 /** 986 * Remove decommission marker from a region server to allow regions assignments. Load regions onto 987 * the server if a list of regions is given. Region loading is asynchronous. 988 * @param server The server to recommission. 989 * @param encodedRegionNames Regions to load onto the server. 990 */ 991 CompletableFuture<Void> recommissionRegionServer(ServerName server, 992 List<byte[]> encodedRegionNames); 993 994 /** 995 * @return cluster status wrapped by {@link CompletableFuture} 996 */ 997 CompletableFuture<ClusterMetrics> getClusterMetrics(); 998 999 /** 1000 * @return cluster status wrapped by {@link CompletableFuture} 1001 */ 1002 CompletableFuture<ClusterMetrics> getClusterMetrics(EnumSet<Option> options); 1003 1004 /** 1005 * @return current master server name wrapped by {@link CompletableFuture} 1006 */ 1007 default CompletableFuture<ServerName> getMaster() { 1008 return getClusterMetrics(EnumSet.of(Option.MASTER)).thenApply(ClusterMetrics::getMasterName); 1009 } 1010 1011 /** 1012 * @return current backup master list wrapped by {@link CompletableFuture} 1013 */ 1014 default CompletableFuture<Collection<ServerName>> getBackupMasters() { 1015 return getClusterMetrics(EnumSet.of(Option.BACKUP_MASTERS)) 1016 .thenApply(ClusterMetrics::getBackupMasterNames); 1017 } 1018 1019 /** 1020 * @return current live region servers list wrapped by {@link CompletableFuture} 1021 */ 1022 default CompletableFuture<Collection<ServerName>> getRegionServers() { 1023 return getClusterMetrics(EnumSet.of(Option.SERVERS_NAME)) 1024 .thenApply(ClusterMetrics::getServersName); 1025 } 1026 1027 /** 1028 * @return a list of master coprocessors wrapped by {@link CompletableFuture} 1029 */ 1030 default CompletableFuture<List<String>> getMasterCoprocessorNames() { 1031 return getClusterMetrics(EnumSet.of(Option.MASTER_COPROCESSORS)) 1032 .thenApply(ClusterMetrics::getMasterCoprocessorNames); 1033 } 1034 1035 /** 1036 * Get the info port of the current master if one is available. 1037 * @return master info port 1038 */ 1039 default CompletableFuture<Integer> getMasterInfoPort() { 1040 return getClusterMetrics(EnumSet.of(Option.MASTER_INFO_PORT)).thenApply( 1041 ClusterMetrics::getMasterInfoPort); 1042 } 1043 1044 /** 1045 * Shuts down the HBase cluster. 1046 */ 1047 CompletableFuture<Void> shutdown(); 1048 1049 /** 1050 * Shuts down the current HBase master only. 1051 */ 1052 CompletableFuture<Void> stopMaster(); 1053 1054 /** 1055 * Stop the designated regionserver. 1056 * @param serverName 1057 */ 1058 CompletableFuture<Void> stopRegionServer(ServerName serverName); 1059 1060 /** 1061 * Update the configuration and trigger an online config change on the regionserver. 1062 * @param serverName : The server whose config needs to be updated. 1063 */ 1064 CompletableFuture<Void> updateConfiguration(ServerName serverName); 1065 1066 /** 1067 * Update the configuration and trigger an online config change on all the masters and 1068 * regionservers. 1069 */ 1070 CompletableFuture<Void> updateConfiguration(); 1071 1072 /** 1073 * Roll the log writer. I.e. for filesystem based write ahead logs, start writing to a new file. 1074 * <p> 1075 * When the returned CompletableFuture is done, it only means the rollWALWriter request was sent 1076 * to the region server and may need some time to finish the rollWALWriter operation. As a side 1077 * effect of this call, the named region server may schedule store flushes at the request of the 1078 * wal. 1079 * @param serverName The servername of the region server. 1080 */ 1081 CompletableFuture<Void> rollWALWriter(ServerName serverName); 1082 1083 /** 1084 * Clear compacting queues on a region server. 1085 * @param serverName 1086 * @param queues the set of queue name 1087 */ 1088 CompletableFuture<Void> clearCompactionQueues(ServerName serverName, Set<String> queues); 1089 1090 /** 1091 * Get a list of {@link RegionMetrics} of all regions hosted on a region seerver. 1092 * @param serverName 1093 * @return a list of {@link RegionMetrics} wrapped by {@link CompletableFuture} 1094 */ 1095 CompletableFuture<List<RegionMetrics>> getRegionMetrics(ServerName serverName); 1096 1097 /** 1098 * Get a list of {@link RegionMetrics} of all regions hosted on a region seerver for a table. 1099 * @param serverName 1100 * @param tableName 1101 * @return a list of {@link RegionMetrics} wrapped by {@link CompletableFuture} 1102 */ 1103 CompletableFuture<List<RegionMetrics>> getRegionMetrics(ServerName serverName, 1104 TableName tableName); 1105 1106 /** 1107 * Check whether master is in maintenance mode 1108 * @return true if master is in maintenance mode, false otherwise. The return value will be 1109 * wrapped by a {@link CompletableFuture} 1110 */ 1111 CompletableFuture<Boolean> isMasterInMaintenanceMode(); 1112 1113 /** 1114 * Get the current compaction state of a table. It could be in a major compaction, a minor 1115 * compaction, both, or none. 1116 * @param tableName table to examine 1117 * @return the current compaction state wrapped by a {@link CompletableFuture} 1118 */ 1119 default CompletableFuture<CompactionState> getCompactionState(TableName tableName) { 1120 return getCompactionState(tableName, CompactType.NORMAL); 1121 } 1122 1123 /** 1124 * Get the current compaction state of a table. It could be in a major compaction, a minor 1125 * compaction, both, or none. 1126 * @param tableName table to examine 1127 * @param compactType {@link org.apache.hadoop.hbase.client.CompactType} 1128 * @return the current compaction state wrapped by a {@link CompletableFuture} 1129 */ 1130 CompletableFuture<CompactionState> getCompactionState(TableName tableName, 1131 CompactType compactType); 1132 1133 /** 1134 * Get the current compaction state of region. It could be in a major compaction, a minor 1135 * compaction, both, or none. 1136 * @param regionName region to examine 1137 * @return the current compaction state wrapped by a {@link CompletableFuture} 1138 */ 1139 CompletableFuture<CompactionState> getCompactionStateForRegion(byte[] regionName); 1140 1141 /** 1142 * Get the timestamp of the last major compaction for the passed table. 1143 * <p> 1144 * The timestamp of the oldest HFile resulting from a major compaction of that table, or not 1145 * present if no such HFile could be found. 1146 * @param tableName table to examine 1147 * @return the last major compaction timestamp wrapped by a {@link CompletableFuture} 1148 */ 1149 CompletableFuture<Optional<Long>> getLastMajorCompactionTimestamp(TableName tableName); 1150 1151 /** 1152 * Get the timestamp of the last major compaction for the passed region. 1153 * <p> 1154 * The timestamp of the oldest HFile resulting from a major compaction of that region, or not 1155 * present if no such HFile could be found. 1156 * @param regionName region to examine 1157 * @return the last major compaction timestamp wrapped by a {@link CompletableFuture} 1158 */ 1159 CompletableFuture<Optional<Long>> getLastMajorCompactionTimestampForRegion(byte[] regionName); 1160 1161 /** 1162 * @return the list of supported security capabilities. The return value will be wrapped by a 1163 * {@link CompletableFuture}. 1164 */ 1165 CompletableFuture<List<SecurityCapability>> getSecurityCapabilities(); 1166 1167 /** 1168 * Turn the load balancer on or off. 1169 * @param on Set to <code>true</code> to enable, <code>false</code> to disable. 1170 * @return Previous balancer value wrapped by a {@link CompletableFuture}. 1171 */ 1172 default CompletableFuture<Boolean> balancerSwitch(boolean on) { 1173 return balancerSwitch(on, false); 1174 } 1175 1176 /** 1177 * Turn the load balancer on or off. 1178 * <p/> 1179 * Notice that, the method itself is always non-blocking, which means it will always return 1180 * immediately. The {@code drainRITs} parameter only effects when will we complete the returned 1181 * {@link CompletableFuture}. 1182 * @param on Set to <code>true</code> to enable, <code>false</code> to disable. 1183 * @param drainRITs If <code>true</code>, it waits until current balance() call, if outstanding, 1184 * to return. 1185 * @return Previous balancer value wrapped by a {@link CompletableFuture}. 1186 */ 1187 CompletableFuture<Boolean> balancerSwitch(boolean on, boolean drainRITs); 1188 1189 /** 1190 * Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the 1191 * reassignments. Can NOT run for various reasons. Check logs. 1192 * @return True if balancer ran, false otherwise. The return value will be wrapped by a 1193 * {@link CompletableFuture}. 1194 */ 1195 default CompletableFuture<Boolean> balance() { 1196 return balance(false); 1197 } 1198 1199 /** 1200 * Invoke the balancer. Will run the balancer and if regions to move, it will go ahead and do the 1201 * reassignments. If there is region in transition, force parameter of true would still run 1202 * balancer. Can *not* run for other reasons. Check logs. 1203 * @param forcible whether we should force balance even if there is region in transition. 1204 * @return True if balancer ran, false otherwise. The return value will be wrapped by a 1205 * {@link CompletableFuture}. 1206 */ 1207 CompletableFuture<Boolean> balance(boolean forcible); 1208 1209 /** 1210 * Query the current state of the balancer. 1211 * @return true if the balance switch is on, false otherwise. The return value will be wrapped by a 1212 * {@link CompletableFuture}. 1213 */ 1214 CompletableFuture<Boolean> isBalancerEnabled(); 1215 1216 /** 1217 * Set region normalizer on/off. 1218 * @param on whether normalizer should be on or off 1219 * @return Previous normalizer value wrapped by a {@link CompletableFuture} 1220 */ 1221 CompletableFuture<Boolean> normalizerSwitch(boolean on); 1222 1223 /** 1224 * Query the current state of the region normalizer 1225 * @return true if region normalizer is on, false otherwise. The return value will be wrapped by a 1226 * {@link CompletableFuture} 1227 */ 1228 CompletableFuture<Boolean> isNormalizerEnabled(); 1229 1230 /** 1231 * Invoke region normalizer. Can NOT run for various reasons. Check logs. 1232 * @return true if region normalizer ran, false otherwise. The return value will be wrapped by a 1233 * {@link CompletableFuture} 1234 */ 1235 CompletableFuture<Boolean> normalize(); 1236 1237 /** 1238 * Turn the cleaner chore on/off. 1239 * @param on 1240 * @return Previous cleaner state wrapped by a {@link CompletableFuture} 1241 */ 1242 CompletableFuture<Boolean> cleanerChoreSwitch(boolean on); 1243 1244 /** 1245 * Query the current state of the cleaner chore. 1246 * @return true if cleaner chore is on, false otherwise. The return value will be wrapped by 1247 * a {@link CompletableFuture} 1248 */ 1249 CompletableFuture<Boolean> isCleanerChoreEnabled(); 1250 1251 /** 1252 * Ask for cleaner chore to run. 1253 * @return true if cleaner chore ran, false otherwise. The return value will be wrapped by a 1254 * {@link CompletableFuture} 1255 */ 1256 CompletableFuture<Boolean> runCleanerChore(); 1257 1258 /** 1259 * Turn the catalog janitor on/off. 1260 * @param on 1261 * @return the previous state wrapped by a {@link CompletableFuture} 1262 */ 1263 CompletableFuture<Boolean> catalogJanitorSwitch(boolean on); 1264 1265 /** 1266 * Query on the catalog janitor state. 1267 * @return true if the catalog janitor is on, false otherwise. The return value will be 1268 * wrapped by a {@link CompletableFuture} 1269 */ 1270 CompletableFuture<Boolean> isCatalogJanitorEnabled(); 1271 1272 /** 1273 * Ask for a scan of the catalog table. 1274 * @return the number of entries cleaned. The return value will be wrapped by a 1275 * {@link CompletableFuture} 1276 */ 1277 CompletableFuture<Integer> runCatalogJanitor(); 1278 1279 /** 1280 * Execute the given coprocessor call on the master. 1281 * <p> 1282 * The {@code stubMaker} is just a delegation to the {@code newStub} call. Usually it is only a 1283 * one line lambda expression, like: 1284 * 1285 * <pre> 1286 * <code> 1287 * channel -> xxxService.newStub(channel) 1288 * </code> 1289 * </pre> 1290 * @param stubMaker a delegation to the actual {@code newStub} call. 1291 * @param callable a delegation to the actual protobuf rpc call. See the comment of 1292 * {@link ServiceCaller} for more details. 1293 * @param <S> the type of the asynchronous stub 1294 * @param <R> the type of the return value 1295 * @return the return value of the protobuf rpc call, wrapped by a {@link CompletableFuture}. 1296 * @see ServiceCaller 1297 */ 1298 <S, R> CompletableFuture<R> coprocessorService(Function<RpcChannel, S> stubMaker, 1299 ServiceCaller<S, R> callable); 1300 1301 /** 1302 * Execute the given coprocessor call on the given region server. 1303 * <p> 1304 * The {@code stubMaker} is just a delegation to the {@code newStub} call. Usually it is only a 1305 * one line lambda expression, like: 1306 * 1307 * <pre> 1308 * <code> 1309 * channel -> xxxService.newStub(channel) 1310 * </code> 1311 * </pre> 1312 * @param stubMaker a delegation to the actual {@code newStub} call. 1313 * @param callable a delegation to the actual protobuf rpc call. See the comment of 1314 * {@link ServiceCaller} for more details. 1315 * @param serverName the given region server 1316 * @param <S> the type of the asynchronous stub 1317 * @param <R> the type of the return value 1318 * @return the return value of the protobuf rpc call, wrapped by a {@link CompletableFuture}. 1319 * @see ServiceCaller 1320 */ 1321 <S, R> CompletableFuture<R> coprocessorService(Function<RpcChannel, S> stubMaker, 1322 ServiceCaller<S, R> callable, ServerName serverName); 1323 1324 /** 1325 * List all the dead region servers. 1326 */ 1327 default CompletableFuture<List<ServerName>> listDeadServers() { 1328 return this.getClusterMetrics(EnumSet.of(Option.DEAD_SERVERS)) 1329 .thenApply(ClusterMetrics::getDeadServerNames); 1330 } 1331 1332 /** 1333 * Clear dead region servers from master. 1334 * @param servers list of dead region servers. 1335 * @return - returns a list of servers that not cleared wrapped by a {@link CompletableFuture}. 1336 */ 1337 CompletableFuture<List<ServerName>> clearDeadServers(final List<ServerName> servers); 1338 1339 /** 1340 * Clear all the blocks corresponding to this table from BlockCache. For expert-admins. Calling 1341 * this API will drop all the cached blocks specific to a table from BlockCache. This can 1342 * significantly impact the query performance as the subsequent queries will have to retrieve the 1343 * blocks from underlying filesystem. 1344 * @param tableName table to clear block cache 1345 * @return CacheEvictionStats related to the eviction wrapped by a {@link CompletableFuture}. 1346 */ 1347 CompletableFuture<CacheEvictionStats> clearBlockCache(final TableName tableName); 1348 1349 /** 1350 * Create a new table by cloning the existent table schema. 1351 * 1352 * @param tableName name of the table to be cloned 1353 * @param newTableName name of the new table where the table will be created 1354 * @param preserveSplits True if the splits should be preserved 1355 */ 1356 CompletableFuture<Void> cloneTableSchema(final TableName tableName, 1357 final TableName newTableName, final boolean preserveSplits); 1358 1359 /** 1360 * Turn the compaction on or off. Disabling compactions will also interrupt any currently ongoing 1361 * compactions. This state is ephemeral. The setting will be lost on restart. Compaction 1362 * can also be enabled/disabled by modifying configuration hbase.regionserver.compaction.enabled 1363 * in hbase-site.xml. 1364 * 1365 * @param switchState Set to <code>true</code> to enable, <code>false</code> to disable. 1366 * @param serverNamesList list of region servers. 1367 * @return Previous compaction states for region servers 1368 */ 1369 CompletableFuture<Map<ServerName, Boolean>> compactionSwitch(boolean switchState, 1370 List<String> serverNamesList); 1371 1372 /** 1373 * Switch the rpc throttle enabled state. 1374 * @param enable Set to <code>true</code> to enable, <code>false</code> to disable. 1375 * @return Previous rpc throttle enabled value 1376 */ 1377 CompletableFuture<Boolean> switchRpcThrottle(boolean enable); 1378 1379 /** 1380 * Get if the rpc throttle is enabled. 1381 * @return True if rpc throttle is enabled 1382 */ 1383 CompletableFuture<Boolean> isRpcThrottleEnabled(); 1384 1385 /** 1386 * Switch the exceed throttle quota. If enabled, user/table/namespace throttle quota 1387 * can be exceeded if region server has availble quota. 1388 * @param enable Set to <code>true</code> to enable, <code>false</code> to disable. 1389 * @return Previous exceed throttle enabled value 1390 */ 1391 CompletableFuture<Boolean> exceedThrottleQuotaSwitch(boolean enable); 1392 1393 /** 1394 * Fetches the table sizes on the filesystem as tracked by the HBase Master. 1395 */ 1396 CompletableFuture<Map<TableName, Long>> getSpaceQuotaTableSizes(); 1397 1398 /** 1399 * Fetches the observed {@link SpaceQuotaSnapshotView}s observed by a RegionServer. 1400 */ 1401 CompletableFuture<? extends Map<TableName, ? extends SpaceQuotaSnapshotView>> 1402 getRegionServerSpaceQuotaSnapshots(ServerName serverName); 1403 1404 /** 1405 * Returns the Master's view of a quota on the given {@code namespace} or null if the Master has 1406 * no quota information on that namespace. 1407 */ 1408 CompletableFuture<? extends SpaceQuotaSnapshotView> 1409 getCurrentSpaceQuotaSnapshot(String namespace); 1410 1411 /** 1412 * Returns the Master's view of a quota on the given {@code tableName} or null if the Master has 1413 * no quota information on that table. 1414 */ 1415 CompletableFuture<? extends SpaceQuotaSnapshotView> getCurrentSpaceQuotaSnapshot( 1416 TableName tableName); 1417 1418 /** 1419 * Grants user specific permissions 1420 * @param userPermission user name and the specific permission 1421 * @param mergeExistingPermissions If set to false, later granted permissions will override 1422 * previous granted permissions. otherwise, it'll merge with previous granted 1423 * permissions. 1424 */ 1425 CompletableFuture<Void> grant(UserPermission userPermission, boolean mergeExistingPermissions); 1426 1427 /** 1428 * Revokes user specific permissions 1429 * @param userPermission user name and the specific permission 1430 */ 1431 CompletableFuture<Void> revoke(UserPermission userPermission); 1432 1433 /** 1434 * Get the global/namespace/table permissions for user 1435 * @param getUserPermissionsRequest A request contains which user, global, namespace or table 1436 * permissions needed 1437 * @return The user and permission list 1438 */ 1439 CompletableFuture<List<UserPermission>> 1440 getUserPermissions(GetUserPermissionsRequest getUserPermissionsRequest); 1441 1442 /** 1443 * Check if the user has specific permissions 1444 * @param userName the user name 1445 * @param permissions the specific permission list 1446 * @return True if user has the specific permissions 1447 */ 1448 CompletableFuture<List<Boolean>> hasUserPermissions(String userName, 1449 List<Permission> permissions); 1450 1451 /** 1452 * Check if call user has specific permissions 1453 * @param permissions the specific permission list 1454 * @return True if user has the specific permissions 1455 */ 1456 default CompletableFuture<List<Boolean>> hasUserPermissions(List<Permission> permissions) { 1457 return hasUserPermissions(null, permissions); 1458 } 1459}