Search in sources :

Example 31 with ManagedChannelWrapper

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

the class AuditClient method createAuditEvent.

@Retryable(value = Exception.class, maxAttempts = 3, backoff = @Backoff(delay = 5000))
public void createAuditEvent(AuditEvent auditEvent) {
    try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
        String actorCrn = actorUtil.getActorCrn(auditEvent.getActor());
        LOGGER.info("Audit log entry will be created: {}", auditEvent);
        AuditProto.AuditEvent protoAuditEvent = auditEventConverter.convert(auditEvent);
        newStub(channelWrapper.getChannel(), protoAuditEvent.getRequestId(), actorCrn).createAuditEvent(CreateAuditEventRequest.newBuilder().setAuditEvent(protoAuditEvent).build());
    }
}
Also used : AuditProto(com.cloudera.thunderhead.service.audit.AuditProto) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) Retryable(org.springframework.retry.annotation.Retryable)

Example 32 with ManagedChannelWrapper

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

the class GrpcIdbmmsClient method getMappingsConfig.

/**
 * Retrieves IDBroker mappings from IDBMMS for a particular environment.
 *
 * @param actorCrn the actor CRN; must not be {@code null}
 * @param environmentCrn the environment CRN to get mappings for; must not be {@code null}
 * @param requestId an optional request ID; must not be {@code null}
 * @return the mappings config associated with environment {@code environmentCrn}; never {@code null}
 * @throws NullPointerException if either argument is {@code null}
 * @throws IdbmmsOperationException if any problem is encountered during the IDBMMS call processing
 */
public MappingsConfig getMappingsConfig(String actorCrn, String environmentCrn, Optional<String> requestId) {
    checkNotNull(actorCrn, "actorCrn should not be null.");
    checkNotNull(environmentCrn);
    checkNotNull(requestId, "requestId should not be null.");
    try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
        IdbmmsClient client = makeClient(channelWrapper.getChannel(), actorCrn);
        String effectiveRequestId = requestId.orElse(UUID.randomUUID().toString());
        LOGGER.debug("Fetching IDBroker mappings for environment {} using request ID {}", environmentCrn, effectiveRequestId);
        MappingsConfig mappingsConfig = client.getMappingsConfig(effectiveRequestId, environmentCrn);
        LOGGER.debug("Retrieved IDBroker mappings of version {} for environment {}", mappingsConfig.getMappingsVersion(), environmentCrn);
        return mappingsConfig;
    } catch (RuntimeException e) {
        throw new IdbmmsOperationException(String.format("Error during IDBMMS operation: %s", e.getMessage()), e);
    }
}
Also used : MappingsConfig(com.sequenceiq.cloudbreak.idbmms.model.MappingsConfig) IdbmmsOperationException(com.sequenceiq.cloudbreak.idbmms.exception.IdbmmsOperationException) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper)

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