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 java.util.List; 021import java.util.concurrent.CompletableFuture; 022import org.apache.hadoop.hbase.RegionLocations; 023import org.apache.hadoop.hbase.ServerName; 024import org.apache.hadoop.hbase.TableName; 025import org.apache.hadoop.hbase.ipc.RpcClient; 026import org.apache.hadoop.hbase.util.Pair; 027import org.apache.hadoop.hbase.wal.WAL.Entry; 028import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; 029import org.apache.hadoop.security.token.Token; 030import org.apache.yetus.audience.InterfaceAudience; 031 032import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.FlushRegionResponse; 033 034/** 035 * The asynchronous connection for internal usage. 036 */ 037@InterfaceAudience.Private 038public interface AsyncClusterConnection extends AsyncConnection { 039 040 /** 041 * Get the admin service for the given region server. 042 */ 043 AsyncRegionServerAdmin getRegionServerAdmin(ServerName serverName); 044 045 /** 046 * Get the nonce generator for this connection. 047 */ 048 NonceGenerator getNonceGenerator(); 049 050 /** 051 * Get the rpc client we used to communicate with other servers. 052 */ 053 RpcClient getRpcClient(); 054 055 /** 056 * Flush a region and get the response. 057 */ 058 CompletableFuture<FlushRegionResponse> flush(byte[] regionName, boolean writeFlushWALMarker); 059 060 /** 061 * Return all the replicas for a region. Used for region replica replication. 062 */ 063 CompletableFuture<RegionLocations> getRegionLocations(TableName tableName, byte[] row, 064 boolean reload); 065 066 /** 067 * Return the token for this bulk load. 068 */ 069 CompletableFuture<String> prepareBulkLoad(TableName tableName); 070 071 /** 072 * Securely bulk load a list of HFiles, passing additional list of clusters ids tracking clusters 073 * where the given bulk load has already been processed (important for bulk loading replication). 074 * <p/> 075 * Defined as default here to avoid breaking callers who rely on the bulkLoad version that does 076 * not expect additional clusterIds param. 077 * @param tableName the target table 078 * @param familyPaths hdfs path for the the table family dirs containg files to be loaded. 079 * @param row row key. 080 * @param assignSeqNum seq num for the event on WAL. 081 * @param userToken user token. 082 * @param bulkToken bulk load token. 083 * @param copyFiles flag for copying the loaded hfiles. 084 * @param clusterIds list of cluster ids where the given bulk load has already been processed. 085 * @param replicate flags if the bulkload is targeted for replication. 086 */ 087 CompletableFuture<Boolean> bulkLoad(TableName tableName, List<Pair<byte[], String>> familyPaths, 088 byte[] row, boolean assignSeqNum, Token<?> userToken, String bulkToken, boolean copyFiles, 089 List<String> clusterIds, boolean replicate); 090 091 /** 092 * Clean up after finishing bulk load, no matter success or not. 093 */ 094 CompletableFuture<Void> cleanupBulkLoad(TableName tableName, String bulkToken); 095 096 /** 097 * Get live region servers from masters. 098 */ 099 CompletableFuture<List<ServerName>> getLiveRegionServers(MasterAddressTracker masterAddrTracker, 100 int count); 101 102 /** 103 * Get the bootstrap node list of another region server. 104 */ 105 CompletableFuture<List<ServerName>> getAllBootstrapNodes(ServerName regionServer); 106 107 /** 108 * Replicate wal edits to a secondary replica. 109 */ 110 CompletableFuture<Void> replicate(RegionInfo replica, List<Entry> entries, int numRetries, 111 long rpcTimeoutNs, long operationTimeoutNs); 112}