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