use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class StackCommonServiceTest method testChangeImageInWorkspace.
@Test
public void testChangeImageInWorkspace() {
StackImageChangeV4Request stackImageChangeRequest = new StackImageChangeV4Request();
when(stackService.getIdByNameOrCrnInWorkspace(STACK_NAME, WORKSPACE_ID)).thenReturn(STACK_ID);
when(stackOperationService.updateImage(any(ImageChangeDto.class))).thenReturn(new FlowIdentifier(FlowType.FLOW, "id"));
FlowIdentifier result = underTest.changeImageInWorkspace(STACK_NAME, WORKSPACE_ID, stackImageChangeRequest);
assertEquals(FlowType.FLOW, result.getType());
assertEquals("id", result.getPollableId());
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class ClusterCommonServiceTest method testRotateAutoTls.
@Test
public void testRotateAutoTls() {
NameOrCrn cluster = NameOrCrn.ofName("cluster");
Stack stack = new Stack();
stack.setName("cluster");
stack.setStackStatus(new StackStatus(stack, AVAILABLE));
CertificatesRotationV4Request certificatesRotationV4Request = new CertificatesRotationV4Request();
when(clusterOperationService.rotateAutoTlsCertificates(stack, certificatesRotationV4Request)).thenReturn(new FlowIdentifier(FlowType.FLOW, "1"));
when(stackService.getByNameOrCrnInWorkspace(cluster, 1L)).thenReturn(stack);
underTest.rotateAutoTlsCertificates(cluster, 1L, certificatesRotationV4Request);
verify(clusterOperationService, times(1)).rotateAutoTlsCertificates(stack, certificatesRotationV4Request);
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxController method create.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_DATALAKE)
public SdxClusterResponse create(String name, @Valid SdxCustomClusterRequest createSdxClusterRequest) {
String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
Pair<SdxCluster, FlowIdentifier> result = sdxService.createSdx(userCrn, name, createSdxClusterRequest);
SdxCluster sdxCluster = result.getLeft();
metricService.incrementMetricCounter(MetricType.CUSTOM_SDX_REQUESTED, sdxCluster);
SdxClusterResponse sdxClusterResponse = sdxClusterConverter.sdxClusterToResponse(sdxCluster);
sdxClusterResponse.setName(sdxCluster.getClusterName());
sdxClusterResponse.setFlowIdentifier(result.getRight());
return sdxClusterResponse;
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxReactorFlowManager method notify.
private FlowIdentifier notify(String selector, SdxEvent acceptable, String identifier) {
Map<String, Object> flowTriggerUserCrnHeader = Map.of(FlowConstants.FLOW_TRIGGER_USERCRN, acceptable.getUserId());
Event<Acceptable> event = eventFactory.createEventWithErrHandler(flowTriggerUserCrnHeader, acceptable);
reactor.notify(selector, event);
try {
FlowAcceptResult accepted = (FlowAcceptResult) event.getData().accepted().await(WAIT_FOR_ACCEPT, TimeUnit.SECONDS);
if (accepted == null) {
throw new FlowNotAcceptedException(String.format("Timeout happened when trying to start the flow for sdx cluster %s.", event.getData().getResourceId()));
} else {
switch(accepted.getResultType()) {
case ALREADY_EXISTING_FLOW:
throw new FlowsAlreadyRunningException(String.format("Request not allowed, datalake cluster '%s' already has a running operation. " + "Running operation(s): [%s]", identifier, flowNameFormatService.formatFlows(accepted.getAlreadyRunningFlows())));
case RUNNING_IN_FLOW:
return new FlowIdentifier(FlowType.FLOW, accepted.getAsFlowId());
case RUNNING_IN_FLOW_CHAIN:
return new FlowIdentifier(FlowType.FLOW_CHAIN, accepted.getAsFlowChainId());
default:
throw new IllegalStateException("Unsupported accept result type: " + accepted.getClass());
}
}
} catch (InterruptedException e) {
throw new CloudbreakApiException(e.getMessage());
}
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxRecoveryServiceTest method triggerCloudbreakRecovery.
@Test
public void triggerCloudbreakRecovery() {
Long clusterId = cluster.getId();
doNothing().when(cloudbreakFlowService).saveLastCloudbreakFlowChainId(any(), any());
FlowIdentifier flowId = new FlowIdentifier(FlowType.FLOW, "FLOW_ID_1");
RecoveryV4Response recoveryV4Response = new RecoveryV4Response(flowId);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
when(sdxService.getById(clusterId)).thenReturn(cluster);
when(ThreadBasedUserCrnProvider.doAsInternalActor("crn:cdp:iam:us-west-1:cloudera:user:__internal__actor__", () -> stackV4Endpoint.recoverClusterByNameInternal(0L, cluster.getClusterName(), ThreadBasedUserCrnProvider.getUserCrn()))).thenReturn(recoveryV4Response);
ThreadBasedUserCrnProvider.doAsInternalActor("crn:cdp:iam:us-west-1:cloudera:user:__internal__actor__", () -> underTest.recoverCluster(clusterId));
verify(stackV4Endpoint).recoverClusterByNameInternal(eq(0L), eq(CLUSTER_NAME), nullable(String.class));
verify(sdxStatusService, times(1)).setStatusForDatalakeAndNotify(DatalakeStatusEnum.RECOVERY_IN_PROGRESS, DATALAKE_RECOVERY_REQUESTED, "Recovering datalake stack", cluster);
}
Aggregations