@Override public List<HAConfig> listHAResources(final Long resourceId, final HAResource.ResourceType resourceType) { return haConfigDao.listHAResource(resourceId, resourceType); }
@Override public boolean stop() { haConfigDao.expireServerOwnership(ManagementServerNode.getManagementServerId()); return true; }
@Override public List<HAConfig> listHAResource(final Long resourceId, final HAResource.ResourceType resourceType) { final SearchCriteria<HAConfigVO> sc = ResourceSearch.create(); if (resourceId != null && resourceId > 0L) { sc.setParameters("resourceId", resourceId); } if (resourceType != null) { sc.setParameters("resourceType", resourceType); } return new ArrayList<HAConfig>(listBy(sc)); }
@Override public Boolean doInTransaction(TransactionStatus status) { HAConfigVO haConfig = (HAConfigVO) haConfigDao.findHAResource(resourceId, resourceType); if (haConfig == null) { haConfig = new HAConfigVO(); throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "HAProvider is not provided for the resource, failing configuration."); if (haConfigDao.persist(haConfig) != null) { return true; throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "HAProvider is not provided for the resource, failing configuration."); return haConfigDao.update(haConfig.getId(), haConfig);
@Override @ActionEvent(eventType = EventTypes.EVENT_HA_RESOURCE_DISABLE, eventDescription = "disabling HA for resource") public boolean disableHA(final Long resourceId, final HAResource.ResourceType resourceType) { Preconditions.checkArgument(resourceId != null && resourceId > 0L); Preconditions.checkArgument(resourceType != null); boolean result = configureHA(resourceId, resourceType, false, null); if (result) { transitionHAState(HAConfig.Event.Disabled, haConfigDao.findHAResource(resourceId, resourceType)); purgeHACounter(resourceId, resourceType); } return result; }
UpdateBuilder ub = getUpdateBuilder(haConfig); ub.set(haConfig, HAStateAttr, nextState); ub.set(haConfig, UpdateTimeAttr, DateUtil.currentGMTTime()); ub.set(haConfig, MsIdAttr, newManagementServerId); int result = update(ub, sc, null); if (LOG.isTraceEnabled() && result <= 0) { LOG.trace(String.format("Failed to update HA state from:%s to:%s due to event:%s for the ha_config id:%d", currentState, nextState, event, haConfig.getId()));
@Override public HAConfig findHAResource(final long resourceId, final HAResource.ResourceType resourceType) { final SearchCriteria<HAConfigVO> sc = ResourceSearch.create(); sc.setParameters("resourceId", resourceId); sc.setParameters("resourceType", resourceType); return findOneBy(sc); }
public HAConfigDaoImpl() { super(); ResourceSearch = createSearchBuilder(); ResourceSearch.and("resourceId", ResourceSearch.entity().getResourceId(), SearchCriteria.Op.EQ); ResourceSearch.and("resourceType", ResourceSearch.entity().getResourceType(), SearchCriteria.Op.EQ); ResourceSearch.done(); StateUpdateSearch = createSearchBuilder(); StateUpdateSearch.and("id", StateUpdateSearch.entity().getId(), SearchCriteria.Op.EQ); StateUpdateSearch.and("haState", StateUpdateSearch.entity().getHaState(), SearchCriteria.Op.EQ); StateUpdateSearch.and("update", StateUpdateSearch.entity().getUpdateCount(), SearchCriteria.Op.EQ); StateUpdateSearch.done(); HAStateAttr = _allAttributes.get("haState"); MsIdAttr = _allAttributes.get("managementServerId"); UpdateTimeAttr = _allAttributes.get("updateTime"); assert (HAStateAttr != null && MsIdAttr != null && UpdateTimeAttr != null) : "Couldn't find one of these attributes"; }
LOG.trace("HA health check task is running..."); final List<HAConfig> haConfigList = new ArrayList<HAConfig>(haConfigDao.listAll()); for (final HAConfig haConfig : haConfigList) { if (haConfig == null) {
@Override public void onManagementNodeLeft(final List<? extends ManagementServerHost> nodeList, final long selfNodeId) { for (final ManagementServerHost vo : nodeList) { s_logger.info("Marking hosts as disconnected on Management server" + vo.getMsid()); final long lastPing = (System.currentTimeMillis() >> 10) - mgmtServiceConf.getTimeout(); _hostDao.markHostsAsDisconnected(vo.getMsid(), lastPing); outOfBandManagementDao.expireServerOwnership(vo.getMsid()); haConfigDao.expireServerOwnership(vo.getMsid()); s_logger.info("Deleting entries from op_host_transfer table for Management server " + vo.getMsid()); cleanupTransferMap(vo.getMsid()); } }
public Boolean isVMAliveOnHost(final Host host) throws Investigator.UnknownVM { final HAConfig haConfig = haConfigDao.findHAResource(host.getId(), HAResource.ResourceType.Host); if (haConfig != null) { if (haConfig.getState() == HAConfig.HAState.Fenced) { if (LOG.isDebugEnabled()){ LOG.debug("HA: Host is fenced " + host.getId()); } return false; } if (LOG.isDebugEnabled()){ LOG.debug("HA: HOST is alive " + host.getId()); } return true; } throw new Investigator.UnknownVM(); }
public Status getHostStatus(final Host host) { final HAConfig haConfig = haConfigDao.findHAResource(host.getId(), HAResource.ResourceType.Host); if (haConfig != null) { if (haConfig.getState() == HAConfig.HAState.Fenced) { if (LOG.isDebugEnabled()){ LOG.debug("HA: Agent is available/suspect/checking Up " + host.getId()); } return Status.Down; } else if (haConfig.getState() == HAConfig.HAState.Degraded || haConfig.getState() == HAConfig.HAState.Recovering || haConfig.getState() == HAConfig.HAState.Fencing) { if (LOG.isDebugEnabled()){ LOG.debug("HA: Agent is disconnected " + host.getId()); } return Status.Disconnected; } return Status.Up; } return Status.Unknown; }
private boolean isHAEligibleForResource(final HAResource resource) { if (resource == null || resource.getId() < 1L) { return false; } HAResource.ResourceType resourceType = null; if (resource instanceof Host) { resourceType = HAResource.ResourceType.Host; } if (resourceType == null) { return false; } final HAConfig haConfig = haConfigDao.findHAResource(resource.getId(), resourceType); return haConfig != null && haConfig.isEnabled() && haConfig.getState() != HAConfig.HAState.Disabled && haConfig.getState() != HAConfig.HAState.Ineligible; }
private boolean transitionResourceStateToDisabled(final Partition partition) { List<? extends HAResource> resources; if (partition.partitionType() == Partition.PartitionType.Cluster) { resources = hostDao.findByClusterId(partition.getId()); } else if (partition.partitionType() == Partition.PartitionType.Zone) { resources = hostDao.findByDataCenterId(partition.getId()); } else { return true; } boolean result = true; for (final HAResource resource: resources) { result = result && transitionHAState(HAConfig.Event.Disabled, haConfigDao.findHAResource(resource.getId(), resource.resourceType())); } return result; }
hostResponse.setHostHAResponse(haConfigDao.findHAResource(host.getId(), HAResource.ResourceType.Host)); hostResponse.setOutOfBandManagementResponse(outOfBandManagementDao.findByHost(host.getId())); hostResponse.setResourceState(host.getResourceState().toString());