use of com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration in project streamline by hortonworks.
the class ServiceConfigurationCatalogResource method addOrUpdateServiceConfiguration.
@PUT
@Path("/services/{serviceId}/configurations/{id}")
@Timed
public Response addOrUpdateServiceConfiguration(@PathParam("serviceId") Long serviceId, @PathParam("id") Long serviceConfigurationId, ServiceConfiguration serviceConfiguration, @Context SecurityContext securityContext) {
SecurityUtil.checkPermissions(authorizer, securityContext, Cluster.NAMESPACE, getClusterId(serviceId), WRITE);
// overwrite service id to given path param
serviceConfiguration.setServiceId(serviceId);
ServiceConfiguration newConfiguration = environmentService.addOrUpdateServiceConfiguration(serviceId, serviceConfigurationId, serviceConfiguration);
return WSUtils.respondEntity(newConfiguration, CREATED);
}
use of com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration in project streamline by hortonworks.
the class OverrideHadoopConfiguration method override.
public static <T extends Configuration> T override(EnvironmentService environmentService, Long clusterId, ServiceConfigurations service, List<String> configNames, T configuration, Map<String, Function<String, String>> samOverrides) throws IOException, ServiceConfigurationNotFoundException, ServiceNotFoundException {
for (String configName : configNames) {
final ServiceConfiguration serviceConfig = environmentService.getServiceConfigurationByName(getServiceIdByClusterId(environmentService, clusterId, service), configName);
if (serviceConfig != null) {
final Map<String, String> configurationMap = serviceConfig.getConfigurationMap();
if (configurationMap != null) {
for (Map.Entry<String, String> propKeyVal : configurationMap.entrySet()) {
LOG.debug("Overriding property {}", propKeyVal);
final String key = propKeyVal.getKey();
final String val = samOverrides.containsKey(key) ? getSamOverride(samOverrides, propKeyVal) : propKeyVal.getValue();
if (key != null && val != null) {
configuration.set(key, val);
LOG.debug("Set property {}={}", key, val);
} else {
LOG.warn("Skipping null key/val property {}", propKeyVal);
}
}
}
} else {
throw new ServiceConfigurationNotFoundException("Required [" + configName + "] configuration not found for service [" + service.name() + "]");
}
}
return configuration;
}
use of com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration in project streamline by hortonworks.
the class ClusterImporter method removeAllServices.
private void removeAllServices(Cluster cluster) {
Collection<Service> services = environmentService.listServices(cluster.getId());
for (Service service : services) {
Collection<Component> components = environmentService.listComponents(service.getId());
for (Component component : components) {
environmentService.listComponentProcesses(component.getId()).forEach(componentProcess -> environmentService.removeComponentProcess(componentProcess.getId()));
environmentService.removeComponent(component.getId());
}
Collection<ServiceConfiguration> configurations = environmentService.listServiceConfigurations(service.getId());
for (ServiceConfiguration configuration : configurations) {
environmentService.removeServiceConfiguration(configuration.getId());
}
environmentService.removeService(service.getId());
}
}
use of com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration in project streamline by hortonworks.
the class DruidSinkBundleHintProvider method getHintsOnCluster.
@Override
public Map<String, Object> getHintsOnCluster(Cluster cluster, SecurityContext securityContext, Subject subject) {
Map<String, Object> hintMap = new HashMap<>();
try {
Service druid = environmentService.getServiceByName(cluster.getId(), Constants.Druid.SERVICE_NAME);
if (druid == null) {
throw new ServiceNotFoundException(Constants.Druid.SERVICE_NAME);
}
ServiceConfiguration commonRuntime = environmentService.getServiceConfigurationByName(druid.getId(), Constants.Druid.CONF_TYPE_COMMON_RUNTIME);
if (commonRuntime == null) {
throw new ServiceConfigurationNotFoundException(Constants.Druid.CONF_TYPE_COMMON_RUNTIME);
}
Map<String, String> configurationMap = commonRuntime.getConfigurationMap();
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Druid.PROPERTY_KEY_ZK_SERVICE_HOSTS, FIELD_NAME_ZK_CONNECT);
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Druid.PROPERTY_KEY_INDEXING_SERVICE_NAME, FIELD_NAME_INDEX_SERVICE);
putToHintMapIfAvailable(configurationMap, hintMap, Constants.Druid.PROPERTY_KEY_DISCOVERY_CURATOR_PATH, FIELD_NAME_DISCOVERY_PATH);
// exceptional case for Ambari import
if (!hintMap.containsKey(FIELD_NAME_INDEX_SERVICE)) {
ServiceConfiguration druidOverload = environmentService.getServiceConfigurationByName(druid.getId(), Constants.Druid.CONF_TYPE_DRUID_OVERLOAD);
if (druidOverload != null) {
putToHintMapIfAvailable(druidOverload.getConfigurationMap(), hintMap, Constants.Druid.PROPERTY_KEY_SERVICE_NAME, FIELD_NAME_INDEX_SERVICE);
}
}
} catch (ServiceNotFoundException e) {
// we access it from mapping information so shouldn't be here
throw new IllegalStateException("Service " + Constants.Druid.SERVICE_NAME + " in cluster " + cluster.getName() + " not found but mapping information exists.");
} catch (ServiceConfigurationNotFoundException e) {
// there's Druid 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 TopologyActionsService method setUpClusterArtifacts.
public void setUpClusterArtifacts(Topology topology, TopologyActions topologyActions) throws IOException {
Namespace namespace = environmentService.getNamespace(topology.getNamespaceId());
if (namespace == null) {
throw new RuntimeException("Corresponding namespace not found: " + topology.getNamespaceId());
}
ObjectMapper objectMapper = new ObjectMapper();
Path artifactsDir = topologyActions.getArtifactsLocation(CatalogToLayoutConverter.getTopologyLayout(topology));
makeEmptyDir(artifactsDir);
Collection<NamespaceServiceClusterMap> serviceClusterMappings = environmentService.listServiceClusterMapping(namespace.getId());
for (NamespaceServiceClusterMap serviceClusterMapping : serviceClusterMappings) {
Service service = environmentService.getServiceByName(serviceClusterMapping.getClusterId(), serviceClusterMapping.getServiceName());
if (service != null) {
Collection<ServiceConfiguration> serviceConfigurations = environmentService.listServiceConfigurations(service.getId());
if (serviceConfigurations != null) {
for (ServiceConfiguration serviceConfiguration : serviceConfigurations) {
writeConfigurationFile(objectMapper, artifactsDir, serviceConfiguration);
}
}
}
}
}
Aggregations