public static String[] toStrings(Status... states) { String[] strs = new String[states.length]; for (int i = 0; i < states.length; i++) { strs[i] = states[i].toString(); } return strs; }
@Override public boolean processDisconnect(long agentId, Status state) { if (s_logger.isDebugEnabled()) { s_logger.debug("Disconnected called on " + agentId + " with status " + state.toString()); } return true; }
@Override public List<StoragePoolHostVO> listByHostStatus(long poolId, Status hostStatus) { TransactionLegacy txn = TransactionLegacy.currentTxn(); String sql = HOST_FOR_POOL_SEARCH; List<StoragePoolHostVO> result = new ArrayList<StoragePoolHostVO>(); try(PreparedStatement pstmt = txn.prepareStatement(sql);) { pstmt.setLong(1, poolId); pstmt.setString(2, hostStatus.toString()); try(ResultSet rs = pstmt.executeQuery();) { while (rs.next()) { // result.add(toEntityBean(rs, false)); TODO: this is buggy in // GenericDaoBase for hand constructed queries long id = rs.getLong(1); // ID column result.add(findById(id)); } }catch (SQLException e) { s_logger.warn("listByHostStatus:Exception: ", e); } } catch (Exception e) { s_logger.warn("listByHostStatus:Exception: ", e); } return result; }
stmt.setDate(11, new Date(DateUtil.currentGMTTime().getTime())); stmt.setLong(12, podId); stmt.setString(13, Status.Up.toString()); stmt.setLong(14, clusterId); stmt.executeUpdate();
@Override public Status investigate(final long hostId) { final HostVO host = _hostDao.findById(hostId); if (host == null) { return Status.Alert; } Status hostState = null; for (Investigator investigator : investigators) { hostState = investigator.isAgentAlive(host); if (hostState != null) { if (s_logger.isDebugEnabled()) { s_logger.debug(investigator.getName() + " was able to determine host " + hostId + " is in " + hostState.toString()); } return hostState; } if (s_logger.isDebugEnabled()) { s_logger.debug(investigator.getName() + " unable to determine the state of the host. Moving on."); } } return hostState; }
/** * Creates a HostVO SearchCriteria where: * <ul> * <li>"status" is Up;</li> * <li>"resourceState" is not in Maintenance, PrepareForMaintenance, or ErrorInMaintenance; and</li> * <li>"type" is Routing.</li> * </ul> */ private SearchCriteria<HostVO> createSearchCriteriaForHostTypeRoutingStateUpAndNotInMaintenance() { SearchCriteria<HostVO> sc = _hostDao.createSearchCriteria(); sc.addAnd("status", SearchCriteria.Op.EQ, Status.Up.toString()); sc.addAnd("resourceState", SearchCriteria.Op.NIN, ResourceState.Maintenance, ResourceState.PrepareForMaintenance, ResourceState.ErrorInMaintenance); sc.addAnd("type", SearchCriteria.Op.EQ, Host.Type.Routing.toString()); return sc; }
str.append("; New=[status=").append(newStatus.toString()).append(":msid=").append(newStatus.lostConnection() ? "null" : host.getManagementServerId()) .append(":lastpinged=").append(host.getLastPinged()).append("]"); str.append("; Old=[status=").append(oldStatus.toString()).append(":msid=").append(host.getManagementServerId()).append(":lastpinged=").append(oldPingTime) .append("]"); str.append("; DB=[status=").append(vo.getStatus().toString()).append(":msid=").append(vo.getManagementServerId()).append(":lastpinged=").append(vo.getLastPinged()) .append(":old update count=").append(oldUpdateCount).append("]"); status_logger.debug(str.toString());
if (host.getType().equals(Host.Type.Routing) && !host.getStatus().equals(Status.Down) && !host.getStatus().equals(Status.Disconnected) && !host.getStatus().equals(Status.Up) && !host.getStatus().equals(Status.Alert)) { final String msg = "host " + host.getPrivateIpAddress() + " should not be in " + host.getStatus().toString() + " status"; throw new CloudRuntimeException("PrepareUnmanaged Failed due to " + msg);
@Override public List<HostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag) { SearchBuilder<HostTagVO> hostTagSearch = _hostTagsDao.createSearchBuilder(); HostTagVO tagEntity = hostTagSearch.entity(); hostTagSearch.and("tag", tagEntity.getTag(), SearchCriteria.Op.EQ); SearchBuilder<HostVO> hostSearch = createSearchBuilder(); HostVO entity = hostSearch.entity(); hostSearch.and("type", entity.getType(), SearchCriteria.Op.EQ); hostSearch.and("pod", entity.getPodId(), SearchCriteria.Op.EQ); hostSearch.and("dc", entity.getDataCenterId(), SearchCriteria.Op.EQ); hostSearch.and("cluster", entity.getClusterId(), SearchCriteria.Op.EQ); hostSearch.and("status", entity.getStatus(), SearchCriteria.Op.EQ); hostSearch.and("resourceState", entity.getResourceState(), SearchCriteria.Op.EQ); hostSearch.join("hostTagSearch", hostTagSearch, entity.getId(), tagEntity.getHostId(), JoinBuilder.JoinType.INNER); SearchCriteria<HostVO> sc = hostSearch.create(); sc.setJoinParameters("hostTagSearch", "tag", hostTag); sc.setParameters("type", type.toString()); if (podId != null) { sc.setParameters("pod", podId); } if (clusterId != null) { sc.setParameters("cluster", clusterId); } sc.setParameters("dc", dcId); sc.setParameters("status", Status.Up.toString()); sc.setParameters("resourceState", ResourceState.Enabled.toString()); return listBy(sc); }
@Override public List<EngineHostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag) { SearchBuilder<HostTagVO> hostTagSearch = _hostTagsDao.createSearchBuilder(); HostTagVO tagEntity = hostTagSearch.entity(); hostTagSearch.and("tag", tagEntity.getTag(), SearchCriteria.Op.EQ); SearchBuilder<EngineHostVO> hostSearch = createSearchBuilder(); EngineHostVO entity = hostSearch.entity(); hostSearch.and("type", entity.getType(), SearchCriteria.Op.EQ); hostSearch.and("pod", entity.getPodId(), SearchCriteria.Op.EQ); hostSearch.and("dc", entity.getDataCenterId(), SearchCriteria.Op.EQ); hostSearch.and("cluster", entity.getClusterId(), SearchCriteria.Op.EQ); hostSearch.and("status", entity.getStatus(), SearchCriteria.Op.EQ); hostSearch.and("resourceState", entity.getResourceState(), SearchCriteria.Op.EQ); hostSearch.join("hostTagSearch", hostTagSearch, entity.getId(), tagEntity.getHostId(), JoinBuilder.JoinType.INNER); SearchCriteria<EngineHostVO> sc = hostSearch.create(); sc.setJoinParameters("hostTagSearch", "tag", hostTag); sc.setParameters("type", type.toString()); if (podId != null) { sc.setParameters("pod", podId); } if (clusterId != null) { sc.setParameters("cluster", clusterId); } sc.setParameters("dc", dcId); sc.setParameters("status", Status.Up.toString()); sc.setParameters("resourceState", ResourceState.Enabled.toString()); return listBy(sc); }
@Override public List<StoragePoolVO> findLocalStoragePoolsByHostAndTags(long hostId, String[] tags) { SearchBuilder<StoragePoolVO> hostSearch = createSearchBuilder(); SearchBuilder<StoragePoolHostVO> hostPoolSearch = _hostDao.createSearchBuilder(); SearchBuilder<StoragePoolTagVO> tagPoolSearch = _tagsDao.createSearchBuilder(); ; // Search for pools on the host hostPoolSearch.and("hostId", hostPoolSearch.entity().getHostId(), Op.EQ); // Set criteria for pools hostSearch.and("scope", hostSearch.entity().getScope(), Op.EQ); hostSearch.and("removed", hostSearch.entity().getRemoved(), Op.NULL); hostSearch.and("status", hostSearch.entity().getStatus(), Op.EQ); hostSearch.join("hostJoin", hostPoolSearch, hostSearch.entity().getId(), hostPoolSearch.entity().getPoolId(), JoinBuilder.JoinType.INNER); if (!(tags == null || tags.length == 0)) { tagPoolSearch.and("tag", tagPoolSearch.entity().getTag(), Op.EQ); hostSearch.join("tagJoin", tagPoolSearch, hostSearch.entity().getId(), tagPoolSearch.entity().getPoolId(), JoinBuilder.JoinType.INNER); } SearchCriteria<StoragePoolVO> sc = hostSearch.create(); sc.setJoinParameters("hostJoin", "hostId", hostId); sc.setParameters("scope", ScopeType.HOST.toString()); sc.setParameters("status", Status.Up.toString()); if (!(tags == null || tags.length == 0)) { for (String tag : tags) { sc.setJoinParameters("tagJoin", "tag", tag); } } return listBy(sc); }