This is an automated email from the ASF dual-hosted git repository.

shashikant pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 873c0d2  HDDS-5696. Close grpcReplicationClient on exception. (#2595)
873c0d2 is described below

commit 873c0d268527e55f9fd9b1a7f66c3d254be22fb9
Author: Sammi Chen <[email protected]>
AuthorDate: Tue Sep 14 14:39:00 2021 +0800

    HDDS-5696. Close grpcReplicationClient on exception. (#2595)
---
 .../replication/SimpleContainerDownloader.java       | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/SimpleContainerDownloader.java
 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/SimpleContainerDownloader.java
index c2415ba..c3d1227 100644
--- 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/SimpleContainerDownloader.java
+++ 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/SimpleContainerDownloader.java
@@ -54,9 +54,7 @@ public class SimpleContainerDownloader implements 
ContainerDownloader {
   private final CertificateClient certClient;
 
   public SimpleContainerDownloader(
-      ConfigurationSource conf,
-      CertificateClient certClient
-  ) {
+      ConfigurationSource conf, CertificateClient certClient) {
 
     String workDirString =
         conf.get(OzoneConfigKeys.OZONE_CONTAINER_COPY_WORKDIR);
@@ -73,9 +71,7 @@ public class SimpleContainerDownloader implements 
ContainerDownloader {
 
   @Override
   public CompletableFuture<Path> getContainerDataFromReplicas(
-      long containerId,
-      List<DatanodeDetails> sourceDatanodes
-  ) {
+      long containerId, List<DatanodeDetails> sourceDatanodes) {
 
     CompletableFuture<Path> result = null;
 
@@ -91,7 +87,7 @@ public class SimpleContainerDownloader implements 
ContainerDownloader {
           result = result.exceptionally(t -> {
             LOG.error("Error on replicating container: " + containerId, t);
             try {
-              return downloadContainer(containerId, datanode).join();
+              return downloadContainer(containerId, datanode).get();
             } catch (Exception e) {
               LOG.error("Error on replicating container: " + containerId,
                   e);
@@ -113,8 +109,7 @@ public class SimpleContainerDownloader implements 
ContainerDownloader {
   //due to data corruption. We need a random selected datanode to have a
   //chance to succeed next time.
   protected List<DatanodeDetails> shuffleDatanodes(
-      List<DatanodeDetails> sourceDatanodes
-  ) {
+      List<DatanodeDetails> sourceDatanodes) {
 
     final ArrayList<DatanodeDetails> shuffledDatanodes =
         new ArrayList<>(sourceDatanodes);
@@ -126,22 +121,19 @@ public class SimpleContainerDownloader implements 
ContainerDownloader {
 
   @VisibleForTesting
   protected CompletableFuture<Path> downloadContainer(
-      long containerId,
-      DatanodeDetails datanode
-  ) throws IOException {
+      long containerId, DatanodeDetails datanode) throws IOException {
     CompletableFuture<Path> result;
     GrpcReplicationClient grpcReplicationClient =
         new GrpcReplicationClient(datanode.getIpAddress(),
             datanode.getPort(Name.REPLICATION).getValue(),
             workingDirectory, securityConfig, certClient);
     result = grpcReplicationClient.download(containerId)
-        .thenApply(r -> {
+        .whenComplete((r, ex) -> {
           try {
             grpcReplicationClient.close();
           } catch (Exception e) {
             LOG.error("Couldn't close Grpc replication client", e);
           }
-          return r;
         });
 
     return result;

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to