diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterClientNamenodeProtocolServerSideTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterClientNamenodeProtocolServerSideTranslatorPB.java index 20f460d957267..88e344a07db87 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterClientNamenodeProtocolServerSideTranslatorPB.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterClientNamenodeProtocolServerSideTranslatorPB.java @@ -333,12 +333,12 @@ public CreateResponseProto create(RpcController controller, CreateRequestProto r req.getCryptoProtocolVersionList()), req.getEcPolicyName(), req.getStoragePolicy()); }, result -> { - if (result != null) { - return CreateResponseProto.newBuilder().setFs(PBHelperClient.convert(result)) - .build(); - } - return VOID_CREATE_RESPONSE; - }); + if (result != null) { + return CreateResponseProto.newBuilder().setFs(PBHelperClient.convert(result)) + .build(); + } + return VOID_CREATE_RESPONSE; + }); return null; } @@ -352,17 +352,17 @@ public AppendResponseProto append(RpcController controller, return server.append(req.getSrc(), req.getClientName(), flags); }, result -> { - AppendResponseProto.Builder builder = - AppendResponseProto.newBuilder(); - if (result.getLastBlock() != null) { - builder.setBlock(PBHelperClient.convertLocatedBlock( - result.getLastBlock())); - } - if (result.getFileStatus() != null) { - builder.setStat(PBHelperClient.convert(result.getFileStatus())); - } - return builder.build(); - }); + AppendResponseProto.Builder builder = + AppendResponseProto.newBuilder(); + if (result.getLastBlock() != null) { + builder.setBlock(PBHelperClient.convertLocatedBlock( + result.getLastBlock())); + } + if (result.getFileStatus() != null) { + builder.setStat(PBHelperClient.convert(result.getFileStatus())); + } + return builder.build(); + }); return null; } @@ -578,13 +578,13 @@ public GetListingResponseProto getListing( req.getNeedLocation()); return result; }, result -> { - if (result != null) { - return GetListingResponseProto.newBuilder().setDirList( - PBHelperClient.convert(result)).build(); - } else { - return VOID_GETLISTING_RESPONSE; - } - }); + if (result != null) { + return GetListingResponseProto.newBuilder().setDirList( + PBHelperClient.convert(result)).build(); + } else { + return VOID_GETLISTING_RESPONSE; + } + }); return null; } @@ -599,36 +599,36 @@ public GetBatchedListingResponseProto getBatchedListing( request.getNeedLocation()); return result; }, result -> { - if (result != null) { - GetBatchedListingResponseProto.Builder builder = - GetBatchedListingResponseProto.newBuilder(); - for (HdfsPartialListing partialListing : result.getListings()) { - HdfsProtos.BatchedDirectoryListingProto.Builder listingBuilder = - HdfsProtos.BatchedDirectoryListingProto.newBuilder(); - if (partialListing.getException() != null) { - RemoteException ex = partialListing.getException(); - HdfsProtos.RemoteExceptionProto.Builder rexBuilder = - HdfsProtos.RemoteExceptionProto.newBuilder(); - rexBuilder.setClassName(ex.getClassName()); - if (ex.getMessage() != null) { - rexBuilder.setMessage(ex.getMessage()); - } - listingBuilder.setException(rexBuilder.build()); - } else { - for (HdfsFileStatus f : partialListing.getPartialListing()) { - listingBuilder.addPartialListing(PBHelperClient.convert(f)); + if (result != null) { + GetBatchedListingResponseProto.Builder builder = + GetBatchedListingResponseProto.newBuilder(); + for (HdfsPartialListing partialListing : result.getListings()) { + HdfsProtos.BatchedDirectoryListingProto.Builder listingBuilder = + HdfsProtos.BatchedDirectoryListingProto.newBuilder(); + if (partialListing.getException() != null) { + RemoteException ex = partialListing.getException(); + HdfsProtos.RemoteExceptionProto.Builder rexBuilder = + HdfsProtos.RemoteExceptionProto.newBuilder(); + rexBuilder.setClassName(ex.getClassName()); + if (ex.getMessage() != null) { + rexBuilder.setMessage(ex.getMessage()); + } + listingBuilder.setException(rexBuilder.build()); + } else { + for (HdfsFileStatus f : partialListing.getPartialListing()) { + listingBuilder.addPartialListing(PBHelperClient.convert(f)); + } } + listingBuilder.setParentIdx(partialListing.getParentIdx()); + builder.addListings(listingBuilder); } - listingBuilder.setParentIdx(partialListing.getParentIdx()); - builder.addListings(listingBuilder); + builder.setHasMore(result.hasMore()); + builder.setStartAfter(ByteString.copyFrom(result.getStartAfter())); + return builder.build(); + } else { + return VOID_GETBATCHEDLISTING_RESPONSE; } - builder.setHasMore(result.hasMore()); - builder.setStartAfter(ByteString.copyFrom(result.getStartAfter())); - return builder.build(); - } else { - return VOID_GETBATCHEDLISTING_RESPONSE; - } - }); + }); return null; } @@ -1210,14 +1210,14 @@ public ListCacheDirectivesResponseProto listCacheDirectives( PBHelperClient.convert(request.getFilter()); return server.listCacheDirectives(request.getPrevId(), filter); }, entries -> { - ListCacheDirectivesResponseProto.Builder builder = - ListCacheDirectivesResponseProto.newBuilder(); - builder.setHasMore(entries.hasMore()); - for (int i=0, n=entries.size(); i { - GetECTopologyResultForPoliciesResponseProto.Builder builder = - GetECTopologyResultForPoliciesResponseProto.newBuilder(); - builder - .setResponse(PBHelperClient.convertECTopologyVerifierResult(result)); - return builder.build(); - }); + GetECTopologyResultForPoliciesResponseProto.Builder builder = + GetECTopologyResultForPoliciesResponseProto.newBuilder(); + builder + .setResponse(PBHelperClient.convertECTopologyVerifierResult(result)); + return builder.build(); + }); return null; } @@ -1605,15 +1605,15 @@ public AddErasureCodingPoliciesResponseProto addErasureCodingPolicies( return server .addErasureCodingPolicies(policies); }, result -> { - List responseProtos = - Arrays.stream(result) - .map(PBHelperClient::convertAddErasureCodingPolicyResponse) - .collect(Collectors.toList()); - AddErasureCodingPoliciesResponseProto response = - AddErasureCodingPoliciesResponseProto.newBuilder() - .addAllResponses(responseProtos).build(); - return response; - }); + List responseProtos = + Arrays.stream(result) + .map(PBHelperClient::convertAddErasureCodingPolicyResponse) + .collect(Collectors.toList()); + AddErasureCodingPoliciesResponseProto response = + AddErasureCodingPoliciesResponseProto.newBuilder() + .addAllResponses(responseProtos).build(); + return response; + }); return null; } @@ -1682,15 +1682,15 @@ public ListOpenFilesResponseProto listOpenFiles( return server.listOpenFiles(req.getId(), openFilesTypes, req.getPath()); }, entries -> { - ListOpenFilesResponseProto.Builder builder = - ListOpenFilesResponseProto.newBuilder(); - builder.setHasMore(entries.hasMore()); - for (int i = 0; i < entries.size(); i++) { - builder.addEntries(PBHelperClient.convert(entries.get(i))); - } - builder.addAllTypes(req.getTypesList()); - return builder.build(); - }); + ListOpenFilesResponseProto.Builder builder = + ListOpenFilesResponseProto.newBuilder(); + builder.setHasMore(entries.hasMore()); + for (int i = 0; i < entries.size(); i++) { + builder.addEntries(PBHelperClient.convert(entries.get(i))); + } + builder.addAllTypes(req.getTypesList()); + return builder.build(); + }); return null; } diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/async/RouterAsyncRpcClient.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/async/RouterAsyncRpcClient.java index 0b9cf46a410fc..32dfab93152fb 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/async/RouterAsyncRpcClient.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/async/RouterAsyncRpcClient.java @@ -108,6 +108,7 @@ public class RouterAsyncRpcClient extends RouterRpcClient{ * @param resolver A NN resolver to determine the currently active NN in HA. * @param monitor Optional performance monitor. * @param routerStateIdContext the router state context object to hold the state ids for all + * @param asyncRouterHandler async router handler * namespaces. */ public RouterAsyncRpcClient(Configuration conf, diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestRouterAsyncRpc.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestRouterAsyncRpc.java index b4731685784b0..9cf35bfc86dc8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestRouterAsyncRpc.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestRouterAsyncRpc.java @@ -1,3 +1,20 @@ +/** + * 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.hdfs.server.federation.router.async; import org.apache.hadoop.conf.Configuration; diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestRouterAsyncRpcMultiDestination.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestRouterAsyncRpcMultiDestination.java index a21188682da14..aefc3fd191254 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestRouterAsyncRpcMultiDestination.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestRouterAsyncRpcMultiDestination.java @@ -1,3 +1,20 @@ +/** + * 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.hdfs.server.federation.router.async; import org.apache.hadoop.conf.Configuration;