Skip to content

Commit 2803cac

Browse files
committed
CLOUDSTACK-6075: Increase the ram size for router service offering
Increased the ram size of Internal load balancer vm service offering also Backported from fix by Harikrishna Patnala <harikrishna.patnala@citrix.com> https://reviews.apache.org/r/17941/ Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 291a34a commit 2803cac

4 files changed

Lines changed: 112 additions & 3 deletions

File tree

‎engine/schema/src/com/cloud/upgrade/dao/Upgrade442to443.java‎

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
import java.io.File;
2121
import java.sql.Connection;
22+
import java.sql.PreparedStatement;
23+
import java.sql.ResultSet;
24+
import java.sql.SQLException;
2225

2326
import org.apache.log4j.Logger;
2427

@@ -55,6 +58,112 @@ public File[] getPrepareScripts() {
5558

5659
@Override
5760
public void performDataMigration(Connection conn) {
61+
updateMaxRouterSizeConfig(conn);
62+
upgradeMemoryOfVirtualRoutervmOffering(conn);
63+
upgradeMemoryOfInternalLoadBalancervmOffering(conn);
64+
}
65+
66+
private void updateMaxRouterSizeConfig(Connection conn) {
67+
PreparedStatement updatePstmt = null;
68+
try {
69+
updatePstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value='256' WHERE name='router.ram.size'");
70+
updatePstmt.executeUpdate();
71+
} catch (SQLException e) {
72+
throw new CloudRuntimeException("Unable to upgrade max ram size of router in config.", e);
73+
} finally {
74+
try {
75+
if (updatePstmt != null) {
76+
updatePstmt.close();
77+
}
78+
} catch (SQLException e) {
79+
}
80+
}
81+
s_logger.debug("Done updating router.ram.size config to 256");
82+
}
83+
84+
private void upgradeMemoryOfInternalLoadBalancervmOffering(Connection conn) {
85+
PreparedStatement updatePstmt = null;
86+
PreparedStatement selectPstmt = null;
87+
ResultSet selectResultSet = null;
88+
int newRamSize = 256; //256MB
89+
long serviceOfferingId = 0;
90+
91+
/**
92+
* Pick first row in service_offering table which has system vm type as internalloadbalancervm. User added offerings would start from 2nd row onwards.
93+
* We should not update/modify any user-defined offering.
94+
*/
95+
96+
try {
97+
selectPstmt = conn.prepareStatement("SELECT id FROM `cloud`.`service_offering` WHERE vm_type='internalloadbalancervm'");
98+
updatePstmt = conn.prepareStatement("UPDATE `cloud`.`service_offering` SET ram_size=? WHERE id=?");
99+
selectResultSet = selectPstmt.executeQuery();
100+
if(selectResultSet.next()) {
101+
serviceOfferingId = selectResultSet.getLong("id");
102+
}
103+
104+
updatePstmt.setInt(1, newRamSize);
105+
updatePstmt.setLong(2, serviceOfferingId);
106+
updatePstmt.executeUpdate();
107+
} catch (SQLException e) {
108+
throw new CloudRuntimeException("Unable to upgrade ram_size of service offering for internal loadbalancer vm. ", e);
109+
} finally {
110+
try {
111+
if (selectPstmt != null) {
112+
selectPstmt.close();
113+
}
114+
if (selectResultSet != null) {
115+
selectResultSet.close();
116+
}
117+
if (updatePstmt != null) {
118+
updatePstmt.close();
119+
}
120+
} catch (SQLException e) {
121+
}
122+
}
123+
s_logger.debug("Done upgrading RAM for service offering of internal loadbalancer vm to " + newRamSize);
124+
}
125+
126+
127+
private void upgradeMemoryOfVirtualRoutervmOffering(Connection conn) {
128+
PreparedStatement updatePstmt = null;
129+
PreparedStatement selectPstmt = null;
130+
ResultSet selectResultSet = null;
131+
int newRamSize = 256; //256MB
132+
long serviceOfferingId = 0;
133+
134+
/**
135+
* Pick first row in service_offering table which has system vm type as domainrouter. User added offerings would start from 2nd row onwards.
136+
* We should not update/modify any user-defined offering.
137+
*/
138+
139+
try {
140+
selectPstmt = conn.prepareStatement("SELECT id FROM `cloud`.`service_offering` WHERE vm_type='domainrouter'");
141+
updatePstmt = conn.prepareStatement("UPDATE `cloud`.`service_offering` SET ram_size=? WHERE id=?");
142+
selectResultSet = selectPstmt.executeQuery();
143+
if(selectResultSet.next()) {
144+
serviceOfferingId = selectResultSet.getLong("id");
145+
}
146+
147+
updatePstmt.setInt(1, newRamSize);
148+
updatePstmt.setLong(2, serviceOfferingId);
149+
updatePstmt.executeUpdate();
150+
} catch (SQLException e) {
151+
throw new CloudRuntimeException("Unable to upgrade ram_size of service offering for domain router. ", e);
152+
} finally {
153+
try {
154+
if (selectPstmt != null) {
155+
selectPstmt.close();
156+
}
157+
if (selectResultSet != null) {
158+
selectResultSet.close();
159+
}
160+
if (updatePstmt != null) {
161+
updatePstmt.close();
162+
}
163+
} catch (SQLException e) {
164+
}
165+
}
166+
s_logger.debug("Done upgrading RAM for service offering of domain router to " + newRamSize);
58167
}
59168

60169
@Override

‎plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManager.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
public interface InternalLoadBalancerVMManager {
3434
//RAM/CPU for the system offering used by Internal LB VMs
35-
public static final int DEFAULT_INTERNALLB_VM_RAMSIZE = 128; // 128 MB
35+
public static final int DEFAULT_INTERNALLB_VM_RAMSIZE = 256; // 256 MB
3636
public static final int DEFAULT_INTERNALLB_VM_CPU_MHZ = 256; // 256 MHz
3737

3838
/**

‎server/src/com/cloud/configuration/Config.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ public enum Config {
13791379
"The allowable clock difference in milliseconds between when an SSO login request is made and when it is received.",
13801380
null),
13811381
//NetworkType("Hidden", ManagementServer.class, String.class, "network.type", "vlan", "The type of network that this deployment will use.", "vlan,direct"),
1382-
RouterRamSize("Hidden", NetworkOrchestrationService.class, Integer.class, "router.ram.size", "128", "Default RAM for router VM (in MB).", null),
1382+
RouterRamSize("Hidden", NetworkOrchestrationService.class, Integer.class, "router.ram.size", "256", "Default RAM for router VM (in MB).", null),
13831383

13841384
DefaultPageSize("Advanced", ManagementServer.class, Long.class, "default.page.size", "500", "Default page size for API list* commands", null),
13851385

‎server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
7070
static final ConfigKey<Integer> RouterAlertsCheckInterval = new ConfigKey<Integer>(Integer.class, RouterAlertsCheckIntervalCK, "Advanced", "1800",
7171
"Interval (in seconds) to check for alerts in Virtual Router.", false, ConfigKey.Scope.Global, null);
7272

73-
public static final int DEFAULT_ROUTER_VM_RAMSIZE = 128; // 128M
73+
public static final int DEFAULT_ROUTER_VM_RAMSIZE = 256; // 256M
7474
public static final int DEFAULT_ROUTER_CPU_MHZ = 500; // 500 MHz
7575
public static final boolean USE_POD_VLAN = false;
7676

0 commit comments

Comments
 (0)