Use simple Registration in ClusterSingletonServiceProvider 46/109246/1
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 9 Dec 2023 07:57:28 +0000 (08:57 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 9 Dec 2023 08:07:14 +0000 (09:07 +0100)
Move ClusterSingletonServiceRegistration into the implementation, so
that end users operate on a plain Registration.

Within implementation, combine it with its sole base implementation to
form a better-named ServiceRegistration.

JIRA: MDSAL-843
Change-Id: I2506a6f86cd66794612b77791d3f5a5ab058f4b5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
singleton-service/mdsal-singleton-common-api/src/main/java/org/opendaylight/mdsal/singleton/common/api/ClusterSingletonServiceProvider.java
singleton-service/mdsal-singleton-common-api/src/main/java/org/opendaylight/mdsal/singleton/common/api/ClusterSingletonServiceRegistration.java [deleted file]
singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/ClusterSingletonServiceGroup.java
singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/ClusterSingletonServiceGroupImpl.java
singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/EOSClusterSingletonServiceProvider.java
singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/PlaceholderGroup.java
singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/ServiceRegistration.java [moved from singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/AbstractClusterSingletonServiceRegistration.java with 61% similarity]
singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/AbstractEOSClusterSingletonServiceProviderTest.java
singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/AsyncEOSClusterSingletonServiceProviderTest.java
singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/ClusterSingletonServiceGroupImplTest.java
singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/SyncEOSClusterSingletonServiceProviderTest.java

index a9aef73b39c335a16b3f208f7547910227ebf3f2..770e534ea414c30370e6a47890dfacc2405cd1e3 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.mdsal.singleton.common.api;
 
+import org.opendaylight.yangtools.concepts.Registration;
+
 /**
  * {@link ClusterSingletonServiceProvider} provides a functionality to register and group services
  * {@link ClusterSingletonService} by service group identifier. Services could be Applications or RPCs.
@@ -30,7 +32,7 @@ public interface ClusterSingletonServiceProvider {
      * RuntimeException implementation is a hotfix for an unwanted API contract changes in boron release only.
      *
      * @param service ClusterSingletonService instance
-     * @return {@link AutoCloseable} registration
+     * @return {@link Registration} registration
      */
-    ClusterSingletonServiceRegistration registerClusterSingletonService(ClusterSingletonService service);
+    Registration registerClusterSingletonService(ClusterSingletonService service);
 }
diff --git a/singleton-service/mdsal-singleton-common-api/src/main/java/org/opendaylight/mdsal/singleton/common/api/ClusterSingletonServiceRegistration.java b/singleton-service/mdsal-singleton-common-api/src/main/java/org/opendaylight/mdsal/singleton/common/api/ClusterSingletonServiceRegistration.java
deleted file mode 100644 (file)
index 8b68933..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.singleton.common.api;
-
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-
-/**
- * An {@link ObjectRegistration} of a {@link ClusterSingletonService} instance.
- */
-public interface ClusterSingletonServiceRegistration extends ObjectRegistration<ClusterSingletonService> {
-
-}
index f52e76f80ab86be535e51f43e6e7b399df1581fb..633cad5fe91be125db944b0aa79263b0c1efdfab 100644 (file)
@@ -13,7 +13,6 @@ import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException
 import org.opendaylight.mdsal.eos.common.api.EntityOwnershipStateChange;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
 import org.opendaylight.yangtools.concepts.Identifiable;
 
 /**
@@ -31,33 +30,32 @@ import org.opendaylight.yangtools.concepts.Identifiable;
 // FIXME: rename to ServiceGroup and seal
 abstract class ClusterSingletonServiceGroup implements Identifiable<String> {
     /**
-     * This method must be called once on startup to initialize this group and
-     * register the relevant group entity candidate. It means create relevant
-     * Group Entity Candidate Registration.
+     * This method must be called once on startup to initialize this group and register the relevant group entity
+     * candidate. It means create relevant Group Entity Candidate Registration.
      */
     abstract void initialize() throws CandidateAlreadyRegisteredException;
 
     /**
-     * This method registers a service instance for this service group. If the local node has
-     * ownership of the service group, the {@link ClusterSingletonService#instantiateServiceInstance()}
-     * method is called. Otherwise, the method is called once the local node gains ownership.
+     * This method registers a service instance for this service group. If the local node has ownership of the service
+     * group, the {@link ClusterSingletonService#instantiateServiceInstance()} method is called. Otherwise, the method
+     * is called once the local node gains ownership.
      *
      * @param service instance
      */
-    abstract void registerService(ClusterSingletonServiceRegistration reg);
+    abstract void registerService(ServiceRegistration reg);
 
     /**
-     * Method provides possibility to restart some service from group without change
-     * leadership for whole group. {@link ClusterSingletonServiceRegistration#close()}
-     * implementation has to call this service.
-     * Candidates are signed for group, so unregistration for group with one service
-     * has to trigger new election only otherwise we can see same behavior as on server
-     * without clustering.
+     * Method provides possibility to restart some service from group without change leadership for whole group.
+     * {@link ServiceRegistration#removeRegistration()} implementation has to call this service.
+     *
+     * <p>
+     * Candidates are signed for group, so unregistration for group with one service has to trigger new election only
+     * otherwise we can see same behavior as on server without clustering.
      *
      * @param service instance
      * @return Future which completes when this instance is shutdown if this was the last registration, null otherwise
      */
-    abstract @Nullable ListenableFuture<?> unregisterService(ClusterSingletonServiceRegistration reg);
+    abstract @Nullable ListenableFuture<?> unregisterService(ServiceRegistration reg);
 
     /**
      * Method implementation has to apply ownershipChange for all registered services.
index bab4be06f6465ce78c71da6348a4892aa3aa0a0b..1f5f4ccab27a17555adb4b060fb38d4ff62f55e7 100644 (file)
@@ -22,11 +22,9 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.SettableFuture;
-import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
@@ -39,7 +37,6 @@ import org.opendaylight.mdsal.eos.common.api.EntityOwnershipStateChange;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -115,9 +112,9 @@ final class ClusterSingletonServiceGroupImpl extends ClusterSingletonServiceGrou
     private final @NonNull DOMEntity serviceEntity;
     private final @NonNull DOMEntity cleanupEntity;
 
-    private final Set<ClusterSingletonServiceRegistration> members = ConcurrentHashMap.newKeySet();
+    private final Set<ServiceRegistration> members = ConcurrentHashMap.newKeySet();
     // Guarded by lock
-    private final Map<ClusterSingletonServiceRegistration, ServiceInfo> services = new HashMap<>();
+    private final Map<ServiceRegistration, ServiceInfo> services = new HashMap<>();
 
     // Marker for when any state changed
     private static final AtomicIntegerFieldUpdater<ClusterSingletonServiceGroupImpl> DIRTY_UPDATER =
@@ -190,8 +187,7 @@ final class ClusterSingletonServiceGroupImpl extends ClusterSingletonServiceGrou
      * @param services Services list
      */
     ClusterSingletonServiceGroupImpl(final String identifier, final DOMEntityOwnershipService entityOwnershipService,
-            final DOMEntity serviceEntity, final DOMEntity cleanupEntity,
-            final Collection<ClusterSingletonServiceRegistration> services) {
+            final DOMEntity serviceEntity, final DOMEntity cleanupEntity, final List<ServiceRegistration> services) {
         checkArgument(!identifier.isEmpty(), "Identifier may not be empty");
         this.identifier = identifier;
         this.entityOwnershipService = requireNonNull(entityOwnershipService);
@@ -253,7 +249,7 @@ final class ClusterSingletonServiceGroupImpl extends ClusterSingletonServiceGrou
     }
 
     @Override
-    void registerService(final ClusterSingletonServiceRegistration reg) {
+    void registerService(final ServiceRegistration reg) {
         final ClusterSingletonService service = verifyRegistration(reg);
         checkNotClosed();
 
@@ -273,7 +269,7 @@ final class ClusterSingletonServiceGroupImpl extends ClusterSingletonServiceGrou
     }
 
     @Override
-    ListenableFuture<?> unregisterService(final ClusterSingletonServiceRegistration reg) {
+    ListenableFuture<?> unregisterService(final ServiceRegistration reg) {
         verifyRegistration(reg);
         checkNotClosed();
 
@@ -295,14 +291,14 @@ final class ClusterSingletonServiceGroupImpl extends ClusterSingletonServiceGrou
         return null;
     }
 
-    private ClusterSingletonService verifyRegistration(final ClusterSingletonServiceRegistration reg) {
+    private ClusterSingletonService verifyRegistration(final ServiceRegistration 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();
+        final var future = SettableFuture.<Void>create();
         if (!closeFuture.compareAndSet(null, future)) {
             return verifyNotNull(closeFuture.get());
         }
@@ -468,7 +464,7 @@ final class ClusterSingletonServiceGroupImpl extends ClusterSingletonServiceGrou
     // Has to be called with lock asserted
     private void tryReconcileState() {
         // First take a safe snapshot of current state on which we will base our decisions.
-        final Set<ClusterSingletonServiceRegistration> localMembers;
+        final Set<ServiceRegistration> localMembers;
         final boolean haveCleanup;
         final boolean haveService;
         synchronized (this) {
@@ -545,18 +541,18 @@ final class ClusterSingletonServiceGroupImpl extends ClusterSingletonServiceGrou
 
     // Has to be called with lock asserted
     @SuppressWarnings("illegalCatch")
-    private void ensureServicesStarting(final Set<ClusterSingletonServiceRegistration> localConfig) {
+    private void ensureServicesStarting(final Set<ServiceRegistration> localConfig) {
         LOG.debug("Service group {} starting services", identifier);
 
         // This may look counter-intuitive, but the localConfig may be missing some services that are started -- for
         // example when this method is executed as part of unregisterService() call. In that case we need to ensure
         // services in the list are stopping
-        final Iterator<Entry<ClusterSingletonServiceRegistration, ServiceInfo>> it = services.entrySet().iterator();
+        final var it = services.entrySet().iterator();
         while (it.hasNext()) {
-            final Entry<ClusterSingletonServiceRegistration, ServiceInfo> entry = it.next();
-            final ClusterSingletonServiceRegistration reg = entry.getKey();
+            final var entry = it.next();
+            final var reg = entry.getKey();
             if (!localConfig.contains(reg)) {
-                final ServiceInfo newInfo = ensureStopping(reg, entry.getValue());
+                final var newInfo = ensureStopping(reg, entry.getValue());
                 if (newInfo != null) {
                     entry.setValue(newInfo);
                 } else {
@@ -566,9 +562,9 @@ final class ClusterSingletonServiceGroupImpl extends ClusterSingletonServiceGrou
         }
 
         // Now make sure member services are being juggled around
-        for (ClusterSingletonServiceRegistration reg : localConfig) {
+        for (var reg : localConfig) {
             if (!services.containsKey(reg)) {
-                final ClusterSingletonService service = reg.getInstance();
+                final var service = reg.getInstance();
                 LOG.debug("Starting service {}", service);
 
                 try {
@@ -586,10 +582,10 @@ final class ClusterSingletonServiceGroupImpl extends ClusterSingletonServiceGrou
 
     // Has to be called with lock asserted
     private void ensureServicesStopping() {
-        final Iterator<Entry<ClusterSingletonServiceRegistration, ServiceInfo>> it = services.entrySet().iterator();
+        final var it = services.entrySet().iterator();
         while (it.hasNext()) {
-            final Entry<ClusterSingletonServiceRegistration, ServiceInfo> entry = it.next();
-            final ServiceInfo newInfo = ensureStopping(entry.getKey(), entry.getValue());
+            final var entry = it.next();
+            final var newInfo = ensureStopping(entry.getKey(), entry.getValue());
             if (newInfo != null) {
                 entry.setValue(newInfo);
             } else {
@@ -599,10 +595,10 @@ final class ClusterSingletonServiceGroupImpl extends ClusterSingletonServiceGrou
     }
 
     @SuppressWarnings("illegalCatch")
-    private ServiceInfo ensureStopping(final ClusterSingletonServiceRegistration reg, final ServiceInfo info) {
+    private ServiceInfo ensureStopping(final ServiceRegistration reg, final ServiceInfo info) {
         switch (info.getState()) {
             case STARTED:
-                final ClusterSingletonService service = reg.getInstance();
+                final var service = reg.getInstance();
 
                 LOG.debug("Service group {} stopping service {}", identifier, service);
                 final @NonNull ListenableFuture<?> future;
index 1c9469fba51dd7a8f237b739872a7a1ced242b89..042653410e637b58568bc4278dc40e66387af836 100644 (file)
@@ -33,7 +33,6 @@ import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.osgi.service.component.annotations.Activate;
@@ -102,8 +101,7 @@ public final class EOSClusterSingletonServiceProvider
     }
 
     @Override
-    public synchronized ClusterSingletonServiceRegistration registerClusterSingletonService(
-            final ClusterSingletonService service) {
+    public synchronized Registration registerClusterSingletonService(final ClusterSingletonService service) {
         LOG.debug("Call registrationService {} method for ClusterSingletonService Provider {}", service, this);
 
         final String serviceIdentifier = service.getIdentifier().getName();
@@ -125,7 +123,7 @@ public final class EOSClusterSingletonServiceProvider
             serviceGroup = existing;
         }
 
-        final var reg = new AbstractClusterSingletonServiceRegistration(service) {
+        final var reg = new ServiceRegistration(service) {
             @Override
             protected void removeRegistration() {
                 // We need to bounce the unregistration through a ordered lock in order not to deal with asynchronous
@@ -139,7 +137,7 @@ public final class EOSClusterSingletonServiceProvider
     }
 
     private ClusterSingletonServiceGroup createGroup(final String serviceIdentifier,
-            final List<ClusterSingletonServiceRegistration> services) {
+            final List<ServiceRegistration> services) {
         return new ClusterSingletonServiceGroupImpl(serviceIdentifier, entityOwnershipService,
             createEntity(SERVICE_ENTITY_TYPE, serviceIdentifier),
             createEntity(CLOSE_SERVICE_ENTITY_TYPE, serviceIdentifier), services);
@@ -155,7 +153,7 @@ public final class EOSClusterSingletonServiceProvider
         }
     }
 
-    private void removeRegistration(final String serviceIdentifier, final ClusterSingletonServiceRegistration reg) {
+    private void removeRegistration(final String serviceIdentifier, final ServiceRegistration reg) {
         final PlaceholderGroup placeHolder;
         final ListenableFuture<?> future;
         synchronized (this) {
index 62405014d2a9d7a7e2ac53c619baeeed19dfce87..a06beb320b082cde1b419bfa1f548c2ae638d2a5 100644 (file)
@@ -18,7 +18,6 @@ import java.util.List;
 import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
 import org.opendaylight.mdsal.eos.common.api.EntityOwnershipStateChange;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -30,7 +29,7 @@ import org.slf4j.LoggerFactory;
 final class PlaceholderGroup extends ClusterSingletonServiceGroup {
     private static final Logger LOG = LoggerFactory.getLogger(PlaceholderGroup.class);
 
-    private final List<ClusterSingletonServiceRegistration> services = new ArrayList<>(0);
+    private final List<ServiceRegistration> services = new ArrayList<>(0);
     private final ClusterSingletonServiceGroup previous;
     private final ListenableFuture<?> closeFuture;
 
@@ -52,14 +51,14 @@ final class PlaceholderGroup extends ClusterSingletonServiceGroup {
     }
 
     @Override
-    void registerService(final ClusterSingletonServiceRegistration reg) {
+    void registerService(final ServiceRegistration reg) {
         verifyNoSuccessor();
         services.add(reg);
         LOG.debug("{}: added service {}", this, reg.getInstance());
     }
 
     @Override
-    ListenableFuture<?> unregisterService(final ClusterSingletonServiceRegistration reg) {
+    ListenableFuture<?> unregisterService(final ServiceRegistration reg) {
         verifyNoSuccessor();
         services.remove(reg);
         LOG.debug("{}: removed service {}", this, reg.getInstance());
@@ -80,7 +79,7 @@ final class PlaceholderGroup extends ClusterSingletonServiceGroup {
     }
 
     // Note: this is a leaked structure, the caller can reuse it at will, but has to regard
-    List<ClusterSingletonServiceRegistration> getServices() {
+    List<ServiceRegistration> getServices() {
         verifyNoSuccessor();
         LOG.trace("{}: returning services {}", this, services);
         return services;
@@ -8,13 +8,10 @@
 package org.opendaylight.mdsal.singleton.dom.impl;
 
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
 
-abstract class AbstractClusterSingletonServiceRegistration extends AbstractObjectRegistration<ClusterSingletonService>
-    implements ClusterSingletonServiceRegistration {
-
-    AbstractClusterSingletonServiceRegistration(final ClusterSingletonService instance) {
+abstract class ServiceRegistration extends AbstractObjectRegistration<ClusterSingletonService> {
+    ServiceRegistration(final ClusterSingletonService instance) {
         super(instance);
     }
 }
index 0218a69686925704e422fccfade1980eb052df4c..2d957ea4c49a1958ed35c268a385e982fdc1409e 100644 (file)
@@ -34,7 +34,6 @@ import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException
 import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
 import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
 import org.opendaylight.yangtools.concepts.Registration;
 
@@ -369,14 +368,13 @@ abstract class AbstractEOSClusterSingletonServiceProviderTest {
         assertEquals(TestClusterSingletonServiceState.INITIALIZED, clusterSingletonService.getServiceState());
         clusterSingletonServiceProvider.ownershipChanged(DOUBLE_ENTITY, LOCAL_OWNERSHIP_GRANTED, false);
         assertEquals(TestClusterSingletonServiceState.STARTED, clusterSingletonService.getServiceState());
-        final ClusterSingletonServiceRegistration reg2 = clusterSingletonServiceProvider
-                .registerClusterSingletonService(clusterSingletonService2);
+        final var reg2 = clusterSingletonServiceProvider.registerClusterSingletonService(clusterSingletonService2);
         assertNotNull(reg2);
         assertEquals(TestClusterSingletonServiceState.STARTED, clusterSingletonService2.getServiceState());
     }
 
     /**
-     * Test checks close processing for {@link ClusterSingletonServiceRegistration}.
+     * Test checks close processing for {@link ServiceRegistration}.
      */
     @Test
     public void closeClusterSingletonServiceRegistrationNoRoleTest() throws Exception {
@@ -393,7 +391,7 @@ abstract class AbstractEOSClusterSingletonServiceProviderTest {
     }
 
     /**
-     * Test checks close processing for {@link ClusterSingletonServiceRegistration}.
+     * Test checks close processing for {@link ServiceRegistration}.
      */
     @Test
     public void closeClusterSingletonServiceRegistrationNoRoleTwoServicesTest() throws Exception {
@@ -414,7 +412,7 @@ abstract class AbstractEOSClusterSingletonServiceProviderTest {
     }
 
     /**
-     * Test checks close processing for {@link ClusterSingletonServiceRegistration}.
+     * Test checks close processing for {@link ServiceRegistration}.
      */
     @Test
     public void closeClusterSingletonServiceRegistrationSlaveTest() throws Exception {
@@ -432,7 +430,7 @@ abstract class AbstractEOSClusterSingletonServiceProviderTest {
     }
 
     /**
-     * Test checks close processing for {@link ClusterSingletonServiceRegistration}.
+     * Test checks close processing for {@link ServiceRegistration}.
      */
     @Test
     public void closeClusterSingletonServiceRegistrationSlaveTwoServicesTest() throws Exception {
@@ -454,7 +452,7 @@ abstract class AbstractEOSClusterSingletonServiceProviderTest {
     }
 
     /**
-     * Test checks close processing for {@link ClusterSingletonServiceRegistration}.
+     * Test checks close processing for {@link ServiceRegistration}.
      */
     @Test
     public void closeClusterSingletonServiceRegistrationMasterTwoServicesTest() throws Exception {
index b0a6324cccd7cd3bbf6b8515822b0be0df3f8fd8..871ca7c9c65ba0db1a6b40cda4865a6137a96100 100644 (file)
@@ -26,7 +26,6 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
 
 /*
  * Testing {@link DOMClusterSingletonServiceProviderImpl} implementation
@@ -77,8 +76,7 @@ public final class AsyncEOSClusterSingletonServiceProviderTest extends AbstractE
      */
     @Test
     public void takeDoubleLeadershipClusterSingletonServiceTest() throws Exception {
-        final ClusterSingletonServiceRegistration reg = clusterSingletonServiceProvider
-                .registerClusterSingletonService(clusterSingletonService);
+        final var reg = clusterSingletonServiceProvider.registerClusterSingletonService(clusterSingletonService);
         assertNotNull(reg);
         verify(mockEos).registerCandidate(ENTITY);
         clusterSingletonServiceProvider.ownershipChanged(ENTITY, LOCAL_OWNERSHIP_GRANTED, false);
@@ -107,8 +105,7 @@ public final class AsyncEOSClusterSingletonServiceProviderTest extends AbstractE
      */
     @Test
     public void unexpectedLostLeadershipDoubleCandidateTest() throws Exception {
-        final ClusterSingletonServiceRegistration reg = clusterSingletonServiceProvider
-                .registerClusterSingletonService(clusterSingletonService);
+        final var reg = clusterSingletonServiceProvider.registerClusterSingletonService(clusterSingletonService);
         assertNotNull(reg);
         verify(mockEos).registerCandidate(ENTITY);
         clusterSingletonServiceProvider.ownershipChanged(ENTITY, LOCAL_OWNERSHIP_GRANTED, false);
@@ -137,8 +134,7 @@ public final class AsyncEOSClusterSingletonServiceProviderTest extends AbstractE
      */
     @Test
     public void inJeopardyMasterTest() throws Exception {
-        final ClusterSingletonServiceRegistration reg = clusterSingletonServiceProvider
-                .registerClusterSingletonService(clusterSingletonService);
+        final var reg = clusterSingletonServiceProvider.registerClusterSingletonService(clusterSingletonService);
         assertNotNull(reg);
         verify(mockEos).registerCandidate(ENTITY);
         clusterSingletonServiceProvider.ownershipChanged(ENTITY, LOCAL_OWNERSHIP_GRANTED, false);
@@ -160,14 +156,13 @@ public final class AsyncEOSClusterSingletonServiceProviderTest extends AbstractE
     }
 
     /**
-     * Test checks close processing for {@link ClusterSingletonServiceRegistration}.
+     * Test checks close processing for {@link ServiceRegistration}.
      *
      * @throws Exception if the condition does not meet
      */
     @Test
     public void closeClusterSingletonServiceRegistrationMasterTest() throws Exception {
-        final ClusterSingletonServiceRegistration reg = clusterSingletonServiceProvider
-                .registerClusterSingletonService(clusterSingletonService);
+        final var reg = clusterSingletonServiceProvider.registerClusterSingletonService(clusterSingletonService);
         assertNotNull(reg);
         assertEquals(TestClusterSingletonServiceState.INITIALIZED, clusterSingletonService.getServiceState());
         verify(mockEos).registerCandidate(ENTITY);
@@ -186,14 +181,13 @@ public final class AsyncEOSClusterSingletonServiceProviderTest extends AbstractE
     }
 
     /**
-     * Test checks close processing for {@link ClusterSingletonServiceRegistration}.
+     * Test checks close processing for {@link ServiceRegistration}.
      *
      * @throws Exception if the condition does not meet
      */
     @Test
     public void closeClusterSingletonServiceRegistrationMasterCloseWithNotificationTimesTest() throws Exception {
-        final ClusterSingletonServiceRegistration reg = clusterSingletonServiceProvider
-                .registerClusterSingletonService(clusterSingletonService);
+        final var reg = clusterSingletonServiceProvider.registerClusterSingletonService(clusterSingletonService);
         assertNotNull(reg);
         assertEquals(TestClusterSingletonServiceState.INITIALIZED, clusterSingletonService.getServiceState());
         verify(mockEos).registerCandidate(ENTITY);
@@ -212,14 +206,13 @@ public final class AsyncEOSClusterSingletonServiceProviderTest extends AbstractE
     }
 
     /**
-     * Test checks close processing for {@link ClusterSingletonServiceRegistration}.
+     * Test checks close processing for {@link ServiceRegistration}.
      *
      * @throws Exception if the condition does not meet
      */
     @Test
     public void closeClusterSingletonServiceRegistrationMasterCloseCoupleTimesTest() throws Exception {
-        final ClusterSingletonServiceRegistration reg = clusterSingletonServiceProvider
-                .registerClusterSingletonService(clusterSingletonService);
+        final var reg = clusterSingletonServiceProvider.registerClusterSingletonService(clusterSingletonService);
         assertNotNull(reg);
         assertEquals(TestClusterSingletonServiceState.INITIALIZED, clusterSingletonService.getServiceState());
         verify(mockEos).registerCandidate(ENTITY);
index 31c0e2bdd7204fbf85e7fdb7196dd0e8468b9ebd..b581188cb1f60d86292f791c7284173c3ccde90d 100644 (file)
@@ -38,7 +38,6 @@ import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
 import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
 import org.opendaylight.yangtools.concepts.Registration;
 
@@ -68,8 +67,8 @@ public class ClusterSingletonServiceGroupImplTest {
 
     public ClusterSingletonServiceGroupImpl singletonServiceGroup;
 
-    public ClusterSingletonServiceRegistration firstReg;
-    public ClusterSingletonServiceRegistration secondReg;
+    public ServiceRegistration firstReg;
+    public ServiceRegistration secondReg;
 
     /**
      * Initialization functionality for every Tests in this suite.
@@ -88,13 +87,13 @@ public class ClusterSingletonServiceGroupImplTest {
         doReturn(SERVICE_GROUP_IDENT).when(mockClusterSingletonService).getIdentifier();
         doReturn(SERVICE_GROUP_IDENT).when(mockClusterSingletonServiceSecond).getIdentifier();
 
-        firstReg = new AbstractClusterSingletonServiceRegistration(mockClusterSingletonService) {
+        firstReg = new ServiceRegistration(mockClusterSingletonService) {
             @Override
             protected void removeRegistration() {
                 // No-op
             }
         };
-        secondReg = new AbstractClusterSingletonServiceRegistration(mockClusterSingletonServiceSecond) {
+        secondReg = new ServiceRegistration(mockClusterSingletonServiceSecond) {
             @Override
             protected void removeRegistration() {
                 // No-op
@@ -420,7 +419,7 @@ public class ClusterSingletonServiceGroupImplTest {
     }
 
     /**
-     * Test checks closing processing for close {@link ClusterSingletonServiceRegistration}.
+     * Test checks closing processing for close {@link ServiceRegistration}.
      *
      * @throws CandidateAlreadyRegisteredException - unexpected exception
      */
index 87a66ecaa8beafec1b4782724c02e35dac9937ef..1a5d7abc784a771de1dcd7c68c7121d882c81e4e 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.mdsal.singleton.dom.impl;
 
 import static org.junit.Assert.assertEquals;
@@ -23,7 +22,6 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
 
 /**
  * Synchronous test suite.
@@ -37,8 +35,7 @@ public class SyncEOSClusterSingletonServiceProviderTest extends AbstractEOSClust
      */
     @Test
     public void takeDoubleLeadershipClusterSingletonServiceTest() throws Exception {
-        final ClusterSingletonServiceRegistration reg = clusterSingletonServiceProvider
-                .registerClusterSingletonService(clusterSingletonService);
+        final var reg = clusterSingletonServiceProvider.registerClusterSingletonService(clusterSingletonService);
         assertNotNull(reg);
         verify(mockEos).registerCandidate(ENTITY);
         clusterSingletonServiceProvider.ownershipChanged(ENTITY, LOCAL_OWNERSHIP_GRANTED, false);
@@ -66,8 +63,7 @@ public class SyncEOSClusterSingletonServiceProviderTest extends AbstractEOSClust
      */
     @Test
     public void unexpectedLostLeadershipDoubleCandidateTest() throws Exception {
-        final ClusterSingletonServiceRegistration reg = clusterSingletonServiceProvider
-                .registerClusterSingletonService(clusterSingletonService);
+        final var reg = clusterSingletonServiceProvider.registerClusterSingletonService(clusterSingletonService);
         assertNotNull(reg);
         verify(mockEos).registerCandidate(ENTITY);
         clusterSingletonServiceProvider.ownershipChanged(ENTITY, LOCAL_OWNERSHIP_GRANTED, false);
@@ -100,8 +96,7 @@ public class SyncEOSClusterSingletonServiceProviderTest extends AbstractEOSClust
      */
     @Test
     public void inJeopardyMasterTest() throws Exception {
-        final ClusterSingletonServiceRegistration reg = clusterSingletonServiceProvider
-                .registerClusterSingletonService(clusterSingletonService);
+        final var reg = clusterSingletonServiceProvider.registerClusterSingletonService(clusterSingletonService);
         assertNotNull(reg);
         verify(mockEos).registerCandidate(ENTITY);
         clusterSingletonServiceProvider.ownershipChanged(ENTITY, LOCAL_OWNERSHIP_GRANTED, false);
@@ -120,14 +115,13 @@ public class SyncEOSClusterSingletonServiceProviderTest extends AbstractEOSClust
     }
 
     /**
-     * Test checks close processing for {@link ClusterSingletonServiceRegistration}.
+     * Test checks close processing for {@link ServiceRegistration}.
      *
      * @throws Exception if the condition does not meet
      */
     @Test
     public void closeClusterSingletonServiceRegistrationMasterTest() throws Exception {
-        final ClusterSingletonServiceRegistration reg = clusterSingletonServiceProvider
-                .registerClusterSingletonService(clusterSingletonService);
+        final var reg = clusterSingletonServiceProvider.registerClusterSingletonService(clusterSingletonService);
         assertNotNull(reg);
         assertEquals(TestClusterSingletonServiceState.INITIALIZED, clusterSingletonService.getServiceState());
         verify(mockEos).registerCandidate(ENTITY);
@@ -145,14 +139,13 @@ public class SyncEOSClusterSingletonServiceProviderTest extends AbstractEOSClust
     }
 
     /**
-     * Test checks close processing for {@link ClusterSingletonServiceRegistration}.
+     * Test checks close processing for {@link ServiceRegistration}.
      *
      * @throws Exception if the condition does not meet
      */
     @Test
     public void closeClusterSingletonServiceRegistrationMasterCloseWithNotificationTimesTest() throws Exception {
-        final ClusterSingletonServiceRegistration reg = clusterSingletonServiceProvider
-                .registerClusterSingletonService(clusterSingletonService);
+        final var reg = clusterSingletonServiceProvider.registerClusterSingletonService(clusterSingletonService);
         assertNotNull(reg);
         assertEquals(TestClusterSingletonServiceState.INITIALIZED, clusterSingletonService.getServiceState());
         verify(mockEos).registerCandidate(ENTITY);
@@ -169,14 +162,13 @@ public class SyncEOSClusterSingletonServiceProviderTest extends AbstractEOSClust
     }
 
     /**
-     * Test checks close processing for {@link ClusterSingletonServiceRegistration}.
+     * Test checks close processing for {@link ServiceRegistration}.
      *
      * @throws Exception if the condition does not meet
      */
     @Test
     public void closeClusterSingletonServiceRegistrationMasterCloseCoupleTimesTest() throws Exception {
-        final ClusterSingletonServiceRegistration reg = clusterSingletonServiceProvider
-                .registerClusterSingletonService(clusterSingletonService);
+        final var reg = clusterSingletonServiceProvider.registerClusterSingletonService(clusterSingletonService);
         assertNotNull(reg);
         assertEquals(TestClusterSingletonServiceState.INITIALIZED, clusterSingletonService.getServiceState());
         verify(mockEos).registerCandidate(ENTITY);
@@ -201,8 +193,7 @@ public class SyncEOSClusterSingletonServiceProviderTest extends AbstractEOSClust
      */
     @Test
     public void testTwoIncarnations() throws Exception {
-        ClusterSingletonServiceRegistration reg = clusterSingletonServiceProvider
-                .registerClusterSingletonService(clusterSingletonService);
+        var reg = clusterSingletonServiceProvider.registerClusterSingletonService(clusterSingletonService);
         assertNotNull(reg);
         assertEquals(TestClusterSingletonServiceState.INITIALIZED, clusterSingletonService.getServiceState());
         verify(mockEos).registerCandidate(ENTITY);