cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [49/59] [abbrv] git commit: updated refs/heads/disk-cache to bbae6f8
Date Wed, 25 Sep 2013 10:29:44 GMT
Committing review 13891.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3e813ce6
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3e813ce6
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3e813ce6

Branch: refs/heads/disk-cache
Commit: 3e813ce61d308c09ce23f54bd67adc980478640c
Parents: df3ee9a
Author: Alex Huang <alex.huang@citrix.com>
Authored: Mon Sep 23 14:59:39 2013 -0700
Committer: Alex Huang <alex.huang@citrix.com>
Committed: Mon Sep 23 14:59:58 2013 -0700

----------------------------------------------------------------------
 .../framework/jobs/impl/AsyncJobMonitor.java    | 35 ++++++++++----------
 1 file changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3e813ce6/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java
b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java
index 3bf3622..ad0da35 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java
@@ -20,6 +20,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Timer;
 import java.util.TimerTask;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
@@ -41,14 +42,14 @@ public class AsyncJobMonitor extends ManagerBase {
 	
 	private final Map<Long, ActiveTaskRecord> _activeTasks = new HashMap<Long, ActiveTaskRecord>();
 	private final Timer _timer = new Timer();
-	
-	private volatile int _activePoolThreads = 0;
-	private volatile int _activeInplaceThreads = 0;
-	
-	// configuration
-	private long _inactivityCheckIntervalMs = 60000;
-	private long _inactivityWarningThresholdMs = 90000;
-	
+
+    private final AtomicInteger _activePoolThreads = new AtomicInteger();
+    private final AtomicInteger _activeInplaceThreads = new AtomicInteger();
+
+    // configuration
+    private long _inactivityCheckIntervalMs = 60000;
+    private long _inactivityWarningThresholdMs = 90000;
+
 	public AsyncJobMonitor() {
 	}
 	
@@ -118,9 +119,9 @@ public class AsyncJobMonitor extends ManagerBase {
             ActiveTaskRecord record = new ActiveTaskRecord(jobId, threadId, fromPoolThread);
 			_activeTasks.put(runNumber, record);
 			if(fromPoolThread)
-				_activePoolThreads++;
+				_activePoolThreads.incrementAndGet();
 			else
-				_activeInplaceThreads++;
+				_activeInplaceThreads.incrementAndGet();
 		}
 	}
 	
@@ -132,23 +133,23 @@ public class AsyncJobMonitor extends ManagerBase {
 				s_logger.info("Remove job-" + record.getJobId() + " from job monitoring");
 				
 				if(record.isPoolThread())
-					_activePoolThreads--;
+					_activePoolThreads.decrementAndGet();
 				else
-					_activeInplaceThreads--;
+					_activeInplaceThreads.decrementAndGet();
 				
 				_activeTasks.remove(runNumber);
 			}
 		}
 	}
-	
+
 	public int getActivePoolThreads() {
-		return _activePoolThreads;
+		return _activePoolThreads.get();
 	}
-	
+
 	public int getActiveInplaceThread() {
-		return _activeInplaceThreads;
+		return _activeInplaceThreads.get();
 	}
-	
+
 	private static class ActiveTaskRecord {
 		long _jobId;
 		long _threadId;


Mime
View raw message