1- /**
1+ /*
22 * Licensed to the Apache Software Foundation (ASF) under one
33 * or more contributor license agreements. See the NOTICE file
44 * distributed with this work for additional information
2121import static org .apache .hadoop .hbase .TableName .META_TABLE_NAME ;
2222import static org .apache .hadoop .hbase .util .FutureUtils .addListener ;
2323import static org .apache .hadoop .hbase .util .FutureUtils .unwrapCompletionException ;
24-
2524import com .google .protobuf .Message ;
2625import com .google .protobuf .RpcChannel ;
2726import java .io .IOException ;
4645import java .util .regex .Pattern ;
4746import java .util .stream .Collectors ;
4847import java .util .stream .Stream ;
49- import org .apache .commons .io .IOUtils ;
5048import org .apache .hadoop .conf .Configuration ;
5149import org .apache .hadoop .hbase .AsyncMetaTableAccessor ;
5250import org .apache .hadoop .hbase .CacheEvictionStats ;
9896import org .apache .yetus .audience .InterfaceAudience ;
9997import org .slf4j .Logger ;
10098import org .slf4j .LoggerFactory ;
101-
10299import org .apache .hbase .thirdparty .com .google .common .annotations .VisibleForTesting ;
103100import org .apache .hbase .thirdparty .com .google .common .base .Preconditions ;
104101import org .apache .hbase .thirdparty .com .google .protobuf .RpcCallback ;
105102import org .apache .hbase .thirdparty .io .netty .util .HashedWheelTimer ;
106103import org .apache .hbase .thirdparty .io .netty .util .Timeout ;
107104import org .apache .hbase .thirdparty .io .netty .util .TimerTask ;
108-
109105import org .apache .hadoop .hbase .shaded .protobuf .ProtobufUtil ;
110106import org .apache .hadoop .hbase .shaded .protobuf .RequestConverter ;
111107import org .apache .hadoop .hbase .shaded .protobuf .generated .AccessControlProtos ;
@@ -784,7 +780,8 @@ private boolean compareRegionsWithSplitKeys(List<HRegionLocation> locations, byt
784780 }
785781
786782 @ Override
787- public CompletableFuture <Void > addColumnFamily (TableName tableName , ColumnFamilyDescriptor columnFamily ) {
783+ public CompletableFuture <Void > addColumnFamily (
784+ TableName tableName , ColumnFamilyDescriptor columnFamily ) {
788785 return this .<AddColumnRequest , AddColumnResponse > procedureCall (tableName ,
789786 RequestConverter .buildAddColumnRequest (tableName , columnFamily , ng .getNonceGroup (),
790787 ng .newNonce ()), (s , c , req , done ) -> s .addColumn (c , req , done ), (resp ) -> resp .getProcId (),
@@ -838,10 +835,10 @@ public CompletableFuture<NamespaceDescriptor> getNamespaceDescriptor(String name
838835 .<NamespaceDescriptor > newMasterCaller ()
839836 .action (
840837 (controller , stub ) -> this
841- .<GetNamespaceDescriptorRequest , GetNamespaceDescriptorResponse , NamespaceDescriptor > call (
842- controller , stub , RequestConverter .buildGetNamespaceDescriptorRequest (name ), ( s , c ,
843- req , done ) -> s .getNamespaceDescriptor (c , req , done ), (resp ) -> ProtobufUtil
844- .toNamespaceDescriptor (resp .getNamespaceDescriptor ()))).call ();
838+ .<GetNamespaceDescriptorRequest , GetNamespaceDescriptorResponse , NamespaceDescriptor >
839+ call ( controller , stub , RequestConverter .buildGetNamespaceDescriptorRequest (name ),
840+ ( s , c , req , done ) -> s .getNamespaceDescriptor (c , req , done ), (resp )
841+ -> ProtobufUtil .toNamespaceDescriptor (resp .getNamespaceDescriptor ()))).call ();
845842 }
846843
847844 @ Override
@@ -859,13 +856,12 @@ public CompletableFuture<List<String>> listNamespaces() {
859856 @ Override
860857 public CompletableFuture <List <NamespaceDescriptor >> listNamespaceDescriptors () {
861858 return this
862- .<List <NamespaceDescriptor >> newMasterCaller ()
863- .action (
864- (controller , stub ) -> this
865- .<ListNamespaceDescriptorsRequest , ListNamespaceDescriptorsResponse , List <NamespaceDescriptor >> call (
866- controller , stub , ListNamespaceDescriptorsRequest .newBuilder ().build (), (s , c , req ,
867- done ) -> s .listNamespaceDescriptors (c , req , done ), (resp ) -> ProtobufUtil
868- .toNamespaceDescriptorList (resp ))).call ();
859+ .<List <NamespaceDescriptor >> newMasterCaller ().action ((controller , stub ) -> this
860+ .<ListNamespaceDescriptorsRequest , ListNamespaceDescriptorsResponse ,
861+ List <NamespaceDescriptor >> call (controller , stub ,
862+ ListNamespaceDescriptorsRequest .newBuilder ().build (), (s , c , req , done ) ->
863+ s .listNamespaceDescriptors (c , req , done ),
864+ (resp ) -> ProtobufUtil .toNamespaceDescriptorList (resp ))).call ();
869865 }
870866
871867 @ Override
@@ -1097,10 +1093,7 @@ private CompletableFuture<Void> compactRegion(byte[] regionName, byte[] columnFa
10971093 private CompletableFuture <List <HRegionLocation >> getTableHRegionLocations (TableName tableName ) {
10981094 if (TableName .META_TABLE_NAME .equals (tableName )) {
10991095 CompletableFuture <List <HRegionLocation >> future = new CompletableFuture <>();
1100- // For meta table, we use zk to fetch all locations.
1101- ConnectionRegistry registry = ConnectionRegistryFactory .getRegistry (
1102- connection .getConfiguration ());
1103- addListener (registry .getMetaRegionLocations (), (metaRegions , err ) -> {
1096+ addListener (connection .registry .getMetaRegionLocations (), (metaRegions , err ) -> {
11041097 if (err != null ) {
11051098 future .completeExceptionally (err );
11061099 } else if (metaRegions == null || metaRegions .isEmpty () ||
@@ -1109,8 +1102,6 @@ private CompletableFuture<List<HRegionLocation>> getTableHRegionLocations(TableN
11091102 } else {
11101103 future .complete (Collections .singletonList (metaRegions .getDefaultRegionLocation ()));
11111104 }
1112- // close the registry.
1113- IOUtils .closeQuietly (registry );
11141105 });
11151106 return future ;
11161107 } else {
@@ -1793,11 +1784,8 @@ private CompletableFuture<List<ReplicationPeerDescription>> listReplicationPeers
17931784 return this
17941785 .<List <ReplicationPeerDescription >> newMasterCaller ()
17951786 .action (
1796- (controller , stub ) -> this
1797- .<ListReplicationPeersRequest , ListReplicationPeersResponse , List <ReplicationPeerDescription >> call (
1798- controller ,
1799- stub ,
1800- request ,
1787+ (controller , stub ) -> this .<ListReplicationPeersRequest , ListReplicationPeersResponse ,
1788+ List <ReplicationPeerDescription >> call (controller , stub , request ,
18011789 (s , c , req , done ) -> s .listReplicationPeers (c , req , done ),
18021790 (resp ) -> resp .getPeerDescList ().stream ()
18031791 .map (ReplicationPeerConfigUtil ::toReplicationPeerDescription )
@@ -2308,11 +2296,13 @@ public CompletableFuture<String> getLocks() {
23082296 }
23092297
23102298 @ Override
2311- public CompletableFuture <Void > decommissionRegionServers (List <ServerName > servers , boolean offload ) {
2299+ public CompletableFuture <Void > decommissionRegionServers (
2300+ List <ServerName > servers , boolean offload ) {
23122301 return this .<Void > newMasterCaller ()
23132302 .action ((controller , stub ) -> this
23142303 .<DecommissionRegionServersRequest , DecommissionRegionServersResponse , Void > call (
2315- controller , stub , RequestConverter .buildDecommissionRegionServersRequest (servers , offload ),
2304+ controller , stub ,
2305+ RequestConverter .buildDecommissionRegionServersRequest (servers , offload ),
23162306 (s , c , req , done ) -> s .decommissionRegionServers (c , req , done ), resp -> null ))
23172307 .call ();
23182308 }
@@ -2334,11 +2324,11 @@ List<ServerName>> call(
23342324 public CompletableFuture <Void > recommissionRegionServer (ServerName server ,
23352325 List <byte []> encodedRegionNames ) {
23362326 return this .<Void > newMasterCaller ()
2337- .action ((controller , stub ) -> this
2338- .<RecommissionRegionServerRequest , RecommissionRegionServerResponse , Void > call (controller ,
2339- stub , RequestConverter .buildRecommissionRegionServerRequest (server , encodedRegionNames ),
2340- (s , c , req , done ) -> s .recommissionRegionServer (c , req , done ), resp -> null ))
2341- .call ();
2327+ .action ((controller , stub ) ->
2328+ this .<RecommissionRegionServerRequest , RecommissionRegionServerResponse , Void > call (
2329+ controller , stub , RequestConverter .buildRecommissionRegionServerRequest (
2330+ server , encodedRegionNames ), (s , c , req , done ) -> s .recommissionRegionServer (
2331+ c , req , done ), resp -> null )) .call ();
23422332 }
23432333
23442334 /**
@@ -2404,7 +2394,6 @@ CompletableFuture<HRegionLocation> getRegionLocation(byte[] regionNameOrEncodedR
24042394 * Get the region info for the passed region name. The region name may be a full region name or
24052395 * encoded region name. If the region does not found, then it'll throw an UnknownRegionException
24062396 * wrapped by a {@link CompletableFuture}
2407- * @param regionNameOrEncodedRegionName
24082397 * @return region info, wrapped by a {@link CompletableFuture}
24092398 */
24102399 private CompletableFuture <RegionInfo > getRegionInfo (byte [] regionNameOrEncodedRegionName ) {
@@ -2895,10 +2884,11 @@ public CompletableFuture<List<SecurityCapability>> getSecurityCapabilities() {
28952884 .<List <SecurityCapability >> newMasterCaller ()
28962885 .action (
28972886 (controller , stub ) -> this
2898- .<SecurityCapabilitiesRequest , SecurityCapabilitiesResponse , List <SecurityCapability >> call (
2899- controller , stub , SecurityCapabilitiesRequest .newBuilder ().build (), (s , c , req ,
2900- done ) -> s .getSecurityCapabilities (c , req , done ), (resp ) -> ProtobufUtil
2901- .toSecurityCapabilityList (resp .getCapabilitiesList ()))).call ();
2887+ .<SecurityCapabilitiesRequest , SecurityCapabilitiesResponse , List <SecurityCapability >>
2888+ call (controller , stub , SecurityCapabilitiesRequest .newBuilder ().build (),
2889+ (s , c , req , done ) -> s .getSecurityCapabilities (c , req , done ),
2890+ (resp ) -> ProtobufUtil .toSecurityCapabilityList (resp .getCapabilitiesList ())))
2891+ .call ();
29022892 }
29032893
29042894 @ Override
@@ -3075,14 +3065,10 @@ public CompletableFuture<Optional<Long>> getLastMajorCompactionTimestamp(TableNa
30753065 MajorCompactionTimestampRequest request =
30763066 MajorCompactionTimestampRequest .newBuilder ()
30773067 .setTableName (ProtobufUtil .toProtoTableName (tableName )).build ();
3078- return this
3079- .<Optional <Long >> newMasterCaller ()
3080- .action (
3081- (controller , stub ) -> this
3082- .<MajorCompactionTimestampRequest , MajorCompactionTimestampResponse , Optional <Long >> call (
3083- controller , stub , request ,
3084- (s , c , req , done ) -> s .getLastMajorCompactionTimestamp (c , req , done ),
3085- ProtobufUtil ::toOptionalTimestamp )).call ();
3068+ return this .<Optional <Long >> newMasterCaller ().action ((controller , stub ) ->
3069+ this .<MajorCompactionTimestampRequest , MajorCompactionTimestampResponse , Optional <Long >>
3070+ call (controller , stub , request , (s , c , req , done ) -> s .getLastMajorCompactionTimestamp (
3071+ c , req , done ), ProtobufUtil ::toOptionalTimestamp )).call ();
30863072 }
30873073
30883074 @ Override
@@ -3222,11 +3208,10 @@ public CompletableFuture<Boolean> balance(boolean forcible) {
32223208 public CompletableFuture <Boolean > isBalancerEnabled () {
32233209 return this
32243210 .<Boolean > newMasterCaller ()
3225- .action (
3226- (controller , stub ) -> this .<IsBalancerEnabledRequest , IsBalancerEnabledResponse , Boolean > call (
3227- controller , stub , RequestConverter .buildIsBalancerEnabledRequest (),
3228- (s , c , req , done ) -> s .isBalancerEnabled (c , req , done ), (resp ) -> resp .getEnabled ()))
3229- .call ();
3211+ .action ((controller , stub ) ->
3212+ this .<IsBalancerEnabledRequest , IsBalancerEnabledResponse , Boolean > call (controller ,
3213+ stub , RequestConverter .buildIsBalancerEnabledRequest (), (s , c , req , done )
3214+ -> s .isBalancerEnabled (c , req , done ), (resp ) -> resp .getEnabled ())).call ();
32303215 }
32313216
32323217 @ Override
0 commit comments