use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class DistroXUpgradeService method initUpgrade.
private UpgradeV4Response initUpgrade(UpgradeV4Request request, UpgradeV4Response upgradeV4Response, NameOrCrn cluster, Long workspaceId, String userCrn) {
ImageInfoV4Response image = imageSelector.determineImageId(request, upgradeV4Response.getUpgradeCandidates());
ImageChangeDto imageChangeDto = createImageChangeDto(cluster, workspaceId, image);
Stack stack = stackService.getByNameOrCrnInWorkspace(cluster, workspaceId);
boolean lockComponents = request.getLockComponents() != null ? request.getLockComponents() : isComponentsLocked(stack, image);
validateOsUpgradeEntitled(lockComponents, request);
boolean replaceVms = determineReplaceVmsParam(upgradeV4Response, lockComponents, stack);
String upgradeVariant = calculateUpgradeVariant(stack, userCrn);
FlowIdentifier flowIdentifier = reactorFlowManager.triggerDistroXUpgrade(stack.getId(), imageChangeDto, replaceVms, lockComponents, upgradeVariant);
UpgradeV4Response response = new UpgradeV4Response("Upgrade started with Image: " + image.getImageId(), flowIdentifier);
response.setReplaceVms(replaceVms);
return response;
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxCcmUpgradeServiceTest method testInitAndWaitForStackUpgrade.
@Test
void testInitAndWaitForStackUpgrade() {
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:altus:iam:us-west-1:altus:user:__internal__actor__");
FlowIdentifier flowId = new FlowIdentifier(FlowType.FLOW, "pollableId");
StackCcmUpgradeV4Response upgradeResponse = new StackCcmUpgradeV4Response(flowId);
when(stackV4Endpoint.upgradeCcmByCrnInternal(eq(0L), eq(STACK_CRN), any())).thenReturn(upgradeResponse);
PollingConfig pc = new PollingConfig(1L, TimeUnit.HOURS, 1L, TimeUnit.HOURS);
SdxCluster sdx = getSdxCluster();
underTest.initAndWaitForStackUpgrade(sdx, pc);
verify(stackV4Endpoint).upgradeCcmByCrnInternal(any(), eq(STACK_CRN), any());
verify(cloudbreakPoller).pollCcmUpgradeUntilAvailable(sdx, pc);
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class Flow2Handler method retryLastFailedFlowFromStart.
/**
* Retry the failed flow completely
*
* @param resourceId Datalake ID
* @return Identifier of flow or a flow chain
*/
public FlowIdentifier retryLastFailedFlowFromStart(Long resourceId) {
FlowLog firstSuccessfulStateLog = getFirstRetryableStateLogfromLatestFlow(resourceId);
LOGGER.info("Trying to restart flow {}", firstSuccessfulStateLog.getFlowType().getName());
restartFlow(firstSuccessfulStateLog);
LOGGER.info("Restarted flow : {}", firstSuccessfulStateLog.getFlowType().getName());
if (firstSuccessfulStateLog.getFlowChainId() != null) {
return new FlowIdentifier(FlowType.FLOW_CHAIN, firstSuccessfulStateLog.getFlowChainId());
} else {
return new FlowIdentifier(FlowType.FLOW, firstSuccessfulStateLog.getFlowId());
}
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class EventSender method doSend.
private FlowIdentifier doSend(BaseFlowEvent event, Event.Headers headers, String resourceName) {
Event<BaseFlowEvent> eventWithErrHandler = eventFactory.createEventWithErrHandler(new HashMap<>(headers.asMap()), event);
reactor.notify(event.selector(), eventWithErrHandler);
Promise<AcceptResult> accepted = eventWithErrHandler.getData().accepted();
String resourceCrn = event.getResourceCrn();
if (accepted != null) {
try {
FlowAcceptResult acceptResult = (FlowAcceptResult) accepted.await(TIMEOUT, TimeUnit.SECONDS);
return createFlowIdentifier(acceptResult, resourceCrn);
} catch (InterruptedException e) {
throw new IllegalStateException(e.getMessage());
}
}
if (headers.contains(FLOW_ID)) {
return new FlowIdentifier(FlowType.FLOW, headers.get(FLOW_ID));
} else if (headers.contains(FLOW_CHAIN_ID)) {
return new FlowIdentifier(FlowType.FLOW_CHAIN, headers.get(FLOW_CHAIN_ID));
}
LOGGER.error("Accepted is null, header does not contains flow or flow chain id, event: {}, header: {}", event, headers);
reactorReporter.logErrorReport();
throw new FlowNotAcceptedException(String.format("Timeout happened when trying to start the flow for stack %s.", resourceCrn));
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class DistroXRemoveInstancesAction method action.
@Override
public DistroXTestDto action(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
List<String> removableInstanceIds = testDto.getInstanceIdsForAction();
if (!removableInstanceIds.isEmpty()) {
MultipleInstanceDeleteRequest instanceDeleteRequest = new MultipleInstanceDeleteRequest();
instanceDeleteRequest.setInstances(removableInstanceIds);
Log.when(LOGGER, String.format(" Removing instances [%s] from distrox '%s'... ", instanceDeleteRequest.getInstances(), testDto.getName()));
FlowIdentifier flowIdentifier = client.getDefaultClient().distroXV1Endpoint().deleteInstancesByCrn(testDto.getCrn(), removableInstanceIds, instanceDeleteRequest, false);
testDto.setFlow("Instance deletion", flowIdentifier);
StackV4Response stackV4Response = client.getDefaultClient().distroXV1Endpoint().getByName(testDto.getName(), new HashSet<>(Arrays.asList("hardware_info", "events")));
testDto.setResponse(stackV4Response);
Log.whenJson(LOGGER, " Distrox remove instances response: ", stackV4Response);
LOGGER.info(String.format("Hardware info for distrox '%s' after remove instances [%s].", testDto.getName(), stackV4Response.getHardwareInfoGroups()));
return testDto;
} else {
throw new TestFailException(String.format("Cannot find any instance to remove from distrox '%s'!", testDto.getName()));
}
}
Aggregations