Search in sources :

Example 21 with ComponentProcess

use of com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess in project streamline by hortonworks.

the class TopologyActionsContainer method buildStormTopologyActionsConfigMap.

private Map<String, Object> buildStormTopologyActionsConfigMap(Namespace namespace, String streamingEngine, Subject subject) {
    // Assuming that a namespace has one mapping of streaming engine except test environment
    Service streamingEngineService = getFirstOccurenceServiceForNamespace(namespace, streamingEngine);
    if (streamingEngineService == null) {
        if (!namespace.getInternal()) {
            throw new RuntimeException("Streaming Engine " + streamingEngine + " is not associated to the namespace " + namespace.getName() + "(" + namespace.getId() + ")");
        } else {
            // the namespace is purposed for test run
            return buildStormTopologyActionsConfigMapForTestRun(namespace, subject);
        }
    }
    Component uiServer = getComponent(streamingEngineService, COMPONENT_NAME_STORM_UI_SERVER).orElseThrow(() -> new RuntimeException(streamingEngine + " doesn't have " + COMPONENT_NAME_STORM_UI_SERVER + " as component"));
    Collection<ComponentProcess> uiServerProcesses = environmentService.listComponentProcesses(uiServer.getId());
    if (uiServerProcesses.isEmpty()) {
        throw new RuntimeException(streamingEngine + " doesn't have component process " + COMPONENT_NAME_STORM_UI_SERVER);
    }
    ComponentProcess uiServerProcess = uiServerProcesses.iterator().next();
    final String uiHost = uiServerProcess.getHost();
    Integer uiPort = uiServerProcess.getPort();
    assertHostAndPort(uiServer.getName(), uiHost, uiPort);
    Component nimbus = getComponent(streamingEngineService, COMPONENT_NAME_NIMBUS).orElseThrow(() -> new RuntimeException(streamingEngine + " doesn't have " + COMPONENT_NAME_NIMBUS + " as component"));
    Collection<ComponentProcess> nimbusProcesses = environmentService.listComponentProcesses(nimbus.getId());
    if (nimbusProcesses.isEmpty()) {
        throw new RuntimeException(streamingEngine + " doesn't have component process " + COMPONENT_NAME_NIMBUS);
    }
    List<String> nimbusHosts = nimbusProcesses.stream().map(ComponentProcess::getHost).collect(Collectors.toList());
    Integer nimbusPort = nimbusProcesses.stream().map(ComponentProcess::getPort).findAny().get();
    assertHostsAndPort(nimbus.getName(), nimbusHosts, nimbusPort);
    Map<String, Object> conf = new HashMap<>();
    // We need to have some local configurations anyway because topology submission can't be done with REST API.
    String stormJarLocation = streamlineConf.get(STREAMLINE_STORM_JAR);
    if (stormJarLocation == null) {
        String jarFindDir = applyReservedPaths(DEFAULT_STORM_JAR_LOCATION_DIR);
        stormJarLocation = findFirstMatchingJarLocation(jarFindDir);
    } else {
        stormJarLocation = applyReservedPaths(stormJarLocation);
    }
    conf.put(STREAMLINE_STORM_JAR, stormJarLocation);
    conf.put(STORM_HOME_DIR, streamlineConf.get(STORM_HOME_DIR));
    // Since we're loading the class dynamically so we can't rely on any enums or constants from there
    conf.put(NIMBUS_SEEDS, String.join(",", nimbusHosts));
    conf.put(NIMBUS_PORT, String.valueOf(nimbusPort));
    conf.put(TopologyLayoutConstants.STORM_API_ROOT_URL_KEY, buildStormRestApiRootUrl(uiHost, uiPort));
    conf.put(TopologyLayoutConstants.SUBJECT_OBJECT, subject);
    putStormConfigurations(streamingEngineService, conf);
    // Topology during run-time will require few critical configs such as schemaRegistryUrl and catalogRootUrl
    // Hence its important to pass StreamlineConfig to TopologyConfig
    conf.putAll(streamlineConf);
    // TopologyActionImpl needs 'EnvironmentService' and namespace ID to load service configurations
    // for specific cluster associated to the namespace
    conf.put(TopologyLayoutConstants.ENVIRONMENT_SERVICE_OBJECT, environmentService);
    conf.put(TopologyLayoutConstants.NAMESPACE_ID, namespace.getId());
    return conf;
}
Also used : HashMap(java.util.HashMap) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Example 22 with ComponentProcess

use of com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess in project streamline by hortonworks.

the class TopologyMetricsContainer method buildAMSTimeSeriesQuerierConfigMap.

private Map<String, String> buildAMSTimeSeriesQuerierConfigMap(Namespace namespace, String timeSeriesDB) {
    // Assuming that a namespace has one mapping of time-series DB service
    Service timeSeriesDBService = getFirstOccurenceServiceForNamespace(namespace, timeSeriesDB);
    if (timeSeriesDBService == null) {
        throw new RuntimeException("Time-series DB " + timeSeriesDB + " is not associated to the namespace " + namespace.getName() + "(" + namespace.getId() + ")");
    }
    Component metricsCollector = getComponent(timeSeriesDBService, COMPONENT_NAME_METRICS_COLLECTOR).orElseThrow(() -> new RuntimeException(timeSeriesDB + " doesn't have " + COMPONENT_NAME_METRICS_COLLECTOR + " as component"));
    Collection<ComponentProcess> metricsCollectorProcesses = environmentService.listComponentProcesses(metricsCollector.getId());
    if (metricsCollectorProcesses.isEmpty()) {
        throw new RuntimeException(timeSeriesDB + " doesn't have any process for " + COMPONENT_NAME_METRICS_COLLECTOR + " as component");
    }
    ComponentProcess metricsCollectorProcess = metricsCollectorProcesses.iterator().next();
    String metricsCollectorHost = metricsCollectorProcess.getHost();
    Integer metricsCollectorPort = metricsCollectorProcess.getPort();
    assertHostAndPort(COMPONENT_NAME_METRICS_COLLECTOR, metricsCollectorHost, metricsCollectorPort);
    Map<String, String> confForTimeSeriesQuerier = new HashMap<>();
    confForTimeSeriesQuerier.put(COLLECTOR_API_URL_KEY, buildAMSCollectorRestApiRootUrl(metricsCollectorHost, metricsCollectorPort));
    return confForTimeSeriesQuerier;
}
Also used : HashMap(java.util.HashMap) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) Service(com.hortonworks.streamline.streams.cluster.catalog.Service) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) ComponentProcess(com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)

Aggregations

ComponentProcess (com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess)22 Component (com.hortonworks.streamline.streams.cluster.catalog.Component)15 Service (com.hortonworks.streamline.streams.cluster.catalog.Service)8 ServiceConfiguration (com.hortonworks.streamline.streams.cluster.catalog.ServiceConfiguration)8 Config (com.hortonworks.streamline.common.Config)7 ComponentPropertyPattern (com.hortonworks.streamline.streams.cluster.discovery.ambari.ComponentPropertyPattern)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Constants (com.hortonworks.streamline.streams.cluster.Constants)5 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)5 List (java.util.List)5 Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)4 ServiceConfigurations (com.hortonworks.streamline.streams.cluster.discovery.ambari.ServiceConfigurations)4 Collections (java.util.Collections)4 Pair (org.apache.commons.math3.util.Pair)4 Test (org.junit.Test)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Collection (java.util.Collection)3 Collectors.toList (java.util.stream.Collectors.toList)3