Search in sources :

Example 1 with SiteErrorResponse

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

the class InternalSiteServiceClient method resumePrecheck.

public void resumePrecheck() {
    WebResource rRoot = createRequest(SITE_INTERNAL_RESUMEPRECHECK);
    SiteErrorResponse response;
    try {
        response = addSignature(rRoot).post(SiteErrorResponse.class);
    } catch (Exception e) {
        throw APIException.internalServerErrors.resumeStandbyPrecheckFailed(site.getName(), e.getMessage());
    }
    if (response != null && response.isErrorResponse()) {
        throw APIException.internalServerErrors.resumeStandbyPrecheckFailed(site.getName(), response.getErrorMessage());
    }
}
Also used : SiteErrorResponse(com.emc.storageos.model.dr.SiteErrorResponse) WebResource(com.sun.jersey.api.client.WebResource) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException)

Example 2 with SiteErrorResponse

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

the class InternalSiteServiceClient method switchoverPrecheck.

public void switchoverPrecheck() {
    WebResource rRoot = createRequest(SITE_INTERNAL_SWITCHOVERPRECHECK);
    SiteErrorResponse response;
    try {
        response = addSignature(rRoot).post(SiteErrorResponse.class);
    } catch (Exception e) {
        throw APIException.internalServerErrors.switchoverPrecheckFailed(site.getName(), e.getMessage());
    }
    if (response != null && response.isErrorResponse()) {
        throw APIException.internalServerErrors.switchoverPrecheckFailed(site.getName(), response.getErrorMessage());
    }
}
Also used : SiteErrorResponse(com.emc.storageos.model.dr.SiteErrorResponse) WebResource(com.sun.jersey.api.client.WebResource) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException)

Example 3 with SiteErrorResponse

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

the class DisasterRecoveryServiceTest method testGetSiteError.

@Test
public void testGetSiteError() {
    SiteErrorResponse siteError = drService.getSiteError("site-uuid-1");
    assertEquals(null, siteError.getCreationTime());
    assertEquals(null, siteError.getErrorMessage());
    assertEquals(null, siteError.getOperation());
    standbySite2.setState(SiteState.STANDBY_ERROR);
    standbySite2.setLastState(SiteState.STANDBY_ADDING);
    SiteError error = new SiteError(APIException.internalServerErrors.addStandbyFailedTimeout(20), SiteState.STANDBY_PAUSING.name());
    doReturn(error).when(coordinator).getTargetInfo(standbySite2.getUuid(), SiteError.class);
    siteError = drService.getSiteError(standbySite2.getUuid());
    assertEquals(new Date(error.getCreationTime()), siteError.getCreationTime());
    assertEquals(error.getErrorMessage(), siteError.getErrorMessage());
    assertEquals(error.getOperation(), siteError.getOperation());
    try {
        drService.getSiteError(NONEXISTENT_ID);
        assert false;
    } catch (Exception e) {
    // ingore expected exception
    }
}
Also used : SiteErrorResponse(com.emc.storageos.model.dr.SiteErrorResponse) SiteError(com.emc.storageos.coordinator.client.model.SiteError) Date(java.util.Date) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) Test(org.junit.Test)

Example 4 with SiteErrorResponse

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

the class DisasterRecoveryService method switchoverPrecheck.

/**
 * This is internal API to do precheck for switchover
 *
 * @return return response with error message and service code
 */
@POST
@Path("/internal/switchoverprecheck")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public SiteErrorResponse switchoverPrecheck() {
    log.info("Precheck for switchover internally");
    SiteErrorResponse response = new SiteErrorResponse();
    try {
        precheckForSwitchoverForLocalStandby();
    } catch (InternalServerErrorException e) {
        log.warn("Failed to precheck switchover", e);
        response.setErrorMessage(e.getMessage());
        response.setServiceCode(e.getServiceCode().ordinal());
        return response;
    } catch (Exception e) {
        log.error("Failed to precheck switchover", e);
        response.setErrorMessage(e.getMessage());
        return response;
    }
    return response;
}
Also used : SiteErrorResponse(com.emc.storageos.model.dr.SiteErrorResponse) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) 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) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 5 with SiteErrorResponse

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

the class DisasterRecovery method errorDetails.

public static void errorDetails(String id) {
    Boolean isError = false;
    String uuid = id;
    // site id doesn't exist
    if (!DisasterRecoveryUtils.hasStandbySite(id)) {
        SiteDetailRestRep disasterSiteTime = new SiteDetailRestRep();
        uuid = "Unknown Standby site id: " + id;
        render(isError, uuid, disasterSiteTime);
    }
    SiteRestRep siteRest = DisasterRecoveryUtils.getSite(id);
    // site is in STANDBY_ERROR state
    if (siteRest.getState().equals(String.valueOf(SiteState.STANDBY_ERROR))) {
        SiteErrorResponse disasterSiteError = DisasterRecoveryUtils.getSiteError(id);
        isError = true;
        if (disasterSiteError.getCreationTime() != null) {
            DateTime errorCreationTime = new DateTime(disasterSiteError.getCreationTime().getTime());
            renderArgs.put("errorCreationTime", errorCreationTime);
        }
        DateTime siteCreationTime = new DateTime(siteRest.getCreateTime());
        renderArgs.put("siteCreationTime", siteCreationTime);
        if (disasterSiteError.getOperation() != null) {
            String operation = disasterSiteError.getOperation();
            renderArgs.put("operation", operation);
        }
        render(isError, uuid, disasterSiteError);
    }
    SiteDetailRestRep disasterSiteDetails = DisasterRecoveryUtils.getSiteDetails(id);
    Boolean isActive = isActiveSiteState(Enum.valueOf(SiteState.class, siteRest.getState()));
    renderArgs.put("isActive", isActive);
    if (disasterSiteDetails.getLastSyncTime() != null) {
        DateTime lastSyncTime = new DateTime(disasterSiteDetails.getLastSyncTime().getTime());
        renderArgs.put("lastSyncTime", lastSyncTime);
    }
    if (disasterSiteDetails.getCreationTime() != null) {
        DateTime creationTime = new DateTime(disasterSiteDetails.getCreationTime().getTime());
        renderArgs.put("creationTime", creationTime);
    }
    render(isError, uuid, disasterSiteDetails);
}
Also used : SiteRestRep(com.emc.storageos.model.dr.SiteRestRep) SiteState(com.emc.storageos.coordinator.client.model.SiteState) SiteErrorResponse(com.emc.storageos.model.dr.SiteErrorResponse) SiteDetailRestRep(com.emc.storageos.model.dr.SiteDetailRestRep) DateTime(org.joda.time.DateTime)

Aggregations

SiteErrorResponse (com.emc.storageos.model.dr.SiteErrorResponse)7 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)5 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)3 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)3 ZkPath (com.emc.storageos.coordinator.common.impl.ZkPath)2 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)2 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)2 WebResource (com.sun.jersey.api.client.WebResource)2 UnknownHostException (java.net.UnknownHostException)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 SiteError (com.emc.storageos.coordinator.client.model.SiteError)1 SiteState (com.emc.storageos.coordinator.client.model.SiteState)1 SiteDetailRestRep (com.emc.storageos.model.dr.SiteDetailRestRep)1 SiteRestRep (com.emc.storageos.model.dr.SiteRestRep)1 BadRequestException (com.emc.storageos.svcs.errorhandling.resources.BadRequestException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Date (java.util.Date)1 DateTime (org.joda.time.DateTime)1