You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2020/04/16 04:20:48 UTC

[airavata-mft] 01/03: Avoiding success status publish for failed transfers

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

dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git

commit cc4a195817f44e4b382bbabfdfd22a28b27ef03d
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Thu Apr 16 00:18:42 2020 -0400

    Avoiding success status publish for failed transfers
---
 .../airavata/mft/agent/TransportMediator.java      | 77 +++++++++++-----------
 1 file changed, 40 insertions(+), 37 deletions(-)

diff --git a/agent/src/main/java/org/apache/airavata/mft/agent/TransportMediator.java b/agent/src/main/java/org/apache/airavata/mft/agent/TransportMediator.java
index 7738ca4..d8a2ebe 100644
--- a/agent/src/main/java/org/apache/airavata/mft/agent/TransportMediator.java
+++ b/agent/src/main/java/org/apache/airavata/mft/agent/TransportMediator.java
@@ -88,6 +88,8 @@ public class TransportMediator {
 
                 try {
                     int futureCnt = futureList.size();
+                    boolean transferErrored = false;
+
                     for (int i = 0; i < futureCnt; i++) {
                         Future<Integer> ft = completionService.take();
                         futureList.remove(ft);
@@ -96,7 +98,7 @@ public class TransportMediator {
                         } catch (Exception e) {
 
                             logger.error("One task failed with error", e);
-
+                            transferErrored = true;
                             statusLock.lock();
                             onStatusCallback.accept(command.getTransferId(), new TransferState()
                                 .setPercentage(0)
@@ -119,52 +121,53 @@ public class TransportMediator {
                         }
                     }
 
-                    Boolean transferred = destMetadataCollector.isAvailable(command.getDestinationId(), command.getDestinationToken());
-
-                    if (!transferred) {
-                        logger.error("Transfer completed but resource is not available in destination");
-                        throw new Exception("Transfer completed but resource is not available in destination");
-                    }
+                    if (!transferErrored) {
+                        Boolean transferred = destMetadataCollector.isAvailable(command.getDestinationId(), command.getDestinationToken());
 
-                    ResourceMetadata destMetadata = destMetadataCollector.getGetResourceMetadata(command.getDestinationId(),
-                                                    command.getDestinationToken());
+                        if (!transferred) {
+                            logger.error("Transfer completed but resource is not available in destination");
+                            throw new Exception("Transfer completed but resource is not available in destination");
+                        }
 
-                    boolean doIntegrityVerify = true;
+                        ResourceMetadata destMetadata = destMetadataCollector.getGetResourceMetadata(command.getDestinationId(),
+                                command.getDestinationToken());
 
-                    if (srcMetadata.getMd5sum() == null) {
-                        logger.warn("MD5 sum is not available for source resource. So this disables integrity verification");
-                        doIntegrityVerify = false;
-                    } else if (destMetadata.getMd5sum() == null) {
-                        logger.warn("MD5 sum is not available for destination resource. So this disables integrity verification");
-                        doIntegrityVerify = false;
-                    }
+                        boolean doIntegrityVerify = true;
 
-                    if (doIntegrityVerify && !destMetadata.getMd5sum().equals(srcMetadata.getMd5sum())) {
-                        logger.error("Resource integrity violated. MD5 sums are not matching. Source md5 {} destination md5 {}",
-                                                            srcMetadata.getMd5sum(), destMetadata.getMd5sum());
-                        throw new Exception("Resource integrity violated. MD5 sums are not matching. Source md5 " + srcMetadata.getMd5sum()
-                                                        + " destination md5 " + destMetadata.getMd5sum());
-                    }
+                        if (srcMetadata.getMd5sum() == null) {
+                            logger.warn("MD5 sum is not available for source resource. So this disables integrity verification");
+                            doIntegrityVerify = false;
+                        } else if (destMetadata.getMd5sum() == null) {
+                            logger.warn("MD5 sum is not available for destination resource. So this disables integrity verification");
+                            doIntegrityVerify = false;
+                        }
 
-                    // Check
+                        if (doIntegrityVerify && !destMetadata.getMd5sum().equals(srcMetadata.getMd5sum())) {
+                            logger.error("Resource integrity violated. MD5 sums are not matching. Source md5 {} destination md5 {}",
+                                    srcMetadata.getMd5sum(), destMetadata.getMd5sum());
+                            throw new Exception("Resource integrity violated. MD5 sums are not matching. Source md5 " + srcMetadata.getMd5sum()
+                                    + " destination md5 " + destMetadata.getMd5sum());
+                        }
 
-                    long endTime = System.nanoTime();
+                        // Check
 
-                    double time = (endTime - startTime) * 1.0 /1000000000;
+                        long endTime = System.nanoTime();
 
-                    statusLock.lock();
-                    onStatusCallback.accept(command.getTransferId(), new TransferState()
-                        .setPercentage(100)
-                        .setState("COMPLETED")
-                        .setUpdateTimeMils(System.currentTimeMillis())
-                        .setDescription("Transfer successfully completed"));
-                    transferInProgress.set(false);
-                    transferSuccess.set(true);
-                    statusLock.unlock();
+                        double time = (endTime - startTime) * 1.0 / 1000000000;
 
-                    logger.info("Transfer {} completed.  Speed {} MB/s", command.getTransferId(),
-                                                    (srcMetadata.getResourceSize() * 1.0 / time) / (1024 * 1024));
+                        statusLock.lock();
+                        onStatusCallback.accept(command.getTransferId(), new TransferState()
+                                .setPercentage(100)
+                                .setState("COMPLETED")
+                                .setUpdateTimeMils(System.currentTimeMillis())
+                                .setDescription("Transfer successfully completed"));
+                        transferInProgress.set(false);
+                        transferSuccess.set(true);
+                        statusLock.unlock();
 
+                        logger.info("Transfer {} completed.  Speed {} MB/s", command.getTransferId(),
+                                (srcMetadata.getResourceSize() * 1.0 / time) / (1024 * 1024));
+                    }
                 } catch (Exception e) {
 
                     statusLock.lock();