Skip to content

Commit

Permalink
fix check & javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
KeeProMise committed Jan 3, 2025
1 parent c37a39a commit 70a52af
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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<n; i++) {
builder.addElements(PBHelperClient.convert(entries.get(i)));
}
return builder.build();
});
ListCacheDirectivesResponseProto.Builder builder =
ListCacheDirectivesResponseProto.newBuilder();
builder.setHasMore(entries.hasMore());
for (int i=0, n=entries.size(); i<n; i++) {
builder.addElements(PBHelperClient.convert(entries.get(i)));
}
return builder.build();
});
return null;
}

Expand Down Expand Up @@ -1430,12 +1430,12 @@ public GetECTopologyResultForPoliciesResponseProto getECTopologyResultForPolicie
return server.getECTopologyResultForPolicies(
policies.toArray(policies.toArray(new String[policies.size()])));
}, result -> {
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;
}

Expand Down Expand Up @@ -1605,15 +1605,15 @@ public AddErasureCodingPoliciesResponseProto addErasureCodingPolicies(
return server
.addErasureCodingPolicies(policies);
}, result -> {
List<HdfsProtos.AddErasureCodingPolicyResponseProto> responseProtos =
Arrays.stream(result)
.map(PBHelperClient::convertAddErasureCodingPolicyResponse)
.collect(Collectors.toList());
AddErasureCodingPoliciesResponseProto response =
AddErasureCodingPoliciesResponseProto.newBuilder()
.addAllResponses(responseProtos).build();
return response;
});
List<HdfsProtos.AddErasureCodingPolicyResponseProto> responseProtos =
Arrays.stream(result)
.map(PBHelperClient::convertAddErasureCodingPolicyResponse)
.collect(Collectors.toList());
AddErasureCodingPoliciesResponseProto response =
AddErasureCodingPoliciesResponseProto.newBuilder()
.addAllResponses(responseProtos).build();
return response;
});
return null;
}

Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 70a52af

Please sign in to comment.