All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.hadoop.hbase.client.AsyncHBaseAdmin Maven / Gradle / Ivy

There is a newer version: 3.0.0-beta-1
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.hadoop.hbase.client;

import com.google.protobuf.RpcChannel;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.function.Function;
import java.util.regex.Pattern;
import org.apache.hadoop.hbase.CacheEvictionStats;
import org.apache.hadoop.hbase.ClusterMetrics;
import org.apache.hadoop.hbase.ClusterMetrics.Option;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.RegionMetrics;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.replication.TableCFs;
import org.apache.hadoop.hbase.client.security.SecurityCapability;
import org.apache.hadoop.hbase.quotas.QuotaFilter;
import org.apache.hadoop.hbase.quotas.QuotaSettings;
import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot;
import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
import org.apache.hadoop.hbase.replication.ReplicationPeerDescription;
import org.apache.hadoop.hbase.security.access.GetUserPermissionsRequest;
import org.apache.hadoop.hbase.security.access.Permission;
import org.apache.hadoop.hbase.security.access.UserPermission;
import org.apache.hadoop.hbase.util.FutureUtils;
import org.apache.yetus.audience.InterfaceAudience;

/**
 * Just a wrapper of {@link RawAsyncHBaseAdmin}. The difference is that users need to provide a
 * thread pool when constructing this class, and the callback methods registered to the returned
 * {@link CompletableFuture} will be executed in this thread pool. So usually it is safe for users
 * to do anything they want in the callbacks without breaking the rpc framework.
 * @since 2.0.0
 * @see RawAsyncHBaseAdmin
 * @see AsyncConnection#getAdmin(ExecutorService)
 * @see AsyncConnection#getAdminBuilder(ExecutorService)
 */
@InterfaceAudience.Private
class AsyncHBaseAdmin implements AsyncAdmin {

  private final RawAsyncHBaseAdmin rawAdmin;

  private final ExecutorService pool;

  AsyncHBaseAdmin(RawAsyncHBaseAdmin rawAdmin, ExecutorService pool) {
    this.rawAdmin = rawAdmin;
    this.pool = pool;
  }

  private  CompletableFuture wrap(CompletableFuture future) {
    return FutureUtils.wrapFuture(future, pool);
  }

  @Override
  public CompletableFuture tableExists(TableName tableName) {
    return wrap(rawAdmin.tableExists(tableName));
  }

  @Override
  public CompletableFuture> listTableDescriptors(boolean includeSysTables) {
    return wrap(rawAdmin.listTableDescriptors(includeSysTables));
  }

  @Override
  public CompletableFuture> listTableDescriptors(Pattern pattern,
    boolean includeSysTables) {
    return wrap(rawAdmin.listTableDescriptors(pattern, includeSysTables));
  }

  @Override
  public CompletableFuture> listTableDescriptors(List tableNames) {
    return wrap(rawAdmin.listTableDescriptors(tableNames));
  }

  @Override
  public CompletableFuture> listTableDescriptorsByNamespace(String name) {
    return wrap(rawAdmin.listTableDescriptorsByNamespace(name));
  }

  @Override
  public CompletableFuture> listTableDescriptorsByState(boolean isEnabled) {
    return wrap(rawAdmin.listTableDescriptorsByState(isEnabled));
  }

  @Override
  public CompletableFuture> listTableNames(boolean includeSysTables) {
    return wrap(rawAdmin.listTableNames(includeSysTables));
  }

  @Override
  public CompletableFuture> listTableNames(Pattern pattern,
    boolean includeSysTables) {
    return wrap(rawAdmin.listTableNames(pattern, includeSysTables));
  }

  @Override
  public CompletableFuture> listTableNamesByNamespace(String name) {
    return wrap(rawAdmin.listTableNamesByNamespace(name));
  }

  @Override
  public CompletableFuture> listTableNamesByState(boolean isEnabled) {
    return wrap(rawAdmin.listTableNamesByState(isEnabled));
  }

  @Override
  public CompletableFuture getDescriptor(TableName tableName) {
    return wrap(rawAdmin.getDescriptor(tableName));
  }

  @Override
  public CompletableFuture createTable(TableDescriptor desc) {
    return wrap(rawAdmin.createTable(desc));
  }

  @Override
  public CompletableFuture createTable(TableDescriptor desc, byte[] startKey, byte[] endKey,
    int numRegions) {
    return wrap(rawAdmin.createTable(desc, startKey, endKey, numRegions));
  }

  @Override
  public CompletableFuture createTable(TableDescriptor desc, byte[][] splitKeys) {
    return wrap(rawAdmin.createTable(desc, splitKeys));
  }

  @Override
  public CompletableFuture modifyTable(TableDescriptor desc) {
    return modifyTable(desc, true);
  }

  @Override
  public CompletableFuture modifyTable(TableDescriptor desc, boolean reopenRegions) {
    return wrap(rawAdmin.modifyTable(desc, reopenRegions));
  }

  @Override
  public CompletableFuture modifyTableStoreFileTracker(TableName tableName, String dstSFT) {
    return wrap(rawAdmin.modifyTableStoreFileTracker(tableName, dstSFT));
  }

  @Override
  public CompletableFuture deleteTable(TableName tableName) {
    return wrap(rawAdmin.deleteTable(tableName));
  }

  @Override
  public CompletableFuture truncateTable(TableName tableName, boolean preserveSplits) {
    return wrap(rawAdmin.truncateTable(tableName, preserveSplits));
  }

  @Override
  public CompletableFuture enableTable(TableName tableName) {
    return wrap(rawAdmin.enableTable(tableName));
  }

  @Override
  public CompletableFuture disableTable(TableName tableName) {
    return wrap(rawAdmin.disableTable(tableName));
  }

  @Override
  public CompletableFuture isTableEnabled(TableName tableName) {
    return wrap(rawAdmin.isTableEnabled(tableName));
  }

  @Override
  public CompletableFuture isTableDisabled(TableName tableName) {
    return wrap(rawAdmin.isTableDisabled(tableName));
  }

  @Override
  public CompletableFuture isTableAvailable(TableName tableName) {
    return wrap(rawAdmin.isTableAvailable(tableName));
  }

  @Override
  public CompletableFuture isTableAvailable(TableName tableName, byte[][] splitKeys) {
    return wrap(rawAdmin.isTableAvailable(tableName, splitKeys));
  }

  @Override
  public CompletableFuture addColumnFamily(TableName tableName,
    ColumnFamilyDescriptor columnFamily) {
    return wrap(rawAdmin.addColumnFamily(tableName, columnFamily));
  }

  @Override
  public CompletableFuture deleteColumnFamily(TableName tableName, byte[] columnFamily) {
    return wrap(rawAdmin.deleteColumnFamily(tableName, columnFamily));
  }

  @Override
  public CompletableFuture modifyColumnFamily(TableName tableName,
    ColumnFamilyDescriptor columnFamily) {
    return wrap(rawAdmin.modifyColumnFamily(tableName, columnFamily));
  }

  @Override
  public CompletableFuture modifyColumnFamilyStoreFileTracker(TableName tableName,
    byte[] family, String dstSFT) {
    return wrap(rawAdmin.modifyColumnFamilyStoreFileTracker(tableName, family, dstSFT));
  }

  @Override
  public CompletableFuture createNamespace(NamespaceDescriptor descriptor) {
    return wrap(rawAdmin.createNamespace(descriptor));
  }

  @Override
  public CompletableFuture modifyNamespace(NamespaceDescriptor descriptor) {
    return wrap(rawAdmin.modifyNamespace(descriptor));
  }

  @Override
  public CompletableFuture deleteNamespace(String name) {
    return wrap(rawAdmin.deleteNamespace(name));
  }

  @Override
  public CompletableFuture getNamespaceDescriptor(String name) {
    return wrap(rawAdmin.getNamespaceDescriptor(name));
  }

  @Override
  public CompletableFuture> listNamespaces() {
    return wrap(rawAdmin.listNamespaces());
  }

  @Override
  public CompletableFuture> listNamespaceDescriptors() {
    return wrap(rawAdmin.listNamespaceDescriptors());
  }

  @Override
  public CompletableFuture> getRegions(ServerName serverName) {
    return wrap(rawAdmin.getRegions(serverName));
  }

  @Override
  public CompletableFuture> getRegions(TableName tableName) {
    return wrap(rawAdmin.getRegions(tableName));
  }

  @Override
  public CompletableFuture flush(TableName tableName) {
    return wrap(rawAdmin.flush(tableName));
  }

  @Override
  public CompletableFuture flush(TableName tableName, byte[] columnFamily) {
    return wrap(rawAdmin.flush(tableName, columnFamily));
  }

  @Override
  public CompletableFuture flush(TableName tableName, List columnFamilies) {
    return wrap(rawAdmin.flush(tableName, columnFamilies));
  }

  @Override
  public CompletableFuture flushRegion(byte[] regionName) {
    return wrap(rawAdmin.flushRegion(regionName));
  }

  @Override
  public CompletableFuture flushRegion(byte[] regionName, byte[] columnFamily) {
    return wrap(rawAdmin.flushRegion(regionName, columnFamily));
  }

  @Override
  public CompletableFuture flushRegionServer(ServerName sn) {
    return wrap(rawAdmin.flushRegionServer(sn));
  }

  @Override
  public CompletableFuture compact(TableName tableName, CompactType compactType) {
    return wrap(rawAdmin.compact(tableName, compactType));
  }

  @Override
  public CompletableFuture compact(TableName tableName, byte[] columnFamily,
    CompactType compactType) {
    return wrap(rawAdmin.compact(tableName, columnFamily, compactType));
  }

  @Override
  public CompletableFuture compactRegion(byte[] regionName) {
    return wrap(rawAdmin.compactRegion(regionName));
  }

  @Override
  public CompletableFuture compactRegion(byte[] regionName, byte[] columnFamily) {
    return wrap(rawAdmin.compactRegion(regionName, columnFamily));
  }

  @Override
  public CompletableFuture majorCompact(TableName tableName, CompactType compactType) {
    return wrap(rawAdmin.majorCompact(tableName, compactType));
  }

  @Override
  public CompletableFuture majorCompact(TableName tableName, byte[] columnFamily,
    CompactType compactType) {
    return wrap(rawAdmin.majorCompact(tableName, columnFamily, compactType));
  }

  @Override
  public CompletableFuture majorCompactRegion(byte[] regionName) {
    return wrap(rawAdmin.majorCompactRegion(regionName));
  }

  @Override
  public CompletableFuture majorCompactRegion(byte[] regionName, byte[] columnFamily) {
    return wrap(rawAdmin.majorCompactRegion(regionName, columnFamily));
  }

  @Override
  public CompletableFuture compactRegionServer(ServerName serverName) {
    return wrap(rawAdmin.compactRegionServer(serverName));
  }

  @Override
  public CompletableFuture majorCompactRegionServer(ServerName serverName) {
    return wrap(rawAdmin.majorCompactRegionServer(serverName));
  }

  @Override
  public CompletableFuture mergeSwitch(boolean enabled, boolean drainMerges) {
    return wrap(rawAdmin.mergeSwitch(enabled, drainMerges));
  }

  @Override
  public CompletableFuture isMergeEnabled() {
    return wrap(rawAdmin.isMergeEnabled());
  }

  @Override
  public CompletableFuture splitSwitch(boolean enabled, boolean drainSplits) {
    return wrap(rawAdmin.splitSwitch(enabled, drainSplits));
  }

  @Override
  public CompletableFuture isSplitEnabled() {
    return wrap(rawAdmin.isSplitEnabled());
  }

  @Override
  public CompletableFuture mergeRegions(List nameOfRegionsToMerge, boolean forcible) {
    return wrap(rawAdmin.mergeRegions(nameOfRegionsToMerge, forcible));
  }

  @Override
  public CompletableFuture split(TableName tableName) {
    return wrap(rawAdmin.split(tableName));
  }

  @Override
  public CompletableFuture split(TableName tableName, byte[] splitPoint) {
    return wrap(rawAdmin.split(tableName, splitPoint));
  }

  @Override
  public CompletableFuture splitRegion(byte[] regionName) {
    return wrap(rawAdmin.splitRegion(regionName));
  }

  @Override
  public CompletableFuture splitRegion(byte[] regionName, byte[] splitPoint) {
    return wrap(rawAdmin.splitRegion(regionName, splitPoint));
  }

  @Override
  public CompletableFuture truncateRegion(byte[] regionName) {
    return wrap(rawAdmin.truncateRegion(regionName));
  }

  @Override
  public CompletableFuture assign(byte[] regionName) {
    return wrap(rawAdmin.assign(regionName));
  }

  @Override
  public CompletableFuture unassign(byte[] regionName) {
    return wrap(rawAdmin.unassign(regionName));
  }

  @Override
  public CompletableFuture offline(byte[] regionName) {
    return wrap(rawAdmin.offline(regionName));
  }

  @Override
  public CompletableFuture move(byte[] regionName) {
    return wrap(rawAdmin.move(regionName));
  }

  @Override
  public CompletableFuture move(byte[] regionName, ServerName destServerName) {
    return wrap(rawAdmin.move(regionName, destServerName));
  }

  @Override
  public CompletableFuture setQuota(QuotaSettings quota) {
    return wrap(rawAdmin.setQuota(quota));
  }

  @Override
  public CompletableFuture> getQuota(QuotaFilter filter) {
    return wrap(rawAdmin.getQuota(filter));
  }

  @Override
  public CompletableFuture addReplicationPeer(String peerId, ReplicationPeerConfig peerConfig,
    boolean enabled) {
    return wrap(rawAdmin.addReplicationPeer(peerId, peerConfig, enabled));
  }

  @Override
  public CompletableFuture removeReplicationPeer(String peerId) {
    return wrap(rawAdmin.removeReplicationPeer(peerId));
  }

  @Override
  public CompletableFuture enableReplicationPeer(String peerId) {
    return wrap(rawAdmin.enableReplicationPeer(peerId));
  }

  @Override
  public CompletableFuture disableReplicationPeer(String peerId) {
    return wrap(rawAdmin.disableReplicationPeer(peerId));
  }

  @Override
  public CompletableFuture getReplicationPeerConfig(String peerId) {
    return wrap(rawAdmin.getReplicationPeerConfig(peerId));
  }

  @Override
  public CompletableFuture updateReplicationPeerConfig(String peerId,
    ReplicationPeerConfig peerConfig) {
    return wrap(rawAdmin.updateReplicationPeerConfig(peerId, peerConfig));
  }

  @Override
  public CompletableFuture appendReplicationPeerTableCFs(String peerId,
    Map> tableCfs) {
    return wrap(rawAdmin.appendReplicationPeerTableCFs(peerId, tableCfs));
  }

  @Override
  public CompletableFuture removeReplicationPeerTableCFs(String peerId,
    Map> tableCfs) {
    return wrap(rawAdmin.removeReplicationPeerTableCFs(peerId, tableCfs));
  }

  @Override
  public CompletableFuture> listReplicationPeers() {
    return wrap(rawAdmin.listReplicationPeers());
  }

  @Override
  public CompletableFuture> listReplicationPeers(Pattern pattern) {
    return wrap(rawAdmin.listReplicationPeers(pattern));
  }

  @Override
  public CompletableFuture> listReplicatedTableCFs() {
    return wrap(rawAdmin.listReplicatedTableCFs());
  }

  @Override
  public CompletableFuture enableTableReplication(TableName tableName) {
    return wrap(rawAdmin.enableTableReplication(tableName));
  }

  @Override
  public CompletableFuture disableTableReplication(TableName tableName) {
    return wrap(rawAdmin.disableTableReplication(tableName));
  }

  @Override
  public CompletableFuture isReplicationPeerEnabled(String peerId) {
    return wrap(rawAdmin.isReplicationPeerEnabled(peerId));
  }

  @Override
  public CompletableFuture replicationPeerModificationSwitch(boolean on,
    boolean drainProcedures) {
    return wrap(rawAdmin.replicationPeerModificationSwitch(on, drainProcedures));
  }

  @Override
  public CompletableFuture isReplicationPeerModificationEnabled() {
    return wrap(rawAdmin.isReplicationPeerModificationEnabled());
  }

  @Override
  public CompletableFuture snapshot(SnapshotDescription snapshot) {
    return wrap(rawAdmin.snapshot(snapshot));
  }

  @Override
  public CompletableFuture isSnapshotFinished(SnapshotDescription snapshot) {
    return wrap(rawAdmin.isSnapshotFinished(snapshot));
  }

  @Override
  public CompletableFuture restoreSnapshot(String snapshotName) {
    return wrap(rawAdmin.restoreSnapshot(snapshotName));
  }

  @Override
  public CompletableFuture restoreSnapshot(String snapshotName, boolean takeFailSafeSnapshot,
    boolean restoreAcl) {
    return wrap(rawAdmin.restoreSnapshot(snapshotName, takeFailSafeSnapshot, restoreAcl));
  }

  @Override
  public CompletableFuture cloneSnapshot(String snapshotName, TableName tableName,
    boolean restoreAcl, String customSFT) {
    return wrap(rawAdmin.cloneSnapshot(snapshotName, tableName, restoreAcl, customSFT));
  }

  @Override
  public CompletableFuture> listSnapshots() {
    return wrap(rawAdmin.listSnapshots());
  }

  @Override
  public CompletableFuture> listSnapshots(Pattern pattern) {
    return wrap(rawAdmin.listSnapshots(pattern));
  }

  @Override
  public CompletableFuture> listTableSnapshots(Pattern tableNamePattern) {
    return wrap(rawAdmin.listTableSnapshots(tableNamePattern));
  }

  @Override
  public CompletableFuture> listTableSnapshots(Pattern tableNamePattern,
    Pattern snapshotNamePattern) {
    return wrap(rawAdmin.listTableSnapshots(tableNamePattern, snapshotNamePattern));
  }

  @Override
  public CompletableFuture deleteSnapshot(String snapshotName) {
    return wrap(rawAdmin.deleteSnapshot(snapshotName));
  }

  @Override
  public CompletableFuture deleteSnapshots() {
    return wrap(rawAdmin.deleteSnapshots());
  }

  @Override
  public CompletableFuture deleteSnapshots(Pattern pattern) {
    return wrap(rawAdmin.deleteSnapshots(pattern));
  }

  @Override
  public CompletableFuture deleteTableSnapshots(Pattern tableNamePattern) {
    return wrap(rawAdmin.deleteTableSnapshots(tableNamePattern));
  }

  @Override
  public CompletableFuture deleteTableSnapshots(Pattern tableNamePattern,
    Pattern snapshotNamePattern) {
    return wrap(rawAdmin.deleteTableSnapshots(tableNamePattern, snapshotNamePattern));
  }

  @Override
  public CompletableFuture execProcedure(String signature, String instance,
    Map props) {
    return wrap(rawAdmin.execProcedure(signature, instance, props));
  }

  @Override
  public CompletableFuture execProcedureWithReturn(String signature, String instance,
    Map props) {
    return wrap(rawAdmin.execProcedureWithReturn(signature, instance, props));
  }

  @Override
  public CompletableFuture isProcedureFinished(String signature, String instance,
    Map props) {
    return wrap(rawAdmin.isProcedureFinished(signature, instance, props));
  }

  @Override
  public CompletableFuture abortProcedure(long procId, boolean mayInterruptIfRunning) {
    return wrap(rawAdmin.abortProcedure(procId, mayInterruptIfRunning));
  }

  @Override
  public CompletableFuture getProcedures() {
    return wrap(rawAdmin.getProcedures());
  }

  @Override
  public CompletableFuture getLocks() {
    return wrap(rawAdmin.getLocks());
  }

  @Override
  public CompletableFuture decommissionRegionServers(List servers,
    boolean offload) {
    return wrap(rawAdmin.decommissionRegionServers(servers, offload));
  }

  @Override
  public CompletableFuture> listDecommissionedRegionServers() {
    return wrap(rawAdmin.listDecommissionedRegionServers());
  }

  @Override
  public CompletableFuture recommissionRegionServer(ServerName server,
    List encodedRegionNames) {
    return wrap(rawAdmin.recommissionRegionServer(server, encodedRegionNames));
  }

  @Override
  public CompletableFuture getClusterMetrics() {
    return getClusterMetrics(EnumSet.allOf(Option.class));
  }

  @Override
  public CompletableFuture getClusterMetrics(EnumSet




© 2015 - 2024 Weber Informatics LLC | Privacy Policy