X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FFrontendMetadata.java;h=efb0fdc04beb351845e6a4465298a705f5ba8156;hb=refs%2Fchanges%2F14%2F82314%2F25;hp=969accd583c130160177be9316992da98704d559;hpb=62cddd88e42e8f3c6a92bbf42c97b0d6806f44ae;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendMetadata.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendMetadata.java index 969accd583..efb0fdc04b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendMetadata.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendMetadata.java @@ -7,6 +7,8 @@ */ package org.opendaylight.controller.cluster.datastore; +import static com.google.common.base.Verify.verify; + import com.google.common.base.Preconditions; import com.google.common.collect.Collections2; import com.google.common.collect.Maps; @@ -57,7 +59,7 @@ final class FrontendMetadata extends ShardDataTreeMetadata toLeaderState(final @NonNull Shard shard) { return new HashMap<>(Maps.transformValues(clients, meta -> meta.toLeaderState(shard))); } + + void disableTracking(final ClientIdentifier clientId) { + 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 + // triggered once. + LOG.debug("{}: disableTracking {} does not match any client, pre-disabling client.", shardName, clientId); + clients.put(frontendId, new FrontendClientMetadataBuilder.Disabled(shardName, clientId)); + return; + } + if (!clientId.equals(client.getIdentifier())) { + LOG.debug("{}: disableTracking {} does not match client {}, ignoring", shardName, clientId, client); + return; + } + if (client instanceof FrontendClientMetadataBuilder.Disabled) { + LOG.debug("{}: client {} is has already disabled tracking", shardName, client); + return; + } + + verify(clients.replace(frontendId, client, new FrontendClientMetadataBuilder.Disabled(shardName, clientId))); + } }