Improve LocalProxyTransaction.doExists()
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / FrontendMetadata.java
index 0bf23e776c563c8e42fe4bb8e3cae79f71a784d5..e3a18997e43e68fc3597936e99a4a58890d73403 100644 (file)
@@ -11,6 +11,7 @@ import static com.google.common.base.Verify.verify;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Maps;
 import java.util.HashMap;
 import java.util.Map;
@@ -21,6 +22,7 @@ import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifie
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.persisted.FrontendClientMetadata;
 import org.opendaylight.controller.cluster.datastore.persisted.FrontendShardDataTreeSnapshotMetadata;
+import org.opendaylight.controller.cluster.datastore.utils.ImmutableUnsignedLongSet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -119,6 +121,11 @@ final class FrontendMetadata extends ShardDataTreeMetadata<FrontendShardDataTree
         ensureClient(txId.getHistoryId().getClientId()).onTransactionPurged(txId);
     }
 
+    @Override
+    void onTransactionsSkipped(final LocalHistoryIdentifier historyId, final ImmutableUnsignedLongSet txIds) {
+        ensureClient(historyId.getClientId()).onTransactionsSkipped(historyId, txIds);
+    }
+
     /**
      * Transform frontend metadata into an active leader state map.
      *
@@ -132,7 +139,7 @@ final class FrontendMetadata extends ShardDataTreeMetadata<FrontendShardDataTree
         final FrontendIdentifier frontendId = clientId.getFrontendId();
         final FrontendClientMetadataBuilder client = clients.get(frontendId);
         if (client == null) {
-            // When we havent seen the client before, we still need to disable tracking for him since this only gets
+            // When we have not seen the client before, we still need to disable tracking for him since this only gets
             // triggered once.
             LOG.debug("{}: disableTracking {} does not match any client, pre-disabling client.", shardName, clientId);
             clients.put(frontendId, new FrontendClientMetadataBuilder.Disabled(shardName, clientId));
@@ -149,4 +156,10 @@ final class FrontendMetadata extends ShardDataTreeMetadata<FrontendShardDataTree
 
         verify(clients.replace(frontendId, client, new FrontendClientMetadataBuilder.Disabled(shardName, clientId)));
     }
+
+    ImmutableSet<ClientIdentifier> getClients() {
+        return clients.values().stream()
+                .map(FrontendClientMetadataBuilder::getIdentifier)
+                .collect(ImmutableSet.toImmutableSet());
+    }
 }