private static Collection<ComponentProcess> getHbaseMasterComponentProcesses(EnvironmentService environmentService, Long clusterId) throws ServiceNotFoundException, ServiceComponentNotFoundException { return EnvironmentServiceUtil.getComponentProcesses( environmentService, clusterId, AMBARI_JSON_SERVICE_HBASE, AMBARI_JSON_COMPONENT_HBASE_MASTER); }
private static Component getHiveMetastoreComponent(EnvironmentService environmentService, Long clusterId) throws ServiceNotFoundException, ServiceComponentNotFoundException { return EnvironmentServiceUtil.getComponent( environmentService, clusterId, AMBARI_JSON_SERVICE_HIVE, AMBARI_JSON_COMPONENT_HIVE_METASTORE); }
private HostPort getHostPort() throws ServiceNotFoundException, ServiceComponentNotFoundException { final Collection<ComponentProcess> stormUiComp = EnvironmentServiceUtil.getComponentProcesses( environmentService, clusterId, AMBARI_JSON_SERVICE_STORM, AMBARI_JSON_COMPONENT_STORM_UI_SERVER); ComponentProcess ui = stormUiComp.iterator().next(); return new HostPort(ui.getHost(), ui.getPort()); } }
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; }
private static Configuration overrideConfig(Configuration hbaseConfig, EnvironmentService environmentService, Long clusterId) throws IOException, ServiceConfigurationNotFoundException, ServiceNotFoundException { return OverrideHadoopConfiguration.override(environmentService, clusterId, ServiceConfigurations.HBASE, AMBARI_JSON_CONFIG_HBASE_SITE, hbaseConfig, getMaxHBaseClientRetries()); }
public List<HostPort> getZkHosts() { if (StringUtils.isEmpty(zkString)) { return Collections.emptyList(); } return Arrays.stream(zkString.split(",")) .map(zkConn -> { String[] splitted = zkConn.split(":"); if (splitted.length > 1) { return new HostPort(splitted[0], Integer.valueOf(splitted[1])); } else { return new HostPort(splitted[0], DEFAULT_ZOOKEEPER_PORT); } }) .collect(toList()); }
public static Component getComponent(EnvironmentService es, Long clusterId, String serviceName, String componentName) throws ServiceNotFoundException, ServiceComponentNotFoundException { final Component component = es.getComponentByName(getServiceIdByName(es, clusterId, serviceName), componentName); if (component == null) { throw new ServiceComponentNotFoundException(clusterId, serviceName, componentName); } return component; }
private String getTopologySummaryRestUrl() throws ServiceNotFoundException, ServiceComponentNotFoundException { final HostPort hostPort = getHostPort(); String url = "http://" + hostPort.toString() + (urlRelativePath.startsWith("/") ? urlRelativePath : "/" + urlRelativePath); if (SecurityUtil.isKerberosAuthenticated(securityContext)) { url += "?" + STORM_REST_API_DO_AS_USER_QUERY_PARAM + "=" + securityContext.getUserPrincipal().getName(); } return url; }
private static Collection<ComponentProcess> getHiveMetastores(EnvironmentService environmentService, Long clusterId) throws ServiceNotFoundException, ServiceComponentNotFoundException { return EnvironmentServiceUtil.getComponentProcesses( environmentService, clusterId, AMBARI_JSON_SERVICE_HIVE, AMBARI_JSON_COMPONENT_HIVE_METASTORE); }
private Component getComponent(String componentName) throws ServiceNotFoundException, ServiceComponentNotFoundException { return EnvironmentServiceUtil.getComponent( environmentService, clusterId, AMBARI_JSON_SERVICE_STORM, componentName); }
public static HDFSMetadataService newInstance(EnvironmentService environmentService, Long clusterId) throws ServiceConfigurationNotFoundException, IOException, ServiceNotFoundException { Configuration hdfsConfiguration = OverrideHadoopConfiguration.override(environmentService, clusterId, ServiceConfigurations.HDFS, STREAMS_JSON_SCHEMA_CONFIG_HDFS, new Configuration()); return new HDFSMetadataService(hdfsConfiguration); }
public static KafkaBrokersInfo<HostPort> hostPort(Collection<ComponentProcess> componentProcesses, Security security, KafkaBrokerListeners kafkaBrokerListeners) throws IOException { List<HostPort> hostsPorts = componentProcesses.stream() .map(cp -> new HostPort(cp.getHost(), cp.getPort())) .collect(toList()); return new KafkaBrokersInfo<>(hostsPorts, security, kafkaBrokerListeners.getProtocolToHostsWithPort()); }
public static Collection<ComponentProcess> getComponentProcesses(EnvironmentService es, Long clusterId, String serviceName, String componentName) throws ServiceNotFoundException, ServiceComponentNotFoundException { final Component component = es.getComponentByName(getServiceIdByName(es, clusterId, serviceName), componentName); if (component == null) { throw new ServiceComponentNotFoundException(clusterId, serviceName, componentName); } return es.listComponentProcesses(component.getId()); }
/** * @return If storm view is configured it returns its URL, otherwise it returns the URL of the Storm UI */ private String getMainPageUrl() throws ServiceNotFoundException, ServiceComponentNotFoundException { final ServiceConfiguration stormViewConfiguration = getServiceConfig(SERVICE_STORM_VIEW); String url = null; if (stormViewConfiguration != null) { try { Map<String, String> confMap = stormViewConfiguration.getConfigurationMap(); url = confMap.get(STORM_VIEW_CONFIGURATION_KEY_STORM_VIEW_URL); } catch (IOException e) { // fail back } } if (url != null) { return url; } else { // just use Storm UI HostPort hostPort = getHostPort(); return "http://" + hostPort.toString(); } }
private Collection<ComponentProcess> getComponentProcesses(String componentName) throws ServiceNotFoundException, ServiceComponentNotFoundException { return EnvironmentServiceUtil.getComponentProcesses( environmentService, clusterId, AMBARI_JSON_SERVICE_STORM, componentName); }
private static Component getKafkaBrokerComponent(EnvironmentService environmentService, Long clusterId) throws ServiceNotFoundException, ServiceComponentNotFoundException { return EnvironmentServiceUtil.getComponent( environmentService, clusterId, AMBARI_JSON_SERVICE_KAFKA, AMBARI_JSON_COMPONENT_KAFKA_BROKER); }
private static HiveConf overrideConfig(EnvironmentService environmentService, Long clusterId) throws IOException, EntityNotFoundException { return OverrideHadoopConfiguration.override(environmentService, clusterId, ServiceConfigurations.HIVE, getConfigNames(), new HiveConf()); }
public List<HostPort> getZookeeperServers() throws ServiceNotFoundException, ServiceComponentNotFoundException { final Long serviceId = environmentService.getServiceIdByName(clusterId, STREAMS_JSON_SCHEMA_SERVICE_ZOOKEEPER); if (serviceId == null) { throw new ServiceNotFoundException(clusterId, ServiceConfigurations.ZOOKEEPER.name()); } final Component zookeeperServer = environmentService.getComponentByName(serviceId, STREAMS_JSON_SCHEMA_COMPONENT_ZOOKEEPER_SERVER); if (zookeeperServer == null) { throw new ServiceComponentNotFoundException(clusterId, ServiceConfigurations.STORM.name(), ComponentPropertyPattern.ZOOKEEPER_SERVER.name()); } final Collection<ComponentProcess> zookeeperServers = environmentService.listComponentProcesses(zookeeperServer.getId()); return zookeeperServers.stream() .map(cp -> new HostPort(cp.getHost(), cp.getPort())) .collect(Collectors.toList()); } }
private static Collection<ComponentProcess> getKafkaBrokers(EnvironmentService environmentService, Long clusterId) throws ServiceNotFoundException, ServiceComponentNotFoundException { return EnvironmentServiceUtil.getComponentProcesses( environmentService, clusterId, AMBARI_JSON_SERVICE_KAFKA, AMBARI_JSON_COMPONENT_KAFKA_BROKER); }
private static Component getHbaseMasterComponent(EnvironmentService environmentService, Long clusterId) throws ServiceNotFoundException, ServiceComponentNotFoundException { return EnvironmentServiceUtil.getComponent( environmentService, clusterId, AMBARI_JSON_SERVICE_HBASE, AMBARI_JSON_COMPONENT_HBASE_MASTER); }