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