use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class StackResponseHardwareInfoProvider method providerEntriesToStackResponse.
@Override
public StackResponse providerEntriesToStackResponse(Stack stack, StackResponse stackResponse) {
Set<HardwareInfoResponse> hardwareInfoResponses = new HashSet<>();
for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
for (InstanceMetaData instanceMetaData : instanceGroup.getAllInstanceMetaData()) {
HostMetadata hostMetadata = null;
if (stack.getCluster() != null && instanceMetaData.getDiscoveryFQDN() != null) {
hostMetadata = hostMetadataRepository.findHostInClusterByName(stack.getCluster().getId(), instanceMetaData.getDiscoveryFQDN());
}
HardwareInfoResponse hardwareInfoResponse = new HardwareInfoResponse();
hardwareInfoResponse.setInstanceMetaData(conversionService.convert(instanceMetaData, InstanceMetaDataJson.class));
hardwareInfoResponse.setHostMetadata(conversionService.convert(hostMetadata, HostMetadataResponse.class));
hardwareInfoResponses.add(hardwareInfoResponse);
}
}
stackResponse.setHardwareInfos(hardwareInfoResponses);
return stackResponse;
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class NetworkUtils method createACLRules.
private static List<EndpointRule> createACLRules(Stack stack) {
List<EndpointRule> rules = new LinkedList<>();
for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
for (SecurityRule rule : instanceGroup.getSecurityGroup().getSecurityRules()) {
rules.add(new EndpointRule(Action.PERMIT.getText(), rule.getCidr()));
}
}
EndpointRule internalRule = new EndpointRule(Action.PERMIT.toString(), stack.getNetwork().getSubnetCIDR());
rules.add(internalRule);
rules.add(EndpointRule.DENY_RULE);
return rules;
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class HdfConfigProvider method createHdfConfig.
public HdfConfigs createHdfConfig(Set<HostGroup> hostgroups, Map<String, List<InstanceMetaData>> groupInstances, String blueprintText) {
BlueprintTextProcessor blueprintTextProcessor = createTextProcessor(blueprintText);
Set<String> nifiMasters = collectNifiMasters(blueprintText);
Set<InstanceGroup> nifiIgs = collectInstanceGroupsWhichContainsNifiMasters(hostgroups, nifiMasters);
List<String> nifiFqdns = collectFqdnsByInstanceGroupName(groupInstances, nifiIgs);
AtomicInteger index = new AtomicInteger(0);
String nodeIdentities = nifiFqdns.stream().map(fqdn -> String.format("<property name=\"Node Identity %s\">CN=%s, OU=NIFI</property>", index.addAndGet(1), fqdn)).collect(Collectors.joining());
return new HdfConfigs(nodeIdentities, getProxyHostsParameter(nifiIgs, blueprintTextProcessor, groupInstances));
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class StackRequestToStackConverter method convertInstanceGroups.
private Set<InstanceGroup> convertInstanceGroups(StackRequest source, Stack stack) {
List<InstanceGroupRequest> instanceGroupRequests = source.getInstanceGroups();
Set<InstanceGroup> convertedSet = new HashSet<>();
for (InstanceGroupRequest instanceGroupRequest : instanceGroupRequests) {
InstanceGroup instanceGroup = getConversionService().convert(instanceGroupRequest, InstanceGroup.class);
if (instanceGroup != null) {
convertedSet.add(getConversionService().convert(instanceGroupRequest, InstanceGroup.class));
}
}
boolean gatewaySpecified = false;
for (InstanceGroup instanceGroup : convertedSet) {
instanceGroup.setStack(stack);
if (!gatewaySpecified) {
if (InstanceGroupType.GATEWAY.equals(instanceGroup.getInstanceGroupType())) {
gatewaySpecified = true;
}
}
}
boolean containerOrchestrator;
try {
containerOrchestrator = orchestratorTypeResolver.resolveType(source.getOrchestrator().getType()).containerOrchestrator();
} catch (CloudbreakException ignored) {
throw new BadRequestException("Orchestrator not supported.");
}
if (!gatewaySpecified && !containerOrchestrator) {
throw new BadRequestException("Ambari server must be specified");
}
return convertedSet;
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class StackToStackResponseConverter method addNodeCount.
private void addNodeCount(Stack source, StackResponse stackJson) {
int nodeCount = 0;
for (InstanceGroup instanceGroup : source.getInstanceGroups()) {
nodeCount += instanceGroup.getNodeCount();
}
stackJson.setNodeCount(nodeCount);
}
Aggregations