use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class ClusterMonitoringEngineTest method createInstanceMetadataSet.
private Set<InstanceMetaData> createInstanceMetadataSet() {
Set<InstanceMetaData> instanceMetaDataSet = new HashSet<>();
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setId(1L);
InstanceGroup instanceGroup = new InstanceGroup();
Template template = new Template();
instanceGroup.setTemplate(template);
instanceMetaData.setInstanceGroup(instanceGroup);
instanceMetaDataSet.add(instanceMetaData);
return instanceMetaDataSet;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class ClusterUpscaleServiceTest method testInstallServicesOnNewHostWithRestartButThereIsAnUnhealthyNode.
@Test
public void testInstallServicesOnNewHostWithRestartButThereIsAnUnhealthyNode() throws CloudbreakException {
Stack stack = new Stack();
stack.setId(1L);
Cluster cluster = new Cluster();
cluster.setId(2L);
stack.setCluster(cluster);
when(stackService.getByIdWithClusterInTransaction(eq(1L))).thenReturn(stack);
ClusterApi clusterApi = mock(ClusterApi.class);
when(clusterApiConnectors.getConnector(any(Stack.class))).thenReturn(clusterApi);
HostGroup hostGroup = new HostGroup();
InstanceGroup instanceGroup = new InstanceGroup();
InstanceMetaData im1 = new InstanceMetaData();
im1.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
InstanceMetaData im2 = new InstanceMetaData();
im2.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
InstanceMetaData im3 = new InstanceMetaData();
im3.setInstanceStatus(InstanceStatus.DELETED_BY_PROVIDER);
stack.setInstanceGroups(Set.of(instanceGroup));
instanceGroup.setInstanceMetaData(Set.of(im1, im2, im3));
hostGroup.setInstanceGroup(instanceGroup);
when(hostGroupService.getByClusterWithRecipes(any())).thenReturn(Set.of(hostGroup));
when(parcelService.removeUnusedParcelComponents(stack)).thenReturn(new ParcelOperationStatus(Collections.emptyMap(), Collections.emptyMap()));
underTest.installServicesOnNewHosts(1L, Set.of("master"), true, true);
verify(clusterApi, times(1)).upscaleCluster(any());
verify(clusterApi, times(0)).restartAll(false);
verify(parcelService).removeUnusedParcelComponents(stack);
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class ClusterBootstrapperErrorHandler method terminateFailedNodes.
public void terminateFailedNodes(HostOrchestrator hostOrchestrator, ContainerOrchestrator containerOrchestrator, Stack stack, GatewayConfig gatewayConfig, Set<Node> nodes) throws CloudbreakOrchestratorFailedException {
List<String> allAvailableNode;
allAvailableNode = hostOrchestrator != null ? hostOrchestrator.getAvailableNodes(gatewayConfig, nodes) : containerOrchestrator.getAvailableNodes(gatewayConfig, nodes);
List<Node> missingNodes = selectMissingNodes(nodes, allAvailableNode);
if (!missingNodes.isEmpty()) {
eventService.fireCloudbreakEvent(stack.getId(), Status.UPDATE_IN_PROGRESS.name(), CLUSTER_BOOTSTRAPPER_ERROR_BOOTSTRAP_FAILED_ON_NODES, Arrays.asList(String.valueOf(missingNodes.size())));
for (Node missingNode : missingNodes) {
InstanceMetaData instanceMetaData = instanceMetaDataService.findNotTerminatedByPrivateAddress(stack.getId(), missingNode.getPrivateIp()).orElseThrow(NotFoundException.notFound("instanceMetaData", missingNode.getPrivateIp()));
InstanceGroup ig = instanceGroupService.findOneWithInstanceMetadataByGroupNameInStack(stack.getId(), instanceMetaData.getInstanceGroup().getGroupName()).orElseThrow(NotFoundException.notFound("instanceGroup", instanceMetaData.getInstanceGroup().getGroupName()));
if (ig.getNodeCount() < 1) {
throw new CloudbreakOrchestratorFailedException(cloudbreakMessagesService.getMessage(CLUSTER_BOOTSTRAPPER_ERROR_INVALID_NODECOUNT.getMessage(), Collections.singletonList(ig.getGroupName())));
}
instanceGroupService.save(ig);
eventService.fireCloudbreakEvent(stack.getId(), Status.UPDATE_IN_PROGRESS.name(), CLUSTER_BOOTSTRAPPER_ERROR_DELETING_NODE, Arrays.asList(instanceMetaData.getInstanceId(), ig.getGroupName()));
deleteResourceAndDependencies(stack, instanceMetaData);
deleteInstanceResourceFromDatabase(stack, instanceMetaData);
instanceMetaData.setTerminationDate(clock.getCurrentTimeMillis());
instanceMetaData.setInstanceStatus(InstanceStatus.TERMINATED);
instanceMetaDataService.save(instanceMetaData);
LOGGER.debug("InstanceMetadata [name: {}, id: {}] status set to {}.", instanceMetaData.getId(), instanceMetaData.getInstanceId(), instanceMetaData.getInstanceStatus());
}
}
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverter method convertTargetGroup.
public List<TargetGroupResponse> convertTargetGroup(TargetGroup targetGroup) {
Set<InstanceGroup> instanceGroups = instanceGroupService.findByTargetGroupId(targetGroup.getId());
Set<String> instanceIds = getInstanceMetadataForGroups(instanceGroups).stream().map(InstanceMetaData::getInstanceId).collect(Collectors.toSet());
TargetGroupConfigDbWrapper targetGroupConfig = targetGroup.getProviderConfig();
Set<TargetGroupPortPair> portPairs = loadBalancerConfigService.getTargetGroupPortPairs(targetGroup);
return portPairs.stream().map(portPair -> mapPortPairToTargetGroup(instanceIds, targetGroupConfig, portPair)).collect(Collectors.toList());
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class StackToStackV4RequestConverter method getInstanceGroups.
private List<InstanceGroupV4Request> getInstanceGroups(Stack stack) {
List<InstanceGroupV4Request> ret = new ArrayList<>();
for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
InstanceGroupV4Request instanceGroupV4Request = instanceGroupToInstanceGroupV4RequestConverter.convert(instanceGroup);
collectInformationsFromActualHostgroup(stack.getCluster(), instanceGroup, instanceGroupV4Request);
ret.add(instanceGroupV4Request);
}
return ret;
}
Aggregations