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.client.ConnectionUtils.setCoprocessorError; 021import static org.apache.hadoop.hbase.util.FutureUtils.get; 022 023import java.io.IOException; 024import java.util.Arrays; 025import java.util.EnumSet; 026import java.util.List; 027import java.util.Map; 028import java.util.Set; 029import java.util.concurrent.Future; 030import java.util.regex.Pattern; 031import org.apache.hadoop.conf.Configuration; 032import org.apache.hadoop.hbase.CacheEvictionStats; 033import org.apache.hadoop.hbase.ClusterMetrics; 034import org.apache.hadoop.hbase.ClusterMetrics.Option; 035import org.apache.hadoop.hbase.HConstants; 036import org.apache.hadoop.hbase.NamespaceDescriptor; 037import org.apache.hadoop.hbase.NamespaceNotFoundException; 038import org.apache.hadoop.hbase.RegionMetrics; 039import org.apache.hadoop.hbase.ServerName; 040import org.apache.hadoop.hbase.TableExistsException; 041import org.apache.hadoop.hbase.TableName; 042import org.apache.hadoop.hbase.TableNotFoundException; 043import org.apache.hadoop.hbase.client.replication.TableCFs; 044import org.apache.hadoop.hbase.client.security.SecurityCapability; 045import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel; 046import org.apache.hadoop.hbase.net.Address; 047import org.apache.hadoop.hbase.quotas.QuotaFilter; 048import org.apache.hadoop.hbase.quotas.QuotaSettings; 049import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshotView; 050import org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException; 051import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; 052import org.apache.hadoop.hbase.replication.ReplicationPeerDescription; 053import org.apache.hadoop.hbase.replication.SyncReplicationState; 054import org.apache.hadoop.hbase.rsgroup.RSGroupInfo; 055import org.apache.hadoop.hbase.security.access.GetUserPermissionsRequest; 056import org.apache.hadoop.hbase.security.access.Permission; 057import org.apache.hadoop.hbase.security.access.UserPermission; 058import org.apache.hadoop.hbase.snapshot.HBaseSnapshotException; 059import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException; 060import org.apache.hadoop.hbase.snapshot.SnapshotCreationException; 061import org.apache.hadoop.hbase.snapshot.UnknownSnapshotException; 062import org.apache.hadoop.hbase.util.Bytes; 063import org.apache.hadoop.hbase.util.Pair; 064import org.apache.yetus.audience.InterfaceAudience; 065import org.slf4j.Logger; 066import org.slf4j.LoggerFactory; 067 068import org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor; 069import org.apache.hbase.thirdparty.com.google.protobuf.Message; 070import org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback; 071import org.apache.hbase.thirdparty.com.google.protobuf.RpcChannel; 072import org.apache.hbase.thirdparty.com.google.protobuf.RpcController; 073import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException; 074 075/** 076 * The {@link Admin} implementation which is based on an {@link AsyncAdmin}. 077 */ 078@InterfaceAudience.Private 079class AdminOverAsyncAdmin implements Admin { 080 081 private static final Logger LOG = LoggerFactory.getLogger(AdminOverAsyncAdmin.class); 082 083 private volatile boolean aborted = false; 084 085 private final Connection conn; 086 087 private final RawAsyncHBaseAdmin admin; 088 089 private final int operationTimeout; 090 091 private final int syncWaitTimeout; 092 093 public AdminOverAsyncAdmin(Connection conn, RawAsyncHBaseAdmin admin) { 094 this.conn = conn; 095 this.admin = admin; 096 this.operationTimeout = conn.getConfiguration().getInt( 097 HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT); 098 this.syncWaitTimeout = 099 conn.getConfiguration().getInt("hbase.client.sync.wait.timeout.msec", 10 * 60000); // 10min 100 } 101 102 @Override 103 public int getOperationTimeout() { 104 return operationTimeout; 105 } 106 107 @Override 108 public int getSyncWaitTimeout() { 109 return syncWaitTimeout; 110 } 111 112 @Override 113 public void abort(String why, Throwable e) { 114 LOG.warn("Aborting becasue of {}", why, e); 115 this.aborted = true; 116 } 117 118 @Override 119 public boolean isAborted() { 120 return aborted; 121 } 122 123 @Override 124 public Connection getConnection() { 125 return conn; 126 } 127 128 @Override 129 public boolean tableExists(TableName tableName) throws IOException { 130 return get(admin.tableExists(tableName)); 131 } 132 133 @Override 134 public List<TableDescriptor> listTableDescriptors() throws IOException { 135 return get(admin.listTableDescriptors()); 136 } 137 138 @Override 139 public List<TableDescriptor> listTableDescriptors(boolean includeSysTables) throws IOException { 140 return get(admin.listTableDescriptors(includeSysTables)); 141 } 142 143 @Override 144 public List<TableDescriptor> listTableDescriptors(Pattern pattern, boolean includeSysTables) 145 throws IOException { 146 return get(admin.listTableDescriptors(pattern, includeSysTables)); 147 } 148 149 @Override 150 public TableName[] listTableNames() throws IOException { 151 return get(admin.listTableNames()).toArray(new TableName[0]); 152 } 153 154 @Override 155 public TableName[] listTableNames(Pattern pattern, boolean includeSysTables) throws IOException { 156 return get(admin.listTableNames(pattern, includeSysTables)).toArray(new TableName[0]); 157 } 158 159 @Override 160 public TableDescriptor getDescriptor(TableName tableName) 161 throws TableNotFoundException, IOException { 162 return get(admin.getDescriptor(tableName)); 163 } 164 165 @Override 166 public void createTable(TableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions) 167 throws IOException { 168 get(admin.createTable(desc, startKey, endKey, numRegions)); 169 } 170 171 @Override 172 public Future<Void> createTableAsync(TableDescriptor desc) throws IOException { 173 return admin.createTable(desc); 174 } 175 176 @Override 177 public Future<Void> createTableAsync(TableDescriptor desc, byte[][] splitKeys) 178 throws IOException { 179 return admin.createTable(desc, splitKeys); 180 } 181 182 @Override 183 public Future<Void> deleteTableAsync(TableName tableName) throws IOException { 184 return admin.deleteTable(tableName); 185 } 186 187 @Override 188 public Future<Void> truncateTableAsync(TableName tableName, boolean preserveSplits) 189 throws IOException { 190 return admin.truncateTable(tableName, preserveSplits); 191 } 192 193 @Override 194 public Future<Void> enableTableAsync(TableName tableName) throws IOException { 195 return admin.enableTable(tableName); 196 } 197 198 @Override 199 public Future<Void> disableTableAsync(TableName tableName) throws IOException { 200 return admin.disableTable(tableName); 201 } 202 203 @Override 204 public boolean isTableEnabled(TableName tableName) throws IOException { 205 return get(admin.isTableEnabled(tableName)); 206 } 207 208 @Override 209 public boolean isTableDisabled(TableName tableName) throws IOException { 210 return get(admin.isTableDisabled(tableName)); 211 } 212 213 @Override 214 public boolean isTableAvailable(TableName tableName) throws IOException { 215 return get(admin.isTableAvailable(tableName)); 216 } 217 218 @Override 219 public Future<Void> addColumnFamilyAsync(TableName tableName, ColumnFamilyDescriptor columnFamily) 220 throws IOException { 221 return admin.addColumnFamily(tableName, columnFamily); 222 } 223 224 @Override 225 public Future<Void> deleteColumnFamilyAsync(TableName tableName, byte[] columnFamily) 226 throws IOException { 227 return admin.deleteColumnFamily(tableName, columnFamily); 228 } 229 230 @Override 231 public Future<Void> modifyColumnFamilyAsync(TableName tableName, 232 ColumnFamilyDescriptor columnFamily) throws IOException { 233 return admin.modifyColumnFamily(tableName, columnFamily); 234 } 235 236 @Override 237 public Future<Void> modifyColumnFamilyStoreFileTrackerAsync(TableName tableName, byte[] family, 238 String dstSFT) throws IOException { 239 return admin.modifyColumnFamilyStoreFileTracker(tableName, family, dstSFT); 240 } 241 242 @Override 243 public List<RegionInfo> getRegions(ServerName serverName) throws IOException { 244 return get(admin.getRegions(serverName)); 245 } 246 247 @Override 248 public void flush(TableName tableName) throws IOException { 249 get(admin.flush(tableName)); 250 } 251 252 @Override 253 public void flush(TableName tableName, byte[] columnFamily) throws IOException { 254 get(admin.flush(tableName, columnFamily)); 255 } 256 257 @Override 258 public void flushRegion(byte[] regionName) throws IOException { 259 get(admin.flushRegion(regionName)); 260 } 261 262 @Override 263 public void flushRegion(byte[] regionName, byte[] columnFamily) throws IOException { 264 get(admin.flushRegion(regionName, columnFamily)); 265 } 266 267 @Override 268 public void flushRegionServer(ServerName serverName) throws IOException { 269 get(admin.flushRegionServer(serverName)); 270 } 271 272 @Override 273 public void compact(TableName tableName) throws IOException { 274 get(admin.compact(tableName)); 275 } 276 277 @Override 278 public void compactRegion(byte[] regionName) throws IOException { 279 get(admin.compactRegion(regionName)); 280 } 281 282 @Override 283 public void compact(TableName tableName, byte[] columnFamily) throws IOException { 284 get(admin.compact(tableName, columnFamily)); 285 } 286 287 @Override 288 public void compactRegion(byte[] regionName, byte[] columnFamily) throws IOException { 289 get(admin.compactRegion(regionName, columnFamily)); 290 } 291 292 @Override 293 public void compact(TableName tableName, CompactType compactType) 294 throws IOException, InterruptedException { 295 get(admin.compact(tableName, compactType)); 296 } 297 298 @Override 299 public void compact(TableName tableName, byte[] columnFamily, CompactType compactType) 300 throws IOException, InterruptedException { 301 get(admin.compact(tableName, columnFamily, compactType)); 302 } 303 304 @Override 305 public void majorCompact(TableName tableName) throws IOException { 306 get(admin.majorCompact(tableName)); 307 } 308 309 @Override 310 public void majorCompactRegion(byte[] regionName) throws IOException { 311 get(admin.majorCompactRegion(regionName)); 312 } 313 314 @Override 315 public void majorCompact(TableName tableName, byte[] columnFamily) throws IOException { 316 get(admin.majorCompact(tableName, columnFamily)); 317 } 318 319 @Override 320 public void majorCompactRegion(byte[] regionName, byte[] columnFamily) throws IOException { 321 get(admin.majorCompactRegion(regionName, columnFamily)); 322 } 323 324 @Override 325 public void majorCompact(TableName tableName, CompactType compactType) 326 throws IOException, InterruptedException { 327 get(admin.majorCompact(tableName, compactType)); 328 } 329 330 @Override 331 public void majorCompact(TableName tableName, byte[] columnFamily, CompactType compactType) 332 throws IOException, InterruptedException { 333 get(admin.majorCompact(tableName, columnFamily, compactType)); 334 } 335 336 @Override 337 public Map<ServerName, Boolean> compactionSwitch(boolean switchState, 338 List<String> serverNamesList) throws IOException { 339 return get(admin.compactionSwitch(switchState, serverNamesList)); 340 } 341 342 @Override 343 public void compactRegionServer(ServerName serverName) throws IOException { 344 get(admin.compactRegionServer(serverName)); 345 } 346 347 @Override 348 public void majorCompactRegionServer(ServerName serverName) throws IOException { 349 get(admin.majorCompactRegionServer(serverName)); 350 } 351 352 @Override 353 public void move(byte[] encodedRegionName) throws IOException { 354 get(admin.move(encodedRegionName)); 355 } 356 357 @Override 358 public void move(byte[] encodedRegionName, ServerName destServerName) throws IOException { 359 get(admin.move(encodedRegionName, destServerName)); 360 } 361 362 @Override 363 public void assign(byte[] regionName) throws IOException { 364 get(admin.assign(regionName)); 365 } 366 367 @Override 368 public void unassign(byte[] regionName) throws IOException { 369 get(admin.unassign(regionName)); 370 } 371 372 @Override 373 public void offline(byte[] regionName) throws IOException { 374 get(admin.offline(regionName)); 375 } 376 377 @Override 378 public boolean balancerSwitch(boolean onOrOff, boolean synchronous) throws IOException { 379 return get(admin.balancerSwitch(onOrOff, synchronous)); 380 } 381 382 public BalanceResponse balance(BalanceRequest request) throws IOException { 383 return get(admin.balance(request)); 384 } 385 386 @Override 387 public boolean balance() throws IOException { 388 return get(admin.balance()); 389 } 390 391 @Override 392 public boolean balance(boolean force) throws IOException { 393 return get(admin.balance(force)); 394 } 395 396 @Override 397 public boolean isBalancerEnabled() throws IOException { 398 return get(admin.isBalancerEnabled()); 399 } 400 401 @Override 402 public CacheEvictionStats clearBlockCache(TableName tableName) throws IOException { 403 return get(admin.clearBlockCache(tableName)); 404 } 405 406 @Override 407 public boolean normalize(NormalizeTableFilterParams ntfp) throws IOException { 408 return get(admin.normalize(ntfp)); 409 } 410 411 @Override 412 public boolean isNormalizerEnabled() throws IOException { 413 return get(admin.isNormalizerEnabled()); 414 } 415 416 @Override 417 public boolean normalizerSwitch(boolean on) throws IOException { 418 return get(admin.normalizerSwitch(on)); 419 } 420 421 @Override 422 public boolean catalogJanitorSwitch(boolean onOrOff) throws IOException { 423 return get(admin.catalogJanitorSwitch(onOrOff)); 424 } 425 426 @Override 427 public int runCatalogJanitor() throws IOException { 428 return get(admin.runCatalogJanitor()); 429 } 430 431 @Override 432 public boolean isCatalogJanitorEnabled() throws IOException { 433 return get(admin.isCatalogJanitorEnabled()); 434 } 435 436 @Override 437 public boolean cleanerChoreSwitch(boolean onOrOff) throws IOException { 438 return get(admin.cleanerChoreSwitch(onOrOff)); 439 } 440 441 @Override 442 public boolean runCleanerChore() throws IOException { 443 return get(admin.runCleanerChore()); 444 } 445 446 @Override 447 public boolean isCleanerChoreEnabled() throws IOException { 448 return get(admin.isCleanerChoreEnabled()); 449 } 450 451 @Override 452 public Future<Void> mergeRegionsAsync(byte[][] nameOfRegionsToMerge, boolean forcible) 453 throws IOException { 454 return admin.mergeRegions(Arrays.asList(nameOfRegionsToMerge), forcible); 455 } 456 457 @Override 458 public void split(TableName tableName) throws IOException { 459 get(admin.split(tableName)); 460 } 461 462 @Override 463 public void split(TableName tableName, byte[] splitPoint) throws IOException { 464 get(admin.split(tableName, splitPoint)); 465 } 466 467 @Override 468 public Future<Void> splitRegionAsync(byte[] regionName) throws IOException { 469 return admin.splitRegion(regionName); 470 } 471 472 @Override 473 public Future<Void> splitRegionAsync(byte[] regionName, byte[] splitPoint) throws IOException { 474 return admin.splitRegion(regionName, splitPoint); 475 } 476 477 @Override 478 public Future<Void> modifyTableAsync(TableDescriptor td) throws IOException { 479 return admin.modifyTable(td); 480 } 481 482 @Override 483 public Future<Void> modifyTableStoreFileTrackerAsync(TableName tableName, String dstSFT) 484 throws IOException { 485 return admin.modifyTableStoreFileTracker(tableName, dstSFT); 486 } 487 488 @Override 489 public void shutdown() throws IOException { 490 get(admin.shutdown()); 491 } 492 493 @Override 494 public void stopMaster() throws IOException { 495 get(admin.stopMaster()); 496 } 497 498 @Override 499 public boolean isMasterInMaintenanceMode() throws IOException { 500 return get(admin.isMasterInMaintenanceMode()); 501 } 502 503 @Override 504 public void stopRegionServer(String hostnamePort) throws IOException { 505 get(admin.stopRegionServer(ServerName.valueOf(hostnamePort, 0))); 506 } 507 508 @Override 509 public ClusterMetrics getClusterMetrics(EnumSet<Option> options) throws IOException { 510 return get(admin.getClusterMetrics(options)); 511 } 512 513 @Override 514 public List<RegionMetrics> getRegionMetrics(ServerName serverName) throws IOException { 515 return get(admin.getRegionMetrics(serverName)); 516 } 517 518 @Override 519 public List<RegionMetrics> getRegionMetrics(ServerName serverName, TableName tableName) 520 throws IOException { 521 return get(admin.getRegionMetrics(serverName, tableName)); 522 } 523 524 @Override 525 public Configuration getConfiguration() { 526 return conn.getConfiguration(); 527 } 528 529 @Override 530 public Future<Void> createNamespaceAsync(NamespaceDescriptor descriptor) throws IOException { 531 return admin.createNamespace(descriptor); 532 } 533 534 @Override 535 public Future<Void> modifyNamespaceAsync(NamespaceDescriptor descriptor) throws IOException { 536 return admin.modifyNamespace(descriptor); 537 } 538 539 @Override 540 public Future<Void> deleteNamespaceAsync(String name) throws IOException { 541 return admin.deleteNamespace(name); 542 } 543 544 @Override 545 public NamespaceDescriptor getNamespaceDescriptor(String name) 546 throws NamespaceNotFoundException, IOException { 547 return get(admin.getNamespaceDescriptor(name)); 548 } 549 550 @Override 551 public String[] listNamespaces() throws IOException { 552 return get(admin.listNamespaces()).toArray(new String[0]); 553 } 554 555 @Override 556 public NamespaceDescriptor[] listNamespaceDescriptors() throws IOException { 557 return get(admin.listNamespaceDescriptors()).toArray(new NamespaceDescriptor[0]); 558 } 559 560 @Override 561 public List<TableDescriptor> listTableDescriptorsByNamespace(byte[] name) throws IOException { 562 return get(admin.listTableDescriptorsByNamespace(Bytes.toString(name))); 563 } 564 565 @Override 566 public TableName[] listTableNamesByNamespace(String name) throws IOException { 567 return get(admin.listTableNamesByNamespace(name)).toArray(new TableName[0]); 568 } 569 570 @Override 571 public List<RegionInfo> getRegions(TableName tableName) throws IOException { 572 return get(admin.getRegions(tableName)); 573 } 574 575 @Override 576 public void close() { 577 // do nothing, AsyncAdmin is not a Closeable. 578 } 579 580 @Override 581 public List<TableDescriptor> listTableDescriptors(List<TableName> tableNames) throws IOException { 582 return get(admin.listTableDescriptors(tableNames)); 583 } 584 585 @Override 586 public Future<Boolean> abortProcedureAsync(long procId, boolean mayInterruptIfRunning) 587 throws IOException { 588 return admin.abortProcedure(procId, mayInterruptIfRunning); 589 } 590 591 @Override 592 public String getProcedures() throws IOException { 593 return get(admin.getProcedures()); 594 } 595 596 @Override 597 public String getLocks() throws IOException { 598 return get(admin.getLocks()); 599 } 600 601 @Override 602 public void rollWALWriter(ServerName serverName) throws IOException, FailedLogCloseException { 603 get(admin.rollWALWriter(serverName)); 604 } 605 606 @Override 607 public CompactionState getCompactionState(TableName tableName) throws IOException { 608 return get(admin.getCompactionState(tableName)); 609 } 610 611 @Override 612 public CompactionState getCompactionState(TableName tableName, CompactType compactType) 613 throws IOException { 614 return get(admin.getCompactionState(tableName, compactType)); 615 } 616 617 @Override 618 public CompactionState getCompactionStateForRegion(byte[] regionName) throws IOException { 619 return get(admin.getCompactionStateForRegion(regionName)); 620 } 621 622 @Override 623 public long getLastMajorCompactionTimestamp(TableName tableName) throws IOException { 624 return get(admin.getLastMajorCompactionTimestamp(tableName)).orElse(0L); 625 } 626 627 @Override 628 public long getLastMajorCompactionTimestampForRegion(byte[] regionName) throws IOException { 629 return get(admin.getLastMajorCompactionTimestampForRegion(regionName)).orElse(0L); 630 } 631 632 @Override 633 public void snapshot(SnapshotDescription snapshot) 634 throws IOException, SnapshotCreationException, IllegalArgumentException { 635 get(admin.snapshot(snapshot)); 636 } 637 638 @Override 639 public Future<Void> snapshotAsync(SnapshotDescription snapshot) 640 throws IOException, SnapshotCreationException { 641 return admin.snapshot(snapshot); 642 } 643 644 @Override 645 public boolean isSnapshotFinished(SnapshotDescription snapshot) 646 throws IOException, HBaseSnapshotException, UnknownSnapshotException { 647 return get(admin.isSnapshotFinished(snapshot)); 648 } 649 650 @Override 651 public void restoreSnapshot(String snapshotName) throws IOException, RestoreSnapshotException { 652 get(admin.restoreSnapshot(snapshotName)); 653 } 654 655 @Override 656 public void restoreSnapshot(String snapshotName, boolean takeFailSafeSnapshot, boolean restoreAcl) 657 throws IOException, RestoreSnapshotException { 658 get(admin.restoreSnapshot(snapshotName, takeFailSafeSnapshot, restoreAcl)); 659 } 660 661 @Override 662 public Future<Void> cloneSnapshotAsync(String snapshotName, TableName tableName, 663 boolean restoreAcl, String customSFT) 664 throws IOException, TableExistsException, RestoreSnapshotException { 665 return admin.cloneSnapshot(snapshotName, tableName, restoreAcl, customSFT); 666 } 667 668 @Override 669 public void execProcedure(String signature, String instance, Map<String, String> props) 670 throws IOException { 671 get(admin.execProcedure(signature, instance, props)); 672 } 673 674 @Override 675 public byte[] execProcedureWithReturn(String signature, String instance, 676 Map<String, String> props) throws IOException { 677 return get(admin.execProcedureWithReturn(signature, instance, props)); 678 } 679 680 @Override 681 public boolean isProcedureFinished(String signature, String instance, Map<String, String> props) 682 throws IOException { 683 return get(admin.isProcedureFinished(signature, instance, props)); 684 } 685 686 @Override 687 public List<SnapshotDescription> listSnapshots() throws IOException { 688 return get(admin.listSnapshots()); 689 } 690 691 @Override 692 public List<SnapshotDescription> listSnapshots(Pattern pattern) throws IOException { 693 return get(admin.listSnapshots(pattern)); 694 } 695 696 @Override 697 public List<SnapshotDescription> listTableSnapshots(Pattern tableNamePattern, 698 Pattern snapshotNamePattern) throws IOException { 699 return get(admin.listTableSnapshots(tableNamePattern, snapshotNamePattern)); 700 } 701 702 @Override 703 public void deleteSnapshot(String snapshotName) throws IOException { 704 get(admin.deleteSnapshot(snapshotName)); 705 } 706 707 @Override 708 public void deleteSnapshots(Pattern pattern) throws IOException { 709 get(admin.deleteSnapshots(pattern)); 710 } 711 712 @Override 713 public void deleteTableSnapshots(Pattern tableNamePattern, Pattern snapshotNamePattern) 714 throws IOException { 715 get(admin.deleteTableSnapshots(tableNamePattern, snapshotNamePattern)); 716 } 717 718 @Override 719 public void setQuota(QuotaSettings quota) throws IOException { 720 get(admin.setQuota(quota)); 721 } 722 723 @Override 724 public List<QuotaSettings> getQuota(QuotaFilter filter) throws IOException { 725 return get(admin.getQuota(filter)); 726 } 727 728 @SuppressWarnings("deprecation") 729 private static final class SyncCoprocessorRpcChannelOverAsync implements CoprocessorRpcChannel { 730 731 private final RpcChannel delegate; 732 733 public SyncCoprocessorRpcChannelOverAsync(RpcChannel delegate) { 734 this.delegate = delegate; 735 } 736 737 @Override 738 public void callMethod(MethodDescriptor method, RpcController controller, Message request, 739 Message responsePrototype, RpcCallback<Message> done) { 740 ClientCoprocessorRpcController c = new ClientCoprocessorRpcController(); 741 CoprocessorBlockingRpcCallback<Message> callback = new CoprocessorBlockingRpcCallback<>(); 742 delegate.callMethod(method, c, request, responsePrototype, callback); 743 Message ret; 744 try { 745 ret = callback.get(); 746 } catch (IOException e) { 747 setCoprocessorError(controller, e); 748 return; 749 } 750 if (c.failed()) { 751 setCoprocessorError(controller, c.getFailed()); 752 } 753 done.run(ret); 754 } 755 756 @Override 757 public Message callBlockingMethod(MethodDescriptor method, RpcController controller, 758 Message request, Message responsePrototype) throws ServiceException { 759 ClientCoprocessorRpcController c = new ClientCoprocessorRpcController(); 760 CoprocessorBlockingRpcCallback<Message> done = new CoprocessorBlockingRpcCallback<>(); 761 callMethod(method, c, request, responsePrototype, done); 762 Message ret; 763 try { 764 ret = done.get(); 765 } catch (IOException e) { 766 throw new ServiceException(e); 767 } 768 if (c.failed()) { 769 setCoprocessorError(controller, c.getFailed()); 770 throw new ServiceException(c.getFailed()); 771 } 772 return ret; 773 } 774 } 775 776 @SuppressWarnings("deprecation") 777 @Override 778 public CoprocessorRpcChannel coprocessorService() { 779 return new SyncCoprocessorRpcChannelOverAsync( 780 new MasterCoprocessorRpcChannelImpl(admin.<Message> newMasterCaller())); 781 } 782 783 @SuppressWarnings("deprecation") 784 @Override 785 public CoprocessorRpcChannel coprocessorService(ServerName serverName) { 786 return new SyncCoprocessorRpcChannelOverAsync(new RegionServerCoprocessorRpcChannelImpl( 787 admin.<Message> newServerCaller().serverName(serverName))); 788 } 789 790 @Override 791 public void updateConfiguration(ServerName server) throws IOException { 792 get(admin.updateConfiguration(server)); 793 } 794 795 @Override 796 public void updateConfiguration() throws IOException { 797 get(admin.updateConfiguration()); 798 } 799 800 @Override 801 public void updateConfiguration(String groupName) throws IOException { 802 get(admin.updateConfiguration(groupName)); 803 } 804 805 @Override 806 public List<SecurityCapability> getSecurityCapabilities() throws IOException { 807 return get(admin.getSecurityCapabilities()); 808 } 809 810 @Override 811 public boolean splitSwitch(boolean enabled, boolean synchronous) throws IOException { 812 return get(admin.splitSwitch(enabled, synchronous)); 813 } 814 815 @Override 816 public boolean mergeSwitch(boolean enabled, boolean synchronous) throws IOException { 817 return get(admin.mergeSwitch(enabled, synchronous)); 818 } 819 820 @Override 821 public boolean isSplitEnabled() throws IOException { 822 return get(admin.isSplitEnabled()); 823 } 824 825 @Override 826 public boolean isMergeEnabled() throws IOException { 827 return get(admin.isMergeEnabled()); 828 } 829 830 @Override 831 public Future<Void> addReplicationPeerAsync(String peerId, ReplicationPeerConfig peerConfig, 832 boolean enabled) throws IOException { 833 return admin.addReplicationPeer(peerId, peerConfig, enabled); 834 } 835 836 @Override 837 public Future<Void> removeReplicationPeerAsync(String peerId) throws IOException { 838 return admin.removeReplicationPeer(peerId); 839 } 840 841 @Override 842 public Future<Void> enableReplicationPeerAsync(String peerId) throws IOException { 843 return admin.enableReplicationPeer(peerId); 844 } 845 846 @Override 847 public Future<Void> disableReplicationPeerAsync(String peerId) throws IOException { 848 return admin.disableReplicationPeer(peerId); 849 } 850 851 @Override 852 public ReplicationPeerConfig getReplicationPeerConfig(String peerId) throws IOException { 853 return get(admin.getReplicationPeerConfig(peerId)); 854 } 855 856 @Override 857 public Future<Void> updateReplicationPeerConfigAsync(String peerId, 858 ReplicationPeerConfig peerConfig) throws IOException { 859 return admin.updateReplicationPeerConfig(peerId, peerConfig); 860 } 861 862 @Override 863 public List<ReplicationPeerDescription> listReplicationPeers() throws IOException { 864 return get(admin.listReplicationPeers()); 865 } 866 867 @Override 868 public List<ReplicationPeerDescription> listReplicationPeers(Pattern pattern) throws IOException { 869 return get(admin.listReplicationPeers(pattern)); 870 } 871 872 @Override 873 public Future<Void> transitReplicationPeerSyncReplicationStateAsync(String peerId, 874 SyncReplicationState state) throws IOException { 875 return admin.transitReplicationPeerSyncReplicationState(peerId, state); 876 } 877 878 @Override 879 public void decommissionRegionServers(List<ServerName> servers, boolean offload) 880 throws IOException { 881 get(admin.decommissionRegionServers(servers, offload)); 882 } 883 884 @Override 885 public List<ServerName> listDecommissionedRegionServers() throws IOException { 886 return get(admin.listDecommissionedRegionServers()); 887 } 888 889 @Override 890 public void recommissionRegionServer(ServerName server, List<byte[]> encodedRegionNames) 891 throws IOException { 892 get(admin.recommissionRegionServer(server, encodedRegionNames)); 893 } 894 895 @Override 896 public List<TableCFs> listReplicatedTableCFs() throws IOException { 897 return get(admin.listReplicatedTableCFs()); 898 } 899 900 @Override 901 public void enableTableReplication(TableName tableName) throws IOException { 902 get(admin.enableTableReplication(tableName)); 903 } 904 905 @Override 906 public void disableTableReplication(TableName tableName) throws IOException { 907 get(admin.disableTableReplication(tableName)); 908 } 909 910 @Override 911 public void clearCompactionQueues(ServerName serverName, Set<String> queues) 912 throws IOException, InterruptedException { 913 get(admin.clearCompactionQueues(serverName, queues)); 914 } 915 916 @Override 917 public List<ServerName> clearDeadServers(List<ServerName> servers) throws IOException { 918 return get(admin.clearDeadServers(servers)); 919 } 920 921 @Override 922 public void cloneTableSchema(TableName tableName, TableName newTableName, boolean preserveSplits) 923 throws IOException { 924 get(admin.cloneTableSchema(tableName, newTableName, preserveSplits)); 925 } 926 927 @Override 928 public boolean switchRpcThrottle(boolean enable) throws IOException { 929 return get(admin.switchRpcThrottle(enable)); 930 } 931 932 @Override 933 public boolean isRpcThrottleEnabled() throws IOException { 934 return get(admin.isRpcThrottleEnabled()); 935 } 936 937 @Override 938 public boolean exceedThrottleQuotaSwitch(boolean enable) throws IOException { 939 return get(admin.exceedThrottleQuotaSwitch(enable)); 940 } 941 942 @Override 943 public Map<TableName, Long> getSpaceQuotaTableSizes() throws IOException { 944 return get(admin.getSpaceQuotaTableSizes()); 945 } 946 947 @Override 948 public Map<TableName, ? extends SpaceQuotaSnapshotView> 949 getRegionServerSpaceQuotaSnapshots(ServerName serverName) throws IOException { 950 return get(admin.getRegionServerSpaceQuotaSnapshots(serverName)); 951 } 952 953 @Override 954 public SpaceQuotaSnapshotView getCurrentSpaceQuotaSnapshot(String namespace) throws IOException { 955 return get(admin.getCurrentSpaceQuotaSnapshot(namespace)); 956 } 957 958 @Override 959 public SpaceQuotaSnapshotView getCurrentSpaceQuotaSnapshot(TableName tableName) 960 throws IOException { 961 return get(admin.getCurrentSpaceQuotaSnapshot(tableName)); 962 } 963 964 @Override 965 public void grant(UserPermission userPermission, boolean mergeExistingPermissions) 966 throws IOException { 967 get(admin.grant(userPermission, mergeExistingPermissions)); 968 } 969 970 @Override 971 public void revoke(UserPermission userPermission) throws IOException { 972 get(admin.revoke(userPermission)); 973 } 974 975 @Override 976 public List<UserPermission> 977 getUserPermissions(GetUserPermissionsRequest getUserPermissionsRequest) throws IOException { 978 return get(admin.getUserPermissions(getUserPermissionsRequest)); 979 } 980 981 @Override 982 public List<Boolean> hasUserPermissions(String userName, List<Permission> permissions) 983 throws IOException { 984 return get(admin.hasUserPermissions(userName, permissions)); 985 } 986 987 @Override 988 public boolean snapshotCleanupSwitch(final boolean on, final boolean synchronous) 989 throws IOException { 990 return get(admin.snapshotCleanupSwitch(on, synchronous)); 991 } 992 993 @Override 994 public boolean isSnapshotCleanupEnabled() throws IOException { 995 return get(admin.isSnapshotCleanupEnabled()); 996 } 997 998 @Override 999 public List<Boolean> clearSlowLogResponses(final Set<ServerName> serverNames) throws IOException { 1000 return get(admin.clearSlowLogResponses(serverNames)); 1001 } 1002 1003 @Override 1004 public RSGroupInfo getRSGroup(String groupName) throws IOException { 1005 return get(admin.getRSGroup(groupName)); 1006 } 1007 1008 @Override 1009 public void moveServersToRSGroup(Set<Address> servers, String groupName) throws IOException { 1010 get(admin.moveServersToRSGroup(servers, groupName)); 1011 } 1012 1013 @Override 1014 public void addRSGroup(String groupName) throws IOException { 1015 get(admin.addRSGroup(groupName)); 1016 } 1017 1018 @Override 1019 public void removeRSGroup(String groupName) throws IOException { 1020 get(admin.removeRSGroup(groupName)); 1021 } 1022 1023 @Override 1024 public BalanceResponse balanceRSGroup(String groupName, BalanceRequest request) 1025 throws IOException { 1026 return get(admin.balanceRSGroup(groupName, request)); 1027 } 1028 1029 @Override 1030 public List<RSGroupInfo> listRSGroups() throws IOException { 1031 return get(admin.listRSGroups()); 1032 } 1033 1034 @Override 1035 public List<TableName> listTablesInRSGroup(String groupName) throws IOException { 1036 return get(admin.listTablesInRSGroup(groupName)); 1037 } 1038 1039 @Override 1040 public Pair<List<String>, List<TableName>> 1041 getConfiguredNamespacesAndTablesInRSGroup(String groupName) throws IOException { 1042 return get(admin.getConfiguredNamespacesAndTablesInRSGroup(groupName)); 1043 } 1044 1045 @Override 1046 public RSGroupInfo getRSGroup(Address hostPort) throws IOException { 1047 return get(admin.getRSGroup(hostPort)); 1048 } 1049 1050 @Override 1051 public void removeServersFromRSGroup(Set<Address> servers) throws IOException { 1052 get(admin.removeServersFromRSGroup(servers)); 1053 } 1054 1055 @Override 1056 public RSGroupInfo getRSGroup(TableName tableName) throws IOException { 1057 return get(admin.getRSGroup(tableName)); 1058 } 1059 1060 @Override 1061 public void setRSGroup(Set<TableName> tables, String groupName) throws IOException { 1062 get(admin.setRSGroup(tables, groupName)); 1063 } 1064 1065 @Override 1066 public void renameRSGroup(String oldName, String newName) throws IOException { 1067 get(admin.renameRSGroup(oldName, newName)); 1068 } 1069 1070 @Override 1071 public void updateRSGroupConfig(String groupName, Map<String, String> configuration) 1072 throws IOException { 1073 get(admin.updateRSGroupConfig(groupName, configuration)); 1074 } 1075 1076 @Override 1077 public List<LogEntry> getLogEntries(Set<ServerName> serverNames, String logType, 1078 ServerType serverType, int limit, Map<String, Object> filterParams) throws IOException { 1079 return get(admin.getLogEntries(serverNames, logType, serverType, limit, filterParams)); 1080 } 1081 1082 @Override 1083 public void flushMasterStore() throws IOException { 1084 get(admin.flushMasterStore()); 1085 } 1086}