diff --git a/usage/.classpath b/usage/.classpath index 4246dc6a6e3..cfb92788e37 100644 --- a/usage/.classpath +++ b/usage/.classpath @@ -5,6 +5,7 @@ + diff --git a/usage/src/com/cloud/usage/UsageAlertManagerImpl.java b/usage/src/com/cloud/usage/UsageAlertManagerImpl.java index 4779363fc55..6ac23df96c2 100644 --- a/usage/src/com/cloud/usage/UsageAlertManagerImpl.java +++ b/usage/src/com/cloud/usage/UsageAlertManagerImpl.java @@ -1,23 +1,5 @@ /** - * * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved - * - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - - -* - * + * Copyright (C) 2011 Cloud.com, Inc. All rights reserved. */ package com.cloud.usage; diff --git a/usage/src/com/cloud/usage/UsageManager.java b/usage/src/com/cloud/usage/UsageManager.java index 47a46459ecf..a715341da23 100644 --- a/usage/src/com/cloud/usage/UsageManager.java +++ b/usage/src/com/cloud/usage/UsageManager.java @@ -1,22 +1,5 @@ /** - * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved - * - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - -* - * + * Copyright (C) 2011 Cloud.com, Inc. All rights reserved. */ package com.cloud.usage; diff --git a/usage/src/com/cloud/usage/UsageManagerImpl.java b/usage/src/com/cloud/usage/UsageManagerImpl.java index 09a927df10b..d873779ba29 100644 --- a/usage/src/com/cloud/usage/UsageManagerImpl.java +++ b/usage/src/com/cloud/usage/UsageManagerImpl.java @@ -1,29 +1,10 @@ /** - * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved - * - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - - -* - * + * Copyright (C) 2011 Cloud.com, Inc. All rights reserved. */ package com.cloud.usage; import java.net.InetAddress; -import java.sql.SQLException; import java.util.Calendar; import java.util.Date; import java.util.HashMap; @@ -55,7 +36,6 @@ import com.cloud.usage.dao.UsagePortForwardingRuleDao; import com.cloud.usage.dao.UsageStorageDao; import com.cloud.usage.dao.UsageVMInstanceDao; import com.cloud.usage.dao.UsageVolumeDao; -import com.cloud.usage.parser.IPAddressUsageParser; import com.cloud.usage.parser.LoadBalancerUsageParser; import com.cloud.usage.parser.NetworkOfferingUsageParser; import com.cloud.usage.parser.NetworkUsageParser; @@ -110,19 +90,16 @@ public class UsageManagerImpl implements UsageManager, Runnable { private String m_version = null; private String m_name = null; private final Calendar m_jobExecTime = Calendar.getInstance(); - private int m_aggregationDuration = 0; - private int m_sanityCheckInterval = 0; + private int m_aggregationDuration = 0; String m_hostname = null; int m_pid = 0; - TimeZone m_usageTimezone = null; + TimeZone m_usageTimezone = TimeZone.getTimeZone("GMT");; private final GlobalLock m_heartbeatLock = GlobalLock.getInternLock("usage.job.heartbeat.check"); private final ScheduledExecutorService m_executor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("Usage-Job")); - private final ScheduledExecutorService m_heartbeatExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("Usage-HB")); - private final ScheduledExecutorService m_sanityExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("Usage-Sanity")); + private final ScheduledExecutorService m_heartbeatExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("Usage-HB")); private Future m_scheduledFuture = null; - private Future m_heartbeat = null; - private Future m_sanity = null; + private Future m_heartbeat = null; protected UsageManagerImpl() { } @@ -167,14 +144,12 @@ public class UsageManagerImpl implements UsageManager, Runnable { String execTime = configs.get("usage.stats.job.exec.time"); String aggregationRange = configs.get("usage.stats.job.aggregation.range"); - String execTimeZone = configs.get("usage.execution.timezone"); - String sanityCheckInterval = configs.get("usage.sanity.check.interval"); - if(sanityCheckInterval != null){ - m_sanityCheckInterval = Integer.parseInt(sanityCheckInterval); - } - - m_usageTimezone = TimeZone.getTimeZone("GMT"); + String execTimeZone = configs.get("usage.execution.timezone"); + String aggreagationTimeZone = configs.get("usage.aggregation.timezone"); + m_usageTimezone = TimeZone.getTimeZone(aggreagationTimeZone); + s_logger.debug("Usage stats aggregation time zone: "+aggreagationTimeZone); + try { if ((execTime == null) || (aggregationRange == null)) { s_logger.error("missing configuration values for usage job, usage.stats.job.exec.time = " + execTime + ", usage.stats.job.aggregation.range = " + aggregationRange); @@ -235,11 +210,7 @@ public class UsageManagerImpl implements UsageManager, Runnable { // use the configured exec time and aggregation duration for scheduling the job m_scheduledFuture = m_executor.scheduleAtFixedRate(this, m_jobExecTime.getTimeInMillis() - System.currentTimeMillis(), m_aggregationDuration * 60 * 1000, TimeUnit.MILLISECONDS); - m_heartbeat = m_heartbeatExecutor.scheduleAtFixedRate(new Heartbeat(), /* start in 15 seconds...*/15*1000, /* check database every minute*/60*1000, TimeUnit.MILLISECONDS); - - if(m_sanityCheckInterval > 0){ - m_sanity = m_sanityExecutor.scheduleAtFixedRate(new SanityCheck(), 1, m_sanityCheckInterval, TimeUnit.DAYS); - } + m_heartbeat = m_heartbeatExecutor.scheduleAtFixedRate(new Heartbeat(), /* start in 15 seconds...*/15*1000, /* check database every minute*/60*1000, TimeUnit.MILLISECONDS); Transaction usageTxn = Transaction.open(Transaction.USAGE_DB); try { @@ -265,10 +236,7 @@ public class UsageManagerImpl implements UsageManager, Runnable { public boolean stop() { m_heartbeat.cancel(true); - m_scheduledFuture.cancel(true); - if(m_sanityCheckInterval > 0){ - m_sanity.cancel(true); - } + m_scheduledFuture.cancel(true); return true; } @@ -742,13 +710,6 @@ public class UsageManagerImpl implements UsageManager, Runnable { if (!parsed) { s_logger.debug("network offering usage successfully parsed? " + parsed + " (for account: " + account.getAccountName() + ", id: " + account.getId() + ")"); } - } - - parsed = IPAddressUsageParser.parse(account, currentStartDate, currentEndDate); - if (s_logger.isDebugEnabled()) { - if (!parsed) { - s_logger.debug("IPAddress usage successfully parsed? " + parsed + " (for account: " + account.getAccountName() + ", id: " + account.getId() + ")"); - } } return parsed; @@ -857,16 +818,7 @@ public class UsageManagerImpl implements UsageManager, Runnable { usageInstance.setEndDate(event.getCreateDate()); m_usageInstanceDao.update(usageInstance); } - } - } - - sc = m_usageInstanceDao.createSearchCriteria(); - sc.addAnd("vmInstanceId", SearchCriteria.Op.EQ, Long.valueOf(vmId)); - sc.addAnd("endDate", SearchCriteria.Op.NULL); - sc.addAnd("usageType", SearchCriteria.Op.EQ, UsageTypes.ALLOCATED_VM); - usageInstances = m_usageInstanceDao.search(sc, null); - if (usageInstances == null || (usageInstances.size() == 0)) { - s_logger.error("Cannot find allocated vm entry for a vm running with id: " + vmId); + } } Long templateId = event.getTemplateId(); @@ -1037,23 +989,7 @@ public class UsageManagerImpl implements UsageManager, Runnable { size = event.getSize(); } - if (EventTypes.EVENT_VOLUME_CREATE.equals(event.getType())) { - SearchCriteria sc = m_usageVolumeDao.createSearchCriteria(); - sc.addAnd("accountId", SearchCriteria.Op.EQ, event.getAccountId()); - sc.addAnd("id", SearchCriteria.Op.EQ, volId); - sc.addAnd("deleted", SearchCriteria.Op.NULL); - List volumesVOs = m_usageVolumeDao.search(sc, null); - if (volumesVOs.size() > 0) { - //This is a safeguard to avoid double counting of volumes. - s_logger.error("Found duplicate usage entry for volume: " + volId + " assigned to account: " + event.getAccountId() + "; marking as deleted..."); - } - for (UsageVolumeVO volumesVO : volumesVOs) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("deleting volume: " + volumesVO.getId() + " from account: " + volumesVO.getAccountId()); - } - volumesVO.setDeleted(event.getCreateDate()); - m_usageVolumeDao.update(volumesVO); - } + if (EventTypes.EVENT_VOLUME_CREATE.equals(event.getType())) { if (s_logger.isDebugEnabled()) { s_logger.debug("create volume with id : " + volId + " for account: " + event.getAccountId()); } @@ -1061,6 +997,7 @@ public class UsageManagerImpl implements UsageManager, Runnable { UsageVolumeVO volumeVO = new UsageVolumeVO(volId, zoneId, event.getAccountId(), acct.getDomainId(), doId, templateId, size, event.getCreateDate(), null); m_usageVolumeDao.persist(volumeVO); } else if (EventTypes.EVENT_VOLUME_DELETE.equals(event.getType())) { + // at this point it's not a sourceNat IP, so find the usage record with this IP and a null released date, update the released date SearchCriteria sc = m_usageVolumeDao.createSearchCriteria(); sc.addAnd("accountId", SearchCriteria.Op.EQ, event.getAccountId()); sc.addAnd("id", SearchCriteria.Op.EQ, volId); @@ -1407,21 +1344,5 @@ public class UsageManagerImpl implements UsageManager, Runnable { sc.addAnd("scheduled", SearchCriteria.Op.EQ, Integer.valueOf(0)); m_usageJobDao.expunge(sc); } - } - - private class SanityCheck implements Runnable { - public void run() { - UsageSanityChecker usc = new UsageSanityChecker(); - try { - String errors = usc.runSanityCheck(); - if(errors.length() > 0){ - _alertMgr.sendAlert(AlertManager.ALERT_TYPE_USAGE_SANITY_RESULT, 0, new Long(0), "Usage Sanity Check failed", errors); - } else { - _alertMgr.clearAlert(AlertManager.ALERT_TYPE_USAGE_SANITY_RESULT, 0, 0); - } - } catch (SQLException e) { - s_logger.error("Error in sanity check", e); - } - } } } diff --git a/usage/src/com/cloud/usage/UsageServer.java b/usage/src/com/cloud/usage/UsageServer.java index f2f6c121571..6558fa5b4cd 100644 --- a/usage/src/com/cloud/usage/UsageServer.java +++ b/usage/src/com/cloud/usage/UsageServer.java @@ -1,20 +1,5 @@ /** - * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved - * - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see .* - * + * Copyright (C) 2011 Cloud.com, Inc. All rights reserved. */ package com.cloud.usage; diff --git a/usage/src/com/cloud/usage/parser/IPAddressUsageParser.java b/usage/src/com/cloud/usage/parser/IPAddressUsageParser.java index ad86346733b..f0d1d8e3e2c 100644 --- a/usage/src/com/cloud/usage/parser/IPAddressUsageParser.java +++ b/usage/src/com/cloud/usage/parser/IPAddressUsageParser.java @@ -1,29 +1,12 @@ -/** - * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved - * - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - +/** + * Copyright (C) 2011 Cloud.com, Inc. All rights reserved. + */ + package com.cloud.usage.parser; -import java.text.DecimalFormat; +import java.util.Calendar; import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; import org.apache.log4j.Logger; @@ -34,145 +17,108 @@ import com.cloud.usage.UsageVO; import com.cloud.usage.dao.UsageDao; import com.cloud.usage.dao.UsageIPAddressDao; import com.cloud.user.AccountVO; -import com.cloud.utils.Pair; import com.cloud.utils.component.ComponentLocator; public class IPAddressUsageParser { - public static final Logger s_logger = Logger.getLogger(IPAddressUsageParser.class.getName()); + public static final Logger s_logger = Logger.getLogger(IPAddressUsageParser.class.getName()); + + private static ComponentLocator _locator = ComponentLocator.getLocator(UsageServer.Name, "usage-components.xml", "log4j-cloud_usage"); + private static UsageDao m_usageDao = _locator.getDao(UsageDao.class); + private static UsageIPAddressDao m_usageIPAddressDao = _locator.getDao(UsageIPAddressDao.class); + + // FIXME: IP Address stuff will be in the helper table and not really rolled up to usage table since it doesn't make sense to have it that way + public static boolean parse(AccountVO account, Date startDate, Date endDate) { + s_logger.info("Parsing all ip address usage events"); - private static ComponentLocator _locator = ComponentLocator.getLocator(UsageServer.Name, "usage-components.xml", "log4j-cloud_usage"); - private static UsageDao m_usageDao = _locator.getDao(UsageDao.class); - private static UsageIPAddressDao m_usageIPAddressDao = _locator.getDao(UsageIPAddressDao.class); + // FIXME: endDate should be 23:59:59 of the day in question if it's not after the current date (or null) + if ((endDate == null) || endDate.after(new Date())) { + endDate = new Date(); + } + List usageInstances = m_usageIPAddressDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate, false, null, null); + + // IP Addresses are billed monthly. In the given date range, figure out how many months occur and create a usage record + // for each month + // FIXME: as part of this usage record, we might want to say startTime/endTime during the month that the IP was allocated + Calendar startCal = Calendar.getInstance(); + startCal.setTime(startDate); + startCal.set(Calendar.DAY_OF_MONTH, 1); + startCal.set(Calendar.HOUR_OF_DAY, 0); + startCal.set(Calendar.MINUTE, 0); + startCal.set(Calendar.SECOND, 0); + startCal.set(Calendar.MILLISECOND, 0); + + // set the end date to be the last day of the month + Calendar endCal = Calendar.getInstance(); + endCal.setTime(endDate); + endCal.set(Calendar.DAY_OF_MONTH, endCal.getActualMaximum(Calendar.DAY_OF_MONTH)); + + int numberOfMonths = 0; + while (startCal.before(endCal)) { + numberOfMonths++; + startCal.roll(Calendar.MONTH, true); + } - public static boolean parse(AccountVO account, Date startDate, Date endDate) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Parsing IP Address usage for account: " + account.getId()); - } - if ((endDate == null) || endDate.after(new Date())) { - endDate = new Date(); + s_logger.debug("processing " + numberOfMonths + " month(s) worth of ip address data"); } - // - query usage_ip_address table with the following criteria: - // - look for an entry for accountId with start date in the given range - // - look for an entry for accountId with end date in the given range - // - look for an entry for accountId with end date null (currently running vm or owned IP) - // - look for an entry for accountId with start date before given range *and* end date after given range - List usageIPAddress = m_usageIPAddressDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate); + for (UsageIPAddressVO usageInstance : usageInstances) { + String ipAddress = usageInstance.getAddress(); + Date assignedDate = usageInstance.getAssigned(); + Date releasedDate = usageInstance.getReleased(); - if(usageIPAddress.isEmpty()){ - s_logger.debug("No IP Address usage for this period"); - return true; - } - - // This map has both the running time *and* the usage amount. - Map> usageMap = new HashMap>(); - - Map IPMap = new HashMap(); - - // loop through all the usage IPs, create a usage record for each - for (UsageIPAddressVO usageIp : usageIPAddress) { - long IpId = usageIp.getId(); - - String key = ""+IpId; - - // store the info in the IP map - IPMap.put(key, new IpInfo(usageIp.getZoneId(), IpId, usageIp.getAddress(), usageIp.isSourceNat())); - - Date IpAssignDate = usageIp.getAssigned(); - Date IpReleaseDeleteDate = usageIp.getReleased(); - - if ((IpReleaseDeleteDate == null) || IpReleaseDeleteDate.after(endDate)) { - IpReleaseDeleteDate = endDate; + // if the IP address is currently owned, bill for up to the current date + if (releasedDate == null) { + releasedDate = new Date(); } - // clip the start date to the beginning of our aggregation range if the vm has been running for a while - if (IpAssignDate.before(startDate)) { - IpAssignDate = startDate; - } + // reset startCal + startCal.setTime(startDate); + startCal.set(Calendar.DAY_OF_MONTH, 1); + startCal.set(Calendar.HOUR_OF_DAY, 0); + startCal.set(Calendar.MINUTE, 0); + startCal.set(Calendar.SECOND, 0); + startCal.set(Calendar.MILLISECOND, 0); - long currentDuration = (IpReleaseDeleteDate.getTime() - IpAssignDate.getTime()) + 1; // make sure this is an inclusive check for milliseconds (i.e. use n - m + 1 to find total number of millis to charge) + // TODO: this really needs to be tested well, and might be over-engineered for what we really need, but the + // point is to count each month in which the IP address is owned and bill for that month + // we know the number of months, create a usage record for each month + // FIXME: this is supposed to create a usage record per month...first of all, that's super confusing and we need + // to get out of the weekly/monthly/daily business and instead we need to say for a given range whether or + // not the IP address was use. It's up to our customers to (a) give sensible date ranges for their own + // usage purposes and (b) + for (int i = 0; i < numberOfMonths; i++) { + if (assignedDate.before(startCal.getTime())) { + assignedDate = startCal.getTime(); + } + startCal.roll(Calendar.MONTH, true); + Date nextMonth = startCal.getTime(); + startCal.add(Calendar.MILLISECOND, -1); + if (releasedDate.before(startCal.getTime())) { + startCal.setTime(releasedDate); + } + createUsageRecord(assignedDate, startCal.getTime(), account, ipAddress, startDate, endDate); - updateIpUsageData(usageMap, key, usageIp.getId(), currentDuration); - } - - for (String ipIdKey : usageMap.keySet()) { - Pair ipTimeInfo = usageMap.get(ipIdKey); - long useTime = ipTimeInfo.second().longValue(); - - // Only create a usage record if we have a runningTime of bigger than zero. - if (useTime > 0L) { - IpInfo info = IPMap.get(ipIdKey); - createUsageRecord(info.getZoneId(), useTime, startDate, endDate, account, info.getIpId(), info.getIPAddress(), info.isSourceNat()); + // go to the start of the next month for the next iteration + startCal.setTime(nextMonth); } } - return true; - } + return true; + } - private static void updateIpUsageData(Map> usageDataMap, String key, long ipId, long duration) { - Pair ipUsageInfo = usageDataMap.get(key); - if (ipUsageInfo == null) { - ipUsageInfo = new Pair(new Long(ipId), new Long(duration)); - } else { - Long runningTime = ipUsageInfo.second(); - runningTime = new Long(runningTime.longValue() + duration); - ipUsageInfo = new Pair(ipUsageInfo.first(), runningTime); - } - usageDataMap.put(key, ipUsageInfo); - } - - private static void createUsageRecord(long zoneId, long runningTime, Date startDate, Date endDate, AccountVO account, long IpId, String IPAddress, boolean isSourceNat) { + // TODO: ip address usage comes from the usage_ip_address table, not cloud_usage table, so this is largely irrelevant and might be going away + private static void createUsageRecord(Date assigned, Date ownedUntil, AccountVO account, String address, Date startDate, Date endDate) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Total usage time " + runningTime + "ms"); + s_logger.debug("Creating usage record for account: " + account.getId() + ", ip: " + address + ", assigned date: " + assigned + ", owned until: " + ownedUntil); } - float usage = runningTime / 1000f / 60f / 60f; - - DecimalFormat dFormat = new DecimalFormat("#.######"); - String usageDisplay = dFormat.format(usage); - - if (s_logger.isDebugEnabled()) { - s_logger.debug("Creating IP usage record with id: " + IpId + ", usage: " + usageDisplay + ", startDate: " + startDate + ", endDate: " + endDate + ", for account: " + account.getId()); - } - - String usageDesc = "IPAddress: "+IPAddress; - // Create the usage record - - UsageVO usageRecord = new UsageVO(zoneId, account.getAccountId(), account.getDomainId(), usageDesc, usageDisplay + " Hrs", - UsageTypes.IP_ADDRESS, new Double(usage), null, null, null, null, IpId, startDate, endDate, (isSourceNat?"SourceNat":"")); + String usageDesc = "usage for ip address '" + address + + "' (assigned on " + assigned + ", owned until " + ownedUntil + ")"; + UsageVO usageRecord = new UsageVO(Long.valueOf(0), account.getId(), account.getDomainId(), usageDesc, "1 Month", UsageTypes.IP_ADDRESS, Double.valueOf(1), + null, null, null, null, null, null, startDate, endDate); m_usageDao.persist(usageRecord); } - - private static class IpInfo { - private long zoneId; - private long IpId; - private String IPAddress; - private boolean isSourceNat; - - public IpInfo(long zoneId,long IpId, String IPAddress, boolean isSourceNat) { - this.zoneId = zoneId; - this.IpId = IpId; - this.IPAddress = IPAddress; - this.isSourceNat = isSourceNat; - } - - public long getZoneId() { - return zoneId; - } - - public long getIpId() { - return IpId; - } - - public String getIPAddress() { - return IPAddress; - } - - public boolean isSourceNat() { - return isSourceNat; - } - } - } diff --git a/usage/src/com/cloud/usage/parser/LoadBalancerUsageParser.java b/usage/src/com/cloud/usage/parser/LoadBalancerUsageParser.java index e0d0b1b01be..2312cc8dcb9 100644 --- a/usage/src/com/cloud/usage/parser/LoadBalancerUsageParser.java +++ b/usage/src/com/cloud/usage/parser/LoadBalancerUsageParser.java @@ -1,21 +1,7 @@ -/** - * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved - * - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/** + * Copyright (C) 2011 Cloud.com, Inc. All rights reserved. + */ + package com.cloud.usage.parser; import java.text.DecimalFormat; diff --git a/usage/src/com/cloud/usage/parser/NetworkOfferingUsageParser.java b/usage/src/com/cloud/usage/parser/NetworkOfferingUsageParser.java index 3672fdc95ba..a1230b66f2a 100644 --- a/usage/src/com/cloud/usage/parser/NetworkOfferingUsageParser.java +++ b/usage/src/com/cloud/usage/parser/NetworkOfferingUsageParser.java @@ -1,21 +1,7 @@ -/** - * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved - * - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/** + * Copyright (C) 2011 Cloud.com, Inc. All rights reserved. + */ + package com.cloud.usage.parser; import java.text.DecimalFormat; diff --git a/usage/src/com/cloud/usage/parser/NetworkUsageParser.java b/usage/src/com/cloud/usage/parser/NetworkUsageParser.java index fa9c0375e3d..b754ade14fe 100644 --- a/usage/src/com/cloud/usage/parser/NetworkUsageParser.java +++ b/usage/src/com/cloud/usage/parser/NetworkUsageParser.java @@ -1,21 +1,7 @@ -/** - * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved - * - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/** + * Copyright (C) 2011 Cloud.com, Inc. All rights reserved. + */ + package com.cloud.usage.parser; import java.util.Date; diff --git a/usage/src/com/cloud/usage/parser/PortForwardingUsageParser.java b/usage/src/com/cloud/usage/parser/PortForwardingUsageParser.java index 575b39ce675..7366d79b652 100644 --- a/usage/src/com/cloud/usage/parser/PortForwardingUsageParser.java +++ b/usage/src/com/cloud/usage/parser/PortForwardingUsageParser.java @@ -1,21 +1,7 @@ -/** - * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved - * - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/** + * Copyright (C) 2011 Cloud.com, Inc. All rights reserved. + */ + package com.cloud.usage.parser; import java.text.DecimalFormat; diff --git a/usage/src/com/cloud/usage/parser/StorageUsageParser.java b/usage/src/com/cloud/usage/parser/StorageUsageParser.java index 6faf56fb869..4d82e7601f0 100644 --- a/usage/src/com/cloud/usage/parser/StorageUsageParser.java +++ b/usage/src/com/cloud/usage/parser/StorageUsageParser.java @@ -1,21 +1,7 @@ -/** - * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved - * - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/** + * Copyright (C) 2011 Cloud.com, Inc. All rights reserved. + */ + package com.cloud.usage.parser; import java.text.DecimalFormat; @@ -74,7 +60,7 @@ public class StorageUsageParser { long storageId = usageStorage.getId(); int storage_type = usageStorage.getStorageType(); long size = usageStorage.getSize(); - long zoneId = usageStorage.getZoneId(); + long zoneId = usageStorage.getZoneId(); Long sourceId = usageStorage.getSourceId(); String key = ""+storageId+"Z"+zoneId+"T"+storage_type; @@ -140,14 +126,14 @@ public class StorageUsageParser { s_logger.debug("Creating Storage usage record for type: "+ type + " with id: " + storageId + ", usage: " + usageDisplay + ", startDate: " + startDate + ", endDate: " + endDate + ", for account: " + account.getId()); } - String usageDesc = ""; + String usageDesc = ""; Long tmplSourceId = null; int usage_type = 0; switch(type){ case StorageTypes.TEMPLATE: usage_type = UsageTypes.TEMPLATE; - usageDesc += "Template "; + usageDesc += "Template "; tmplSourceId = sourceId; break; case StorageTypes.ISO: @@ -171,14 +157,14 @@ public class StorageUsageParser { private static class StorageInfo { private long zoneId; private long storageId; - private int storageType; + private int storageType; private Long sourceId; private long size; public StorageInfo(long zoneId, long storageId, int storageType, Long sourceId, long size) { this.zoneId = zoneId; this.storageId = storageId; - this.storageType = storageType; + this.storageType = storageType; this.sourceId = sourceId; this.size = size; } @@ -194,11 +180,11 @@ public class StorageUsageParser { public int getStorageType() { return storageType; } - - public long getSourceId() { - return sourceId; - } - + + public long getSourceId() { + return sourceId; + } + public long getSize() { return size; diff --git a/usage/src/com/cloud/usage/parser/UsageParser.java b/usage/src/com/cloud/usage/parser/UsageParser.java index b628a4e39c6..46bc5375850 100644 --- a/usage/src/com/cloud/usage/parser/UsageParser.java +++ b/usage/src/com/cloud/usage/parser/UsageParser.java @@ -1,21 +1,7 @@ -/** - * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved - * - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/** + * Copyright (C) 2011 Cloud.com, Inc. All rights reserved. + */ + package com.cloud.usage.parser; import java.util.Date; diff --git a/usage/src/com/cloud/usage/parser/VMInstanceUsageParser.java b/usage/src/com/cloud/usage/parser/VMInstanceUsageParser.java index 93bb324d3be..6268d13b268 100644 --- a/usage/src/com/cloud/usage/parser/VMInstanceUsageParser.java +++ b/usage/src/com/cloud/usage/parser/VMInstanceUsageParser.java @@ -1,21 +1,7 @@ -/** - * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved - * - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/** + * Copyright (C) 2011 Cloud.com, Inc. All rights reserved. + */ + package com.cloud.usage.parser; import java.text.DecimalFormat; diff --git a/usage/src/com/cloud/usage/parser/VolumeUsageParser.java b/usage/src/com/cloud/usage/parser/VolumeUsageParser.java index 85f3005a266..bc0c0bc3f6d 100644 --- a/usage/src/com/cloud/usage/parser/VolumeUsageParser.java +++ b/usage/src/com/cloud/usage/parser/VolumeUsageParser.java @@ -1,21 +1,7 @@ -/** - * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved - * - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - +/** + * Copyright (C) 2011 Cloud.com, Inc. All rights reserved. + */ + package com.cloud.usage.parser; import java.text.DecimalFormat;