Search in sources :

Example 1 with SdxRestoreStatusResponse

use of com.sequenceiq.sdx.api.model.SdxRestoreStatusResponse in project cloudbreak by hortonworks.

the class SdxBackupRestoreService method getDatalakeRestoreStatus.

public SdxRestoreStatusResponse getDatalakeRestoreStatus(String datalakeName, String restoreId, String backupName, String userCrn) {
    LOGGER.info("Requesting datalake restore status for datalake: '{}' with restoreId '{}'", datalakeName, restoreId);
    DatalakeBackupStatusResponse datalakeBackupStatusResponse = datalakeDrClient.getRestoreStatus(datalakeName, restoreId, backupName, userCrn);
    return new SdxRestoreStatusResponse(datalakeBackupStatusResponse.getBackupId(), datalakeBackupStatusResponse.getState().name(), datalakeBackupStatusResponse.getFailureReason());
}
Also used : DatalakeBackupStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse) SdxRestoreStatusResponse(com.sequenceiq.sdx.api.model.SdxRestoreStatusResponse)

Example 2 with SdxRestoreStatusResponse

use of com.sequenceiq.sdx.api.model.SdxRestoreStatusResponse in project cloudbreak by hortonworks.

the class SdxBackupRestoreTest method validateDatalakeRestoreStatus.

private SdxInternalTestDto validateDatalakeRestoreStatus(TestContext testContext, SdxInternalTestDto testDto, SdxClient client) {
    String sdxName = testDto.getName();
    String status;
    String statusReason;
    try {
        restoreId = client.getDefaultClient().sdxRestoreEndpoint().getDatalakeRestoreId(sdxName, null);
        SdxRestoreStatusResponse sdxRestoreStatusResponse = client.getDefaultClient().sdxRestoreEndpoint().getRestoreDatalakeStatus(sdxName, restoreId, null);
        status = sdxRestoreStatusResponse.getStatus();
        statusReason = sdxRestoreStatusResponse.getReason();
        LOGGER.info(format(" SDX '%s' restore '%s' status '%s', because of %s ", sdxName, restoreId, status, statusReason));
    } catch (Exception e) {
        if (e.getMessage().contains("not found")) {
            throw new TestFailException(String.format(" NOT FOUND :: Cannot get status information for restore '%s' on datalake '%s'." + " Please check the selected backup was successful and the related backup ID is correct. ", restoreId, testDto.getName()), e.getCause());
        }
        throw e;
    }
    if (StringUtils.isBlank(status)) {
        LOGGER.error(String.format(" Sdx '%s' restore status is not available ", testDto.getName()));
        throw new TestFailException(String.format(" Sdx '%s' restore status is not available  ", testDto.getName()));
    } else if (status.contains("FAILED")) {
        LOGGER.error(String.format(" Sdx '%s' restore has been failed: '%s' ", testDto.getName(), statusReason));
        throw new TestFailException(String.format(" Sdx '%s' restore has been failed: '%s' ", testDto.getName(), statusReason));
    } else {
        LOGGER.info(String.format(" Sdx '%s' restore has been done with '%s'. ", testDto.getName(), statusReason));
        Log.then(LOGGER, format(" Sdx '%s' restore has been done with '%s'. ", testDto.getName(), statusReason));
    }
    return testDto;
}
Also used : SdxRestoreStatusResponse(com.sequenceiq.sdx.api.model.SdxRestoreStatusResponse) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Aggregations

SdxRestoreStatusResponse (com.sequenceiq.sdx.api.model.SdxRestoreStatusResponse)2 DatalakeBackupStatusResponse (com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1