Merge "Refactor TransactionProxy"
authorTom Pantelis <tpanteli@brocade.com>
Wed, 7 Jan 2015 21:09:05 +0000 (21:09 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 7 Jan 2015 21:09:05 +0000 (21:09 +0000)
opendaylight/adsal/topologymanager/implementation/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLAdapter.java
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/jdbc/JDBCResultSet.java

index 600f1d8cbfafb05162be7cba530e6b4c05505d3a..a361285db5c60d42b65d0866a731d7a247d4c250 100644 (file)
@@ -756,7 +756,8 @@ public class TopologyManagerImplTest {
     }
 
     @Test
-    public void bug1348FixTest() throws ConstructionException {
+    public void bug1348FixTest() throws ConstructionException,
+           InterruptedException {
         TestSwitchManager swMgr = new TestSwitchManager();
         topoManagerImpl.setSwitchManager(swMgr);
         topoManagerImpl.nonClusterObjectCreate();
@@ -782,12 +783,15 @@ public class TopologyManagerImplTest {
         }
 
         Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000));
+        // Give TopologyManger time to update its edges DB.
+        Thread.sleep(1000);
         Assert.assertEquals(1, topoManagerImpl.getEdges().size());
         Assert.assertNotNull(topoManagerImpl.getEdges().get(edge));
     }
 
     @Test
-    public void testNotifyNodeConnector() throws ConstructionException {
+    public void testNotifyNodeConnector() throws ConstructionException,
+           InterruptedException {
         TestSwitchManager swMgr = new TestSwitchManager();
         topoManagerImpl.setSwitchManager(swMgr);
         topoManagerImpl.nonClusterObjectCreate();
@@ -826,6 +830,8 @@ public class TopologyManagerImplTest {
         swMgr.addNodeConnectors(nc2);
         topoManagerImpl.notifyNodeConnector(nc2, UpdateType.CHANGED, propMap);
         Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000));
+        // Give TopologyManger time to update its edges DB.
+        Thread.sleep(1000);
         Assert.assertEquals(2, topoManagerImpl.getEdges().size());
 
         teu1 = new TopoEdgeUpdate(edge1, props, UpdateType.REMOVED);
@@ -835,6 +841,8 @@ public class TopologyManagerImplTest {
         topoedgeupdateList.add(teu2);
         topoManagerImpl.edgeUpdate(topoedgeupdateList);
         Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000));
+        // Give TopologyManger time to update its edges DB.
+        Thread.sleep(1000);
         Assert.assertEquals(0, topoManagerImpl.getEdges().size());
         topoManagerImpl.notifyNodeConnector(nc1, UpdateType.REMOVED, propMap);
         topoManagerImpl.notifyNodeConnector(nc2, UpdateType.REMOVED, propMap);
@@ -862,10 +870,14 @@ public class TopologyManagerImplTest {
         swMgr.addNodeConnectors(nc2);
         topoManagerImpl.notifyNodeConnector(nc2, UpdateType.CHANGED, propMap);
         Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000));
+        // Give TopologyManger time to update its edges DB.
+        Thread.sleep(1000);
         Assert.assertEquals(0, topoManagerImpl.getEdges().size());
         topoManagerImpl.notifyNodeConnector(nc1, UpdateType.REMOVED, propMap);
         topoManagerImpl.notifyNodeConnector(nc2, UpdateType.REMOVED, propMap);
         Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000));
+        // Give TopologyManger time to update its edges DB.
+        Thread.sleep(1000);
         Assert.assertEquals(0, topoManagerImpl.getEdges().size());
     }
 }
index ad4bd46d719e6dbf286f3dafd408c38dd4fbece4..a5658ccc9ed661b9b2d616f2ca70a2303e875bb0 100644 (file)
@@ -164,13 +164,14 @@ public class XSQLAdapter extends Thread implements SchemaContextListener {
                     return result;
                 }
 
-                // XSQLAdapter.log(""+node);
                 Map<?, ?> children = XSQLODLUtils.getChildren(node);
                 for (Object c : children.values()) {
+                    result.add(c);
+                    /* I don't remember why i did this... possibly to prevent different siblings queried together
                     Map<?, ?> sons = XSQLODLUtils.getChildren(c);
                     for (Object child : sons.values()) {
                         result.add(child);
-                    }
+                    }*/
                 }
 
                 return result;
index d37fdb8819b9d037356a7c38b525fbe8bc6e3074..757f1a8b0487d675661bc35c45ef8a38ae1c6861 100644 (file)
@@ -423,20 +423,20 @@ public class JDBCResultSet implements Serializable, ResultSet,
         return result;
     }
 
-    public List<Record> addRecords(Object element, XSQLBluePrintNode node,
-            boolean root, String tableName, XSQLBluePrint bluePrint) {
-
+    public List<Record> addRecords(Object element, XSQLBluePrintNode node,boolean root, String tableName, XSQLBluePrint bluePrint) {
         List<Record> result = new LinkedList<Record>();
+        //In case this is a sibling to the requested table, the elenment type
+        //won't be in the path of the leaf node
+        if(node==null){
+            return result;
+        }
         String nodeID = XSQLODLUtils.getNodeIdentiofier(element);
         if (node.getODLTableName().equals(nodeID)) {
-            XSQLBluePrintNode bluePrintNode = bluePrint
-                    .getBluePrintNodeByODLTableName(nodeID)[0];
+            XSQLBluePrintNode bluePrintNode = bluePrint.getBluePrintNodeByODLTableName(nodeID)[0];
             Record rec = new Record();
             rec.element = element;
-            XSQLBluePrintNode bpn = this.tablesInQueryMap.get(bluePrintNode
-                    .getBluePrintNodeName());
-            if (this.criteria.containsKey(bluePrintNode.getBluePrintNodeName())
-                    || bpn != null) {
+            XSQLBluePrintNode bpn = this.tablesInQueryMap.get(bluePrintNode.getBluePrintNodeName());
+            if (this.criteria.containsKey(bluePrintNode.getBluePrintNodeName()) || bpn != null) {
                 Map<String, Object> allKeyValues = collectColumnValues(element, bpn);
                 if (!(isObjectFitCriteria(allKeyValues,
                         bpn.getBluePrintNodeName()) == 1)) {
@@ -453,8 +453,7 @@ public class JDBCResultSet implements Serializable, ResultSet,
         }
 
         XSQLBluePrintNode parent = node.getParent();
-        List<Record> subRecords = addRecords(element, parent, false, tableName,
-                bluePrint);
+        List<Record> subRecords = addRecords(element, parent, false, tableName,bluePrint);
         for (Record subRec : subRecords) {
             List<Object> subO = getChildren(subRec.element, tableName,
                     bluePrint);