use of com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold 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.common.api.adjustment.AdjustmentTypeWithThreshold 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);
}
use of com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold in project cloudbreak by hortonworks.
the class AbstractStackDownscaleAction method createStackScalingFlowContextFromVariables.
private StackScalingFlowContext createStackScalingFlowContextFromVariables(FlowParameters flowParameters, Map<Object, Object> variables, Stack stack, CloudContext cloudContext, CloudCredential cloudCredential, CloudStack cloudStack) {
Map<String, Integer> hostGroupWithAdjustment = getHostGroupWithAdjustment(variables);
Map<String, Set<Long>> hostGroupWithPrivateIds = getHostGroupWithPrivateIds(stack.getId(), variables);
Map<String, Set<String>> hostgroupWithHostnames = getHostGroupWithHostnames(stack.getId(), variables);
return new StackScalingFlowContext(flowParameters, stack, cloudContext, cloudCredential, cloudStack, hostGroupWithAdjustment, hostGroupWithPrivateIds, hostgroupWithHostnames, isRepair(variables), new AdjustmentTypeWithThreshold(AdjustmentType.BEST_EFFORT, null));
}
use of com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold in project cloudbreak by hortonworks.
the class AbstractStackDownscaleAction method createStackScalingFlowContextFromPayload.
private StackScalingFlowContext createStackScalingFlowContextFromPayload(FlowParameters flowParameters, StackDownscaleTriggerEvent payload, Map<Object, Object> variables, Stack stack, CloudContext cloudContext, CloudCredential cloudCredential, CloudStack cloudStack) {
LOGGER.info("Payload type is StackDownscaleTriggerEvent");
boolean repair = payload.isRepair();
Map<String, Set<String>> hostgroupsWithHostnames = payload.getHostGroupsWithHostNames();
Map<String, Integer> hostGroupsWithAdjustment = payload.getHostGroupsWithAdjustment();
Map<String, Set<Long>> hostGroupsWithPrivateIds = payload.getHostGroupsWithPrivateIds();
variables.put(REPAIR, repair);
variables.put(HOST_GROUP_WITH_ADJUSTMENT, hostGroupsWithAdjustment);
variables.put(HOST_GROUP_WITH_HOSTNAMES, hostgroupsWithHostnames);
if (MapUtils.isEmpty(hostGroupsWithPrivateIds) && variables.get(PRIVATE_IDS) != null) {
hostGroupsWithPrivateIds = getHostGroupsWithPrivateIdsFromVariables(variables, stack);
}
if (hostGroupsWithPrivateIds.values().stream().mapToLong(Collection::size).sum() == 0) {
hostGroupsWithPrivateIds = createHostGroupsWithPrivateIdsFromUnusedPrivateIds(stack, hostGroupsWithAdjustment);
}
variables.put(HOST_GROUP_WITH_PRIVATE_IDS, hostGroupsWithPrivateIds);
LOGGER.info("Variables in AbstractStackDownscaleAction: {}", variables);
return new StackScalingFlowContext(flowParameters, stack, cloudContext, cloudCredential, cloudStack, hostGroupsWithAdjustment, hostGroupsWithPrivateIds, hostgroupsWithHostnames, repair, new AdjustmentTypeWithThreshold(AdjustmentType.BEST_EFFORT, null));
}
use of com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold in project cloudbreak by hortonworks.
the class AbstractStackUpscaleAction method createFlowContext.
@Override
protected StackScalingFlowContext createFlowContext(FlowParameters flowParameters, StateContext<StackUpscaleState, StackUpscaleEvent> stateContext, P payload) {
Map<Object, Object> variables = stateContext.getExtendedState().getVariables();
Stack stack = stackService.getByIdWithListsInTransaction(payload.getResourceId());
stack.setResources(new HashSet<>(resourceService.getAllByStackId(payload.getResourceId())));
MDCBuilder.buildMdcContext(stack);
Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
CloudContext cloudContext = CloudContext.Builder.builder().withId(stack.getId()).withName(stack.getName()).withCrn(stack.getResourceCrn()).withPlatform(stack.getCloudPlatform()).withVariant(getTriggeredVariantOrStackVariant(variables, stack)).withLocation(location).withWorkspaceId(stack.getWorkspace().getId()).withAccountId(Crn.safeFromString(stack.getResourceCrn()).getAccountId()).withTenantId(stack.getTenant().getId()).build();
CloudCredential cloudCredential = stackUtil.getCloudCredential(stack);
CloudStack cloudStack = cloudStackConverter.convert(stack);
if (payload instanceof StackScaleTriggerEvent) {
StackScaleTriggerEvent stackScaleTriggerEvent = (StackScaleTriggerEvent) payload;
boolean repair = stackScaleTriggerEvent.isRepair();
Map<String, Set<String>> hostgroupsWithHostnames = stackScaleTriggerEvent.getHostGroupsWithHostNames();
Map<String, Integer> hostGroupsWithAdjustment = stackScaleTriggerEvent.getHostGroupsWithAdjustment();
Map<String, Set<Long>> hostGroupsWithPrivateIds = stackScaleTriggerEvent.getHostGroupsWithPrivateIds();
NetworkScaleDetails networkScaleDetails = stackScaleTriggerEvent.getNetworkScaleDetails();
AdjustmentTypeWithThreshold adjustmentTypeWithThreshold = stackScaleTriggerEvent.getAdjustmentTypeWithThreshold();
variables.put(REPAIR, repair);
variables.put(HOST_GROUP_WITH_ADJUSTMENT, hostGroupsWithAdjustment);
variables.put(HOST_GROUP_WITH_HOSTNAMES, hostgroupsWithHostnames);
variables.put(NETWORK_SCALE_DETAILS, networkScaleDetails);
variables.put(ADJUSTMENT_WITH_THRESHOLD, adjustmentTypeWithThreshold);
return new StackScalingFlowContext(flowParameters, stack, cloudContext, cloudCredential, cloudStack, hostGroupsWithAdjustment, hostGroupsWithPrivateIds, hostgroupsWithHostnames, repair, networkScaleDetails, adjustmentTypeWithThreshold);
} else {
Map<String, Integer> hostGroupWithAdjustment = getHostGroupWithAdjustment(variables);
Map<String, Set<String>> hostgroupWithHostnames = getHostGroupWithHostnames(variables);
NetworkScaleDetails stackNetworkScaleDetails = getStackNetworkScaleDetails(variables);
AdjustmentTypeWithThreshold adjustmentWithThreshold = getAdjustmentWithThreshold(variables);
return new StackScalingFlowContext(flowParameters, stack, cloudContext, cloudCredential, cloudStack, hostGroupWithAdjustment, null, hostgroupWithHostnames, isRepair(variables), stackNetworkScaleDetails, adjustmentWithThreshold);
}
}
Aggregations