You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2014/07/24 14:03:01 UTC
[1/5] git commit: updated refs/heads/master to 676b2d1
Repository: cloudstack
Updated Branches:
refs/heads/master da55aff64 -> 676b2d156
Fix CID 1114609 Log the correct number
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1440a1c6
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1440a1c6
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1440a1c6
Branch: refs/heads/master
Commit: 1440a1c6a062d562058d9421ec9b9ef66507d44c
Parents: ec43bfc
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Thu Jul 24 12:14:06 2014 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Thu Jul 24 12:21:37 2014 +0200
----------------------------------------------------------------------
.../deploy/DeploymentPlanningManagerImpl.java | 249 ++++++++++---------
1 file changed, 125 insertions(+), 124 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1440a1c6/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
index bb94b76..b5ff5b8 100644
--- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
+++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
@@ -31,6 +31,8 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
+import org.apache.log4j.Logger;
+
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
import org.apache.cloudstack.affinity.AffinityGroupService;
import org.apache.cloudstack.affinity.AffinityGroupVMMapVO;
@@ -49,7 +51,6 @@ import org.apache.cloudstack.managed.context.ManagedContextTimerTask;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.utils.identity.ManagementServerNode;
-import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.agent.Listener;
@@ -130,7 +131,7 @@ import com.cloud.vm.dao.VMInstanceDao;
@Local(value = {DeploymentPlanningManager.class})
public class DeploymentPlanningManagerImpl extends ManagerBase implements DeploymentPlanningManager, Manager, Listener,
- StateListener<State, VirtualMachine.Event, VirtualMachine> {
+StateListener<State, VirtualMachine.Event, VirtualMachine> {
private static final Logger s_logger = Logger.getLogger(DeploymentPlanningManagerImpl.class);
@Inject
@@ -276,14 +277,14 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
ServiceOffering offering = vmProfile.getServiceOffering();
if(planner == null){
- String plannerName = offering.getDeploymentPlanner();
- if (plannerName == null) {
- if (vm.getHypervisorType() == HypervisorType.BareMetal) {
- plannerName = "BareMetalPlanner";
- } else {
- plannerName = _configDao.getValue(Config.VmDeploymentPlanner.key());
+ String plannerName = offering.getDeploymentPlanner();
+ if (plannerName == null) {
+ if (vm.getHypervisorType() == HypervisorType.BareMetal) {
+ plannerName = "BareMetalPlanner";
+ } else {
+ plannerName = _configDao.getValue(Config.VmDeploymentPlanner.key());
+ }
}
- }
planner = getDeploymentPlannerByName(plannerName);
}
@@ -294,7 +295,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
s_logger.debug("DeploymentPlanner allocation algorithm: " + planner);
s_logger.debug("Trying to allocate a host and storage pools from dc:" + plan.getDataCenterId() + ", pod:" + plan.getPodId() + ",cluster:" +
- plan.getClusterId() + ", requested cpu: " + cpu_requested + ", requested ram: " + ram_requested);
+ plan.getClusterId() + ", requested cpu: " + cpu_requested + ", requested ram: " + ram_requested);
s_logger.debug("Is ROOT volume READY (pool already allocated)?: " + (plan.getPoolId() != null ? "Yes" : "No"));
}
@@ -314,13 +315,13 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
} else {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Looking for suitable pools for this host under zone: " + host.getDataCenterId() + ", pod: " + host.getPodId() + ", cluster: " +
- host.getClusterId());
+ host.getClusterId());
}
// search for storage under the zone, pod, cluster of the host.
DataCenterDeployment lastPlan =
- new DataCenterDeployment(host.getDataCenterId(), host.getPodId(), host.getClusterId(), hostIdSpecified, plan.getPoolId(), null,
- plan.getReservationContext());
+ new DataCenterDeployment(host.getDataCenterId(), host.getPodId(), host.getClusterId(), hostIdSpecified, plan.getPoolId(), null,
+ plan.getReservationContext());
Pair<Map<Volume, List<StoragePool>>, List<Volume>> result = findSuitablePoolsForVolumes(vmProfile, lastPlan, avoids, HostAllocator.RETURN_UPTO_ALL);
Map<Volume, List<StoragePool>> suitableVolumeStoragePools = result.first();
@@ -331,8 +332,8 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
List<Host> suitableHosts = new ArrayList<Host>();
suitableHosts.add(host);
Pair<Host, Map<Volume, StoragePool>> potentialResources = findPotentialDeploymentResources(
- suitableHosts, suitableVolumeStoragePools, avoids,
- getPlannerUsage(planner, vmProfile, plan, avoids), readyAndReusedVolumes);
+ suitableHosts, suitableVolumeStoragePools, avoids,
+ getPlannerUsage(planner, vmProfile, plan, avoids), readyAndReusedVolumes);
if (potentialResources != null) {
Pod pod = _podDao.findById(host.getPodId());
Cluster cluster = _clusterDao.findById(host.getClusterId());
@@ -363,7 +364,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
s_logger.debug("The last host of this VM is in avoid set");
} else if (_capacityMgr.checkIfHostReachMaxGuestLimit(host)) {
s_logger.debug("The last Host, hostId: " + host.getId() +
- " already has max Running VMs(count includes system VMs), skipping this and trying other available hosts");
+ " already has max Running VMs(count includes system VMs), skipping this and trying other available hosts");
} else if ((offeringDetails = _serviceOfferingDetailsDao.findDetail(offering.getId(), GPU.Keys.vgpuType.toString())) != null) {
ServiceOfferingDetailsVO groupName = _serviceOfferingDetailsDao.findDetail(offering.getId(), GPU.Keys.pciDevice.toString());
if(!_resourceMgr.isGPUDeviceAvailable(host.getId(), groupName.getValue(), offeringDetails.getValue())){
@@ -379,64 +380,64 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
}
}
if (hostTagsMatch) {
- long cluster_id = host.getClusterId();
+ long cluster_id = host.getClusterId();
ClusterDetailsVO cluster_detail_cpu = _clusterDetailsDao.findDetail(cluster_id,
"cpuOvercommitRatio");
ClusterDetailsVO cluster_detail_ram = _clusterDetailsDao.findDetail(cluster_id,
"memoryOvercommitRatio");
- Float cpuOvercommitRatio = Float.parseFloat(cluster_detail_cpu.getValue());
- Float memoryOvercommitRatio = Float.parseFloat(cluster_detail_ram.getValue());
+ Float cpuOvercommitRatio = Float.parseFloat(cluster_detail_cpu.getValue());
+ Float memoryOvercommitRatio = Float.parseFloat(cluster_detail_ram.getValue());
if (_capacityMgr.checkIfHostHasCapacity(host.getId(), cpu_requested, ram_requested, true,
cpuOvercommitRatio, memoryOvercommitRatio, true)
&& _capacityMgr.checkIfHostHasCpuCapability(host.getId(), offering.getCpu(),
offering.getSpeed())) {
- s_logger.debug("The last host of this VM is UP and has enough capacity");
+ s_logger.debug("The last host of this VM is UP and has enough capacity");
s_logger.debug("Now checking for suitable pools under zone: " + host.getDataCenterId()
+ ", pod: " + host.getPodId() + ", cluster: " + host.getClusterId());
// search for storage under the zone, pod, cluster
// of
- // the last host.
+ // the last host.
DataCenterDeployment lastPlan = new DataCenterDeployment(host.getDataCenterId(),
host.getPodId(), host.getClusterId(), host.getId(), plan.getPoolId(), null);
Pair<Map<Volume, List<StoragePool>>, List<Volume>> result = findSuitablePoolsForVolumes(
vmProfile, lastPlan, avoids, HostAllocator.RETURN_UPTO_ALL);
- Map<Volume, List<StoragePool>> suitableVolumeStoragePools = result.first();
- List<Volume> readyAndReusedVolumes = result.second();
+ Map<Volume, List<StoragePool>> suitableVolumeStoragePools = result.first();
+ List<Volume> readyAndReusedVolumes = result.second();
// choose the potential pool for this VM for this
// host
- if (!suitableVolumeStoragePools.isEmpty()) {
- List<Host> suitableHosts = new ArrayList<Host>();
- suitableHosts.add(host);
- Pair<Host, Map<Volume, StoragePool>> potentialResources = findPotentialDeploymentResources(
- suitableHosts, suitableVolumeStoragePools, avoids,
- getPlannerUsage(planner, vmProfile, plan, avoids), readyAndReusedVolumes);
- if (potentialResources != null) {
- Pod pod = _podDao.findById(host.getPodId());
- Cluster cluster = _clusterDao.findById(host.getClusterId());
- Map<Volume, StoragePool> storageVolMap = potentialResources.second();
- // remove the reused vol<->pool from
+ if (!suitableVolumeStoragePools.isEmpty()) {
+ List<Host> suitableHosts = new ArrayList<Host>();
+ suitableHosts.add(host);
+ Pair<Host, Map<Volume, StoragePool>> potentialResources = findPotentialDeploymentResources(
+ suitableHosts, suitableVolumeStoragePools, avoids,
+ getPlannerUsage(planner, vmProfile, plan, avoids), readyAndReusedVolumes);
+ if (potentialResources != null) {
+ Pod pod = _podDao.findById(host.getPodId());
+ Cluster cluster = _clusterDao.findById(host.getClusterId());
+ Map<Volume, StoragePool> storageVolMap = potentialResources.second();
+ // remove the reused vol<->pool from
// destination, since we don't have to
// prepare
- // this volume.
- for (Volume vol : readyAndReusedVolumes) {
- storageVolMap.remove(vol);
- }
+ // this volume.
+ for (Volume vol : readyAndReusedVolumes) {
+ storageVolMap.remove(vol);
+ }
DeployDestination dest = new DeployDestination(dc, pod, cluster, host,
storageVolMap);
- s_logger.debug("Returning Deployment Destination: " + dest);
- return dest;
+ s_logger.debug("Returning Deployment Destination: " + dest);
+ return dest;
+ }
}
+ } else {
+ s_logger.debug("The last host of this VM does not have enough capacity");
}
} else {
- s_logger.debug("The last host of this VM does not have enough capacity");
- }
- } else {
s_logger.debug("Service Offering host tag does not match the last host of this VM");
}
} else {
s_logger.debug("The last host of this VM is not UP or is not enabled, host status is: " + host.getStatus().name() + ", host resource state is: " +
- host.getResourceState());
+ host.getResourceState());
}
}
s_logger.debug("Cannot choose the last host to deploy this VM ");
@@ -450,21 +451,21 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
if (planner instanceof DeploymentClusterPlanner) {
ExcludeList plannerAvoidInput =
- new ExcludeList(avoids.getDataCentersToAvoid(), avoids.getPodsToAvoid(), avoids.getClustersToAvoid(), avoids.getHostsToAvoid(),
- avoids.getPoolsToAvoid());
+ new ExcludeList(avoids.getDataCentersToAvoid(), avoids.getPodsToAvoid(), avoids.getClustersToAvoid(), avoids.getHostsToAvoid(),
+ avoids.getPoolsToAvoid());
clusterList = ((DeploymentClusterPlanner)planner).orderClusters(vmProfile, plan, avoids);
if (clusterList != null && !clusterList.isEmpty()) {
// planner refactoring. call allocators to list hosts
ExcludeList plannerAvoidOutput =
- new ExcludeList(avoids.getDataCentersToAvoid(), avoids.getPodsToAvoid(), avoids.getClustersToAvoid(), avoids.getHostsToAvoid(),
- avoids.getPoolsToAvoid());
+ new ExcludeList(avoids.getDataCentersToAvoid(), avoids.getPodsToAvoid(), avoids.getClustersToAvoid(), avoids.getHostsToAvoid(),
+ avoids.getPoolsToAvoid());
resetAvoidSet(plannerAvoidOutput, plannerAvoidInput);
dest =
- checkClustersforDestination(clusterList, vmProfile, plan, avoids, dc, getPlannerUsage(planner, vmProfile, plan, avoids), plannerAvoidOutput);
+ checkClustersforDestination(clusterList, vmProfile, plan, avoids, dc, getPlannerUsage(planner, vmProfile, plan, avoids), plannerAvoidOutput);
if (dest != null) {
return dest;
}
@@ -591,7 +592,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
}
private PlannerResourceUsage getPlannerUsage(DeploymentPlanner planner, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoids)
- throws InsufficientServerCapacityException {
+ throws InsufficientServerCapacityException {
if (planner != null && planner instanceof DeploymentClusterPlanner) {
return ((DeploymentClusterPlanner)planner).getResourceUsage(vmProfile, plan, avoids);
} else {
@@ -619,7 +620,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
return true;
} else {
s_logger.debug("Cannot use this host for usage: " + resourceUsageRequired + ", since this host has been reserved for planner usage : " +
- hostResourceType);
+ hostResourceType);
return false;
}
} else {
@@ -629,27 +630,27 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
return Transaction.execute(new TransactionCallback<Boolean>() {
@Override
public Boolean doInTransaction(TransactionStatus status) {
- final PlannerHostReservationVO lockedEntry = _plannerHostReserveDao.lockRow(id, true);
- if (lockedEntry == null) {
- s_logger.error("Unable to lock the host entry for reservation, host: " + hostId);
- return false;
- }
- // check before updating
- if (lockedEntry.getResourceUsage() == null) {
- lockedEntry.setResourceUsage(resourceUsageRequired);
- _plannerHostReserveDao.persist(lockedEntry);
- return true;
- } else {
- // someone updated it earlier. check if we can still use it
- if (lockedEntry.getResourceUsage() == resourceUsageRequired) {
+ final PlannerHostReservationVO lockedEntry = _plannerHostReserveDao.lockRow(id, true);
+ if (lockedEntry == null) {
+ s_logger.error("Unable to lock the host entry for reservation, host: " + hostId);
+ return false;
+ }
+ // check before updating
+ if (lockedEntry.getResourceUsage() == null) {
+ lockedEntry.setResourceUsage(resourceUsageRequired);
+ _plannerHostReserveDao.persist(lockedEntry);
return true;
} else {
+ // someone updated it earlier. check if we can still use it
+ if (lockedEntry.getResourceUsage() == resourceUsageRequired) {
+ return true;
+ } else {
s_logger.debug("Cannot use this host for usage: " + resourceUsageRequired + ", since this host has been reserved for planner usage : " +
- hostResourceTypeFinal);
- return false;
+ hostResourceTypeFinal);
+ return false;
+ }
}
}
- }
});
}
@@ -695,7 +696,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
List<VMInstanceVO> vmsStoppingMigratingByHostId = _vmInstanceDao.findByHostInStates(hostId, State.Stopping, State.Migrating, State.Starting);
if (vmsStoppingMigratingByHostId.size() > 0) {
if (s_logger.isDebugEnabled()) {
- s_logger.debug("Cannot release reservation, Found " + vms.size() + " VMs stopping/migrating on host " + hostId);
+ s_logger.debug("Cannot release reservation, Found " + vmsStoppingMigratingByHostId.size() + " VMs stopping/migrating/starting on host " + hostId);
}
return false;
}
@@ -721,20 +722,20 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
return Transaction.execute(new TransactionCallback<Boolean>() {
@Override
public Boolean doInTransaction(TransactionStatus status) {
- final PlannerHostReservationVO lockedEntry = _plannerHostReserveDao.lockRow(id, true);
- if (lockedEntry == null) {
- s_logger.error("Unable to lock the host entry for reservation, host: " + hostId);
- return false;
- }
- // check before updating
- if (lockedEntry.getResourceUsage() != null) {
- lockedEntry.setResourceUsage(null);
- _plannerHostReserveDao.persist(lockedEntry);
- return true;
- }
+ final PlannerHostReservationVO lockedEntry = _plannerHostReserveDao.lockRow(id, true);
+ if (lockedEntry == null) {
+ s_logger.error("Unable to lock the host entry for reservation, host: " + hostId);
+ return false;
+ }
+ // check before updating
+ if (lockedEntry.getResourceUsage() != null) {
+ lockedEntry.setResourceUsage(null);
+ _plannerHostReserveDao.persist(lockedEntry);
+ return true;
+ }
return false;
- }
+ }
});
}
@@ -833,7 +834,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
public void onPublishMessage(String senderAddress, String subject, Object obj) {
VMInstanceVO vm = ((VMInstanceVO)obj);
s_logger.debug("MessageBus message: host reserved capacity released for VM: " + vm.getLastHostId() +
- ", checking if host reservation can be released for host:" + vm.getLastHostId());
+ ", checking if host reservation can be released for host:" + vm.getLastHostId());
Long hostId = vm.getLastHostId();
checkHostReservationRelease(hostId);
}
@@ -890,7 +891,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
// /refactoring planner methods
private DeployDestination checkClustersforDestination(List<Long> clusterList, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, DataCenter dc,
- DeploymentPlanner.PlannerResourceUsage resourceUsageRequired, ExcludeList plannerAvoidOutput) {
+ DeploymentPlanner.PlannerResourceUsage resourceUsageRequired, ExcludeList plannerAvoidOutput) {
if (s_logger.isTraceEnabled()) {
s_logger.trace("ClusterId List to consider: " + clusterList);
@@ -909,7 +910,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
// search for resources(hosts and storage) under this zone, pod,
// cluster.
DataCenterDeployment potentialPlan =
- new DataCenterDeployment(plan.getDataCenterId(), clusterVO.getPodId(), clusterVO.getId(), null, plan.getPoolId(), null, plan.getReservationContext());
+ new DataCenterDeployment(plan.getDataCenterId(), clusterVO.getPodId(), clusterVO.getId(), null, plan.getPoolId(), null, plan.getReservationContext());
// find suitable hosts under this cluster, need as many hosts as we
// get.
@@ -924,15 +925,15 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
}
Pair<Map<Volume, List<StoragePool>>, List<Volume>> result =
- findSuitablePoolsForVolumes(vmProfile, potentialPlan, avoid, StoragePoolAllocator.RETURN_UPTO_ALL);
+ findSuitablePoolsForVolumes(vmProfile, potentialPlan, avoid, StoragePoolAllocator.RETURN_UPTO_ALL);
Map<Volume, List<StoragePool>> suitableVolumeStoragePools = result.first();
List<Volume> readyAndReusedVolumes = result.second();
// choose the potential host and pool for the VM
if (!suitableVolumeStoragePools.isEmpty()) {
Pair<Host, Map<Volume, StoragePool>> potentialResources = findPotentialDeploymentResources(
- suitableHosts, suitableVolumeStoragePools, avoid, resourceUsageRequired,
- readyAndReusedVolumes);
+ suitableHosts, suitableVolumeStoragePools, avoid, resourceUsageRequired,
+ readyAndReusedVolumes);
if (potentialResources != null) {
Pod pod = _podDao.findById(clusterVO.getPodId());
@@ -965,7 +966,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
private boolean canAvoidCluster(Cluster clusterVO, ExcludeList avoids, ExcludeList plannerAvoidOutput, VirtualMachineProfile vmProfile) {
ExcludeList allocatorAvoidOutput =
- new ExcludeList(avoids.getDataCentersToAvoid(), avoids.getPodsToAvoid(), avoids.getClustersToAvoid(), avoids.getHostsToAvoid(), avoids.getPoolsToAvoid());
+ new ExcludeList(avoids.getDataCentersToAvoid(), avoids.getPodsToAvoid(), avoids.getClustersToAvoid(), avoids.getHostsToAvoid(), avoids.getPoolsToAvoid());
// remove any hosts/pools that the planners might have added
// to get the list of hosts/pools that Allocators flagged as 'avoid'
@@ -977,7 +978,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
boolean avoidAllHosts = true, avoidAllPools = true;
List<HostVO> allhostsInCluster =
- _hostDao.listAllUpAndEnabledNonHAHosts(Host.Type.Routing, clusterVO.getId(), clusterVO.getPodId(), clusterVO.getDataCenterId(), null);
+ _hostDao.listAllUpAndEnabledNonHAHosts(Host.Type.Routing, clusterVO.getId(), clusterVO.getPodId(), clusterVO.getDataCenterId(), null);
for (HostVO host : allhostsInCluster) {
if (!allocatorAvoidOutput.shouldAvoid(host)) {
// there's some host in the cluster that is not yet in avoid set
@@ -1003,21 +1004,21 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
boolean vmRequiresLocalStorege = storageRequirements.second();
if (vmRequiresSharedStorage) {
- // check shared pools
+ // check shared pools
List<StoragePoolVO> allPoolsInCluster = _storagePoolDao.findPoolsByTags(clusterVO.getDataCenterId(), clusterVO.getPodId(), clusterVO.getId(), null);
- for (StoragePoolVO pool : allPoolsInCluster) {
- if (!allocatorAvoidOutput.shouldAvoid(pool)) {
- // there's some pool in the cluster that is not yet in avoid set
- avoidAllPools = false;
- break;
+ for (StoragePoolVO pool : allPoolsInCluster) {
+ if (!allocatorAvoidOutput.shouldAvoid(pool)) {
+ // there's some pool in the cluster that is not yet in avoid set
+ avoidAllPools = false;
+ break;
+ }
}
}
- }
if (vmRequiresLocalStorege) {
// check local pools
List<StoragePoolVO> allLocalPoolsInCluster =
- _storagePoolDao.findLocalStoragePoolsByTags(clusterVO.getDataCenterId(), clusterVO.getPodId(), clusterVO.getId(), null);
+ _storagePoolDao.findLocalStoragePoolsByTags(clusterVO.getDataCenterId(), clusterVO.getPodId(), clusterVO.getId(), null);
for (StoragePoolVO pool : allLocalPoolsInCluster) {
if (!allocatorAvoidOutput.shouldAvoid(pool)) {
// there's some pool in the cluster that is not yet
@@ -1058,7 +1059,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
}
protected Pair<Host, Map<Volume, StoragePool>> findPotentialDeploymentResources(List<Host> suitableHosts, Map<Volume, List<StoragePool>> suitableVolumeStoragePools,
- ExcludeList avoid, DeploymentPlanner.PlannerResourceUsage resourceUsageRequired, List<Volume> readyAndReusedVolumes) {
+ ExcludeList avoid, DeploymentPlanner.PlannerResourceUsage resourceUsageRequired, List<Volume> readyAndReusedVolumes) {
s_logger.debug("Trying to find a potenial host and associated storage pools from the suitable host/pool lists for this VM");
boolean hostCanAccessPool = false;
@@ -1116,7 +1117,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
}
if (hostCanAccessPool && haveEnoughSpace && checkIfHostFitsPlannerUsage(potentialHost.getId(), resourceUsageRequired)) {
s_logger.debug("Found a potential host " + "id: " + potentialHost.getId() + " name: " + potentialHost.getName() +
- " and associated storage pools for this VM");
+ " and associated storage pools for this VM");
return new Pair<Host, Map<Volume, StoragePool>>(potentialHost, storage);
} else {
avoid.addHost(potentialHost.getId());
@@ -1382,43 +1383,43 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
return Transaction.execute(new TransactionCallback<String>() {
@Override
public String doInTransaction(TransactionStatus status) {
- boolean saveReservation = true;
-
- if (vmGroupCount > 0) {
- List<Long> groupIds = _affinityGroupVMMapDao.listAffinityGroupIdsByVmId(vm.getId());
- SearchCriteria<AffinityGroupVO> criteria = _affinityGroupDao.createSearchCriteria();
- criteria.addAnd("id", SearchCriteria.Op.IN, groupIds.toArray(new Object[groupIds.size()]));
- List<AffinityGroupVO> groups = _affinityGroupDao.lockRows(criteria, null, true);
-
- for (AffinityGroupProcessor processor : _affinityProcessors) {
- if (!processor.check(vmProfile, plannedDestination)) {
- saveReservation = false;
- break;
+ boolean saveReservation = true;
+
+ if (vmGroupCount > 0) {
+ List<Long> groupIds = _affinityGroupVMMapDao.listAffinityGroupIdsByVmId(vm.getId());
+ SearchCriteria<AffinityGroupVO> criteria = _affinityGroupDao.createSearchCriteria();
+ criteria.addAnd("id", SearchCriteria.Op.IN, groupIds.toArray(new Object[groupIds.size()]));
+ _affinityGroupDao.lockRows(criteria, null, true);
+
+ for (AffinityGroupProcessor processor : _affinityProcessors) {
+ if (!processor.check(vmProfile, plannedDestination)) {
+ saveReservation = false;
+ break;
+ }
}
}
- }
- if (saveReservation) {
+ if (saveReservation) {
VMReservationVO vmReservation =
- new VMReservationVO(vm.getId(), plannedDestination.getDataCenter().getId(), plannedDestination.getPod().getId(), plannedDestination.getCluster()
- .getId(), plannedDestination.getHost().getId());
+ new VMReservationVO(vm.getId(), plannedDestination.getDataCenter().getId(), plannedDestination.getPod().getId(), plannedDestination.getCluster()
+ .getId(), plannedDestination.getHost().getId());
if (planner != null) {
vmReservation.setDeploymentPlanner(planner.getName());
}
- Map<Long, Long> volumeReservationMap = new HashMap<Long, Long>();
+ Map<Long, Long> volumeReservationMap = new HashMap<Long, Long>();
- if (vm.getHypervisorType() != HypervisorType.BareMetal) {
- for (Volume vo : plannedDestination.getStorageForDisks().keySet()) {
- volumeReservationMap.put(vo.getId(), plannedDestination.getStorageForDisks().get(vo).getId());
+ if (vm.getHypervisorType() != HypervisorType.BareMetal) {
+ for (Volume vo : plannedDestination.getStorageForDisks().keySet()) {
+ volumeReservationMap.put(vo.getId(), plannedDestination.getStorageForDisks().get(vo).getId());
+ }
+ vmReservation.setVolumeReservation(volumeReservationMap);
}
- vmReservation.setVolumeReservation(volumeReservationMap);
+ _reservationDao.persist(vmReservation);
+ return vmReservation.getUuid();
}
- _reservationDao.persist(vmReservation);
- return vmReservation.getUuid();
- }
- return null;
- }
+ return null;
+ }
});
}
[2/5] git commit: updated refs/heads/master to 676b2d1
Posted by hu...@apache.org.
Fix false positve in coverity, simple rewrite.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ec43bfce
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ec43bfce
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ec43bfce
Branch: refs/heads/master
Commit: ec43bfce90912cf9dc33a97b8a563eb567db222d
Parents: f275f29
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Thu Jul 24 12:10:49 2014 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Thu Jul 24 12:21:37 2014 +0200
----------------------------------------------------------------------
.../CloudStackPrimaryDataStoreDriverImpl.java | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ec43bfce/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
index 5983a05..4115289 100644
--- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
+++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
@@ -24,6 +24,8 @@ import java.util.UUID;
import javax.inject.Inject;
+import org.apache.log4j.Logger;
+
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
@@ -49,7 +51,6 @@ import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
import org.apache.cloudstack.storage.to.TemplateObjectTO;
import org.apache.cloudstack.storage.volume.VolumeObject;
-import org.apache.log4j.Logger;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.storage.ResizeVolumeAnswer;
@@ -258,13 +259,11 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
public boolean canCopy(DataObject srcData, DataObject destData) {
//BUG fix for CLOUDSTACK-4618
DataStore store = destData.getDataStore();
- if (store.getRole() == DataStoreRole.Primary) {
- if ((srcData.getType() == DataObjectType.TEMPLATE && destData.getType() == DataObjectType.TEMPLATE) ||
- (srcData.getType() == DataObjectType.TEMPLATE && destData.getType() == DataObjectType.VOLUME)) {
- StoragePoolVO storagePoolVO = primaryStoreDao.findById(store.getId());
- if (storagePoolVO != null && storagePoolVO.getPoolType() == Storage.StoragePoolType.CLVM) {
- return true;
- }
+ if (store.getRole() == DataStoreRole.Primary && srcData.getType() == DataObjectType.TEMPLATE
+ && (destData.getType() == DataObjectType.TEMPLATE || destData.getType() == DataObjectType.VOLUME)) {
+ StoragePoolVO storagePoolVO = primaryStoreDao.findById(store.getId());
+ if (storagePoolVO != null && storagePoolVO.getPoolType() == Storage.StoragePoolType.CLVM) {
+ return true;
}
}
return false;
@@ -282,7 +281,7 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
}
CreateObjectCommand cmd = new CreateObjectCommand(snapshotTO);
- EndPoint ep = this.epSelector.select(snapshot, StorageAction.TAKESNAPSHOT);
+ EndPoint ep = epSelector.select(snapshot, StorageAction.TAKESNAPSHOT);
Answer answer = null;
if (ep == null) {
[4/5] git commit: updated refs/heads/master to 676b2d1
Posted by hu...@apache.org.
Fix CID 1114611 Check the right variable
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/885e08d4
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/885e08d4
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/885e08d4
Branch: refs/heads/master
Commit: 885e08d47696a237d410ed7e998b92b5b8fae9e2
Parents: 1440a1c
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Thu Jul 24 12:20:34 2014 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Thu Jul 24 12:21:38 2014 +0200
----------------------------------------------------------------------
.../cloudstack/storage/resource/NfsSecondaryStorageResource.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/885e08d4/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
index 78f4bf1..b536804 100755
--- a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
+++ b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
@@ -1920,7 +1920,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
}
_configAuthScr = Script.findScript(getDefaultScriptsDir(), "config_auth.sh");
- if (_configSslScr != null) {
+ if (_configAuthScr != null) {
s_logger.info("config_auth.sh found in " + _configAuthScr);
}
[5/5] git commit: updated refs/heads/master to 676b2d1
Posted by hu...@apache.org.
Fix overflow before widening issues reported by Coverity
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/676b2d15
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/676b2d15
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/676b2d15
Branch: refs/heads/master
Commit: 676b2d15692b105f12eecaf22a4f3944257a7674
Parents: 885e08d
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Thu Jul 24 13:22:14 2014 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Thu Jul 24 13:22:14 2014 +0200
----------------------------------------------------------------------
.../vm/VirtualMachinePowerStateSyncImpl.java | 2 +-
usage/src/com/cloud/usage/UsageManagerImpl.java | 107 +++++++++----------
2 files changed, 53 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/676b2d15/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
index 9edecac..d3dcdec 100644
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
@@ -107,7 +107,7 @@ public class VirtualMachinePowerStateSyncImpl implements VirtualMachinePowerStat
s_logger.debug("Run missing VM report. current time: " + currentTime.getTime());
// 2 times of sync-update interval for graceful period
- long milliSecondsGracefullPeriod = PingInterval.value() * 2000;
+ long milliSecondsGracefullPeriod = PingInterval.value() * 2000L;
for (VMInstanceVO instance : vmsThatAreMissingReport) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/676b2d15/usage/src/com/cloud/usage/UsageManagerImpl.java
----------------------------------------------------------------------
diff --git a/usage/src/com/cloud/usage/UsageManagerImpl.java b/usage/src/com/cloud/usage/UsageManagerImpl.java
index 159380b..fe7ee1e 100644
--- a/usage/src/com/cloud/usage/UsageManagerImpl.java
+++ b/usage/src/com/cloud/usage/UsageManagerImpl.java
@@ -43,8 +43,8 @@ import org.apache.cloudstack.usage.UsageTypes;
import com.cloud.alert.AlertManager;
import com.cloud.event.EventTypes;
-import com.cloud.event.UsageEventVO;
import com.cloud.event.UsageEventDetailsVO;
+import com.cloud.event.UsageEventVO;
import com.cloud.event.dao.UsageEventDao;
import com.cloud.event.dao.UsageEventDetailsDao;
import com.cloud.usage.dao.UsageDao;
@@ -214,9 +214,9 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
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);
+ aggregationRange);
throw new ConfigurationException("Missing configuration values for usage job, usage.stats.job.exec.time = " + execTime +
- ", usage.stats.job.aggregation.range = " + aggregationRange);
+ ", usage.stats.job.aggregation.range = " + aggregationRange);
}
String[] execTimeSegments = execTime.split(":");
if (execTimeSegments.length != 2) {
@@ -253,7 +253,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
_hostname = InetAddress.getLocalHost().getHostName() + "/" + InetAddress.getLocalHost().getHostAddress();
} catch (NumberFormatException ex) {
throw new ConfigurationException("Unable to parse usage.stats.job.exec.time '" + execTime + "' or usage.stats.job.aggregation.range '" + aggregationRange +
- "', please check configuration values");
+ "', please check configuration values");
} catch (Exception e) {
s_logger.error("Unhandled exception configuring UsageManger", e);
throw new ConfigurationException("Unhandled exception configuring UsageManager " + e.toString());
@@ -270,11 +270,11 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
// use the configured exec time and aggregation duration for scheduling the job
_scheduledFuture =
- _executor.scheduleAtFixedRate(this, _jobExecTime.getTimeInMillis() - System.currentTimeMillis(), _aggregationDuration * 60 * 1000, TimeUnit.MILLISECONDS);
+ _executor.scheduleAtFixedRate(this, _jobExecTime.getTimeInMillis() - System.currentTimeMillis(), _aggregationDuration * 60 * 1000, TimeUnit.MILLISECONDS);
_heartbeat =
- _heartbeatExecutor.scheduleAtFixedRate(new Heartbeat(), /* start in 15 seconds...*/15 * 1000, /* check database every minute*/60 * 1000,
- TimeUnit.MILLISECONDS);
+ _heartbeatExecutor.scheduleAtFixedRate(new Heartbeat(), /* start in 15 seconds...*/15 * 1000, /* check database every minute*/60 * 1000,
+ TimeUnit.MILLISECONDS);
if (_sanityCheckInterval > 0) {
_sanity = _sanityExecutor.scheduleAtFixedRate(new SanityCheck(), 1, _sanityCheckInterval, TimeUnit.DAYS);
@@ -400,7 +400,6 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
boolean success = false;
long timeStart = System.currentTimeMillis();
- long deleteOldStatsTimeMillis = 0L;
try {
if ((endDateMillis == 0) || (endDateMillis > timeStart)) {
endDateMillis = timeStart;
@@ -433,8 +432,6 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
return;
}
- deleteOldStatsTimeMillis = startDateMillis;
-
Date startDate = new Date(startDateMillis);
Date endDate = new Date(endDateMillis);
if (s_logger.isInfoEnabled()) {
@@ -631,8 +628,8 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
UserStatisticsVO hostAggregatedStat = aggregatedStats.get(hostKey);
if (hostAggregatedStat == null) {
hostAggregatedStat =
- new UserStatisticsVO(userStat.getAccountId(), userStat.getDataCenterId(), userStat.getPublicIpAddress(), userStat.getDeviceId(),
- userStat.getDeviceType(), userStat.getNetworkId());
+ new UserStatisticsVO(userStat.getAccountId(), userStat.getDataCenterId(), userStat.getPublicIpAddress(), userStat.getDeviceId(),
+ userStat.getDeviceType(), userStat.getNetworkId());
}
hostAggregatedStat.setAggBytesSent(hostAggregatedStat.getAggBytesSent() + userStat.getAggBytesSent());
@@ -675,11 +672,11 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
for (VmDiskStatisticsVO vmDiskStat : vmDiskStats) {
if (vmDiskStat.getVmId() != null) {
String hostKey =
- vmDiskStat.getDataCenterId() + "-" + vmDiskStat.getAccountId() + "-Vm-" + vmDiskStat.getVmId() + "-Disk-" + vmDiskStat.getVolumeId();
+ vmDiskStat.getDataCenterId() + "-" + vmDiskStat.getAccountId() + "-Vm-" + vmDiskStat.getVmId() + "-Disk-" + vmDiskStat.getVolumeId();
VmDiskStatisticsVO hostAggregatedStat = aggregatedDiskStats.get(hostKey);
if (hostAggregatedStat == null) {
hostAggregatedStat =
- new VmDiskStatisticsVO(vmDiskStat.getAccountId(), vmDiskStat.getDataCenterId(), vmDiskStat.getVmId(), vmDiskStat.getVolumeId());
+ new VmDiskStatisticsVO(vmDiskStat.getAccountId(), vmDiskStat.getDataCenterId(), vmDiskStat.getVmId(), vmDiskStat.getVolumeId());
}
hostAggregatedStat.setAggIORead(hostAggregatedStat.getAggIORead() + vmDiskStat.getAggIORead());
@@ -769,7 +766,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
List<UsageStorageVO> storageVOs = _usageStorageDao.listById(account.getId(), templateId, StorageTypes.TEMPLATE);
if (storageVOs.size() > 1) {
s_logger.warn("More that one usage entry for storage: " + templateId + " assigned to account: " + account.getId() +
- "; marking them all as deleted...");
+ "; marking them all as deleted...");
}
for (UsageStorageVO storageVO : storageVOs) {
if (s_logger.isDebugEnabled()) {
@@ -820,7 +817,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
TransactionLegacy swap = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
if (!success) {
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USAGE_SERVER_RESULT, 0, new Long(0), "Usage job failed. Job id: " + job.getId(),
- "Usage job failed. Job id: " + job.getId());
+ "Usage job failed. Job id: " + job.getId());
} else {
_alertMgr.clearAlert(AlertManager.AlertType.ALERT_TYPE_USAGE_SERVER_RESULT, 0, 0);
}
@@ -962,7 +959,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
private boolean isVolumeEvent(String eventType) {
return eventType != null &&
- (eventType.equals(EventTypes.EVENT_VOLUME_CREATE) || eventType.equals(EventTypes.EVENT_VOLUME_DELETE) || eventType.equals(EventTypes.EVENT_VOLUME_RESIZE));
+ (eventType.equals(EventTypes.EVENT_VOLUME_CREATE) || eventType.equals(EventTypes.EVENT_VOLUME_DELETE) || eventType.equals(EventTypes.EVENT_VOLUME_RESIZE));
}
private boolean isTemplateEvent(String eventType) {
@@ -999,7 +996,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
if (eventType == null)
return false;
return (eventType.equals(EventTypes.EVENT_NETWORK_OFFERING_CREATE) || eventType.equals(EventTypes.EVENT_NETWORK_OFFERING_DELETE) ||
- eventType.equals(EventTypes.EVENT_NETWORK_OFFERING_ASSIGN) || eventType.equals(EventTypes.EVENT_NETWORK_OFFERING_REMOVE));
+ eventType.equals(EventTypes.EVENT_NETWORK_OFFERING_ASSIGN) || eventType.equals(EventTypes.EVENT_NETWORK_OFFERING_REMOVE));
}
private boolean isVPNUserEvent(String eventType) {
@@ -1076,8 +1073,8 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
// add this VM to the usage helper table
UsageVMInstanceVO usageInstanceNew =
- new UsageVMInstanceVO(UsageTypes.RUNNING_VM, zoneId, event.getAccountId(), vmId, vmName, soId, templateId, hypervisorType, event.getCreateDate(),
- null);
+ new UsageVMInstanceVO(UsageTypes.RUNNING_VM, zoneId, event.getAccountId(), vmId, vmName, soId, templateId, hypervisorType, event.getCreateDate(),
+ null);
populateDynamicComputeOfferingDetailsAndPersist(usageInstanceNew, event.getId());
} catch (Exception ex) {
s_logger.error("Error saving usage instance for vm: " + vmId, ex);
@@ -1108,7 +1105,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
// add this VM to the usage helper table
UsageVMInstanceVO usageInstanceNew = new UsageVMInstanceVO(UsageTypes.ALLOCATED_VM, zoneId, event.getAccountId(), vmId, vmName,
- soId, templateId, hypervisorType, event.getCreateDate(), null);
+ soId, templateId, hypervisorType, event.getCreateDate(), null);
populateDynamicComputeOfferingDetailsAndPersist(usageInstanceNew, event.getId());
} catch (Exception ex) {
s_logger.error("Error saving usage instance for vm: " + vmId, ex);
@@ -1148,7 +1145,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
String hypervisorType = event.getResourceType();
// add this VM to the usage helper table
UsageVMInstanceVO usageInstanceNew =
- new UsageVMInstanceVO(UsageTypes.ALLOCATED_VM, zoneId, event.getAccountId(), vmId, vmName, soId, templateId, hypervisorType, event.getCreateDate(), null);
+ new UsageVMInstanceVO(UsageTypes.ALLOCATED_VM, zoneId, event.getAccountId(), vmId, vmName, soId, templateId, hypervisorType, event.getCreateDate(), null);
populateDynamicComputeOfferingDetailsAndPersist(usageInstanceNew, event.getId());
} else if (EventTypes.EVENT_VM_DYNAMIC_SCALE.equals(event.getType())) {
// Ending the running vm event
@@ -1193,7 +1190,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
// add this VM to the usage helper table with new service offering Id
UsageVMInstanceVO usageInstanceNew =
- new UsageVMInstanceVO(UsageTypes.RUNNING_VM, zoneId, event.getAccountId(), vmId, vmName, soId, templateId, hypervisorType, event.getCreateDate(), null);
+ new UsageVMInstanceVO(UsageTypes.RUNNING_VM, zoneId, event.getAccountId(), vmId, vmName, soId, templateId, hypervisorType, event.getCreateDate(), null);
populateDynamicComputeOfferingDetailsAndPersist(usageInstanceNew, event.getId());
}
}
@@ -1230,7 +1227,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
if (usageNetworkStats != null) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("getting current accounted bytes for... accountId: " + usageNetworkStats.getAccountId() + " in zone: " + userStat.getDataCenterId() +
- "; abr: " + usageNetworkStats.getAggBytesReceived() + "; abs: " + usageNetworkStats.getAggBytesSent());
+ "; abr: " + usageNetworkStats.getAggBytesReceived() + "; abs: " + usageNetworkStats.getAggBytesSent());
}
currentAccountedBytesSent = usageNetworkStats.getAggBytesSent();
currentAccountedBytesReceived = usageNetworkStats.getAggBytesReceived();
@@ -1240,12 +1237,12 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
if (bytesSent < 0) {
s_logger.warn("Calculated negative value for bytes sent: " + bytesSent + ", user stats say: " + userStat.getAggBytesSent() +
- ", previous network usage was: " + currentAccountedBytesSent);
+ ", previous network usage was: " + currentAccountedBytesSent);
bytesSent = 0;
}
if (bytesReceived < 0) {
s_logger.warn("Calculated negative value for bytes received: " + bytesReceived + ", user stats say: " + userStat.getAggBytesReceived() +
- ", previous network usage was: " + currentAccountedBytesReceived);
+ ", previous network usage was: " + currentAccountedBytesReceived);
bytesReceived = 0;
}
@@ -1256,12 +1253,12 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
}
UsageNetworkVO usageNetworkVO =
- new UsageNetworkVO(userStat.getAccountId(), userStat.getDataCenterId(), hostId, userStat.getDeviceType(), userStat.getNetworkId(), bytesSent, bytesReceived,
- userStat.getAggBytesReceived(), userStat.getAggBytesSent(), timestamp);
+ new UsageNetworkVO(userStat.getAccountId(), userStat.getDataCenterId(), hostId, userStat.getDeviceType(), userStat.getNetworkId(), bytesSent, bytesReceived,
+ userStat.getAggBytesReceived(), userStat.getAggBytesSent(), timestamp);
if (s_logger.isDebugEnabled()) {
s_logger.debug("creating networkHelperEntry... accountId: " + userStat.getAccountId() + " in zone: " + userStat.getDataCenterId() + "; abr: " +
- userStat.getAggBytesReceived() + "; abs: " + userStat.getAggBytesSent() + "; curABS: " + currentAccountedBytesSent + "; curABR: " +
- currentAccountedBytesReceived + "; ubs: " + bytesSent + "; ubr: " + bytesReceived);
+ userStat.getAggBytesReceived() + "; abs: " + userStat.getAggBytesSent() + "; curABS: " + currentAccountedBytesSent + "; curABR: " +
+ currentAccountedBytesReceived + "; ubs: " + bytesSent + "; ubr: " + bytesReceived);
}
usageNetworks.add(usageNetworkVO);
}
@@ -1274,8 +1271,8 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
if (usageVmDiskStat != null) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("getting current accounted bytes for... accountId: " + usageVmDiskStat.getAccountId() + " in zone: " + vmDiskStat.getDataCenterId() +
- "; aiw: " + vmDiskStat.getAggIOWrite() + "; air: " + usageVmDiskStat.getAggIORead() + "; abw: " + vmDiskStat.getAggBytesWrite() + "; abr: " +
- usageVmDiskStat.getAggBytesRead());
+ "; aiw: " + vmDiskStat.getAggIOWrite() + "; air: " + usageVmDiskStat.getAggIORead() + "; abw: " + vmDiskStat.getAggBytesWrite() + "; abr: " +
+ usageVmDiskStat.getAggBytesRead());
}
currentAccountedIORead = usageVmDiskStat.getAggIORead();
currentAccountedIOWrite = usageVmDiskStat.getAggIOWrite();
@@ -1289,22 +1286,22 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
if (ioRead < 0) {
s_logger.warn("Calculated negative value for io read: " + ioRead + ", vm disk stats say: " + vmDiskStat.getAggIORead() + ", previous vm disk usage was: " +
- currentAccountedIORead);
+ currentAccountedIORead);
ioRead = 0;
}
if (ioWrite < 0) {
s_logger.warn("Calculated negative value for io write: " + ioWrite + ", vm disk stats say: " + vmDiskStat.getAggIOWrite() + ", previous vm disk usage was: " +
- currentAccountedIOWrite);
+ currentAccountedIOWrite);
ioWrite = 0;
}
if (bytesRead < 0) {
s_logger.warn("Calculated negative value for bytes read: " + bytesRead + ", vm disk stats say: " + vmDiskStat.getAggBytesRead() +
- ", previous vm disk usage was: " + currentAccountedBytesRead);
+ ", previous vm disk usage was: " + currentAccountedBytesRead);
bytesRead = 0;
}
if (bytesWrite < 0) {
s_logger.warn("Calculated negative value for bytes write: " + bytesWrite + ", vm disk stats say: " + vmDiskStat.getAggBytesWrite() +
- ", previous vm disk usage was: " + currentAccountedBytesWrite);
+ ", previous vm disk usage was: " + currentAccountedBytesWrite);
bytesWrite = 0;
}
@@ -1315,13 +1312,13 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
}
UsageVmDiskVO usageVmDiskVO =
- new UsageVmDiskVO(vmDiskStat.getAccountId(), vmDiskStat.getDataCenterId(), vmId, vmDiskStat.getVolumeId(), ioRead, ioWrite, vmDiskStat.getAggIORead(),
- vmDiskStat.getAggIOWrite(), bytesRead, bytesWrite, vmDiskStat.getAggBytesRead(), vmDiskStat.getAggBytesWrite(), timestamp);
+ new UsageVmDiskVO(vmDiskStat.getAccountId(), vmDiskStat.getDataCenterId(), vmId, vmDiskStat.getVolumeId(), ioRead, ioWrite, vmDiskStat.getAggIORead(),
+ vmDiskStat.getAggIOWrite(), bytesRead, bytesWrite, vmDiskStat.getAggBytesRead(), vmDiskStat.getAggBytesWrite(), timestamp);
if (s_logger.isDebugEnabled()) {
s_logger.debug("creating vmDiskHelperEntry... accountId: " + vmDiskStat.getAccountId() + " in zone: " + vmDiskStat.getDataCenterId() + "; aiw: " +
- vmDiskStat.getAggIOWrite() + "; air: " + vmDiskStat.getAggIORead() + "; curAIR: " + currentAccountedIORead + "; curAIW: " + currentAccountedIOWrite +
- "; uir: " + ioRead + "; uiw: " + ioWrite + "; abw: " + vmDiskStat.getAggBytesWrite() + "; abr: " + vmDiskStat.getAggBytesRead() + "; curABR: " +
- currentAccountedBytesRead + "; curABW: " + currentAccountedBytesWrite + "; ubr: " + bytesRead + "; ubw: " + bytesWrite);
+ vmDiskStat.getAggIOWrite() + "; air: " + vmDiskStat.getAggIORead() + "; curAIR: " + currentAccountedIORead + "; curAIW: " + currentAccountedIOWrite +
+ "; uir: " + ioRead + "; uiw: " + ioWrite + "; abw: " + vmDiskStat.getAggBytesWrite() + "; abr: " + vmDiskStat.getAggBytesRead() + "; curABR: " +
+ currentAccountedBytesRead + "; curABW: " + currentAccountedBytesWrite + "; ubr: " + bytesRead + "; ubw: " + bytesWrite);
}
usageVmDisks.add(usageVmDiskVO);
}
@@ -1341,7 +1338,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
boolean isSourceNat = (sourceNat == 1) ? true : false;
boolean isSystem = (event.getTemplateId() == null || event.getTemplateId() == 0) ? false : true;
UsageIPAddressVO ipAddressVO =
- new UsageIPAddressVO(id, event.getAccountId(), acct.getDomainId(), zoneId, ipAddress, isSourceNat, isSystem, event.getCreateDate(), null);
+ new UsageIPAddressVO(id, event.getAccountId(), acct.getDomainId(), zoneId, ipAddress, isSourceNat, isSystem, event.getCreateDate(), null);
_usageIPAddressDao.persist(ipAddressVO);
} else if (EventTypes.EVENT_NET_IP_RELEASE.equals(event.getType())) {
SearchCriteria<UsageIPAddressVO> sc = _usageIPAddressDao.createSearchCriteria();
@@ -1351,7 +1348,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
List<UsageIPAddressVO> ipAddressVOs = _usageIPAddressDao.search(sc, null);
if (ipAddressVOs.size() > 1) {
s_logger.warn("More that one usage entry for ip address: " + ipAddress + " assigned to account: " + event.getAccountId() +
- "; marking them all as released...");
+ "; marking them all as released...");
}
for (UsageIPAddressVO ipAddressVO : ipAddressVOs) {
if (s_logger.isDebugEnabled()) {
@@ -1441,8 +1438,8 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
}
Account acct = _accountDao.findByIdIncludingRemoved(event.getAccountId());
UsageStorageVO storageVO =
- new UsageStorageVO(templateId, zoneId, event.getAccountId(), acct.getDomainId(), StorageTypes.TEMPLATE, event.getTemplateId(), templateSize,
- event.getVirtualSize(), event.getCreateDate(), null);
+ new UsageStorageVO(templateId, zoneId, event.getAccountId(), acct.getDomainId(), StorageTypes.TEMPLATE, event.getTemplateId(), templateSize,
+ event.getVirtualSize(), event.getCreateDate(), null);
_usageStorageDao.persist(storageVO);
} else if (EventTypes.EVENT_TEMPLATE_DELETE.equals(event.getType())) {
List<UsageStorageVO> storageVOs;
@@ -1453,7 +1450,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
}
if (storageVOs.size() > 1) {
s_logger.warn("More that one usage entry for storage: " + templateId + " assigned to account: " + event.getAccountId() +
- "; marking them all as deleted...");
+ "; marking them all as deleted...");
}
for (UsageStorageVO storageVO : storageVOs) {
if (s_logger.isDebugEnabled()) {
@@ -1485,7 +1482,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
}
Account acct = _accountDao.findByIdIncludingRemoved(event.getAccountId());
UsageStorageVO storageVO =
- new UsageStorageVO(isoId, zoneId, event.getAccountId(), acct.getDomainId(), StorageTypes.ISO, null, isoSize, isoSize, event.getCreateDate(), null);
+ new UsageStorageVO(isoId, zoneId, event.getAccountId(), acct.getDomainId(), StorageTypes.ISO, null, isoSize, isoSize, event.getCreateDate(), null);
_usageStorageDao.persist(storageVO);
} else if (EventTypes.EVENT_ISO_DELETE.equals(event.getType())) {
List<UsageStorageVO> storageVOs;
@@ -1524,7 +1521,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
}
Account acct = _accountDao.findByIdIncludingRemoved(event.getAccountId());
UsageStorageVO storageVO =
- new UsageStorageVO(snapId, zoneId, event.getAccountId(), acct.getDomainId(), StorageTypes.SNAPSHOT, null, snapSize, event.getCreateDate(), null);
+ new UsageStorageVO(snapId, zoneId, event.getAccountId(), acct.getDomainId(), StorageTypes.SNAPSHOT, null, snapSize, event.getCreateDate(), null);
_usageStorageDao.persist(storageVO);
} else if (EventTypes.EVENT_SNAPSHOT_DELETE.equals(event.getType())) {
List<UsageStorageVO> storageVOs = _usageStorageDao.listById(event.getAccountId(), snapId, StorageTypes.SNAPSHOT);
@@ -1563,7 +1560,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
List<UsageLoadBalancerPolicyVO> lbVOs = _usageLoadBalancerPolicyDao.search(sc, null);
if (lbVOs.size() > 1) {
s_logger.warn("More that one usage entry for load balancer policy: " + id + " assigned to account: " + event.getAccountId() +
- "; marking them all as deleted...");
+ "; marking them all as deleted...");
}
for (UsageLoadBalancerPolicyVO lbVO : lbVOs) {
if (s_logger.isDebugEnabled()) {
@@ -1597,7 +1594,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
List<UsagePortForwardingRuleVO> pfVOs = _usagePortForwardingRuleDao.search(sc, null);
if (pfVOs.size() > 1) {
s_logger.warn("More that one usage entry for port forwarding rule: " + id + " assigned to account: " + event.getAccountId() +
- "; marking them all as deleted...");
+ "; marking them all as deleted...");
}
for (UsagePortForwardingRuleVO pfVO : pfVOs) {
if (s_logger.isDebugEnabled()) {
@@ -1630,7 +1627,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
Account acct = _accountDao.findByIdIncludingRemoved(event.getAccountId());
boolean isDefault = (event.getSize() == 1) ? true : false;
UsageNetworkOfferingVO networkOffering =
- new UsageNetworkOfferingVO(zoneId, event.getAccountId(), acct.getDomainId(), vmId, networkOfferingId, nicId, isDefault, event.getCreateDate(), null);
+ new UsageNetworkOfferingVO(zoneId, event.getAccountId(), acct.getDomainId(), vmId, networkOfferingId, nicId, isDefault, event.getCreateDate(), null);
_usageNetworkOfferingDao.persist(networkOffering);
} else if (EventTypes.EVENT_NETWORK_OFFERING_DELETE.equals(event.getType()) || EventTypes.EVENT_NETWORK_OFFERING_REMOVE.equals(event.getType())) {
SearchCriteria<UsageNetworkOfferingVO> sc = _usageNetworkOfferingDao.createSearchCriteria();
@@ -1642,7 +1639,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
List<UsageNetworkOfferingVO> noVOs = _usageNetworkOfferingDao.search(sc, null);
if (noVOs.size() > 1) {
s_logger.warn("More that one usage entry for networking offering: " + networkOfferingId + " for Vm: " + vmId + " assigned to account: " +
- event.getAccountId() + "; marking them all as deleted...");
+ event.getAccountId() + "; marking them all as deleted...");
}
for (UsageNetworkOfferingVO noVO : noVOs) {
if (s_logger.isDebugEnabled()) {
@@ -1711,7 +1708,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
List<UsageSecurityGroupVO> sgVOs = _usageSecurityGroupDao.search(sc, null);
if (sgVOs.size() > 1) {
s_logger.warn("More that one usage entry for security group: " + sgId + " for Vm: " + vmId + " assigned to account: " + event.getAccountId() +
- "; marking them all as deleted...");
+ "; marking them all as deleted...");
}
for (UsageSecurityGroupVO sgVO : sgVOs) {
if (s_logger.isDebugEnabled()) {
@@ -1766,7 +1763,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
long now = System.currentTimeMillis();
long timeToJob = _jobExecTime.getTimeInMillis() - now;
long timeSinceJob = 0;
- long aggregationDurationMillis = _aggregationDuration * 60 * 1000;
+ long aggregationDurationMillis = _aggregationDuration * 60L * 1000L;
long lastSuccess = _usageJobDao.getLastJobSuccessDateMillis();
if (lastSuccess > 0) {
timeSinceJob = now - lastSuccess;
@@ -1776,7 +1773,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
if (timeToJob > (aggregationDurationMillis / 2)) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("it's been " + timeSinceJob + " ms since last usage job and " + timeToJob +
- " ms until next job, scheduling an immediate job to catch up (aggregation duration is " + _aggregationDuration + " minutes)");
+ " ms until next job, scheduling an immediate job to catch up (aggregation duration is " + _aggregationDuration + " minutes)");
}
scheduleParse();
}
[3/5] git commit: updated refs/heads/master to 676b2d1
Posted by hu...@apache.org.
Fix CID 1114608 Store virtualsize in the the virtualsize column
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f275f293
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f275f293
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f275f293
Branch: refs/heads/master
Commit: f275f293bbcb2897179d96a137281aeccd1e12b7
Parents: da55aff
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Thu Jul 24 12:00:34 2014 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Thu Jul 24 12:21:37 2014 +0200
----------------------------------------------------------------------
.../src/com/cloud/usage/dao/UsageDaoImpl.java | 27 ++++++++++----------
1 file changed, 14 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f275f293/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java b/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
index 32f63e6..a2d38e2 100644
--- a/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
+++ b/engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java
@@ -49,12 +49,12 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage
private static final String DELETE_ALL_BY_ACCOUNTID = "DELETE FROM cloud_usage WHERE account_id = ?";
private static final String INSERT_ACCOUNT = "INSERT INTO cloud_usage.account (id, account_name, type, domain_id, removed, cleanup_needed) VALUES (?,?,?,?,?,?)";
private static final String INSERT_USER_STATS =
- "INSERT INTO cloud_usage.user_statistics (id, data_center_id, account_id, public_ip_address, device_id, device_type, network_id, net_bytes_received,"
- + " net_bytes_sent, current_bytes_received, current_bytes_sent, agg_bytes_received, agg_bytes_sent) VALUES (?,?,?,?,?,?,?,?,?,?, ?, ?, ?)";
+ "INSERT INTO cloud_usage.user_statistics (id, data_center_id, account_id, public_ip_address, device_id, device_type, network_id, net_bytes_received,"
+ + " net_bytes_sent, current_bytes_received, current_bytes_sent, agg_bytes_received, agg_bytes_sent) VALUES (?,?,?,?,?,?,?,?,?,?, ?, ?, ?)";
private static final String UPDATE_ACCOUNT = "UPDATE cloud_usage.account SET account_name=?, removed=? WHERE id=?";
private static final String UPDATE_USER_STATS =
- "UPDATE cloud_usage.user_statistics SET net_bytes_received=?, net_bytes_sent=?, current_bytes_received=?, current_bytes_sent=?, agg_bytes_received=?, agg_bytes_sent=? WHERE id=?";
+ "UPDATE cloud_usage.user_statistics SET net_bytes_received=?, net_bytes_sent=?, current_bytes_received=?, current_bytes_sent=?, agg_bytes_received=?, agg_bytes_sent=? WHERE id=?";
private static final String GET_LAST_ACCOUNT = "SELECT id FROM cloud_usage.account ORDER BY id DESC LIMIT 1";
private static final String GET_LAST_USER_STATS = "SELECT id FROM cloud_usage.user_statistics ORDER BY id DESC LIMIT 1";
@@ -62,15 +62,16 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage
private static final String GET_LAST_VM_DISK_STATS = "SELECT id FROM cloud_usage.vm_disk_statistics ORDER BY id DESC LIMIT 1";
private static final String INSERT_VM_DISK_STATS =
- "INSERT INTO cloud_usage.vm_disk_statistics (id, data_center_id, account_id, vm_id, volume_id, net_io_read, net_io_write, current_io_read, "
- + "current_io_write, agg_io_read, agg_io_write, net_bytes_read, net_bytes_write, current_bytes_read, current_bytes_write, agg_bytes_read, agg_bytes_write) "
- + " VALUES (?,?,?,?,?,?,?,?,?,?, ?, ?, ?, ?,?, ?, ?)";
+ "INSERT INTO cloud_usage.vm_disk_statistics (id, data_center_id, account_id, vm_id, volume_id, net_io_read, net_io_write, current_io_read, "
+ + "current_io_write, agg_io_read, agg_io_write, net_bytes_read, net_bytes_write, current_bytes_read, current_bytes_write, agg_bytes_read, agg_bytes_write) "
+ + " VALUES (?,?,?,?,?,?,?,?,?,?, ?, ?, ?, ?,?, ?, ?)";
private static final String UPDATE_VM_DISK_STATS =
- "UPDATE cloud_usage.vm_disk_statistics SET net_io_read=?, net_io_write=?, current_io_read=?, current_io_write=?, agg_io_read=?, agg_io_write=?, "
- + "net_bytes_read=?, net_bytes_write=?, current_bytes_read=?, current_bytes_write=?, agg_bytes_read=?, agg_bytes_write=? WHERE id=?";
- private static final String INSERT_USGAE_RECORDS = "INSERT INTO cloud_usage.cloud_usage (zone_id, account_id, domain_id, description, usage_display, " +
- "usage_type, raw_usage, vm_instance_id, vm_name, offering_id, template_id, "
- + "usage_id, type, size, network_id, start_date, end_date, virtual_size) VALUES (?,?,?,?,?,?,?,?,?, ?, ?, ?,?,?,?,?,?,?)";
+ "UPDATE cloud_usage.vm_disk_statistics SET net_io_read=?, net_io_write=?, current_io_read=?, current_io_write=?, agg_io_read=?, agg_io_write=?, "
+ + "net_bytes_read=?, net_bytes_write=?, current_bytes_read=?, current_bytes_write=?, agg_bytes_read=?, agg_bytes_write=? WHERE id=?";
+ private static final String INSERT_USAGE_RECORDS = "INSERT INTO cloud_usage.cloud_usage (zone_id, account_id, domain_id, description, usage_display, "
+ +
+ "usage_type, raw_usage, vm_instance_id, vm_name, offering_id, template_id, "
+ + "usage_id, type, size, network_id, start_date, end_date, virtual_size) VALUES (?,?,?,?,?,?,?,?,?, ?, ?, ?,?,?,?,?,?,?)";
protected final static TimeZone s_gmtTimeZone = TimeZone.getTimeZone("GMT");
@@ -390,7 +391,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage
TransactionLegacy txn = TransactionLegacy.currentTxn();
try {
txn.start();
- String sql = INSERT_USGAE_RECORDS;
+ String sql = INSERT_USAGE_RECORDS;
PreparedStatement pstmt = null;
pstmt = txn.prepareAutoCloseStatement(sql); // in reality I just want CLOUD_USAGE dataSource connection
for (UsageVO usageRecord : usageRecords) {
@@ -436,7 +437,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage
pstmt.setString(16, DateUtil.getDateDisplayString(s_gmtTimeZone, usageRecord.getStartDate()));
pstmt.setString(17, DateUtil.getDateDisplayString(s_gmtTimeZone, usageRecord.getEndDate()));
if (usageRecord.getVirtualSize() != null) {
- pstmt.setLong(18, usageRecord.getSize());
+ pstmt.setLong(18, usageRecord.getVirtualSize());
} else {
pstmt.setNull(18, Types.BIGINT);
}