Search in sources :

Example 1 with ConsoleProxyLoadInfo

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);
}
Also used : ConsoleProxyLoadInfo(com.cloud.info.ConsoleProxyLoadInfo) Pair(com.cloud.utils.Pair)

Example 2 with ConsoleProxyLoadInfo

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;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) SQLException(java.sql.SQLException) ConsoleProxyLoadInfo(com.cloud.info.ConsoleProxyLoadInfo) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 3 with ConsoleProxyLoadInfo

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);
    }
}
Also used : ConsoleProxyLoadInfo(com.cloud.info.ConsoleProxyLoadInfo)

Aggregations

ConsoleProxyLoadInfo (com.cloud.info.ConsoleProxyLoadInfo)3 Pair (com.cloud.utils.Pair)1 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1