public TopologyProcessor addOrUpdateTopologyProcessor(Long topologyId, Long id, TopologyProcessor topologyProcessor) { Long currentTopologyVersionId = getCurrentVersionId(topologyId); topologyProcessor.setId(id); topologyProcessor.setVersionId(currentTopologyVersionId); topologyProcessor.setTopologyId(topologyId); validateTopologyProcessor(topologyProcessor); topologyProcessor.setReconfigure(false); dao.addOrUpdate(topologyProcessor); List<Long> newList = Collections.emptyList(); if (topologyProcessor.getOutputStreamIds() != null) { newList = topologyProcessor.getOutputStreamIds(); } else if (topologyProcessor.getOutputStreams() != null) { newList = updateOutputStreams(topologyProcessor); } List<Long> existing = getOutputStreamIds(topologyProcessor); Sets.SetView<Long> streamIdsToRemove = Sets.difference(ImmutableSet.copyOf(existing), ImmutableSet.copyOf(newList)); Sets.SetView<Long> streamIdsToAdd = Sets.difference(ImmutableSet.copyOf(newList), ImmutableSet.copyOf(existing)); removeProcessorStreamMapping(topologyProcessor, Lists.newArrayList(streamIdsToRemove)); addProcessorStreamMapping(topologyProcessor, Lists.newArrayList(streamIdsToAdd)); TopologyProcessor updatedProcessor = getTopologyProcessor(topologyId, id, currentTopologyVersionId); updatedProcessor.setVersionTimestamp(updateVersionTimestamp(currentTopologyVersionId).getTimestamp()); return topologyProcessor; }
public TopologyProcessor addTopologyProcessor(Long topologyId, Long versionId, TopologyProcessor topologyProcessor) { if (topologyProcessor.getId() == null) { topologyProcessor.setId(getNextTopologyComponentId()); } topologyProcessor.setVersionId(versionId); topologyProcessor.setTopologyId(topologyId); validateTopologyProcessor(topologyProcessor); List<TopologyStream> topologyStreams = addTopologyOutputComponent(topologyProcessor); addProcessorStreamMapping(topologyProcessor, topologyProcessor.getOutputStreamIds()); topologyProcessor.setOutputStreams(topologyStreams); topologyProcessor.setVersionTimestamp(updateVersionTimestamp(versionId).getTimestamp()); return topologyProcessor; }