use of com.hortonworks.streamline.streams.catalog.TopologySource in project streamline by hortonworks.
the class StreamCatalogService method copyTopologyDependencies.
private void copyTopologyDependencies(Long topologyId, Long oldVersionId, Long newVersionId) throws Exception {
List<QueryParam> topologyIdVersionIdQueryParams = WSUtils.buildTopologyIdAndVersionIdAwareQueryParams(topologyId, oldVersionId, null);
// topology editor metadata
TopologyEditorMetadata metadata = getTopologyEditorMetadata(topologyId, oldVersionId);
if (metadata != null) {
addTopologyEditorMetadata(topologyId, newVersionId, new TopologyEditorMetadata(metadata));
}
// sources, output streams
Collection<TopologySource> sources = listTopologySources(topologyIdVersionIdQueryParams);
for (TopologySource source : sources) {
addTopologySource(topologyId, newVersionId, new TopologySource(source));
}
// processors, output streams
Collection<TopologyProcessor> processors = listTopologyProcessors(topologyIdVersionIdQueryParams);
for (TopologyProcessor processor : processors) {
addTopologyProcessor(topologyId, newVersionId, new TopologyProcessor(processor));
}
// add sinks
Collection<TopologySink> sinks = listTopologySinks(topologyIdVersionIdQueryParams);
for (TopologySink sink : sinks) {
addTopologySink(topologyId, newVersionId, new TopologySink(sink));
}
// branch rules
Collection<TopologyBranchRule> topologyBranchRules = listBranchRules(topologyIdVersionIdQueryParams);
for (TopologyBranchRule topologyBranchRule : topologyBranchRules) {
addBranchRule(topologyId, newVersionId, new TopologyBranchRule(topologyBranchRule));
}
// windowed rules
Collection<TopologyWindow> topologyWindows = listWindows(topologyIdVersionIdQueryParams);
for (TopologyWindow topologyWindow : topologyWindows) {
addWindow(topologyId, newVersionId, new TopologyWindow(topologyWindow));
}
// rules
Collection<TopologyRule> topologyRules = listRules(topologyIdVersionIdQueryParams);
for (TopologyRule topologyRule : topologyRules) {
addRule(topologyId, newVersionId, new TopologyRule(topologyRule));
}
// add edges
Collection<TopologyEdge> edges = listTopologyEdges(topologyIdVersionIdQueryParams);
for (TopologyEdge edge : edges) {
addTopologyEdge(topologyId, newVersionId, new TopologyEdge(edge));
}
// add 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());
TopologyTestRunCase newCase = addTopologyTestRunCase(topologyId, newVersionId, new TopologyTestRunCase(runCase));
// add topology test run case source
for (TopologyTestRunCaseSource runCaseSource : runCaseSources) {
addTopologyTestRunCaseSource(newCase.getId(), newVersionId, new TopologyTestRunCaseSource(runCaseSource));
}
// add topology test run case sink
for (TopologyTestRunCaseSink runCaseSink : runCaseSinks) {
addTopologyTestRunCaseSink(newCase.getId(), newVersionId, new TopologyTestRunCaseSink(runCaseSink));
}
}
}
use of com.hortonworks.streamline.streams.catalog.TopologySource in project streamline by hortonworks.
the class StreamCatalogService method getFrom.
private TopologyOutputComponent getFrom(TopologyEdge edge) {
TopologySource source = getTopologySource(edge.getTopologyId(), edge.getFromId(), edge.getVersionId());
TopologyProcessor processor = getTopologyProcessor(edge.getTopologyId(), edge.getFromId(), edge.getVersionId());
return processor != null ? processor : source;
}
use of com.hortonworks.streamline.streams.catalog.TopologySource in project streamline by hortonworks.
the class StreamCatalogService method addOrUpdateTopologySource.
public TopologySource addOrUpdateTopologySource(Long topologyId, Long sourceId, TopologySource topologySource) {
Long currentTopologyVersionId = getCurrentVersionId(topologyId);
topologySource.setId(sourceId);
topologySource.setVersionId(currentTopologyVersionId);
topologySource.setTopologyId(topologyId);
validateTopologySource(topologySource);
topologySource.setReconfigure(false);
dao.addOrUpdate(topologySource);
List<Long> newList = Collections.emptyList();
if (topologySource.getOutputStreamIds() != null) {
newList = topologySource.getOutputStreamIds();
} else if (topologySource.getOutputStreams() != null) {
newList = updateOutputStreams(topologySource);
}
List<Long> existing = getOutputStreamIds(topologySource);
Sets.SetView<Long> streamIdsToRemove = Sets.difference(ImmutableSet.copyOf(existing), ImmutableSet.copyOf(newList));
Sets.SetView<Long> streamIdsToAdd = Sets.difference(ImmutableSet.copyOf(newList), ImmutableSet.copyOf(existing));
removeSourceStreamMapping(topologySource, Lists.newArrayList(streamIdsToRemove));
addSourceStreamMapping(topologySource, Lists.newArrayList(streamIdsToAdd));
TopologySource updatedSource = getTopologySource(topologyId, sourceId, currentTopologyVersionId);
updatedSource.setVersionTimestamp(updateVersionTimestamp(currentTopologyVersionId).getTimestamp());
return updatedSource;
}
use of com.hortonworks.streamline.streams.catalog.TopologySource 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);
}
use of com.hortonworks.streamline.streams.catalog.TopologySource in project streamline by hortonworks.
the class TopologyComponentFactory method getOutputComponent.
private OutputComponent getOutputComponent(TopologyEdge topologyEdge) {
TopologySource topologySource;
TopologyProcessor topologyProcessor;
if ((topologySource = catalogService.getTopologySource(topologyEdge.getTopologyId(), topologyEdge.getFromId(), topologyEdge.getVersionId())) != null) {
return getStreamlineSource(topologySource);
} else if ((topologyProcessor = catalogService.getTopologyProcessor(topologyEdge.getTopologyId(), topologyEdge.getFromId(), topologyEdge.getVersionId())) != null) {
return getStreamlineProcessor(topologyProcessor);
} else {
throw new IllegalArgumentException("Invalid from id for edge " + topologyEdge);
}
}
Aggregations