Search in sources :

Example 1 with DatalakeBackupInfo

use of com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.DatalakeBackupInfo in project cloudbreak by hortonworks.

the class DatalakeDrClient method getLastSuccessBackup.

public DatalakeBackupInfo getLastSuccessBackup(String datalakeName, String actorCrn) {
    DatalakeBackupInfo datalakeBackupInfo = null;
    if (!datalakeDrConfig.isConfigured()) {
        return null;
    }
    checkNotNull(datalakeName);
    checkNotNull(actorCrn, "actorCrn should not be null.");
    try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
        ListDatalakeBackupRequest.Builder builder = ListDatalakeBackupRequest.newBuilder().setDatalakeName(datalakeName);
        ListDatalakeBackupResponse response = newStub(channelWrapper.getChannel(), UUID.randomUUID().toString(), actorCrn).listDatalakeBackups(builder.build());
        if (response != null && response.getDatalakeInfoList() != null) {
            datalakeBackupInfo = response.getDatalakeInfoList().stream().filter(backup -> "SUCCESSFUL".equals(backup.getOverallState())).findFirst().orElse(null);
        }
        return datalakeBackupInfo;
    }
}
Also used : RestoreDatalakeRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.RestoreDatalakeRequest) DEFAULT_MAX_MESSAGE_SIZE(io.grpc.internal.GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE) com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc.datalakeDRBlockingStub(com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc.datalakeDRBlockingStub) ManagedChannel(io.grpc.ManagedChannel) LoggerFactory(org.slf4j.LoggerFactory) BackupDatalakeStatusRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.BackupDatalakeStatusRequest) RestoreDatalakeStatusRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.RestoreDatalakeStatusRequest) ListDatalakeBackupRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.ListDatalakeBackupRequest) DatalakeBackupInfo(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.DatalakeBackupInfo) Strings(com.google.common.base.Strings) DatalakeBackupStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse) com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc(com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc) BackupDatalakeRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.BackupDatalakeRequest) GrpcStatusResponseToDatalakeBackupRestoreStatusResponseConverter(com.sequenceiq.cloudbreak.datalakedr.converter.GrpcStatusResponseToDatalakeBackupRestoreStatusResponseConverter) AltusMetadataInterceptor(com.sequenceiq.cloudbreak.grpc.altus.AltusMetadataInterceptor) GrpcUtil(com.sequenceiq.cloudbreak.grpc.util.GrpcUtil) Logger(org.slf4j.Logger) Tracer(io.opentracing.Tracer) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) UUID(java.util.UUID) ManagedChannelBuilder(io.grpc.ManagedChannelBuilder) Component(org.springframework.stereotype.Component) DatalakeDrConfig(com.sequenceiq.cloudbreak.datalakedr.config.DatalakeDrConfig) Optional(java.util.Optional) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) DatalakeRestoreStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse) ListDatalakeBackupResponse(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.ListDatalakeBackupResponse) DatalakeBackupInfo(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.DatalakeBackupInfo) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) ListDatalakeBackupResponse(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.ListDatalakeBackupResponse) ListDatalakeBackupRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.ListDatalakeBackupRequest)

Example 2 with DatalakeBackupInfo

use of com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.DatalakeBackupInfo in project cloudbreak by hortonworks.

the class DatalakeDrClient method getLastSuccessfulBackup.

public DatalakeBackupInfo getLastSuccessfulBackup(String datalakeName, String actorCrn, Optional<String> runtime) {
    if (!datalakeDrConfig.isConfigured()) {
        return null;
    }
    checkNotNull(datalakeName);
    checkNotNull(actorCrn, "actorCrn should not be null.");
    try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
        ListDatalakeBackupRequest.Builder builder = ListDatalakeBackupRequest.newBuilder().setDatalakeName(datalakeName);
        ListDatalakeBackupResponse response = newStub(channelWrapper.getChannel(), UUID.randomUUID().toString(), actorCrn).listDatalakeBackups(builder.build());
        if (response != null) {
            return response.getDatalakeInfoList().stream().filter(backup -> "SUCCESSFUL".equals(backup.getOverallState())).filter(backup -> runtime.isEmpty() || backup.getRuntimeVersion().equalsIgnoreCase(runtime.get())).peek(backupInfo -> LOGGER.debug("The following successful backup was found for data lake {} and runtime {}: {}", datalakeName, runtime, backupInfo)).findFirst().orElse(null);
        }
        LOGGER.debug("No successful backup was found for data lake {} and runtime {}", datalakeName, runtime);
        return null;
    }
}
Also used : RestoreDatalakeRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.RestoreDatalakeRequest) DEFAULT_MAX_MESSAGE_SIZE(io.grpc.internal.GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE) com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc.datalakeDRBlockingStub(com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc.datalakeDRBlockingStub) ManagedChannel(io.grpc.ManagedChannel) LoggerFactory(org.slf4j.LoggerFactory) BackupDatalakeStatusRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.BackupDatalakeStatusRequest) RestoreDatalakeStatusRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.RestoreDatalakeStatusRequest) ListDatalakeBackupRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.ListDatalakeBackupRequest) DatalakeBackupInfo(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.DatalakeBackupInfo) Strings(com.google.common.base.Strings) DatalakeBackupStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse) com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc(com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc) BackupDatalakeRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.BackupDatalakeRequest) GrpcStatusResponseToDatalakeBackupRestoreStatusResponseConverter(com.sequenceiq.cloudbreak.datalakedr.converter.GrpcStatusResponseToDatalakeBackupRestoreStatusResponseConverter) AltusMetadataInterceptor(com.sequenceiq.cloudbreak.grpc.altus.AltusMetadataInterceptor) GrpcUtil(com.sequenceiq.cloudbreak.grpc.util.GrpcUtil) Logger(org.slf4j.Logger) Tracer(io.opentracing.Tracer) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) UUID(java.util.UUID) ManagedChannelBuilder(io.grpc.ManagedChannelBuilder) Component(org.springframework.stereotype.Component) DatalakeDrConfig(com.sequenceiq.cloudbreak.datalakedr.config.DatalakeDrConfig) Optional(java.util.Optional) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) DatalakeRestoreStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse) ListDatalakeBackupResponse(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.ListDatalakeBackupResponse) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) ListDatalakeBackupResponse(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.ListDatalakeBackupResponse) ListDatalakeBackupRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.ListDatalakeBackupRequest)

Example 3 with DatalakeBackupInfo

use of com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.DatalakeBackupInfo in project cloudbreak by hortonworks.

the class DatalakeDrClient method getBackupById.

public DatalakeBackupInfo getBackupById(String datalakeName, String backupId, String actorCrn) {
    DatalakeBackupInfo datalakeBackupInfo = null;
    if (!datalakeDrConfig.isConfigured()) {
        return null;
    }
    checkNotNull(datalakeName);
    checkNotNull(backupId);
    checkNotNull(actorCrn, "actorCrn should not be null.");
    try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
        ListDatalakeBackupRequest.Builder builder = ListDatalakeBackupRequest.newBuilder().setDatalakeName(datalakeName);
        ListDatalakeBackupResponse response = newStub(channelWrapper.getChannel(), UUID.randomUUID().toString(), actorCrn).listDatalakeBackups(builder.build());
        if (response != null) {
            datalakeBackupInfo = response.getDatalakeInfoList().stream().filter(backup -> backupId.equals(backup.getBackupId())).findFirst().orElse(null);
        }
        return datalakeBackupInfo;
    }
}
Also used : RestoreDatalakeRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.RestoreDatalakeRequest) DEFAULT_MAX_MESSAGE_SIZE(io.grpc.internal.GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE) com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc.datalakeDRBlockingStub(com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc.datalakeDRBlockingStub) ManagedChannel(io.grpc.ManagedChannel) LoggerFactory(org.slf4j.LoggerFactory) BackupDatalakeStatusRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.BackupDatalakeStatusRequest) RestoreDatalakeStatusRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.RestoreDatalakeStatusRequest) ListDatalakeBackupRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.ListDatalakeBackupRequest) DatalakeBackupInfo(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.DatalakeBackupInfo) Strings(com.google.common.base.Strings) DatalakeBackupStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse) com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc(com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc) BackupDatalakeRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.BackupDatalakeRequest) GrpcStatusResponseToDatalakeBackupRestoreStatusResponseConverter(com.sequenceiq.cloudbreak.datalakedr.converter.GrpcStatusResponseToDatalakeBackupRestoreStatusResponseConverter) AltusMetadataInterceptor(com.sequenceiq.cloudbreak.grpc.altus.AltusMetadataInterceptor) GrpcUtil(com.sequenceiq.cloudbreak.grpc.util.GrpcUtil) Logger(org.slf4j.Logger) Tracer(io.opentracing.Tracer) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) UUID(java.util.UUID) ManagedChannelBuilder(io.grpc.ManagedChannelBuilder) Component(org.springframework.stereotype.Component) DatalakeDrConfig(com.sequenceiq.cloudbreak.datalakedr.config.DatalakeDrConfig) Optional(java.util.Optional) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) DatalakeRestoreStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse) ListDatalakeBackupResponse(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.ListDatalakeBackupResponse) DatalakeBackupInfo(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.DatalakeBackupInfo) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) ListDatalakeBackupResponse(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.ListDatalakeBackupResponse) ListDatalakeBackupRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.ListDatalakeBackupRequest)

Aggregations

com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc (com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc)3 com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc.datalakeDRBlockingStub (com.cloudera.thunderhead.service.datalakedr.datalakeDRGrpc.datalakeDRBlockingStub)3 BackupDatalakeRequest (com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.BackupDatalakeRequest)3 BackupDatalakeStatusRequest (com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.BackupDatalakeStatusRequest)3 DatalakeBackupInfo (com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.DatalakeBackupInfo)3 ListDatalakeBackupRequest (com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.ListDatalakeBackupRequest)3 ListDatalakeBackupResponse (com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.ListDatalakeBackupResponse)3 RestoreDatalakeRequest (com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.RestoreDatalakeRequest)3 RestoreDatalakeStatusRequest (com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.RestoreDatalakeStatusRequest)3 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)3 Strings (com.google.common.base.Strings)3 DatalakeDrConfig (com.sequenceiq.cloudbreak.datalakedr.config.DatalakeDrConfig)3 GrpcStatusResponseToDatalakeBackupRestoreStatusResponseConverter (com.sequenceiq.cloudbreak.datalakedr.converter.GrpcStatusResponseToDatalakeBackupRestoreStatusResponseConverter)3 DatalakeBackupStatusResponse (com.sequenceiq.cloudbreak.datalakedr.model.DatalakeBackupStatusResponse)3 DatalakeRestoreStatusResponse (com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse)3 ManagedChannelWrapper (com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper)3 AltusMetadataInterceptor (com.sequenceiq.cloudbreak.grpc.altus.AltusMetadataInterceptor)3 GrpcUtil (com.sequenceiq.cloudbreak.grpc.util.GrpcUtil)3 ManagedChannel (io.grpc.ManagedChannel)3 ManagedChannelBuilder (io.grpc.ManagedChannelBuilder)3