Search in sources :

Example 1 with TopologyMetrics

use of com.hortonworks.streamline.streams.metrics.topology.TopologyMetrics in project streamline by hortonworks.

the class TopologyMetricsContainer method initTopologyMetrics.

private TopologyMetrics initTopologyMetrics(Map<String, Object> conf, String className) {
    try {
        TopologyMetrics topologyMetrics = instantiate(className);
        topologyMetrics.init(conf);
        return topologyMetrics;
    } catch (IllegalAccessException | InstantiationException | ClassNotFoundException | ConfigException e) {
        throw new RuntimeException("Can't initialize Topology metrics instance - Class Name: " + className, e);
    }
}
Also used : TopologyMetrics(com.hortonworks.streamline.streams.metrics.topology.TopologyMetrics) ConfigException(com.hortonworks.streamline.common.exception.ConfigException)

Example 2 with TopologyMetrics

use of com.hortonworks.streamline.streams.metrics.topology.TopologyMetrics in project streamline by hortonworks.

the class TopologyMetricsService method getTopologyMetricsInstance.

private TopologyMetrics getTopologyMetricsInstance(Topology topology) {
    Namespace namespace = environmentService.getNamespace(topology.getNamespaceId());
    if (namespace == null) {
        throw new RuntimeException("Corresponding namespace not found: " + topology.getNamespaceId());
    }
    TopologyMetrics topologyMetrics = topologyMetricsContainer.findInstance(namespace);
    if (topologyMetrics == null) {
        throw new RuntimeException("Can't find Topology Metrics for such namespace " + topology.getNamespaceId());
    }
    return topologyMetrics;
}
Also used : TopologyMetrics(com.hortonworks.streamline.streams.metrics.topology.TopologyMetrics) Namespace(com.hortonworks.streamline.streams.cluster.catalog.Namespace)

Example 3 with TopologyMetrics

use of com.hortonworks.streamline.streams.metrics.topology.TopologyMetrics in project streamline by hortonworks.

the class TopologyMetricsContainer method initializeInstance.

@Override
protected TopologyMetrics initializeInstance(Namespace namespace) {
    String streamingEngine = namespace.getStreamingEngine();
    MappedTopologyMetricsImpl metricsImpl;
    // Only Storm is supported as streaming engine
    try {
        metricsImpl = MappedTopologyMetricsImpl.valueOf(streamingEngine);
    } catch (IllegalArgumentException e) {
        throw new RuntimeException("Unsupported streaming engine: " + streamingEngine, e);
    }
    // FIXME: "how to initialize" is up to implementation detail - now we just only consider about Storm implementation
    Map<String, Object> conf = buildStormTopologyMetricsConfigMap(namespace, streamingEngine, subject);
    String className = metricsImpl.getClassName();
    TopologyMetrics topologyMetrics = initTopologyMetrics(conf, className);
    String timeSeriesDB = namespace.getTimeSeriesDB();
    if (timeSeriesDB != null && !timeSeriesDB.isEmpty()) {
        String querierKey = MappedTimeSeriesQuerierImpl.getName(streamingEngine, timeSeriesDB);
        MappedTimeSeriesQuerierImpl timeSeriesQuerierImpl;
        try {
            timeSeriesQuerierImpl = MappedTimeSeriesQuerierImpl.valueOf(querierKey);
        } catch (IllegalArgumentException e) {
            throw new RuntimeException("Unsupported streaming engine and time-series DB combination: " + streamingEngine + " & " + timeSeriesDB, e);
        }
        // FIXME: "how to initialize" is up to implementation detail - now we just only consider about Storm & AMS implementation
        Map<String, String> confTimeSeriesQuerier = buildAMSTimeSeriesQuerierConfigMap(namespace, timeSeriesDB);
        className = timeSeriesQuerierImpl.getClassName();
        TimeSeriesQuerier timeSeriesQuerier = initTimeSeriesQuerier(confTimeSeriesQuerier, className);
        topologyMetrics.setTimeSeriesQuerier(timeSeriesQuerier);
    }
    return topologyMetrics;
}
Also used : TimeSeriesQuerier(com.hortonworks.streamline.streams.metrics.TimeSeriesQuerier) MappedTopologyMetricsImpl(com.hortonworks.streamline.streams.metrics.container.mapping.MappedTopologyMetricsImpl) TopologyMetrics(com.hortonworks.streamline.streams.metrics.topology.TopologyMetrics) MappedTimeSeriesQuerierImpl(com.hortonworks.streamline.streams.metrics.container.mapping.MappedTimeSeriesQuerierImpl)

Example 4 with TopologyMetrics

use of com.hortonworks.streamline.streams.metrics.topology.TopologyMetrics in project streamline by hortonworks.

the class TopologyMetricsService method getTopNAndOtherComponentsLatency.

public List<Pair<String, Double>> getTopNAndOtherComponentsLatency(Topology topology, String asUser, int nOfTopN) throws IOException {
    TopologyMetrics topologyMetrics = getTopologyMetricsInstance(topology);
    Map<String, TopologyMetrics.ComponentMetric> metricsForTopology = topologyMetrics.getMetricsForTopology(CatalogToLayoutConverter.getTopologyLayout(topology), asUser);
    List<Pair<String, Double>> topNAndOther = new ArrayList<>();
    List<ImmutablePair<String, Double>> latencyOrderedComponents = metricsForTopology.entrySet().stream().map((x) -> new ImmutablePair<>(x.getValue().getComponentName(), x.getValue().getProcessedTime())).sorted((c1, c2) -> {
        if (c2.getValue() == null) {
            // assuming c1 is bigger
            return -1;
        } else {
            return c2.getValue().compareTo(c1.getValue());
        }
    }).collect(toList());
    latencyOrderedComponents.stream().limit(nOfTopN).forEachOrdered(topNAndOther::add);
    double sumLatencyOthers = latencyOrderedComponents.stream().skip(nOfTopN).filter((x) -> x.getValue() != null).mapToDouble(Pair::getValue).sum();
    topNAndOther.add(new ImmutablePair<>("Others", sumLatencyOthers));
    return topNAndOther;
}
Also used : Topology(com.hortonworks.streamline.streams.catalog.Topology) Namespace(com.hortonworks.streamline.streams.cluster.catalog.Namespace) CatalogToLayoutConverter(com.hortonworks.streamline.streams.catalog.CatalogToLayoutConverter) ContainingNamespaceAwareContainer(com.hortonworks.streamline.streams.cluster.container.ContainingNamespaceAwareContainer) IOException(java.io.IOException) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Subject(javax.security.auth.Subject) ArrayList(java.util.ArrayList) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) TopologyComponent(com.hortonworks.streamline.streams.catalog.TopologyComponent) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Pair(org.apache.commons.lang3.tuple.Pair) TopologyTimeSeriesMetrics(com.hortonworks.streamline.streams.metrics.topology.TopologyTimeSeriesMetrics) TopologyMetricsContainer(com.hortonworks.streamline.streams.metrics.container.TopologyMetricsContainer) Map(java.util.Map) TopologyMetrics(com.hortonworks.streamline.streams.metrics.topology.TopologyMetrics) ArrayList(java.util.ArrayList) TopologyMetrics(com.hortonworks.streamline.streams.metrics.topology.TopologyMetrics) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Pair(org.apache.commons.lang3.tuple.Pair)

Aggregations

TopologyMetrics (com.hortonworks.streamline.streams.metrics.topology.TopologyMetrics)4 Namespace (com.hortonworks.streamline.streams.cluster.catalog.Namespace)2 ConfigException (com.hortonworks.streamline.common.exception.ConfigException)1 CatalogToLayoutConverter (com.hortonworks.streamline.streams.catalog.CatalogToLayoutConverter)1 Topology (com.hortonworks.streamline.streams.catalog.Topology)1 TopologyComponent (com.hortonworks.streamline.streams.catalog.TopologyComponent)1 ContainingNamespaceAwareContainer (com.hortonworks.streamline.streams.cluster.container.ContainingNamespaceAwareContainer)1 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)1 TimeSeriesQuerier (com.hortonworks.streamline.streams.metrics.TimeSeriesQuerier)1 TopologyMetricsContainer (com.hortonworks.streamline.streams.metrics.container.TopologyMetricsContainer)1 MappedTimeSeriesQuerierImpl (com.hortonworks.streamline.streams.metrics.container.mapping.MappedTimeSeriesQuerierImpl)1 MappedTopologyMetricsImpl (com.hortonworks.streamline.streams.metrics.container.mapping.MappedTopologyMetricsImpl)1 TopologyTimeSeriesMetrics (com.hortonworks.streamline.streams.metrics.topology.TopologyTimeSeriesMetrics)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Collectors.toList (java.util.stream.Collectors.toList)1 Subject (javax.security.auth.Subject)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1