Search in sources :

Example 1 with InstanceGroupService

use of com.sequenceiq.freeipa.service.stack.instance.InstanceGroupService in project cloudbreak by hortonworks.

the class FreeIpaDownscaleActions method updateMetadataAction.

@Bean(name = "DOWNSCALE_UPDATE_METADATA_STATE")
public Action<?, ?> updateMetadataAction() {
    return new AbstractDownscaleAction<>(RemoveHostsFromOrchestrationSuccess.class) {

        @Inject
        private InstanceGroupService instanceGroupService;

        @Override
        protected void doExecute(StackContext context, RemoveHostsFromOrchestrationSuccess payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Updating metadata");
            List<String> repairInstanceIds = getInstanceIds(variables);
            terminationService.finalizeTermination(stack.getId(), repairInstanceIds);
            terminationService.finalizeTerminationForInstancesWithoutInstanceIds(stack.getId());
            if (!isRepair(variables)) {
                int nodeCount = getInstanceCountByGroup(variables);
                instanceGroupService.findByStackId(stack.getId()).forEach(instanceGroup -> {
                    instanceGroup.setNodeCount(nodeCount);
                    instanceGroupService.save(instanceGroup);
                });
            }
            sendEvent(context, UPDATE_METADATA_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
        }
    };
}
Also used : InstanceGroupService(com.sequenceiq.freeipa.service.stack.instance.InstanceGroupService) RemoveHostsFromOrchestrationSuccess(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removehosts.RemoveHostsFromOrchestrationSuccess) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) Map(java.util.Map) EnvironmentEndpoint(com.sequenceiq.environment.api.v1.environment.endpoint.EnvironmentEndpoint) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Aggregations

EnvironmentEndpoint (com.sequenceiq.environment.api.v1.environment.endpoint.EnvironmentEndpoint)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 RemoveHostsFromOrchestrationSuccess (com.sequenceiq.freeipa.flow.freeipa.downscale.event.removehosts.RemoveHostsFromOrchestrationSuccess)1 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)1 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)1 InstanceGroupService (com.sequenceiq.freeipa.service.stack.instance.InstanceGroupService)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1