Search in sources :

Example 6 with TopologyEdge

use of com.hortonworks.streamline.streams.catalog.TopologyEdge in project streamline by hortonworks.

the class StreamCatalogService method getTopologyEdge.

public TopologyEdge getTopologyEdge(Long topologyId, Long edgeId, Long versionId) {
    TopologyEdge topologyEdge = new TopologyEdge();
    topologyEdge.setId(edgeId);
    topologyEdge.setVersionId(versionId);
    TopologyEdge edge = dao.get(new StorableKey(TOPOLOGY_EDGE_NAMESPACE, topologyEdge.getPrimaryKey()));
    if (edge == null || !edge.getTopologyId().equals(topologyId)) {
        return null;
    }
    edge.setVersionTimestamp(getVersionTimestamp(versionId));
    return edge;
}
Also used : StorableKey(com.hortonworks.registries.storage.StorableKey) TopologyEdge(com.hortonworks.streamline.streams.catalog.TopologyEdge)

Example 7 with TopologyEdge

use of com.hortonworks.streamline.streams.catalog.TopologyEdge in project streamline by hortonworks.

the class StreamCatalogService method removeTopologyDependencies.

private void removeTopologyDependencies(Long topologyId, Long versionId) throws Exception {
    List<QueryParam> topologyIdVersionIdQueryParams = WSUtils.buildTopologyIdAndVersionIdAwareQueryParams(topologyId, versionId, null);
    // remove topology test histories
    Collection<TopologyTestRunHistory> runHistories = listTopologyTestRunHistory(topologyId, versionId);
    runHistories.forEach(history -> removeTopologyTestRunHistory(history.getId()));
    // remove topology test run case
    Collection<TopologyTestRunCase> runCases = listTopologyTestRunCase(topologyIdVersionIdQueryParams);
    for (TopologyTestRunCase runCase : runCases) {
        Collection<TopologyTestRunCaseSource> runCaseSources = listTopologyTestRunCaseSource(runCase.getId());
        Collection<TopologyTestRunCaseSink> runCaseSinks = listTopologyTestRunCaseSink(runCase.getId());
        // remove topology test run case source
        for (TopologyTestRunCaseSource runCaseSource : runCaseSources) {
            removeTopologyTestRunCaseSource(runCaseSource.getId());
        }
        // remove topology test run case sink
        for (TopologyTestRunCaseSink runCaseSink : runCaseSinks) {
            removeTopologyTestRunCaseSink(runCaseSink.getId());
        }
        removeTestRunCase(topologyId, runCase.getId());
    }
    // remove edges
    Collection<TopologyEdge> edges = listTopologyEdges(topologyIdVersionIdQueryParams);
    for (TopologyEdge edge : edges) {
        removeTopologyEdge(topologyId, edge.getId(), versionId);
    }
    // remove rules
    Collection<TopologyRule> topologyRules = listRules(topologyIdVersionIdQueryParams);
    for (TopologyRule topologyRule : topologyRules) {
        removeRule(topologyId, topologyRule.getId(), versionId);
    }
    // remove windowed rules
    Collection<TopologyWindow> topologyWindows = listWindows(topologyIdVersionIdQueryParams);
    for (TopologyWindow topologyWindow : topologyWindows) {
        removeWindow(topologyId, topologyWindow.getId(), versionId);
    }
    // remove branch rules
    Collection<TopologyBranchRule> topologyBranchRules = listBranchRules(topologyIdVersionIdQueryParams);
    for (TopologyBranchRule topologyBranchRule : topologyBranchRules) {
        removeBranchRule(topologyId, topologyBranchRule.getId(), versionId);
    }
    // remove sinks
    Collection<TopologySink> sinks = listTopologySinks(topologyIdVersionIdQueryParams);
    for (TopologySink sink : sinks) {
        removeTopologySink(topologyId, sink.getId(), versionId, false);
    }
    // remove processors
    Collection<TopologyProcessor> processors = listTopologyProcessors(topologyIdVersionIdQueryParams);
    for (TopologyProcessor processor : processors) {
        removeTopologyProcessor(topologyId, processor.getId(), versionId, false);
    }
    // remove sources
    Collection<TopologySource> sources = listTopologySources(topologyIdVersionIdQueryParams);
    for (TopologySource source : sources) {
        removeTopologySource(topologyId, source.getId(), versionId, false);
    }
    // remove output streams
    Collection<TopologyStream> topologyStreams = listStreamInfos(topologyIdVersionIdQueryParams);
    for (TopologyStream topologyStream : topologyStreams) {
        removeStreamInfo(topologyId, topologyStream.getId(), versionId);
    }
    // remove topology editor metadata
    removeTopologyEditorMetadata(topologyId, versionId);
}
Also used : TopologyBranchRule(com.hortonworks.streamline.streams.catalog.TopologyBranchRule) TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) TopologyTestRunHistory(com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory) TopologyRule(com.hortonworks.streamline.streams.catalog.TopologyRule) BaseTopologyRule(com.hortonworks.streamline.streams.catalog.BaseTopologyRule) TopologyEdge(com.hortonworks.streamline.streams.catalog.TopologyEdge) TopologyTestRunCase(com.hortonworks.streamline.streams.catalog.TopologyTestRunCase) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) TopologyProcessor(com.hortonworks.streamline.streams.catalog.TopologyProcessor) TopologyWindow(com.hortonworks.streamline.streams.catalog.TopologyWindow) TopologySink(com.hortonworks.streamline.streams.catalog.TopologySink) TopologyStream(com.hortonworks.streamline.streams.catalog.TopologyStream) TopologyTestRunCaseSink(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink) QueryParam(com.hortonworks.registries.common.QueryParam) WSUtils.versionIdQueryParam(com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam) WSUtils.buildEdgesFromQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam) WSUtils.currentVersionQueryParam(com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam) WSUtils.buildEdgesToQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam)

Example 8 with TopologyEdge

use of com.hortonworks.streamline.streams.catalog.TopologyEdge in project streamline by hortonworks.

the class TopologyComponentFactory method getStreamlineEdge.

public Edge getStreamlineEdge(TopologyEdge topologyEdge) {
    Edge edge = new Edge();
    edge.setId(topologyEdge.getId().toString());
    edge.setFrom(getOutputComponent(topologyEdge));
    edge.setTo(getInputComponent(topologyEdge));
    Set<StreamGrouping> streamGroupings = new HashSet<>();
    for (TopologyEdge.StreamGrouping streamGrouping : topologyEdge.getStreamGroupings()) {
        Stream stream = getStream(catalogService.getStreamInfo(topologyEdge.getTopologyId(), streamGrouping.getStreamId(), topologyEdge.getVersionId()));
        Stream.Grouping grouping = Stream.Grouping.valueOf(streamGrouping.getGrouping().name());
        streamGroupings.add(new StreamGrouping(stream, grouping, streamGrouping.getFields()));
    }
    edge.addStreamGroupings(streamGroupings);
    return edge;
}
Also used : TopologyStream(com.hortonworks.streamline.streams.catalog.TopologyStream) Stream(com.hortonworks.streamline.streams.layout.component.Stream) Edge(com.hortonworks.streamline.streams.layout.component.Edge) TopologyEdge(com.hortonworks.streamline.streams.catalog.TopologyEdge) TopologyEdge(com.hortonworks.streamline.streams.catalog.TopologyEdge) StreamGrouping(com.hortonworks.streamline.streams.layout.component.StreamGrouping) HashSet(java.util.HashSet)

Example 9 with TopologyEdge

use of com.hortonworks.streamline.streams.catalog.TopologyEdge in project streamline by hortonworks.

the class TopologyExportVisitor method visit.

public void visit(Edge edge) {
    TopologyEdge topologyEdge = streamCatalogService.getTopologyEdge(topologyId, Long.parseLong(edge.getId()));
    topologyData.addEdge(topologyEdge);
}
Also used : TopologyEdge(com.hortonworks.streamline.streams.catalog.TopologyEdge)

Example 10 with TopologyEdge

use of com.hortonworks.streamline.streams.catalog.TopologyEdge in project streamline by hortonworks.

the class StreamCatalogService method addOrUpdateTopologyEdge.

public TopologyEdge addOrUpdateTopologyEdge(Long topologyId, Long id, TopologyEdge topologyEdge) {
    Long currentTopologyVersionId = getCurrentVersionId(topologyId);
    topologyEdge.setId(id);
    topologyEdge.setVersionId(currentTopologyVersionId);
    topologyEdge.setTopologyId(topologyId);
    validateEdge(topologyEdge);
    // reconfigure target of current edge
    TopologyEdge curEdge = getTopologyEdge(topologyId, id);
    if (curEdge != null) {
        if (!curEdge.getToId().equals(topologyEdge.getToId()) || !getStreamIds(curEdge).equals(getStreamIds(topologyEdge))) {
            setReconfigureTarget(curEdge);
        }
    }
    dao.addOrUpdate(topologyEdge);
    topologyEdge.setVersionTimestamp(updateVersionTimestamp(currentTopologyVersionId).getTimestamp());
    return topologyEdge;
}
Also used : TopologyEdge(com.hortonworks.streamline.streams.catalog.TopologyEdge)

Aggregations

TopologyEdge (com.hortonworks.streamline.streams.catalog.TopologyEdge)15 Timed (com.codahale.metrics.annotation.Timed)5 QueryParam (com.hortonworks.registries.common.QueryParam)5 WSUtils.buildEdgesFromQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam)5 WSUtils.buildEdgesToQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam)5 WSUtils.currentVersionQueryParam (com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam)5 WSUtils.versionIdQueryParam (com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam)5 Path (javax.ws.rs.Path)5 StorableKey (com.hortonworks.registries.storage.StorableKey)4 BaseTopologyRule (com.hortonworks.streamline.streams.catalog.BaseTopologyRule)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 StorageException (com.hortonworks.registries.storage.exception.StorageException)3 ComponentConfigException (com.hortonworks.streamline.common.exception.ComponentConfigException)3 TopologyBranchRule (com.hortonworks.streamline.streams.catalog.TopologyBranchRule)3 TopologyProcessor (com.hortonworks.streamline.streams.catalog.TopologyProcessor)3 TopologyRule (com.hortonworks.streamline.streams.catalog.TopologyRule)3 TopologySink (com.hortonworks.streamline.streams.catalog.TopologySink)3 TopologySource (com.hortonworks.streamline.streams.catalog.TopologySource)3 TopologyStream (com.hortonworks.streamline.streams.catalog.TopologyStream)3 TopologyTestRunCase (com.hortonworks.streamline.streams.catalog.TopologyTestRunCase)3