use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.
the class CloudStorageConfigDetails method queryParameters.
public Set<ConfigQueryEntry> queryParameters(BlueprintTextProcessor blueprintTextProcessor, ConfigQueryEntries configQueryEntries, FileSystemConfigQueryObject request) {
Set<ConfigQueryEntry> filtered = new HashSet<>();
Map<String, Set<String>> componentsByHostGroup = blueprintTextProcessor.getComponentsByHostGroup();
boolean attachedCluster = request.isAttachedCluster();
for (Map.Entry<String, Set<String>> serviceHostgroupEntry : componentsByHostGroup.entrySet()) {
for (String service : serviceHostgroupEntry.getValue()) {
Set<ConfigQueryEntry> collectedEntries = configQueryEntries.getEntries().stream().filter(configQueryEntry -> configQueryEntry.getRelatedServices().stream().anyMatch(relatedService -> relatedService.equalsIgnoreCase(service))).filter(configQueryEntry -> {
if ((configQueryEntry.isRequiredForAttachedCluster() && attachedCluster) || !attachedCluster) {
return true;
}
return false;
}).filter(configQueryEntry -> configQueryEntry.getSupportedStorages().contains(request.getFileSystemType().toUpperCase())).collect(Collectors.toSet());
filtered.addAll(collectedEntries);
}
}
Set<ConfigQueryEntry> collectedEntries = configQueryEntries.getEntries().stream().filter(configQueryEntry -> blueprintDoesNotContainActual(configQueryEntry.getRelatedMissingServices(), componentsByHostGroup)).collect(Collectors.toSet());
filtered.addAll(collectedEntries);
String fileSystemTypeRequest = request.getFileSystemType();
FileSystemType fileSystemType = FileSystemType.valueOf(fileSystemTypeRequest);
String protocol = fileSystemType.getProtocol();
Map<String, Object> templateObject = getTemplateObject(request, protocol);
for (ConfigQueryEntry configQueryEntry : filtered) {
try {
boolean secure = request.isSecure();
configQueryEntry.setProtocol(secure ? protocol + "s" : protocol);
configQueryEntry.setSecure(secure);
configQueryEntry.setDefaultPath(generateConfigWithParameters(configQueryEntry.getDefaultPath(), fileSystemType, templateObject));
} catch (IOException e) {
}
}
filtered = filtered.stream().sorted(Comparator.comparing(ConfigQueryEntry::getPropertyName)).collect(Collectors.toCollection(LinkedHashSet::new));
return filtered;
}
use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.
the class StackScaleV4RequestToUpdateClusterV4RequestConverter method convert.
public UpdateClusterV4Request convert(StackScaleV4Request source) {
try {
return transactionService.required(() -> {
UpdateClusterV4Request updateStackJson = new UpdateClusterV4Request();
Stack stack = stackService.getByIdWithListsInTransaction(source.getStackId());
stack.getInstanceGroups().stream().filter(instanceGroup -> source.getGroup().equals(instanceGroup.getGroupName())).findFirst().ifPresentOrElse(instanceGroup -> {
String blueprintText = stack.getCluster().getBlueprint().getBlueprintText();
BlueprintTextProcessor blueprintTextProcessor = clusterDefinitionTextProcessorFactory.createBlueprintTextProcessor(blueprintText);
boolean dataNodeComponentInHostGroup = blueprintTextProcessor.isComponentExistsInHostGroup("DATANODE", instanceGroup.getGroupName());
HostGroupAdjustmentV4Request hostGroupAdjustmentJson = new HostGroupAdjustmentV4Request();
hostGroupAdjustmentJson.setWithStackUpdate(true);
hostGroupAdjustmentJson.setValidateNodeCount(dataNodeComponentInHostGroup);
hostGroupAdjustmentJson.setHostGroup(source.getGroup());
hostGroupAdjustmentJson.setForced(source.getForced());
int scaleNumber = source.getDesiredCount() - instanceGroup.getNotTerminatedInstanceMetaDataSet().size();
hostGroupAdjustmentJson.setScalingAdjustment(scaleNumber);
updateStackJson.setHostGroupAdjustment(hostGroupAdjustmentJson);
}, () -> {
throw new BadRequestException(String.format("Group '%s' not available on stack", source.getGroup()));
});
return updateStackJson;
});
} catch (TransactionExecutionException e) {
throw e.getCause();
}
}
use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.
the class ComponentLocatorServiceTest method testGetComponentLocation.
@Test
void testGetComponentLocation() {
HostGroup master1 = new HostGroup();
master1.setName(MASTER_1);
InstanceGroup ig1 = new InstanceGroup();
InstanceMetaData imd1 = new InstanceMetaData();
imd1.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
imd1.setDiscoveryFQDN(MASTER1_FQDN);
ig1.setInstanceMetaData(Set.of(imd1));
master1.setInstanceGroup(ig1);
HostGroup master2 = new HostGroup();
master2.setName(MASTER_2);
InstanceGroup ig2 = new InstanceGroup();
InstanceMetaData imd2 = new InstanceMetaData();
imd2.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
imd2.setDiscoveryFQDN(MASTER2_FQDN);
ig2.setInstanceMetaData(Set.of(imd2));
master2.setInstanceGroup(ig2);
HostGroup master3 = new HostGroup();
master3.setName(MASTER_3);
InstanceGroup ig3 = new InstanceGroup();
InstanceMetaData imd3 = new InstanceMetaData();
imd3.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
imd3.setDiscoveryFQDN(MASTER3_FQDN);
ig3.setInstanceMetaData(Set.of(imd3));
master3.setInstanceGroup(ig3);
HostGroup executor = new HostGroup();
executor.setName(EXECUTOR);
InstanceGroup ig4 = new InstanceGroup();
Set<InstanceMetaData> imd4 = EXECUTOR_FQDNS.stream().map(fqdn -> {
InstanceMetaData imd = new InstanceMetaData();
imd.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
imd.setDiscoveryFQDN(fqdn);
return imd;
}).collect(Collectors.toSet());
ig4.setInstanceMetaData(imd4);
executor.setInstanceGroup(ig4);
HostGroup coordinator = new HostGroup();
coordinator.setName(COORDINATOR);
InstanceGroup ig5 = new InstanceGroup();
Set<InstanceMetaData> imd5 = COORDINATOR_FQDNS.stream().map(fqdn -> {
InstanceMetaData imd = new InstanceMetaData();
imd.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
imd.setDiscoveryFQDN(fqdn);
return imd;
}).collect(Collectors.toSet());
ig5.setInstanceMetaData(imd5);
coordinator.setInstanceGroup(ig5);
Set<HostGroup> hostGroups = new LinkedHashSet<>(List.of(master1, master2, master3, executor, coordinator));
when(blueprintTextProcessor.getComponentsInHostGroup(MASTER_1)).thenReturn(MASTER1_COMPONENTS);
when(blueprintTextProcessor.getComponentsInHostGroup(MASTER_2)).thenReturn(MASTER2_COMPONENTS);
when(blueprintTextProcessor.getComponentsInHostGroup(MASTER_3)).thenReturn(MASTER3_COMPONENTS);
when(blueprintTextProcessor.getComponentsInHostGroup(EXECUTOR)).thenReturn(EXECUTOR_COMPONENTS);
when(blueprintTextProcessor.getComponentsInHostGroup(COORDINATOR)).thenReturn(COORDINATOR_COMPONENTS);
when(hostGroupService.getByCluster(CLUSTER_ID)).thenReturn(hostGroups);
Map<String, List<String>> result = underTest.getComponentLocation(CLUSTER_ID, blueprintTextProcessor, COMPONENT_NAMES);
assertEquals(1, result.get(NAMENODE).size());
assertEquals(MASTER1_FQDN, result.get(NAMENODE).get(0));
assertEquals(3, result.get(KUDU_MASTER).size());
assertEquals(1, result.get(SPARK_YARN_HISTORY_SERVER).size());
assertEquals(6, result.size());
}
use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.
the class ServiceEndpointCollector method prepareClusterExposedServices.
public Map<String, Collection<ClusterExposedServiceV4Response>> prepareClusterExposedServices(Cluster cluster, String managerIp) {
String blueprintText = getBlueprintString(cluster);
Map<String, Collection<ClusterExposedServiceV4Response>> clusterExposedServiceMap = new HashMap<>();
if (!Strings.isNullOrEmpty(blueprintText)) {
BlueprintTextProcessor processor = cmTemplateProcessorFactory.get(blueprintText);
Collection<ExposedService> knownExposedServices = getExposedServices(blueprintText, entitlementService.getEntitlements(cluster.getWorkspace().getTenant().getName()));
Gateway gateway = cluster.getGateway();
Optional<String> version = Optional.ofNullable(cluster.getBlueprint()).map(Blueprint::getStackVersion);
Map<String, List<String>> privateIps = componentLocatorService.getComponentLocation(cluster.getId(), processor, knownExposedServices.stream().map(ExposedService::getServiceName).collect(Collectors.toSet()));
LOGGER.debug("The private IPs in the cluster {}", privateIps);
if (privateIps.containsKey(exposedServiceCollector.getImpalaService().getServiceName())) {
setImpalaDebugUIToCoordinator(cluster, privateIps);
}
if (gateway != null) {
for (GatewayTopology gatewayTopology : gateway.getTopologies()) {
generateGatewayTopology(cluster, managerIp, clusterExposedServiceMap, knownExposedServices, gateway, privateIps, gatewayTopology, version);
}
}
}
return clusterExposedServiceMap;
}
use of com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor in project cloudbreak by hortonworks.
the class BlueprintViewProvider method getBlueprintView.
public BlueprintView getBlueprintView(@Nonnull Blueprint blueprint) {
String blueprintText = blueprint.getBlueprintText();
BlueprintStackInfo blueprintStackInfo = stackInfoService.blueprintStackInfo(blueprintText);
BlueprintTextProcessor processor = blueprintTextProcessorFactory.createBlueprintTextProcessor(blueprintText);
return new BlueprintView(blueprintText, blueprintStackInfo.getVersion(), blueprintStackInfo.getType(), processor);
}
Aggregations