From a5458da5eb1fa27c052ff93dee8b39e69aa0ca4d Mon Sep 17 00:00:00 2001 From: Lorand Jakab Date: Sun, 7 Aug 2016 22:53:45 -0500 Subject: [PATCH] Revert "Clustering - common infrastructure." This reverts commit 9493583244a2b9b5583e2ca9ac11ff73bb4ad1d3. Change-Id: I8d87010928504c3d91825c19348ac4d330065851 Signed-off-by: Lorand Jakab --- features/pom.xml | 5 - features/src/main/features/features.xml | 2 - mappingservice/clustering/pom.xml | 66 ------------- .../ClusterNodeModulSwitcherImpl.java | 85 ----------------- .../api/ClusterNodeModuleSwitcher.java | 20 ---- .../clustering/util/ClusteringUtil.java | 20 ---- .../ClusterNodeModulSwitcherImplTest.java | 92 ------------------- .../mdsal/AbstractDataListener.java | 3 +- mappingservice/pom.xml | 1 - .../lisp/AuthenticationKeyDataListener.java | 3 +- 10 files changed, 2 insertions(+), 295 deletions(-) delete mode 100644 mappingservice/clustering/pom.xml delete mode 100644 mappingservice/clustering/src/main/java/org/opendaylight/lispflowmapping/clustering/ClusterNodeModulSwitcherImpl.java delete mode 100644 mappingservice/clustering/src/main/java/org/opendaylight/lispflowmapping/clustering/api/ClusterNodeModuleSwitcher.java delete mode 100644 mappingservice/clustering/src/main/java/org/opendaylight/lispflowmapping/clustering/util/ClusteringUtil.java delete mode 100644 mappingservice/clustering/src/main/test/org/opendaylight/lispflowmapping/clustering/ClusterNodeModulSwitcherImplTest.java diff --git a/features/pom.xml b/features/pom.xml index f0a31d5ac..9b7afcf71 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -89,11 +89,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html xml runtime - - ${project.groupId} - mappingservice.clustering - ${project.version} - ${project.groupId} mappingservice.dsbackend diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index 0cfbbfde1..314fc6e78 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -31,7 +31,6 @@ odl-mdsal-broker odl-lispflowmapping-models odl-lispflowmapping-inmemorydb - mvn:org.opendaylight.lispflowmapping/mappingservice.clustering/{{VERSION}} mvn:org.opendaylight.lispflowmapping/mappingservice.dsbackend/{{VERSION}} mvn:org.opendaylight.lispflowmapping/mappingservice.mapcache/{{VERSION}} mvn:org.opendaylight.lispflowmapping/mappingservice.implementation/{{VERSION}} @@ -53,7 +52,6 @@ odl-mdsal-broker odl-lispflowmapping-models odl-lispflowmapping-inmemorydb - mvn:org.opendaylight.lispflowmapping/mappingservice.clustering/{{VERSION}} mvn:org.opendaylight.lispflowmapping/mappingservice.dsbackend/{{VERSION}} mvn:org.opendaylight.lispflowmapping/mappingservice.mapcache/{{VERSION}} mvn:org.opendaylight.lispflowmapping/mappingservice.southbound/{{VERSION}} diff --git a/mappingservice/clustering/pom.xml b/mappingservice/clustering/pom.xml deleted file mode 100644 index 5f0ecff25..000000000 --- a/mappingservice/clustering/pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - 4.0.0 - - - org.opendaylight.lispflowmapping - mappingservice-parent - 1.4.0-SNAPSHOT - - - mappingservice.clustering - bundle - Mapping Service Clustering - - - - org.slf4j - slf4j-api - - - org.opendaylight.controller - sal-common-api - 1.4.0-SNAPSHOT - - - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - true - checkstyle.violationSeverity=error - - - - - - - - ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ - - - - opendaylight-site - ${nexus.site.url}/${project.artifactId}/ - - - diff --git a/mappingservice/clustering/src/main/java/org/opendaylight/lispflowmapping/clustering/ClusterNodeModulSwitcherImpl.java b/mappingservice/clustering/src/main/java/org/opendaylight/lispflowmapping/clustering/ClusterNodeModulSwitcherImpl.java deleted file mode 100644 index c3b806887..000000000 --- a/mappingservice/clustering/src/main/java/org/opendaylight/lispflowmapping/clustering/ClusterNodeModulSwitcherImpl.java +++ /dev/null @@ -1,85 +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.lispflowmapping.clustering; - -import static org.opendaylight.lispflowmapping.clustering.util.ClusteringUtil.LISPFLOWMAPPING_ENTITY_NAME; -import static org.opendaylight.lispflowmapping.clustering.util.ClusteringUtil.LISPFLOWMAPPING_ENTITY_TYPE; - -import com.google.common.base.Optional; -import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException; -import org.opendaylight.controller.md.sal.common.api.clustering.Entity; -import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipChange; -import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener; -import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService; -import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState; -import org.opendaylight.lispflowmapping.clustering.api.ClusterNodeModuleSwitcher; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Class responsible for turning on|off module in node cluster. - */ -public class ClusterNodeModulSwitcherImpl implements EntityOwnershipListener { - - private static final Logger LOG = LoggerFactory.getLogger(ClusterNodeModulSwitcherImpl.class); - private final EntityOwnershipService entityOwnershipService; - private final Entity entity; - private boolean moduleIsRunning = true; - private ClusterNodeModuleSwitcher module; - - public ClusterNodeModulSwitcherImpl(final EntityOwnershipService entityOwnershipService) { - this.entityOwnershipService = entityOwnershipService; - this.entityOwnershipService.registerListener(LISPFLOWMAPPING_ENTITY_NAME, this); - entity = new Entity(LISPFLOWMAPPING_ENTITY_NAME, LISPFLOWMAPPING_ENTITY_TYPE); - try { - this.entityOwnershipService.registerCandidate(entity); - } catch (CandidateAlreadyRegisteredException e) { - LOG.debug("Candidate already registered. Trace: {}", e); - } - } - - @Override - public void ownershipChanged(final EntityOwnershipChange entityOwnershipChange) { - LOG.debug("Entity ownership change message received."); - switchModuleState(entityOwnershipChange.isOwner()); - } - - public void switchModuleByEntityOwnership() { - switchModuleState(isMaster()); - } - - private void switchModuleState(final boolean isOwner) { - if (module != null) { - if (!isOwner && moduleIsRunning) { - module.stopModule(); - moduleIsRunning = false; - LOG.debug("Module {} was stopped.", module.getClass().getName()); - } else if (isOwner && !moduleIsRunning) { - module.startModule(); - moduleIsRunning = true; - LOG.debug("Module {} was restarted.", module.getClass().getName()); - } - } else { - LOG.debug("Module wasn't initialized yet."); - } - } - - public boolean isMaster() { - final Optional ownershipState = entityOwnershipService.getOwnershipState(entity); - if (ownershipState.isPresent()) { - return ownershipState.get().isOwner(); - } else { - LOG.debug("Ownership state information wasn't present in entity ownership service."); - } - return false; - } - - public void setModule(final ClusterNodeModuleSwitcher module) { - this.module = module; - } -} diff --git a/mappingservice/clustering/src/main/java/org/opendaylight/lispflowmapping/clustering/api/ClusterNodeModuleSwitcher.java b/mappingservice/clustering/src/main/java/org/opendaylight/lispflowmapping/clustering/api/ClusterNodeModuleSwitcher.java deleted file mode 100644 index 0d20ffef0..000000000 --- a/mappingservice/clustering/src/main/java/org/opendaylight/lispflowmapping/clustering/api/ClusterNodeModuleSwitcher.java +++ /dev/null @@ -1,20 +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.lispflowmapping.clustering.api; - -/** - * Interface specify operations necessary to turn on|off module in node cluster. - */ -public interface ClusterNodeModuleSwitcher { - - void startModule(); - - void stopModule(); - -} diff --git a/mappingservice/clustering/src/main/java/org/opendaylight/lispflowmapping/clustering/util/ClusteringUtil.java b/mappingservice/clustering/src/main/java/org/opendaylight/lispflowmapping/clustering/util/ClusteringUtil.java deleted file mode 100644 index 0031252c9..000000000 --- a/mappingservice/clustering/src/main/java/org/opendaylight/lispflowmapping/clustering/util/ClusteringUtil.java +++ /dev/null @@ -1,20 +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.lispflowmapping.clustering.util; - -public final class ClusteringUtil { - - public static final String LISPFLOWMAPPING_ENTITY_NAME = "lispflowmapping"; - public static final String LISPFLOWMAPPING_ENTITY_TYPE = "application"; - - private ClusteringUtil() { - throw new UnsupportedOperationException(); - } - -} diff --git a/mappingservice/clustering/src/main/test/org/opendaylight/lispflowmapping/clustering/ClusterNodeModulSwitcherImplTest.java b/mappingservice/clustering/src/main/test/org/opendaylight/lispflowmapping/clustering/ClusterNodeModulSwitcherImplTest.java deleted file mode 100644 index c8d39fb96..000000000 --- a/mappingservice/clustering/src/main/test/org/opendaylight/lispflowmapping/clustering/ClusterNodeModulSwitcherImplTest.java +++ /dev/null @@ -1,92 +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.lispflowmapping.clustering; - -import static org.opendaylight.lispflowmapping.clustering.util.ClusteringUtil.LISPFLOWMAPPING_ENTITY_NAME; -import static org.opendaylight.lispflowmapping.clustering.util.ClusteringUtil.LISPFLOWMAPPING_ENTITY_TYPE; - -import com.google.common.base.Optional; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Matchers; -import org.mockito.Mockito; -import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException; -import org.opendaylight.controller.md.sal.common.api.clustering.Entity; -import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipChange; -import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService; -import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState; -import org.opendaylight.lispflowmapping.clustering.api.ClusterNodeModuleSwitcher; - -public class ClusterNodeModulSwitcherImplTest { - - private EntityOwnershipService entityOwnershipServiceMocked; - private ClusterNodeModulSwitcherImpl clusterNodeModulSwitcherImpl; - private ClusterNodeModuleSwitcher module; - private Entity entity = new Entity(LISPFLOWMAPPING_ENTITY_NAME, LISPFLOWMAPPING_ENTITY_TYPE); - - @Before - public void init() { - entityOwnershipServiceMocked = Mockito.mock(EntityOwnershipService.class); - clusterNodeModulSwitcherImpl = new ClusterNodeModulSwitcherImpl(entityOwnershipServiceMocked); - module = Mockito.mock(ClusterNodeModuleSwitcher.class); - } - - @Test - public void constructorCallTest() throws CandidateAlreadyRegisteredException { - Mockito.verify(entityOwnershipServiceMocked).registerListener(Matchers.eq(LISPFLOWMAPPING_ENTITY_NAME), - Matchers.any(ClusterNodeModulSwitcherImpl.class)); - Mockito.verify(entityOwnershipServiceMocked).registerCandidate(Matchers.eq(entity)); - } - - @Test - public void ownershipChangedTest() { - //is not owner - ownershipChanged(false); - Mockito.verify(module).stopModule(); - //is owner - ownershipChanged(true); - Mockito.verify(module).startModule(); - } - - @Test - public void isMasterTest_OptionalAbsent() { - Mockito.when(entityOwnershipServiceMocked.getOwnershipState(Matchers.eq(entity))).thenReturn(Optional - .absent - ()); - Assert.assertFalse(clusterNodeModulSwitcherImpl.isMaster()); - } - - @Test - public void isMasterTest_True() { - Mockito.when(entityOwnershipServiceMocked.getOwnershipState(Matchers.eq(entity))).thenReturn(Optional - .of(new EntityOwnershipState(true, true))); - Assert.assertTrue(clusterNodeModulSwitcherImpl.isMaster()); - } - - @Test - public void isMasterTest_False() { - Mockito.when(entityOwnershipServiceMocked.getOwnershipState(Matchers.eq(entity))).thenReturn(Optional - .of(new EntityOwnershipState(false, true))); - Assert.assertFalse(clusterNodeModulSwitcherImpl.isMaster()); - } - - @Test - public void switchModuleByEntityOwnershipTest() { - Mockito.when(entityOwnershipServiceMocked.getOwnershipState(Matchers.eq(entity))).thenReturn(Optional - .of(new EntityOwnershipState(false, true))); - clusterNodeModulSwitcherImpl.switchModuleByEntityOwnership(); - } - - private void ownershipChanged(boolean isOwner) { - final EntityOwnershipChange entityOwnershipChangeMock = Mockito.mock(EntityOwnershipChange.class); - clusterNodeModulSwitcherImpl.setModule(module); - Mockito.when(entityOwnershipChangeMock.isOwner()).thenReturn(isOwner); - clusterNodeModulSwitcherImpl.ownershipChanged(entityOwnershipChangeMock); - } -} diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/mdsal/AbstractDataListener.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/mdsal/AbstractDataListener.java index 39e319e3e..97ac5550e 100644 --- a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/mdsal/AbstractDataListener.java +++ b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/mdsal/AbstractDataListener.java @@ -7,7 +7,6 @@ */ package org.opendaylight.lispflowmapping.implementation.mdsal; -import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; @@ -20,7 +19,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; * The superclass for the different MD-SAL data change event listeners. * */ -public abstract class AbstractDataListener implements ClusteredDataTreeChangeListener { +public abstract class AbstractDataListener implements DataTreeChangeListener { private DataBroker broker; private InstanceIdentifier path; private ListenerRegistration> registration; diff --git a/mappingservice/pom.xml b/mappingservice/pom.xml index a1d1346cf..10fdd7e83 100644 --- a/mappingservice/pom.xml +++ b/mappingservice/pom.xml @@ -22,7 +22,6 @@ lisp-proto api - clustering inmemorydb dsbackend mapcache diff --git a/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/lisp/AuthenticationKeyDataListener.java b/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/lisp/AuthenticationKeyDataListener.java index 9496005b1..d66ed11ca 100644 --- a/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/lisp/AuthenticationKeyDataListener.java +++ b/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/lisp/AuthenticationKeyDataListener.java @@ -9,7 +9,6 @@ package org.opendaylight.lispflowmapping.southbound.lisp; import java.util.Collection; -import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType; @@ -33,7 +32,7 @@ import org.slf4j.LoggerFactory; * DataListener for all AuthenticationKey modification events. * */ -public class AuthenticationKeyDataListener implements ClusteredDataTreeChangeListener { +public class AuthenticationKeyDataListener implements DataTreeChangeListener { private static final Logger LOG = LoggerFactory.getLogger(AuthenticationKeyDataListener.class); private final SimpleMapCache smc; -- 2.36.6