Search in sources :

Example 21 with ManagedChannelWrapper

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

the class GrpcClusterDnsClient method createOrUpdateDnsEntryWithCloudDns.

public CreateDnsEntryResponse createOrUpdateDnsEntryWithCloudDns(String accountId, String endpoint, String environment, String cloudDns, String hostedZoneId, Optional<String> requestId) {
    try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
        ClusterDnsClient client = makeClient(channelWrapper.getChannel(), regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString());
        LOGGER.info("Create a dns entry with account id: {} and requestId: {} for cloud DNS: {}", accountId, requestId, cloudDns);
        CreateDnsEntryResponse response = client.createDnsEntryWithCloudDns(requestId.orElse(UUID.randomUUID().toString()), accountId, endpoint, environment, cloudDns, hostedZoneId);
        LOGGER.info("Dns entry creation finished for cloud DNS {}", cloudDns);
        return response;
    }
}
Also used : CreateDnsEntryResponse(com.cloudera.thunderhead.service.publicendpointmanagement.PublicEndpointManagementProto.CreateDnsEntryResponse) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper)

Example 22 with ManagedChannelWrapper

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

Example 23 with ManagedChannelWrapper

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

the class DatalakeDrClient method getBackupStatusByBackupId.

public DatalakeBackupStatusResponse getBackupStatusByBackupId(String datalakeName, String backupId, String backupName, String actorCrn) {
    if (!datalakeDrConfig.isConfigured()) {
        return missingConnectorResponseOnBackup();
    }
    checkNotNull(datalakeName);
    checkNotNull(actorCrn, "actorCrn should not be null.");
    checkNotNull(backupId);
    try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
        BackupDatalakeStatusRequest.Builder builder = BackupDatalakeStatusRequest.newBuilder().setDatalakeName(datalakeName).setBackupId(backupId);
        if (!Strings.isNullOrEmpty(backupName)) {
            builder.setBackupName(backupName);
        }
        return statusConverter.convert(newStub(channelWrapper.getChannel(), UUID.randomUUID().toString(), actorCrn).backupDatalakeStatus(builder.build()));
    }
}
Also used : BackupDatalakeStatusRequest(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto.BackupDatalakeStatusRequest) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper)

Example 24 with ManagedChannelWrapper

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

the class SigmaDatabusClient method putRecord.

/**
 * Upload data into databus. If the payload is larger than 1 MB, the data will be uploaded to cloudera S3.
 * @param request databus record payload input
 * @throws DatabusRecordProcessingException error during databus record processing
 */
public void putRecord(DatabusRequest request) throws DatabusRecordProcessingException {
    ManagedChannelWrapper channelWrapper = getMessageWrapper();
    DbusProto.PutRecordRequest recordRequest = convert(request, databusStreamConfiguration);
    String requestId = MDCBuilder.getOrGenerateRequestId();
    LOGGER.debug("Creating databus request with request id: {}", requestId);
    buildMdcContext(request, requestId);
    DbusProto.PutRecordResponse recordResponse = newStub(channelWrapper.getChannel(), requestId, regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString()).putRecord(recordRequest);
    DbusProto.Record.Reply.Status status = recordResponse.getRecord().getStatus();
    LOGGER.debug("Returned dbus record status is {}", status);
    if (DbusProto.Record.Reply.Status.SENT.equals(status)) {
        String recordId = recordResponse.getRecord().getRecordId();
        LOGGER.debug("Dbus record sucessfully processed with record id: {}", recordId);
    } else if (DbusProto.Record.Reply.Status.PENDING.equals(status)) {
        String recordId = recordResponse.getRecord().getRecordId();
        String s3BucketUrl = recordResponse.getRecord().getUploadUrl();
        LOGGER.debug("Dbus record can be uploaded to s3 [record id: {}], [s3 url: {}]", recordId, s3BucketUrl);
        uploadRecordToS3(s3BucketUrl, request, recordId);
    } else {
        throw new DatabusRecordProcessingException("Cannot process record to Sigma Databus.");
    }
}
Also used : DatabusRecordProcessingException(com.sequenceiq.cloudbreak.sigmadbus.model.DatabusRecordProcessingException) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) DbusProto(com.cloudera.sigma.service.dbus.DbusProto)

Example 25 with ManagedChannelWrapper

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

the class GrpcCcmV2Client method unRegisterAgent.

public UnregisterAgentResponse unRegisterAgent(String requestId, String agentCrn, String actorCrn) {
    try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
        ClusterConnectivityManagementV2BlockingStub client = makeClient(channelWrapper.getChannel(), requestId, actorCrn);
        UnregisterAgentRequest unregisterAgentRequest = UnregisterAgentRequest.newBuilder().setAgentCrn(agentCrn).build();
        LOGGER.debug("Calling unRegisterAgent with params agentCrn: '{}'", agentCrn);
        return client.unregisterAgent(unregisterAgentRequest);
    }
}
Also used : UnregisterAgentRequest(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.UnregisterAgentRequest) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) ClusterConnectivityManagementV2BlockingStub(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub)

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