use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.
the class UpscaleFlowEventChainFactory method createFlowTriggerEventQueue.
@Override
public Queue<Selectable> createFlowTriggerEventQueue(StackAndClusterUpscaleTriggerEvent event) {
StackView stackView = stackService.getByIdView(event.getStackId());
ClusterView clusterView = stackView.getClusterView();
Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
flowEventChain.add(new StackSyncTriggerEvent(STACK_SYNC_EVENT.event(), event.getStackId(), false, event.accepted()));
flowEventChain.add(new StackScaleTriggerEvent(ADD_INSTANCES_EVENT.event(), event.getStackId(), event.getInstanceGroup(), event.getAdjustment(), event.getHostNames()));
if (ScalingType.isClusterUpScale(event.getScalingType()) && clusterView != null) {
HostGroup hostGroup = hostGroupService.getByClusterIdAndInstanceGroupName(clusterView.getId(), event.getInstanceGroup());
flowEventChain.add(new ClusterScaleTriggerEvent(CLUSTER_UPSCALE_TRIGGER_EVENT.event(), stackView.getId(), hostGroup.getName(), event.getAdjustment()));
}
return flowEventChain;
}
use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.
the class StackUpscaleActions method bootstrapNewNodes.
@Bean(name = "BOOTSTRAP_NEW_NODES_STATE")
public Action<?, ?> bootstrapNewNodes() {
return new AbstractStackUpscaleAction<BootstrapNewNodesEvent>(BootstrapNewNodesEvent.class) {
@Override
protected void doExecute(StackScalingFlowContext context, BootstrapNewNodesEvent payload, Map<Object, Object> variables) {
stackUpscaleService.bootstrappingNewNodes(context.getStack());
Selectable request = new BootstrapNewNodesRequest(context.getStack().getId(), payload.getUpscaleCandidateAddresses(), context.getHostNames());
sendEvent(context.getFlowId(), request);
}
};
}
use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.
the class StackDownscaleActions method stackDownscaleCollectResourcesAction.
@Bean(name = "DOWNSCALE_COLLECT_RESOURCES_STATE")
public Action<?, ?> stackDownscaleCollectResourcesAction() {
return new AbstractStackDownscaleAction<StackDownscaleTriggerEvent>(StackDownscaleTriggerEvent.class) {
@Override
protected void doExecute(StackScalingFlowContext context, StackDownscaleTriggerEvent payload, Map<Object, Object> variables) {
stackDownscaleService.startStackDownscale(context, payload);
Stack stack = context.getStack();
LOGGER.debug("Assembling downscale stack event for stack: {}", stack);
List<CloudResource> resources = cloudResourceConverter.convert(stack.getResources());
variables.put(RESOURCES, resources);
List<CloudInstance> instances = new ArrayList<>();
InstanceGroup group = stack.getInstanceGroupByInstanceGroupName(context.getInstanceGroupName());
for (InstanceMetaData metaData : group.getAllInstanceMetaData()) {
if (context.getInstanceIds().contains(metaData.getInstanceId())) {
CloudInstance cloudInstance = metadataConverter.convert(metaData);
instances.add(cloudInstance);
}
}
variables.put(INSTANCES, instances);
Selectable request = new DownscaleStackCollectResourcesRequest(context.getCloudContext(), context.getCloudCredential(), context.getCloudStack(), resources, instances);
sendEvent(context.getFlowId(), request);
}
};
}
use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.
the class AbstractAction method sendEvent.
protected void sendEvent(C context) {
Selectable payload = createRequest(context);
sendEvent(context.getFlowId(), payload.selector(), payload);
}
use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.
the class StackRepairFlowEventChainFactory method createFlowTriggerEventQueue.
@Override
public Queue<Selectable> createFlowTriggerEventQueue(StackRepairTriggerEvent event) {
Queue<Selectable> flowChainTriggers = new ConcurrentLinkedDeque<>();
flowChainTriggers.add(new StackEvent(FlowChainTriggers.FULL_SYNC_TRIGGER_EVENT, event.getStackId(), event.accepted()));
UnhealthyInstances unhealthyInstances = event.getUnhealthyInstances();
String fullUpscaleTriggerEvent = FlowChainTriggers.FULL_UPSCALE_TRIGGER_EVENT;
for (String hostGroupName : unhealthyInstances.getHostGroups()) {
List<String> instances = unhealthyInstances.getInstancesForGroup(hostGroupName);
flowChainTriggers.add(new StackAndClusterUpscaleTriggerEvent(fullUpscaleTriggerEvent, event.getStackId(), hostGroupName, instances.size(), ScalingType.UPSCALE_TOGETHER));
}
return flowChainTriggers;
}
Aggregations