Merge "Topology Manager changes for cross checking Production switches"
authorJason Ye <yisye@cisco.com>
Sun, 17 Nov 2013 19:45:23 +0000 (19:45 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Sun, 17 Nov 2013 19:45:23 +0000 (19:45 +0000)
20 files changed:
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BlankTransactionServiceTracker.java
opendaylight/forwardingrulesmanager_mdsal/openflow/src/main/java/org/opendaylight/controller/forwardingrulesmanager_mdsal/consumer/impl/FlowConsumerImpl.java
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FlowProgrammerAdapter.xtend
opendaylight/md-sal/model/model-flow-base/src/main/yang/group-types.yang
opendaylight/md-sal/model/model-flow-base/src/main/yang/meter-types.yang
opendaylight/md-sal/model/model-flow-service/src/main/yang/flow-error.yang [new file with mode: 0644]
opendaylight/md-sal/model/model-flow-service/src/main/yang/flow-service.yang
opendaylight/md-sal/model/model-flow-statistics/src/main/yang/group-statistics.yang
opendaylight/md-sal/model/model-flow-statistics/src/main/yang/meter-statistics.yang
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NoficationTest.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonReader.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/CompositeNodeWrapper.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/SimpleNodeWrapper.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlProvidersTest.java
opendaylight/md-sal/statistics-manager/pom.xml
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatistics.java
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsManagerActivator.java
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsUpdateCommiter.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java

index 106a7fbb2be8ced7bfb2d054b296b9a86e0462d7..de1a425ce64813f5c783c710367cee51232e66fc 100644 (file)
@@ -37,7 +37,7 @@ public class BlankTransactionServiceTracker implements ServiceTrackerCustomizer<
         return null;
     }
 
-    private void blankTransaction() {
+    private synchronized void blankTransaction() {
         // create transaction
         ObjectName tx = configRegistry.beginConfig();
         CommitStatus commitStatus = configRegistry.commitConfig(tx);
index d17bf8da11dbbeb9f012589c49297faf535b71bf..1ff7a98ebb816f07ede8e891c71c152ae46447b2 100644 (file)
@@ -35,6 +35,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddF
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
@@ -492,6 +494,19 @@ public class FlowConsumerImpl implements IForwardingRulesManager {
         @Override
         public void onSwitchFlowRemoved(SwitchFlowRemoved notification) {
             // TODO
+        }
+
+        @Override
+        public void onNodeErrorNotification(NodeErrorNotification notification) {
+            // TODO Auto-generated method stub
+            
+        }
+
+        @Override
+        public void onNodeExperimenterErrorNotification(
+                NodeExperimenterErrorNotification notification) {
+            // TODO Auto-generated method stub
+            
         };
 
     }
index 15f0685819d0921cdf81f730499ac842271cd59e..2eae511e02975e6aa23f9d2a09091fa186ab3764 100644 (file)
@@ -13,6 +13,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.Swit
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification
 import org.opendaylight.yangtools.yang.common.RpcResult
 import org.slf4j.LoggerFactory
 
@@ -137,4 +139,12 @@ class FlowProgrammerAdapter implements IPluginInFlowProgrammerService, SalFlowLi
         // NOOP : Not supported by AD SAL
     }
     
+     override onNodeErrorNotification(NodeErrorNotification notification) {
+        // NOOP : Not supported by AD SAL
+    }
+    
+     override onNodeExperimenterErrorNotification(
+                NodeExperimenterErrorNotification notification) {
+        // NOOP : Not supported by AD SAL
+    }
 }
index 685728a88709cac4396294e375f22943113de17c..97ca8b3c71491063d21ac4284b62e537c3b56dd6 100644 (file)
@@ -73,16 +73,6 @@ module opendaylight-group-types {
         }
     }
     
-    grouping group-statistics-request {
-        list group-stats {
-            key "group-id";         
-            
-            leaf group-id {
-                type int32;
-            }           
-        }
-    }
-    
     grouping group-statistics {
             
         leaf group-id {
@@ -128,7 +118,44 @@ module opendaylight-group-types {
         }       
     }
 
+    grouping group-features {
+        uses group-types;
+            
+        leaf capabilities { 
+               type enumeration {
+                enum select-weight;
+                enum select-liveness;
+                enum chaining;
+                enum chaining-checks;
+            }   
+        }
+
+        leaf-list max-groups {
+            type uint32;
+            description "Maximum number of groups for each type";
+            max-elements 4;
+        }
+            
+        leaf-list actions {
+            type uint32;
+            description "Bitmap number OFPAT_* that are supported";
+            max-elements 4;
+        }
+    }
+    
+    grouping group-statistics-request {
+        list group-stats {
+            key "group-id";         
+            
+            leaf group-id {
+                type int32;
+            }           
+        }
+    }
+    
+    
     grouping group-statistics-reply {
+       
         list group-stats {
             key "group-stats-order";
             leaf group-stats-order {
@@ -139,10 +166,10 @@ module opendaylight-group-types {
         }
     }
     
-    grouping group-desc-stats {
+    grouping group-desc-stats-reply {
+       
         list group-desc-stats {
             key "order-id";         
-            
             leaf order-id {
                 type int32;
             }
@@ -151,35 +178,8 @@ module opendaylight-group-types {
         }
     }
     
-    grouping group-features {
-        list group-features {
-            key "order";
-            leaf order {
-                type int32;
-            }
-            
-            uses group-types;
-            
-            leaf capabilities { 
-                type enumeration {
-                    enum select-weight;
-                    enum select-liveness;
-                    enum chaining;
-                    enum chaining-checks;
-                }   
-            }
-
-            leaf-list max-groups {
-                type uint32;
-                description "Maximum number of groups for each type";
-                max-elements 4;
-            }
-            
-            leaf-list actions {
-                type uint32;
-                description "Bitmap number OFPAT_* that are supported";
-                max-elements 4;
-            }
-        }
-    }    
+    grouping group-features-reply {
+       uses group-features;
+    }
+    
 }
\ No newline at end of file
index 148ac9687f5baa8d66fa0fbfb143d91b6fdafb6f..d26ca667996f164f9ca7f8b57c6df25a7c381563 100644 (file)
@@ -119,16 +119,6 @@ module opendaylight-meter-types {
         }
     }
     
-    grouping meter-stats-config-request {
-        list meter-stats {
-            key "meter-id";         
-            
-            leaf meter-id {
-                type int32;
-            }           
-        }
-    }
-    
     grouping meter-statistics {
             
         leaf meter-id {
@@ -174,6 +164,39 @@ module opendaylight-meter-types {
         }
     }
 
+    grouping meter-features {
+                           
+        leaf max_meter {
+            type yang:counter32;
+        }
+           
+        leaf band_types {
+            type yang:counter32;
+        }
+        
+        leaf capabilities {
+            type yang:counter32;
+        }
+        
+        leaf max_bands {
+            type uint8;
+        }
+        
+        leaf max_color {
+            type uint8;
+        }
+    }
+
+    grouping meter-stats-config-request {
+        list meter-stats {
+            key "meter-id";         
+            
+            leaf meter-id {
+                type int32;
+            }           
+        }
+    }
+    
     grouping meter-statistics-reply {
         list meter-stats {
             key "meter-stats-order";
@@ -184,10 +207,9 @@ module opendaylight-meter-types {
         }
     }
     
-    grouping meter-config-stats {
+    grouping meter-config-stats-reply {
         list meter-config-stats {
             key "meter-config-order";
-            
             leaf meter-config-order {
                 type int32;
             }
@@ -196,33 +218,8 @@ module opendaylight-meter-types {
         } 
     }
     
-    grouping meter-features {
-        list meter-features {
-            key "meter-feature-order";
-            
-            leaf meter-feature-order {
-                type yang:counter32;
-            }          
-            
-            leaf max_meter {
-                type yang:counter32;
-            }
-            
-            leaf band_types {
-                type yang:counter32;
-            }
-            
-            leaf capabilities {
-                type yang:counter32;
-            }
-            
-            leaf max_bands {
-                type uint8;
-            }
-            
-            leaf max_color {
-                type uint8;
-            }
-        }
-    }    
+    grouping meter-features-reply {
+       uses meter-features;
+    }
+    
 }
\ No newline at end of file
diff --git a/opendaylight/md-sal/model/model-flow-service/src/main/yang/flow-error.yang b/opendaylight/md-sal/model/model-flow-service/src/main/yang/flow-error.yang
new file mode 100644 (file)
index 0000000..171f956
--- /dev/null
@@ -0,0 +1,60 @@
+module flow-errors {
+       namespace "urn:opendaylight:flow:errors";
+    prefix error;
+    
+    revision "2013-11-16" {
+        description "Initial revision of error";
+    }
+
+    typedef error-type {
+        type enumeration {
+            enum hello-failed;
+            enum bad-request;
+            enum bad-action;
+            enum bad-instruction;
+            enum bad-match;
+            enum flow-mod-failed;
+            enum group-mod-failed;
+            enum port-mod-failed;
+            enum table-mod-failed;
+            enum meter-mod-failed;
+            enum queue-op-failed;
+            enum switch-config-failed;
+            enum role-request-failed;
+            enum table-features-failed;
+            enum experimenter;
+        }
+    }
+    
+    grouping error-message {
+        leaf type {
+            type error-type;
+        }
+        
+        leaf code {
+            type uint16;        
+        }
+        
+        leaf data {
+            type string;
+        }
+    }
+    
+    grouping experimenter-error-message {
+        leaf type {
+            type error-type;
+        }
+        
+        leaf exp-type {
+            type uint16;        
+        }
+        
+        leaf experimenter-id {
+            type uint32;        
+        }
+        
+        leaf data {
+            type string;
+        }
+    }   
+}
\ No newline at end of file
index f8589193d7cba41d76789782619c700243fceae9..df0b2527b8731c4036d902d481d7adee1b1e7233 100644 (file)
@@ -7,6 +7,7 @@ module sal-flow {
     import ietf-inet-types {prefix inet; revision-date "2010-09-24";}
     import opendaylight-flow-types {prefix types;revision-date "2013-10-26";}
     import flow-capable-transaction {prefix tr;}
+    import flow-errors {prefix error;}
 
     revision "2013-08-19" {
         description "Initial revision of flow service";
@@ -93,4 +94,12 @@ module sal-flow {
     notification switch-flow-removed {
         uses node-flow-removed;
     }
+    
+    notification node-error-notification {
+        uses error:error-message;
+    }
+    
+    notification node-experimenter-error-notification {
+        uses error:experimenter-error-message;
+    }
 }
\ No newline at end of file
index c1740d8abd27fa04c38fc88670cc755501adff65..e6f166ac02d224f9ab57a2080851e5300e4d686c 100644 (file)
@@ -7,65 +7,45 @@ module opendaylight-group-statistics {
     import opendaylight-group-types {prefix group-types;revision-date "2013-10-18";}
     import flow-capable-transaction {prefix tr;}
     
+    contact
+       "Anilkumar Vishnoi
+       Email: avishnoi@in.ibm.com";
+               
     revision "2013-11-11" {
         description "Initial revision of group statistics service";
     }
     
-    typedef group-stats-ref {
-        type instance-identifier;
-    }
-    
-    grouping group-stats-response {
-        uses "inv:node-context-ref";
-
-        list group-statistics{
-               uses group-types:group-statistics;
+    augment "/inv:nodes/inv:node" {
+        ext:augment-identifier "node-group-statistics";
+        container group-statistics {
+               config "false";
+               uses group-types:group-statistics-reply;
         }
     }
 
-    typedef group-features-ref {
-        type instance-identifier;
-    }
-    
-    grouping group-features-response {
-        uses "inv:node-context-ref";
-
-        uses group-types:group-features;
-    }
-
-    typedef group-desc-ref {
-        type instance-identifier;
-    }
-    
-    grouping group-desc-response {
-        uses "inv:node-context-ref";
-
-        list group-desc-stats {
-               uses group-types:group-desc-stats;
+       augment "/inv:nodes/inv:node" {
+        ext:augment-identifier "node-group-desc-stats";
+        container group-desc {
+               config "false";
+               uses group-types:group-desc-stats-reply;
         }
     }
-    
-    container group-all-statistics {
-       container group-stats {
-               uses group-stats-response;
-       }
-       
-       container group-features {
-                       uses group-features-response;
-               }
-               
-               container group-desc {
-                       uses group-desc-response;
-               }
+       
+       augment "/inv:nodes/inv:node" {
+        ext:augment-identifier "node-group-features";
+        container group-features {
+               config "false";
+               uses group-types:group-features-reply;
+        }
     }
 
        // RPC calls
        rpc get-all-group-statistics {
                input {
-            uses inv:node-context-ref;
+            uses inv:node;
         }
         output {
-               uses group-stats-response;
+               uses group-types:group-statistics-reply;
             uses tr:transaction-aware;
         }
        
@@ -73,13 +53,10 @@ module opendaylight-group-statistics {
        
        rpc get-group-statistics {
                input {
-            uses inv:node-context-ref;
-            leaf group-id{
-               type group-types:group-id;
-            }
+            uses inv:node;
         }
         output {
-            uses group-stats-response;
+            uses group-types:group-statistics-reply;
             uses tr:transaction-aware;
         }
        
@@ -87,20 +64,20 @@ module opendaylight-group-statistics {
        
        rpc get-group-description {
                input {
-            uses inv:node-context-ref;
+            uses inv:node;
         }
         output {
-            uses group-desc-response;
+            uses group-types:group-desc-stats-reply;
             uses tr:transaction-aware;
         }
        }
        
        rpc get-group-features {
                input {
-            uses inv:node-context-ref;
+            uses inv:node;
         }
         output {
-            uses group-features-response;
+            uses group-types:group-features-reply;
             uses tr:transaction-aware;
         }
        }
@@ -109,29 +86,29 @@ module opendaylight-group-statistics {
        //Notification calls
        
        notification group-statistics-updated {
-           leaf group-stats-id {
-            type group-stats-ref;
-        }
-               
-               uses group-stats-response;
+               leaf moreReplies {
+                       type boolean;
+               }
+               uses inv:node;
+               uses group-types:group-statistics-reply;
         uses tr:transaction-aware;
        }
        
        notification group-desc-stats-updated {
-               leaf group-desc-id {
-            type group-desc-ref;
-        }
-       
-               uses group-desc-response;
+               leaf moreReplies {
+                       type boolean;
+               }
+               uses inv:node;
+               uses group-types:group-desc-stats-reply;
         uses tr:transaction-aware;
        }
 
        notification group-features-updated {
-               leaf group-features-id {
-            type group-features-ref;
-        }
-       
-               uses group-features-response;
+               leaf moreReplies {
+                       type boolean;
+               }
+               uses inv:node;
+               uses group-types:group-features-reply;
         uses tr:transaction-aware;
        }
 }
index 3561e4f33990751d2379e7f08f51c58c5e36c8d8..b9a6c0d49b1568991dc2d9c4ccf9302112b6ed38 100644 (file)
@@ -7,65 +7,45 @@ module opendaylight-meter-statistics {
     import opendaylight-meter-types {prefix meter-types;revision-date "2013-09-18";}
     import flow-capable-transaction {prefix tr;}
     
+    contact
+       "Anilkumar Vishnoi
+       Email: avishnoi@in.ibm.com";
 
     revision "2013-11-11" {
         description "Initial revision of meter statistics service";
     }
 
-    typedef meter-stats-ref {
-        type instance-identifier;
-    }
-    
-    grouping meter-stats-response {
-        uses "inv:node-context-ref";
-
-        list meter-statistics {
-               uses meter-types:meter-statistics;
+    augment "/inv:nodes/inv:node" {
+        ext:augment-identifier "node-meter-statistics";
+        container meter-statistics {
+               config "false";
+               uses meter-types:meter-statistics-reply;
         }
     }
 
-    typedef meter-config-ref {
-        type instance-identifier;
-    }
-    
-    grouping meter-config-response {
-        uses "inv:node-context-ref";
-
-        list meter-config-stats {
-               uses meter-types:meter-config-stats;
+       augment "/inv:nodes/inv:node" {
+        ext:augment-identifier "node-meter-config-stats";
+        container meter-config-stats {
+               config "false";
+               uses meter-types:meter-config-stats-reply;
         }
     }
-
-    typedef meter-features-ref {
-        type instance-identifier;
-    }
-    
-    grouping meter-features-response {
-        uses "inv:node-context-ref";
-
-        uses meter-types:meter-features;
+       
+       augment "/inv:nodes/inv:node" {
+        ext:augment-identifier "node-meter-features";
+        container meter-features {
+               config "false";
+               uses meter-types:meter-features-reply;
+        }
     }
 
-       container meter-all-stats {
-               container meter-stats {
-                       uses meter-stats-response;
-               }
-               
-               container meter-config {
-                       uses meter-config-response;
-               }
-               
-               container meter-features {
-                       uses meter-features-response;
-               }
-       }
        // RPC calls
        rpc get-all-meter-statistics {
                input {
-            uses inv:node-context-ref;
+            uses inv:node;
         }
         output {
-                       uses meter-stats-response;
+                       uses meter-types:meter-statistics-reply;
                        uses tr:transaction-aware;
         }
        
@@ -73,13 +53,13 @@ module opendaylight-meter-statistics {
        
        rpc get-meter-statistics {
                input {
-            uses inv:node-context-ref;
+            uses inv:node;
             leaf meter-id{
                type meter-types:meter-id;
             }
         }
         output {
-            uses meter-stats-response;
+            uses meter-types:meter-statistics-reply;
             uses tr:transaction-aware;
         }
        
@@ -87,20 +67,20 @@ module opendaylight-meter-statistics {
        
        rpc get-all-meter-config-statistics {
                input {
-            uses inv:node-context-ref;
+            uses inv:node;
         }
         output {
-               uses meter-config-response;
+               uses meter-types:meter-config-stats-reply;
             uses tr:transaction-aware;
         }
        }
        
        rpc get-meter-features {
                input {
-            uses inv:node-context-ref;
+            uses inv:node;
         }
         output {
-               uses meter-features-response;
+               uses meter-types:meter-features-reply;
             uses tr:transaction-aware;
         }
        }
@@ -109,28 +89,32 @@ module opendaylight-meter-statistics {
        //Notification calls
        
        notification meter-statistics-updated {
-           leaf meter-stats-id {
-            type meter-stats-ref;
-        }
-       uses meter-stats-response;
+               leaf moreReplies {
+                       type boolean;
+               }
+               
+               uses inv:node;
+        uses meter-types:meter-statistics-reply;
         uses tr:transaction-aware;
        }
        
        notification meter-config-stats-updated {
-               leaf meter-config-id {
-            type meter-config-ref;
-        }
-       
-               uses meter-config-response;
-        uses tr:transaction-aware;
+               leaf moreReplies {
+                       type boolean;
+               }
+           
+        uses inv:node;
+           uses meter-types:meter-config-stats-reply;
+       uses tr:transaction-aware;
        }
 
        notification meter-features-updated {
-           leaf meter-features-id {
-            type meter-features-ref;
-        }
-       
-               uses meter-features-response;
+               leaf moreReplies {
+                       type boolean;
+               }
+               
+               uses inv:node;
+        uses meter-types:meter-features-reply;
         uses tr:transaction-aware;
        }
 }
index 1627243267dd5a774cf54f5456c428ff8f09248c..6fec18033f8feeed2df5dd7f040d2ddf622d63ad 100644 (file)
@@ -18,6 +18,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.Flow
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
 import org.opendaylight.yangtools.concepts.Registration;
@@ -205,5 +207,18 @@ public class NoficationTest extends AbstractTest {
             
         }
 
+        @Override
+        public void onNodeErrorNotification(NodeErrorNotification notification) {
+            // TODO Auto-generated method stub
+            
+        }
+
+        @Override
+        public void onNodeExperimenterErrorNotification(
+                NodeExperimenterErrorNotification notification) {
+            // TODO Auto-generated method stub
+            
+        }
+
     }
 }
index fa00908e4d54c41245332ebc5d6dedc8f78492d9..3115994e01575a57661db4bbc73bc81927e9713d 100644 (file)
@@ -2,6 +2,7 @@ package org.opendaylight.controller.sal.rest.impl;
 
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.net.URI;
 import java.util.Map.Entry;
 import java.util.Set;
 
@@ -48,7 +49,8 @@ class JsonReader {
     }
     
     private CompositeNodeWrapper createStructureWithRoot(String rootObjectName, JsonObject rootObject) {
-        CompositeNodeWrapper firstNode = new CompositeNodeWrapper(rootObjectName);
+        CompositeNodeWrapper firstNode = new CompositeNodeWrapper(getNamespaceFrom(rootObjectName),
+                getLocalNameFrom(rootObjectName));
         for (Entry<String, JsonElement> childOfFirstNode : rootObject.entrySet()) {
             addChildToParent(childOfFirstNode.getKey(), childOfFirstNode.getValue(), firstNode);
         }
@@ -57,7 +59,8 @@ class JsonReader {
     
     private void addChildToParent(String childName, JsonElement childType, CompositeNodeWrapper parent) {
         if (childType.isJsonObject()) {
-            CompositeNodeWrapper child = new CompositeNodeWrapper(childName);
+            CompositeNodeWrapper child = new CompositeNodeWrapper(getNamespaceFrom(childName),
+                    getLocalNameFrom(childName));
             parent.addValue(child);
             for (Entry<String, JsonElement> childOfChild : childType.getAsJsonObject().entrySet()) {
                 addChildToParent(childOfChild.getKey(), childOfChild.getValue(), child);
@@ -71,11 +74,28 @@ class JsonReader {
             String value = childPrimitive.getAsString();
             SimpleNodeWrapper child = null;
             if (value.equals("[null]")) {
-                child = new SimpleNodeWrapper(childName, null);
+                child = new SimpleNodeWrapper(getNamespaceFrom(childName), getLocalNameFrom(childName), null);
             } else {
-                child = new SimpleNodeWrapper(childName, value);
+                child = new SimpleNodeWrapper(getNamespaceFrom(childName), getLocalNameFrom(childName), value);
             }
             parent.addValue(child);
         }
     }
+
+    private URI getNamespaceFrom(String jsonElementName) {
+        int indexOfDelimeter = jsonElementName.lastIndexOf(':');
+        if (indexOfDelimeter == -1) {
+            return null;
+        }
+        return URI.create(jsonElementName.substring(0, indexOfDelimeter));
+    }
+
+    private String getLocalNameFrom(String jsonElementName) {
+        int indexOfDelimeter = jsonElementName.lastIndexOf(':');
+        if (indexOfDelimeter == -1) {
+            return jsonElementName;
+        }
+        return jsonElementName.substring(indexOfDelimeter + 1, jsonElementName.length());
+    }
+
 }
index da07bba187a25e185cab8b72211860e0ffd99437..e000c7e29e21c0a39904088351940d6862e3f42d 100644 (file)
@@ -29,6 +29,11 @@ public final class CompositeNodeWrapper implements NodeWrapper<CompositeNode>, C
     public CompositeNodeWrapper(String localName) {
         this.localName = Preconditions.checkNotNull(localName);
     }
+    
+    public CompositeNodeWrapper(URI namespace, String localName) {
+        this(localName);
+        this.namespace = namespace;
+    }
 
     @Override
     public String getLocalName() {
index 50b6ac77e6ee8b3c885efe87869231736ffce2d2..4600d0890bcc41f30f6f43ff0907c978156352a3 100644 (file)
@@ -24,6 +24,11 @@ public final class SimpleNodeWrapper implements NodeWrapper<SimpleNode<?>>, Simp
         this.value = value;
     }
     
+    public SimpleNodeWrapper(URI namespace, String localName, String value) {
+        this(localName, value);
+        this.namespace = namespace;
+    }
+    
     @Override
     public String getLocalName() {
         if (simpleNode != null) {
index 0b8b5d48de1d6fe40bafaa5e82b61e854162fed6..9d004362d29d0b64b9a8636f51430ccfa46d8ca3 100644 (file)
@@ -24,6 +24,7 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
 import org.glassfish.jersey.test.TestProperties;
@@ -151,6 +152,21 @@ public class XmlProvidersTest extends JerseyTest {
                 Entity.entity("<SimpleNode>", new MediaType("application", "vnd.yang.api+xml")));
         assertEquals(400, response.getStatus());
     }
+    
+    @Test
+    public void testXmlToCompositeNode404NotFound() {
+        URI uri = null;
+        try {
+            uri = new URI("/datastore/" + URLEncoder.encode("ietf-interfaces:interfaces/interface/eth0", Charsets.US_ASCII.name()).toString());
+        } catch (UnsupportedEncodingException | URISyntaxException e) {
+            e.printStackTrace();
+        }
+        
+        when(brokerFacade.readOperationalData(any(InstanceIdentifier.class))).thenReturn(null);
+        
+        Response response = target(uri.toASCIIString()).request(MediaTypes.API+RestconfService.XML).get();
+        assertEquals(404, response.getStatus());
+    }
 
     @Override
     protected Application configure() {
index 3a355d2e4aff4127db68ccf603f642485a66b268..b85fc681c06724b93ec94be6933f85783e37c86e 100644 (file)
                     </instructions>
                 </configuration>
             </plugin>
-            <plugin>
-                <groupId>org.eclipse.xtend</groupId>
-                <artifactId>xtend-maven-plugin</artifactId>
-            </plugin>
             <plugin>
                 <artifactId>maven-clean-plugin</artifactId>
             </plugin>
index 8507324b571e6bd2d10b48457c73de37e13aaef0..0cc7beb356a38a508a1cdd52138f88b4a45a4a0c 100644 (file)
@@ -1,28 +1,37 @@
+/*
+ * Copyright IBM Corporation, 2013.  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.controller.md.statistics.manager;
 
 import java.util.List;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.desc.response.GroupDescStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.stats.response.GroupStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.nodes.node.GroupFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.meter.config.response.MeterConfigStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.meter.stats.response.MeterStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.MeterFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats;
 
 public class NodeStatistics {
 
     private NodeRef targetNode;
     
-    private List<GroupStatistics> groupStatistics;
+    private List<GroupStats> groupStatistics;
     
-    private List<MeterStatistics> meterStatistics;
+    private List<MeterStats> meterStatistics;
     
     private List<GroupDescStats> groupDescStats;
     
     private List<MeterConfigStats> meterConfigStats;
     
-    private List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.features.GroupFeatures> groupFeatures;
+    private GroupFeatures groupFeatures;
     
-    private List<org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.features.MeterFeatures> meterFeatures;
+    private MeterFeatures meterFeatures;
     
     public NodeStatistics(){
         
@@ -36,19 +45,19 @@ public class NodeStatistics {
         this.targetNode = targetNode;
     }
 
-    public List<GroupStatistics> getGroupStatistics() {
+    public List<GroupStats> getGroupStatistics() {
         return groupStatistics;
     }
 
-    public void setGroupStatistics(List<GroupStatistics> groupStatistics) {
+    public void setGroupStatistics(List<GroupStats> groupStatistics) {
         this.groupStatistics = groupStatistics;
     }
 
-    public List<MeterStatistics> getMeterStatistics() {
+    public List<MeterStats> getMeterStatistics() {
         return meterStatistics;
     }
 
-    public void setMeterStatistics(List<MeterStatistics> meterStatistics) {
+    public void setMeterStatistics(List<MeterStats> meterStatistics) {
         this.meterStatistics = meterStatistics;
     }
 
@@ -68,21 +77,19 @@ public class NodeStatistics {
         this.meterConfigStats = meterConfigStats;
     }
 
-    public List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.features.GroupFeatures> getGroupFeatures() {
+    public GroupFeatures getGroupFeatures() {
         return groupFeatures;
     }
 
-    public void setGroupFeatures(
-            List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.features.GroupFeatures> groupFeatures) {
+    public void setGroupFeatures(GroupFeatures groupFeatures) {
         this.groupFeatures = groupFeatures;
     }
 
-    public List<org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.features.MeterFeatures> getMeterFeatures() {
+    public MeterFeatures getMeterFeatures() {
         return meterFeatures;
     }
 
-    public void setMeterFeatures(
-            List<org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.features.MeterFeatures> meterFeatures) {
+    public void setMeterFeatures(MeterFeatures meterFeatures) {
         this.meterFeatures = meterFeatures;
     }
     
index 3c5c57994c7fb95ec02300735a98cf7db482e8c3..7cbd2314b60265e04626ba4d2409a4f2912be559 100644 (file)
@@ -1,3 +1,16 @@
+/*
+ * Copyright IBM Corporation, 2013.  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
+ */
+/*
+ * TODO: Handle multipart messages with following flag true 
+ * OFPMPF_REPLY_MORE = 1 << 0
+ * Better accumulate all the messages and update local cache 
+ * and configurational data store
+ */
 package org.opendaylight.controller.md.statistics.manager;
 
 import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
index 5c02b6cea069b5266244189990f54e66cddff67f..5218d051fa2cdb40ec9fa47f58114abf5c334dc6 100644 (file)
@@ -1,6 +1,12 @@
+/*
+ * Copyright IBM Corporation, 2013.  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.controller.md.statistics.manager;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
@@ -17,7 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+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.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder;
@@ -52,8 +58,8 @@ public class StatisticsProvider implements AutoCloseable {
     
     //Local caching of stats
     
-    private final ConcurrentMap<NodeRef,NodeStatistics> statisticsCache = 
-            new ConcurrentHashMap<NodeRef,NodeStatistics>();
+    private final ConcurrentMap<NodeId,NodeStatistics> statisticsCache = 
+            new ConcurrentHashMap<NodeId,NodeStatistics>();
     
     public DataProviderService getDataService() {
       return this.dps;
@@ -94,12 +100,13 @@ public class StatisticsProvider implements AutoCloseable {
             public void run() {
                 while(true){
                     try {
+                        spLogger.info("Statistics requester thread started with timer interval : {}",5000);
+                        
                         statsRequestSender();
                         
                         Thread.sleep(5000);
                     }catch (Exception e){
-                        spLogger.error("Exception occurred while sending stats request : {}",e.getMessage());
-                        e.printStackTrace();
+                        spLogger.error("Exception occurred while sending stats request : {}",e);
                     }
                 }
             }
@@ -116,93 +123,96 @@ public class StatisticsProvider implements AutoCloseable {
     private void statsRequestSender(){
         
         //Need to call API to receive all the nodes connected to controller.
-        
-        List<NodeRef> targetNodes = new ArrayList<NodeRef>();
-        
-        for (NodeRef targetNode : targetNodes){
-            
-            sendAllGroupStatisticsRequest(targetNode);
-            
-            sendAllMeterStatisticsRequest(targetNode);
+        List<Node> targetNodes = getAllConnectedNodes();
 
-            //We need to add check, so see if groups/meters are supported
-            //by the target node.
-            sendGroupDescriptionRequest(targetNode);
-            
-            sendGroupFeaturesRequest(targetNode);
-            
-            sendMeterConfigStatisticsRequest(targetNode);
+        for (Node targetNode : targetNodes){
+            spLogger.info("Send request for stats collection to node : {})",targetNode.getId());
             
-            sendMeterFeaturesRequest(targetNode);
+            //We need to add check, so see if groups/meters are supported
+            //by the target node. Below check doesn't look good.
+            if(targetNode.getId().getValue().contains("openflow:")){
+                sendAllGroupStatisticsRequest(targetNode);
+                
+                sendAllMeterStatisticsRequest(targetNode);
+                
+                sendGroupDescriptionRequest(targetNode);
+                
+                sendGroupFeaturesRequest(targetNode);
+                
+                sendMeterConfigStatisticsRequest(targetNode);
+                
+                sendMeterFeaturesRequest(targetNode);
+            }
         }
     }
     
-    private void sendAllGroupStatisticsRequest(NodeRef targetNode){
+    private void sendAllGroupStatisticsRequest(Node targetNode){
         
-        GetAllGroupStatisticsInputBuilder input = new GetAllGroupStatisticsInputBuilder();
+        final GetAllGroupStatisticsInputBuilder input = new GetAllGroupStatisticsInputBuilder();
         
-        input.setNode(targetNode);
+        input.setId(targetNode.getId());
 
         Future<RpcResult<GetAllGroupStatisticsOutput>> response = 
                 groupStatsService.getAllGroupStatistics(input.build());
     }
     
-    private void sendGroupDescriptionRequest(NodeRef targetNode){
-        GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder();
+    private void sendGroupDescriptionRequest(Node targetNode){
+        final GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder();
         
-        input.setNode(targetNode);
+        input.setId(targetNode.getId());
         
         Future<RpcResult<GetGroupDescriptionOutput>> response = 
                 groupStatsService.getGroupDescription(input.build());
     }
     
-    private void sendGroupFeaturesRequest(NodeRef targetNode){
+    private void sendGroupFeaturesRequest(Node targetNode){
         
         GetGroupFeaturesInputBuilder input = new GetGroupFeaturesInputBuilder();
         
-        input.setNode(targetNode);
+        input.setId(targetNode.getId());
         
         Future<RpcResult<GetGroupFeaturesOutput>> response = 
                 groupStatsService.getGroupFeatures(input.build());
     }
     
-    private void sendAllMeterStatisticsRequest(NodeRef targenetNode){
+    private void sendAllMeterStatisticsRequest(Node targetNode){
         
         GetAllMeterStatisticsInputBuilder input = new GetAllMeterStatisticsInputBuilder();
         
-        input.setNode(targenetNode);
+        input.setId(targetNode.getId());
         
         Future<RpcResult<GetAllMeterStatisticsOutput>> response = 
                 meterStatsService.getAllMeterStatistics(input.build());
     }
     
-    private void sendMeterConfigStatisticsRequest(NodeRef targetNode){
+    private void sendMeterConfigStatisticsRequest(Node targetNode){
         
         GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder();
         
-        input.setNode(targetNode);
+        input.setId(targetNode.getId());
         
         Future<RpcResult<GetAllMeterConfigStatisticsOutput>> response = 
                 meterStatsService.getAllMeterConfigStatistics(input.build());
         
     }
-    private void sendMeterFeaturesRequest(NodeRef targetNode){
+    private void sendMeterFeaturesRequest(Node targetNode){
      
         GetMeterFeaturesInputBuilder input = new GetMeterFeaturesInputBuilder();
         
-        input.setNode(targetNode);
+        input.setId(targetNode.getId());
         
         Future<RpcResult<GetMeterFeaturesOutput>> response = 
                 meterStatsService.getMeterFeatures(input.build());
     }
     
-    public ConcurrentMap<NodeRef, NodeStatistics> getStatisticsCache() {
+    public ConcurrentMap<NodeId, NodeStatistics> getStatisticsCache() {
         return statisticsCache;
     }
     
     private List<Node> getAllConnectedNodes(){
         
         Nodes nodes = (Nodes) dps.readOperationalData(nodesIdentifier);
+        spLogger.info("Number of connected nodes : {}",nodes.getNode().size());
         return nodes.getNode();
     }
 
index cba039f815126a071e2184f397eca2faa7cf92e2..c207db0478c9696ae68c28b00566b42085e4244b 100644 (file)
@@ -1,30 +1,49 @@
+/*
+ * Copyright IBM Corporation, 2013.  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.controller.md.statistics.manager;
 
 import java.util.concurrent.ConcurrentMap;
 
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdated;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatsRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupDescStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatisticsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.all.statistics.GroupDescBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.all.statistics.GroupFeaturesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.all.statistics.GroupStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.nodes.node.GroupDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.nodes.node.GroupFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.nodes.node.GroupStatisticsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigRef;
+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.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdated;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatsRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterConfigStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterConfigStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatisticsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.meter.all.stats.MeterConfigBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.meter.all.stats.MeterFeaturesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.meter.all.stats.MeterStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.MeterConfigStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.MeterFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.MeterStatisticsBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
 
 public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsListener,
         OpendaylightMeterStatisticsListener {
@@ -35,140 +54,210 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
 
         this.statisticsManager = manager;
     }
+    
     public StatisticsProvider getStatisticsManager(){
         return statisticsManager;
     }
+   
     @Override
     public void onMeterConfigStatsUpdated(MeterConfigStatsUpdated notification) {
+
         //Add statistics to local cache
-        ConcurrentMap<NodeRef, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
-        if(!cache.containsKey(notification.getNode())){
-            cache.put(notification.getNode(), new NodeStatistics());
+        ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
+        if(!cache.containsKey(notification.getId())){
+            cache.put(notification.getId(), new NodeStatistics());
         }
-        cache.get(notification.getNode()).setMeterConfigStats(notification.getMeterConfigStats());
+        cache.get(notification.getId()).setMeterConfigStats(notification.getMeterConfigStats());
         
         //Publish data to configuration data store
         DataModificationTransaction it = this.statisticsManager.startChange();
-        MeterConfigRef ref = notification.getMeterConfigId();
-
-        MeterConfigBuilder meterConfig = new MeterConfigBuilder();
-        meterConfig.setNode(notification.getNode());
-        meterConfig.setMeterConfigStats(notification.getMeterConfigStats());
+        NodeKey key = new NodeKey(notification.getId());
+        NodeRef ref = getNodeRef(key);
+        
+        final NodeBuilder nodeData = new NodeBuilder(); 
+        nodeData.setKey(key);
+        
+        NodeMeterConfigStatsBuilder meterConfig= new NodeMeterConfigStatsBuilder();
+        MeterConfigStatsBuilder stats = new MeterConfigStatsBuilder();
+        stats.setMeterConfigStats(notification.getMeterConfigStats());
+        meterConfig.setMeterConfigStats(stats.build());
+        
+        //Update augmented data
+        nodeData.addAugmentation(NodeMeterConfigStats.class, meterConfig.build());
         
         InstanceIdentifier<? extends Object> refValue = ref.getValue();
-        it.putRuntimeData(refValue, meterConfig.build());
+        it.putRuntimeData(refValue, nodeData.build());
         it.commit();
+
     }
 
     @Override
     public void onMeterStatisticsUpdated(MeterStatisticsUpdated notification) {
         //Add statistics to local cache
-        ConcurrentMap<NodeRef, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
-        if(!cache.containsKey(notification.getNode())){
-            cache.put(notification.getNode(), new NodeStatistics());
+        ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
+        if(!cache.containsKey(notification.getId())){
+            cache.put(notification.getId(), new NodeStatistics());
         }
-        cache.get(notification.getNode()).setMeterStatistics(notification.getMeterStatistics());
+        cache.get(notification.getId()).setMeterStatistics(notification.getMeterStats());
         
         //Publish data to configuration data store
         DataModificationTransaction it = this.statisticsManager.startChange();
-        MeterStatsRef ref = notification.getMeterStatsId();
-
-        MeterStatsBuilder meterStats = new MeterStatsBuilder();
-        meterStats.setNode(notification.getNode());
-        meterStats.setMeterStatistics(notification.getMeterStatistics());
+        NodeKey key = new NodeKey(notification.getId());
+        NodeRef ref = getNodeRef(key);
+        
+        final NodeBuilder nodeData = new NodeBuilder(); 
+        nodeData.setKey(key);
+        
+        NodeMeterStatisticsBuilder meterStats= new NodeMeterStatisticsBuilder();
+        MeterStatisticsBuilder stats = new MeterStatisticsBuilder();
+        stats.setMeterStats(notification.getMeterStats());
+        meterStats.setMeterStatistics(stats.build());
+        
+        //Update augmented data
+        nodeData.addAugmentation(NodeMeterStatistics.class, meterStats.build());
         
         InstanceIdentifier<? extends Object> refValue = ref.getValue();
-        it.putRuntimeData(refValue, meterStats.build());
+        it.putRuntimeData(refValue, nodeData.build());
         it.commit();
+
     }
 
     @Override
     public void onGroupDescStatsUpdated(GroupDescStatsUpdated notification) {
         //Add statistics to local cache
-        ConcurrentMap<NodeRef, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
-        if(!cache.containsKey(notification.getNode())){
-            cache.put(notification.getNode(), new NodeStatistics());
+        ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
+        if(!cache.containsKey(notification.getId())){
+            cache.put(notification.getId(), new NodeStatistics());
         }
-        cache.get(notification.getNode()).setGroupDescStats(notification.getGroupDescStats());
+        cache.get(notification.getId()).setGroupDescStats(notification.getGroupDescStats());
         
         //Publish data to configuration data store
         DataModificationTransaction it = this.statisticsManager.startChange();
-        GroupDescRef ref = notification.getGroupDescId();
-
-        GroupDescBuilder descStats = new GroupDescBuilder();
-        descStats.setNode(notification.getNode());
-        descStats.setGroupDescStats(notification.getGroupDescStats());
+        NodeKey key = new NodeKey(notification.getId());
+        NodeRef ref = getNodeRef(key);
+        
+        final NodeBuilder nodeData = new NodeBuilder(); 
+        nodeData.setKey(key);
+        
+        NodeGroupDescStatsBuilder groupDesc= new NodeGroupDescStatsBuilder();
+        GroupDescBuilder stats = new GroupDescBuilder();
+        stats.setGroupDescStats(notification.getGroupDescStats());
+        groupDesc.setGroupDesc(stats.build());
+        
+        //Update augmented data
+        nodeData.addAugmentation(NodeGroupDescStats.class, groupDesc.build());
         
         InstanceIdentifier<? extends Object> refValue = ref.getValue();
-        it.putRuntimeData(refValue, descStats.build());
+        it.putRuntimeData(refValue, nodeData.build());
         it.commit();
+
     }
 
     @Override
     public void onGroupStatisticsUpdated(GroupStatisticsUpdated notification) {
         
         //Add statistics to local cache
-        ConcurrentMap<NodeRef, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
-        if(!cache.containsKey(notification.getNode())){
-            cache.put(notification.getNode(), new NodeStatistics());
+        ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
+        if(!cache.containsKey(notification.getId())){
+            cache.put(notification.getId(), new NodeStatistics());
         }
-        cache.get(notification.getNode()).setGroupStatistics(notification.getGroupStatistics());
+        cache.get(notification.getId()).setGroupStatistics(notification.getGroupStats());
         
         //Publish data to configuration data store
+        
         DataModificationTransaction it = this.statisticsManager.startChange();
-        GroupStatsRef ref = notification.getGroupStatsId();
-
-        GroupStatsBuilder groupStats = new GroupStatsBuilder();
-        groupStats.setNode(notification.getNode());
-        groupStats.setGroupStatistics(notification.getGroupStatistics());
+        NodeKey key = new NodeKey(notification.getId());
+        NodeRef ref = getNodeRef(key);
+        
+        final NodeBuilder nodeData = new NodeBuilder(); 
+        nodeData.setKey(key);
+        
+        NodeGroupStatisticsBuilder groupStats = new NodeGroupStatisticsBuilder();
+        GroupStatisticsBuilder stats = new GroupStatisticsBuilder();
+        stats.setGroupStats(notification.getGroupStats());
+        groupStats.setGroupStatistics(stats.build());
+        
+        //Update augmented data
+        nodeData.addAugmentation(NodeGroupStatistics.class, groupStats.build());
         
         InstanceIdentifier<? extends Object> refValue = ref.getValue();
-        it.putRuntimeData(refValue, groupStats.build());
+        it.putRuntimeData(refValue, nodeData.build());
         it.commit();
     }
+    
     @Override
     public void onMeterFeaturesUpdated(MeterFeaturesUpdated notification) {
 
         //Add statistics to local cache
-        ConcurrentMap<NodeRef, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
-        if(!cache.containsKey(notification.getNode())){
-            cache.put(notification.getNode(), new NodeStatistics());
+        ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
+        if(!cache.containsKey(notification.getId())){
+            cache.put(notification.getId(), new NodeStatistics());
         }
-        cache.get(notification.getNode()).setMeterFeatures(notification.getMeterFeatures());
+        MeterFeaturesBuilder meterFeature = new MeterFeaturesBuilder();
+        meterFeature.setBandTypes(notification.getBandTypes());
+        meterFeature.setCapabilities(notification.getCapabilities());
+        meterFeature.setMaxBands(notification.getMaxBands());
+        meterFeature.setMaxColor(notification.getMaxColor());
+        meterFeature.setMaxMeter(notification.getMaxMeter());
+        
+        cache.get(notification.getId()).setMeterFeatures(meterFeature.build());
         
         //Publish data to configuration data store
         DataModificationTransaction it = this.statisticsManager.startChange();
-        MeterFeaturesRef ref = notification.getMeterFeaturesId();
-
-        MeterFeaturesBuilder meterFeatures = new MeterFeaturesBuilder();
-        meterFeatures.setNode(notification.getNode());
-        meterFeatures.setMeterFeatures(notification.getMeterFeatures());
+        NodeKey key = new NodeKey(notification.getId());
+        NodeRef ref = getNodeRef(key);
+        
+        final NodeBuilder nodeData = new NodeBuilder(); 
+        nodeData.setKey(key);
+        
+        NodeMeterFeaturesBuilder nodeMeterFeatures= new NodeMeterFeaturesBuilder();
+        nodeMeterFeatures.setMeterFeatures(meterFeature.build());
+        
+        //Update augmented data
+        nodeData.addAugmentation(NodeMeterFeatures.class, nodeMeterFeatures.build());
         
         InstanceIdentifier<? extends Object> refValue = ref.getValue();
-        it.putRuntimeData(refValue, meterFeatures.build());
+        it.putRuntimeData(refValue, nodeData.build());
         it.commit();
     }
     
     @Override
     public void onGroupFeaturesUpdated(GroupFeaturesUpdated notification) {
-        
         //Add statistics to local cache
-        ConcurrentMap<NodeRef, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
-        if(!cache.containsKey(notification.getNode())){
-            cache.put(notification.getNode(), new NodeStatistics());
+        ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
+        if(!cache.containsKey(notification.getId())){
+            cache.put(notification.getId(), new NodeStatistics());
         }
-        cache.get(notification.getNode()).setGroupFeatures(notification.getGroupFeatures());
+        
+        GroupFeaturesBuilder groupFeatures = new GroupFeaturesBuilder();
+        groupFeatures.setActions(notification.getActions());
+        groupFeatures.setCapabilities(notification.getCapabilities());
+        groupFeatures.setGroupType(notification.getGroupType());
+        groupFeatures.setMaxGroups(notification.getMaxGroups());
+        cache.get(notification.getId()).setGroupFeatures(groupFeatures.build());
         
         //Publish data to configuration data store
         DataModificationTransaction it = this.statisticsManager.startChange();
-        GroupFeaturesRef ref = notification.getGroupFeaturesId();
-
-        GroupFeaturesBuilder featuresStats = new GroupFeaturesBuilder();
-        featuresStats.setNode(notification.getNode());
-        featuresStats.setGroupFeatures(notification.getGroupFeatures());
+        NodeKey key = new NodeKey(notification.getId());
+        NodeRef ref = getNodeRef(key);
+        
+        final NodeBuilder nodeData = new NodeBuilder(); 
+        nodeData.setKey(key);
+        
+        NodeGroupFeaturesBuilder nodeGroupFeatures= new NodeGroupFeaturesBuilder();
+        nodeGroupFeatures.setGroupFeatures(groupFeatures.build());
+        
+        //Update augmented data
+        nodeData.addAugmentation(NodeGroupFeatures.class, nodeGroupFeatures.build());
         
         InstanceIdentifier<? extends Object> refValue = ref.getValue();
-        it.putRuntimeData(refValue, featuresStats.build());
+        it.putRuntimeData(refValue, nodeData.build());
         it.commit();
     }
+
+    private NodeRef getNodeRef(NodeKey nodeKey){
+        InstanceIdentifierBuilder<?> builder = InstanceIdentifier.builder().node(Nodes.class);
+        return new NodeRef(builder.node(Node.class,nodeKey).toInstance());
+    }
+
 }
index ce0036f9afa6024d18282e5e2cfe559b2744cd4a..5055c935838e974125529d814334d1b616057b66 100644 (file)
@@ -72,13 +72,12 @@ public class NetconfOperationServiceImpl implements NetconfOperationService {
     private static Set<Capability> setupCapabilities(YangStoreSnapshot yangStoreSnapshot) {
         Set<Capability> capabilities = Sets.newHashSet();
 
+        // [RFC6241] 8.3.  Candidate Configuration Capability
         capabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:candidate:1.0"));
+        // [RFC6241] 8.5.  Rollback-on-Error Capability
         capabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:rollback-on-error:1.0"));
-        capabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:operations:1.0"));
-        capabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:operations:1.1"));
-        capabilities
-                .add(new BasicCapability(
-                        "urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&amp;revision=2010-10-04"));
+        // [RFC6022] get-schema RPC. TODO: implement rest of the RFC
+        capabilities.add(new BasicCapability("urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&revision=2010-10-04"));
 
         final Collection<Map.Entry<Module, String>> modulesAndContents = yangStoreSnapshot.getModuleMap().values();
         for (Map.Entry<Module, String> moduleAndContent : modulesAndContents) {