use of com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration in project streamline by hortonworks.
the class TopologyActionsContainer method putStormConfigurations.
private void putStormConfigurations(Service streamingEngineService, Map<String, Object> conf) {
ServiceConfiguration storm = getServiceConfiguration(streamingEngineService, SERVICE_CONFIGURATION_STORM).orElse(new ServiceConfiguration());
ServiceConfiguration stormEnv = getServiceConfiguration(streamingEngineService, SERVICE_CONFIGURATION_STORM_ENV).orElse(new ServiceConfiguration());
try {
Map<String, String> stormConfMap = storm.getConfigurationMap();
if (stormConfMap != null) {
if (stormConfMap.containsKey(TopologyLayoutConstants.NIMBUS_THRIFT_MAX_BUFFER_SIZE)) {
conf.put(TopologyLayoutConstants.NIMBUS_THRIFT_MAX_BUFFER_SIZE, Long.parseLong(stormConfMap.get(TopologyLayoutConstants.NIMBUS_THRIFT_MAX_BUFFER_SIZE)));
}
if (stormConfMap.containsKey(TopologyLayoutConstants.STORM_THRIFT_TRANSPORT)) {
String thriftTransport = stormConfMap.get(TopologyLayoutConstants.STORM_THRIFT_TRANSPORT);
if (!thriftTransport.startsWith("{{") && !thriftTransport.endsWith("}}")) {
conf.put(TopologyLayoutConstants.STORM_THRIFT_TRANSPORT, stormConfMap.get(TopologyLayoutConstants.STORM_THRIFT_TRANSPORT));
}
}
if (stormConfMap.containsKey(TopologyLayoutConstants.STORM_NONSECURED_THRIFT_TRANSPORT)) {
conf.put(TopologyLayoutConstants.STORM_NONSECURED_THRIFT_TRANSPORT, stormConfMap.get(TopologyLayoutConstants.STORM_NONSECURED_THRIFT_TRANSPORT));
}
if (stormConfMap.containsKey(TopologyLayoutConstants.STORM_SECURED_THRIFT_TRANSPORT)) {
conf.put(TopologyLayoutConstants.STORM_SECURED_THRIFT_TRANSPORT, stormConfMap.get(TopologyLayoutConstants.STORM_SECURED_THRIFT_TRANSPORT));
}
if (stormConfMap.containsKey(TopologyLayoutConstants.STORM_PRINCIPAL_TO_LOCAL)) {
conf.put(TopologyLayoutConstants.STORM_PRINCIPAL_TO_LOCAL, stormConfMap.get(TopologyLayoutConstants.STORM_PRINCIPAL_TO_LOCAL));
}
}
Map<String, String> stormEnvConfMap = stormEnv.getConfigurationMap();
if (stormEnvConfMap != null) {
if (stormEnvConfMap.containsKey(TopologyLayoutConstants.STORM_NIMBUS_PRINCIPAL_NAME)) {
conf.put(TopologyLayoutConstants.STORM_NIMBUS_PRINCIPAL_NAME, stormEnvConfMap.get(TopologyLayoutConstants.STORM_NIMBUS_PRINCIPAL_NAME));
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration in project streamline by hortonworks.
the class AbstractServiceRegistrar method register.
@Override
public Service register(Cluster cluster, Config config, List<ConfigFileInfo> configFileInfos) throws IOException {
Service service = environmentService.createService(cluster, getServiceName());
List<ServiceConfiguration> configurations = new ArrayList<>();
Map<String, String> flattenConfigMap = new HashMap<>();
List<ServiceConfiguration> serviceConfigurations = createServiceConfigurations(config);
if (serviceConfigurations != null && !serviceConfigurations.isEmpty()) {
serviceConfigurations.forEach(sc -> {
configurations.add(sc);
try {
flattenConfigMap.putAll(sc.getConfigurationMap());
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
for (ConfigFileInfo configFileInfo : configFileInfos) {
Map<String, String> configMap = readConfigFile(configFileInfo);
String fileName = FilenameUtils.getName(configFileInfo.getName());
String confType = getConfType(fileName);
String actualFileName = ConfigFilePattern.getOriginFileName(confType);
ServiceConfiguration configuration = environmentService.createServiceConfiguration(service.getId(), confType, actualFileName, new HashMap<>(configMap));
configurations.add(configuration);
flattenConfigMap.putAll(configMap);
}
Map<Component, List<ComponentProcess>> components = createComponents(config, flattenConfigMap);
if (!validateComponents(components)) {
throw new IllegalArgumentException("Validation failed for components.");
}
if (!validateServiceConfigurations(configurations)) {
throw new IllegalArgumentException("Validation failed for service configurations.");
}
if (!validateServiceConfiguationsAsFlattenedMap(flattenConfigMap)) {
throw new IllegalArgumentException("Validation failed for service configurations.");
}
// here we are storing actual catalogs
// before that we need to replace dummy service id to the actual one
service = environmentService.addService(service);
for (Map.Entry<Component, List<ComponentProcess>> entry : components.entrySet()) {
Component component = entry.getKey();
List<ComponentProcess> componentProcesses = entry.getValue();
component.setServiceId(service.getId());
component = environmentService.addComponent(component);
for (ComponentProcess componentProcess : componentProcesses) {
componentProcess.setComponentId(component.getId());
environmentService.addComponentProcess(componentProcess);
}
}
for (ServiceConfiguration configuration : configurations) {
configuration.setServiceId(service.getId());
environmentService.addServiceConfiguration(configuration);
}
return service;
}
use of com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration in project streamline by hortonworks.
the class NotificationSinkBundleHintProvider method getHintsOnCluster.
@Override
public Map<String, Object> getHintsOnCluster(Cluster cluster, SecurityContext securityContext, Subject subject) {
Map<String, Object> hintMap = new HashMap<>();
try {
Service email = environmentService.getServiceByName(cluster.getId(), Constants.Email.SERVICE_NAME);
if (email == null) {
throw new ServiceNotFoundException(Constants.Email.SERVICE_NAME);
}
ServiceConfiguration properties = environmentService.getServiceConfigurationByName(email.getId(), Constants.Email.CONF_TYPE_PROPERTIES);
if (properties == null) {
throw new ServiceConfigurationNotFoundException(Constants.Email.CONF_TYPE_PROPERTIES);
}
Map<String, String> configurationMap = properties.getConfigurationMap();
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_HOST, FIELD_NAME_HOST);
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_PORT, FIELD_NAME_PORT);
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_SSL, FIELD_NAME_SSL);
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_STARTTLS, FIELD_NAME_STARTTLS);
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_PROTOCOL, FIELD_NAME_PROTOCOL);
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Email.PROPERTY_KEY_AUTH, FIELD_NAME_AUTH);
} catch (ServiceNotFoundException e) {
// we access it from mapping information so shouldn't be here
throw new IllegalStateException("Service " + Constants.Email.SERVICE_NAME + " in cluster " + cluster.getName() + " not found but mapping information exists.");
} catch (ServiceConfigurationNotFoundException e) {
// there's Email service configuration but not having enough information
} catch (Exception e) {
throw new RuntimeException(e);
}
return hintMap;
}
use of com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration in project streamline by hortonworks.
the class ServiceCatalogResource method buildManualServiceRegisterResult.
private ServiceWithComponents buildManualServiceRegisterResult(Service service) {
Collection<ServiceConfiguration> configurations = environmentService.listServiceConfigurations(service.getId());
Collection<Component> components = environmentService.listComponents(service.getId());
ServiceWithComponents s = new ServiceWithComponents(service);
s.setComponents(components);
s.setConfigurations(configurations);
return s;
}
use of com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration in project streamline by hortonworks.
the class EnvironmentService method getServiceConfiguration.
public ServiceConfiguration getServiceConfiguration(Long configurationId) {
ServiceConfiguration serviceConfiguration = new ServiceConfiguration();
serviceConfiguration.setId(configurationId);
return this.dao.get(new StorableKey(SERVICE_CONFIGURATION_NAMESPACE, serviceConfiguration.getPrimaryKey()));
}
Aggregations