Merge "TxChaingManager logging changed to warning"
authormichal rehak <mirehak@cisco.com>
Wed, 29 Apr 2015 04:07:54 +0000 (04:07 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 29 Apr 2015 04:07:54 +0000 (04:07 +0000)
applications/table-miss-enforcer/pom.xml
applications/table-miss-enforcer/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/table/miss/enforcer/rev140326/LLDPPacketPuntEnforcerModule.java
applications/topology-manager/pom.xml
applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/DataChangeListenerImpl.java
features-li/src/main/resources/features.xml
features/src/main/resources/features.xml
test-common/pom.xml
test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/AbstractDropTest.java
test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestCommiter.java
test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestRpcSender.java

index a15f63742abda12df2f2990a885f99766a55150b..d73ed15ec6ad4be3bdca62d463cd13196d27049a 100644 (file)
           <groupId>org.opendaylight.openflowplugin</groupId>
           <artifactId>openflowplugin-api</artifactId>
       </dependency>
+      <dependency>
+          <groupId>org.opendaylight.openflowplugin</groupId>
+          <artifactId>openflowplugin-common</artifactId>
+      </dependency>
+
       <dependency>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>sal-binding-api</artifactId>
@@ -53,8 +58,8 @@
              <groupId>org.opendaylight.yangtools</groupId>
              <artifactId>yang-maven-plugin</artifactId>
          </plugin>
-         
-          <plugin>
+
+         <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>build-helper-maven-plugin</artifactId>
           <executions>
index fca8a634130646e0be72647e67abd06eba81ec49..39b506212ede21d8b53a4fde1f86742c302e9617 100644 (file)
@@ -1,15 +1,25 @@
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.table.miss.enforcer.rev140326;
 
+import java.util.concurrent.Callable;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.applications.tableMissEnforcer.LLDPPacketPuntEnforcer;
+import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
 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.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class LLDPPacketPuntEnforcerModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.table.miss.enforcer.rev140326.AbstractLLDPPacketPuntEnforcerModule {
+    private static final long STARTUP_LOOP_TICK = 500L;
+    private static final int STARTUP_LOOP_MAX_RETRIES = 8;
+    private static Logger LOG = LoggerFactory.getLogger(LLDPPacketPuntEnforcerModule.class);
+
     public LLDPPacketPuntEnforcerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
@@ -25,13 +35,28 @@ public class LLDPPacketPuntEnforcerModule extends org.opendaylight.yang.gen.v1.u
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class);
-        SalFlowService salFlowService = getRpcRegistryDependency().getRpcService(SalFlowService.class);
-        return getDataBrokerDependency().registerDataChangeListener(
-                LogicalDatastoreType.OPERATIONAL,
-                path,
-                new LLDPPacketPuntEnforcer(salFlowService),
-                AsyncDataBroker.DataChangeScope.BASE);
+        final InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class);
+        final SalFlowService salFlowService = getRpcRegistryDependency().getRpcService(SalFlowService.class);
+
+        ListenerRegistration<DataChangeListener> dataChangeListenerRegistration;
+        SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
+        try {
+            dataChangeListenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<DataChangeListener>>() {
+                @Override
+                public ListenerRegistration<DataChangeListener> call() throws Exception {
+                    return getDataBrokerDependency().registerDataChangeListener(
+                            LogicalDatastoreType.OPERATIONAL,
+                            path,
+                            new LLDPPacketPuntEnforcer(salFlowService),
+                            AsyncDataBroker.DataChangeScope.BASE);
+                }
+            });
+        } catch (Exception e) {
+            LOG.warn("data listener registration failed: {}", e.getMessage());
+            LOG.debug("data listener registration failed.. ", e);
+            throw new IllegalStateException("LLDPPacketPuntEnforcer startup fail! System needs restart.", e);
+        }
+        return dataChangeListenerRegistration;
     }
 
 }
index 0f337ad0ce72f7c04c35de5f83f59958fa0d37e7..5a89417dad5333bf5a19d10481e2b47efa1cad1e 100644 (file)
       <groupId>org.opendaylight.openflowplugin.model</groupId>
       <artifactId>model-flow-service</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.openflowplugin</groupId>
+      <artifactId>openflowplugin-common</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller.model</groupId>
       <artifactId>model-inventory</artifactId>
index 39653d5040c217d7203644b40dbafa68c7f57b2d..4f192133ddf56214339b9fbf8a47fd9ba9645a7d 100644 (file)
@@ -7,28 +7,31 @@
  */
 package org.opendaylight.openflowplugin.applications.topology.manager;
 
+import java.util.concurrent.Callable;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
 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.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 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.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public abstract class DataChangeListenerImpl implements DataChangeListener, AutoCloseable {
 
     private final static Logger LOG = LoggerFactory.getLogger(DataChangeListenerImpl.class);
+    private static final long STARTUP_LOOP_TICK = 500L;
+    private static final int STARTUP_LOOP_MAX_RETRIES = 8;
     protected final ListenerRegistration<DataChangeListener> dataChangeListenerRegistration;
     protected OperationProcessor operationProcessor;
 
@@ -47,8 +50,22 @@ public abstract class DataChangeListenerImpl implements DataChangeListener, Auto
      */
     public DataChangeListenerImpl(final OperationProcessor operationProcessor, final DataBroker dataBroker,
             final InstanceIdentifier<?> ii) {
-        dataChangeListenerRegistration = dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, ii,
-                this, AsyncDataBroker.DataChangeScope.BASE);
+        SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
+        try {
+            dataChangeListenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<DataChangeListener>>() {
+                @Override
+                public ListenerRegistration<DataChangeListener> call() throws Exception {
+                    return dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, ii,
+                            DataChangeListenerImpl.this, AsyncDataBroker.DataChangeScope.BASE);
+
+                }
+            });
+        } catch (Exception e) {
+            LOG.warn("data listener registration failed: {}", e.getMessage());
+            LOG.debug("data listener registration failed.. ", e);
+            throw new IllegalStateException("TopologyManager startup fail! TM bundle needs restart.", e);
+        }
+
         this.operationProcessor = operationProcessor;
     }
 
index e0f1ae0a4bb00d62fcf41e95704d510e273d5d37..14d50e6965a2a4e14a024b186fb141629a056e1d 100644 (file)
@@ -29,6 +29,7 @@
         <feature version="${mdsal.version}">odl-mdsal-broker</feature>
         <feature version="${project.version}">odl-openflowplugin-nsf-services-li</feature>
         <feature version="${openflowjava.version}">odl-openflowjava-protocol</feature>
+        <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-common/${project.version}</bundle>
         <!-- TODO : remove dependency on openflowplugin in the future -->
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin/${project.version}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-impl/${project.version}</bundle>
index a8ca229d1fe0d4fc14acdcbeb0b8a0b08628e473..e8ba45cd65bef8983f0e441cee80a0d0309a59d5 100644 (file)
@@ -29,6 +29,7 @@
         <feature version="${mdsal.version}">odl-mdsal-broker</feature>
         <feature version="${project.version}">odl-openflowplugin-nsf-model</feature>
         <feature version="${openflowjava.version}">odl-openflowjava-protocol</feature>
+        <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-common/${project.version}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin/${project.version}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-api/${project.version}</bundle>
         <bundle>mvn:org.opendaylight.openflowplugin/openflowplugin-extension-api/${project.version}</bundle>
index 454db66cdad78d8272138afe0133326522660c7c..07211ea811c4d97c55315ee6fc0b9df9111a9747 100644 (file)
@@ -14,7 +14,7 @@
         <connection>scm:git:ssh://git.opendaylight.org:29418/openflowplugin.git</connection>
         <developerConnection>scm:git:ssh://git.opendaylight.org:29418/openflowplugin.git</developerConnection>
     </scm>
-    
+
     <dependencies>
         <dependency>
             <groupId>com.google.guava</groupId>
             <groupId>org.opendaylight.openflowjava</groupId>
             <artifactId>util</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.openflowplugin</groupId>
+            <artifactId>openflowplugin-common</artifactId>
+        </dependency>
     </dependencies>
 
     <build>
index 4707573098f9a86a55f53cc7d219961878e6c8be..665ebfe48273dc5682ad0aad32fd1f36f5cbbe5a 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * <p/>
  * 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
@@ -47,6 +47,9 @@ abstract class AbstractDropTest implements PacketProcessingListener, AutoCloseab
     protected static final Integer IDLE_TIMEOUT = 240;
     protected static final short TABLE_ID = 0;
 
+    static final long STARTUP_LOOP_TICK = 500L;
+    static final int STARTUP_LOOP_MAX_RETRIES = 8;
+
     private static final AtomicIntegerFieldUpdater<AbstractDropTest> SENT_UPDATER = AtomicIntegerFieldUpdater.newUpdater(AbstractDropTest.class, "sent");
     private volatile int sent;
 
@@ -60,7 +63,7 @@ abstract class AbstractDropTest implements PacketProcessingListener, AutoCloseab
         return new DropTestStats(this.sent, this.rcvd, this.excs);
     }
 
-    public final void clearStats(){
+    public final void clearStats() {
         this.sent = 0;
         this.rcvd = 0;
         this.excs = 0;
index 28ee0ee92e10fb1856dbf5398f477074bfb7e924..0de0f82c2e65fd75b26156587278f998ff004a27 100644 (file)
@@ -8,11 +8,13 @@
 package org.opendaylight.openflowplugin.testcommon;
 
 import java.math.BigInteger;
+import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicLong;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
 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.tables.Table;
@@ -71,7 +73,20 @@ public class DropTestCommiter extends AbstractDropTest {
      * start listening on packetIn
      */
     public void start() {
-        notificationRegistration = notificationService.registerNotificationListener(this);
+        SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK,
+                STARTUP_LOOP_MAX_RETRIES);
+        try {
+            notificationRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<NotificationListener>>() {
+                @Override
+                public ListenerRegistration<NotificationListener> call() throws Exception {
+                    return notificationService.registerNotificationListener(DropTestCommiter.this);
+                }
+            });
+        } catch (Exception e) {
+            LOG.warn("DropTest committer notification listener registration fail!");
+            LOG.debug("DropTest committer notification listener registration fail! ..", e);
+            throw new IllegalStateException("DropTest startup fail! Try again later.", e);
+        }
     }
 
     /**
index 30089b69a18688d694648d85ffac5c17c0682167..8c4b5c9fcab3f1716b06ca3522a398efdb0cbc7a 100644 (file)
@@ -7,14 +7,10 @@
  */
 package org.opendaylight.openflowplugin.testcommon;
 
-import static org.opendaylight.openflowplugin.testcommon.AbstractDropTest.BUFFER_ID;
-import static org.opendaylight.openflowplugin.testcommon.AbstractDropTest.HARD_TIMEOUT;
-import static org.opendaylight.openflowplugin.testcommon.AbstractDropTest.IDLE_TIMEOUT;
-import static org.opendaylight.openflowplugin.testcommon.AbstractDropTest.PRIORITY;
-import static org.opendaylight.openflowplugin.testcommon.AbstractDropTest.TABLE_ID;
-
 import java.math.BigInteger;
+import java.util.concurrent.Callable;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
@@ -76,7 +72,20 @@ public class DropTestRpcSender extends AbstractDropTest {
      * start listening on packetIn
      */
     public void start() {
-        notificationRegistration = notificationService.registerNotificationListener(this);
+        SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK,
+                STARTUP_LOOP_MAX_RETRIES);
+        try {
+            notificationRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<NotificationListener>>() {
+                @Override
+                public ListenerRegistration<NotificationListener> call() throws Exception {
+                    return notificationService.registerNotificationListener(DropTestRpcSender.this);
+                }
+            });
+        } catch (Exception e) {
+            LOG.warn("DropTest sender notification listener registration fail!");
+            LOG.debug("DropTest sender notification listener registration fail! ..", e);
+            throw new IllegalStateException("DropTest startup fail! Try again later.", e);
+        }
     }
 
     @Override