import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
Futures.addCallback(future, new FutureCallback<Optional<FlowCapableNode>>() {
@Override
- public void onSuccess(Optional<FlowCapableNode> result) {
+ public void onSuccess(@Nonnull Optional<FlowCapableNode> result) {
result.asSet().stream()
.filter(Objects::nonNull)
.filter(flowCapableNode -> Objects.nonNull(flowCapableNode.getTable()))
// Even when read operation failed, close the transaction
transaction.close();
}
- });
+ }, MoreExecutors.directExecutor());
return future;
}
}
private FlowRegistryKey getExistingKey(final FlowRegistryKey flowRegistryKey) {
- if (flowRegistryKey.getMatch().getAugmentation(GeneralAugMatchNodesNodeTableFlow.class) == null) {
+ if (flowRegistryKey.getMatch().augmentation(GeneralAugMatchNodesNodeTableFlow.class) == null) {
if (flowRegistry.containsKey(flowRegistryKey)) {
return flowRegistryKey;
}
} else {
- for (Map.Entry<FlowRegistryKey, FlowDescriptor> keyValueSet : flowRegistry.entrySet()) {
- if (keyValueSet.getKey().equals(flowRegistryKey)) {
- return keyValueSet.getKey();
+ synchronized (flowRegistry) {
+ for (Map.Entry<FlowRegistryKey, FlowDescriptor> keyValueSet : flowRegistry.entrySet()) {
+ if (keyValueSet.getKey().equals(flowRegistryKey)) {
+ return keyValueSet.getKey();
+ }
}
}
}