Finish committing transactions when state resync is done 74/4574/2
authorRobert Varga <rovarga@cisco.com>
Wed, 22 Jan 2014 13:08:19 +0000 (14:08 +0100)
committerRobert Varga <rovarga@cisco.com>
Wed, 22 Jan 2014 13:33:47 +0000 (14:33 +0100)
It turns out we forgot to commit the modification transaction when the
initial resync is done. Also add a few debugs so we know what we push
where.

Change-Id: Ia253bd4a421d88ea4f3ed70a73ba238a931e7a4b
Signed-off-by: Robert Varga <rovarga@cisco.com>
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/ServerSessionManager.java
pcep/topology-provider/src/test/java/org/opendaylight/bgpcep/pcep/topology/provider/ParserToSalTest.java

index 693d23886c321d2f14cf6938d605eda36e019e2d..95e5ec79cf0f42e155fecefe2db58a8052685b72 100644 (file)
@@ -159,6 +159,7 @@ final class ServerSessionManager implements SessionListenerFactory<PCEPSessionLi
                        LOG.debug("Peer {} resolved to topology node {}", peerAddress, topoNode);
 
                        // Our augmentation in the topology node
+                       this.synced = false;
                        this.pccBuilder = new PathComputationClientBuilder();
                        this.pccBuilder.setIpAddress(IpAddressBuilder.getDefaultInstance(peerAddress.getHostAddress()));
 
@@ -169,12 +170,19 @@ final class ServerSessionManager implements SessionListenerFactory<PCEPSessionLi
                                        this.pccBuilder.setReportedLsp(Collections.<ReportedLsp> emptyList());
                                        this.pccBuilder.setStatefulTlv(new StatefulTlvBuilder().setStateful(stateful).build());
                                        this.pccBuilder.setStateSync(PccSyncState.InitialResync);
+                               } else {
+                                       LOG.debug("Peer {} does not advertise stateful TLV", peerAddress);
                                }
+                       } else {
+                               LOG.debug("Peer {} does not advertise stateful TLV", peerAddress);
                        }
 
                        this.topologyAugmentBuilder = new Node1Builder().setPathComputationClient(this.pccBuilder.build());
                        this.topologyAugment = InstanceIdentifier.builder(this.topologyNode).augmentation(Node1.class).toInstance();
-                       trans.putOperationalData(this.topologyAugment, this.topologyAugmentBuilder.build());
+                       final Node1 ta = topologyAugmentBuilder.build();
+
+                       trans.putOperationalData(this.topologyAugment, ta);
+                       LOG.debug("Peer data {} set to {}", this.topologyAugment, ta);
 
                        // All set, commit the modifications
                        final ListenableFuture<RpcResult<TransactionStatus>> f = JdkFutureAdapters.listenInPoolThread(trans.commit());
@@ -271,7 +279,9 @@ final class ServerSessionManager implements SessionListenerFactory<PCEPSessionLi
                                        // Update synchronization flag
                                        this.synced = true;
                                        this.topologyAugmentBuilder.setPathComputationClient(this.pccBuilder.setStateSync(PccSyncState.Synchronized).build());
-                                       trans.putOperationalData(this.topologyAugment, this.topologyAugmentBuilder.build());
+                                       final Node1 ta = this.topologyAugmentBuilder.build();
+                                       trans.putOperationalData(this.topologyAugment, ta);
+                                       LOG.debug("Peer data {} set to {}", this.topologyAugment, ta);
 
                                        // The node has completed synchronization, cleanup metadata no longer reported back
                                        this.nodeState.cleanupExcept(Collections2.transform(
@@ -284,7 +294,7 @@ final class ServerSessionManager implements SessionListenerFactory<PCEPSessionLi
                                                                }
                                                        }));
                                        LOG.debug("Session {} achieved synchronized state", session);
-                                       return;
+                                       continue;
                                }
 
                                final ReportedLspBuilder rlb = new ReportedLspBuilder(r);
@@ -445,7 +455,7 @@ final class ServerSessionManager implements SessionListenerFactory<PCEPSessionLi
                                new TopologyBuilder().setKey(k).setTopologyId(k.getTopologyId()).setTopologyTypes(
                                                new TopologyTypesBuilder().addAugmentation(TopologyTypes1.class,
                                                                new TopologyTypes1Builder().setTopologyPcep(new TopologyPcepBuilder().build()).build()).build()).setNode(
-                                               new ArrayList<Node>()).build());
+                                                                               new ArrayList<Node>()).build());
 
                Futures.addCallback(JdkFutureAdapters.listenInPoolThread(t.commit()), new FutureCallback<RpcResult<TransactionStatus>>() {
                        @Override
index cee476ae0e9a1bb58d55130494154839b6cd9fb8..ee88fe1475b36250f085effe1f416e8733862992 100644 (file)
@@ -222,6 +222,6 @@ public class ParserToSalTest {
                this.session.handleMessage(this.rptmsg);
                Mockito.verify(this.mockedTransaction, Mockito.times(4)).putOperationalData(Matchers.any(InstanceIdentifier.class),
                                Matchers.any(DataObject.class));
-               Mockito.verify(this.mockedTransaction, Mockito.times(2)).commit();
+               Mockito.verify(this.mockedTransaction, Mockito.times(3)).commit();
        }
 }