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 2013/11/07 15:10:18 UTC

[5/5] git commit: updated refs/heads/master to 85f38b3

Fix CID 1127051 DLS: Dead local store
Fix CID 1127050 WMI: Inefficient Map iterator



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

Branch: refs/heads/master
Commit: 85f38b3e07bf6bb0419392f2b4d4438c796327f9
Parents: 831eeeb
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Thu Nov 7 15:01:21 2013 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Thu Nov 7 15:01:21 2013 +0100

----------------------------------------------------------------------
 .../configuration/ConfigurationManagerImpl.java | 123 +++++++++----------
 1 file changed, 61 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/85f38b3e/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index e4bbe8e..c3a196f 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -28,6 +28,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.UUID;
 
@@ -35,6 +36,8 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.acl.SecurityChecker;
 import org.apache.cloudstack.affinity.AffinityGroup;
 import org.apache.cloudstack.affinity.AffinityGroupService;
@@ -79,10 +82,8 @@ import org.apache.cloudstack.region.Region;
 import org.apache.cloudstack.region.RegionVO;
 import org.apache.cloudstack.region.dao.RegionDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
-import org.apache.log4j.Logger;
 
 import com.cloud.alert.AlertManager;
 import com.cloud.api.ApiDBUtils;
@@ -95,7 +96,6 @@ import com.cloud.dc.ClusterDetailsVO;
 import com.cloud.dc.ClusterVO;
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
-import com.cloud.dc.DataCenterDetailVO;
 import com.cloud.dc.DataCenterIpAddressVO;
 import com.cloud.dc.DataCenterLinkLocalIpAddressVO;
 import com.cloud.dc.DataCenterVO;
@@ -207,7 +207,7 @@ import com.cloud.vm.dao.NicSecondaryIpDao;
 
 @Local(value = { ConfigurationManager.class, ConfigurationService.class })
 public class
-        ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService {
+ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService {
     public static final Logger s_logger = Logger.getLogger(ConfigurationManagerImpl.class);
 
     @Inject
@@ -407,16 +407,16 @@ public class
                 _alertMgr.sendAlert(AlertManager.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0),
                         "Management network CIDR is not configured originally. Set it default to " + localCidrs[0], "");
                 _configDao
-                        .update(Config.ManagementNetwork.key(), Config.ManagementNetwork.getCategory(), localCidrs[0]);
+                .update(Config.ManagementNetwork.key(), Config.ManagementNetwork.getCategory(), localCidrs[0]);
             } else {
                 s_logger.warn("Management network CIDR is not properly configured and we are not able to find a default setting");
                 _alertMgr
-                        .sendAlert(
-                                AlertManager.ALERT_TYPE_MANAGMENT_NODE,
-                                0,
-                                new Long(0),
-                                "Management network CIDR is not properly configured and we are not able to find a default setting",
-                                "");
+                .sendAlert(
+                        AlertManager.ALERT_TYPE_MANAGMENT_NODE,
+                        0,
+                        new Long(0),
+                        "Management network CIDR is not properly configured and we are not able to find a default setting",
+                        "");
             }
         }
 
@@ -475,7 +475,7 @@ public class
                     throw new InvalidParameterValueException("unable to find storage pool by id " + resourceId);
                 }
                 _storagePoolDetailsDao.addDetail(resourceId, name, value);
-                
+
                 break;
 
             case Account:
@@ -1200,7 +1200,7 @@ public class
                         _capacityDao.updateCapacityState(null, pod.getId(), null, null, allocationStateStrFinal);
                         pod.setAllocationState(allocationState);
                     }
-        
+
                     _podDao.update(id, pod);
                 }
             });
@@ -1679,8 +1679,8 @@ public class
         boolean checkForDuplicates = !zoneName.equals(oldZoneName);
         checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, checkForDuplicates, null,
                 allocationStateStr, ip6Dns1, ip6Dns2);// not allowing updating
-                                                      // domain associated with
-                                                      // a zone, once created
+        // domain associated with
+        // a zone, once created
 
         zone.setName(zoneName);
         zone.setDns1(dns1);
@@ -1712,10 +1712,10 @@ public class
                 }
                 updatedDetails.putAll(newDetails);
                 zone.setDetails(updatedDetails);
-        
+
                 if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
                     Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr);
-        
+
                     if (allocationState == Grouping.AllocationState.Enabled) {
                         // check if zone has necessary trafficTypes before enabling
                         try {
@@ -1729,7 +1729,7 @@ public class
                                 // network with public Thpe
                                 _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Public);
                             }
-        
+
                             try {
                                 _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Storage);
                             } catch (InvalidParameterValueException noStorage) {
@@ -1976,7 +1976,7 @@ public class
 
         return createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, guestCidr,
                 domainVO != null ? domainVO.getName() : null, domainId, zoneType, allocationState, networkDomain,
-                isSecurityGroupEnabled, isLocalStorageEnabled, ip6Dns1, ip6Dns2);
+                        isSecurityGroupEnabled, isLocalStorageEnabled, ip6Dns1, ip6Dns2);
     }
 
     @Override
@@ -1999,7 +1999,6 @@ public class
         Integer cpuNumber = cmd.getCpuNumber();
         Integer cpuSpeed = cmd.getCpuSpeed();
         Integer memory = cmd.getMemory();
-        boolean customized = cmd.getCustomized();
 
         if ((cpuNumber != null) && ((cpuNumber.intValue() <=0) || (cpuNumber.intValue() > 2147483647))) {
             throw new InvalidParameterValueException("Failed to create service offering " + name
@@ -2101,10 +2100,10 @@ public class
         if ((offering = _serviceOfferingDao.persist(offering)) != null) {
             if (details != null) {
                 List<ServiceOfferingDetailsVO> detailsVO = new ArrayList<ServiceOfferingDetailsVO>();
-                for (String key : details.keySet()) {
-                    detailsVO.add(new ServiceOfferingDetailsVO(offering.getId(), key, details.get(key)));
+                for (Entry<String, String> detailEntry : details.entrySet()) {
+                    detailsVO.add(new ServiceOfferingDetailsVO(offering.getId(), detailEntry.getKey(), detailEntry.getValue()));
                 }
-                
+
                 _serviceOfferingDetailsDao.saveDetails(detailsVO);
             }
             CallContext.current().setEventDetails("Service offering id=" + offering.getId());
@@ -2187,8 +2186,8 @@ public class
     }
 
     protected DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized,
-    		boolean localStorageRequired, boolean isDisplayOfferingEnabled, Boolean isCustomizedIops, Long minIops, Long maxIops,
-    		Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate, Integer hypervisorSnapshotReserve) {
+            boolean localStorageRequired, boolean isDisplayOfferingEnabled, Boolean isCustomizedIops, Long minIops, Long maxIops,
+            Long bytesReadRate, Long bytesWriteRate, Long iopsReadRate, Long iopsWriteRate, Integer hypervisorSnapshotReserve) {
         long diskSize = 0;// special case for custom disk offerings
         if (numGibibytes != null && (numGibibytes <= 0)) {
             throw new InvalidParameterValueException("Please specify a disk size of at least 1 Gb.");
@@ -2211,8 +2210,8 @@ public class
             iopsWriteRate = null;
 
             if (isCustomizedIops) {
-            	minIops = null;
-            	maxIops = null;
+                minIops = null;
+                maxIops = null;
             }
             else {
                 if (minIops == null && maxIops == null) {
@@ -2220,17 +2219,17 @@ public class
                     maxIops = 0L;
                 }
                 else {
-                	if (minIops == null || minIops <= 0) {
-                	    throw new InvalidParameterValueException("The min IOPS must be greater than 0.");
-        	        }
+                    if (minIops == null || minIops <= 0) {
+                        throw new InvalidParameterValueException("The min IOPS must be greater than 0.");
+                    }
 
-                	if (maxIops == null) {
-        	        	maxIops = 0L;
-        	        }
+                    if (maxIops == null) {
+                        maxIops = 0L;
+                    }
 
-                	if (minIops > maxIops) {
-                		throw new InvalidParameterValueException("The min IOPS must be less than or equal to the max IOPS.");
-                	}
+                    if (minIops > maxIops) {
+                        throw new InvalidParameterValueException("The min IOPS must be less than or equal to the max IOPS.");
+                    }
                 }
             }
         }
@@ -2241,7 +2240,7 @@ public class
 
         tags = StringUtils.cleanupTags(tags);
         DiskOfferingVO newDiskOffering = new DiskOfferingVO(domainId, name, description, diskSize, tags, isCustomized,
-        		isCustomizedIops, minIops, maxIops);
+                isCustomizedIops, minIops, maxIops);
         newDiskOffering.setUseLocalStorage(localStorageRequired);
         newDiskOffering.setDisplayOffering(isDisplayOfferingEnabled);
 
@@ -2278,8 +2277,8 @@ public class
         Long numGibibytes = cmd.getDiskSize();
         boolean isDisplayOfferingEnabled = cmd.getDisplayOffering() != null ? cmd.getDisplayOffering() : true;
         boolean isCustomized = cmd.isCustomized() != null ? cmd.isCustomized() : false; // false
-                                                                                        // by
-                                                                                        // default
+        // by
+        // default
         String tags = cmd.getTags();
         // Long domainId = cmd.getDomainId() != null ? cmd.getDomainId() :
         // Long.valueOf(DomainVO.ROOT_DOMAIN); // disk offering
@@ -2441,9 +2440,9 @@ public class
     @Override
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_VLAN_IP_RANGE_CREATE, eventDescription = "creating vlan ip range",
-            async = false)
+    async = false)
     public Vlan createVlanAndPublicIpRange(CreateVlanIpRangeCmd cmd) throws InsufficientCapacityException,
-            ConcurrentOperationException, ResourceUnavailableException, ResourceAllocationException {
+    ConcurrentOperationException, ResourceUnavailableException, ResourceAllocationException {
         Long zoneId = cmd.getZoneId();
         Long podId = cmd.getPodId();
         String startIP = cmd.getStartIp();
@@ -2453,8 +2452,8 @@ public class
         String vlanId = cmd.getVlan();
         // TODO decide if we should be forgiving or demand a valid and complete URI
         if (!((vlanId == null)
-            || ("".equals(vlanId))
-            || vlanId.startsWith(BroadcastDomainType.Vlan.scheme())))
+                || ("".equals(vlanId))
+                || vlanId.startsWith(BroadcastDomainType.Vlan.scheme())))
             vlanId = BroadcastDomainType.Vlan.toUri(vlanId).toString();
         Boolean forVirtualNetwork = cmd.isForVirtualNetwork();
         Long networkId = cmd.getNetworkID();
@@ -2690,12 +2689,12 @@ public class
             public Vlan doInTransaction(TransactionStatus status) {
                 String newVlanNetmask = newVlanNetmaskFinal;
                 String newVlanGateway = newVlanGatewayFinal;
-                
+
                 if ((sameSubnet == null || sameSubnet.first() == false) && (network.getTrafficType()== TrafficType.Guest) && (network.getGuestType() == GuestType.Shared) && (_vlanDao.listVlansByNetworkId(networkId) != null)) {
                     Map<Capability, String> dhcpCapabilities = _networkSvc.getNetworkOfferingServiceCapabilities(_networkOfferingDao.findById(network.getNetworkOfferingId()), Service.Dhcp);
                     String supportsMultipleSubnets = dhcpCapabilities.get(Capability.DhcpAccrossMultipleSubnets);
                     if (supportsMultipleSubnets == null || !Boolean.valueOf(supportsMultipleSubnets)) {
-                               throw new  InvalidParameterValueException("The Dhcp serivice provider for this network dose not support the dhcp  across multiple subnets");
+                        throw new  InvalidParameterValueException("The Dhcp serivice provider for this network dose not support the dhcp  across multiple subnets");
                     }
                     s_logger.info("adding a new subnet to the network " + network.getId());
                 } else if (sameSubnet != null)  {
@@ -2776,7 +2775,7 @@ public class
                         sameSubnet = true;
                         //check if the gateway provided by the user is same as that of the subnet.
                         if (newVlanGateway != null && !newVlanGateway.equals(vlanGateway)) {
-                             throw new InvalidParameterValueException("The gateway of the subnet should be unique. The subnet alreaddy has a gateway "+ vlanGateway);
+                            throw new InvalidParameterValueException("The gateway of the subnet should be unique. The subnet alreaddy has a gateway "+ vlanGateway);
                         }
                         break;
                     }
@@ -2982,7 +2981,7 @@ public class
                     throw new InvalidParameterValueException("This subnet is overlapped with subnet in other network " + vlan.getNetworkId()
                             + " in zone " + zone.getName()
                             + " . Please specify a different gateway/netmask.");
-                   
+
                 }
                 String[] otherVlanIpRange = vlan.getIpRange().split("\\-");
                 String otherVlanStartIP = otherVlanIpRange[0];
@@ -2999,7 +2998,7 @@ public class
                 }
                 if (NetUtils.ipRangesOverlap(startIP, endIP, otherVlanStartIP, otherVlanEndIP)) {
                     throw new InvalidParameterValueException("The IP range already has IPs that overlap with the new range." +
-                    		" Please specify a different start IP/end IP.");
+                            " Please specify a different start IP/end IP.");
                 }
             }
         }
@@ -3202,7 +3201,7 @@ public class
     @Override
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_VLAN_IP_RANGE_DEDICATE, eventDescription = "dedicating vlan ip range",
-            async = false)
+    async = false)
     public Vlan dedicatePublicIpRange(DedicatePublicIpRangeCmd cmd) throws ResourceAllocationException {
         Long vlanDbId = cmd.getId();
         String accountName = cmd.getAccountName();
@@ -3291,7 +3290,7 @@ public class
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_VLAN_IP_RANGE_RELEASE, eventDescription = "releasing a public ip range",
-            async = false)
+    async = false)
     public boolean releasePublicIpRange(ReleasePublicIpRangeCmd cmd) {
         Long vlanDbId = cmd.getId();
 
@@ -3425,7 +3424,7 @@ public class
     }
 
     private void checkConflictsWithPortableIpRange(long zoneId, String vlanId, String vlanGateway, String vlanNetmask,
-                                          String startIP, String endIP) {
+            String startIP, String endIP) {
         // check and throw exception if there is portable IP range that overlaps with public ip range being configured
         if (checkOverlapPortableIpRange(_regionDao.getRegionId(), startIP, endIP)) {
             throw new InvalidParameterValueException("Ip range: " + startIP + "-" + endIP
@@ -3549,7 +3548,7 @@ public class
                     if (podName.equals("newPod")) {
                         throw new InvalidParameterValueException(
                                 "The subnet of the pod you are adding conflicts with the subnet of pod " + otherPodName
-                                        + " in zone " + zoneName + ". Please specify a different CIDR.");
+                                + " in zone " + zoneName + ". Please specify a different CIDR.");
                     } else {
                         throw new InvalidParameterValueException("Warning: The pods " + podName + " and "
                                 + otherPodName + " in zone " + zoneName
@@ -3610,7 +3609,7 @@ public class
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_VLAN_IP_RANGE_DELETE, eventDescription = "deleting vlan ip range",
-            async = false)
+    async = false)
     public boolean deleteVlanIpRange(DeleteVlanIpRangeCmd cmd) {
         Long vlanDbId = cmd.getId();
 
@@ -3802,7 +3801,7 @@ public class
                         if (provider == Provider.PaloAlto) {
                             firewallProvider = Provider.PaloAlto;
                         }
-                        
+
                         if ((service == Service.PortForwarding || service == Service.StaticNat)
                                 && provider == Provider.VirtualRouter) {
                             firewallProvider = Provider.VirtualRouter;
@@ -3840,7 +3839,7 @@ public class
                     "Capabilities for LB service can be specifed only when LB service is enabled for network offering.");
         }
         validateLoadBalancerServiceCapabilities(lbServiceCapabilityMap);
-        
+
         if (lbServiceCapabilityMap != null && !lbServiceCapabilityMap.isEmpty()) {
             maxconn = cmd.getMaxconnections();
             if (maxconn == null) {
@@ -3850,7 +3849,7 @@ public class
         if(cmd.getKeepAliveEnabled() != null && cmd.getKeepAliveEnabled()) {
             enableKeepAlive = true;
         }
-        
+
         // validate the Source NAT service capabilities specified in the network
         // offering
         Map<Capability, String> sourceNatServiceCapabilityMap = cmd.getServiceCapabilities(Service.SourceNat);
@@ -4164,7 +4163,7 @@ public class
                 }
             }
         }
-        
+
         if (serviceProviderMap != null && serviceProviderMap.containsKey(Service.Lb) && !internalLb && !publicLb) {
             //if not specified, default public lb to true
             publicLb = true;
@@ -4626,7 +4625,7 @@ public class
         }
         if (_ntwkOffServiceMapDao.areServicesSupportedByNetworkOffering(offering.getId(), Service.Lb)){
             if (maxconn != null) {
-                 offering.setConcurrentConnections(maxconn);
+                offering.setConcurrentConnections(maxconn);
             }
         }
 
@@ -4845,7 +4844,7 @@ public class
     @Override
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_PORTABLE_IP_RANGE_CREATE,
-            eventDescription = "creating portable ip range", async = false)
+    eventDescription = "creating portable ip range", async = false)
     public PortableIpRange createPortableIpRange(CreatePortableIpRangeCmd cmd) throws ConcurrentOperationException {
         final Integer regionId = cmd.getRegionId();
         final String startIP = cmd.getStartIp();
@@ -4920,7 +4919,7 @@ public class
                     // implicitly enable portable IP service for the region
                     region.setPortableipEnabled(true);
                     _regionDao.update(region.getId(), region);
-                    
+
                     return portableIpRange;
                 }
             });
@@ -4932,7 +4931,7 @@ public class
     @Override
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_PORTABLE_IP_RANGE_DELETE,
-            eventDescription = "deleting portable ip range", async = false)
+    eventDescription = "deleting portable ip range", async = false)
     public boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd) {
         long rangeId = cmd.getId();
 
@@ -5032,7 +5031,7 @@ public class
 
     @Inject
     public void setSecChecker(List<SecurityChecker> secChecker) {
-        this._secChecker = secChecker;
+        _secChecker = secChecker;
     }