Skip to content

Commit cfebce7

Browse files
bug 10848: Removing the Host Capacity Checker thread which checks for skipcounting hours and also keeps host's CPU and Memory in sync. This work would be done by capacity checker thread now.
1 parent 4c1a2f5 commit cfebce7

3 files changed

Lines changed: 15 additions & 36 deletions

File tree

‎server/src/com/cloud/alert/AlertManagerImpl.java‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.apache.log4j.Logger;
4343

4444
import com.cloud.alert.dao.AlertDao;
45+
import com.cloud.capacity.CapacityManager;
4546
import com.cloud.capacity.CapacityVO;
4647
import com.cloud.capacity.dao.CapacityDao;
4748
import com.cloud.configuration.Config;
@@ -51,6 +52,7 @@
5152
import com.cloud.dc.dao.DataCenterDao;
5253
import com.cloud.dc.dao.DataCenterIpAddressDao;
5354
import com.cloud.dc.dao.HostPodDao;
55+
import com.cloud.host.Host;
5456
import com.cloud.host.HostVO;
5557
import com.cloud.host.Status;
5658
import com.cloud.host.dao.HostDao;
@@ -85,8 +87,8 @@ public class AlertManagerImpl implements AlertManager {
8587
private EmailAlert _emailAlert;
8688
@Inject private AlertDao _alertDao;
8789
@Inject private HostDao _hostDao;
88-
@Inject protected StorageManager _storageMgr;
89-
@Inject private ServiceOfferingDao _offeringsDao;
90+
@Inject protected StorageManager _storageMgr;
91+
@Inject protected CapacityManager _capacityMgr;
9092
@Inject private CapacityDao _capacityDao;
9193
@Inject private DataCenterDao _dcDao;
9294
@Inject private HostPodDao _podDao;
@@ -239,16 +241,12 @@ public void recalculateCapacity() {
239241
if (s_logger.isTraceEnabled()) {
240242
s_logger.trace("recalculating system capacity");
241243
}
242-
243-
// get all hosts..
244-
SearchCriteria<HostVO> sc = _hostDao.createSearchCriteria();
245-
sc.addAnd("status", SearchCriteria.Op.EQ, Status.Up.toString());
246-
247-
// prep the service offerings
248-
List<ServiceOfferingVO> offerings = _offeringsDao.listAllIncludingRemoved();
249-
Map<Long, ServiceOfferingVO> offeringsMap = new HashMap<Long, ServiceOfferingVO>();
250-
for (ServiceOfferingVO offering : offerings) {
251-
offeringsMap.put(offering.getId(), offering);
244+
245+
// Calculate CPU and RAM capacitites
246+
// get all hosts...even if they are not in 'UP' state
247+
List<HostVO> hosts = _hostDao.listByType(Host.Type.Routing);
248+
for (HostVO host : hosts) {
249+
_capacityMgr.updateCapacityForHost(host);
252250
}
253251

254252
// Calculate storage pool capacity
@@ -274,9 +272,9 @@ public void recalculateCapacity() {
274272
//ideal way would be to remove out the vlan param, and filter only on dcId
275273
//implementing the same
276274

277-
s_logger.trace("Executing capacity update");
275+
s_logger.trace("Executing public ip capacity update");
278276
createOrUpdateIpCapacity(dcId, null, CapacityVO.CAPACITY_TYPE_PUBLIC_IP);
279-
s_logger.trace("Done with capacity update");
277+
s_logger.trace("Done with public ip capacity update");
280278

281279
}
282280
txn.commit();
@@ -288,9 +286,9 @@ public void recalculateCapacity() {
288286
long podId = pod.getId();
289287
long dcId = pod.getDataCenterId();
290288

291-
s_logger.trace("Executing capacity update");
289+
s_logger.trace("Executing private ip capacity update");
292290
createOrUpdateIpCapacity(dcId, podId, CapacityVO.CAPACITY_TYPE_PRIVATE_IP);
293-
s_logger.trace("Done with capacity update");
291+
s_logger.trace("Done with private ip capacity update");
294292

295293
}
296294
txn.commit();

‎server/src/com/cloud/capacity/CapacityManagerImpl.java‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ public class CapacityManagerImpl implements CapacityManager, StateListener<State
9191
@Override
9292
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
9393
_name = name;
94-
_hostCapacityCheckerDelay = NumbersUtil.parseInt(_configDao.getValue(Config.HostCapacityCheckerWait.key()), 3600);
95-
_hostCapacityCheckerInterval = NumbersUtil.parseInt(_configDao.getValue(Config.HostCapacityCheckerInterval.key()), 3600);
9694
_vmCapacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(Config.CapacitySkipcountingHours.key()), 3600);
9795
_storageOverProvisioningFactor = NumbersUtil.parseFloat(_configDao.getValue(Config.StorageOverprovisioningFactor.key()), 1.0f);
9896
_cpuOverProvisioningFactor = NumbersUtil.parseFloat(_configDao.getValue(Config.CPUOverprovisioningFactor.key()), 1.0f);
@@ -110,7 +108,6 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
110108

111109
@Override
112110
public boolean start() {
113-
_executor.scheduleWithFixedDelay(new HostCapacityCollector(), _hostCapacityCheckerDelay, _hostCapacityCheckerInterval, TimeUnit.SECONDS);
114111
return true;
115112
}
116113

@@ -413,20 +410,6 @@ public boolean checkIfHostHasCapacity(long hostId, Integer cpu, long ram, boolea
413410
return hasCapacity;
414411

415412
}
416-
417-
public class HostCapacityCollector implements Runnable {
418-
419-
@Override
420-
public void run() {
421-
s_logger.debug("HostCapacityCollector is running...");
422-
// get all hosts...even if they are not in 'UP' state
423-
List<HostVO> hosts = _hostDao.listByType(Host.Type.Routing);
424-
for (HostVO host : hosts) {
425-
updateCapacityForHost(host);
426-
}
427-
428-
}
429-
}
430413

431414
@Override
432415
public void updateCapacityForHost(HostVO host){

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,7 @@ public enum Config {
190190
DirectAttachNetworkExternalAPIURL("Advanced", ManagementServer.class, String.class, "direct.attach.network.externalIpAllocator.url", null, "Direct-attach VMs using external DHCP server (API url)", null),
191191
CheckPodCIDRs("Advanced", ManagementServer.class, String.class, "check.pod.cidrs", "true", "If true, different pods must belong to different CIDR subnets.", "true,false"),
192192
NetworkGcWait("Advanced", ManagementServer.class, Integer.class, "network.gc.wait", "600", "Time (in seconds) to wait before shutting down a network that's not in used", null),
193-
NetworkGcInterval("Advanced", ManagementServer.class, Integer.class, "network.gc.interval", "600", "Seconds to wait before checking for networks to shutdown", null),
194-
HostCapacityCheckerWait("Advanced", ManagementServer.class, Integer.class, "host.capacity.checker.wait", "3600", "Time (in seconds) to wait before starting host capacity background checker", null),
195-
HostCapacityCheckerInterval("Advanced", ManagementServer.class, Integer.class, "host.capacity.checker.interval", "3600", "Time (in seconds) to wait before recalculating host's capacity", null),
193+
NetworkGcInterval("Advanced", ManagementServer.class, Integer.class, "network.gc.interval", "600", "Seconds to wait before checking for networks to shutdown", null),
196194
CapacitySkipcountingHours("Advanced", ManagementServer.class, Integer.class, "capacity.skipcounting.hours", "3600", "Time (in seconds) to wait before release VM's cpu and memory when VM in stopped state", null),
197195
VmStatsInterval("Advanced", ManagementServer.class, Integer.class, "vm.stats.interval", "60000", "The interval (in milliseconds) when vm stats are retrieved from agents.", null),
198196
VmTransitionWaitInterval("Advanced", ManagementServer.class, Integer.class, "vm.tranisition.wait.interval", "3600", "Time (in seconds) to wait before taking over a VM in transition state", null),

0 commit comments

Comments
 (0)