cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [07/50] [abbrv] git commit: updated refs/heads/master to 1c408de
Date Thu, 07 May 2015 14:04:45 GMT
GetUsageRecordsCmd - NewInputFormat for START_DATE and END_DATE (with time; backward capabile)

This closes #191

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


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

Branch: refs/heads/master
Commit: 50dd37fcc941861c575fd82b58b11a2eb4a03482
Parents: cc900bf
Author: Ilia Shakitko <shakitko@gmail.com>
Authored: Sat Apr 25 01:20:04 2015 +0200
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Sat Apr 25 02:49:21 2015 +0200

----------------------------------------------------------------------
 .../command/admin/usage/GetUsageRecordsCmd.java  |  4 ++--
 .../cloud/api/dispatch/ParamProcessWorker.java   |  4 ++--
 server/src/com/cloud/usage/UsageServiceImpl.java | 19 ++++---------------
 3 files changed, 8 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/50dd37fc/api/src/org/apache/cloudstack/api/command/admin/usage/GetUsageRecordsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/usage/GetUsageRecordsCmd.java
b/api/src/org/apache/cloudstack/api/command/admin/usage/GetUsageRecordsCmd.java
index 8c1ce87..fd8173d 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/usage/GetUsageRecordsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/usage/GetUsageRecordsCmd.java
@@ -55,13 +55,13 @@ public class GetUsageRecordsCmd extends BaseListCmd {
     @Parameter(name = ApiConstants.END_DATE,
                type = CommandType.DATE,
                required = true,
-               description = "End date range for usage record query. Use yyyy-MM-dd as the
date format, e.g. startDate=2009-06-03.")
+               description = "End date range for usage record query (use format \"yyyy-MM-dd\"
or the new format \"yyyy-MM-dd HH:mm:ss\", e.g. startDate=2015-01-01 or startdate=2015-01-01
10:30:00).")
     private Date endDate;
 
     @Parameter(name = ApiConstants.START_DATE,
                type = CommandType.DATE,
                required = true,
-               description = "Start date range for usage record query. Use yyyy-MM-dd as
the date format, e.g. startDate=2009-06-01.")
+               description = "Start date range for usage record query (use format \"yyyy-MM-dd\"
or the new format \"yyyy-MM-dd HH:mm:ss\", e.g. startDate=2015-01-01 or startdate=2015-01-01
11:00:00).")
     private Date startDate;
 
     @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class,
description = "List usage records for the specified account")

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/50dd37fc/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/dispatch/ParamProcessWorker.java b/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
index 6eb53e0..b990d4a 100644
--- a/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
+++ b/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
@@ -50,6 +50,7 @@ import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.command.admin.resource.ArchiveAlertsCmd;
 import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd;
+import org.apache.cloudstack.api.command.admin.usage.GetUsageRecordsCmd;
 import org.apache.cloudstack.api.command.user.event.ArchiveEventsCmd;
 import org.apache.cloudstack.api.command.user.event.DeleteEventsCmd;
 import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
@@ -254,9 +255,8 @@ public class ParamProcessWorker implements DispatchWorker {
             case DATE:
                 // This piece of code is for maintaining backward compatibility
                 // and support both the date formats(Bug 9724)
-                // Do the date messaging for ListEventsCmd only
                 if (cmdObj instanceof ListEventsCmd || cmdObj instanceof DeleteEventsCmd
|| cmdObj instanceof ArchiveEventsCmd ||
-                        cmdObj instanceof ArchiveAlertsCmd || cmdObj instanceof DeleteAlertsCmd)
{
+                        cmdObj instanceof ArchiveAlertsCmd || cmdObj instanceof DeleteAlertsCmd
|| cmdObj instanceof GetUsageRecordsCmd) {
                     final boolean isObjInNewDateFormat = isObjInNewDateFormat(paramObj.toString());
                     if (isObjInNewDateFormat) {
                         final DateFormat newFormat = BaseCmd.NEW_INPUT_FORMAT;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/50dd37fc/server/src/com/cloud/usage/UsageServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/usage/UsageServiceImpl.java b/server/src/com/cloud/usage/UsageServiceImpl.java
index f81415b..6fe313d 100755
--- a/server/src/com/cloud/usage/UsageServiceImpl.java
+++ b/server/src/com/cloud/usage/UsageServiceImpl.java
@@ -224,11 +224,11 @@ public class UsageServiceImpl extends ManagerBase implements UsageService,
Manag
             throw new InvalidParameterValueException("Incorrect Date Range. Start date: "
+ startDate + " is after end date:" + endDate);
         }
         TimeZone usageTZ = getUsageTimezone();
-        Date adjustedStartDate = computeAdjustedTime(startDate, usageTZ, true);
-        Date adjustedEndDate = computeAdjustedTime(endDate, usageTZ, false);
+        Date adjustedStartDate = computeAdjustedTime(startDate, usageTZ);
+        Date adjustedEndDate = computeAdjustedTime(endDate, usageTZ);
 
         if (s_logger.isDebugEnabled()) {
-            s_logger.debug("getting usage records for account: " + accountId + ", domainId:
" + domainId + ", between " + startDate + " and " + endDate +
+            s_logger.debug("getting usage records for account: " + accountId + ", domainId:
" + domainId + ", between " + adjustedStartDate + " and " + adjustedEndDate +
                 ", using pageSize: " + cmd.getPageSizeVal() + " and startIndex: " + cmd.getStartIndex());
         }
 
@@ -375,7 +375,7 @@ public class UsageServiceImpl extends ManagerBase implements UsageService,
Manag
         return _usageTimezone;
     }
 
-    private Date computeAdjustedTime(Date initialDate, TimeZone targetTZ, boolean adjustToDayStart)
{
+    private Date computeAdjustedTime(Date initialDate, TimeZone targetTZ) {
         Calendar cal = Calendar.getInstance();
         cal.setTime(initialDate);
         TimeZone localTZ = cal.getTimeZone();
@@ -395,17 +395,6 @@ public class UsageServiceImpl extends ManagerBase implements UsageService,
Manag
         }
 
         calTS.add(Calendar.MILLISECOND, -1 * timezoneOffset);
-        if (adjustToDayStart) {
-            calTS.set(Calendar.HOUR_OF_DAY, 0);
-            calTS.set(Calendar.MINUTE, 0);
-            calTS.set(Calendar.SECOND, 0);
-            calTS.set(Calendar.MILLISECOND, 0);
-        } else {
-            calTS.set(Calendar.HOUR_OF_DAY, 23);
-            calTS.set(Calendar.MINUTE, 59);
-            calTS.set(Calendar.SECOND, 59);
-            calTS.set(Calendar.MILLISECOND, 999);
-        }
 
         return calTS.getTime();
     }


Mime
View raw message