Merge changes I67420353,I6851f9b9
authorTony Tkacik <ttkacik@cisco.com>
Wed, 23 Apr 2014 11:48:59 +0000 (11:48 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 23 Apr 2014 11:48:59 +0000 (11:48 +0000)
* changes:
  Bug:701-Have Typed ErrorNotification for different node errors
  Bug:645 - MDSAL Notification pool threads not getting spawned besides the core threads

opendaylight/md-sal/model/model-flow-service/src/main/yang/node-errors.yang [new file with mode: 0644]
opendaylight/md-sal/model/model-flow-service/src/main/yang/sal-flow.yang
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolder.java

diff --git a/opendaylight/md-sal/model/model-flow-service/src/main/yang/node-errors.yang b/opendaylight/md-sal/model/model-flow-service/src/main/yang/node-errors.yang
new file mode 100644 (file)
index 0000000..a8eec26
--- /dev/null
@@ -0,0 +1,168 @@
+module node-error {
+    namespace "urn:opendaylight:node:error:service";
+    prefix node-error;
+
+    import sal-flow {prefix flow; revision-date "2013-08-19";}
+    import flow-errors {prefix error;}
+    import flow-capable-transaction {prefix tr;}
+    import yang-ext {prefix ext; revision-date "2013-07-09";}
+    import opendaylight-inventory {prefix inv;revision-date "2013-08-19";}
+    import opendaylight-flow-types {prefix types;revision-date "2013-10-26";}
+    import opendaylight-group-types {prefix group-type;revision-date 2013-10-18;}
+    import opendaylight-meter-types {prefix meter-type;revision-date "2013-09-18";}
+
+    revision "2014-04-10" {
+        description "Initial revision of errors received from a node";
+    }
+
+    notification hello-failed-error-notification {
+        description "Model for ofp_error-Type=0, Hello protocol failed";
+
+        uses error:error-message;
+        uses tr:transaction-aware;
+        uses tr:transaction-metadata;
+        uses flow:base-node-error-notification;
+        uses flow:node-error-reference;
+    }
+
+    notification bad-request-error-notification {
+        description "Model for ofp_error-Type=1, Request was not understood.";
+
+        uses error:error-message;
+        uses tr:transaction-aware;
+        uses tr:transaction-metadata;
+        uses flow:base-node-error-notification;
+        uses flow:node-error-reference;
+    }
+
+    notification bad-action-error-notification {
+        description "Model for ofp_error-Type=2, Error in action description.";
+
+        uses error:error-message;
+        uses tr:transaction-aware;
+        uses tr:transaction-metadata;
+        uses flow:base-node-error-notification;
+        uses flow:node-error-reference;
+    }
+
+    notification bad-instruction-error-notification {
+            description "Model for ofp_error-Type=3, Error in instruction list.";
+
+            uses error:error-message;
+            uses tr:transaction-aware;
+            uses tr:transaction-metadata;
+            uses flow:base-node-error-notification;
+            uses flow:node-error-reference;
+        }
+
+    notification bad-match-error-notification {
+            description "Model for ofp_error-Type=4, Error in match.";
+
+            uses error:error-message;
+            uses tr:transaction-aware;
+            uses tr:transaction-metadata;
+            uses flow:base-node-error-notification;
+            uses flow:node-error-reference;
+        }
+
+    notification flow-mod-error-notification {
+            description "Model for ofp_error-Type=5 - Problem modifying flow entry.";
+
+            uses error:error-message;
+            uses tr:transaction-aware;
+            uses tr:transaction-metadata;
+            uses flow:base-node-error-notification;
+            uses flow:node-error-reference;
+            uses flow:node-error-reference;
+        }
+
+    notification group-mod-error-notification {
+            description "Model for ofp_error-Type=6 - Problem modifying group entry.";
+
+            uses error:error-message;
+            uses tr:transaction-aware;
+            uses tr:transaction-metadata;
+            uses flow:base-node-error-notification;
+            uses flow:node-error-reference;
+        }
+
+    notification port-mod-error-notification {
+            description "Model for ofp_error-Type=7 - Port mod request failed.";
+
+            uses error:error-message;
+            uses tr:transaction-aware;
+            uses tr:transaction-metadata;
+            uses flow:base-node-error-notification;
+            uses flow:node-error-reference;
+        }
+
+    notification table-mod-error-notification {
+            description "Model for ofp_error-Type=8 - Table mod request failed.";
+
+            uses error:error-message;
+            uses tr:transaction-aware;
+            uses tr:transaction-metadata;
+            uses flow:base-node-error-notification;
+            uses flow:node-error-reference;
+        }
+
+    notification queue-op-error-notification {
+            description "Model for ofp_error-Type=9 - Queue operation failed.";
+
+            uses error:error-message;
+            uses tr:transaction-aware;
+            uses tr:transaction-metadata;
+            uses flow:base-node-error-notification;
+            uses flow:node-error-reference;
+        }
+
+    notification switch-config-error-notification {
+            description "Model for ofp_error-Type=10 - Switch Config request failed.";
+
+            uses error:error-message;
+            uses tr:transaction-aware;
+            uses tr:transaction-metadata;
+            uses flow:base-node-error-notification;
+            uses flow:node-error-reference;
+        }
+
+    notification role-request-error-notification {
+            description "Model for ofp_error-Type=11 - Controller Role request failed.";
+
+            uses error:error-message;
+            uses tr:transaction-aware;
+            uses tr:transaction-metadata;
+            uses flow:base-node-error-notification;
+            uses flow:node-error-reference;
+        }
+
+    notification meter-mod-error-notification {
+            description "Model for ofp_error-Type=12 - Error in meter.";
+
+            uses error:error-message;
+            uses tr:transaction-aware;
+            uses tr:transaction-metadata;
+            uses flow:base-node-error-notification;
+            uses flow:node-error-reference;
+        }
+
+    notification table-features-error-notification {
+            description "Model for ofp_error-Type=13 - Setting table features failed.";
+
+            uses error:error-message;
+            uses tr:transaction-aware;
+            uses tr:transaction-metadata;
+            uses flow:base-node-error-notification;
+            uses flow:node-error-reference;
+        }
+
+    notification experimenter-error-notification {
+            description "Model for ofp_error-Type=65535  - Experimenter Error Messages";
+            uses error:error-message;
+            uses tr:transaction-aware;
+            uses tr:transaction-metadata;
+            uses flow:base-node-error-notification;
+            uses flow:node-error-reference;
+        }
+}
+
index b3e6e450af8c3f9d4b0d593b91547e0f48023620..4cb1d08917a5040e06397d334df383cb99cac35e 100644 (file)
@@ -38,6 +38,33 @@ module sal-flow {
         uses types:flow;
     }
 
+    grouping base-node-error-notification {
+        leaf node {
+            ext:context-reference "inv:node-context";
+                type inv:node-ref;
+        }
+    }
+
+    grouping node-error-reference {
+        choice object-reference {
+            case flow-ref{
+                leaf flow-ref {
+                        type types:flow-ref;
+                }
+            }
+            case group-ref{
+                leaf group-ref {
+                    type group-type:group-ref;
+                }
+            }
+            case meter-ref{
+                leaf meter-ref {
+                    type meter-type:meter-ref;
+                }
+            }
+        }
+    }
+
     /** Base configuration structure **/
     grouping flow-update {
         uses "inv:node-context-ref";
@@ -124,28 +151,8 @@ module sal-flow {
         uses error:error-message;
         uses tr:transaction-aware;
         uses tr:transaction-metadata;
-        choice object-reference {
-        case flow-ref{
-                   leaf flow-ref {
-            type types:flow-ref;
-         }
-       }
-        case group-ref{
-                   leaf group-ref {
-            type group-type:group-ref;
-         }
-       }
-        case meter-ref{
-                   leaf meter-ref {
-            type meter-type:meter-ref;
-         }
-       }
-     }
-        leaf node {
-            ext:context-reference "inv:node-context";
-            type inv:node-ref;
-        }
-        
+        uses node-error-reference;
+        uses base-node-error-notification;
     }
     
     notification node-experimenter-error-notification {
index 4deef69198216c5d0f6fe1578caccee90dbc1458..ac26445bf408677b6e397c9fbb77bcf4fcaa19de 100644 (file)
@@ -7,22 +7,22 @@
  */
 package org.opendaylight.controller.sal.binding.codegen.impl;
 
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import javassist.ClassPool;
+import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator;
+import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory;
+
+import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionHandler;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
-import javassist.ClassPool;
-
-import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator;
-import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory;
-
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
 public class SingletonHolder {
 
     public static final ClassPool CLASS_POOL = ClassPool.getDefault();
@@ -45,12 +45,43 @@ public class SingletonHolder {
      */
     @Deprecated
     public static synchronized final ListeningExecutorService getDefaultNotificationExecutor() {
+
         if (NOTIFICATION_EXECUTOR == null) {
+            // Overriding the queue since we need an unbounded queue
+            // and threadpoolexecutor would not create new threads if the queue is not full
+            BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>() {
+                @Override
+                public boolean offer(Runnable r) {
+                    if (size() <= 1) {
+                        // if the queue is empty (or has just 1), no need to rampup the threads
+                        return super.offer(r);
+                    } else {
+                        // if the queue is not empty, force the queue to return false.
+                        // threadpoolexecutor will spawn a new thread if the queue.offer returns false.
+                        return false;
+                    }
+                }
+            };
+
             ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("md-sal-binding-notification-%d").build();
-            ExecutorService executor = new ThreadPoolExecutor(CORE_NOTIFICATION_THREADS, MAX_NOTIFICATION_THREADS,
-                    NOTIFICATION_THREAD_LIFE, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), factory);
+
+            ThreadPoolExecutor executor = new ThreadPoolExecutor(CORE_NOTIFICATION_THREADS, MAX_NOTIFICATION_THREADS,
+                    NOTIFICATION_THREAD_LIFE, TimeUnit.SECONDS, queue , factory,
+                    new RejectedExecutionHandler() {
+                        // if the max threads are met, then it will raise a rejectedExecution. We then push to the queue.
+                        @Override
+                        public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+                            try {
+                                executor.getQueue().put(r);
+                            } catch (InterruptedException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    });
+
             NOTIFICATION_EXECUTOR = MoreExecutors.listeningDecorator(executor);
         }
+
         return NOTIFICATION_EXECUTOR;
     }