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; }
/** * Return the list of running hosts to which upload certificates for Direct Download */ private List<HostVO> getRunningHostsToUploadCertificate(HypervisorType hypervisorType) { return hostDao.listAllHostsByType(Host.Type.Routing) .stream() .filter(x -> x.getStatus().equals(Status.Up) && x.getHypervisorType().equals(hypervisorType)) .collect(Collectors.toList()); }
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); sb.and("update", sb.entity().getUpdated(), SearchCriteria.Op.EQ); if (newStatus.checkManagementServer()) { sb.and("ping", sb.entity().getLastPinged(), SearchCriteria.Op.EQ); sb.and().op("nullmsid", sb.entity().getManagementServerId(), SearchCriteria.Op.NULL); sc.setParameters("update", host.getUpdated()); long oldUpdateCount = host.getUpdated(); if (newStatus.checkManagementServer()) { sc.setParameters("ping", oldPingTime); sc.setParameters("msid", host.getManagementServerId()); UpdateBuilder ub = getUpdateBuilder(host); ub.set(host, _statusAttr, newStatus); if (newStatus.updateManagementServer()) { if (newStatus.lostConnection()) { ub.set(host, _msIdAttr, null); } else { 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());
List<HostVO> hosts = listAllHosts(Host.Type.Routing, cluster.getId(), cluster.getPodId(), cluster.getDataCenterId()); for (final HostVO host : hosts) { 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); if (host.getStatus().equals(Status.Up)) { umanageHost(host.getId()); if (!host.getStatus().equals(Status.Down) && !host.getStatus().equals(Status.Disconnected) && !host.getStatus().equals(Status.Alert)) { lsuccess = false; break;
LOG.trace("Resource state = " + hostStatus.name());
} else { try { nextStatus = currentStatus.getNextStatus(event); } catch (final NoTransitionException e) { final String err = "Cannot find next status for " + event + " as current status is " + currentStatus + " for agent " + hostId;
Set<com.cloud.host.Status.Event> possibleEvents = host.getStatus().getPossibleEvents(); if ((possibleEvents != null) && !possibleEvents.isEmpty()) { String events = "";
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { initMessageBusListeners(); initNuageVspResourceListeners(); initNuageVspVpcOffering(); Status.getStateMachine().registerListener(this); return true; }
s_logger.debug("The last host of this VM is not UP or is not enabled, host status is: " + host.getStatus().name() + ", host resource state is: " + host.getResourceState());
Status nextStatus = null; try { nextStatus = host.getStatus().getNextStatus(event); } catch (final NoTransitionException ne) {
Set<com.cloud.host.Status.Event> possibleEvents = host.getStatus().getPossibleEvents(); if ((possibleEvents != null) && !possibleEvents.isEmpty()) { String events = "";
@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; }
/** * Get running host IDs within the same hypervisor, cluster and datacenter than hostId. ID hostId is not included on the returned list */ protected List<Long> getRunningHostIdsInTheSameCluster(Long clusterId, long dataCenterId, HypervisorType hypervisorType, long hostId) { List<Long> list = hostDao.listByDataCenterIdAndHypervisorType(dataCenterId, hypervisorType) .stream() .filter(x -> x.getHypervisorType().equals(hypervisorType) && x.getStatus().equals(Status.Up) && x.getType().equals(Host.Type.Routing) && x.getClusterId().equals(clusterId) && x.getId() != hostId) .map(x -> x.getId()) .collect(Collectors.toList()); Collections.shuffle(list); return list; }
@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; }
@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); }