Repository: airavata Updated Branches: refs/heads/airavata-0.15-release-branch 14044de5d -> 7b9418ae9
update deliverytag in case of redelivery Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/7b9418ae Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/7b9418ae Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/7b9418ae Branch: refs/heads/airavata-0.15-release-branch Commit: 7b9418ae9d4e8d8062f1b6a403deef4829b03739 Parents: 14044de Author: Shameera Rathanyaka <[email protected]> Authored: Wed Jun 10 14:07:31 2015 -0400 Committer: Shameera Rathanyaka <[email protected]> Committed: Wed Jun 10 14:07:31 2015 -0400 ---------------------------------------------------------------------- .../airavata/gfac/core/utils/GFacUtils.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/7b9418ae/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java index 5d39f40..3570703 100644 --- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java +++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java @@ -423,9 +423,10 @@ public class GFacUtils { } else { log.error("ExperimentID: " + experimentID + " taskID: " + taskID + " was running by some Gfac instance,but it failed"); removeCancelDeliveryTagNode(oldExperimentPath, curatorClient); // remove previous cancel deliveryTagNode - if(newExperimentPath.equals(oldExperimentPath)){ - log.info("Re-launch experiment came to the same GFac instance"); - }else { + if(newExperimentPath.equals(oldExperimentPath)) { + updateDeliveryTag(oldExperimentPath, curatorClient, deliveryTag); + log.info("Re-launch experiment came to the same GFac instance"); + }else { log.info("Re-launch experiment came to a new GFac instance so we are moving data to new gfac node"); curatorClient.create().withMode(CreateMode.PERSISTENT).withACL(OPEN_ACL_UNSAFE).forPath(newExperimentPath, curatorClient.getData().storingStatIn(exists1).forPath(oldExperimentPath)); // recursively copy children @@ -448,7 +449,17 @@ public class GFacUtils { return true; } - private static void removeCancelDeliveryTagNode(String experimentPath, CuratorFramework curatorClient) throws Exception { + private static void updateDeliveryTag(String oldExperimentPath, CuratorFramework curatorClient, long deliveryTag) throws Exception { + Stat stat = curatorClient.checkExists().forPath(oldExperimentPath + AiravataZKUtils.DELIVERY_TAG_POSTFIX); + if (stat != null) { + curatorClient.setData().withVersion(-1).forPath(oldExperimentPath + AiravataZKUtils.DELIVERY_TAG_POSTFIX, longToBytes(deliveryTag)); + } else { + curatorClient.create().withMode(CreateMode.PERSISTENT).withACL(OPEN_ACL_UNSAFE) + .forPath(oldExperimentPath + AiravataZKUtils.DELIVERY_TAG_POSTFIX, longToBytes(deliveryTag)); + } + } + + private static void removeCancelDeliveryTagNode(String experimentPath, CuratorFramework curatorClient) throws Exception { Stat exists = curatorClient.checkExists().forPath(experimentPath + AiravataZKUtils.CANCEL_DELIVERY_TAG_POSTFIX); if (exists != null) { ZKPaths.deleteChildren(curatorClient.getZookeeperClient().getZooKeeper(), experimentPath + AiravataZKUtils.CANCEL_DELIVERY_TAG_POSTFIX, true);
