http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/usage/src/com/cloud/usage/parser/NetworkOfferingUsageParser.java ---------------------------------------------------------------------- diff --git a/usage/src/com/cloud/usage/parser/NetworkOfferingUsageParser.java b/usage/src/com/cloud/usage/parser/NetworkOfferingUsageParser.java index 6aa61d6..4a5a1d2 100644 --- a/usage/src/com/cloud/usage/parser/NetworkOfferingUsageParser.java +++ b/usage/src/com/cloud/usage/parser/NetworkOfferingUsageParser.java @@ -41,8 +41,8 @@ import com.cloud.utils.Pair; public class NetworkOfferingUsageParser { public static final Logger s_logger = Logger.getLogger(NetworkOfferingUsageParser.class.getName()); - private static UsageDao m_usageDao; - private static UsageNetworkOfferingDao m_usageNetworkOfferingDao; + private static UsageDao s_usageDao; + private static UsageNetworkOfferingDao s_usageNetworkOfferingDao; @Inject private UsageDao _usageDao; @@ -51,8 +51,8 @@ public class NetworkOfferingUsageParser { @PostConstruct void init() { - m_usageDao = _usageDao; - m_usageNetworkOfferingDao = _usageNetworkOfferingDao; + s_usageDao = _usageDao; + s_usageNetworkOfferingDao = _usageNetworkOfferingDao; } public static boolean parse(AccountVO account, Date startDate, Date endDate) { @@ -68,7 +68,7 @@ public class NetworkOfferingUsageParser { // - 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<UsageNetworkOfferingVO> usageNOs = m_usageNetworkOfferingDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate, false, 0); + List<UsageNetworkOfferingVO> usageNOs = s_usageNetworkOfferingDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate, false, 0); if (usageNOs.isEmpty()) { s_logger.debug("No NetworkOffering usage events for this period"); @@ -154,14 +154,14 @@ public class NetworkOfferingUsageParser { UsageVO usageRecord = new UsageVO(zoneId, account.getId(), account.getDomainId(), usageDesc, usageDisplay + " Hrs", type, new Double(usage), vmId, null, noId, null, defaultNic, null, startDate, endDate); - m_usageDao.persist(usageRecord); + s_usageDao.persist(usageRecord); } private static class NOInfo { - private long vmId; - private long zoneId; - private long noId; - private boolean isDefault; + private final long vmId; + private final long zoneId; + private final long noId; + private final boolean isDefault; public NOInfo(long vmId, long zoneId, long noId, boolean isDefault) { this.vmId = vmId;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/usage/src/com/cloud/usage/parser/NetworkUsageParser.java ---------------------------------------------------------------------- diff --git a/usage/src/com/cloud/usage/parser/NetworkUsageParser.java b/usage/src/com/cloud/usage/parser/NetworkUsageParser.java index 5dec1e0..a54cb3e 100644 --- a/usage/src/com/cloud/usage/parser/NetworkUsageParser.java +++ b/usage/src/com/cloud/usage/parser/NetworkUsageParser.java @@ -41,8 +41,8 @@ import com.cloud.utils.db.SearchCriteria; public class NetworkUsageParser { public static final Logger s_logger = Logger.getLogger(NetworkUsageParser.class.getName()); - private static UsageDao m_usageDao; - private static UsageNetworkDao m_usageNetworkDao; + private static UsageDao s_usageDao; + private static UsageNetworkDao s_usageNetworkDao; @Inject private UsageDao _usageDao; @@ -51,8 +51,8 @@ public class NetworkUsageParser { @PostConstruct void init() { - m_usageDao = _usageDao; - m_usageNetworkDao = _usageNetworkDao; + s_usageDao = _usageDao; + s_usageNetworkDao = _usageNetworkDao; } public static boolean parse(AccountVO account, Date startDate, Date endDate) { @@ -66,10 +66,10 @@ public class NetworkUsageParser { // - query usage_network table for all entries for userId with // event_date in the given range - SearchCriteria<UsageNetworkVO> sc = m_usageNetworkDao.createSearchCriteria(); + SearchCriteria<UsageNetworkVO> sc = s_usageNetworkDao.createSearchCriteria(); sc.addAnd("accountId", SearchCriteria.Op.EQ, account.getId()); sc.addAnd("eventTimeMillis", SearchCriteria.Op.BETWEEN, startDate.getTime(), endDate.getTime()); - List<UsageNetworkVO> usageNetworkVOs = m_usageNetworkDao.search(sc, null); + List<UsageNetworkVO> usageNetworkVOs = s_usageNetworkDao.search(sc, null); Map<String, NetworkInfo> networkUsageByZone = new HashMap<String, NetworkInfo>(); @@ -136,7 +136,7 @@ public class NetworkUsageParser { } } - m_usageDao.saveUsageRecords(usageRecords); + s_usageDao.saveUsageRecords(usageRecords); return true; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/usage/src/com/cloud/usage/parser/PortForwardingUsageParser.java ---------------------------------------------------------------------- diff --git a/usage/src/com/cloud/usage/parser/PortForwardingUsageParser.java b/usage/src/com/cloud/usage/parser/PortForwardingUsageParser.java index dd12d57..37c7751 100644 --- a/usage/src/com/cloud/usage/parser/PortForwardingUsageParser.java +++ b/usage/src/com/cloud/usage/parser/PortForwardingUsageParser.java @@ -41,8 +41,8 @@ import com.cloud.utils.Pair; public class PortForwardingUsageParser { public static final Logger s_logger = Logger.getLogger(PortForwardingUsageParser.class.getName()); - private static UsageDao m_usageDao; - private static UsagePortForwardingRuleDao m_usagePFRuleDao; + private static UsageDao s_usageDao; + private static UsagePortForwardingRuleDao s_usagePFRuleDao; @Inject private UsageDao _usageDao; @@ -51,8 +51,8 @@ public class PortForwardingUsageParser { @PostConstruct void init() { - m_usageDao = _usageDao; - m_usagePFRuleDao = _usagePFRuleDao; + s_usageDao = _usageDao; + s_usagePFRuleDao = _usagePFRuleDao; } public static boolean parse(AccountVO account, Date startDate, Date endDate) { @@ -68,7 +68,7 @@ public class PortForwardingUsageParser { // - 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<UsagePortForwardingRuleVO> usagePFs = m_usagePFRuleDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate, false, 0); + List<UsagePortForwardingRuleVO> usagePFs = s_usagePFRuleDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate, false, 0); if (usagePFs.isEmpty()) { s_logger.debug("No port forwarding usage events for this period"); @@ -152,7 +152,7 @@ public class PortForwardingUsageParser { UsageVO usageRecord = new UsageVO(zoneId, account.getId(), account.getDomainId(), usageDesc, usageDisplay + " Hrs", type, new Double(usage), null, null, null, null, pfId, null, startDate, endDate); - m_usageDao.persist(usageRecord); + s_usageDao.persist(usageRecord); } private static class PFInfo { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/usage/src/com/cloud/usage/parser/SecurityGroupUsageParser.java ---------------------------------------------------------------------- diff --git a/usage/src/com/cloud/usage/parser/SecurityGroupUsageParser.java b/usage/src/com/cloud/usage/parser/SecurityGroupUsageParser.java index cb1d72e..ea86d49 100644 --- a/usage/src/com/cloud/usage/parser/SecurityGroupUsageParser.java +++ b/usage/src/com/cloud/usage/parser/SecurityGroupUsageParser.java @@ -41,8 +41,8 @@ import com.cloud.utils.Pair; public class SecurityGroupUsageParser { public static final Logger s_logger = Logger.getLogger(SecurityGroupUsageParser.class.getName()); - private static UsageDao m_usageDao; - private static UsageSecurityGroupDao m_usageSecurityGroupDao; + private static UsageDao s_usageDao; + private static UsageSecurityGroupDao s_usageSecurityGroupDao; @Inject private UsageDao _usageDao; @@ -51,8 +51,8 @@ public class SecurityGroupUsageParser { @PostConstruct void init() { - m_usageDao = _usageDao; - m_usageSecurityGroupDao = _usageSecurityGroupDao; + s_usageDao = _usageDao; + s_usageSecurityGroupDao = _usageSecurityGroupDao; } public static boolean parse(AccountVO account, Date startDate, Date endDate) { @@ -68,7 +68,7 @@ public class SecurityGroupUsageParser { // - 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<UsageSecurityGroupVO> usageSGs = m_usageSecurityGroupDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate, false, 0); + List<UsageSecurityGroupVO> usageSGs = s_usageSecurityGroupDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate, false, 0); if (usageSGs.isEmpty()) { s_logger.debug("No SecurityGroup usage events for this period"); @@ -152,7 +152,7 @@ public class SecurityGroupUsageParser { UsageVO usageRecord = new UsageVO(zoneId, account.getId(), account.getDomainId(), usageDesc, usageDisplay + " Hrs", type, new Double(usage), vmId, null, null, null, sgId, null, startDate, endDate); - m_usageDao.persist(usageRecord); + s_usageDao.persist(usageRecord); } private static class SGInfo { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/usage/src/com/cloud/usage/parser/StorageUsageParser.java ---------------------------------------------------------------------- diff --git a/usage/src/com/cloud/usage/parser/StorageUsageParser.java b/usage/src/com/cloud/usage/parser/StorageUsageParser.java index 560f6b0..f1091a1 100644 --- a/usage/src/com/cloud/usage/parser/StorageUsageParser.java +++ b/usage/src/com/cloud/usage/parser/StorageUsageParser.java @@ -42,8 +42,8 @@ import com.cloud.utils.Pair; public class StorageUsageParser { public static final Logger s_logger = Logger.getLogger(StorageUsageParser.class.getName()); - private static UsageDao m_usageDao; - private static UsageStorageDao m_usageStorageDao; + private static UsageDao s_usageDao; + private static UsageStorageDao s_usageStorageDao; @Inject private UsageDao _usageDao; @@ -52,8 +52,8 @@ public class StorageUsageParser { @PostConstruct void init() { - m_usageDao = _usageDao; - m_usageStorageDao = _usageStorageDao; + s_usageDao = _usageDao; + s_usageStorageDao = _usageStorageDao; } public static boolean parse(AccountVO account, Date startDate, Date endDate) { @@ -69,7 +69,7 @@ public class StorageUsageParser { // - 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<UsageStorageVO> usageUsageStorages = m_usageStorageDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate, false, 0); + List<UsageStorageVO> usageUsageStorages = s_usageStorageDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate, false, 0); if (usageUsageStorages.isEmpty()) { s_logger.debug("No Storage usage events for this period"); @@ -183,7 +183,7 @@ public class StorageUsageParser { UsageVO usageRecord = new UsageVO(zoneId, account.getId(), account.getDomainId(), usageDesc, usageDisplay + " Hrs", usage_type, new Double(usage), null, null, null, tmplSourceId, storageId, size, virtualSize, startDate, endDate); - m_usageDao.persist(usageRecord); + s_usageDao.persist(usageRecord); } private static class StorageInfo { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/usage/src/com/cloud/usage/parser/VMInstanceUsageParser.java ---------------------------------------------------------------------- diff --git a/usage/src/com/cloud/usage/parser/VMInstanceUsageParser.java b/usage/src/com/cloud/usage/parser/VMInstanceUsageParser.java index 78cafed..ba0d4bf 100644 --- a/usage/src/com/cloud/usage/parser/VMInstanceUsageParser.java +++ b/usage/src/com/cloud/usage/parser/VMInstanceUsageParser.java @@ -41,8 +41,8 @@ import com.cloud.utils.Pair; public class VMInstanceUsageParser { public static final Logger s_logger = Logger.getLogger(VMInstanceUsageParser.class.getName()); - private static UsageDao m_usageDao; - private static UsageVMInstanceDao m_usageInstanceDao; + private static UsageDao s_usageDao; + private static UsageVMInstanceDao s_usageInstanceDao; @Inject private UsageDao _usageDao;; @@ -51,8 +51,8 @@ public class VMInstanceUsageParser { @PostConstruct void init() { - m_usageDao = _usageDao; - m_usageInstanceDao = _usageInstanceDao; + s_usageDao = _usageDao; + s_usageInstanceDao = _usageInstanceDao; } public static boolean parse(AccountVO account, Date startDate, Date endDate) { @@ -68,7 +68,7 @@ public class VMInstanceUsageParser { // - 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<UsageVMInstanceVO> usageInstances = m_usageInstanceDao.getUsageRecords(account.getId(), startDate, endDate); + List<UsageVMInstanceVO> usageInstances = s_usageInstanceDao.getUsageRecords(account.getId(), startDate, endDate); //ToDo: Add domainID for getting usage records // This map has both the running time *and* the usage amount. @@ -180,7 +180,7 @@ public class VMInstanceUsageParser { UsageVO usageRecord = new UsageVO(Long.valueOf(zoneId), account.getId(), account.getDomainId(), usageDesc, usageDisplay + " Hrs", type, new Double(usage), Long.valueOf(vmId), vmName, Long.valueOf(serviceOfferingId), Long.valueOf(templateId), Long.valueOf(vmId), startDate, endDate, hypervisorType); - m_usageDao.persist(usageRecord); + s_usageDao.persist(usageRecord); } private static class VMInfo { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/usage/src/com/cloud/usage/parser/VMSnapshotUsageParser.java ---------------------------------------------------------------------- diff --git a/usage/src/com/cloud/usage/parser/VMSnapshotUsageParser.java b/usage/src/com/cloud/usage/parser/VMSnapshotUsageParser.java index 0d2b0c1..9af8137 100644 --- a/usage/src/com/cloud/usage/parser/VMSnapshotUsageParser.java +++ b/usage/src/com/cloud/usage/parser/VMSnapshotUsageParser.java @@ -40,8 +40,8 @@ import com.cloud.user.AccountVO; public class VMSnapshotUsageParser { public static final Logger s_logger = Logger.getLogger(VMSnapshotUsageParser.class.getName()); - private static UsageDao m_usageDao; - private static UsageVMSnapshotDao m_usageVMSnapshotDao; + private static UsageDao s_usageDao; + private static UsageVMSnapshotDao s_usageVMSnapshotDao; @Inject private UsageDao _usageDao; @@ -50,8 +50,8 @@ public class VMSnapshotUsageParser { @PostConstruct void init() { - m_usageDao = _usageDao; - m_usageVMSnapshotDao = _usageVMSnapshotDao; + s_usageDao = _usageDao; + s_usageVMSnapshotDao = _usageVMSnapshotDao; } public static boolean parse(AccountVO account, Date startDate, Date endDate) { @@ -62,7 +62,7 @@ public class VMSnapshotUsageParser { endDate = new Date(); } - List<UsageVMSnapshotVO> usageUsageVMSnapshots = m_usageVMSnapshotDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate); + List<UsageVMSnapshotVO> usageUsageVMSnapshots = s_usageVMSnapshotDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate); if (usageUsageVMSnapshots.isEmpty()) { s_logger.debug("No VM snapshot usage events for this period"); @@ -79,7 +79,7 @@ public class VMSnapshotUsageParser { unprocessedUsage.put(key, usageRec); continue; } - UsageVMSnapshotVO previousEvent = m_usageVMSnapshotDao.getPreviousUsageRecord(usageRec); + UsageVMSnapshotVO previousEvent = s_usageVMSnapshotDao.getPreviousUsageRecord(usageRec); if (previousEvent == null || previousEvent.getSize() == 0) { unprocessedUsage.put(key, usageRec); continue; @@ -96,11 +96,11 @@ public class VMSnapshotUsageParser { createUsageRecord(UsageTypes.VM_SNAPSHOT, duration, previousCreated, createDate, account, volId, zoneId, previousEvent.getDiskOfferingId(), vmId, previousEvent.getSize()); previousEvent.setProcessed(new Date()); - m_usageVMSnapshotDao.update(previousEvent); + s_usageVMSnapshotDao.update(previousEvent); if (usageRec.getSize() == 0) { usageRec.setProcessed(new Date()); - m_usageVMSnapshotDao.update(usageRec); + s_usageVMSnapshotDao.update(usageRec); } else unprocessedUsage.put(key, usageRec); } @@ -148,7 +148,7 @@ public class VMSnapshotUsageParser { UsageVO usageRecord = new UsageVO(zoneId, account.getId(), account.getDomainId(), usageDesc, usageDisplay + " Hrs", type, new Double(usage), vmId, null, doId, null, volId, size, startDate, endDate); - m_usageDao.persist(usageRecord); + s_usageDao.persist(usageRecord); } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/usage/src/com/cloud/usage/parser/VPNUserUsageParser.java ---------------------------------------------------------------------- diff --git a/usage/src/com/cloud/usage/parser/VPNUserUsageParser.java b/usage/src/com/cloud/usage/parser/VPNUserUsageParser.java index a6f4a69..619c861 100644 --- a/usage/src/com/cloud/usage/parser/VPNUserUsageParser.java +++ b/usage/src/com/cloud/usage/parser/VPNUserUsageParser.java @@ -41,8 +41,8 @@ import com.cloud.utils.Pair; public class VPNUserUsageParser { public static final Logger s_logger = Logger.getLogger(VPNUserUsageParser.class.getName()); - private static UsageDao m_usageDao; - private static UsageVPNUserDao m_usageVPNUserDao; + private static UsageDao s_usageDao; + private static UsageVPNUserDao s_usageVPNUserDao; @Inject private UsageDao _usageDao; @@ -51,8 +51,8 @@ public class VPNUserUsageParser { @PostConstruct void init() { - m_usageDao = _usageDao; - m_usageVPNUserDao = _usageVPNUserDao; + s_usageDao = _usageDao; + s_usageVPNUserDao = _usageVPNUserDao; } public static boolean parse(AccountVO account, Date startDate, Date endDate) { @@ -63,7 +63,7 @@ public class VPNUserUsageParser { endDate = new Date(); } - List<UsageVPNUserVO> usageVUs = m_usageVPNUserDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate, false, 0); + List<UsageVPNUserVO> usageVUs = s_usageVPNUserDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate, false, 0); if (usageVUs.isEmpty()) { s_logger.debug("No VPN user usage events for this period"); @@ -147,7 +147,7 @@ public class VPNUserUsageParser { UsageVO usageRecord = new UsageVO(zoneId, account.getId(), account.getDomainId(), usageDesc, usageDisplay + " Hrs", type, new Double(usage), null, null, null, null, userId, null, startDate, endDate); - m_usageDao.persist(usageRecord); + s_usageDao.persist(usageRecord); } private static class VUInfo { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/usage/src/com/cloud/usage/parser/VmDiskUsageParser.java ---------------------------------------------------------------------- diff --git a/usage/src/com/cloud/usage/parser/VmDiskUsageParser.java b/usage/src/com/cloud/usage/parser/VmDiskUsageParser.java index 8ab216d..6022a3e 100644 --- a/usage/src/com/cloud/usage/parser/VmDiskUsageParser.java +++ b/usage/src/com/cloud/usage/parser/VmDiskUsageParser.java @@ -41,8 +41,8 @@ import com.cloud.utils.db.SearchCriteria; public class VmDiskUsageParser { public static final Logger s_logger = Logger.getLogger(VmDiskUsageParser.class.getName()); - private static UsageDao m_usageDao; - private static UsageVmDiskDao m_usageVmDiskDao; + private static UsageDao s_usageDao; + private static UsageVmDiskDao s_usageVmDiskDao; @Inject private UsageDao _usageDao; @@ -51,8 +51,8 @@ public class VmDiskUsageParser { @PostConstruct void init() { - m_usageDao = _usageDao; - m_usageVmDiskDao = _usageVmDiskDao; + s_usageDao = _usageDao; + s_usageVmDiskDao = _usageVmDiskDao; } public static boolean parse(AccountVO account, Date startDate, Date endDate) { @@ -66,10 +66,10 @@ public class VmDiskUsageParser { // - query usage_disk table for all entries for userId with // event_date in the given range - SearchCriteria<UsageVmDiskVO> sc = m_usageVmDiskDao.createSearchCriteria(); + SearchCriteria<UsageVmDiskVO> sc = s_usageVmDiskDao.createSearchCriteria(); sc.addAnd("accountId", SearchCriteria.Op.EQ, account.getId()); sc.addAnd("eventTimeMillis", SearchCriteria.Op.BETWEEN, startDate.getTime(), endDate.getTime()); - List<UsageVmDiskVO> usageVmDiskVOs = m_usageVmDiskDao.search(sc, null); + List<UsageVmDiskVO> usageVmDiskVOs = s_usageVmDiskDao.search(sc, null); Map<String, VmDiskInfo> vmDiskUsageByZone = new HashMap<String, VmDiskInfo>(); @@ -164,7 +164,7 @@ public class VmDiskUsageParser { } } - m_usageDao.saveUsageRecords(usageRecords); + s_usageDao.saveUsageRecords(usageRecords); return true; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/usage/src/com/cloud/usage/parser/VolumeUsageParser.java ---------------------------------------------------------------------- diff --git a/usage/src/com/cloud/usage/parser/VolumeUsageParser.java b/usage/src/com/cloud/usage/parser/VolumeUsageParser.java index adcf468..cd092a9 100644 --- a/usage/src/com/cloud/usage/parser/VolumeUsageParser.java +++ b/usage/src/com/cloud/usage/parser/VolumeUsageParser.java @@ -41,8 +41,8 @@ import com.cloud.utils.Pair; public class VolumeUsageParser { public static final Logger s_logger = Logger.getLogger(VolumeUsageParser.class.getName()); - private static UsageDao m_usageDao; - private static UsageVolumeDao m_usageVolumeDao; + private static UsageDao s_usageDao; + private static UsageVolumeDao s_usageVolumeDao; @Inject private UsageDao _usageDao; @@ -51,8 +51,8 @@ public class VolumeUsageParser { @PostConstruct void init() { - m_usageDao = _usageDao; - m_usageVolumeDao = _usageVolumeDao; + s_usageDao = _usageDao; + s_usageVolumeDao = _usageVolumeDao; } public static boolean parse(AccountVO account, Date startDate, Date endDate) { @@ -68,7 +68,7 @@ public class VolumeUsageParser { // - 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<UsageVolumeVO> usageUsageVols = m_usageVolumeDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate, false, 0); + List<UsageVolumeVO> usageUsageVols = s_usageVolumeDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate, false, 0); if (usageUsageVols.isEmpty()) { s_logger.debug("No volume usage events for this period"); @@ -164,7 +164,7 @@ public class VolumeUsageParser { UsageVO usageRecord = new UsageVO(zoneId, account.getId(), account.getDomainId(), usageDesc, usageDisplay + " Hrs", type, new Double(usage), null, null, doId, templateId, volId, size, startDate, endDate); - m_usageDao.persist(usageRecord); + s_usageDao.persist(usageRecord); } private static class VolInfo { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/usage/test/com/cloud/usage/UsageManagerTestConfiguration.java ---------------------------------------------------------------------- diff --git a/usage/test/com/cloud/usage/UsageManagerTestConfiguration.java b/usage/test/com/cloud/usage/UsageManagerTestConfiguration.java index 85b6cec..26b6106 100644 --- a/usage/test/com/cloud/usage/UsageManagerTestConfiguration.java +++ b/usage/test/com/cloud/usage/UsageManagerTestConfiguration.java @@ -64,12 +64,12 @@ import com.cloud.user.dao.UserStatisticsDaoImpl; @Configuration @ComponentScan(basePackageClasses = {AccountDaoImpl.class, UsageDaoImpl.class, UsageJobDaoImpl.class, UsageVMInstanceDaoImpl.class, UsageIPAddressDaoImpl.class, - UsageNetworkDaoImpl.class, UsageVolumeDaoImpl.class, UsageStorageDaoImpl.class, UsageLoadBalancerPolicyDaoImpl.class, - UsagePortForwardingRuleDaoImpl.class, UsageNetworkOfferingDaoImpl.class, UsageVPNUserDaoImpl.class, UsageVmDiskDaoImpl.class, - UsageSecurityGroupDaoImpl.class, ConfigurationDaoImpl.class, UsageManagerImpl.class, VMInstanceUsageParser.class, IPAddressUsageParser.class, - LoadBalancerUsageParser.class, NetworkOfferingUsageParser.class, NetworkUsageParser.class, PortForwardingUsageParser.class, - SecurityGroupUsageParser.class, StorageUsageParser.class, VmDiskUsageParser.class, VolumeUsageParser.class, VPNUserUsageParser.class, - UserStatisticsDaoImpl.class}, + UsageNetworkDaoImpl.class, UsageVolumeDaoImpl.class, UsageStorageDaoImpl.class, UsageLoadBalancerPolicyDaoImpl.class, + UsagePortForwardingRuleDaoImpl.class, UsageNetworkOfferingDaoImpl.class, UsageVPNUserDaoImpl.class, UsageVmDiskDaoImpl.class, + UsageSecurityGroupDaoImpl.class, ConfigurationDaoImpl.class, UsageManagerImpl.class, VMInstanceUsageParser.class, IPAddressUsageParser.class, + LoadBalancerUsageParser.class, NetworkOfferingUsageParser.class, NetworkUsageParser.class, PortForwardingUsageParser.class, + SecurityGroupUsageParser.class, StorageUsageParser.class, VmDiskUsageParser.class, VolumeUsageParser.class, VPNUserUsageParser.class, + UserStatisticsDaoImpl.class}, includeFilters = {@Filter(value = Library.class, type = FilterType.CUSTOM)}, useDefaultFilters = false) public class UsageManagerTestConfiguration { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/utils/src/com/cloud/utils/DateUtil.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/DateUtil.java b/utils/src/com/cloud/utils/DateUtil.java index 510afd2..560c92b 100644 --- a/utils/src/com/cloud/utils/DateUtil.java +++ b/utils/src/com/cloud/utils/DateUtil.java @@ -28,7 +28,7 @@ import com.cloud.utils.exception.CloudRuntimeException; public class DateUtil { public static final TimeZone GMT_TIMEZONE = TimeZone.getTimeZone("GMT"); public static final String YYYYMMDD_FORMAT = "yyyyMMddHHmmss"; - private static final DateFormat _outputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); + private static final DateFormat s_outputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); public static Date currentGMTTime() { // Date object always stores miliseconds offset based on GMT internally @@ -76,8 +76,8 @@ public class DateUtil { return ""; } String formattedString = null; - synchronized (_outputFormat) { - formattedString = _outputFormat.format(date); + synchronized (s_outputFormat) { + formattedString = s_outputFormat.format(date); } return formattedString; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/utils/src/com/cloud/utils/StringUtils.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/StringUtils.java b/utils/src/com/cloud/utils/StringUtils.java index 6b4c8f8..38d1369 100644 --- a/utils/src/com/cloud/utils/StringUtils.java +++ b/utils/src/com/cloud/utils/StringUtils.java @@ -189,25 +189,23 @@ public class StringUtils { return found > 0 ? found : end - start; } - - public static Map<String, String> stringToMap(String s){ - Map<String, String> map=new HashMap<String, String>(); + public static Map<String, String> stringToMap(String s) { + Map<String, String> map = new HashMap<String, String>(); String[] elements = s.split(";"); - for (String parts: elements) { + for (String parts : elements) { String[] keyValue = parts.split(":"); map.put(keyValue[0], keyValue[1]); } return map; } - - public static String mapToString(Map<String, String> map){ + public static String mapToString(Map<String, String> map) { String s = ""; - for (Map.Entry<String, String> entry: map.entrySet()) { - s += entry.getKey() + ":" + entry.getValue() +";"; + for (Map.Entry<String, String> entry : map.entrySet()) { + s += entry.getKey() + ":" + entry.getValue() + ";"; } if (s.length() > 0) { - s = s.substring(0, s.length()-1); + s = s.substring(0, s.length() - 1); } return s; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/utils/src/com/cloud/utils/SwiftUtil.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/SwiftUtil.java b/utils/src/com/cloud/utils/SwiftUtil.java index c920e1f..829159f 100644 --- a/utils/src/com/cloud/utils/SwiftUtil.java +++ b/utils/src/com/cloud/utils/SwiftUtil.java @@ -29,7 +29,7 @@ import com.cloud.utils.script.Script; public class SwiftUtil { private static Logger logger = Logger.getLogger(SwiftUtil.class); - private static long SWIFT_MAX_SIZE = 5L * 1024L * 1024L * 1024L; + private static final long SWIFT_MAX_SIZE = 5L * 1024L * 1024L * 1024L; public interface SwiftClientCfg { String getAccount(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/utils/src/com/cloud/utils/events/EventArgs.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/events/EventArgs.java b/utils/src/com/cloud/utils/events/EventArgs.java index 0f3dcdd..4bfe206 100644 --- a/utils/src/com/cloud/utils/events/EventArgs.java +++ b/utils/src/com/cloud/utils/events/EventArgs.java @@ -20,7 +20,7 @@ import java.io.Serializable; public class EventArgs implements Serializable { private static final long serialVersionUID = 30659016120504139L; - public static EventArgs Empty = new EventArgs(); + public static final EventArgs Empty = new EventArgs(); private String subject; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/utils/src/com/cloud/utils/net/NetUtils.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java index c0c792f..f6f6285 100755 --- a/utils/src/com/cloud/utils/net/NetUtils.java +++ b/utils/src/com/cloud/utils/net/NetUtils.java @@ -72,10 +72,10 @@ public class NetUtils { public final static int DEFAULT_AUTOSCALE_VM_DESTROY_TIME = 2 * 60; // Grace period before Vm is destroyed public final static int DEFAULT_AUTOSCALE_POLICY_INTERVAL_TIME = 30; public final static int DEFAULT_AUTOSCALE_POLICY_QUIET_TIME = 5 * 60; - private final static Random _rand = new Random(System.currentTimeMillis()); + private final static Random s_rand = new Random(System.currentTimeMillis()); public static long createSequenceBasedMacAddress(long macAddress) { - return macAddress | 0x060000000000l | (((long)_rand.nextInt(32768) << 25) & 0x00fffe000000l); + return macAddress | 0x060000000000l | (((long)s_rand.nextInt(32768) << 25) & 0x00fffe000000l); } public static String getHostName() { @@ -702,7 +702,7 @@ public class NetUtils { //e.g., cidr = 192.168.10.0, size = /24, avoid = 192.168.10.1, 192.168.10.20, 192.168.10.254 // range = 2^8 - 1 - 3 = 252 range = range - avoid.size(); - int next = _rand.nextInt(range); //note: nextInt excludes last value + int next = s_rand.nextInt(range); //note: nextInt excludes last value long ip = startIp + next; for (Long avoidable : avoid) { if (ip >= avoidable) { @@ -1234,9 +1234,9 @@ public class NetUtils { String startIp = ips[0]; IPv6Address start = IPv6Address.fromString(startIp); BigInteger gap = countIp6InRange(ip6Range); - BigInteger next = new BigInteger(gap.bitLength(), _rand); + BigInteger next = new BigInteger(gap.bitLength(), s_rand); while (next.compareTo(gap) >= 0) { - next = new BigInteger(gap.bitLength(), _rand); + next = new BigInteger(gap.bitLength(), s_rand); } BigInteger startInt = convertIPv6AddressToBigInteger(start); BigInteger resultInt = startInt.add(next); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/utils/src/com/cloud/utils/nio/Link.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/nio/Link.java b/utils/src/com/cloud/utils/nio/Link.java index e20210d..dfeb9dc 100755 --- a/utils/src/com/cloud/utils/nio/Link.java +++ b/utils/src/com/cloud/utils/nio/Link.java @@ -150,7 +150,7 @@ public class Link { pkgBuf.clear(); engResult = sslEngine.wrap(buffers, pkgBuf); if (engResult.getHandshakeStatus() != HandshakeStatus.FINISHED && engResult.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING && - engResult.getStatus() != SSLEngineResult.Status.OK) { + engResult.getStatus() != SSLEngineResult.Status.OK) { throw new IOException("SSL: SSLEngine return bad result! " + engResult); } @@ -276,7 +276,7 @@ public class Link { appBuf = ByteBuffer.allocate(sslSession.getApplicationBufferSize() + 40); engResult = _sslEngine.unwrap(_readBuffer, appBuf); if (engResult.getHandshakeStatus() != HandshakeStatus.FINISHED && engResult.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING && - engResult.getStatus() != SSLEngineResult.Status.OK) { + engResult.getStatus() != SSLEngineResult.Status.OK) { throw new IOException("SSL: SSLEngine return bad result! " + engResult); } if (remaining == _readBuffer.remaining()) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/utils/src/com/cloud/utils/security/CertificateHelper.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/security/CertificateHelper.java b/utils/src/com/cloud/utils/security/CertificateHelper.java index 5d8f6ad..64ba8bf 100644 --- a/utils/src/com/cloud/utils/security/CertificateHelper.java +++ b/utils/src/com/cloud/utils/security/CertificateHelper.java @@ -114,7 +114,7 @@ public class CertificateHelper { return kf.generatePrivate(keysp); } - public static List<Certificate> parseChain(String chain) throws IOException { + public static List<Certificate> parseChain(String chain) throws IOException { List<Certificate> certs = new ArrayList<Certificate>(); PEMReader reader = new PEMReader(new StringReader(chain)); @@ -160,6 +160,4 @@ public class CertificateHelper { return buffer.toString(); } - - } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/utils/src/com/cloud/utils/ssh/SSHCmdHelper.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/ssh/SSHCmdHelper.java b/utils/src/com/cloud/utils/ssh/SSHCmdHelper.java index 8b63c51..ebd65f5 100644 --- a/utils/src/com/cloud/utils/ssh/SSHCmdHelper.java +++ b/utils/src/com/cloud/utils/ssh/SSHCmdHelper.java @@ -62,7 +62,7 @@ public class SSHCmdHelper { try { if (sshExecuteCmdOneShot(sshConnection, cmd)) return true; - } catch (sshException e) { + } catch (SshException e) { continue; } } @@ -77,7 +77,7 @@ public class SSHCmdHelper { for (int i = 0; i < nTimes; i++) { try { return sshExecuteCmdOneShotWithExitCode(sshConnection, cmd); - } catch (sshException e) { + } catch (SshException e) { continue; } } @@ -88,7 +88,7 @@ public class SSHCmdHelper { return sshExecuteCmd(sshConnection, cmd, 3); } - public static int sshExecuteCmdOneShotWithExitCode(com.trilead.ssh2.Connection sshConnection, String cmd) throws sshException { + public static int sshExecuteCmdOneShotWithExitCode(com.trilead.ssh2.Connection sshConnection, String cmd) throws SshException { s_logger.debug("Executing cmd: " + cmd); Session sshSession = null; try { @@ -98,7 +98,7 @@ public class SSHCmdHelper { Thread.sleep(1000); if (sshSession == null) { - throw new sshException("Cannot open ssh session"); + throw new SshException("Cannot open ssh session"); } sshSession.execCommand(cmd); @@ -109,7 +109,7 @@ public class SSHCmdHelper { byte[] buffer = new byte[8192]; while (true) { if (stdout == null || stderr == null) { - throw new sshException("stdout or stderr of ssh session is null"); + throw new SshException("stdout or stderr of ssh session is null"); } if ((stdout.available() == 0) && (stderr.available() == 0)) { @@ -143,14 +143,14 @@ public class SSHCmdHelper { return sshSession.getExitStatus(); } catch (Exception e) { s_logger.debug("Ssh executed failed", e); - throw new sshException("Ssh executed failed " + e.getMessage()); + throw new SshException("Ssh executed failed " + e.getMessage()); } finally { if (sshSession != null) sshSession.close(); } } - public static boolean sshExecuteCmdOneShot(com.trilead.ssh2.Connection sshConnection, String cmd) throws sshException { + public static boolean sshExecuteCmdOneShot(com.trilead.ssh2.Connection sshConnection, String cmd) throws SshException { return sshExecuteCmdOneShotWithExitCode(sshConnection, cmd) == 0; } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/utils/src/com/cloud/utils/ssh/SshException.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/ssh/SshException.java b/utils/src/com/cloud/utils/ssh/SshException.java new file mode 100644 index 0000000..7c9d35c --- /dev/null +++ b/utils/src/com/cloud/utils/ssh/SshException.java @@ -0,0 +1,27 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.utils.ssh; + +import com.cloud.utils.SerialVersionUID; + +public class SshException extends Exception { + private static final long serialVersionUID = SerialVersionUID.sshException; + + public SshException(String msg) { + super(msg); + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/utils/src/com/cloud/utils/ssh/SshHelper.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/ssh/SshHelper.java b/utils/src/com/cloud/utils/ssh/SshHelper.java index e482a80..41625eb 100755 --- a/utils/src/com/cloud/utils/ssh/SshHelper.java +++ b/utils/src/com/cloud/utils/ssh/SshHelper.java @@ -27,8 +27,8 @@ import com.trilead.ssh2.ChannelCondition; import com.cloud.utils.Pair; public class SshHelper { - private static int DEFAULT_CONNECT_TIMEOUT = 60000; - private static int DEFAULT_KEX_TIMEOUT = 60000; + private static final int DEFAULT_CONNECT_TIMEOUT = 60000; + private static final int DEFAULT_KEX_TIMEOUT = 60000; private static final Logger s_logger = Logger.getLogger(SshHelper.class); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/utils/src/com/cloud/utils/ssh/sshException.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/ssh/sshException.java b/utils/src/com/cloud/utils/ssh/sshException.java deleted file mode 100644 index ca3cbb6..0000000 --- a/utils/src/com/cloud/utils/ssh/sshException.java +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.utils.ssh; - -import com.cloud.utils.SerialVersionUID; - -public class sshException extends Exception { - private static final long serialVersionUID = SerialVersionUID.sshException; - - public sshException(String msg) { - super(msg); - } -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/utils/src/org/apache/cloudstack/utils/identity/ManagementServerNode.java ---------------------------------------------------------------------- diff --git a/utils/src/org/apache/cloudstack/utils/identity/ManagementServerNode.java b/utils/src/org/apache/cloudstack/utils/identity/ManagementServerNode.java index 6149eaf..7dee846 100755 --- a/utils/src/org/apache/cloudstack/utils/identity/ManagementServerNode.java +++ b/utils/src/org/apache/cloudstack/utils/identity/ManagementServerNode.java @@ -28,7 +28,7 @@ import com.cloud.utils.net.MacAddress; @Local(value = {SystemIntegrityChecker.class}) public class ManagementServerNode extends AdapterBase implements SystemIntegrityChecker { - private final Logger s_logger = Logger.getLogger(ManagementServerNode.class); + private static final Logger s_logger = Logger.getLogger(ManagementServerNode.class); private static final long s_nodeId = MacAddress.getMacAddress().toLong(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java index 20e5b26..771c4a5 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java @@ -111,7 +111,7 @@ import com.cloud.utils.script.Script; public class VirtualMachineMO extends BaseMO { private static final Logger s_logger = Logger.getLogger(VirtualMachineMO.class); - private static final ExecutorService _monitorServiceExecutor = Executors.newCachedThreadPool(new NamedThreadFactory("VM-Question-Monitor")); + private static final ExecutorService MonitorServiceExecutor = Executors.newCachedThreadPool(new NamedThreadFactory("VM-Question-Monitor")); private ManagedObjectReference _vmEnvironmentBrowser = null; public VirtualMachineMO(VmwareContext context, ManagedObjectReference morVm) { @@ -1238,7 +1238,7 @@ public class VirtualMachineMO extends BaseMO { // Monitor VM questions final Boolean[] flags = {false}; final VirtualMachineMO vmMo = this; - Future<?> future = _monitorServiceExecutor.submit(new Runnable() { + Future<?> future = MonitorServiceExecutor.submit(new Runnable() { @Override public void run() { s_logger.info("VM Question monitor started..."); @@ -2334,7 +2334,7 @@ public class VirtualMachineMO extends BaseMO { // Monitor VM questions final Boolean[] flags = {false}; final VirtualMachineMO vmMo = this; - Future<?> future = _monitorServiceExecutor.submit(new Runnable() { + Future<?> future = MonitorServiceExecutor.submit(new Runnable() { @Override public void run() { s_logger.info("VM Question monitor started..."); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java index 9ecd987..0a44a72 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java @@ -79,19 +79,19 @@ public class VmwareClient { } static { - try { - trustAllHttpsCertificates(); - HostnameVerifier hv = new HostnameVerifier() { - @Override - public boolean verify(String urlHostName, SSLSession session) { - return true; - } - }; - HttpsURLConnection.setDefaultHostnameVerifier(hv); - - vimService = new VimService(); - } catch (Exception e) { - } + try { + trustAllHttpsCertificates(); + HostnameVerifier hv = new HostnameVerifier() { + @Override + public boolean verify(String urlHostName, SSLSession session) { + return true; + } + }; + HttpsURLConnection.setDefaultHostnameVerifier(hv); + + vimService = new VimService(); + } catch (Exception e) { + } } private static void trustAllHttpsCertificates() throws Exception { @@ -106,11 +106,11 @@ public class VmwareClient { javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } - private ManagedObjectReference SVC_INST_REF = new ManagedObjectReference(); + private final ManagedObjectReference svcInstRef = new ManagedObjectReference(); private static VimService vimService; private VimPortType vimPort; private String serviceCookie; - private final String SVC_INST_NAME = "ServiceInstance"; + private final static String SVC_INST_NAME = "ServiceInstance"; private int vCenterSessionTimeout = 1200000; // Timeout in milliseconds private boolean isConnected = false; @@ -125,8 +125,8 @@ public class VmwareClient { * the exception */ public void connect(String url, String userName, String password) throws Exception { - SVC_INST_REF.setType(SVC_INST_NAME); - SVC_INST_REF.setValue(SVC_INST_NAME); + svcInstRef.setType(SVC_INST_NAME); + svcInstRef.setValue(SVC_INST_NAME); vimPort = vimService.getVimPort(); Map<String, Object> ctxt = ((BindingProvider)vimPort).getRequestContext(); @@ -137,7 +137,7 @@ public class VmwareClient { ctxt.put("com.sun.xml.internal.ws.request.timeout", vCenterSessionTimeout); ctxt.put("com.sun.xml.internal.ws.connect.timeout", vCenterSessionTimeout); - ServiceContent serviceContent = vimPort.retrieveServiceContent(SVC_INST_REF); + ServiceContent serviceContent = vimPort.retrieveServiceContent(svcInstRef); // Extract a cookie. See vmware sample program com.vmware.httpfileaccess.GetVMFiles Map<String, List<String>> headers = (Map<String, List<String>>)((BindingProvider)vimPort).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS); @@ -177,7 +177,7 @@ public class VmwareClient { public ServiceContent getServiceContent() { try { - return vimPort.retrieveServiceContent(SVC_INST_REF); + return vimPort.retrieveServiceContent(svcInstRef); } catch (RuntimeFaultFaultMsg e) { } return null; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java index 44d9f0c..4c3ff55 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java @@ -57,10 +57,10 @@ import com.cloud.utils.ActionDelegate; public class VmwareContext { private static final Logger s_logger = Logger.getLogger(VmwareContext.class); - private static int MAX_CONNECT_RETRY = 5; - private static int CONNECT_RETRY_INTERVAL = 1000; + private static final int MAX_CONNECT_RETRY = 5; + private static final int CONNECT_RETRY_INTERVAL = 1000; - private final int _CHUNKSIZE = 1 * 1024 * 1024; // 1M + private static final int ChunkSize = 1 * 1024 * 1024; // 1M private final VmwareClient _vimClient; private final String _serverAddress; @@ -327,7 +327,7 @@ public class VmwareContext { InputStream in = conn.getInputStream(); OutputStream out = new FileOutputStream(new File(localFileFullName)); - byte[] buf = new byte[_CHUNKSIZE]; + byte[] buf = new byte[ChunkSize]; int len = 0; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); @@ -349,7 +349,7 @@ public class VmwareContext { try { out = conn.getOutputStream(); in = new FileInputStream(localFile); - byte[] buf = new byte[_CHUNKSIZE]; + byte[] buf = new byte[ChunkSize]; int len = 0; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); @@ -381,7 +381,7 @@ public class VmwareContext { conn.setDoOutput(true); conn.setUseCaches(false); - conn.setChunkedStreamingMode(_CHUNKSIZE); + conn.setChunkedStreamingMode(ChunkSize); conn.setRequestMethod(httpMethod); conn.setRequestProperty("Connection", "Keep-Alive"); conn.setRequestProperty("Content-Type", "application/x-vnd.vmware-streamVmdk"); @@ -393,7 +393,7 @@ public class VmwareContext { try { bos = new BufferedOutputStream(conn.getOutputStream()); is = new BufferedInputStream(new FileInputStream(localFileName)); - int bufferSize = _CHUNKSIZE; + int bufferSize = ChunkSize; byte[] buffer = new byte[bufferSize]; while (true) { int bytesRead = is.read(buffer, 0, bufferSize); @@ -438,7 +438,7 @@ public class VmwareContext { in = conn.getInputStream(); out = new FileOutputStream(new File(localFileName)); - byte[] buf = new byte[_CHUNKSIZE]; + byte[] buf = new byte[ChunkSize]; int len = 0; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); @@ -464,7 +464,7 @@ public class VmwareContext { InputStream in = conn.getInputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream(); - byte[] buf = new byte[_CHUNKSIZE]; + byte[] buf = new byte[ChunkSize]; int len = 0; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len);