import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicReference;
-import javax.annotation.CheckReturnValue;
-import javax.annotation.concurrent.GuardedBy;
-import javax.annotation.concurrent.ThreadSafe;
+import org.checkerframework.checker.lock.qual.GuardedBy;
+import org.checkerframework.checker.lock.qual.Holding;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
import org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState;
import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
-import org.opendaylight.yangtools.concepts.Path;
+import org.opendaylight.yangtools.concepts.HierarchicalIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Implementation of {@link ClusterSingletonServiceGroup} on top of the Entitiy Ownership Service. Since EOS is atomic
+ * Implementation of {@link ClusterSingletonServiceGroup} on top of the Entity Ownership Service. Since EOS is atomic
* in its operation and singleton services incur startup and most notably cleanup, we need to do something smart here.
*
* <p>
* @param <G> the GenericEntityOwnershipListener type
* @param <S> the GenericEntityOwnershipService type
*/
-@ThreadSafe
-final class ClusterSingletonServiceGroupImpl<P extends Path<P>, E extends GenericEntity<P>,
+final class ClusterSingletonServiceGroupImpl<P extends HierarchicalIdentifier<P>, E extends GenericEntity<P>,
C extends GenericEntityOwnershipChange<P, E>, G extends GenericEntityOwnershipListener<P, C>,
S extends GenericEntityOwnershipService<P, E, G>> extends ClusterSingletonServiceGroup<P, E, C> {
@Override
void registerService(final ClusterSingletonServiceRegistration reg) {
- final ClusterSingletonService service = reg.getInstance();
- verify(identifier.equals(service.getIdentifier().getValue()));
+ final ClusterSingletonService service = verifyRegistration(reg);
checkNotClosed();
checkState(initialized, "Service group %s is not initialized yet", identifier);
reconcileState();
}
- @CheckReturnValue
@Override
ListenableFuture<?> unregisterService(final ClusterSingletonServiceRegistration reg) {
- final ClusterSingletonService service = reg.getInstance();
- verify(identifier.equals(service.getIdentifier().getValue()));
+ verifyRegistration(reg);
checkNotClosed();
verify(members.remove(reg));
return null;
}
+ private ClusterSingletonService verifyRegistration(final ClusterSingletonServiceRegistration reg) {
+ final ClusterSingletonService service = reg.getInstance();
+ verify(identifier.equals(service.getIdentifier().getName()));
+ return service;
+ }
+
private synchronized @NonNull ListenableFuture<?> destroyGroup() {
final SettableFuture<Void> future = SettableFuture.create();
if (!closeFuture.compareAndSet(null, future)) {
if (isDirty()) {
if (!tryLock()) {
- LOG.debug("Service group {} postponing ownership change sync");
+ LOG.debug("Service group {} postponing ownership change sync", identifier);
return;
}
*
* @param ownershipChange reported change
*/
- @GuardedBy("this")
+ @Holding("this")
private void lockedOwnershipChanged(final C ownershipChange) {
final E entity = ownershipChange.getEntity();
if (serviceEntity.equals(entity)) {
}
}
- @GuardedBy("this")
+ @Holding("this")
private void cleanupCandidateOwnershipChanged(final EntityOwnershipChangeState state, final boolean jeopardy) {
if (jeopardy) {
switch (state) {
}
}
- @GuardedBy("this")
+ @Holding("this")
private void serviceOwnershipChanged(final EntityOwnershipChangeState state, final boolean jeopardy) {
if (jeopardy) {
LOG.info("Service group {} service entity ownership uncertain", identifier);
}
}
+ @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "https://github.com/spotbugs/spotbugs/issues/811")
private void serviceTransitionCompleted() {
markDirty();
if (tryLock()) {