Fixed PCEP synchronization. 53/3753/2
authorDana Kutenicsova <dkutenic@cisco.com>
Mon, 16 Dec 2013 15:51:05 +0000 (16:51 +0100)
committerDana Kutenicsova <dkutenic@cisco.com>
Mon, 16 Dec 2013 15:51:05 +0000 (16:51 +0100)
Change-Id: I4d552691227b820e28b3482886cb95161701fa8d
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractPCEPSessionNegotiator.java
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 51342e66a4d7fac425aa33e9404c2ec42b3d8926..8f43dc37f5f590ef07e792cd8925854b7ee695ae 100644 (file)
@@ -201,7 +201,7 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
        protected final synchronized void handleMessage(final Message msg) {
                this.failTimer.cancel();
 
-               LOG.debug("Channel {} handling message in state {}", this.channel, this.state);
+               LOG.debug("Channel {} handling message {} in state {}", this.channel, msg, this.state);
 
                switch (this.state) {
                case Finished:
index fdfdb6eef1aff6b6dd4c906bf3f48d08960e095e..9259c0ff4a31b494f4e57c1adfc275e04f85fd72 100644 (file)
@@ -262,12 +262,13 @@ final class ServerSessionManager implements SessionListenerFactory<PCEPSessionLi
                        for (final Reports r : rpt.getReports()) {
                                final Lsp lsp = r.getLsp();
 
-                               if (lsp.isSync() && !this.synced) {
+                               if (!lsp.isSync() && !this.synced) {
                                        // Update synchronization flag
                                        this.synced = true;
                                        this.topologyAugmentBuilder.setPathComputationClient(this.pccBuilder.setStateSync(PccSyncState.Synchronized).build());
                                        trans.putOperationalData(this.topologyAugment, this.topologyAugmentBuilder.build());
                                        LOG.debug("Session {} achieved synchronized state", session);
+                                       return;
                                }
 
                                final Srp srp = r.getSrp();
index d7d64b12eb84a3e5b5dda0a4ef901698cffdb098..eee783ecf40d41369fe5e1c229a86d524cc0c100 100644 (file)
@@ -148,7 +148,7 @@ public class ParserToSalTest {
 
                        @Override
                        public RpcResult<TransactionStatus> get(final long timeout, final TimeUnit unit) throws InterruptedException,
-                       ExecutionException, TimeoutException {
+                                       ExecutionException, TimeoutException {
                                return null;
                        }
                }).when(this.mockedTransaction).commit();
@@ -197,9 +197,9 @@ public class ParserToSalTest {
 
                }).when(this.mockedTransaction).putOperationalData(Matchers.any(InstanceIdentifier.class), Matchers.any(DataObject.class));
 
-               manager = new ServerSessionManager(this.providerService, InstanceIdentifier.builder(
-                               NetworkTopology.class).child(Topology.class, new TopologyKey(new TopologyId("testtopo"))).toInstance());
-               final DefaultPCEPSessionNegotiator neg = new DefaultPCEPSessionNegotiator(new HashedWheelTimer(), mock(Promise.class), this.clientListener, manager.getSessionListener(), (short) 1, 5, this.localPrefs);
+               this.manager = new ServerSessionManager(this.providerService, InstanceIdentifier.builder(NetworkTopology.class).child(
+                               Topology.class, new TopologyKey(new TopologyId("testtopo"))).toInstance());
+               final DefaultPCEPSessionNegotiator neg = new DefaultPCEPSessionNegotiator(new HashedWheelTimer(), mock(Promise.class), this.clientListener, this.manager.getSessionListener(), (short) 1, 5, this.localPrefs);
                this.session = neg.createSession(new HashedWheelTimer(), this.clientListener, this.localPrefs, this.localPrefs);
 
                final List<Reports> reports = Lists.newArrayList(new ReportsBuilder().setLsp(
@@ -211,7 +211,7 @@ public class ParserToSalTest {
 
        @After
        public void tearDown() throws InterruptedException, ExecutionException {
-               manager.close();
+               this.manager.close();
        }
 
        @Test
@@ -220,6 +220,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(3)).commit();
+               Mockito.verify(this.mockedTransaction, Mockito.times(2)).commit();
        }
 }