HAConfigVO haConfig = (HAConfigVO) haConfigDao.findHAResource(resourceId, resourceType); if (haConfig == null) { haConfig = new HAConfigVO(); if (haProvider != null) { haConfig.setHaProvider(haProvider); haConfig.setEnabled(enable); haConfig.setManagementServerId(ManagementServerNode.getManagementServerId()); haConfig.setResourceId(resourceId); haConfig.setResourceType(resourceType); if (Strings.isNullOrEmpty(haConfig.getHaProvider())) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "HAProvider is not provided for the resource, failing configuration."); haConfig.setEnabled(enable); haConfig.setHaProvider(haProvider); if (Strings.isNullOrEmpty(haConfig.getHaProvider())) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "HAProvider is not provided for the resource, failing configuration."); return haConfigDao.update(haConfig.getId(), haConfig);
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"; }
if (currentState == nextState && (haConfig.getManagementServerId() != null && haConfig.getManagementServerId().equals(newManagementServerId))) { return false; sc.setParameters("id", haConfig.getId()); sc.setParameters("haState", currentState); sc.setParameters("update", haConfig.getUpdateCount()); haConfig.incrUpdateCount(); UpdateBuilder ub = getUpdateBuilder(haConfig); ub.set(haConfig, HAStateAttr, nextState); 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()));