mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
updating copyright licenses, including build-usage.xml
This commit is contained in:
parent
7621dea575
commit
81c376dd5b
@ -25,4 +25,5 @@
|
||||
<import file="${base.dir}/build/build-tests.xml" optional="true"/>
|
||||
<import file="${base.dir}/build/package.xml" optional="true"/>
|
||||
<import file="${base.dir}/build/developer.xml" optional="true"/>
|
||||
<import file="${base.dir}/build/build-usage.xml" optional="false"/>
|
||||
</project>
|
||||
|
||||
49
build/build-usage.xml
Normal file
49
build/build-usage.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright 2008 Cloud, Inc. All Rights Reserved -->
|
||||
<project name="Cloud Stack Usage Server" default="help" basedir=".">
|
||||
<description>
|
||||
Cloud Stack Usage server build
|
||||
</description>
|
||||
<property name="base.dir" location="${ant.file.Cloud Stack Usage Server}/../../.."/>
|
||||
<property name="oss.build.dir" location="${base.dir}/build"/>
|
||||
<property name="usage.jar" value="cloud-usage.jar" />
|
||||
<dirname property="proprietary.dir" file="${ant.file.Cloud Stack Usage Server}/../"/>
|
||||
<property name="usage.build.dir" location="${proprietary.dir}/build"/>
|
||||
|
||||
<import file="${oss.build.dir}/build-cloud.xml" optional="false"/>
|
||||
<property name="usage.dir" location="${base.dir}/usage" />
|
||||
<property name="usage.dist.dir" location="${dist.dir}/usage" />
|
||||
|
||||
<!-- ===================== Usage.Jar ===================== -->
|
||||
<path id="usage.classpath">
|
||||
<path refid="thirdparty.classpath" />
|
||||
<path refid="dist.classpath" />
|
||||
</path>
|
||||
<target name="compile-usage" depends="-init, compile-utils, compile-core, compile-server" description="Compile the usage server">
|
||||
<compile-java jar.name="${usage.jar}" top.dir="${usage.dir}" classpath="usage.classpath" />
|
||||
</target>
|
||||
|
||||
<target name="build-usage" depends="build-all, compile-usage">
|
||||
<mkdir dir="${usage.dist.dir}/bin" />
|
||||
<mkdir dir="${usage.dist.dir}/conf" />
|
||||
|
||||
<copy todir="${usage.dist.dir}/bin">
|
||||
<fileset dir="${usage.dir}/scripts">
|
||||
<include name="usageserver.sh" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy overwrite="true" todir="${usage.dist.dir}/lib">
|
||||
<fileset dir="${jar.dir}">
|
||||
<include name="${usage.jar}" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="run-usage">
|
||||
<echo message="Run usage server ${usage.build.dir}/usage-runner" />
|
||||
<exec dir="${usage.build.dir}" executable="bash">
|
||||
<arg value="usage-runner" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
@ -1,5 +1,21 @@
|
||||
/**
|
||||
* * 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@ -1,5 +1,20 @@
|
||||
/**
|
||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@ -1,5 +1,21 @@
|
||||
/**
|
||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@ -1,5 +1,20 @@
|
||||
/**
|
||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@ -1,6 +1,19 @@
|
||||
/**
|
||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@ -1,16 +1,29 @@
|
||||
/**
|
||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.cloud.usage.parser;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@ -21,7 +34,7 @@ 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.Pair;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
|
||||
public class IPAddressUsageParser {
|
||||
@ -30,136 +43,136 @@ public class IPAddressUsageParser {
|
||||
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);
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
// - 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<UsageIPAddressVO> usageIPAddress = m_usageIPAddressDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate);
|
||||
|
||||
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<String, Pair<Long, Long>> usageMap = new HashMap<String, Pair<Long, Long>>();
|
||||
|
||||
Map<String, IpInfo> IPMap = new HashMap<String, IpInfo>();
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
updateIpUsageData(usageMap, key, usageIp.getId(), currentDuration);
|
||||
}
|
||||
|
||||
for (String ipIdKey : usageMap.keySet()) {
|
||||
Pair<Long, Long> 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());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void updateIpUsageData(Map<String, Pair<Long, Long>> usageDataMap, String key, long ipId, long duration) {
|
||||
Pair<Long, Long> ipUsageInfo = usageDataMap.get(key);
|
||||
if (ipUsageInfo == null) {
|
||||
ipUsageInfo = new Pair<Long, Long>(new Long(ipId), new Long(duration));
|
||||
} else {
|
||||
Long runningTime = ipUsageInfo.second();
|
||||
runningTime = new Long(runningTime.longValue() + duration);
|
||||
ipUsageInfo = new Pair<Long, Long>(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) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Total usage time " + runningTime + "ms");
|
||||
}
|
||||
|
||||
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":""));
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
// - 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<UsageIPAddressVO> usageIPAddress = m_usageIPAddressDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate);
|
||||
|
||||
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<String, Pair<Long, Long>> usageMap = new HashMap<String, Pair<Long, Long>>();
|
||||
|
||||
Map<String, IpInfo> IPMap = new HashMap<String, IpInfo>();
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
updateIpUsageData(usageMap, key, usageIp.getId(), currentDuration);
|
||||
}
|
||||
|
||||
for (String ipIdKey : usageMap.keySet()) {
|
||||
Pair<Long, Long> 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());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void updateIpUsageData(Map<String, Pair<Long, Long>> usageDataMap, String key, long ipId, long duration) {
|
||||
Pair<Long, Long> ipUsageInfo = usageDataMap.get(key);
|
||||
if (ipUsageInfo == null) {
|
||||
ipUsageInfo = new Pair<Long, Long>(new Long(ipId), new Long(duration));
|
||||
} else {
|
||||
Long runningTime = ipUsageInfo.second();
|
||||
runningTime = new Long(runningTime.longValue() + duration);
|
||||
ipUsageInfo = new Pair<Long, Long>(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) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Total usage time " + runningTime + "ms");
|
||||
}
|
||||
|
||||
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":""));
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,21 @@
|
||||
/**
|
||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.cloud.usage.parser;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
@ -1,8 +1,21 @@
|
||||
/**
|
||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.cloud.usage.parser;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
@ -1,8 +1,21 @@
|
||||
/**
|
||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.cloud.usage.parser;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ -1,8 +1,21 @@
|
||||
/**
|
||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.cloud.usage.parser;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
@ -1,8 +1,21 @@
|
||||
/**
|
||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.cloud.usage.parser;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
@ -61,7 +74,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;
|
||||
@ -127,14 +140,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:
|
||||
@ -158,14 +171,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;
|
||||
}
|
||||
@ -181,11 +194,11 @@ public class StorageUsageParser {
|
||||
public int getStorageType() {
|
||||
return storageType;
|
||||
}
|
||||
|
||||
public long getSourceId() {
|
||||
return sourceId;
|
||||
}
|
||||
|
||||
|
||||
public long getSourceId() {
|
||||
return sourceId;
|
||||
}
|
||||
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
|
||||
@ -1,8 +1,21 @@
|
||||
/**
|
||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.cloud.usage.parser;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ -1,8 +1,21 @@
|
||||
/**
|
||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.cloud.usage.parser;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
@ -1,8 +1,21 @@
|
||||
/**
|
||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.cloud.usage.parser;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user