Search in sources :

Example 11 with ManagedChannelWrapper

use of com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper 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 12 with ManagedChannelWrapper

use of com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper in project cloudbreak by hortonworks.

the class DatalakeDrClient method getRestoreId.

public String getRestoreId(String datalakeName, String backupName, String actorCrn) {
    if (!datalakeDrConfig.isConfigured()) {
        throw new IllegalStateException("altus.datalakedr.endpoint is not enabled or configured appropriately!");
    }
    checkNotNull(datalakeName);
    checkNotNull(actorCrn, "actorCrn should not be null.");
    try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
        RestoreDatalakeStatusRequest.Builder builder = RestoreDatalakeStatusRequest.newBuilder().setDatalakeName(datalakeName);
        return newStub(channelWrapper.getChannel(), UUID.randomUUID().toString(), actorCrn).restoreDatalakeStatus(builder.build()).getRestoreId();
    }
}
Also used : ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) RestoreDatalakeStatusRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.RestoreDatalakeStatusRequest)

Example 13 with ManagedChannelWrapper

use of com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper in project cloudbreak by hortonworks.

the class DatalakeDrClient method getRestoreStatusByRestoreId.

public DatalakeBackupStatusResponse getRestoreStatusByRestoreId(String datalakeName, String restoreId, String actorCrn) {
    if (!datalakeDrConfig.isConfigured()) {
        return missingConnectorResponseOnBackup();
    }
    checkNotNull(datalakeName);
    checkNotNull(actorCrn, "actorCrn should not be null.");
    checkNotNull(restoreId);
    try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
        RestoreDatalakeStatusRequest.Builder builder = RestoreDatalakeStatusRequest.newBuilder().setDatalakeName(datalakeName).setRestoreId(restoreId);
        return statusConverter.convert(newStub(channelWrapper.getChannel(), UUID.randomUUID().toString(), actorCrn).restoreDatalakeStatus(builder.build()));
    }
}
Also used : ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) RestoreDatalakeStatusRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.RestoreDatalakeStatusRequest)

Example 14 with ManagedChannelWrapper

use of com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper in project cloudbreak by hortonworks.

the class AuditClient method listEvents.

public List<AuditProto.CdpAuditEvent> listEvents(ListAuditEvent listAuditEvent) {
    try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
        String actorCrn = actorUtil.getActorCrn(listAuditEvent.getActor());
        AuditProto.ListEventsRequest.Builder builder = AuditProto.ListEventsRequest.newBuilder();
        doIfNotNull(listAuditEvent.getEventSource(), eventSource -> builder.setEventSource(eventSource.getName()));
        doIfNotNull(listAuditEvent.getAccountId(), builder::setAccountId);
        doIfNotNull(listAuditEvent.getRequestId(), builder::setRequestId);
        doIfNotNull(listAuditEvent.getFromTimestamp(), builder::setFromTimestamp);
        doIfNotNull(listAuditEvent.getToTimestamp(), builder::setToTimestamp);
        doIfNotNull(listAuditEvent.getPageSize(), builder::setPageSize);
        doIfNotNull(listAuditEvent.getPageToken(), builder::setPageToken);
        AuditProto.ListEventsResponse listEventsResponse = newStub(channelWrapper.getChannel(), UUID.randomUUID().toString(), actorCrn).listEvents(builder.build());
        return listEventsResponse.getAuditEventList();
    }
}
Also used : AuditProto(com.cloudera.thunderhead.service.audit.AuditProto) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper)

Example 15 with ManagedChannelWrapper

use of com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper in project cloudbreak by hortonworks.

the class GrpcClusterDnsClient method deleteDnsEntryWithIp.

public DeleteDnsEntryResponse deleteDnsEntryWithIp(String accountId, String endpoint, String environment, boolean wildcard, List<String> ips, Optional<String> requestId) {
    try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
        ClusterDnsClient client = makeClient(channelWrapper.getChannel(), regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString());
        LOGGER.info("Delete a dns entry with account id: {} and requestId: {} for ips: {}", accountId, requestId, String.join(",", ips));
        DeleteDnsEntryResponse response = client.deleteDnsEntryWithIp(requestId.orElse(UUID.randomUUID().toString()), accountId, endpoint, environment, wildcard, ips);
        LOGGER.info("Dns entry deletion finished for ips {}", String.join(",", ips));
        return response;
    }
}
Also used : ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) DeleteDnsEntryResponse(com.cloudera.thunderhead.service.publicendpointmanagement.PublicEndpointManagementProto.DeleteDnsEntryResponse)

Aggregations

ManagedChannelWrapper (com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper)32 BackupDatalakeStatusRequest (com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.BackupDatalakeStatusRequest)6 RestoreDatalakeStatusRequest (com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.RestoreDatalakeStatusRequest)6 AuditProto (com.cloudera.thunderhead.service.audit.AuditProto)4 ClusterConnectivityManagementV2BlockingStub (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub)4 BackupDatalakeRequest (com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.BackupDatalakeRequest)4 RestoreDatalakeRequest (com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.RestoreDatalakeRequest)4 ManagedChannelBuilder (io.grpc.ManagedChannelBuilder)4 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 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 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)3 Strings (com.google.common.base.Strings)3 CcmException (com.sequenceiq.cloudbreak.ccm.exception.CcmException)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