airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject [3/3] git commit: Optimized zookeeper update code, only update if job count is differ from exist job count
Date Fri, 12 Sep 2014 02:43:44 GMT
Optimized zookeeper update code, only update if job count is differ from exist job count


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/45f0d68f
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/45f0d68f
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/45f0d68f

Branch: refs/heads/master
Commit: 45f0d68fd3da85f692a899cc371b3247267cac74
Parents: d004df1
Author: shamrath <shameerainfo@gmail.com>
Authored: Thu Sep 11 22:02:56 2014 -0400
Committer: shamrath <shameerainfo@gmail.com>
Committed: Thu Sep 11 22:02:56 2014 -0400

----------------------------------------------------------------------
 .../monitor/impl/pull/qstat/HPCPullMonitor.java | 22 ++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/45f0d68f/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/HPCPullMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/HPCPullMonitor.java
b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/HPCPullMonitor.java
index 6d6108e..d7c8a4e 100644
--- a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/HPCPullMonitor.java
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/HPCPullMonitor.java
@@ -343,6 +343,7 @@ public class HPCPullMonitor extends PullMonitor {
 
     /**
      * Build the /stat/{username}/{hostAddress}/job znode path and store job count
+     *
      * @param userMonitorData
      * @param completedJobs
      * @throws ApplicationSettingsException
@@ -373,9 +374,20 @@ public class HPCPullMonitor extends PullMonitor {
                             .append(hostData.getHost().getType().getHostAddress()).append("/").append(Constants.JOB);
                     checkAndCreateZNode(zk, jobPathBuilder.toString());
                     int jobCount = 0;
+                    String jobCountStr = new String(zk.getData(jobPathBuilder.toString(),
null, null));
+                    try {
+                        jobCount = Integer.parseInt(jobCountStr);
+                    } catch (NumberFormatException e) {
+                        // do nothing , keep jobCount 0
+                    }
                     List<MonitorID> idList = hostData.getMonitorIDs();
+                    boolean updatePath = true;
                     if (idList != null) {
-                        jobCount = idList.size();
+                        if (jobCount == idList.size()) {
+                            updatePath = false;
+                        } else {
+                            jobCount = idList.size();
+                        }
                         // removed already updated jobs from complete jobs
                         for (MonitorID monitorID : idList) {
                             if (completedJobs.contains(monitorID)) {
@@ -383,8 +395,10 @@ public class HPCPullMonitor extends PullMonitor {
                             }
                         }
                     }
-                    zk.setData(jobPathBuilder.toString(), String.valueOf(jobCount).getBytes(),
-1);
-                    updatedPathList.add(jobPathBuilder.toString());
+                    if (updatePath) {
+                        zk.setData(jobPathBuilder.toString(), String.valueOf(jobCount).getBytes(),
-1);
+                        updatedPathList.add(jobPathBuilder.toString());
+                    }
                 }
 
                 //handle completed jobs
@@ -416,7 +430,7 @@ public class HPCPullMonitor extends PullMonitor {
         } catch (ApplicationSettingsException e) {
             logger.error("Error while getting zookeeper hostport property", e);
         } catch (InterruptedException e) {
-            logger.error("Error while waiting for SyncConnected message" , e);
+            logger.error("Error while waiting for SyncConnected message", e);
         }
 
     }


Mime
View raw message