cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kis...@apache.org
Subject git commit: updated refs/heads/master to 4ac96d6
Date Wed, 07 Jan 2015 06:23:36 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master bc235ed5e -> 4ac96d637


Trigger user stats aggregation job at midnight in usage aggregation timezone


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

Branch: refs/heads/master
Commit: 4ac96d637c9efe0db50dd707dd161426aeb54a13
Parents: bc235ed
Author: Kishan Kavala <kishan@apache.org>
Authored: Thu Nov 20 17:08:17 2014 +0530
Committer: Kishan Kavala <kishan@apache.org>
Committed: Wed Jan 7 11:17:24 2015 +0530

----------------------------------------------------------------------
 .../VirtualNetworkApplianceManagerImpl.java     | 25 +++++++++++++-------
 1 file changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4ac96d63/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index c505755..c9590fe 100644
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -651,34 +651,36 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine>
{
             s_logger.debug("router.stats.interval - " + _routerStatsInterval + " so not scheduling
the router stats thread");
         }
 
-        // Schedule Network stats update task
+        //Schedule Network stats update task
+        //Network stats aggregation should align with aggregation range
+        //For daily aggregation, update stats at the end of the day
+        //For hourly aggregation, update stats at the end of the hour
         final TimeZone usageTimezone = TimeZone.getTimeZone(_usageTimeZone);
         final Calendar cal = Calendar.getInstance(usageTimezone);
         cal.setTime(new Date());
-        long endDate = 0;
+        //aggDate is the time in millis when the aggregation should happen
+        long aggDate = 0;
         final int HOURLY_TIME = 60;
         final int DAILY_TIME = 60 * 24;
         if (_usageAggregationRange == DAILY_TIME) {
-            cal.roll(Calendar.DAY_OF_YEAR, false);
             cal.set(Calendar.HOUR_OF_DAY, 0);
             cal.set(Calendar.MINUTE, 0);
             cal.set(Calendar.SECOND, 0);
             cal.set(Calendar.MILLISECOND, 0);
             cal.roll(Calendar.DAY_OF_YEAR, true);
             cal.add(Calendar.MILLISECOND, -1);
-            endDate = cal.getTime().getTime();
+            aggDate = cal.getTime().getTime();
             _dailyOrHourly = true;
         } else if (_usageAggregationRange == HOURLY_TIME) {
-            cal.roll(Calendar.HOUR_OF_DAY, false);
             cal.set(Calendar.MINUTE, 0);
             cal.set(Calendar.SECOND, 0);
             cal.set(Calendar.MILLISECOND, 0);
             cal.roll(Calendar.HOUR_OF_DAY, true);
             cal.add(Calendar.MILLISECOND, -1);
-            endDate = cal.getTime().getTime();
+            aggDate = cal.getTime().getTime();
             _dailyOrHourly = true;
         } else {
-            endDate = cal.getTime().getTime();
+            aggDate = cal.getTime().getTime();
             _dailyOrHourly = false;
         }
 
@@ -687,7 +689,14 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine>
{
             _usageAggregationRange = UsageUtils.USAGE_AGGREGATION_RANGE_MIN;
         }
 
-        _networkStatsUpdateExecutor.scheduleAtFixedRate(new NetworkStatsUpdateTask(), endDate
- System.currentTimeMillis(), _usageAggregationRange * 60 * 1000,
+        // We cannot schedule a job at specific time. Provide initial delay instead, from
current time, so that the job runs at desired time
+        long initialDelay = aggDate - System.currentTimeMillis();
+
+        if( initialDelay < 0){
+            s_logger.warn("Initial delay for network usage stats update task is incorrect.
Stats update task will run immediately");
+        }
+
+        _networkStatsUpdateExecutor.scheduleAtFixedRate(new NetworkStatsUpdateTask(), initialDelay,
(_usageAggregationRange * 60 * 1000),
                 TimeUnit.MILLISECONDS);
 
         if (_routerCheckInterval > 0) {


Mime
View raw message