- LOG.trace("Storing flowDescriptor with table ID : {} and flow ID : {} for flow hash : {}", flowDescriptor.getTableKey().getId(), flowDescriptor.getFlowId().getValue(), flowRegistryKey.hashCode());
- flowRegistry.put(flowRegistryKey, flowDescriptor);
+ try {
+ LOG.trace("Storing flowDescriptor with table ID : {} and flow ID : {} for flow hash : {}",
+ flowDescriptor.getTableKey().getId(), flowDescriptor.getFlowId().getValue(), flowRegistryKey.hashCode());
+ flowRegistry.put(flowRegistryKey, flowDescriptor);
+ } catch (IllegalArgumentException ex) {
+ LOG.error("Flow with flowId {} already exists in table {}", flowDescriptor.getFlowId().getValue(),
+ flowDescriptor.getTableKey().getId());
+ final FlowId newFlowId = createAlienFlowId(flowDescriptor.getTableKey().getId());
+ final FlowDescriptor newFlowDescriptor = FlowDescriptorFactory.
+ create(flowDescriptor.getTableKey().getId(), newFlowId);
+ flowRegistry.put(flowRegistryKey, newFlowDescriptor);
+ }
+ }
+
+ @Override
+ public void update(final FlowRegistryKey newFlowRegistryKey, final FlowDescriptor flowDescriptor) {
+ LOG.trace("Updating the entry with hash: {}", newFlowRegistryKey.hashCode());
+ flowRegistry.forcePut(newFlowRegistryKey, flowDescriptor);