use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class DiagnosticsService method collectCmDiagnostics.
public FlowIdentifier collectCmDiagnostics(CmDiagnosticsCollectionRequest request) {
String userId = ThreadBasedUserCrnProvider.getUserCrn();
SdxCluster cluster = sdxService.getByCrn(userId, request.getStackCrn());
StackV4Response stackV4Response = sdxService.getDetail(cluster.getClusterName(), new HashSet<>(), cluster.getAccountId());
diagnosticsCollectionValidator.validate(request, stackV4Response);
Map<String, Object> properties = diagnosticsParamsConverter.convertFromCmRequest(request);
SdxCmDiagnosticsCollectionEvent event = new SdxCmDiagnosticsCollectionEvent(cluster.getId(), userId, properties, null);
FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerCmDiagnosticsCollection(event, cluster.getClusterName());
LOGGER.debug("Start CM based diagnostics collection with flow pollable identifier: {}", flowIdentifier.getPollableId());
return flowIdentifier;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class SdxBackupRestoreService method getStackResponseAttemptResult.
private AttemptResult<StackV4Response> getStackResponseAttemptResult(SdxCluster sdxCluster, String pollingMessage, FlowState flowState) throws JsonProcessingException {
StackV4Response stackV4Response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.get(0L, sdxCluster.getClusterName(), Collections.emptySet(), sdxCluster.getAccountId()));
LOGGER.info("Response from cloudbreak: {}", JsonUtil.writeValueAsString(stackV4Response));
ClusterV4Response cluster = stackV4Response.getCluster();
if (isStackOrClusterDrStatusComplete(stackV4Response.getStatus()) && isStackOrClusterDrStatusComplete(cluster.getStatus())) {
return sdxDrSucceeded(stackV4Response);
} else if (isStackOrClusterStatusFailed(stackV4Response.getStatus())) {
LOGGER.info("{} failed for Stack {} with status {}", pollingMessage, stackV4Response.getName(), stackV4Response.getStatus());
return sdxDrFailed(sdxCluster, stackV4Response.getStatusReason(), pollingMessage);
} else if (isStackOrClusterStatusFailed(stackV4Response.getCluster().getStatus())) {
LOGGER.info("{} failed for Cluster {} status {}", pollingMessage, stackV4Response.getCluster().getName(), stackV4Response.getCluster().getStatus());
return sdxDrFailed(sdxCluster, stackV4Response.getCluster().getStatusReason(), pollingMessage);
} else if (FINISHED.equals(flowState)) {
LOGGER.info("Flow finished, but Backup/Restore is not complete: {}", sdxCluster.getClusterName());
return sdxDrFailed(sdxCluster, "stack is in improper state", pollingMessage);
} else {
LOGGER.info("Flow is unknown state");
return sdxDrFailed(sdxCluster, "Flow is unknown state", pollingMessage);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class StackResponseUtils method getRoleConfigNameForHostGroup.
public String getRoleConfigNameForHostGroup(StackV4Response stackResponse, String hostGroupName, String serviceType, String roleType) throws Exception {
String template = stackResponse.getCluster().getBlueprint().getBlueprint();
ApiClusterTemplate cmTemplate = JsonUtil.readValue(template, ApiClusterTemplate.class);
Set<String> hostGroupRoleConfigNames = cmTemplate.getHostTemplates().stream().filter(clusterTemplate -> clusterTemplate.getRefName().equalsIgnoreCase(hostGroupName)).findFirst().map(ApiClusterTemplateHostTemplate::getRoleConfigGroupsRefNames).orElse(List.of()).stream().collect(Collectors.toSet());
String roleReferenceName = cmTemplate.getServices().stream().filter(s -> s.getServiceType().equalsIgnoreCase(serviceType)).findFirst().map(ApiClusterTemplateService::getRoleConfigGroups).orElse(List.of()).stream().filter(rcg -> rcg.getRoleType().equalsIgnoreCase(roleType)).filter(rcg -> hostGroupRoleConfigNames.contains(rcg.getRefName())).map(ApiClusterTemplateRoleConfigGroup::getRefName).findFirst().orElseThrow(() -> new Exception(String.format("Unable to retrieve RoleConfigGroupRefName for Service '%s', RoleType '%s'," + " HostGroup '%s', Cluster '%s'", serviceType, roleType, hostGroupName, stackResponse.getCrn())));
return roleReferenceName;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class SdxController method getDetailByCrn.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_DETAILED_DATALAKE)
public SdxClusterDetailResponse getDetailByCrn(@TenantAwareParam @ResourceCrn String clusterCrn, Set<String> entries) {
SdxCluster sdxCluster = getSdxClusterByCrn(clusterCrn);
StackV4Response stackV4Response = sdxService.getDetail(sdxCluster.getClusterName(), entries, sdxCluster.getAccountId());
SdxClusterResponse sdxClusterResponse = sdxClusterConverter.sdxClusterToResponse(sdxCluster);
return SdxClusterDetailResponse.create(sdxClusterResponse, stackV4Response);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class SdxController method getDetail.
@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DESCRIBE_DETAILED_DATALAKE)
public SdxClusterDetailResponse getDetail(@ResourceName String name, Set<String> entries) {
SdxCluster sdxCluster = getSdxClusterByName(name);
StackV4Response stackV4Response = sdxService.getDetail(name, entries, sdxCluster.getAccountId());
SdxClusterResponse sdxClusterResponse = sdxClusterConverter.sdxClusterToResponse(sdxCluster);
return SdxClusterDetailResponse.create(sdxClusterResponse, stackV4Response);
}
Aggregations