use of com.cloud.info.ConsoleProxyLoadInfo in project cloudstack by apache.
the class ConsoleProxyManagerImpl method scanPool.
@Override
public Pair<AfterScanAction, Object> scanPool(Long pool) {
long dataCenterId = pool.longValue();
ConsoleProxyLoadInfo proxyInfo = _zoneProxyCountMap.get(dataCenterId);
if (proxyInfo == null) {
return new Pair<AfterScanAction, Object>(AfterScanAction.nop, null);
}
ConsoleProxyLoadInfo vmInfo = _zoneVmCountMap.get(dataCenterId);
if (vmInfo == null) {
vmInfo = new ConsoleProxyLoadInfo();
}
if (!checkCapacity(proxyInfo, vmInfo)) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Expand console proxy standby capacity for zone " + proxyInfo.getName());
}
return new Pair<AfterScanAction, Object>(AfterScanAction.expand, null);
}
return new Pair<AfterScanAction, Object>(AfterScanAction.nop, null);
}
use of com.cloud.info.ConsoleProxyLoadInfo in project cloudstack by apache.
the class ConsoleProxyDaoImpl method getDatacenterLoadMatrix.
private List<ConsoleProxyLoadInfo> getDatacenterLoadMatrix(String sql) {
ArrayList<ConsoleProxyLoadInfo> l = new ArrayList<ConsoleProxyLoadInfo>();
TransactionLegacy txn = TransactionLegacy.currentTxn();
;
PreparedStatement pstmt = null;
try {
pstmt = txn.prepareAutoCloseStatement(sql);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
ConsoleProxyLoadInfo info = new ConsoleProxyLoadInfo();
info.setId(rs.getLong(1));
info.setName(rs.getString(2));
info.setCount(rs.getInt(3));
l.add(info);
}
} catch (SQLException e) {
s_logger.debug("Exception: ", e);
}
return l;
}
use of com.cloud.info.ConsoleProxyLoadInfo in project cloudstack by apache.
the class ConsoleProxyManagerImpl method onScanStart.
@Override
public void onScanStart() {
// to reduce possible number of DB queries for capacity scan, we run following aggregated queries in preparation
// stage
_zoneHostInfoMap = getZoneHostInfo();
_zoneProxyCountMap = new HashMap<Long, ConsoleProxyLoadInfo>();
List<ConsoleProxyLoadInfo> listProxyCounts = _consoleProxyDao.getDatacenterProxyLoadMatrix();
for (ConsoleProxyLoadInfo info : listProxyCounts) {
_zoneProxyCountMap.put(info.getId(), info);
}
_zoneVmCountMap = new HashMap<Long, ConsoleProxyLoadInfo>();
List<ConsoleProxyLoadInfo> listVmCounts = _consoleProxyDao.getDatacenterSessionLoadMatrix();
for (ConsoleProxyLoadInfo info : listVmCounts) {
_zoneVmCountMap.put(info.getId(), info);
}
}
Aggregations