+ LOG.trace("Storing flowDescriptor with table ID : {} and flow ID : {} for flow hash : {}",
+ flowDescriptor.getTableKey().getId(), flowDescriptor.getFlowId().getValue(), correctFlowRegistryKey.hashCode());
+
+ flowRegistry.put(correctFlowRegistryKey, flowDescriptor);
+ } catch (IllegalArgumentException ex) {
+ if (hasMark(flowRegistry.inverse().get(flowDescriptor))) {
+ // We are probably doing update of flow, but without changing flow ID or table ID, so we need to replace
+ // old value with new value, but keep the old value marked for removal
+ flowRegistry.forcePut(correctFlowRegistryKey, flowDescriptor);
+ return;
+ }
+
+ // We are trying to store new flow to flow registry, but we already have different flow with same flow ID
+ // stored in registry, so we need to create alien ID for this new flow here.
+ LOG.warn("Flow with flow ID {} already exists in table {}, generating alien flow ID", flowDescriptor.getFlowId().getValue(),
+ flowDescriptor.getTableKey().getId());
+
+ flowRegistry.put(
+ correctFlowRegistryKey,
+ FlowDescriptorFactory.create(
+ flowDescriptor.getTableKey().getId(),
+ createAlienFlowId(flowDescriptor.getTableKey().getId())));
+ }
+ }
+
+ @Override
+ @GuardedBy("this")
+ public synchronized void forEachEntry(final BiConsumer<FlowRegistryKey, FlowDescriptor> consumer) {
+ flowRegistry.forEach(consumer);
+ }
+
+ @Override
+ @GuardedBy("this")
+ public synchronized void store(final FlowRegistryKey flowRegistryKey) {
+ if (Objects.isNull(retrieveDescriptor(flowRegistryKey))) {
+ // We do not found flow in flow registry, that means it do not have any ID already assigned, so we need
+ // to generate new alien flow ID here.
+ LOG.debug("Flow descriptor for flow hash : {} not found, generating alien flow ID", flowRegistryKey.hashCode());