use of com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper 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;
}
}
use of com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper in project cloudbreak by hortonworks.
the class GrpcCcmV2Client method registerAgent.
public InvertingProxyAgent registerAgent(String requestId, String accountId, Optional<String> environmentCrnOpt, String domainName, String keyId, String actorCrn) {
try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
ClusterConnectivityManagementV2BlockingStub client = makeClient(channelWrapper.getChannel(), requestId, actorCrn);
RegisterAgentRequest.Builder registerAgentRequestBuilder = RegisterAgentRequest.newBuilder().setAccountId(accountId).setDomainName(domainName).setKeyId(keyId);
environmentCrnOpt.ifPresent(registerAgentRequestBuilder::setEnvironmentCrn);
RegisterAgentRequest registerAgentRequest = registerAgentRequestBuilder.build();
LOGGER.debug("Calling registerAgent with params accountId: '{}', environmentCrnOpt: '{}', domainName: '{}', keyId:'{}' ", accountId, environmentCrnOpt, domainName, keyId);
RegisterAgentResponse registerAgentResponse = client.registerAgent(registerAgentRequest);
return registerAgentResponse.getInvertingProxyAgent();
}
}
use of com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper in project cloudbreak by hortonworks.
the class GrpcMinaSshdManagementClient method generateAndRegisterSshTunnelingKeyPair.
/**
* Wraps call to generateAndRegisterSshTunnelingKeyPair, with retries to tolerate transient failures.
*
* @param requestId the request ID for the request
* @param actorCrn the actor CRN
* @param accountId the account ID
* @param minaSshdServiceId the minasshd service ID
* @param keyId the key ID
* @return the response containing the key pair
* @throws CcmException if an exception occurs
* @throws InterruptedException if the action is interrupted
*/
public MinaSshdManagementProto.GenerateAndRegisterSshTunnelingKeyPairResponse generateAndRegisterSshTunnelingKeyPair(String requestId, String actorCrn, String accountId, String minaSshdServiceId, String keyId) throws CcmException, InterruptedException {
try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
MinaSshdManagementClient client = makeClient(channelWrapper.getChannel(), actorCrn);
ZonedDateTime waitUntilTime = ZonedDateTime.now(clock).plus(minaSshdManagementClientConfig.getTimeoutMs(), ChronoUnit.MILLIS);
int pollingIntervalMillis = minaSshdManagementClientConfig.getPollingIntervalMs();
String actionDescription = "generate tunneling key pair for accountId " + accountId;
Supplier<CcmException> timeoutExceptionSupplier = () -> new CcmException(String.format("Timed out while trying to %s", actionDescription), true);
return RetryUtil.performWithRetries(() -> client.generateAndRegisterSshTunnelingKeyPair(requestId, accountId, minaSshdServiceId, keyId), actionDescription, waitUntilTime, pollingIntervalMillis, CcmException.class, timeoutExceptionSupplier, LOGGER);
}
}
use of com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper in project cloudbreak by hortonworks.
the class GrpcMinaSshdManagementClient method unregisterSshTunnelingKey.
/**
* Wraps call to unregisterSshTunnelingKey, with retries to tolerate transient failures.
*
* @param requestId the request ID for the request
* @param actorCrn the actor CRN
* @param accountId the account ID
* @param keyId the key ID
* @param minaSshdServiceId minaSshdServiceId
* @return the response
* @throws CcmException if an exception occurs
* @throws InterruptedException if the action is interrupted
*/
public MinaSshdManagementProto.UnregisterSshTunnelingKeyResponse unregisterSshTunnelingKey(String requestId, String actorCrn, String accountId, String keyId, String minaSshdServiceId) throws CcmException, InterruptedException {
try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
MinaSshdManagementClient client = makeClient(channelWrapper.getChannel(), actorCrn);
ZonedDateTime waitUntilTime = ZonedDateTime.now(clock).plus(minaSshdManagementClientConfig.getTimeoutMs(), ChronoUnit.MILLIS);
int pollingIntervalMillis = minaSshdManagementClientConfig.getPollingIntervalMs();
String actionDescription = "deregister tunneling key " + keyId;
Supplier<CcmException> timeoutExceptionSupplier = () -> new CcmException(String.format("Timed out while trying to %s", actionDescription), true);
return RetryUtil.performWithRetries(() -> client.unregisterSshTunnelingKey(requestId, minaSshdServiceId, keyId), actionDescription, waitUntilTime, pollingIntervalMillis, CcmException.class, timeoutExceptionSupplier, LOGGER);
}
}
use of com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper in project cloudbreak by hortonworks.
the class GrpcIdbmmsClient method deleteMappings.
/**
* Deletes IDBroker mappings in IDBMMS for a particular environment.
*
* @param actorCrn the actor CRN; must not be {@code null}
* @param environmentCrn the environment CRN to delete mappings for; must not be {@code null}
* @param requestId an optional request ID; must not be {@code null}
* @throws NullPointerException if either argument is {@code null}
* @throws IdbmmsOperationException if any problem is encountered during the IDBMMS call processing
*/
public void deleteMappings(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("Deleting IDBroker mappings for environment {} using request ID {}", environmentCrn, effectiveRequestId);
client.deleteMappings(effectiveRequestId, environmentCrn);
LOGGER.debug("Deleted IDBroker mappings for environment {}", environmentCrn);
} catch (RuntimeException e) {
throw new IdbmmsOperationException(String.format("Error during IDBMMS operation: %s", e.getMessage()), e);
}
}
Aggregations