Merge "BUG:5888 - Changing FRM from clustered DCN to clustered DTCN"
authorAnil Vishnoi <vishnoianil@gmail.com>
Wed, 8 Jun 2016 06:33:56 +0000 (06:33 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 8 Jun 2016 06:33:56 +0000 (06:33 +0000)
65 files changed:
applications/forwardingrules-manager-config/src/main/resources/initial/30-forwardingrules-manager.xml
applications/forwardingrules-manager/pom.xml
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/forwardingrules_manager/ForwardingRulesManagerModule.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/config/yang/forwardingrules_manager/ForwardingRulesManagerModuleFactory.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesManager.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerConfig.java [deleted file]
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java
applications/forwardingrules-manager/src/main/resources/org/opendaylight/blueprint/forwardingrules-manager.xml [new file with mode: 0644]
applications/forwardingrules-manager/src/main/yang/forwarding-manager.yang
applications/forwardingrules-manager/src/main/yang/forwardingrules-manager-config.yang [new file with mode: 0644]
applications/forwardingrules-manager/src/test/java/test/mock/FlowListenerTest.java
applications/forwardingrules-manager/src/test/java/test/mock/util/FRMTest.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/NodeListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/SyncReactor.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeCachedDao.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeDao.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeOdlDao.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeSnapshotDao.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/AbstractFrmSyncListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/FlowForwarder.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/ForwardingRulesSyncProvider.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/FrmExecutors.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/MeterForwarder.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedConfigListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureDecorator.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureWithCompressionDecorator.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/TableForwarder.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowCapableNodeLookups.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/SemaphoreKeeperGuavaImpl.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/FlowForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/ForwardingRulesSyncProviderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/GroupForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/MeterForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedConfigListenerTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListenerTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecoratorTest.java [new file with mode: 0644]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/TableForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/DiffInputFactory.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImplTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtilTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/SemaphoreKeeperTest.java
applications/topology-lldp-discovery/src/main/config/default-config.xml
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPActivator.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryListener.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryProvider.java [deleted file]
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/utils/LLDPDiscoveryUtils.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/lldp/discovery/impl/rev150530/TopologyLldpDiscoveryImplModule.java
applications/topology-lldp-discovery/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/lldp/discovery/impl/rev150530/TopologyLldpDiscoveryImplModuleFactory.java
applications/topology-lldp-discovery/src/main/resources/org/opendaylight/blueprint/topology-lldp-discovery.xml [new file with mode: 0644]
applications/topology-lldp-discovery/src/main/yang/topology-lldp-discovery-config.yang [new file with mode: 0644]
applications/topology-lldp-discovery/src/main/yang/topology-lldp-discovery-impl.yang
applications/topology-manager/src/main/config/default-config.xml
applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyProvider.java
applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/OperationProcessor.java
applications/topology-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/manager/impl/rev150530/TopologyLldpDiscoveryImplModule.java
applications/topology-manager/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/topology/manager/impl/rev150530/TopologyLldpDiscoveryImplModuleFactory.java
applications/topology-manager/src/main/resources/org/opendaylight/blueprint/topology-manager.xml [new file with mode: 0644]
applications/topology-manager/src/main/yang/topology-manager-impl.yang
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedV10Translator.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslatorTest.java

index 450ec70fc4d99f18b3938890c4cc44a069c28422..faebaf467170c2b5e1e84db2cc3ee4066a155b14 100644 (file)
@@ -6,6 +6,9 @@
  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
+
+ NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for
+       backwards compatibility. Runtime modifications are not honored.
 -->
 <snapshot>
     <configuration>
index d5ad08f08fd16471ad8b8e9143e4afd39280ad57..f10ac94bc8dbd99c7a5c61b04ff5ca91ed346dcf 100644 (file)
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>config-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-common-util</artifactId>
+    </dependency>
 
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index d92645a21a48b4120b0d7085d89c61292fc7252d..65da14cffe1050a23a07a2a31daddd3f3a24f270 100644 (file)
@@ -8,16 +8,13 @@
 
 package org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager;
 
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerConfig;
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
 
-public class ForwardingRulesManagerModule extends org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager.AbstractForwardingRulesManagerModule {
-
-    private static final Logger LOG = LoggerFactory.getLogger(ForwardingRulesManagerModule.class);
-    private static final boolean ENABLE_FGM_STALE_MARKING = false;
-    private static final int RECONCILIATION_RETRY_COUNT = 5;
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class ForwardingRulesManagerModule extends AbstractForwardingRulesManagerModule {
 
     public ForwardingRulesManagerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
@@ -28,56 +25,8 @@ public class ForwardingRulesManagerModule extends org.opendaylight.openflowplugi
     }
 
     @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        LOG.info("FRM module initialization.");
-        final ForwardingRulesManagerConfig config = readConfig();
-        final ForwardingRulesManagerImpl forwardingrulessManagerProvider =
-                new ForwardingRulesManagerImpl(getDataBrokerDependency(), getRpcRegistryDependency(), config, getEntityOwnershipServiceDependency());
-        forwardingrulessManagerProvider.start();
-        LOG.info("FRM module started successfully.");
-        return new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-                try {
-                    forwardingrulessManagerProvider.close();
-                } catch (final Exception e) {
-                    LOG.warn("Unexpected error by stopping FRM", e);
-                }
-                LOG.info("FRM module stopped.");
-            }
-        };
-    }
-
-    private ForwardingRulesManagerConfig readConfig(){
-
-        final ForwardingRulesManagerConfig.ForwardingRulesManagerConfigBuilder fwdRulesMgrCfgBuilder = ForwardingRulesManagerConfig.builder();
-
-        if (getForwardingManagerSettings() != null && getForwardingManagerSettings().getStaleMarkingEnabled() != null){
-            fwdRulesMgrCfgBuilder.setStaleMarkingEnabled(getForwardingManagerSettings().getStaleMarkingEnabled());
-        }
-        else{
-            LOG.warn("Could not load XML configuration file via ConfigSubsystem! Fallback to default config value(s)");
-            fwdRulesMgrCfgBuilder.setStaleMarkingEnabled(ENABLE_FGM_STALE_MARKING);
-        }
-
-       if(getForwardingManagerSettings() != null && getForwardingManagerSettings().getReconciliationRetryCount()>0){
-                   fwdRulesMgrCfgBuilder.setReconciliationRetryCount(getForwardingManagerSettings().getReconciliationRetryCount());
-       }
-       else{
-             LOG.warn("Could not load XML configuration file via ConfigSubsystem for reconciliation retry! " +
-             "Fallback to default config value(s)");
-             fwdRulesMgrCfgBuilder.setReconciliationRetryCount(RECONCILIATION_RETRY_COUNT);
-            }
-
-
-
-        return fwdRulesMgrCfgBuilder.build();
-
+    public AutoCloseable createInstance() {
+        // FRM instance is created via blueprint so this in a no-op.
+        return NoopAutoCloseable.INSTANCE;
     }
-
 }
index 9a42dac24f111515d14e29e4bd26fed8bd0f930d..c58886050ba898dc24627997ddcc72735b9c6e12 100644 (file)
 * Do not modify this file unless it is present under src/main directory
 */
 package org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager;
-public class ForwardingRulesManagerModuleFactory extends org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager.AbstractForwardingRulesManagerModuleFactory {
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class ForwardingRulesManagerModuleFactory extends AbstractForwardingRulesManagerModuleFactory {
 
 }
index 286ffa1027db270863915fc5aaa6ec6c89e2ffb2..d6916d18e004c9fb080a6fd43f7e994b843a5abc 100644 (file)
@@ -8,11 +8,8 @@
 
 package org.opendaylight.openflowplugin.applications.frm;
 
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
-
-import org.opendaylight.openflowplugin.applications.frm.impl.FlowNodeConnectorInventoryTranslatorImpl;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.openflowplugin.applications.frm.impl.FlowNodeConnectorInventoryTranslatorImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
@@ -20,7 +17,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalF
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 /**
@@ -161,7 +160,7 @@ public interface ForwardingRulesManager extends AutoCloseable {
      * @return True if owner, else false
      */
     public boolean isNodeOwner(InstanceIdentifier<FlowCapableNode> ident);
-     
+
     /**
      * Content definition method and prevent code duplicity
      * @return FlowNodeConnectorInventoryTranslatorImpl
diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerConfig.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerConfig.java
deleted file mode 100644 (file)
index 0b4714e..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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.openflowplugin.applications.frm.impl;
-
-/**
- * Created by efiijjp on 10/14/2015.
- */
-public class ForwardingRulesManagerConfig {
-
-    private final boolean m_staleMarkingEnabled;
-    private final int m_reconciliationRetryCount;
-
-    private ForwardingRulesManagerConfig(ForwardingRulesManagerConfigBuilder builder){
-        m_staleMarkingEnabled = builder.isStaleMarkingEnabled();
-        m_reconciliationRetryCount = builder.getReconciliationRetryCount();
-    }
-
-    public boolean isStaleMarkingEnabled(){
-        return m_staleMarkingEnabled;
-    }
-
-    public int getReconciliationRetryCount() {
-        return m_reconciliationRetryCount;
-    }
-
-
-    public static ForwardingRulesManagerConfigBuilder builder(){
-        return new ForwardingRulesManagerConfigBuilder();
-    }
-
-
-
-    public static class ForwardingRulesManagerConfigBuilder {
-        private boolean staleMarkingEnabled ;
-        private int reconciliationRetryCount ;
-
-        public boolean isStaleMarkingEnabled(){
-            return staleMarkingEnabled;
-        }
-        public int getReconciliationRetryCount() {return reconciliationRetryCount;}
-
-        public void setStaleMarkingEnabled(boolean staleMarkingEnabledFlag){
-            staleMarkingEnabled = staleMarkingEnabledFlag;
-        }
-
-        public void setReconciliationRetryCount(int retryCount ){
-            reconciliationRetryCount = retryCount;
-        }
-
-        public ForwardingRulesManagerConfig build(){
-            return new ForwardingRulesManagerConfig(this);
-        }
-    }
-
-}
index cd05e4e58412bba2be7fff9d3672092b3bb0af15..ef7ff256d76824c20c8eb12b5e3e6c7bd8ad28c8 100644 (file)
@@ -11,11 +11,10 @@ package org.opendaylight.openflowplugin.applications.frm.impl;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.CheckedFuture;
 import java.util.Collections;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
-
-import com.google.common.util.concurrent.CheckedFuture;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
@@ -36,8 +35,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -109,7 +109,7 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
 
         this.tableListener = new TableForwarder(this, dataService);
         this.nodeListener = new FlowNodeReconciliationImpl(this, dataService);
-       flowNodeConnectorInventoryTranslatorImpl = 
+       flowNodeConnectorInventoryTranslatorImpl =
                            new FlowNodeConnectorInventoryTranslatorImpl(this,dataService);
         LOG.info("ForwardingRulesManager has started successfully.");
 
diff --git a/applications/forwardingrules-manager/src/main/resources/org/opendaylight/blueprint/forwardingrules-manager.xml b/applications/forwardingrules-manager/src/main/resources/org/opendaylight/blueprint/forwardingrules-manager.xml
new file mode 100644 (file)
index 0000000..1902cba
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+  <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
+  <reference id="entityOwnershipService" interface="org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService"/>
+
+  <odl:clustered-app-config id="frmConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig"/>
+
+  <bean id="frmManager" class="org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl"
+          init-method="start" destroy-method="close">
+    <argument ref="dataBroker"/>
+    <argument ref="rpcRegistry"/>
+    <argument ref="frmConfig"/>
+    <argument ref="entityOwnershipService"/>
+  </bean>
+</blueprint>
\ No newline at end of file
index 0b40bb0a5d063ecbd6c21f31482dc44a5c65a642..7151141111a2a902513871538e2e3f6603e0659d 100644 (file)
@@ -20,6 +20,7 @@ module forwardingrules-manager {
     identity forwardingrules-manager {
             base config:module-type;
             config:java-name-prefix ForwardingRulesManager;
+            status deprecated;
     }
 
     augment "/config:modules/config:module/config:configuration" {
diff --git a/applications/forwardingrules-manager/src/main/yang/forwardingrules-manager-config.yang b/applications/forwardingrules-manager/src/main/yang/forwardingrules-manager-config.yang
new file mode 100644 (file)
index 0000000..f2772f8
--- /dev/null
@@ -0,0 +1,25 @@
+module forwarding-rules-manager-config {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:openflowplugin:app:forwardingrules-manager:config";
+    prefix "frm";
+
+    description
+        "Configuration for Forwarding Rules Manager application..";
+
+    revision "2016-05-11" {
+        description
+            "Initial revision.";
+    }
+
+    container forwarding-rules-manager-config {
+        leaf stale-marking-enabled {
+            type boolean;
+            default false;
+        }
+
+        leaf reconciliation-retry-count {
+            type uint16;
+            default 5;
+        }
+    }
+}
\ No newline at end of file
index 44cc0055163a93ef8545c883348d997011c71fa1..9eedf33a736099f1e57e064cd3016b45c52ba314 100644 (file)
@@ -7,12 +7,14 @@
  */
 package test.mock;
 
+import static org.junit.Assert.assertEquals;
+import java.util.Collections;
+import java.util.List;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerConfig;
 import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
@@ -20,7 +22,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.Fl
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
@@ -33,17 +40,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
 import test.mock.util.EntityOwnershipServiceMock;
 import test.mock.util.FRMTest;
 import test.mock.util.RpcProviderRegistryMock;
 import test.mock.util.SalFlowServiceMock;
 
-import java.util.Collections;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
 public class FlowListenerTest extends FRMTest {
     RpcProviderRegistry rpcProviderRegistryMock = new RpcProviderRegistryMock();
     EntityOwnershipService eos = new EntityOwnershipServiceMock();
index 4d45861a2eaa4ea3505f508c592bc1b07feee060..ca2d80771d9fa91cd47223f17d86e1307ddf6e00 100644 (file)
@@ -1,10 +1,5 @@
 package test.mock.util;
 
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import java.util.Collections;
 import java.util.concurrent.ExecutionException;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
@@ -12,11 +7,17 @@ import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfigBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public abstract class FRMTest extends AbstractDataBrokerTest {
@@ -56,9 +57,9 @@ public abstract class FRMTest extends AbstractDataBrokerTest {
     }
 
     public ForwardingRulesManagerConfig getConfig(){
-        ForwardingRulesManagerConfig.ForwardingRulesManagerConfigBuilder cfgBuilder =
-                new ForwardingRulesManagerConfig.ForwardingRulesManagerConfigBuilder();
+        ForwardingRulesManagerConfigBuilder cfgBuilder = new ForwardingRulesManagerConfigBuilder();
         cfgBuilder.setStaleMarkingEnabled(false);
+        cfgBuilder.setReconciliationRetryCount(0);
         return cfgBuilder.build();
 
     }
index df1bab02168f862c57ff3c57da67dad9545d157a..f3bc24928f31b93f4188d706568c66ae0c9883fd 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.openflowplugin.applications.frsync;
 
 import java.util.EventListener;
-
 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
index 12cffd1362eb6bdaab84810cba078d04521cf493..141e3b465ae915b87fa06c0e1490d9c7ae7f68bd 100644 (file)
@@ -8,11 +8,10 @@
 
 package org.opendaylight.openflowplugin.applications.frsync;
 
+import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import com.google.common.util.concurrent.ListenableFuture;
-
 /**
  * Device synchronization API.
  */
index 0aebb06b0c7bc5c8370f33dbf2bc7cb85379e4a0..149c25959605e1eb272fb2da055708034b62c5b7 100644 (file)
@@ -8,13 +8,11 @@
 \r
 package org.opendaylight.openflowplugin.applications.frsync.dao;\r
 \r
+import com.google.common.base.Optional;\r
 import javax.annotation.Nonnull;\r
-\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;\r
 \r
-import com.google.common.base.Optional;\r
-\r
 /**\r
  * Implementation of data access object for {@link FlowCapableNode}.\r
  * Contains pair of snapshot and odl DAOs.\r
index 0bc6b991ce9ff3e3dbd058c15e6d857e466c95d8..469fc13cde12b082f50ae9054ba067271872dbcb 100644 (file)
@@ -8,13 +8,11 @@
 \r
 package org.opendaylight.openflowplugin.applications.frsync.dao;\r
 \r
+import com.google.common.base.Optional;\r
 import javax.annotation.Nonnull;\r
-\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;\r
 \r
-import com.google.common.base.Optional;\r
-\r
 /**\r
  * Data access object for {@link FlowCapableNode}.\r
  */\r
index 724c43ad67d0f73b7602f76e08bc2793d614aa57..a97fcc170836e9898245710a2a872aa78c675395 100644 (file)
@@ -9,10 +9,8 @@
 package org.opendaylight.openflowplugin.applications.frsync.dao;\r
 \r
 import com.google.common.base.Optional;\r
-\r
 import java.util.concurrent.TimeUnit;\r
 import java.util.concurrent.TimeoutException;\r
-\r
 import javax.annotation.Nonnull;\r
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;\r
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;\r
index 2c40af77b91beb73f339f8a41f59c10e5eb1d082..5cbf726cc53af6400e2c82a8682f764649761991 100644 (file)
@@ -8,15 +8,12 @@
 \r
 package org.opendaylight.openflowplugin.applications.frsync.dao;\r
 \r
+import com.google.common.base.Optional;\r
 import java.util.concurrent.ConcurrentHashMap;\r
-\r
 import javax.annotation.Nonnull;\r
-\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;\r
 \r
-import com.google.common.base.Optional;\r
-\r
 /**\r
  * Adding cache to data access object of {@link FlowCapableNode}.\r
  */\r
index 4d1e53a6932ff16f9fc5671122eb19639aa5a49f..2a4d1bd0f5b3d4559cb41778b138203b02b6e67d 100644 (file)
@@ -52,9 +52,9 @@ public abstract class AbstractFrmSyncListener<T extends DataObject> implements N
     protected abstract Optional<ListenableFuture<Boolean>> processNodeModification(
             DataTreeModification<T> modification) throws ReadFailedException, InterruptedException;
 
-    public abstract LogicalDatastoreType dsType();
+    protected abstract LogicalDatastoreType dsType();
 
-    static String threadName() {
+    private static String threadName() {
         final Thread currentThread = Thread.currentThread();
         return currentThread.getName();
     }
index f0babcba30af0ae1659b4bfe4a1397e37613f0b7..8bc18dd0ffec6c228a7f3548b78ebe4a8e30ff56 100644 (file)
@@ -8,8 +8,8 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Preconditions;
 import java.util.concurrent.Future;
-
 import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
@@ -26,7 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.Upda
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -36,8 +35,6 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-
 /**
  * Implements {@link ForwardingRulesCommitter} methods for processing add, update and remove of {@link Flow}.
  */
index 57c404b6d8cca5c7a0913e960e1e8cb5f189aa12..a35cde26003ea1ab3dc2008615f3deabc32e1e36 100644 (file)
@@ -31,12 +31,8 @@ import org.opendaylight.openflowplugin.applications.frsync.util.SemaphoreKeeperG
 import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.SalFlatBatchService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.FlowCapableTransactionService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -53,11 +49,7 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
     public static final int STARTUP_LOOP_MAX_RETRIES = 8;
 
     private final DataBroker dataService;
-    private final SalFlowService salFlowService;
-    private final SalGroupService salGroupService;
-    private final SalMeterService salMeterService;
     private final SalTableService salTableService;
-    private final FlowCapableTransactionService transactionService;
     private final SalFlatBatchService flatBatchService;
 
     /** wildcard path to flow-capable-node augmentation of inventory node */
@@ -78,27 +70,14 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
     public ForwardingRulesSyncProvider(final BindingAwareBroker broker,
                                        final DataBroker dataBroker,
                                        final RpcConsumerRegistry rpcRegistry) {
-        this.dataService = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
-
         Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry can not be null !");
-
-        this.salFlowService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlowService.class),
-                "RPC SalFlowService not found.");
-        this.salGroupService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalGroupService.class),
-                "RPC SalGroupService not found.");
-        this.salMeterService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalMeterService.class),
-                "RPC SalMeterService not found.");
+        this.dataService = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
         this.salTableService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalTableService.class),
                 "RPC SalTableService not found.");
-        this.transactionService =
-                Preconditions.checkNotNull(rpcRegistry.getRpcService(FlowCapableTransactionService.class),
-                        "RPC SalTableService not found.");
-        this.flatBatchService =
-                Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlatBatchService.class),
-                        "RPC SalFlatBatchService not found.");
-
-        nodeConfigDataTreePath =
-                new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, FLOW_CAPABLE_NODE_WC_PATH);
+        this.flatBatchService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlatBatchService.class),
+                "RPC SalFlatBatchService not found.");
+
+        nodeConfigDataTreePath = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, FLOW_CAPABLE_NODE_WC_PATH);
         nodeOperationalDataTreePath = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, NODE_WC_PATH);
 
         broker.registerProvider(this);
@@ -121,69 +100,52 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
 
     @Override
     public void onSessionInitiated(final BindingAwareBroker.ProviderContext providerContext) {
-        final FlowForwarder flowForwarder = new FlowForwarder(salFlowService);
-        final GroupForwarder groupForwarder = new GroupForwarder(salGroupService);
-        final MeterForwarder meterForwarder = new MeterForwarder(salMeterService);
         final TableForwarder tableForwarder = new TableForwarder(salTableService);
 
-        {
-            //TODO: make is switchable
-//            final SyncPlanPushStrategy syncPlanPushStrategy = new SyncPlanPushStrategyIncrementalImpl()
-//                    .setFlowForwarder(flowForwarder)
-//                    .setGroupForwarder(groupForwarder)
-//                    .setMeterForwarder(meterForwarder)
-//                    .setTableForwarder(tableForwarder)
-//                    .setTransactionService(transactionService);
-
-            final SyncPlanPushStrategy syncPlanPushStrategy = new SyncPlanPushStrategyFlatBatchImpl()
-                    .setFlatBatchService(flatBatchService)
-                    .setTableForwarder(tableForwarder);
-
-            final SyncReactorImpl syncReactorImpl = new SyncReactorImpl(syncPlanPushStrategy);
-            final SyncReactor syncReactorGuard = new SyncReactorGuardDecorator(syncReactorImpl,
-                    new SemaphoreKeeperGuavaImpl<InstanceIdentifier<FlowCapableNode>>(1, true));
-
-            final SyncReactor cfgReactor = new SyncReactorFutureWithCompressionDecorator(syncReactorGuard, syncThreadPool);
-            final SyncReactor operReactor = new SyncReactorFutureWithCompressionDecorator(syncReactorGuard, syncThreadPool);
-
-            final FlowCapableNodeSnapshotDao configSnapshot = new FlowCapableNodeSnapshotDao();
-            final FlowCapableNodeSnapshotDao operationalSnapshot = new FlowCapableNodeSnapshotDao();
-            final FlowCapableNodeDao configDao = new FlowCapableNodeCachedDao(configSnapshot,
-                    new FlowCapableNodeOdlDao(dataService, LogicalDatastoreType.CONFIGURATION));
-            final FlowCapableNodeDao operationalDao = new FlowCapableNodeCachedDao(operationalSnapshot,
-                    new FlowCapableNodeOdlDao(dataService, LogicalDatastoreType.OPERATIONAL));
-
-            final NodeListener<FlowCapableNode> nodeListenerConfig =
-                    new SimplifiedConfigListener(
-                            cfgReactor,
-                            configSnapshot, operationalDao);
-            final NodeListener<Node> nodeListenerOperational =
-                    new SimplifiedOperationalListener(operReactor, operationalSnapshot, configDao);
-
-            try {
-                SimpleTaskRetryLooper looper1 = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
-                dataTreeConfigChangeListener = looper1.loopUntilNoException(
-                        new Callable<ListenerRegistration<NodeListener>>() {
-                            @Override
-                            public ListenerRegistration<NodeListener> call() throws Exception {
-                                return dataService.registerDataTreeChangeListener(
-                                        nodeConfigDataTreePath, nodeListenerConfig);
-                            }
-                        });
-
-                SimpleTaskRetryLooper looper2 = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
-                dataTreeOperationalChangeListener = looper2.loopUntilNoException(
-                        new Callable<ListenerRegistration<NodeListener>>() {
-                            @Override
-                            public ListenerRegistration<NodeListener> call() throws Exception {
-                                return dataService.registerDataTreeChangeListener(
-                                        nodeOperationalDataTreePath, nodeListenerOperational);
-                            }
-                        });
-            } catch (final Exception e) {
-                LOG.warn("FR-Sync node DataChange listener registration fail!", e);
-                throw new IllegalStateException("FR-Sync startup fail!", e);
-            }
+        final SyncPlanPushStrategy syncPlanPushStrategy = new SyncPlanPushStrategyFlatBatchImpl()
+                .setFlatBatchService(flatBatchService)
+                .setTableForwarder(tableForwarder);
+
+        final SyncReactorImpl syncReactorImpl = new SyncReactorImpl(syncPlanPushStrategy);
+        final SyncReactor syncReactorGuard = new SyncReactorGuardDecorator(syncReactorImpl,
+                new SemaphoreKeeperGuavaImpl<InstanceIdentifier<FlowCapableNode>>(1, true));
+
+        final SyncReactor cfgReactor = new SyncReactorFutureWithCompressionDecorator(syncReactorGuard, syncThreadPool);
+        final SyncReactor operReactor = new SyncReactorFutureWithCompressionDecorator(syncReactorGuard, syncThreadPool);
+
+        final FlowCapableNodeSnapshotDao configSnapshot = new FlowCapableNodeSnapshotDao();
+        final FlowCapableNodeSnapshotDao operationalSnapshot = new FlowCapableNodeSnapshotDao();
+        final FlowCapableNodeDao configDao = new FlowCapableNodeCachedDao(configSnapshot,
+                new FlowCapableNodeOdlDao(dataService, LogicalDatastoreType.CONFIGURATION));
+        final FlowCapableNodeDao operationalDao = new FlowCapableNodeCachedDao(operationalSnapshot,
+                new FlowCapableNodeOdlDao(dataService, LogicalDatastoreType.OPERATIONAL));
+
+        final NodeListener<FlowCapableNode> nodeListenerConfig = new SimplifiedConfigListener(cfgReactor, configSnapshot, operationalDao);
+        final NodeListener<Node> nodeListenerOperational = new SimplifiedOperationalListener(operReactor, operationalSnapshot, configDao);
+
+        try {
+            SimpleTaskRetryLooper looper1 = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
+            dataTreeConfigChangeListener = looper1.loopUntilNoException(
+                    new Callable<ListenerRegistration<NodeListener>>() {
+                        @Override
+                        public ListenerRegistration<NodeListener> call() throws Exception {
+                            return dataService.registerDataTreeChangeListener(
+                                    nodeConfigDataTreePath, nodeListenerConfig);
+                        }
+                    });
+
+            SimpleTaskRetryLooper looper2 = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
+            dataTreeOperationalChangeListener = looper2.loopUntilNoException(
+                    new Callable<ListenerRegistration<NodeListener>>() {
+                        @Override
+                        public ListenerRegistration<NodeListener> call() throws Exception {
+                            return dataService.registerDataTreeChangeListener(
+                                    nodeOperationalDataTreePath, nodeListenerOperational);
+                        }
+                    });
+        } catch (final Exception e) {
+            LOG.warn("FR-Sync node DataChange listener registration fail!", e);
+            throw new IllegalStateException("FR-Sync startup fail!", e);
         }
         LOG.info("ForwardingRulesSync has started.");
     }
index 44e625dd239a712a896c8bd108b90e7a551567dc..17c500f003ca86bf992eed0db8ea6ea0d42de5be 100644 (file)
@@ -8,33 +8,32 @@
 \r
 package org.opendaylight.openflowplugin.applications.frsync.impl;\r
 \r
-import java.util.concurrent.ExecutorService;\r
-import java.util.concurrent.Executors;\r
-import java.util.concurrent.ThreadFactory;\r
-\r
 import com.google.common.annotations.VisibleForTesting;\r
 import com.google.common.util.concurrent.ListeningExecutorService;\r
 import com.google.common.util.concurrent.MoreExecutors;\r
+import java.util.concurrent.ExecutorService;\r
+import java.util.concurrent.Executors;\r
+import java.util.concurrent.ThreadFactory;\r
 \r
 /**\r
- * Static Factory for creating ExecutorServicess (because there is no dependency injection but\r
+ * Static Factory for creating ExecutorServices (because there is no dependency injection but\r
  * static getInstance).\r
  */\r
 public final class FrmExecutors {\r
-    public static PceExecursFactory instance() {\r
+    public static PceExecutorsFactory instance() {\r
         return DEFAULT_EXECUTORS;\r
     }\r
 \r
-    public interface PceExecursFactory {\r
+    public interface PceExecutorsFactory {\r
 \r
-        public ListeningExecutorService newFixedThreadPool(int nThreads, ThreadFactory factory);\r
+        ListeningExecutorService newFixedThreadPool(int nThreads, ThreadFactory factory);\r
     }\r
 \r
     /**\r
      * This will be rewritten in JUnits using SynchronousExecutorService\r
      */\r
     @VisibleForTesting // should not be private and final\r
-    static PceExecursFactory DEFAULT_EXECUTORS = new PceExecursFactory() {\r
+    static PceExecutorsFactory DEFAULT_EXECUTORS = new PceExecutorsFactory() {\r
 \r
         public ListeningExecutorService newFixedThreadPool(int nThreads, ThreadFactory factory) {\r
             final ExecutorService executorService = Executors.newFixedThreadPool(nThreads, factory);\r
index 9e69f2c40e078dc6b47d2bd38afef6fdb8b6d6cc..58faaab38f5706135eebd49fa8406e70ffe1aca8 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
 import java.util.concurrent.Future;
-
 import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
index 94265eccfc737c3c4c3248429039e538c146bfa9..c2298aa7dec155ac6b99bfbe26794d47a0de3779 100644 (file)
@@ -8,8 +8,9 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
-
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -23,15 +24,12 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
-
 /**
  * Listens to config changes and delegates add/remove/update/barrier to {@link SyncReactor}.
  */
 public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapableNode> {
     private static final Logger LOG = LoggerFactory.getLogger(SimplifiedConfigListener.class);
-    protected final SyncReactor reactor;
+    private final SyncReactor reactor;
     private final FlowCapableNodeSnapshotDao configSnaphot;
     private final FlowCapableNodeDao operationalDao;
 
index e66bf3f25f8f4c5106b6bc70c6099ddf4afc30a2..573ca80d68d66a9314271af5653d167561d037b9 100644 (file)
@@ -8,9 +8,10 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
 import java.util.List;
-
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
@@ -29,25 +30,20 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
-
 /**
  * Listens to operational new nodes and delegates add/remove/update/barrier to {@link SyncReactor}.
  */
 public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node> {
     private static final Logger LOG = LoggerFactory.getLogger(SimplifiedOperationalListener.class);
 
-    protected final SyncReactor reactor;
-
-    private FlowCapableNodeSnapshotDao operationalSnaphot;
-
+    private final SyncReactor reactor;
+    private FlowCapableNodeSnapshotDao operationalSnapshot;
     private FlowCapableNodeDao configDao;
 
     public SimplifiedOperationalListener(SyncReactor reactor,
-            FlowCapableNodeSnapshotDao operationalSnaphot, FlowCapableNodeDao configDao) {
+            FlowCapableNodeSnapshotDao operationalSnapshot, FlowCapableNodeDao configDao) {
         this.reactor = reactor;
-        this.operationalSnaphot = operationalSnaphot;
+        this.operationalSnapshot = operationalSnapshot;
         this.configDao = configDao;
     }
 
@@ -82,17 +78,17 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
     /**
      * Remove if delete. Update only if FlowCapableNode Augmentation modified.
      *
-     * @param modification
+     * @param modification Datastore modification
      */
     protected void updateCache(DataTreeModification<Node> modification) {
         try {
             boolean isDelete = isDelete(modification) || isDeleteLogical(modification);
             if (isDelete) {
-                operationalSnaphot.updateCache(nodeId(modification), Optional.<FlowCapableNode>absent());
+                operationalSnapshot.updateCache(nodeId(modification), Optional.<FlowCapableNode>absent());
                 return;
             }
 
-            operationalSnaphot.updateCache(nodeId(modification), Optional.fromNullable(flowCapableNodeAfter(modification)));
+            operationalSnapshot.updateCache(nodeId(modification), Optional.fromNullable(flowCapableNodeAfter(modification)));
         } catch(Exception e) {
             LOG.error("update cache failed {}", nodeId(modification), e);
         }
@@ -159,14 +155,16 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
             DataTreeModification<Node> modification) throws InterruptedException {
         final NodeId nodeId = nodeId(modification);
 
-        LOG.debug("reconciliation {}", nodeId.getValue());
+        LOG.debug("Reconciliation: {}", nodeId.getValue());
 
         final Optional<FlowCapableNode> nodeConfiguration = configDao.loadByNodeId(nodeId);
         final InstanceIdentifier<FlowCapableNode> nodePath = InstanceIdentifier.create(Nodes.class)
                 .child(Node.class, new NodeKey(nodeId(modification))).augmentation(FlowCapableNode.class);
-        final ListenableFuture<Boolean> rpcResult =
-                reactor.syncup(nodePath, nodeConfiguration.orNull(), flowCapableNodeAfter(modification));
-        return Optional.of(rpcResult);
+
+        if (nodeConfiguration.isPresent())
+            return Optional.of(reactor.syncup(nodePath, nodeConfiguration.get(), flowCapableNodeAfter(modification)));
+        else
+            return skipModification(modification);
     }
 
     static FlowCapableNode flowCapableNodeAfter(DataTreeModification<Node> modification) {
@@ -183,11 +181,8 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
         }
 
         final List<NodeConnector> nodeConnectors = node.getNodeConnector();
-        if (nodeConnectors == null || nodeConnectors.isEmpty()) {
-            return true;
-        }
 
-        return false;
+        return nodeConnectors == null || nodeConnectors.isEmpty();
     }
 
     static String nodeIdValue(DataTreeModification<Node> modification) {
index fb0b3e98503f6cb08bd245631e5c10ce338c5edd..33db6ea9c54f467253abea1125571fba0a2f2f0d 100644 (file)
@@ -8,10 +8,11 @@
 \r
 package org.opendaylight.openflowplugin.applications.frsync.impl;\r
 \r
+import com.google.common.util.concurrent.ListenableFuture;\r
+import com.google.common.util.concurrent.ListeningExecutorService;\r
 import java.util.concurrent.Callable;\r
 import java.util.concurrent.TimeUnit;\r
 import java.util.concurrent.TimeoutException;\r
-\r
 import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;\r
 import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
@@ -20,9 +21,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
-import com.google.common.util.concurrent.ListenableFuture;\r
-import com.google.common.util.concurrent.ListeningExecutorService;\r
-\r
 /**\r
  * Decorator for running delegate syncup in Future.\r
  */\r
index 44f3ee7fbe6a7dcad507a296cf71b52850c0e8f5..ce7c579070def5a766b439cdb7e6e8d3e5076e76 100644 (file)
@@ -8,12 +8,13 @@
 \r
 package org.opendaylight.openflowplugin.applications.frsync.impl;\r
 \r
+import com.google.common.util.concurrent.Futures;\r
+import com.google.common.util.concurrent.ListenableFuture;\r
+import com.google.common.util.concurrent.ListeningExecutorService;\r
 import java.util.HashMap;\r
 import java.util.Map;\r
 import java.util.concurrent.Semaphore;\r
-\r
 import javax.annotation.concurrent.GuardedBy;\r
-\r
 import org.apache.commons.lang3.tuple.Pair;\r
 import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;\r
 import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;\r
@@ -23,10 +24,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
-import com.google.common.util.concurrent.Futures;\r
-import com.google.common.util.concurrent.ListenableFuture;\r
-import com.google.common.util.concurrent.ListeningExecutorService;\r
-\r
 /**\r
  * Enriches {@link SyncReactorFutureDecorator} with state compression.\r
  */\r
@@ -34,10 +31,10 @@ public class SyncReactorFutureWithCompressionDecorator extends SyncReactorFuture
 \r
     private static final Logger LOG = LoggerFactory.getLogger(SyncReactorFutureWithCompressionDecorator.class);\r
 \r
-    @GuardedBy("beforeCompressionGuard")\r
-    final Map<InstanceIdentifier<FlowCapableNode>, Pair<FlowCapableNode, FlowCapableNode>> beforeCompression =\r
+    @GuardedBy("compressionGuard")\r
+    final Map<InstanceIdentifier<FlowCapableNode>, Pair<FlowCapableNode, FlowCapableNode>> compressionQueue =\r
             new HashMap<>();\r
-    final Semaphore beforeCompressionGuard = new Semaphore(1, false);\r
+    final Semaphore compressionGuard = new Semaphore(1, false);\r
 \r
     public SyncReactorFutureWithCompressionDecorator(SyncReactor delegate, ListeningExecutorService executorService) {\r
         super(delegate, executorService);\r
@@ -49,7 +46,7 @@ public class SyncReactorFutureWithCompressionDecorator extends SyncReactorFuture
         LOG.trace("syncup {}", nodeId.getValue());\r
 \r
         try {\r
-            beforeCompressionGuard.acquire();\r
+            compressionGuard.acquire();\r
 \r
             final boolean newFutureNecessary = updateCompressionState(flowcapableNodePath, configTree, operationalTree);\r
             if (newFutureNecessary) {\r
@@ -57,7 +54,7 @@ public class SyncReactorFutureWithCompressionDecorator extends SyncReactorFuture
             }\r
             return Futures.immediateFuture(true);\r
         } finally {\r
-            beforeCompressionGuard.release();\r
+            compressionGuard.release();\r
         }\r
     }\r
 \r
@@ -79,13 +76,13 @@ public class SyncReactorFutureWithCompressionDecorator extends SyncReactorFuture
 \r
     protected boolean updateCompressionState(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,\r
             final FlowCapableNode configTree, final FlowCapableNode operationalTree) {\r
-        final Pair<FlowCapableNode, FlowCapableNode> previous = beforeCompression.get(flowcapableNodePath);\r
+        final Pair<FlowCapableNode, FlowCapableNode> previous = compressionQueue.get(flowcapableNodePath);\r
         if (previous != null) {\r
             final FlowCapableNode previousOperational = previous.getRight();\r
-            beforeCompression.put(flowcapableNodePath, Pair.of(configTree, previousOperational));\r
+            compressionQueue.put(flowcapableNodePath, Pair.of(configTree, previousOperational));\r
             return false;\r
         } else {\r
-            beforeCompression.put(flowcapableNodePath, Pair.of(configTree, operationalTree));\r
+            compressionQueue.put(flowcapableNodePath, Pair.of(configTree, operationalTree));\r
             return true;\r
         }\r
     }\r
@@ -94,14 +91,14 @@ public class SyncReactorFutureWithCompressionDecorator extends SyncReactorFuture
             final InstanceIdentifier<FlowCapableNode> flowcapableNodePath) {\r
         try {\r
             try {\r
-                beforeCompressionGuard.acquire();\r
+                compressionGuard.acquire();\r
             } catch (InterruptedException e) {\r
                 return null;\r
             }\r
 \r
-            return beforeCompression.remove(flowcapableNodePath);\r
+            return compressionQueue.remove(flowcapableNodePath);\r
         } finally {\r
-            beforeCompressionGuard.release();\r
+            compressionGuard.release();\r
         }\r
     }\r
 }\r
index ea019e5ee6bd72bf2c0266ee24f596014bf362c5..92627831e7b8f007a086a5434a82dec0522f1f31 100644 (file)
@@ -8,11 +8,13 @@
 \r
 package org.opendaylight.openflowplugin.applications.frsync.impl;\r
 \r
+import com.google.common.base.Preconditions;\r
+import com.google.common.util.concurrent.FutureCallback;\r
+import com.google.common.util.concurrent.Futures;\r
+import com.google.common.util.concurrent.ListenableFuture;\r
 import java.util.concurrent.Semaphore;\r
 import java.util.concurrent.TimeUnit;\r
-\r
 import javax.annotation.Nullable;\r
-\r
 import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;\r
 import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;\r
 import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;\r
@@ -22,11 +24,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
-import com.google.common.base.Preconditions;\r
-import com.google.common.util.concurrent.FutureCallback;\r
-import com.google.common.util.concurrent.Futures;\r
-import com.google.common.util.concurrent.ListenableFuture;\r
-\r
 /**\r
  * Decorator for NodeId level syncup locking.\r
  */\r
@@ -73,10 +70,10 @@ public class SyncReactorGuardDecorator implements SyncReactor {
                                 formatNanos(stampAfterGuard - stampBeforeGuard),\r
                                 guard, threadName());\r
                     }\r
-                    \r
-                    lockReleaseForNodeId(nodeId, guard);\r
+\r
+                    releaseGuardForNodeId(nodeId, guard);\r
                 }\r
-                \r
+\r
                 @Override\r
                 public void onFailure(final Throwable t) {\r
                     if (LOG.isDebugEnabled()) {\r
@@ -87,13 +84,13 @@ public class SyncReactorGuardDecorator implements SyncReactor {
                                 formatNanos(stampAfterGuard - stampBeforeGuard),\r
                                 guard, threadName());\r
                     }\r
-                    \r
-                    lockReleaseForNodeId(nodeId, guard);\r
+\r
+                    releaseGuardForNodeId(nodeId, guard);\r
                 }\r
             });\r
             return endResult;\r
         } catch(InterruptedException e) {\r
-            lockReleaseForNodeId(nodeId, guard);\r
+            releaseGuardForNodeId(nodeId, guard);\r
             throw e;\r
         }\r
     }\r
@@ -105,8 +102,8 @@ public class SyncReactorGuardDecorator implements SyncReactor {
     /**\r
      * get guard\r
      *\r
-     * @param flowcapableNodePath\r
-     * @return\r
+     * @param flowcapableNodePath II of node for which guard should be acquired\r
+     * @return semaphore guard\r
      */\r
     protected Semaphore summonGuardAndAcquire(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath)\r
             throws InterruptedException {\r
@@ -129,11 +126,10 @@ public class SyncReactorGuardDecorator implements SyncReactor {
     /**\r
      * unlock per node\r
      *\r
-     * @param nodeId\r
-     * @param guard\r
+     * @param nodeId NodeId of node which should be unlocked\r
+     * @param guard semaphore guard\r
      */\r
-    protected void lockReleaseForNodeId(final NodeId nodeId,\r
-            final Semaphore guard) {\r
+    protected void releaseGuardForNodeId(final NodeId nodeId, final Semaphore guard) {\r
         if (guard == null) {\r
             return;\r
         }\r
index f2dc532bb6596369caaef4c5ff22e8c02766ab92..74347b1a8735107de89b32b64e3c355c4eb50999 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.applications.frsync.impl;
 
 import java.util.Collections;
 import java.util.concurrent.Future;
-
 import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesUpdateCommitter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
index 48560a457581128ec451afe58805d2a9b93dea1a..ed90d2854624002de508eda5556f6ce1b3fca027 100644 (file)
@@ -180,7 +180,7 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
             @Override
             public void onSuccess(@Nullable final RpcResult<ProcessFlatBatchOutput> result) {
                 if (!result.isSuccessful() && result.getResult() != null && !result.getResult().getBatchFailure().isEmpty()) {
-                    Map<Range<Integer>, Batch> batchMap = mapBachesToRanges(inputBatchBag, failureIndexLimit);
+                    Map<Range<Integer>, Batch> batchMap = mapBatchesToRanges(inputBatchBag, failureIndexLimit);
 
                     for (BatchFailure batchFailure : result.getResult().getBatchFailure()) {
                         for (Map.Entry<Range<Integer>, Batch> rangeBatchEntry : batchMap.entrySet()) {
@@ -224,7 +224,7 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
         }
     }
 
-    static Map<Range<Integer>, Batch> mapBachesToRanges(final List<Batch> inputBatchBag, final int failureIndexLimit) {
+    static Map<Range<Integer>, Batch> mapBatchesToRanges(final List<Batch> inputBatchBag, final int failureIndexLimit) {
         final Map<Range<Integer>, Batch> batchMap = new LinkedHashMap<>();
         final PeekingIterator<Batch> batchPeekingIterator = Iterators.peekingIterator(inputBatchBag.iterator());
         while (batchPeekingIterator.hasNext()) {
@@ -248,7 +248,6 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
         // process flow remove
         if (flowItemSyncTableMap != null) {
             for (Map.Entry<TableKey, ItemSyncBox<Flow>> syncBoxEntry : flowItemSyncTableMap.entrySet()) {
-                final TableKey tableKey = syncBoxEntry.getKey();
                 final ItemSyncBox<Flow> flowItemSyncBox = syncBoxEntry.getValue();
 
                 if (!flowItemSyncBox.getItemsToPush().isEmpty()) {
@@ -422,7 +421,6 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
         // process flow add+update
         if (flowItemSyncTableMap != null) {
             for (Map.Entry<TableKey, ItemSyncBox<Flow>> syncBoxEntry : flowItemSyncTableMap.entrySet()) {
-                final TableKey tableKey = syncBoxEntry.getKey();
                 final ItemSyncBox<Flow> flowItemSyncBox = syncBoxEntry.getValue();
 
                 if (!flowItemSyncBox.getItemsToPush().isEmpty()) {
index df3a3db7951c0e3e2641e1d81b51d67fb90b0ff2..1a6b277962b0fc36011366ea7261338d0543733f 100644 (file)
@@ -14,10 +14,8 @@ import java.util.List;
 import java.util.Map;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-
 import org.opendaylight.openflowplugin.applications.frsync.markandsweep.SwitchFlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
index 1a11c9f16fe509eaccfde0df8bada1325db22815..2cd6204033839af51e4372ff0f9980069c3285dc 100644 (file)
@@ -8,15 +8,12 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.util;
 
-import java.util.concurrent.Semaphore;
-
-import javax.annotation.Nonnull;
-
-import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;
-
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
+import java.util.concurrent.Semaphore;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;
 
 /**
  * Key-based semaphore provider.
index 1effafda9442521b74794c7e0a46fc0247aba4e1..7feb84aa58f1324ed504d3bea1b4381a3d263e2d 100644 (file)
@@ -12,7 +12,6 @@ import java.math.BigInteger;
 import java.util.Collections;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
index 1b1fac25e5f91068fe6239d87c122f0303d6efd2..76fb1fad803b57f91e90879625058f6bb523502f 100644 (file)
@@ -21,11 +21,8 @@ import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.SalFlatBatchService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.FlowCapableTransactionService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 
@@ -57,13 +54,8 @@ public class ForwardingRulesSyncProviderTest {
                 });
 
         provider = new ForwardingRulesSyncProvider(broker, dataBroker, rpcRegistry);
-
-        Mockito.verify(rpcRegistry).getRpcService(SalFlowService.class);
-        Mockito.verify(rpcRegistry).getRpcService(SalGroupService.class);
-        Mockito.verify(rpcRegistry).getRpcService(SalMeterService.class);
         Mockito.verify(rpcRegistry).getRpcService(SalTableService.class);
-        Mockito.verify(rpcRegistry).getRpcService(FlowCapableTransactionService.class);
-
+        Mockito.verify(rpcRegistry).getRpcService(SalFlatBatchService.class);
         Mockito.verify(broker).registerProvider(provider);
     }
 
index 2cf2eec9516ef166a8755d256877c538e29eebd4..8e980dcb60bd0bc2b51b9fcb95d3f2b9e99aeba1 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.applications.frsync.impl;
 import java.math.BigInteger;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
index 7c820748d689234a9ca751d2eacfed4bee92b2bb..28ae5dc4c3e637916963a648e30050e3a673f697 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.applications.frsync.impl;
 import java.math.BigInteger;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
index 3b5caeaec036a414671d888f33755d4d35607640..7e37a1f9a5487b930e4b6286edd4f46277f59129 100644 (file)
@@ -8,8 +8,9 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.Futures;
 import java.util.Collections;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -36,13 +37,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.Futures;
-
 /**
  * Test for {@link SimplifiedConfigListener}.
  */
-@SuppressWarnings("deprecation")
 @RunWith(MockitoJUnitRunner.class)
 public class SimplifiedConfigListenerTest {
 
index 4be870f5e8bd48dc6225ac7639b523b803787146..04005d2c0cfb72f477029265b7fddf7bbc063729 100644 (file)
@@ -8,8 +8,9 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.Futures;
 import java.util.Collections;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -35,16 +36,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.AsyncFunction;
-import com.google.common.util.concurrent.Futures;
 
 /**
  * Test for {@link SimplifiedOperationalListener}.
  */
-@SuppressWarnings("deprecation")
 @RunWith(MockitoJUnitRunner.class)
 public class SimplifiedOperationalListenerTest {
 
@@ -52,31 +47,41 @@ public class SimplifiedOperationalListenerTest {
     @Mock
     private SyncReactor reactor;
     @Mock
-    private DataBroker db;
+    private ReadOnlyTransaction roTx;
     @Mock
     private DataTreeModification<Node> dataTreeModification;
     @Mock
-    private ReadOnlyTransaction roTx;
+    private FlowCapableNode configNode;
     @Mock
-    private DataObjectModification<Node> operationalModification;
+    private FlowCapableNode fcOperationalNode;
 
     private InstanceIdentifier<Node> nodePath;
     private InstanceIdentifier<FlowCapableNode> fcNodePath;
     private SimplifiedOperationalListener nodeListenerOperational;
 
-    @SuppressWarnings("deprecation")
     @Before
     public void setUp() throws Exception {
+        final DataBroker db = Mockito.mock(DataBroker.class);
+        final DataObjectModification<Node> operationalModification = Mockito.mock(DataObjectModification.class);
+        final Node operationalNode = Mockito.mock(Node.class);
+
         final FlowCapableNodeSnapshotDao configSnaphot = new FlowCapableNodeSnapshotDao();
         final FlowCapableNodeSnapshotDao operationalSnaphot = new FlowCapableNodeSnapshotDao();
         final FlowCapableNodeDao configDao = new FlowCapableNodeCachedDao(configSnaphot,
                 new FlowCapableNodeOdlDao(db, LogicalDatastoreType.CONFIGURATION));
-
-
         nodeListenerOperational = new SimplifiedOperationalListener(reactor, operationalSnaphot, configDao);
-        nodePath = InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, new NodeKey(NODE_ID));
+        nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
         fcNodePath = nodePath.augmentation(FlowCapableNode.class);
+
+        final DataTreeIdentifier<Node> dataTreeIdentifier =
+                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, nodePath);
+
+        Mockito.when(operationalNode.getId()).thenReturn(NODE_ID);
+        Mockito.when(db.newReadOnlyTransaction()).thenReturn(roTx);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableNode.class)).thenReturn(fcOperationalNode);
+        Mockito.when(dataTreeModification.getRootPath()).thenReturn(dataTreeIdentifier);
+        Mockito.when(dataTreeModification.getRootNode()).thenReturn(operationalModification);
+        Mockito.when(operationalModification.getDataAfter()).thenReturn(operationalNode);
     }
 
     @Test
@@ -85,29 +90,27 @@ public class SimplifiedOperationalListenerTest {
     }
 
     @Test
-    public void testOnDataTreeChanged() throws Exception {
-        final FlowCapableNode configTree = Mockito.mock(FlowCapableNode.class);
-        final Node mockOperationalNode = Mockito.mock(Node.class);
-        final FlowCapableNode mockOperationalFlowCapableNode = Mockito.mock(FlowCapableNode.class);
-        Mockito.when(mockOperationalNode.getAugmentation(FlowCapableNode.class))
-            .thenReturn(mockOperationalFlowCapableNode);
-        Mockito.when(mockOperationalNode.getId()).thenReturn(NODE_ID);
+    public void testOnDataTreeChangedSyncup() throws Exception {
+        Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(),Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any())).thenReturn(Futures.immediateFuture(Boolean.TRUE));
+        Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath))
+                .thenReturn(Futures.immediateCheckedFuture(Optional.of(configNode)));
 
-        final DataTreeIdentifier<Node> dataTreeIdentifier =
-                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, nodePath);
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
-        Mockito.when(dataTreeModification.getRootPath()).thenReturn(dataTreeIdentifier);
-        Mockito.when(dataTreeModification.getRootNode()).thenReturn(operationalModification);
-        Mockito.when(operationalModification.getDataAfter()).thenReturn(mockOperationalNode);
-        Mockito.when(db.newReadOnlyTransaction()).thenReturn(roTx);
-        Mockito.doReturn(Futures.immediateCheckedFuture(Optional.of(configTree))).when(
-                roTx).read(LogicalDatastoreType.CONFIGURATION, fcNodePath);
-        Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(),Matchers.<FlowCapableNode>any(),Matchers.<FlowCapableNode>any()))
-                .thenReturn(Futures.immediateFuture(Boolean.TRUE));
+        Mockito.verify(reactor, Mockito.times(1)).syncup(fcNodePath, configNode, fcOperationalNode);
+        Mockito.verify(roTx).close();
+    }
+
+    @Test
+    public void testOnDataTreeChangedSkip() throws Exception {
+        // Related to bug 5920 -> https://bugs.opendaylight.org/show_bug.cgi?id=5920
+        Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath))
+                .thenReturn(Futures.immediateCheckedFuture(Optional.absent()));
 
         nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
-        Mockito.verify(reactor).syncup(fcNodePath, configTree, mockOperationalFlowCapableNode);
+        Mockito.verifyZeroInteractions(reactor);
         Mockito.verify(roTx).close();
     }
 }
diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecoratorTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecoratorTest.java
new file mode 100644 (file)
index 0000000..8eda58c
--- /dev/null
@@ -0,0 +1,73 @@
+/**
+ * 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.openflowplugin.applications.frsync.impl;
+
+import com.google.common.util.concurrent.Futures;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowplugin.applications.frsync.util.SemaphoreKeeperGuavaImpl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Test for {@link SyncReactorGuardDecorator}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class SyncReactorGuardDecoratorTest {
+
+    private static final NodeId NODE_ID = new NodeId("test-node");
+    private SyncReactorGuardDecorator reactor;
+    private InstanceIdentifier<FlowCapableNode> fcNodePath;
+
+    @Mock
+    private SyncReactorImpl delegate;
+    @Mock
+    private FlowCapableNode fcConfigNode;
+    @Mock
+    private FlowCapableNode fcOperationalNode;
+
+    @Before
+    public void setUp() throws Exception {
+        reactor = new SyncReactorGuardDecorator(delegate, new SemaphoreKeeperGuavaImpl<InstanceIdentifier<FlowCapableNode>>(1, true));
+        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
+        fcNodePath = nodePath.augmentation(FlowCapableNode.class);
+
+        final Node operationalNode = Mockito.mock(Node.class);
+        Mockito.when(operationalNode.getId()).thenReturn(NODE_ID);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableNode.class)).thenReturn(fcOperationalNode);
+    }
+
+    @Test
+    public void testSyncupSuccess() throws Exception {
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(),Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any())).thenReturn(Futures.immediateFuture(Boolean.TRUE));
+        reactor.syncup(fcNodePath, fcConfigNode, fcOperationalNode);
+        Mockito.verify(delegate).syncup(fcNodePath, fcConfigNode, fcOperationalNode);
+
+    }
+
+    @Test
+    public void testSyncupFail() throws Exception {
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(),Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any())).thenReturn(Futures.immediateFailedFuture(new Exception()));
+        reactor.syncup(fcNodePath, fcConfigNode, fcOperationalNode);
+        Mockito.verify(delegate).syncup(fcNodePath, fcConfigNode, fcOperationalNode);
+
+    }
+
+}
\ No newline at end of file
index 7e88950e84b7b001c4b4a466bd511eea6e802ce7..86cf17bf4cadf39d11b6b41dee709a0b41b03170 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.applications.frsync.impl;
 import java.math.BigInteger;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
index a30d600799df016e1c1c8d2dd2bba8239f956b4f..0eadaef2304f7a106a96f14236ae1358035fb9de 100644 (file)
@@ -43,7 +43,7 @@ public class DiffInputFactory {
         return groupBox;
     }
 
-    static Group createPlainGroup(final long gid) {
+    private static Group createPlainGroup(final long gid) {
         return new GroupBuilder().setGroupId(new GroupId(gid)).build();
     }
 
@@ -67,7 +67,7 @@ public class DiffInputFactory {
         return groupBox;
     }
 
-    static Meter createPlainMeter(final long mid) {
+    private static Meter createPlainMeter(final long mid) {
         return new MeterBuilder().setMeterId(new MeterId(mid)).build();
     }
 
@@ -91,7 +91,7 @@ public class DiffInputFactory {
         return groupBox;
     }
 
-    static Flow createPlainFlow(final String fid) {
+    private static Flow createPlainFlow(final String fid) {
         return new FlowBuilder().setId(new FlowId(fid)).build();
     }
 }
index e83d9b036212141eb0c0753d29b10f42440d4d5e..90b7cf8b876e0c0a44a960641d7b1c526be5562e 100644 (file)
@@ -287,7 +287,7 @@ public class SyncPlanPushStrategyFlatBatchImplTest {
                 new BatchBuilder().setBatchOrder(9).build(),
                 new BatchBuilder().setBatchOrder(15).build()
         );
-        final Map<Range<Integer>, Batch> rangeBatchMap = SyncPlanPushStrategyFlatBatchImpl.mapBachesToRanges(inputBatchBag, 42);
+        final Map<Range<Integer>, Batch> rangeBatchMap = SyncPlanPushStrategyFlatBatchImpl.mapBatchesToRanges(inputBatchBag, 42);
 
         Assert.assertEquals(4, rangeBatchMap.size());
         int idx = 0;
index 75aa3b23bcd36e0f8dbe863aeff8bbbf99e5336c..ee09da96ee7447fd94ea482fb237f14537eb5d34 100644 (file)
@@ -12,6 +12,14 @@ import com.google.common.base.Splitter;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
@@ -46,15 +54,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * Test for {@link ReconcileUtil}.
  */
index f874eb7b5de3e8de9de6f21f001a4dda637032a7..b2d38d06ec87c36de820629eb7bbbc4e5f36fae1 100644 (file)
@@ -15,7 +15,6 @@ import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -29,7 +28,7 @@ import org.slf4j.LoggerFactory;
 public class SemaphoreKeeperTest {
     private static final Logger LOG = LoggerFactory.getLogger(SemaphoreKeeperTest.class);
     private SemaphoreKeeperGuavaImpl<String> semaphoreKeeper;
-    final String key = "11";
+    private final String key = "11";
 
     @Before
     public void setUp() throws Exception {
index cf7005a47b79787b961807533ca6e952b253f724..1fc3a7af5e2ece5e8b4e706fe02dd8d899516c41 100644 (file)
@@ -6,6 +6,9 @@ Copyright (c) 2014 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
+
+NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for
+       backwards compatibility. Runtime modifications are not honored.
 -->
 <snapshot>
   <required-capabilities>
index 79f100fa0730915b80b8aa0238055afe28efc8fe..3e5fb3bf10b96a5f69302b7e73ac259d34ac7b88 100644 (file)
@@ -7,39 +7,35 @@
  */
 package org.opendaylight.openflowplugin.applications.topology.lldp;
 
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class LLDPActivator implements BindingAwareProvider, AutoCloseable {
+public class LLDPActivator implements AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(LLDPActivator.class);
-    private static LLDPDiscoveryProvider provider = new LLDPDiscoveryProvider();
+
     private static String lldpSecureKey;
 
-    public LLDPActivator(String secureKey) {
+    private final ListenerRegistration<NotificationListener> lldpNotificationRegistration;
+
+    public LLDPActivator(NotificationProviderService notificationService, LLDPDiscoveryListener lldpDiscoveryListener,
+            String secureKey) {
         lldpSecureKey = secureKey;
-    }
 
-    public void onSessionInitiated(final ProviderContext session) {
-        DataProviderService dataService = session.<DataProviderService>getSALService(DataProviderService.class);
-        provider.setDataService(dataService);
-        NotificationProviderService notificationService = session.<NotificationProviderService>getSALService(NotificationProviderService.class);
-        provider.setNotificationService(notificationService);
-        provider.start();
+        LOG.info("Starting LLDPActivator with lldpSecureKey: {}", lldpSecureKey);
+
+        lldpNotificationRegistration = notificationService.registerNotificationListener(lldpDiscoveryListener);
+
+        LOG.info("LLDPDiscoveryListener started.");
     }
 
     @Override
-    public void close() throws Exception {
-        if(provider != null) {
-            try {
-                provider.close();
-            } catch (Exception e) {
-                LOG.warn("Exception when closing down topology-lldp-discovery",e);
-            }
-        }
+    public void close() {
+        lldpNotificationRegistration.close();
+
+        LOG.info("LLDPDiscoveryListener stopped.");
     }
 
     public static String getLldpSecureKey() {
index 08c3c9c4a9b196cb47517fbca2aafe7493efbb9e..097d0edc4ebc0089c11375afa782ad9577ccb387 100644 (file)
@@ -17,16 +17,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.Pa
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-class LLDPDiscoveryListener implements PacketProcessingListener {
+public class LLDPDiscoveryListener implements PacketProcessingListener {
     private static final Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryListener.class);
 
-    private LLDPLinkAger lldpLinkAger;
-    private NotificationProviderService notificationService;
+    private final LLDPLinkAger lldpLinkAger;
+    private final NotificationProviderService notificationService;
 
-    LLDPDiscoveryListener(NotificationProviderService notificationService) {
+    public LLDPDiscoveryListener(NotificationProviderService notificationService, LLDPLinkAger lldpLinkAger) {
         this.notificationService = notificationService;
+        this.lldpLinkAger = lldpLinkAger;
     }
 
+    @Override
     public void onPacketReceived(PacketReceived lldp) {
         NodeConnectorRef src = LLDPDiscoveryUtils.lldpToNodeConnectorRef(lldp.getPayload(), true);
         if(src != null) {
@@ -39,8 +41,4 @@ class LLDPDiscoveryListener implements PacketProcessingListener {
             lldpLinkAger.put(ld);
         }
     }
-
-    public void setLldpLinkAger(LLDPLinkAger lldpLinkAger) {
-        this.lldpLinkAger = lldpLinkAger;
-    }
-}
+}
\ No newline at end of file
diff --git a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryProvider.java b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryProvider.java
deleted file mode 100644 (file)
index c6203ef..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Copyright (c) 2013 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.openflowplugin.applications.topology.lldp;
-
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.openflowplugin.applications.topology.lldp.utils.LLDPDiscoveryUtils;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LLDPDiscoveryProvider implements AutoCloseable {
-    private static final Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryProvider.class);
-    private DataProviderService dataService;
-    private NotificationProviderService notificationService;
-
-    private ListenerRegistration<NotificationListener> listenerRegistration;
-    private LLDPLinkAger lldpLinkAger;
-
-    public DataProviderService getDataService() {
-        return this.dataService;
-    }
-
-    public void setDataService(final DataProviderService dataService) {
-        this.dataService = dataService;
-    }
-
-    public NotificationProviderService getNotificationService() {
-        return this.notificationService;
-    }
-
-    public void setNotificationService(final NotificationProviderService notificationService) {
-        this.notificationService = notificationService;
-    }
-
-    public void start() {
-        lldpLinkAger = new LLDPLinkAger(LLDPDiscoveryUtils.LLDP_INTERVAL, LLDPDiscoveryUtils.LLDP_EXPIRATION_TIME);
-        lldpLinkAger.setNotificationService(notificationService);
-
-        LLDPDiscoveryListener committer = new LLDPDiscoveryListener(notificationService);
-        committer.setLldpLinkAger(lldpLinkAger);
-
-        ListenerRegistration<NotificationListener> registerNotificationListener =
-                notificationService.registerNotificationListener(committer);
-        this.listenerRegistration = registerNotificationListener;
-        LOG.info("LLDPDiscoveryListener Started.");
-    }
-
-    public void close() {
-        try {
-            LOG.info("LLDPDiscoveryListener stopped.");
-            if (this.listenerRegistration!=null) {
-                this.listenerRegistration.close();
-            }
-            lldpLinkAger.close();
-        } catch (Exception e) {
-            throw new Error(e);
-        }
-    }
-}
index 67b74995f78d6a0ee5566013ff15cab05628a089..9acd4b2de34251d1a1c4972ffba82cde103bf24d 100644 (file)
@@ -20,15 +20,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev
 
 public class LLDPLinkAger implements AutoCloseable {
     private final long linkExpirationTime;
-    private Map<LinkDiscovered, Date> linkToDate;
-    private Timer timer;
-    private NotificationProviderService notificationService;
+    private final Map<LinkDiscovered, Date> linkToDate;
+    private final Timer timer;
+    private final NotificationProviderService notificationService;
 
     /**
      * default ctor - start timer
      */
-    public LLDPLinkAger(final long lldpInterval, final long linkExpirationTime) {
+    public LLDPLinkAger(final long lldpInterval, final long linkExpirationTime,
+            final NotificationProviderService notificationService) {
         this.linkExpirationTime = linkExpirationTime;
+        this.notificationService = notificationService;
         linkToDate = new ConcurrentHashMap<>();
         timer = new Timer();
         timer.schedule(new LLDPAgingTask(), 0, lldpInterval);
@@ -46,10 +48,6 @@ public class LLDPLinkAger implements AutoCloseable {
         linkToDate.clear();
     }
 
-    public void setNotificationService(NotificationProviderService notificationService) {
-        this.notificationService = notificationService;
-    }
-
     private class LLDPAgingTask extends TimerTask {
 
         @Override
index 8112bcc2df886f11d3f062f0b7f18d2ba60e2052..29c99eca6f725cb52ba6763d9081a3c39dd18b53 100644 (file)
@@ -7,31 +7,31 @@
  */
 package org.opendaylight.openflowplugin.applications.topology.lldp.utils;
 
-import org.apache.commons.lang3.ArrayUtils;
-import java.nio.charset.Charset;
 import com.google.common.hash.HashCode;
+import com.google.common.hash.HashFunction;
+import com.google.common.hash.Hasher;
+import com.google.common.hash.Hashing;
+import java.lang.management.ManagementFactory;
+import java.nio.charset.Charset;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import org.apache.commons.lang3.ArrayUtils;
+import org.opendaylight.controller.liblldp.BitBufferHelper;
+import org.opendaylight.controller.liblldp.CustomTLVKey;
 import org.opendaylight.controller.liblldp.Ethernet;
 import org.opendaylight.controller.liblldp.LLDP;
-import org.opendaylight.controller.liblldp.BitBufferHelper;
 import org.opendaylight.controller.liblldp.LLDPTLV;
 import org.opendaylight.controller.liblldp.NetUtils;
-import com.google.common.hash.Hasher;
-import com.google.common.hash.Hashing;
-import com.google.common.hash.HashFunction;
 import org.opendaylight.openflowplugin.applications.topology.lldp.LLDPActivator;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import java.util.Arrays;
-import java.security.NoSuchAlgorithmException;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
-import java.lang.management.ManagementFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.controller.liblldp.CustomTLVKey;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,12 +39,6 @@ import org.slf4j.LoggerFactory;
 public class LLDPDiscoveryUtils {
     private static final Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryUtils.class);
 
-    // Send LLDP every five seconds
-    public static final Long LLDP_INTERVAL = (long) (1000*5);
-
-    // Let up to three intervals pass before we decide we are expired.
-    public static final Long LLDP_EXPIRATION_TIME = LLDP_INTERVAL*3;
-
     public static String macToString(byte[] mac) {
         StringBuilder b = new StringBuilder();
         for (int i = 0; i < mac.length; i++) {
index eed30f9e4134febf29c2172e6e2efa8a5cf0eb37..447dda656c9ac7c568d2370024507a7aed6dc248 100644 (file)
@@ -1,8 +1,12 @@
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.impl.rev150530;
 
-import org.opendaylight.openflowplugin.applications.topology.lldp.LLDPActivator;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
 
-public class TopologyLldpDiscoveryImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.impl.rev150530.AbstractTopologyLldpDiscoveryImplModule {
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class TopologyLldpDiscoveryImplModule extends AbstractTopologyLldpDiscoveryImplModule {
     public TopologyLldpDiscoveryImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
@@ -12,15 +16,8 @@ public class TopologyLldpDiscoveryImplModule extends org.opendaylight.yang.gen.v
     }
 
     @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
+    public AutoCloseable createInstance() {
+        // LLDPActivator instance is created via blueprint so this in a no-op.
+        return NoopAutoCloseable.INSTANCE;
     }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        LLDPActivator provider = new LLDPActivator(getLldpSecureKey());
-        getBrokerDependency().registerProvider(provider);
-        return provider;
-    }
-
 }
index e9670e2f1205e93227e41229ffc156b161f5b059..d335fc564efd83b990683f8161ae49976045de53 100644 (file)
@@ -8,6 +8,11 @@
 * Do not modify this file unless it is present under src/main directory
 */
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.impl.rev150530;
-public class TopologyLldpDiscoveryImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.impl.rev150530.AbstractTopologyLldpDiscoveryImplModuleFactory {
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class TopologyLldpDiscoveryImplModuleFactory extends AbstractTopologyLldpDiscoveryImplModuleFactory {
 
 }
diff --git a/applications/topology-lldp-discovery/src/main/resources/org/opendaylight/blueprint/topology-lldp-discovery.xml b/applications/topology-lldp-discovery/src/main/resources/org/opendaylight/blueprint/topology-lldp-discovery.xml
new file mode 100644 (file)
index 0000000..12ac129
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="notificationService" interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService"/>
+
+  <odl:clustered-app-config id="topologyLLDPConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.config.rev160511.TopologyLldpDiscoveryConfig">
+    <odl:default-config><![CDATA[
+      <topology-lldp-discovery-config xmlns="urn:opendaylight:params:xml:ns:yang:topology-lldp-discovery:config">
+        <lldp-secure-key>aa9251f8-c7c0-4322-b8d6-c3a84593bda3</lldp-secure-key>
+      </topology-lldp-discovery-config>
+    ]]></odl:default-config>
+  </odl:clustered-app-config>
+
+  <bean id="lldpLinkAger" class="org.opendaylight.openflowplugin.applications.topology.lldp.LLDPLinkAger"
+          destroy-method="close">
+    <!-- Interval to send LLDP (five seconds) -->
+    <argument value="5000"/>
+    <!-- Expiration interval for aging out links (3 * the interval)  -->
+    <argument value="15000"/>
+    <argument ref="notificationService"/>
+  </bean>
+
+  <bean id="lldpDiscoveryListener" class="org.opendaylight.openflowplugin.applications.topology.lldp.LLDPDiscoveryListener">
+    <argument ref="notificationService"/>
+    <argument ref="lldpLinkAger"/>
+  </bean>
+
+  <bean id="LLDPActivator" class="org.opendaylight.openflowplugin.applications.topology.lldp.LLDPActivator"
+         destroy-method="close">
+    <argument ref="notificationService"/>
+    <argument ref="lldpDiscoveryListener"/>
+    <argument>
+      <bean factory-ref="topologyLLDPConfig" factory-method="getLldpSecureKey"/>
+    </argument>
+  </bean>
+</blueprint>
\ No newline at end of file
diff --git a/applications/topology-lldp-discovery/src/main/yang/topology-lldp-discovery-config.yang b/applications/topology-lldp-discovery/src/main/yang/topology-lldp-discovery-config.yang
new file mode 100644 (file)
index 0000000..0e1189e
--- /dev/null
@@ -0,0 +1,21 @@
+module topology-lldp-discovery-config {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:topology-lldp-discovery:config";
+    prefix "topology-lldp-discovery-config";
+
+    description
+        "Configuration for Topology LLDP discovery application.";
+
+    revision "2016-05-11" {
+        description
+            "Initial revision.";
+    }
+
+    container topology-lldp-discovery-config {
+        leaf lldp-secure-key {
+            description "Provided key will be used to generate LLDP custom security hash";
+            type string;
+            mandatory true;
+        }
+    }
+}
\ No newline at end of file
index 709da19ae0d180c4706eb907ef6f736fb6181834..8daf8761154505448f4e1b1d8472fd3a6f0d8e4e 100644 (file)
@@ -17,6 +17,7 @@ module topology-lldp-discovery-impl {
     identity topology-lldp-discovery-impl {
         base config:module-type;
         config:java-name-prefix TopologyLldpDiscoveryImpl;
+        status deprecated;
     }
 
     augment "/config:modules/config:module/config:configuration" {
index 4c21c68308a1525107306e410a9ea0a922667cc1..6a9478b9509995079d58d4d759295711cbf3b263 100644 (file)
@@ -6,6 +6,9 @@ Copyright (c) 2014 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
+
+NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for
+       backwards compatibility. Runtime modifications are not honored.
 -->
 <snapshot>
   <required-capabilities>
index 66168949ff76176ea6b4720a82905c4efd1f1328..f49d0f52c63a72d6ef306e5d704d00c023c887ab 100644 (file)
@@ -7,16 +7,13 @@
  */
 package org.opendaylight.openflowplugin.applications.topology.manager;
 
-import java.util.concurrent.ExecutionException;
-
 import com.google.common.base.Optional;
+import java.util.concurrent.ExecutionException;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
@@ -29,34 +26,33 @@ import org.opendaylight.yangtools.yang.binding.NotificationListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class FlowCapableTopologyProvider implements BindingAwareProvider, AutoCloseable {
+public class FlowCapableTopologyProvider implements AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(FlowCapableTopologyProvider.class);
-    private ListenerRegistration<NotificationListener> listenerRegistration;
-    private Thread thread;
-    private TerminationPointChangeListenerImpl terminationPointChangeListener;
-    private NodeChangeListenerImpl nodeChangeListener;
     static final String TOPOLOGY_ID = "flow:1";
 
+    private final DataBroker dataBroker;
+    private final NotificationProviderService notificationService;
+    private final OperationProcessor processor;
+    private ListenerRegistration<NotificationListener> listenerRegistration;
+
+    public FlowCapableTopologyProvider(DataBroker dataBroker, NotificationProviderService notificationService,
+            OperationProcessor processor) {
+        this.dataBroker = dataBroker;
+        this.notificationService = notificationService;
+        this.processor = processor;
+    }
+
     /**
      * Gets called on start of a bundle.
-     *
-     * @param session
      */
-    @Override
-    public synchronized void onSessionInitiated(final ProviderContext session) {
-        final DataBroker dataBroker = session.getSALService(DataBroker.class);
-        final NotificationProviderService notificationService = session.getSALService(NotificationProviderService.class);
-
+    public void start() {
         final TopologyKey key = new TopologyKey(new TopologyId(TOPOLOGY_ID));
         final InstanceIdentifier<Topology> path = InstanceIdentifier
                 .create(NetworkTopology.class)
                 .child(Topology.class, key);
 
-        final OperationProcessor processor = new OperationProcessor(dataBroker);
         final FlowCapableTopologyExporter listener = new FlowCapableTopologyExporter(processor, path);
         this.listenerRegistration = notificationService.registerNotificationListener(listener);
-        this.terminationPointChangeListener = new TerminationPointChangeListenerImpl(dataBroker, processor);
-        nodeChangeListener = new NodeChangeListenerImpl(dataBroker, processor);
 
         if(!isFlowTopologyExist(dataBroker, path)){
             final ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
@@ -68,14 +64,11 @@ public class FlowCapableTopologyProvider implements BindingAwareProvider, AutoCl
             }
         }
 
-        thread = new Thread(processor);
-        thread.setDaemon(true);
-        thread.setName("FlowCapableTopologyExporter-" + TOPOLOGY_ID);
-        thread.start();
+        LOG.info("FlowCapableTopologyProvider started");
     }
 
     @Override
-    public synchronized void close() throws InterruptedException {
+    public void close() {
         LOG.info("FlowCapableTopologyProvider stopped.");
         if (this.listenerRegistration != null) {
             try {
@@ -86,24 +79,6 @@ public class FlowCapableTopologyProvider implements BindingAwareProvider, AutoCl
             }
             listenerRegistration = null;
         }
-        unregisterListener(terminationPointChangeListener);
-        unregisterListener(nodeChangeListener);
-        if (thread != null) {
-            thread.interrupt();
-            thread.join();
-            thread = null;
-        }
-    }
-
-    private static void unregisterListener(final AutoCloseable listenerToClose) {
-        if (listenerToClose != null) {
-            try {
-                listenerToClose.close();
-            } catch (Exception e) {
-                LOG.warn("Failed to close listener registration: {}", e.getMessage());
-                LOG.debug("Failed to close listener registration.. ", e);
-            }
-        }
     }
 
     private boolean isFlowTopologyExist(final DataBroker dataBroker,
index 87fb7354debb21ac8a458f3a7c3c7cb3bd6de118..96365a338868467d728dcd204d384633be24c106 100644 (file)
@@ -20,19 +20,24 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFaile
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-final class OperationProcessor implements AutoCloseable, Runnable, TransactionChainListener {
+public final class OperationProcessor implements AutoCloseable, Runnable, TransactionChainListener {
     private static final Logger LOG = LoggerFactory.getLogger(OperationProcessor.class);
     private static final int MAX_TRANSACTION_OPERATIONS = 100;
     private static final int OPERATION_QUEUE_DEPTH = 500;
 
     private final BlockingQueue<TopologyOperation> queue = new LinkedBlockingQueue<>(OPERATION_QUEUE_DEPTH);
     private final DataBroker dataBroker;
+    private final Thread thread;
     private BindingTransactionChain transactionChain;
     private volatile boolean finishing = false;
 
-    OperationProcessor(final DataBroker dataBroker) {
+    public OperationProcessor(final DataBroker dataBroker) {
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
         transactionChain = this.dataBroker.createTransactionChain(this);
+
+        thread = new Thread(this);
+        thread.setDaemon(true);
+        thread.setName("FlowCapableTopologyExporter-" + FlowCapableTopologyProvider.TOPOLOGY_ID);
     }
 
     void enqueueOperation(final TopologyOperation task) {
@@ -43,6 +48,10 @@ final class OperationProcessor implements AutoCloseable, Runnable, TransactionCh
         }
     }
 
+    public void start() {
+        thread.start();
+    }
+
     @Override
     public void run() {
             while (!finishing) {
@@ -84,7 +93,8 @@ final class OperationProcessor implements AutoCloseable, Runnable, TransactionCh
                     transactionChain = dataBroker.createTransactionChain(this);
                     cleanDataStoreOperQueue();
                 } catch (final InterruptedException e) {
-                    LOG.warn("Stat Manager DS Operation thread interupted!", e);
+                    // This should mean we're shutting down.
+                    LOG.debug("Stat Manager DS Operation thread interupted!", e);
                     finishing = true;
                 } catch (final Exception e) {
                     LOG.warn("Stat DataStore Operation executor fail!", e);
@@ -115,10 +125,18 @@ final class OperationProcessor implements AutoCloseable, Runnable, TransactionCh
     }
 
     @Override
-    public void close() throws Exception {
+    public void close() {
+        thread.interrupt();
+        try {
+            thread.join();
+        } catch(InterruptedException e) {
+            LOG.debug("Join of thread {} was interrupted", thread.getName(), e);
+        }
+
         if (transactionChain != null) {
             transactionChain.close();
         }
 
+        LOG.debug("OperationProcessor closed");
     }
 }
index fb0c504c6676e672551377680e5d313c161a8f7e..e5a3185942f9ff4b3dd6df704281da08d2056edd 100644 (file)
@@ -1,8 +1,12 @@
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.manager.impl.rev150530;
 
-import org.opendaylight.openflowplugin.applications.topology.manager.FlowCapableTopologyProvider;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
 
-public class TopologyLldpDiscoveryImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.manager.impl.rev150530.AbstractTopologyLldpDiscoveryImplModule {
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class TopologyLldpDiscoveryImplModule extends AbstractTopologyLldpDiscoveryImplModule {
     public TopologyLldpDiscoveryImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
@@ -11,16 +15,9 @@ public class TopologyLldpDiscoveryImplModule extends org.opendaylight.yang.gen.v
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
     @Override
     public java.lang.AutoCloseable createInstance() {
-        FlowCapableTopologyProvider provider = new FlowCapableTopologyProvider();
-        getBrokerDependency().registerProvider(provider);
-        return provider;
+        // FlowCapableTopologyProvider instance is created via blueprint so this in a no-op.
+        return NoopAutoCloseable.INSTANCE;
     }
-
 }
index a98e3802f54184699eba57667ff0c8b809fe28c9..32f92de96b2e9e0af0bd96a19f11e0ba245448e1 100644 (file)
@@ -8,6 +8,11 @@
 * Do not modify this file unless it is present under src/main directory
 */
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.manager.impl.rev150530;
-public class TopologyLldpDiscoveryImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.manager.impl.rev150530.AbstractTopologyLldpDiscoveryImplModuleFactory {
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class TopologyLldpDiscoveryImplModuleFactory extends AbstractTopologyLldpDiscoveryImplModuleFactory {
 
 }
diff --git a/applications/topology-manager/src/main/resources/org/opendaylight/blueprint/topology-manager.xml b/applications/topology-manager/src/main/resources/org/opendaylight/blueprint/topology-manager.xml
new file mode 100644 (file)
index 0000000..97827a9
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+  <reference id="notificationService" interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService"/>
+
+  <bean id="operationProcessor" class="org.opendaylight.openflowplugin.applications.topology.manager.OperationProcessor"
+          init-method="start" destroy-method="close">
+    <argument ref="dataBroker"/>
+  </bean>
+
+  <bean id="termPointChangeListener" class="org.opendaylight.openflowplugin.applications.topology.manager.TerminationPointChangeListenerImpl"
+          destroy-method="close">
+    <argument ref="dataBroker"/>
+    <argument ref="operationProcessor"/>
+  </bean>
+
+  <bean id="nodeChangeListener" class="org.opendaylight.openflowplugin.applications.topology.manager.NodeChangeListenerImpl"
+          destroy-method="close">
+    <argument ref="dataBroker"/>
+    <argument ref="operationProcessor"/>
+  </bean>
+
+  <bean id="topologyProvider" class="org.opendaylight.openflowplugin.applications.topology.manager.FlowCapableTopologyProvider"
+          init-method="start" destroy-method="close">
+    <argument ref="dataBroker"/>
+    <argument ref="notificationService"/>
+    <argument ref="operationProcessor"/>
+  </bean>
+</blueprint>
\ No newline at end of file
index e6fe667f35003f04cb0a08f4f94019ff417bded6..35ea8cc85add188888c87dafb22151b98e4b1f10 100644 (file)
@@ -17,6 +17,7 @@ module topology-manager-impl {
     identity topology-manager-impl {
         base config:module-type;
         config:java-name-prefix TopologyLldpDiscoveryImpl;
+        status deprecated;
     }
 
     augment "/config:modules/config:module/config:configuration" {
index 4ab88331e3a1385a320e2ac8f3364cd919689c05..4aa08b00288f215fe1ec111544d5600e9e025941 100644 (file)
@@ -29,7 +29,7 @@ public class FlowRemovedTranslator implements MessageTranslator<FlowRemoved, org
                 .setCookie(new FlowCookie(input.getCookie()))
                 .setNode(new NodeRef(deviceState.getNodeInstanceIdentifier()))
                 .setPriority(input.getPriority())
-                .setTableId(input.getTableId().getValue().shortValue());
+                .setTableId(translateTableId(input));
 
         return flowRemovedBld.build();
     }
@@ -38,4 +38,14 @@ public class FlowRemovedTranslator implements MessageTranslator<FlowRemoved, org
         return MatchConvertorImpl.fromOFMatchToSALMatch(flowRemoved.getMatch(),
                 deviceState.getFeatures().getDatapathId(), OpenflowVersion.OF13);
     }
+
+    /**
+     * Translate the table ID in the FLOW_REMOVED message to SAL table ID.
+     *
+     * @param flowRemoved  FLOW_REMOVED message.
+     * @return  SAL table ID.
+     */
+    protected Short translateTableId(FlowRemoved flowRemoved) {
+        return flowRemoved.getTableId().getValue().shortValue();
+    }
 }
index d951273edaff8fafbe4073c0892e4c37ad8a1a30..23efec2ed636a1c5f06feb76987e7b5278c901e1 100644 (file)
@@ -24,4 +24,15 @@ public class FlowRemovedV10Translator extends FlowRemovedTranslator {
         return MatchConvertorImpl.fromOFMatchV10ToSALMatch(flowRemoved.getMatchV10(),
                 deviceState.getFeatures().getDatapathId(), OpenflowVersion.OF10);
     }
+
+    /**
+     * Always returns zero because OF10 FLOW_REMOVED doesn't contain table ID.
+     *
+     * @param flowRemoved  FLOW_REMOVED message.
+     * @return  Zero.
+     */
+    @Override
+    protected Short translateTableId(FlowRemoved flowRemoved) {
+        return Short.valueOf((short)0);
+    }
 }
index a695ef097017dbdde2df959cea31b6d0ac9061cd..823a5b14651c24b875f6315b5d7d5999706b741e 100644 (file)
@@ -91,21 +91,21 @@ public class FlowRemovedTranslatorTest {
 
         assertEquals(flowRemovedMessage.getCookie(), flowRemoved.getCookie().getValue());
         assertEquals(flowRemovedMessage.getPriority(), flowRemoved.getPriority());
-        assertEquals((long)flowRemovedMessage.getTableId().getValue(), (long)flowRemoved.getTableId());
+        assertEquals((short)0, flowRemoved.getTableId().shortValue());
     }
 
     private org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved buildMessage(boolean isV10) {
         FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder()
                 .setCookie(BigInteger.ONE)
-                .setPriority(1)
-                .setTableId(new TableId(42l));
+                .setPriority(1);
 
         if (isV10) {
             builder.setMatchV10(new MatchV10Builder().setWildcards(flowWildcards).build());
         } else {
-            builder.setMatch(new MatchBuilder().setMatchEntry(Collections.<MatchEntry>emptyList()).build());
+            builder.setMatch(new MatchBuilder().setMatchEntry(Collections.<MatchEntry>emptyList()).build())
+                .setTableId(new TableId(42l));
         }
 
         return builder.build();
     }
-}
\ No newline at end of file
+}