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 getTopologyProcessor(Long topologyId, Long processorId, Long versionId) { TopologyProcessor topologyProcessor = new TopologyProcessor(); topologyProcessor.setId(processorId); topologyProcessor.setVersionId(versionId); TopologyProcessor processor = dao.get(new StorableKey(TOPOLOGY_PROCESSOR_NAMESPACE, topologyProcessor.getPrimaryKey())); if (processor == null || !processor.getTopologyId().equals(topologyId)) { return null; } fillProcessorStreams(processor); processor.setVersionTimestamp(getVersionTimestamp(versionId)); return processor; }
public TopologyProcessor removeTopologyProcessor(Long topologyId, Long processorId, Long versionId, boolean removeEdges) { TopologyProcessor topologyProcessor = getTopologyProcessor(topologyId, processorId, versionId); if (topologyProcessor != null) { if (removeEdges) { removeAllEdges(topologyProcessor); } removeProcessorStreamMapping(topologyProcessor); topologyProcessor = dao.<TopologyProcessor>remove(new StorableKey(TOPOLOGY_PROCESSOR_NAMESPACE, topologyProcessor.getPrimaryKey())); topologyProcessor.setVersionTimestamp(updateVersionTimestamp(versionId).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; }