use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class FlowProgressResponseConverter method createFlowStateTransitions.
private List<FlowStateTransitionResponse> createFlowStateTransitions(List<FlowLog> reversedFlowLogs, Long currentCreatedTime) {
List<FlowStateTransitionResponse> transitions = new ArrayList<>();
for (int flowLogIndex = 0; flowLogIndex < reversedFlowLogs.size(); flowLogIndex++) {
FlowLog fl = reversedFlowLogs.get(flowLogIndex);
Double elapsedTime = null;
if (!fl.getFinalized() && flowLogIndex == reversedFlowLogs.size() - 1) {
elapsedTime = getRoundedTimeInSeconds(currentCreatedTime, new Date().getTime());
} else {
elapsedTime = getRoundedTimeInSeconds(currentCreatedTime, fl.getCreated());
}
currentCreatedTime = fl.getCreated();
transitions.add(convertToFlowTransitionResponse(fl, elapsedTime));
}
return transitions;
}
use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class FlowLogsToListDiagnosticsCollectionResponseConverter method convert.
public ListDiagnosticsCollectionResponse convert(List<FlowLog> flowLogs) {
ListDiagnosticsCollectionResponse response = new ListDiagnosticsCollectionResponse();
if (!flowLogs.isEmpty()) {
List<DiagnosticsCollection> collections = flowLogs.stream().map(flowLog -> {
DiagnosticsCollection collection = new DiagnosticsCollection();
collection.setFlowId(flowLog.getFlowId());
collection.setCreated(flowLog.getCreated());
collection.setProperties(flowPayloadToDiagnosticDetailsConverter.convert(flowLog.getPayload()));
collection.setStatus(calculateStatus(flowLog));
collection.setCurrentFlowStatus(flowLog.getCurrentState());
collection.setProgressPercentage(calculateProgressPercentage(flowLog));
return collection;
}).collect(Collectors.toList());
response.setCollections(collections);
}
return response;
}
use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class ClusterRepairServiceTest method testRepairByNodeIds.
@Test
public void testRepairByNodeIds() {
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setInstanceGroupType(InstanceGroupType.CORE);
HostGroup hostGroup1 = new HostGroup();
hostGroup1.setName("hostGroup1");
hostGroup1.setRecoveryMode(RecoveryMode.MANUAL);
hostGroup1.setInstanceGroup(instanceGroup);
when(hostGroupService.getByCluster(eq(1L))).thenReturn(Set.of(hostGroup1));
when(freeipaService.checkFreeipaRunning(stack.getEnvironmentCrn())).thenReturn(true);
when(environmentService.environmentStatusInDesiredState(stack, Set.of(EnvironmentStatus.AVAILABLE))).thenReturn(true);
InstanceMetaData instance1md = new InstanceMetaData();
instance1md.setInstanceId("instanceId1");
instance1md.setDiscoveryFQDN("host1Name.healthy");
instance1md.setInstanceGroup(instanceGroup);
instanceGroup.setInstanceMetaData(Collections.singleton(instance1md));
Resource volumeSet = new Resource();
VolumeSetAttributes attributes = new VolumeSetAttributes("eu-west-1", Boolean.TRUE, "", List.of(), 100, "standard");
attributes.setDeleteOnTermination(null);
volumeSet.setAttributes(new Json(attributes));
volumeSet.setInstanceId("instanceId1");
volumeSet.setResourceType(ResourceType.AWS_VOLUMESET);
FlowLog flowLog = new FlowLog();
flowLog.setStateStatus(StateStatus.SUCCESSFUL);
when(stackUpdater.updateStackStatus(1L, DetailedStackStatus.REPAIR_IN_PROGRESS)).thenReturn(stack);
when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack);
when(stack.getInstanceMetaDataAsList()).thenReturn(List.of(instance1md));
when(resourceService.findByStackIdAndType(stack.getId(), volumeSet.getResourceType())).thenReturn(List.of(volumeSet));
when(stackStopRestrictionService.isInfrastructureStoppable(stack)).thenReturn(StopRestrictionReason.NONE);
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.repairNodes(1L, Set.of("instanceId1"), false, false));
verify(resourceService).findByStackIdAndType(stack.getId(), volumeSet.getResourceType());
@SuppressWarnings("unchecked") ArgumentCaptor<List<Resource>> saveCaptor = ArgumentCaptor.forClass(List.class);
verify(resourceService).saveAll(saveCaptor.capture());
assertFalse(resourceAttributeUtil.getTypedAttributes(saveCaptor.getValue().get(0), VolumeSetAttributes.class).get().getDeleteOnTermination());
verify(flowManager).triggerClusterRepairFlow(eq(1L), eq(Map.of("hostGroup1", List.of("host1Name.healthy"))), eq(false), eq(false));
}
use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class SdxRetryServiceTest method noRetryAndNoRestartFlowIfStateSuccessful.
@Test
public void noRetryAndNoRestartFlowIfStateSuccessful() {
SdxCluster sdxCluster = new SdxCluster();
sdxCluster.setId(1L);
sdxCluster.setClusterName("sdxclustername");
FlowLog successfulFlowLog = new FlowLog();
successfulFlowLog.setFlowId("FLOW_ID_1");
successfulFlowLog.setStateStatus(StateStatus.SUCCESSFUL);
successfulFlowLog.setNextEvent(SDX_VALIDATION_EVENT.name());
successfulFlowLog.setCreated(1L);
successfulFlowLog.setCurrentState(SDX_CREATION_WAIT_RDS_STATE.name());
successfulFlowLog.setFlowType(ClassValue.of(SdxCreateFlowConfig.class));
doAnswer(invocation -> {
((Consumer<FlowLog>) invocation.getArgument(1)).accept(successfulFlowLog);
return null;
}).when(flow2Handler).retryLastFailedFlow(anyLong(), any());
when(flow2Handler.getFirstRetryableStateLogfromLatestFlow(anyLong())).thenReturn(successfulFlowLog);
sdxRetryService.retrySdx(sdxCluster);
verify(stackV4Endpoint, times(0)).retry(any(), any(), anyString());
}
use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.
the class TerminationTriggerServiceTest method whenStackNotDeletedAndNotTerminationFlowLogAndKerbAndNotForcedShouldTerminate.
@Test
public void whenStackNotDeletedAndNotTerminationFlowLogAndKerbAndNotForcedShouldTerminate() {
FlowLog flowLog = new FlowLog();
flowLog.setFlowType(ClassValue.of(StackCreationFlowConfig.class));
when(flowLogService.findAllByResourceIdAndFinalizedIsFalseOrderByCreatedDesc(anyLong())).thenReturn(List.of(flowLog));
setupKerberized();
underTest.triggerTermination(getAvailableStack(), false);
verifyTerminationEventFired(true, false, false);
}
Aggregations