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; }
Long oldComponentId = topologySource.getId(); topologySource.setId(null); topologySource.setTopologyId(newTopology.getId()); TopologyComponentBundle bundle = getCurrentTopologyComponentBundle( TopologyComponentBundle.TopologyComponentType.SOURCE,
public TopologySource addTopologySource(Long topologyId, Long versionId, TopologySource topologySource) { if (topologySource.getId() == null) { topologySource.setId(getNextTopologyComponentId()); } topologySource.setVersionId(versionId); topologySource.setTopologyId(topologyId); validateTopologySource(topologySource); List<TopologyStream> topologyStreams = addTopologyOutputComponent(topologySource); addSourceStreamMapping(topologySource, topologySource.getOutputStreamIds()); topologySource.setOutputStreams(topologyStreams); topologySource.setVersionTimestamp(updateVersionTimestamp(versionId).getTimestamp()); return topologySource; }