public TopologySource getTopologySource(Long topologyId, Long sourceId, Long versionId) { TopologySource topologySource = new TopologySource(); topologySource.setId(sourceId); topologySource.setVersionId(versionId); TopologySource source = dao.get(new StorableKey(TOPOLOGY_SOURCE_NAMESPACE, topologySource.getPrimaryKey())); if (source == null || !source.getTopologyId().equals(topologyId)) { return null; } fillSourceStreams(source); return source; }
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; }
topologySource.setId(null); topologySource.setTopologyId(newTopology.getId()); TopologyComponentBundle bundle = getCurrentTopologyComponentBundle(
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; }