diff --git a/api/src/com/cloud/offering/NetworkOffering.java b/api/src/com/cloud/offering/NetworkOffering.java index 43312db0d18..6c5573e0368 100644 --- a/api/src/com/cloud/offering/NetworkOffering.java +++ b/api/src/com/cloud/offering/NetworkOffering.java @@ -129,4 +129,5 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity, boolean getPublicLb(); boolean getEgressDefaultPolicy(); + Integer getConcurrentConnections(); } diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java index 83999b6d8f3..0550a39a0ba 100755 --- a/api/src/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/org/apache/cloudstack/api/ApiConstants.java @@ -518,6 +518,7 @@ public class ApiConstants { public static final String NUMBER = "number"; public static final String IS_DYNAMICALLY_SCALABLE = "isdynamicallyscalable"; public static final String ROUTING = "isrouting"; + public static final String MAX_CONNECTIONS = "maxconnections"; public enum HostDetails { all, capacity, events, stats, min; diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java index 94e263c2d39..bdad904c1dd 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java @@ -102,6 +102,9 @@ public class CreateNetworkOfferingCmd extends BaseCmd { @Parameter(name=ApiConstants.EGRESS_DEFAULT_POLICY, type=CommandType.BOOLEAN, description="true if default guest network egress policy is allow; false if default egress policy is deny") private Boolean egressDefaultPolicy; + @Parameter(name=ApiConstants.MAX_CONNECTIONS, type=CommandType.INTEGER, description="maximum number of concurrent connections supported by the network offering") + private Integer maxConnections; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -172,6 +175,10 @@ public class CreateNetworkOfferingCmd extends BaseCmd { return egressDefaultPolicy; } + public Integer getMaxconnections() { + return maxConnections; + } + public Map> getServiceProviders() { Map> serviceProviderMap = null; if (serviceProviderList != null && !serviceProviderList.isEmpty()) { diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkOfferingCmd.java index ba685a94995..c9c4c8ad3b4 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkOfferingCmd.java @@ -57,6 +57,9 @@ public class UpdateNetworkOfferingCmd extends BaseCmd { @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="update state for the network offering") private String state; + @Parameter(name=ApiConstants.MAX_CONNECTIONS, type=CommandType.INTEGER, description="maximum number of concurrent connections supported by the network offering") + private Integer maxConnections; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -85,6 +88,9 @@ public class UpdateNetworkOfferingCmd extends BaseCmd { return sortKey; } + public Integer getMaxconnections() { + return maxConnections; + } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/core/src/com/cloud/agent/api/routing/LoadBalancerConfigCommand.java b/core/src/com/cloud/agent/api/routing/LoadBalancerConfigCommand.java index 1c1fb914da3..ee29290b720 100644 --- a/core/src/com/cloud/agent/api/routing/LoadBalancerConfigCommand.java +++ b/core/src/com/cloud/agent/api/routing/LoadBalancerConfigCommand.java @@ -32,6 +32,7 @@ public class LoadBalancerConfigCommand extends NetworkElementCommand { public String lbStatsSrcCidrs = "0/0" ; /* TODO : currently there is no filtering based on the source ip */ public String lbStatsAuth = "admin1:AdMiN123"; public String lbStatsUri = "/admin?stats"; + public String maxconn =""; NicTO nic; Long vpcId; @@ -43,13 +44,14 @@ public class LoadBalancerConfigCommand extends NetworkElementCommand { this.vpcId = vpcId; } - public LoadBalancerConfigCommand(LoadBalancerTO[] loadBalancers,String PublicIp,String GuestIp,String PrivateIp, NicTO nic, Long vpcId) { + public LoadBalancerConfigCommand(LoadBalancerTO[] loadBalancers,String PublicIp,String GuestIp,String PrivateIp, NicTO nic, Long vpcId, String maxconn) { this.loadBalancers = loadBalancers; this.lbStatsPublicIP = PublicIp; this.lbStatsPrivateIP = PrivateIp; this.lbStatsGuestIP = GuestIp; this.nic = nic; this.vpcId = vpcId; + this.maxconn=maxconn; } public NicTO getNic() { diff --git a/core/src/com/cloud/network/HAProxyConfigurator.java b/core/src/com/cloud/network/HAProxyConfigurator.java index 162571fa689..230912595cf 100644 --- a/core/src/com/cloud/network/HAProxyConfigurator.java +++ b/core/src/com/cloud/network/HAProxyConfigurator.java @@ -528,8 +528,9 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator { @Override public String[] generateConfiguration(LoadBalancerConfigCommand lbCmd) { List result = new ArrayList(); - - result.addAll(Arrays.asList(globalSection)); + List gSection = Arrays.asList(globalSection); + gSection.set(2,"\tmaxconn " + lbCmd.maxconn); + result.addAll(gSection); result.add(blankLine); result.addAll(Arrays.asList(defaultsSection)); if (!lbCmd.lbStatsVisibility.equals("disabled")) { diff --git a/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java b/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java index 6317f72d0df..f8f25ea2582 100755 --- a/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java +++ b/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java @@ -133,6 +133,9 @@ public class NetworkOfferingVO implements NetworkOffering { @Column(name = "egress_default_policy") boolean egressdefaultpolicy; + @Column(name = "concurrent_connections") + Integer concurrent_connections; + @Override public String getDisplayText() { return displayText; @@ -426,4 +429,11 @@ public class NetworkOfferingVO implements NetworkOffering { this.internalLb = internalLb; } + public Integer getConcurrentConnections() { + return this.concurrent_connections; + } + + public void setConcurrentConnections(Integer concurrent_connections) { + this.concurrent_connections = concurrent_connections; + } } diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java index 9c34a8bc44b..3e2cbbe4863 100644 --- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java +++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java @@ -303,8 +303,16 @@ ElasticLoadBalancerManager, VirtualMachineGuru { lbs[i++] = lb; } + NetworkOffering offering =_networkOfferingDao.findById(guestNetworkId); + String maxconn= null; + if (offering.getConcurrentConnections() == null) { + maxconn = _configDao.getValue(Config.NetworkLBHaproxyMaxConn.key()); + } + else { + maxconn = offering.getConcurrentConnections().toString(); + } LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs,elbVm.getPublicIpAddress(), - _nicDao.getIpAddress(guestNetworkId, elbVm.getId()),elbVm.getPrivateIpAddress(), null, null); + _nicDao.getIpAddress(guestNetworkId, elbVm.getId()),elbVm.getPrivateIpAddress(), null, null, maxconn); cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, elbVm.getPrivateIpAddress()); cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java index 5d6a6718362..e027ec3c25e 100644 --- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java +++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java @@ -482,9 +482,17 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements _ntwkModel.isSecurityGroupSupportedInNetwork(guestNetwork), _ntwkModel.getNetworkTag(internalLbVm.getHypervisorType(), guestNetwork)); - LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs, guestNic.getIp4Address(), + NetworkOffering offering =_networkOfferingDao.findById(guestNetworkId); + String maxconn= null; + if (offering.getConcurrentConnections() == null) { + maxconn = _configDao.getValue(Config.NetworkLBHaproxyMaxConn.key()); + } + else { + maxconn = offering.getConcurrentConnections().toString(); + } + LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs, guestNic.getIp4Address(), guestNic.getIp4Address(), internalLbVm.getPrivateIpAddress(), - _itMgr.toNicTO(guestNicProfile, internalLbVm.getHypervisorType()), internalLbVm.getVpcId()); + _itMgr.toNicTO(guestNicProfile, internalLbVm.getHypervisorType()), internalLbVm.getVpcId(), maxconn); cmd.lbStatsVisibility = _configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key()); cmd.lbStatsUri = _configDao.getValue(Config.NetworkLBHaproxyStatsUri.key()); @@ -878,7 +886,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements s_logger.debug("No lb rules to be applied for network " + network); return true; } - + s_logger.info("lb rules to be applied for network "); //only one internal lb vm is supported per ip address at this time if (internalLbVms == null || internalLbVms.isEmpty()) { throw new CloudRuntimeException("Can't apply the lb rules on network " + network + " as the list of internal lb vms is empty"); diff --git a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMManagerTest.java b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMManagerTest.java index a19a82e30c1..85cf87e0d4d 100644 --- a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMManagerTest.java +++ b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMManagerTest.java @@ -24,6 +24,9 @@ import java.util.List; import javax.inject.Inject; +import com.cloud.offering.NetworkOffering; +import com.cloud.offerings.NetworkOfferingVO; +import com.cloud.offerings.dao.NetworkOfferingDao; import junit.framework.TestCase; import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO; @@ -91,7 +94,7 @@ public class InternalLBVMManagerTest extends TestCase { @Inject NetworkModel _ntwkModel; @Inject VirtualMachineManager _itMgr; @Inject DataCenterDao _dcDao; - + @Inject NetworkOfferingDao _offeringDao; long validNtwkId = 1L; long invalidNtwkId = 2L; String requestedIp = "10.1.1.1"; @@ -153,7 +156,9 @@ public class InternalLBVMManagerTest extends TestCase { DataCenterVO dc = new DataCenterVO (1L, null, null, null, null, null, null, null, null, null, NetworkType.Advanced, null, null); Mockito.when(_dcDao.findById(Mockito.anyLong())).thenReturn(dc); - + NetworkOfferingVO networkOfferingVO = new NetworkOfferingVO(); + networkOfferingVO.setConcurrentConnections(500); + Mockito.when(_offeringDao.findById(Mockito.anyLong())).thenReturn(networkOfferingVO); try { Mockito.when(_itMgr.expunge(Mockito.any(DomainRouterVO.class), Mockito.any(User.class), Mockito.any(Account.class))).thenReturn(true); diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index e77f6ce0403..bb0237c172f 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -92,6 +92,7 @@ public enum Config { NetworkLBHaproxyStatsUri("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.uri","/admin?stats","Load Balancer(haproxy) uri.",null), NetworkLBHaproxyStatsAuth("Secure", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.auth","admin1:AdMiN123","Load Balancer(haproxy) authetication string in the format username:password",null), NetworkLBHaproxyStatsPort("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.port","8081","Load Balancer(haproxy) stats port number.",null), + NetworkLBHaproxyMaxConn("Network", ManagementServer.class, Integer.class, "network.loadbalancer.haproxy.max.conn", "4096", "Load Balancer(haproxy) maximum number of concurrent connections(global max)", null), NetworkRouterRpFilter("Network", ManagementServer.class, Integer.class, "network.disable.rpfilter", "true", "disable rp_filter on Domain Router VM public interfaces.", null), GuestVlanBits("Network", ManagementServer.class, Integer.class, "guest.vlan.bits", "12", "The number of bits to reserve for the VLAN identifier in the guest subnet.", null), diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java index 1b99b63afdf..e06488e740a 100755 --- a/server/src/com/cloud/configuration/ConfigurationManager.java +++ b/server/src/com/cloud/configuration/ConfigurationManager.java @@ -219,7 +219,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager { NetworkOfferingVO createNetworkOffering(String name, String displayText, TrafficType trafficType, String tags, boolean specifyVlan, Availability availability, Integer networkRate, Map> serviceProviderMap, boolean isDefault, Network.GuestType type, boolean systemOnly, Long serviceOfferingId, boolean conserveMode, Map> serviceCapabilityMap, - boolean specifyIpRanges, boolean isPersistent, Map details, boolean egressDefaultPolicy); + boolean specifyIpRanges, boolean isPersistent, Map details, boolean egressDefaultPolicy, Integer maxconn); Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, String vlanId, Account vlanOwner, String startIPv6, String endIPv6, String vlanIp6Gateway, String vlanIp6Cidr) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException; diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index bdb526089b2..9498c8208cc 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -3827,6 +3827,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati boolean isPersistent = cmd.getIsPersistent(); Map detailsStr = cmd.getDetails(); Boolean egressDefaultPolicy = cmd.getEgressDefaultPolicy(); + Integer maxconn = null; // Verify traffic type for (TrafficType tType : TrafficType.values()) { @@ -3981,7 +3982,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati "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) { + maxconn=Integer.parseInt(_configDao.getValue(Config.NetworkLBHaproxyMaxConn.key())); + } + } + // validate the Source NAT service capabilities specified in the network // offering Map sourceNatServiceCapabilityMap = cmd.getServiceCapabilities(Service.SourceNat); @@ -4176,7 +4184,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati Map> serviceProviderMap, boolean isDefault, Network.GuestType type, boolean systemOnly, Long serviceOfferingId, boolean conserveMode, Map> serviceCapabilityMap, boolean specifyIpRanges, boolean isPersistent, - Map details, boolean egressDefaultPolicy) { + Map details, boolean egressDefaultPolicy, Integer maxconn) { String multicastRateStr = _configDao.getValue("multicast.throttling.rate"); int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr)); @@ -4334,6 +4342,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati txn.start(); // 1) create network offering object s_logger.debug("Adding network offering " + offering); + offering.setConcurrentConnections(maxconn); offering = _networkOfferingDao.persist(offering, details); // 2) populate services and providers if (serviceProviderMap != null) { @@ -4694,6 +4703,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati String name = cmd.getNetworkOfferingName(); String availabilityStr = cmd.getAvailability(); Integer sortKey = cmd.getSortKey(); + Integer maxconn = cmd.getMaxconnections(); Availability availability = null; String state = cmd.getState(); CallContext.current().setEventDetails(" Id: " + id); @@ -4768,6 +4778,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } } + if (maxconn != null) { + offering.setConcurrentConnections(maxconn); + } + if (_networkOfferingDao.update(id, offering)) { return _networkOfferingDao.findById(id); } else { diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 0e8011962b0..db375c3dbdc 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -1336,7 +1336,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L _configMgr.createNetworkOffering(NetworkOffering.QuickCloudNoServices, "Offering for QuickCloud with no services", TrafficType.Guest, null, true, Availability.Optional, null, new HashMap>(), true, - Network.GuestType.Shared, false, null, true, null, true, false, null, false); + Network.GuestType.Shared, false, null, true, null, true, false, null, false, null); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } @@ -1347,7 +1347,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L _configMgr.createNetworkOffering(NetworkOffering.DefaultSharedNetworkOfferingWithSGService, "Offering for Shared Security group enabled networks", TrafficType.Guest, null, true, Availability.Optional, null, defaultSharedNetworkOfferingProviders, true, - Network.GuestType.Shared, false, null, true, null, true, false, null, false); + Network.GuestType.Shared, false, null, true, null, true, false, null, false, null); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } @@ -1355,7 +1355,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L //#3 - shared network offering with no SG service if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedNetworkOffering) == null) { offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultSharedNetworkOffering, "Offering for Shared networks", TrafficType.Guest, null, true, Availability.Optional, null, - defaultSharedNetworkOfferingProviders, true, Network.GuestType.Shared, false, null, true, null, true, false, null, false); + defaultSharedNetworkOfferingProviders, true, Network.GuestType.Shared, false, null, true, null, true, false, null, false, null); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } @@ -1366,7 +1366,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService, "Offering for Isolated networks with Source Nat service enabled", TrafficType.Guest, null, false, Availability.Required, null, defaultIsolatedSourceNatEnabledNetworkOfferingProviders, - true, Network.GuestType.Isolated, false, null, true, null, false, false, null, false); + true, Network.GuestType.Isolated, false, null, true, null, false, false, null, false, null); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); @@ -1377,7 +1377,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks, "Offering for Isolated VPC networks with Source Nat service enabled", TrafficType.Guest, null, false, Availability.Optional, null, defaultVPCOffProviders, - true, Network.GuestType.Isolated, false, null, false, null, false, false, null,false); + true, Network.GuestType.Isolated, false, null, false, null, false, false, null,false, null); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } @@ -1389,7 +1389,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksNoLB, "Offering for Isolated VPC networks with Source Nat service enabled and LB service disabled", TrafficType.Guest, null, false, Availability.Optional, null, defaultVPCOffProviders, - true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false); + true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } @@ -1399,7 +1399,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOffering, "Offering for Isolated networks with no Source Nat service", TrafficType.Guest, null, true, Availability.Optional, null, defaultIsolatedNetworkOfferingProviders, true, Network.GuestType.Isolated, - false, null, true, null, true, false, null, false); + false, null, true, null, true, false, null, false, null); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } @@ -1425,7 +1425,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB, "Offering for Isolated VPC networks with Internal Lb support", TrafficType.Guest, null, false, Availability.Optional, null, internalLbOffProviders, - true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false); + true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null); offering.setState(NetworkOffering.State.Enabled); offering.setInternalLb(true); _networkOfferingDao.update(offering.getId(), offering); @@ -1455,7 +1455,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedEIPandELBNetworkOffering) == null) { offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultSharedEIPandELBNetworkOffering, "Offering for Shared networks with Elastic IP and Elastic LB capabilities", TrafficType.Guest, null, true, - Availability.Optional, null, netscalerServiceProviders, true, Network.GuestType.Shared, false, null, true, serviceCapabilityMap, true, false, null, false); + Availability.Optional, null, netscalerServiceProviders, true, Network.GuestType.Shared, false, null, true, serviceCapabilityMap, true, false, null, false, null); offering.setState(NetworkOffering.State.Enabled); offering.setDedicatedLB(false); _networkOfferingDao.update(offering.getId(), offering); diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 0a67cff9a7c..e437af68f52 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -3319,10 +3319,17 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V _networkModel.getNetworkRate(guestNetwork.getId(), router.getId()), _networkModel.isSecurityGroupSupportedInNetwork(guestNetwork), _networkModel.getNetworkTag(router.getHypervisorType(), guestNetwork)); - - LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs,routerPublicIp, - getRouterIpInNetwork(guestNetworkId, router.getId()),router.getPrivateIpAddress(), - _itMgr.toNicTO(nicProfile, router.getHypervisorType()), router.getVpcId()); + NetworkOffering offering =_networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()); + String maxconn= null; + if (offering.getConcurrentConnections() == null) { + maxconn = _configDao.getValue(Config.NetworkLBHaproxyMaxConn.key()); + } + else { + maxconn = offering.getConcurrentConnections().toString(); + } + LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs, routerPublicIp, + getRouterIpInNetwork(guestNetworkId, router.getId()), router.getPrivateIpAddress(), + _itMgr.toNicTO(nicProfile, router.getHypervisorType()), router.getVpcId(), maxconn); cmd.lbStatsVisibility = _configDao.getValue(Config.NetworkLBHaproxyStatsVisbility.key()); cmd.lbStatsUri = _configDao.getValue(Config.NetworkLBHaproxyStatsUri.key()); diff --git a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java index 7a61978f289..80b9e231561 100755 --- a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java +++ b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java @@ -555,7 +555,7 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu @Override public NetworkOfferingVO createNetworkOffering(String name, String displayText, TrafficType trafficType, String tags, boolean specifyVlan, Availability availability, Integer networkRate, Map> serviceProviderMap, boolean isDefault, GuestType type, boolean systemOnly, Long serviceOfferingId, boolean conserveMode, - Map> serviceCapabilityMap, boolean specifyIpRanges, boolean isPersistent, Map details, boolean egressDefaultPolicy) { + Map> serviceCapabilityMap, boolean specifyIpRanges, boolean isPersistent, Map details, boolean egressDefaultPolicy, Integer maxconn) { // TODO Auto-generated method stub return null; } diff --git a/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java b/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java index 9825cab729f..552703138d5 100644 --- a/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java +++ b/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java @@ -106,7 +106,7 @@ public class CreateNetworkOfferingTest extends TestCase{ public void createSharedNtwkOffWithVlan() { NetworkOfferingVO off = configMgr.createNetworkOffering("shared", "shared", TrafficType.Guest, null, true, Availability.Optional, 200, null, false, Network.GuestType.Shared, false, - null, false, null, true, false, null, false); + null, false, null, true, false, null, false, null); assertNotNull("Shared network offering with specifyVlan=true failed to create ", off); } @@ -115,7 +115,7 @@ public class CreateNetworkOfferingTest extends TestCase{ try { NetworkOfferingVO off = configMgr.createNetworkOffering("shared", "shared", TrafficType.Guest, null, false, Availability.Optional, 200, null, false, Network.GuestType.Shared, false, - null, false, null, true, false, null, false); + null, false, null, true, false, null, false, null); assertNull("Shared network offering with specifyVlan=false was created", off); } catch (InvalidParameterValueException ex) { } @@ -125,7 +125,7 @@ public class CreateNetworkOfferingTest extends TestCase{ public void createSharedNtwkOffWithSpecifyIpRanges() { NetworkOfferingVO off = configMgr.createNetworkOffering("shared", "shared", TrafficType.Guest, null, true, Availability.Optional, 200, null, false, Network.GuestType.Shared, false, - null, false, null, true, false, null, false); + null, false, null, true, false, null, false, null); assertNotNull("Shared network offering with specifyIpRanges=true failed to create ", off); } @@ -135,7 +135,7 @@ public class CreateNetworkOfferingTest extends TestCase{ try { NetworkOfferingVO off = configMgr.createNetworkOffering("shared", "shared", TrafficType.Guest, null, true, Availability.Optional, 200, null, false, Network.GuestType.Shared, false, - null, false, null, false, false, null, false); + null, false, null, false, false, null, false, null); assertNull("Shared network offering with specifyIpRanges=false was created", off); } catch (InvalidParameterValueException ex) { } @@ -150,7 +150,7 @@ public class CreateNetworkOfferingTest extends TestCase{ serviceProviderMap.put(Network.Service.SourceNat, vrProvider); NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, false, Availability.Optional, 200, serviceProviderMap, false, Network.GuestType.Isolated, false, - null, false, null, false, false, null, false); + null, false, null, false, false, null, false, null); assertNotNull("Isolated network offering with specifyIpRanges=false failed to create ", off); } @@ -163,7 +163,7 @@ public class CreateNetworkOfferingTest extends TestCase{ serviceProviderMap.put(Network.Service.SourceNat, vrProvider); NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, true, Availability.Optional, 200, serviceProviderMap, false, Network.GuestType.Isolated, false, - null, false, null, false, false, null, false); + null, false, null, false, false, null, false, null); assertNotNull("Isolated network offering with specifyVlan=true wasn't created", off); } @@ -177,7 +177,7 @@ public class CreateNetworkOfferingTest extends TestCase{ serviceProviderMap.put(Network.Service.SourceNat, vrProvider); NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, false, Availability.Optional, 200, serviceProviderMap, false, Network.GuestType.Isolated, false, - null, false, null, true, false, null, false); + null, false, null, true, false, null, false, null); assertNull("Isolated network offering with specifyIpRanges=true and source nat service enabled, was created", off); } catch (InvalidParameterValueException ex) { } @@ -190,7 +190,7 @@ public class CreateNetworkOfferingTest extends TestCase{ Set vrProvider = new HashSet(); NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, false, Availability.Optional, 200, serviceProviderMap, false, Network.GuestType.Isolated, false, - null, false, null, true, false, null, false); + null, false, null, true, false, null, false, null); assertNotNull("Isolated network offering with specifyIpRanges=true and with no sourceNatService, failed to create", off); } @@ -208,7 +208,7 @@ public class CreateNetworkOfferingTest extends TestCase{ serviceProviderMap.put(Network.Service.Lb , vrProvider); NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, true, Availability.Optional, 200, serviceProviderMap, false, Network.GuestType.Isolated, false, - null, false, null, false, false, null, false); + null, false, null, false, false, null, false, null); // System.out.println("Creating Vpc Network Offering"); assertNotNull("Vpc Isolated network offering with Vpc provider ", off); } @@ -228,7 +228,7 @@ public class CreateNetworkOfferingTest extends TestCase{ serviceProviderMap.put(Network.Service.Lb, lbProvider); NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, true, Availability.Optional, 200, serviceProviderMap, false, Network.GuestType.Isolated, false, null, false, - null, false, false, null, false); + null, false, false, null, false, null); // System.out.println("Creating Vpc Network Offering"); assertNotNull("Vpc Isolated network offering with Vpc and Netscaler provider ", off); } diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql index e9fa9954c0e..fe1426ef055 100644 --- a/setup/db/db/schema-410to420.sql +++ b/setup/db/db/schema-410to420.sql @@ -2232,3 +2232,6 @@ CREATE VIEW `cloud`.`project_view` AS and resource_tags.resource_type = 'Project' left join `cloud`.`project_account` pacct ON projects.id = pacct.project_id; +INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'network.loadbalancer.haproxy.max.conn', '4096', 'Load Balancer(haproxy) maximum number of concurrent connections(global max)'); + +ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `concurrent_connections` int(10) unsigned COMMENT 'Load Balancer(haproxy) maximum number of concurrent connections(global max)';