use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class BindUserCreateServiceTest method testCreateStartedFLowNotified.
@Test
public void testCreateStartedFLowNotified() {
BindUserCreateRequest request = createRequest();
Operation operation = new Operation();
operation.setOperationId("op");
operation.setStatus(OperationState.RUNNING);
when(operationService.startOperation(eq(ACCOUNT), eq(OperationType.BIND_USER_CREATE), anyCollection(), anyCollection())).thenReturn(operation);
OperationStatus operationStatus = new OperationStatus();
when(operationConverter.convert(operation)).thenReturn(operationStatus);
OperationStatus response = underTest.createBindUser(ACCOUNT, request);
assertEquals(operationStatus, response);
ArgumentCaptor<Acceptable> captor = ArgumentCaptor.forClass(Acceptable.class);
verify(flowManager).notify(eq(CREATE_BIND_USER_EVENT.event()), captor.capture());
Acceptable event = captor.getValue();
assertTrue(event instanceof CreateBindUserEvent);
CreateBindUserEvent bindUserEvent = (CreateBindUserEvent) event;
assertEquals(CREATE_BIND_USER_EVENT.event(), bindUserEvent.selector());
assertEquals(STACK_ID, bindUserEvent.getResourceId());
assertEquals(ACCOUNT, bindUserEvent.getAccountId());
assertEquals(operation.getOperationId(), bindUserEvent.getOperationId());
assertEquals(request.getEnvironmentCrn(), bindUserEvent.getEnvironmentCrn());
assertEquals(request.getBindUserNameSuffix(), bindUserEvent.getSuffix());
}
use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class ReactorFlowManager method triggerStopStartStackUpscale.
public FlowIdentifier triggerStopStartStackUpscale(Long stackId, InstanceGroupAdjustmentV4Request instanceGroupAdjustment, boolean withClusterEvent) {
LOGGER.debug("FlowManager trigger for stopstart-upscale");
String selector = FlowChainTriggers.STOPSTART_UPSCALE_CHAIN_TRIGGER_EVENT;
AdjustmentTypeWithThreshold adjustmentTypeWithThreshold = new AdjustmentTypeWithThreshold(instanceGroupAdjustment.getAdjustmentType(), instanceGroupAdjustment.getThreshold());
CloudPlatformVariant cloudPlatformVariant = stackService.getPlatformVariantByStackId(stackId);
Acceptable stackAndClusterUpscaleTriggerEvent = new StackAndClusterUpscaleTriggerEvent(selector, stackId, Collections.singletonMap(instanceGroupAdjustment.getInstanceGroup(), instanceGroupAdjustment.getScalingAdjustment()), withClusterEvent ? ScalingType.UPSCALE_TOGETHER : ScalingType.UPSCALE_ONLY_STACK, getStackNetworkScaleDetails(instanceGroupAdjustment), adjustmentTypeWithThreshold, cloudPlatformVariant.getVariant().value());
return reactorNotifier.notify(stackId, selector, stackAndClusterUpscaleTriggerEvent);
}
use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class ReactorFlowManager method triggerStackStart.
public FlowIdentifier triggerStackStart(Long stackId) {
String selector = FlowChainTriggers.FULL_START_TRIGGER_EVENT;
Acceptable startTriggerEvent = new StackEvent(selector, stackId);
return reactorNotifier.notify(stackId, selector, startTriggerEvent);
}
use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class ReactorFlowManager method triggerStackDownscale.
public FlowIdentifier triggerStackDownscale(Long stackId, InstanceGroupAdjustmentV4Request instanceGroupAdjustment) {
String selector = STACK_DOWNSCALE_EVENT.event();
CloudPlatformVariant cloudPlatformVariant = stackService.getPlatformVariantByStackId(stackId);
Acceptable stackScaleTriggerEvent = new StackDownscaleTriggerEvent(selector, stackId, Collections.singletonMap(instanceGroupAdjustment.getInstanceGroup(), instanceGroupAdjustment.getScalingAdjustment()), cloudPlatformVariant.getVariant().value());
return reactorNotifier.notify(stackId, selector, stackScaleTriggerEvent);
}
use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class ReactorFlowManager method triggerStackUpscale.
public FlowIdentifier triggerStackUpscale(Long stackId, InstanceGroupAdjustmentV4Request instanceGroupAdjustment, boolean withClusterEvent) {
LOGGER.info("FlowManager trigger for upscale");
String selector = FlowChainTriggers.FULL_UPSCALE_TRIGGER_EVENT;
AdjustmentTypeWithThreshold adjustmentTypeWithThreshold = new AdjustmentTypeWithThreshold(instanceGroupAdjustment.getAdjustmentType(), instanceGroupAdjustment.getThreshold());
CloudPlatformVariant cloudPlatformVariant = stackService.getPlatformVariantByStackId(stackId);
Acceptable stackAndClusterUpscaleTriggerEvent = new StackAndClusterUpscaleTriggerEvent(selector, stackId, Collections.singletonMap(instanceGroupAdjustment.getInstanceGroup(), instanceGroupAdjustment.getScalingAdjustment()), withClusterEvent ? ScalingType.UPSCALE_TOGETHER : ScalingType.UPSCALE_ONLY_STACK, getStackNetworkScaleDetails(instanceGroupAdjustment), adjustmentTypeWithThreshold, cloudPlatformVariant.getVariant().value());
LOGGER.info("Triggering stack upscale with {} adjustment, {} adjustment type, {} threshold", instanceGroupAdjustment.getScalingAdjustment(), adjustmentTypeWithThreshold.getAdjustmentType(), adjustmentTypeWithThreshold.getThreshold());
return reactorNotifier.notify(stackId, selector, stackAndClusterUpscaleTriggerEvent);
}
Aggregations