use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class TestUtil method generateGcpInstanceGroupsByNodeCount.
public static Set<InstanceGroup> generateGcpInstanceGroupsByNodeCount(int... count) {
Set<InstanceGroup> instanceGroups = new HashSet<>();
instanceGroups.add(instanceGroup(0L, InstanceGroupType.GATEWAY, gcpTemplate(1L), count[0]));
for (int i = 1; i < count.length; i++) {
instanceGroups.add(instanceGroup((long) i, InstanceGroupType.CORE, gcpTemplate(1L), count[i]));
}
return instanceGroups;
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class TestUtil method instanceGroup.
public static InstanceGroup instanceGroup(Long id, String name, InstanceGroupType instanceGroupType, Template template, int nodeCount) {
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setId(id);
instanceGroup.setNodeCount(nodeCount);
instanceGroup.setGroupName(name);
instanceGroup.setInstanceGroupType(instanceGroupType);
instanceGroup.setTemplate(template);
instanceGroup.setSecurityGroup(securityGroup(1L));
instanceGroup.setInstanceMetaData(generateInstanceMetaDatas(nodeCount, id, instanceGroup));
return instanceGroup;
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class StackSyncService method updateMetaDataToRunning.
private void updateMetaDataToRunning(Long stackId, Cluster cluster, InstanceMetaData instanceMetaData) {
InstanceGroup instanceGroup = instanceMetaData.getInstanceGroup();
if (InstanceStatus.TERMINATED.equals(instanceMetaData.getInstanceStatus())) {
instanceGroup.setNodeCount(instanceGroup.getNodeCount() + 1);
}
HostMetadata hostMetadata = hostMetadataRepository.findHostInClusterByName(cluster.getId(), instanceMetaData.getDiscoveryFQDN());
if (hostMetadata != null) {
LOGGER.info("Instance '{}' was found in the cluster metadata, setting it's state to REGISTERED.", instanceMetaData.getInstanceId());
instanceMetaData.setInstanceStatus(InstanceStatus.REGISTERED);
} else {
LOGGER.info("Instance '{}' was not found in the cluster metadata, setting it's state to UNREGISTERED.", instanceMetaData.getInstanceId());
instanceMetaData.setInstanceStatus(InstanceStatus.UNREGISTERED);
}
instanceMetaDataRepository.save(instanceMetaData);
instanceGroupRepository.save(instanceGroup);
eventService.fireCloudbreakEvent(stackId, AVAILABLE.name(), cloudbreakMessagesService.getMessage(Msg.STACK_SYNC_INSTANCE_UPDATED.code(), Arrays.asList(instanceMetaData.getDiscoveryFQDN(), "running")));
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class StackCreationService method updateNodeCount.
private void updateNodeCount(Long stackId, Iterable<Group> originalGroups, Iterable<CloudResourceStatus> statuses) {
for (Group group : originalGroups) {
int nodeCount = group.getInstancesSize();
List<CloudResourceStatus> failedResources = removeFailedMetadata(stackId, statuses, group);
if (!failedResources.isEmpty()) {
int failedCount = failedResources.size();
InstanceGroup instanceGroup = instanceGroupRepository.findOneByGroupNameInStack(stackId, group.getName());
instanceGroup.setNodeCount(nodeCount - failedCount);
instanceGroupRepository.save(instanceGroup);
flowMessageService.fireEventAndLog(stackId, Msg.STACK_INFRASTRUCTURE_ROLLBACK_MESSAGE, UPDATE_IN_PROGRESS.name(), failedCount, group.getName(), failedResources.get(0).getStatusReason());
}
}
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class StackDownscaleService method finishStackDownscale.
public void finishStackDownscale(StackScalingFlowContext context, String instanceGroupName, Collection<String> instanceIds) {
Stack stack = context.getStack();
InstanceGroup g = stack.getInstanceGroupByInstanceGroupName(instanceGroupName);
int nodeCount = stackScalingService.updateRemovedResourcesState(stack, instanceIds, g);
List<String> fqdns = instanceMetaDataRepository.findAllByInstanceIdIn(instanceIds).stream().map(InstanceMetaData::getDiscoveryFQDN).collect(toList());
stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.DOWNSCALE_COMPLETED, String.format("Downscale of the cluster infrastructure finished successfully. Terminated node(s): %s", fqdns));
flowMessageService.fireEventAndLog(stack.getId(), Msg.STACK_DOWNSCALE_SUCCESS, AVAILABLE.name(), fqdns);
if (stack.getCluster() != null && stack.getCluster().getEmailNeeded()) {
emailSenderService.sendDownScaleSuccessEmail(stack.getCluster().getOwner(), stack.getCluster().getEmailTo(), stackUtil.extractAmbariIp(stack), stack.getCluster().getName());
flowMessageService.fireEventAndLog(context.getStack().getId(), Msg.STACK_NOTIFICATION_EMAIL, AVAILABLE.name());
}
usageService.scaleUsagesForStack(stack.getId(), instanceGroupName, nodeCount);
}
Aggregations