Search in sources :

Example 1 with SiteRemoved

use of com.emc.storageos.model.dr.SiteRemoved in project coprhd-controller by CoprHD.

the class DisasterRecoveryService method isLocalSiteRemoved.

/**
 *  Check if Local Site Removed
 *
 * @brief Check if local site is removed
 * @return result that indicates whether local site is removed
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/islocalsiteremoved")
public SiteRemoved isLocalSiteRemoved() {
    SiteRemoved response = new SiteRemoved();
    Site localSite = drUtil.getLocalSite();
    if (SiteState.ACTIVE == localSite.getState()) {
        return response;
    }
    for (Site remoteSite : drUtil.listSites()) {
        if (remoteSite.getUuid().equals(localSite.getUuid())) {
            continue;
        }
        try (InternalSiteServiceClient client = new InternalSiteServiceClient(remoteSite, coordinator, apiSignatureGenerator)) {
            SiteList sites = client.getSiteList();
            if (!isActiveSite(remoteSite.getUuid(), sites)) {
                continue;
            }
            if (isSiteContainedBy(localSite.getUuid(), sites)) {
                return response;
            } else {
                log.info("According returned result from current active site {}, local site {} has been removed", remoteSite.getUuid(), localSite.getUuid());
                response.setIsRemoved(true);
                return response;
            }
        } catch (Exception e) {
            log.warn("Error happened when fetching site list from site {}", remoteSite.getUuid(), e);
            continue;
        }
    }
    return response;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) SiteList(com.emc.storageos.model.dr.SiteList) SiteRemoved(com.emc.storageos.model.dr.SiteRemoved) InternalSiteServiceClient(com.emc.storageos.api.service.impl.resource.utils.InternalSiteServiceClient) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) UnknownHostException(java.net.UnknownHostException) Path(javax.ws.rs.Path) ZkPath(com.emc.storageos.coordinator.common.impl.ZkPath) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

InternalSiteServiceClient (com.emc.storageos.api.service.impl.resource.utils.InternalSiteServiceClient)1 Site (com.emc.storageos.coordinator.client.model.Site)1 ZkPath (com.emc.storageos.coordinator.common.impl.ZkPath)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)1 SiteList (com.emc.storageos.model.dr.SiteList)1 SiteRemoved (com.emc.storageos.model.dr.SiteRemoved)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 UnknownHostException (java.net.UnknownHostException)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1