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;
}
}
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();
}
}
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()));
}
}
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();
}
}
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;
}
}
Aggregations