use of com.sequenceiq.cloudbreak.template.model.ServiceComponent in project cloudbreak by hortonworks.
the class RangerRazDatahubConfigProvider method getAdditionalServices.
@Override
public Map<String, ApiClusterTemplateService> getAdditionalServices(CmTemplateProcessor cmTemplateProcessor, TemplatePreparationObject source) {
if (isConfigurationNeeded(cmTemplateProcessor, source)) {
ApiClusterTemplateService coreSettings = createTemplate();
Set<HostgroupView> hostgroupViews = source.getHostgroupViews();
Map<String, Set<ServiceComponent>> serviceComponentsByHostGroup = cmTemplateProcessor.getServiceComponentsByHostGroup();
Set<String> zkServerGroups = collectZKServers(serviceComponentsByHostGroup);
boolean weHaveMoreThan2ZKServer = getZKHostNumbers(hostgroupViews, zkServerGroups);
return hostgroupViews.stream().filter(hg -> isProperHostGroupForRaz(hg, zkServerGroups, weHaveMoreThan2ZKServer)).collect(Collectors.toMap(HostgroupView::getName, v -> coreSettings));
}
return Map.of();
}
use of com.sequenceiq.cloudbreak.template.model.ServiceComponent in project cloudbreak by hortonworks.
the class CmTemplateProcessor method collectServiceComponentsByHostGroup.
private Map<String, Set<ServiceComponent>> collectServiceComponentsByHostGroup(Map<String, ServiceComponent> rolesByRoleRef) {
Map<String, Set<ServiceComponent>> result = new HashMap<>();
List<ApiClusterTemplateHostTemplate> hostTemplates = Optional.ofNullable(cmTemplate.getHostTemplates()).orElse(List.of());
for (ApiClusterTemplateHostTemplate apiClusterTemplateHostTemplate : hostTemplates) {
Set<ServiceComponent> components = apiClusterTemplateHostTemplate.getRoleConfigGroupsRefNames().stream().map(rolesByRoleRef::get).filter(Objects::nonNull).collect(toSet());
result.put(apiClusterTemplateHostTemplate.getRefName(), components);
}
return result;
}
use of com.sequenceiq.cloudbreak.template.model.ServiceComponent in project cloudbreak by hortonworks.
the class CmHostGroupRoleConfigProviderProcessor method groupByHostGroupName.
private void groupByHostGroupName(TemplatePreparationObject source, Map<String, Map<String, List<ApiClusterTemplateConfig>>> configsByRoleConfigGroup, Map<String, ServiceComponent> serviceComponents, String hostGroupName, List<String> roleConfigGroups, HostgroupView hostgroupView) {
for (String roleConfigGroup : roleConfigGroups) {
for (CmHostGroupRoleConfigProvider provider : providers) {
ServiceComponent serviceComponent = serviceComponents.get(roleConfigGroup);
if (isServiceComponentEquals(provider, serviceComponent)) {
Map<String, List<ApiClusterTemplateConfig>> configs = configsByRoleConfigGroup.computeIfAbsent(roleConfigGroup, __ -> new HashMap<>());
configs.computeIfAbsent(hostGroupName, __ -> new ArrayList<>()).addAll(provider.getRoleConfigs(serviceComponent.getComponent(), hostgroupView, source));
}
}
}
}
use of com.sequenceiq.cloudbreak.template.model.ServiceComponent in project cloudbreak by hortonworks.
the class CmHostGroupRoleConfigProviderProcessor method generateConfigs.
@VisibleForTesting
Map<String, Map<String, List<ApiClusterTemplateConfig>>> generateConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject source) {
Map<String, Map<String, List<ApiClusterTemplateConfig>>> configsByRoleConfigGroup = new HashMap<>();
Map<String, HostgroupView> hostGroups = source.getHostgroupViews().stream().collect(toMap(HostgroupView::getName, Function.identity()));
List<ApiClusterTemplateHostTemplate> hostTemplates = getHostTemplates(templateProcessor);
Map<String, ServiceComponent> serviceComponents = templateProcessor.mapRoleRefsToServiceComponents();
for (ApiClusterTemplateHostTemplate hostTemplate : hostTemplates) {
String hostGroupName = hostTemplate.getRefName();
List<String> roleConfigGroups = ofNullable(hostTemplate.getRoleConfigGroupsRefNames()).orElseGet(List::of);
HostgroupView hostgroupView = hostGroups.get(hostGroupName);
groupByHostGroupName(source, configsByRoleConfigGroup, serviceComponents, hostGroupName, roleConfigGroups, hostgroupView);
}
return configsByRoleConfigGroup;
}
use of com.sequenceiq.cloudbreak.template.model.ServiceComponent in project cloudbreak by hortonworks.
the class ServiceEndpointCollector method getExposedServices.
/**
* Get all exposed services for blueprint, there are filtered by visibility
*
* @param blueprintText given blueprintText
* @return all visible exposed services for the given blueprint
*/
private Collection<ExposedService> getExposedServices(String blueprintText, List<String> entitlements) {
CmTemplateProcessor processor = cmTemplateProcessorFactory.get(blueprintText);
List<String> components = processor.getAllComponents().stream().map(ServiceComponent::getComponent).collect(Collectors.toList());
return exposedServiceCollector.knoxServicesForComponents(processor.getVersion(), components).stream().filter(ExposedService::isVisible).filter(e -> serviceEndpointCollectorEntitlementComparator.entitlementSupported(entitlements, e.getEntitlement())).collect(Collectors.toList());
}
Aggregations