diff --git a/apps/pce/app/pom.xml b/apps/pce/app/pom.xml
index 1f5d837..a20469b 100644
--- a/apps/pce/app/pom.xml
+++ b/apps/pce/app/pom.xml
@@ -22,6 +22,7 @@
         <groupId>org.onosproject</groupId>
         <artifactId>onos-pce</artifactId>
         <version>1.6.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
     </parent>
     <artifactId>onos-app-pce</artifactId>
     <packaging>bundle</packaging>
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
index 904371d..89a685b 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
@@ -26,6 +26,12 @@
 import java.util.Optional;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.onlab.packet.Ethernet;
+import org.onlab.packet.IPv4;
 
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
@@ -35,6 +41,7 @@
 import org.apache.felix.scr.annotations.Service;
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.IpPrefix;
+import org.onlab.packet.TCP;
 import org.onlab.util.Bandwidth;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
@@ -52,6 +59,7 @@
 import org.onosproject.incubator.net.tunnel.TunnelListener;
 import org.onosproject.incubator.net.tunnel.TunnelName;
 import org.onosproject.incubator.net.tunnel.TunnelService;
+import org.onosproject.mastership.MastershipService;
 import org.onosproject.net.DefaultAnnotations;
 import org.onosproject.net.DefaultAnnotations.Builder;
 import org.onosproject.net.Device;
@@ -63,6 +71,7 @@
 import org.onosproject.net.flowobjective.Objective;
 import org.onosproject.net.intent.Constraint;
 import org.onosproject.net.intent.constraint.BandwidthConstraint;
+import org.onosproject.net.link.LinkEvent;
 import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
 import org.onosproject.pce.pceservice.constraint.CapabilityConstraint.CapabilityType;
 import org.onosproject.pce.pceservice.constraint.CostConstraint;
@@ -76,6 +85,9 @@
 import org.onosproject.net.topology.LinkWeight;
 import org.onosproject.net.topology.PathService;
 import org.onosproject.net.topology.TopologyEdge;
+import org.onosproject.net.topology.TopologyEvent;
+import org.onosproject.net.topology.TopologyListener;
+import org.onosproject.net.topology.TopologyService;
 import org.onosproject.pce.pceservice.api.PceService;
 import org.onosproject.pce.pcestore.PcePathInfo;
 import org.onosproject.pce.pcestore.PceccTunnelInfo;
@@ -131,6 +143,7 @@
     private static final String TRUE = "true";
     private static final String FALSE = "false";
     private static final String END_OF_SYNC_IP_PREFIX = "0.0.0.0/32";
+    public static final int PCEP_PORT = 4189;
 
     private IdGenerator localLspIdIdGen;
     protected DistributedSet<Short> localLspIdFreeList;
@@ -171,12 +184,23 @@
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected FlowObjectiveService flowObjectiveService;
 
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected MastershipService mastershipService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected TopologyService topologyService;
+
     private TunnelListener listener = new InnerTunnelListener();
     private BasicPceccHandler crHandler;
     private PceccSrTeBeHandler srTeHandler;
     private ApplicationId appId;
 
     private final PcepPacketProcessor processor = new PcepPacketProcessor();
+    private final TopologyListener topologyListener = new InternalTopologyListener();
+    private ScheduledExecutorService executor;
+
+    public static final int INITIAL_DELAY = 30;
+    public static final int PERIODIC_DELAY = 30;
 
     /**
      * Creates new instance of PceManager.
@@ -204,6 +228,10 @@
                 .asDistributedSet();
 
         packetService.addProcessor(processor, PacketProcessor.director(4));
+        topologyService.addListener(topologyListener);
+        executor = Executors.newSingleThreadScheduledExecutor();
+        //Start a timer when the component is up, with initial delay of 30min and periodic delays at 30min
+        executor.scheduleAtFixedRate(new GlobalOptimizationTimer(), INITIAL_DELAY, PERIODIC_DELAY, TimeUnit.MINUTES);
         log.info("Started");
     }
 
@@ -211,6 +239,9 @@
     protected void deactivate() {
         tunnelService.removeListener(listener);
         packetService.removeProcessor(processor);
+        topologyService.removeListener(topologyListener);
+        //Shutdown the thread when component is deactivated
+        executor.shutdown();
         log.info("Stopped");
     }
 
@@ -395,6 +426,7 @@
         List<Link> links = tunnel.path().links();
         String lspSigType = tunnel.annotations().value(LSP_SIG_TYPE);
         double bwConstraintValue = 0;
+        String costType = null;
         SharedBandwidthConstraint shBwConstraint = null;
         BandwidthConstraint bwConstraint = null;
         CostConstraint costConstraint = null;
@@ -409,6 +441,7 @@
                     bwConstraintValue = bwConstraint.bandwidth().bps();
                 } else if (constraint instanceof CostConstraint) {
                     costConstraint = (CostConstraint) constraint;
+                costType = costConstraint.type().name();
                 }
             }
 
@@ -454,6 +487,9 @@
 
         Builder annotationBuilder = DefaultAnnotations.builder();
         annotationBuilder.set(BANDWIDTH, String.valueOf(bwConstraintValue));
+        if (costType != null) {
+            annotationBuilder.set(COST_TYPE, costType);
+        }
         annotationBuilder.set(LSP_SIG_TYPE, lspSigType);
         annotationBuilder.set(PCE_INIT, TRUE);
         annotationBuilder.set(DELEGATE, TRUE);
@@ -594,8 +630,66 @@
         }
     }
 
+    //TODO: annotations used for temporarily later projection/network config will be used
+    private class InternalTopologyListener implements TopologyListener {
+       @Override
+        public void event(TopologyEvent event) {
+             event.reasons().forEach(e -> {
+                //If event type is link removed, get the impacted tunnel
+                if (e instanceof LinkEvent) {
+                    LinkEvent linkEvent = (LinkEvent) e;
+                    if (linkEvent.type() == LinkEvent.Type.LINK_REMOVED) {
+                        tunnelService.queryTunnel(MPLS).forEach(t -> {
+                                if (t.path().links().contains((e.subject()))) {
+                                    // Check whether this ONOS instance is master for ingress device if yes,
+                                    // recompute and send update
+                                    checkForMasterAndUpdateTunnel(t.path().src().deviceId(), t);
+                                }
+                        });
+                    }
+                }
+                });
+        }
+    }
 
-    // Allocates the bandwidth locally for PCECC tunnels.
+    private boolean checkForMasterAndUpdateTunnel(DeviceId src, Tunnel tunnel) {
+        /**
+         * Master of ingress node will recompute and also delegation flag must be set.
+         */
+        if (mastershipService.isLocalMaster(src)
+                && Boolean.valueOf(tunnel.annotations().value(DELEGATE)) != null) {
+            LinkedList<Constraint> constraintList = new LinkedList<>();
+
+            if (tunnel.annotations().value(BANDWIDTH) != null) {
+                //Requested bandwidth will be same as previous allocated bandwidth for the tunnel
+                BandwidthConstraint localConst = new BandwidthConstraint(Bandwidth.bps(Double.parseDouble(tunnel
+                        .annotations().value(BANDWIDTH))));
+                constraintList.add(localConst);
+            }
+            if (tunnel.annotations().value(COST_TYPE) != null) {
+                constraintList.add(CostConstraint.of(CostConstraint.Type.valueOf(tunnel.annotations().value(
+                        COST_TYPE))));
+            }
+
+            /*
+             * If tunnel was UP after recomputation failed then store failed path in PCE store send PCIntiate(remove)
+             * and If tunnel is failed and computation fails nothing to do because tunnel status will be same[Failed]
+             */
+            if (!updatePath(tunnel.tunnelId(), constraintList) && !tunnel.state().equals(Tunnel.State.FAILED)) {
+                // If updation fails store in PCE store as failed path
+                // then PCInitiate (Remove)
+                pceStore.addFailedPathInfo(new PcePathInfo(tunnel.path().src().deviceId(), tunnel
+                        .path().dst().deviceId(), tunnel.tunnelName().value(), constraintList,
+                        LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE))));
+                //Release that tunnel calling PCInitiate
+                releasePath(tunnel.tunnelId());
+            }
+        }
+
+        return false;
+    }
+
+     // Allocates the bandwidth locally for PCECC tunnels.
     private TunnelConsumerId reserveBandwidth(Path computedPath, double bandwidthConstraint,
                                   SharedBandwidthConstraint shBwConstraint) {
         checkNotNull(computedPath);
@@ -860,14 +954,72 @@
         public void process(PacketContext context) {
             // Stop processing if the packet has been handled, since we
             // can't do any more to it.
-
             if (context.isHandled()) {
                 return;
             }
 
             InboundPacket pkt = context.inPacket();
+            if (pkt == null) {
+                return;
+            }
+
+            Ethernet ethernet = pkt.parsed();
+            if (ethernet == null || ethernet.getEtherType() != Ethernet.TYPE_IPV4) {
+                return;
+            }
+
+            IPv4 ipPacket = (IPv4) ethernet.getPayload();
+            if (ipPacket == null || ipPacket.getProtocol() != IPv4.PROTOCOL_TCP) {
+                return;
+            }
+
+            TCP tcp = (TCP) ipPacket.getPayload();
+            if (tcp == null || tcp.getDestinationPort() != PCEP_PORT) {
+                return;
+            }
+
             syncLabelDb(pkt.receivedFrom().deviceId());
         }
     }
 
+    //Computes path from tunnel store and also path failed to setup.
+    private void callForOptimization() {
+        //Recompute the LSPs which it was delegated [LSPs stored in PCE store (failed paths)]
+        for (PcePathInfo failedPathInfo : pceStore.getFailedPathInfos()) {
+            checkForMasterAndSetupPath(failedPathInfo);
+        }
+
+        //Recompute the LSPs for which it was delegated [LSPs stored in tunnel store]
+        tunnelService.queryTunnel(MPLS).forEach(t -> {
+        checkForMasterAndUpdateTunnel(t.path().src().deviceId(), t);
+        });
+    }
+
+    private boolean checkForMasterAndSetupPath(PcePathInfo failedPathInfo) {
+        /**
+         * Master of ingress node will setup the path failed stored in PCE store.
+         */
+        if (mastershipService.isLocalMaster(failedPathInfo.src())) {
+            if (setupPath(failedPathInfo.src(), failedPathInfo.dst(), failedPathInfo.name(),
+                    failedPathInfo.constraints(), failedPathInfo.lspType())) {
+                // If computation is success remove that path
+                pceStore.removeFailedPathInfo(failedPathInfo);
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    //Timer to call global optimization
+    private class GlobalOptimizationTimer implements Runnable {
+
+        public GlobalOptimizationTimer() {
+        }
+
+        @Override
+        public void run() {
+            callForOptimization();
+        }
+    }
 }
\ No newline at end of file
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/BasicPceccHandlerTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/BasicPceccHandlerTest.java
index 8c3de14..cd28f9e 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/BasicPceccHandlerTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/BasicPceccHandlerTest.java
@@ -19,7 +19,6 @@
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.notNullValue;
 import static org.hamcrest.Matchers.nullValue;
-
 import static org.onosproject.net.Link.Type.DIRECT;
 
 import java.util.Iterator;
@@ -29,7 +28,6 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-
 import org.onlab.packet.IpAddress;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
@@ -165,6 +163,7 @@
 
     @After
     public void tearDown() throws Exception {
+        PceManagerTest.flowsDownloaded = 0;
     }
 
     /**
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
index 5b0d869..2da22e5 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
@@ -15,13 +15,17 @@
 import static org.onosproject.pce.pceservice.PathComputationTest.D2;
 import static org.onosproject.pce.pceservice.PathComputationTest.D3;
 import static org.onosproject.pce.pceservice.PathComputationTest.D4;
+import static org.onosproject.pce.pceservice.PathComputationTest.DEVICE1;
+import static org.onosproject.pce.pceservice.PathComputationTest.DEVICE2;
+import static org.onosproject.pce.pceservice.PathComputationTest.DEVICE3;
+import static org.onosproject.pce.pceservice.PathComputationTest.DEVICE4;
 import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LOCAL_LSP_ID;
 import static org.onosproject.pce.pceservice.PcepAnnotationKeys.PLSP_ID;
 import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE;
 import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED;
+import static org.onosproject.net.MastershipRole.MASTER;
 
 import java.net.URISyntaxException;
-import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -35,14 +39,18 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.onlab.graph.GraphPathSearch;
+import org.onlab.junit.TestUtils;
+import org.onlab.junit.TestUtils.TestUtilsException;
 import org.onlab.packet.Ethernet;
 import org.onlab.packet.IPv4;
+import org.onlab.packet.TCP;
 import org.onlab.util.Bandwidth;
 import org.onosproject.common.DefaultTopologyGraph;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreServiceAdapter;
 import org.onosproject.core.DefaultApplicationId;
 import org.onosproject.core.IdGenerator;
+import org.onosproject.event.Event;
 import org.onosproject.incubator.net.resource.label.LabelResourceId;
 import org.onosproject.incubator.net.resource.label.LabelResourceService;
 import org.onosproject.incubator.net.tunnel.DefaultTunnel;
@@ -52,6 +60,7 @@
 import org.onosproject.incubator.net.tunnel.TunnelEvent;
 import org.onosproject.incubator.net.tunnel.TunnelId;
 import org.onosproject.incubator.net.tunnel.TunnelListener;
+import org.onosproject.mastership.MastershipServiceAdapter;
 import org.onosproject.net.AnnotationKeys;
 import org.onosproject.net.Annotations;
 import org.onosproject.net.ConnectPoint;
@@ -60,6 +69,7 @@
 import org.onosproject.net.DefaultLink;
 import org.onosproject.net.Device;
 import org.onosproject.net.DefaultAnnotations.Builder;
+import org.onosproject.net.MastershipRole;
 import org.onosproject.net.device.DeviceServiceAdapter;
 import org.onosproject.net.flowobjective.ForwardingObjective;
 import org.onosproject.net.DeviceId;
@@ -71,6 +81,7 @@
 import org.onosproject.net.intent.Constraint;
 import org.onosproject.net.intent.IntentId;
 import org.onosproject.net.intent.constraint.BandwidthConstraint;
+import org.onosproject.net.link.LinkEvent;
 import org.onosproject.net.packet.DefaultInboundPacket;
 import org.onosproject.net.packet.DefaultPacketContext;
 import org.onosproject.net.packet.InboundPacket;
@@ -86,7 +97,9 @@
 import org.onosproject.net.topology.PathServiceAdapter;
 import org.onosproject.net.topology.Topology;
 import org.onosproject.net.topology.TopologyEdge;
+import org.onosproject.net.topology.TopologyEvent;
 import org.onosproject.net.topology.TopologyGraph;
+import org.onosproject.net.topology.TopologyListener;
 import org.onosproject.net.topology.TopologyServiceAdapter;
 import org.onosproject.net.topology.TopologyVertex;
 import org.onosproject.pce.pceservice.PathComputationTest.MockPathResourceService;
@@ -97,7 +110,9 @@
 import org.onosproject.pce.util.TunnelServiceAdapter;
 import org.onosproject.pce.util.FlowObjServiceAdapter;
 import org.onosproject.store.service.TestStorageService;
+
 import com.google.common.collect.ImmutableSet;
+import static org.onosproject.pce.pceservice.PceManager.PCEP_PORT;
 
 /**
  * Tests the functions of PceManager.
@@ -107,6 +122,7 @@
     private PathComputationTest pathCompTest = new PathComputationTest();
     private MockPathResourceService resourceService = pathCompTest.new MockPathResourceService();
     private MockTopologyService topologyService = new MockTopologyService();
+    private MockMastershipService mastershipService = new MockMastershipService();
     private MockPathService pathService = new MockPathService();
     private PceManager pceManager = new PceManager();
     private MockCoreService coreService = new MockCoreService();
@@ -129,13 +145,19 @@
     private Device deviceD1, deviceD2, deviceD3, deviceD4;
     private Device pcepDeviceD1, pcepDeviceD2, pcepDeviceD3, pcepDeviceD4;
     private Link link1, link2, link3, link4;
-    private static int flowsDownloaded;
+    protected static int flowsDownloaded;
     private TunnelListener tunnelListener;
+    private TopologyListener listener;
+    private Topology topology;
+    private Set<TopologyEdge> edges;
+    private Set<TopologyVertex> vertexes;
 
     @Before
-    public void startUp() {
+    public void startUp() throws TestUtilsException {
+        listener = TestUtils.getField(pceManager, "topologyListener");
         pceManager.pathService = pathService;
         pceManager.resourceService = resourceService;
+        pceManager.topologyService = topologyService;
         pceManager.tunnelService = tunnelService;
         pceManager.coreService = coreService;
         pceManager.storageService = storageService;
@@ -144,34 +166,52 @@
         pceManager.labelRsrcService = labelResourceService;
         pceManager.flowObjectiveService = flowObjectiveService;
         pceManager.pceStore = pceStore;
+        pceManager.mastershipService = mastershipService;
         pceManager.activate();
     }
 
+    private class MockMastershipService extends MastershipServiceAdapter {
+        @Override
+        public MastershipRole getLocalRole(DeviceId deviceId) {
+            return MASTER;
+        }
+
+        @Override
+        public boolean isLocalMaster(DeviceId deviceId) {
+            return getLocalRole(deviceId) == MASTER;
+        }
+    }
+
     private void build4RouterTopo(boolean setCost, boolean setPceccCap, boolean setSrCap,
                                  boolean setLabelStackCap, int bandwidth) {
+        link1 = PathComputationTest.addLink(DEVICE1, 10, DEVICE2, 20, setCost, 50);
+        link2 = PathComputationTest.addLink(DEVICE2, 30, DEVICE4, 40, setCost, 20);
+        link3 = PathComputationTest.addLink(DEVICE1, 80, DEVICE3, 70, setCost, 100);
+        link4 = PathComputationTest.addLink(DEVICE3, 60, DEVICE4, 50, setCost, 80);
+
         Set<TopologyVertex> vertexes = new HashSet<TopologyVertex>();
         vertexes.add(D1);
         vertexes.add(D2);
         vertexes.add(D3);
         vertexes.add(D4);
 
+        this.vertexes = vertexes;
+
         Set<TopologyEdge> edges = new HashSet<TopologyEdge>();
-        link1 = PathComputationTest.addLink(D1.deviceId().toString(), 10, D2.deviceId().toString(), 20, setCost, 50);
         TopologyEdge edge1 = new DefaultTopologyEdge(D1, D2, link1);
         edges.add(edge1);
 
-        link2 = PathComputationTest.addLink(D2.deviceId().toString(), 30, D4.deviceId().toString(), 40, setCost, 20);
         TopologyEdge edge2 = new DefaultTopologyEdge(D2, D4, link2);
         edges.add(edge2);
 
-        link3 = PathComputationTest.addLink(D1.deviceId().toString(), 80, D3.deviceId().toString(), 70, setCost, 100);
         TopologyEdge edge3 = new DefaultTopologyEdge(D1, D3, link3);
         edges.add(edge3);
 
-        link4 = PathComputationTest.addLink(D3.deviceId().toString(), 60, D4.deviceId().toString(), 50, setCost, 80);
         TopologyEdge edge4 = new DefaultTopologyEdge(D3, D4, link4);
         edges.add(edge4);
 
+        this.edges = edges;
+
         graph = new DefaultTopologyGraph(vertexes, edges);
 
         DefaultAnnotations.Builder builderDev1 = DefaultAnnotations.builder();
@@ -636,21 +676,18 @@
      * Tests packet in to trigger label DB sync.
      */
     @Test
-    public void packetProcessingTest() throws URISyntaxException {
+    public void packetProcessingTest1() throws URISyntaxException {
 
         build4RouterTopo(false, true, true, true, 0); // This also initializes devices etc.
 
-        final int srcHost = 2;
-        final int dstHost = 5;
-
         LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
         LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
 
         pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
         pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
 
-        ConnectPoint src = new ConnectPoint(D1.deviceId(), PortNumber.portNumber(srcHost));
-        ConnectPoint dst = new ConnectPoint(D2.deviceId(), PortNumber.portNumber(dstHost));
+        ConnectPoint src = new ConnectPoint(D1.deviceId(), PortNumber.portNumber(1));
+        ConnectPoint dst = new ConnectPoint(D2.deviceId(), PortNumber.portNumber(2));
 
         Link link1 = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).type(DIRECT)
                 .providerId(new ProviderId("eth", "1")).build();
@@ -658,24 +695,66 @@
         LabelResourceId link1Label = LabelResourceId.labelResourceId(5204);
         pceManager.pceStore.addAdjLabel(link1, link1Label);
 
-        Ethernet eth;
-        IPv4 ipv4;
+        TCP tcp = new TCP();
+        tcp.setDestinationPort(PCEP_PORT);
 
-        ipv4 = new IPv4();
-        eth = new Ethernet();
+        IPv4 ipv4 = new IPv4();
+        ipv4.setProtocol(IPv4.PROTOCOL_TCP);
+        ipv4.setPayload(tcp);
+
+        Ethernet eth = new Ethernet();
         eth.setEtherType(Ethernet.TYPE_IPV4);
         eth.setPayload(ipv4);
 
-        eth.setSourceMACAddress("00:00:00:10:00:0" + srcHost).setDestinationMACAddress("00:00:00:10:00:0" + dstHost);
-
-        InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(D1.deviceId(), PortNumber.portNumber(srcHost)),
-                                                       eth, ByteBuffer.wrap(eth.serialize()));
+        InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(D1.deviceId(),
+                                                                        PortNumber.portNumber(PCEP_PORT)),
+                                                       eth, null);
 
         pktProcessor.process(new MockPcepPacketContext(inPkt, null));
         assertThat(flowsDownloaded, is(4));
     }
 
     /**
+     * Tests faulty packet in to trigger label DB sync.
+     */
+    @Test
+    public void packetProcessingTest2() throws URISyntaxException {
+
+        build4RouterTopo(false, true, true, true, 0); // This also initializes devices etc.
+
+        LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
+        LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
+
+        pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
+        pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
+
+        ConnectPoint src = new ConnectPoint(D1.deviceId(), PortNumber.portNumber(1));
+        ConnectPoint dst = new ConnectPoint(D2.deviceId(), PortNumber.portNumber(2));
+
+        Link link1 = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).type(DIRECT)
+                .providerId(new ProviderId("eth", "1")).build();
+
+        LabelResourceId link1Label = LabelResourceId.labelResourceId(5204);
+        pceManager.pceStore.addAdjLabel(link1, link1Label);
+
+        TCP tcp = new TCP(); // Not set the pcep port.
+        IPv4 ipv4 = new IPv4();
+        ipv4.setProtocol(IPv4.PROTOCOL_TCP);
+        ipv4.setPayload(tcp);
+
+        Ethernet eth = new Ethernet();
+        eth.setEtherType(Ethernet.TYPE_IPV4);
+        eth.setPayload(ipv4);
+
+        InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(D1.deviceId(),
+                                                                        PortNumber.portNumber(PCEP_PORT)),
+                                                       eth, null);
+
+        pktProcessor.process(new MockPcepPacketContext(inPkt, null));
+        assertThat(flowsDownloaded, is(0));
+    }
+
+    /**
      * Tests tunnel events added and removed.
      */
     @Test
@@ -800,6 +879,390 @@
         assertThat(pceStore.getFailedPathInfoCount(), is(1));
     }
 
+    /**
+     * Tests resilency when L2 link is down.
+     */
+    @Test
+    public void resilencyTest1() {
+        build4RouterTopo(true, false, false, false, 10);
+
+
+        List<Constraint> constraints = new LinkedList<Constraint>();
+        CostConstraint costConstraint = new CostConstraint(COST);
+        constraints.add(costConstraint);
+        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        constraints.add(localBwConst);
+
+        //Setup the path , tunnel created
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123", constraints, WITH_SIGNALLING);
+        assertThat(result, is(true));
+        assertThat(pceStore.getTunnelInfoCount(), is(1));
+        assertThat(pceStore.getFailedPathInfoCount(), is(0));
+
+        List<Event> reasons = new LinkedList<>();
+        final LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
+        reasons.add(linkEvent);
+        final TopologyEvent event = new TopologyEvent(
+                TopologyEvent.Type.TOPOLOGY_CHANGED,
+                topology,
+                reasons);
+
+        //Change Topology : remove link2
+        Set<TopologyEdge> tempEdges = new HashSet<>();
+        tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
+        topologyService.changeInTopology(getGraph(null,  tempEdges));
+        listener.event(event);
+
+        List<Link> links = new LinkedList<>();
+        links.add(link3);
+        links.add(link4);
+
+        //Path is D1-D3-D4
+        assertThat(pathService.paths().iterator().next().links(), is(links));
+        assertThat(pathService.paths().iterator().next().cost(), is((double) 180));
+    }
+
+    /**
+     * Tests resilency when L2 and L4 link is down.
+     */
+    @Test
+    public void resilencyTest2() {
+        build4RouterTopo(true, false, false, false, 10);
+
+        List<Constraint> constraints = new LinkedList<Constraint>();
+        CostConstraint costConstraint = new CostConstraint(COST);
+        constraints.add(costConstraint);
+        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        constraints.add(localBwConst);
+
+        //Setup the path , tunnel created
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123", constraints, WITH_SIGNALLING);
+        assertThat(result, is(true));
+
+        List<Event> reasons = new LinkedList<>();
+        LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
+        reasons.add(linkEvent);
+        linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link4);
+        reasons.add(linkEvent);
+        final TopologyEvent event = new TopologyEvent(
+                TopologyEvent.Type.TOPOLOGY_CHANGED,
+                topology,
+                reasons);
+
+        //Change Topology : remove link2 and link4
+        Set<TopologyEdge> tempEdges = new HashSet<>();
+        tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
+        tempEdges.add(new DefaultTopologyEdge(D3, D4, link4));
+        topologyService.changeInTopology(getGraph(null,  tempEdges));
+        listener.event(event);
+
+        //No Path
+        assertThat(pathService.paths().size(), is(0));
+    }
+
+    /**
+     * Tests resilency when D2 device is down.
+     */
+    @Test
+    public void resilencyTest3() {
+        build4RouterTopo(true, false, false, false, 10);
+
+        List<Constraint> constraints = new LinkedList<Constraint>();
+        CostConstraint costConstraint = new CostConstraint(COST);
+        constraints.add(costConstraint);
+        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        constraints.add(localBwConst);
+
+        //Setup the path , tunnel created
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123", constraints, WITH_SIGNALLING);
+        assertThat(result, is(true));
+
+        List<Event> reasons = new LinkedList<>();
+        LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
+        reasons.add(linkEvent);
+        linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link1);
+        reasons.add(linkEvent);
+        final TopologyEvent event = new TopologyEvent(
+                TopologyEvent.Type.TOPOLOGY_CHANGED,
+                topology,
+                reasons);
+
+        //Change Topology : remove link2 and link1
+        Set<TopologyEdge> tempEdges = new HashSet<>();
+        tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
+        tempEdges.add(new DefaultTopologyEdge(D1, D2, link1));
+        topologyService.changeInTopology(getGraph(null,  tempEdges));
+        listener.event(event);
+
+        List<Link> links = new LinkedList<>();
+        links.add(link3);
+        links.add(link4);
+
+        //Path is D1-D3-D4
+        assertThat(pathService.paths().iterator().next().links(), is(links));
+        assertThat(pathService.paths().iterator().next().cost(), is((double) 180));
+    }
+
+    /**
+     * Tests resilency when ingress device is down.
+     */
+    @Test
+    public void resilencyTest4() {
+        build4RouterTopo(true, false, false, false, 10);
+
+        List<Constraint> constraints = new LinkedList<Constraint>();
+        CostConstraint costConstraint = new CostConstraint(COST);
+        constraints.add(costConstraint);
+        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        constraints.add(localBwConst);
+
+        //Setup the path , tunnel created
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123", constraints, WITH_SIGNALLING);
+        assertThat(result, is(true));
+
+        List<Event> reasons = new LinkedList<>();
+        LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link3);
+        reasons.add(linkEvent);
+        linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link1);
+        reasons.add(linkEvent);
+        final TopologyEvent event = new TopologyEvent(
+                TopologyEvent.Type.TOPOLOGY_CHANGED,
+                topology,
+                reasons);
+
+        //Change Topology : remove link2 and link1
+        Set<TopologyEdge> tempEdges = new HashSet<>();
+        tempEdges.add(new DefaultTopologyEdge(D1, D3, link3));
+        tempEdges.add(new DefaultTopologyEdge(D1, D2, link1));
+        topologyService.changeInTopology(getGraph(null,  tempEdges));
+        listener.event(event);
+
+        //No path
+        assertThat(pathService.paths().size(), is(0));
+    }
+
+    /**
+     * Tests resilency when D2 and D3 devices are down.
+     */
+    @Test
+    public void resilencyTest5() {
+        build4RouterTopo(true, false, false, false, 10);
+
+        List<Constraint> constraints = new LinkedList<Constraint>();
+        CostConstraint costConstraint = new CostConstraint(COST);
+        constraints.add(costConstraint);
+        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        constraints.add(localBwConst);
+
+        //Setup the path , tunnel created
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123", constraints, WITH_SIGNALLING);
+        assertThat(result, is(true));
+
+        List<Event> reasons = new LinkedList<>();
+        LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
+        reasons.add(linkEvent);
+        linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link1);
+        reasons.add(linkEvent);
+        linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link3);
+        reasons.add(linkEvent);
+        linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link4);
+        reasons.add(linkEvent);
+
+        final TopologyEvent event = new TopologyEvent(
+                TopologyEvent.Type.TOPOLOGY_CHANGED,
+                topology,
+                reasons);
+
+        //Change Topology : remove device2, device3 and all links
+        Set<TopologyEdge> tempEdges = new HashSet<>();
+        tempEdges.add(new DefaultTopologyEdge(D1, D2, link1));
+        tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
+        tempEdges.add(new DefaultTopologyEdge(D1, D3, link3));
+        tempEdges.add(new DefaultTopologyEdge(D3, D4, link4));
+        Set<TopologyVertex> tempVertexes = new HashSet<>();
+        tempVertexes.add(D2);
+        tempVertexes.add(D3);
+        topologyService.changeInTopology(getGraph(tempVertexes, tempEdges));
+        listener.event(event);
+
+        //No path
+        assertThat(pathService.paths().size(), is(0));
+    }
+
+    /**
+     * Tests resilency when egress device is down.
+     */
+    @Test
+    public void resilencyTest6() {
+        build4RouterTopo(true, false, false, false, 10);
+
+        List<Constraint> constraints = new LinkedList<Constraint>();
+        CostConstraint costConstraint = new CostConstraint(COST);
+        constraints.add(costConstraint);
+        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        constraints.add(localBwConst);
+
+        //Setup the path , tunnel created
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123", constraints, WITH_SIGNALLING);
+        assertThat(result, is(true));
+
+        List<Event> reasons = new LinkedList<>();
+        LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
+        reasons.add(linkEvent);
+        linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link4);
+        reasons.add(linkEvent);
+
+        final TopologyEvent event = new TopologyEvent(
+                TopologyEvent.Type.TOPOLOGY_CHANGED,
+                topology,
+                reasons);
+
+        //Change Topology : remove device4 , link2 and link4
+        Set<TopologyEdge> tempEdges = new HashSet<>();
+        tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
+        tempEdges.add(new DefaultTopologyEdge(D3, D4, link4));
+        Set<TopologyVertex> tempVertexes = new HashSet<>();
+        tempVertexes.add(D4);
+        topologyService.changeInTopology(getGraph(tempVertexes, tempEdges));
+        listener.event(event);
+
+        //No path
+        assertThat(pathService.paths().size(), is(0));
+    }
+
+    /**
+     * Tests resilency when egress device is down.
+     */
+    @Test
+    public void resilencyTest7() {
+        build4RouterTopo(true, false, false, false, 10);
+
+        List<Constraint> constraints = new LinkedList<Constraint>();
+        CostConstraint costConstraint = new CostConstraint(COST);
+        constraints.add(costConstraint);
+        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        constraints.add(localBwConst);
+
+        //Setup the path , tunnel created
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123", constraints, WITH_SIGNALLING);
+        assertThat(result, is(true));
+
+        List<Event> reasons = new LinkedList<>();
+        LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
+        reasons.add(linkEvent);
+        linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link4);
+        reasons.add(linkEvent);
+
+        final TopologyEvent event = new TopologyEvent(
+                TopologyEvent.Type.TOPOLOGY_CHANGED,
+                topology,
+                reasons);
+
+        //Change Topology : remove device4 , link2 and link4
+        Set<TopologyEdge> tempEdges = new HashSet<>();
+        tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
+        tempEdges.add(new DefaultTopologyEdge(D3, D4, link4));
+        Set<TopologyVertex> tempVertexes = new HashSet<>();
+        tempVertexes.add(D4);
+        topologyService.changeInTopology(getGraph(tempVertexes, tempEdges));
+        listener.event(event);
+
+        //No path
+        assertThat(pathService.paths().size(), is(0));
+    }
+
+    /**
+     * Tests resilency when D2 device is suspended.
+     */
+    @Test
+    public void resilencyTest8() {
+        build4RouterTopo(true, false, false, false, 10);
+
+        List<Constraint> constraints = new LinkedList<Constraint>();
+        CostConstraint costConstraint = new CostConstraint(COST);
+        constraints.add(costConstraint);
+        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        constraints.add(localBwConst);
+
+        //Setup the path , tunnel created
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123", constraints, WITH_SIGNALLING);
+        assertThat(result, is(true));
+
+        List<Event> reasons = new LinkedList<>();
+        LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link1);
+        reasons.add(linkEvent);
+        linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
+        reasons.add(linkEvent);
+
+        final TopologyEvent event = new TopologyEvent(
+                TopologyEvent.Type.TOPOLOGY_CHANGED,
+                topology,
+                reasons);
+
+        //Change Topology : remove device2 , link1 and link2
+        Set<TopologyEdge> tempEdges = new HashSet<>();
+        tempEdges.add(new DefaultTopologyEdge(D1, D2, link1));
+        tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
+        Set<TopologyVertex> tempVertexes = new HashSet<>();
+        tempVertexes.add(D2);
+        topologyService.changeInTopology(getGraph(tempVertexes, tempEdges));
+        listener.event(event);
+
+        List<Link> links = new LinkedList<>();
+        links.add(link3);
+        links.add(link4);
+
+        //Path is D1-D3-D4
+        assertThat(pathService.paths().iterator().next().links(), is(links));
+        assertThat(pathService.paths().iterator().next().cost(), is((double) 180));
+    }
+
+    /**
+     * Tests resilency when D2 device availability is changed.
+     */
+    @Test
+    public void resilencyTest11() {
+        build4RouterTopo(true, false, false, false, 10);
+
+        List<Constraint> constraints = new LinkedList<Constraint>();
+        CostConstraint costConstraint = new CostConstraint(COST);
+        constraints.add(costConstraint);
+        BandwidthConstraint localBwConst = new BandwidthConstraint(Bandwidth.bps(10));
+        constraints.add(localBwConst);
+
+        //Setup the path , tunnel created
+        boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123", constraints, WITH_SIGNALLING);
+        assertThat(result, is(true));
+
+        List<Event> reasons = new LinkedList<>();
+        LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link1);
+        reasons.add(linkEvent);
+        linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
+        reasons.add(linkEvent);
+
+        final TopologyEvent event = new TopologyEvent(
+                TopologyEvent.Type.TOPOLOGY_CHANGED,
+                topology,
+                reasons);
+
+        //Change Topology : remove device2 , link1 and link2
+        Set<TopologyEdge> tempEdges = new HashSet<>();
+        tempEdges.add(new DefaultTopologyEdge(D1, D2, link1));
+        tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
+        Set<TopologyVertex> tempVertexes = new HashSet<>();
+        tempVertexes.add(D2);
+        topologyService.changeInTopology(getGraph(tempVertexes, tempEdges));
+        listener.event(event);
+
+        List<Link> links = new LinkedList<>();
+        links.add(link3);
+        links.add(link4);
+
+        //Path is D1-D3-D4
+        assertThat(pathService.paths().iterator().next().links(), is(links));
+        assertThat(pathService.paths().iterator().next().cost(), is((double) 180));
+    }
+
     @After
     public void tearDown() {
         pceManager.deactivate();
@@ -813,10 +1276,16 @@
         pceManager.labelRsrcService = null;
         pceManager.flowObjectiveService = null;
         pceManager.pceStore = null;
+        pceManager.topologyService = null;
+        pceManager.mastershipService = null;
         flowsDownloaded = 0;
     }
 
     private class MockTopologyService extends TopologyServiceAdapter {
+        private void changeInTopology(TopologyGraph graphModified) {
+            graph = graphModified;
+        }
+
         @Override
         public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
             DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
@@ -837,8 +1306,27 @@
         }
     }
 
-    private class MockPathService extends PathServiceAdapter {
+    private TopologyGraph getGraph(Set<TopologyVertex> removedVertex, Set<TopologyEdge> removedEdges) {
+        if (removedVertex != null) {
+            vertexes.remove(removedVertex);
+            removedVertex.forEach(v ->
+            {
+                vertexes.remove(v);
+            });
+        }
 
+        if (removedEdges != null) {
+            removedEdges.forEach(e ->
+            {
+                edges.remove(e);
+            });
+        }
+
+        return new DefaultTopologyGraph(vertexes, edges);
+    }
+
+    private class MockPathService extends PathServiceAdapter {
+        Set<Path> computedPaths;
         @Override
         public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
             // If either edge is null, bail with no paths.
@@ -848,7 +1336,12 @@
 
             // Otherwise get all paths between the source and destination edge
             // devices.
-            return topologyService.getPaths(null, (DeviceId) src, (DeviceId) dst, weight);
+            computedPaths = topologyService.getPaths(null, (DeviceId) src, (DeviceId) dst, weight);
+            return computedPaths;
+        }
+
+        private Set<Path> paths() {
+            return computedPaths;
         }
     }
 
@@ -946,6 +1439,31 @@
 
             return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result);
         }
+
+        @Override
+        public Collection<Tunnel> queryAllTunnels() {
+            Collection<Tunnel> result = new HashSet<Tunnel>();
+
+            for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
+                result.add(tunnelIdAsKeyStore.get(tunnelId));
+            }
+
+            return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result);
+        }
+        @Override
+        public Iterable<Tunnel> getTunnels(DeviceId deviceId) {
+            List<Tunnel> tunnelList = new LinkedList<>();
+
+            for (Tunnel t : tunnelIdAsKeyStore.values()) {
+                for (Link l : t.path().links()) {
+                    if (l.src().deviceId().equals(deviceId) || l.dst().deviceId().equals(deviceId)) {
+                        tunnelList.add(t);
+                        break;
+                    }
+                }
+            }
+            return tunnelList;
+        }
     }
 
     public static class MockCoreService extends CoreServiceAdapter {
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceccSrTeBeHandlerTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceccSrTeBeHandlerTest.java
index 2a419b5..a49bb0b 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceccSrTeBeHandlerTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceccSrTeBeHandlerTest.java
@@ -158,6 +158,7 @@
 
     @After
     public void tearDown() throws Exception {
+        PceManagerTest.flowsDownloaded = 0;
     }
 
     /**
diff --git a/apps/pce/pceweb/app.png b/apps/pce/pceweb/app.png
index abe34eb..01ea558 100644
--- a/apps/pce/pceweb/app.png
+++ b/apps/pce/pceweb/app.png
Binary files differ
diff --git a/apps/pce/pceweb/pom.xml b/apps/pce/pceweb/pom.xml
index b9b1435..9e815a0 100644
--- a/apps/pce/pceweb/pom.xml
+++ b/apps/pce/pceweb/pom.xml
@@ -23,6 +23,7 @@
         <groupId>org.onosproject</groupId>
         <artifactId>onos-pce</artifactId>
         <version>1.6.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
     </parent>
 
     <artifactId>onos-app-pceweb</artifactId>
@@ -42,6 +43,11 @@
             <artifactId>onos-cli</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-app-pce</artifactId>
+            <version>${project.version}</version>
+        </dependency>
     </dependencies>
 
     <properties>
diff --git a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovMessageHandler.java b/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovMessageHandler.java
index 0c1a5b5..95e9f1f 100644
--- a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovMessageHandler.java
+++ b/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovMessageHandler.java
@@ -17,33 +17,48 @@
 package org.onosproject.pceweb;
 
 import com.fasterxml.jackson.databind.node.ObjectNode;
-
-
 import com.google.common.collect.ImmutableSet;
+
 import org.onlab.osgi.ServiceDirectory;
+import org.onlab.packet.IpAddress;
+import org.onlab.util.DataRateUnit;
+import org.onosproject.net.Device;
 import org.onosproject.net.DeviceId;
-import org.onosproject.net.DisjointPath;
 import org.onosproject.net.ElementId;
 import org.onosproject.net.HostId;
 import org.onosproject.net.Link;
 import org.onosproject.net.Path;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.topology.LinkWeight;
-import org.onosproject.net.topology.PathService;
+import org.onosproject.net.topology.TopologyEvent;
+import org.onosproject.net.topology.TopologyListener;
 import org.onosproject.net.topology.TopologyService;
 import org.onosproject.ui.RequestHandler;
 import org.onosproject.ui.UiConnection;
 import org.onosproject.ui.UiMessageHandler;
 import org.onosproject.ui.topo.DeviceHighlight;
 import org.onosproject.ui.topo.Highlights;
-import org.onosproject.ui.topo.HostHighlight;
 import org.onosproject.ui.topo.NodeBadge;
 import org.onosproject.ui.topo.TopoJson;
-
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.intent.Constraint;
+import org.onosproject.pce.pceservice.LspType;
+import org.onosproject.pce.pceservice.api.PceService;
+import org.onosproject.pce.pceservice.constraint.CostConstraint;
+import org.onosproject.net.intent.constraint.BandwidthConstraint;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
+import org.onosproject.incubator.net.tunnel.Tunnel;
+import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
+import org.onosproject.incubator.net.tunnel.TunnelEvent;
+import org.onosproject.incubator.net.tunnel.TunnelId;
+import org.onosproject.incubator.net.tunnel.TunnelListener;
+import org.onosproject.incubator.net.tunnel.TunnelService;
+import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS;
+
+import com.fasterxml.jackson.databind.node.ArrayNode;
 
 import java.util.Collection;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 
@@ -56,47 +71,66 @@
     private static final String PCEWEB_SET_SRC = "pceTopovSetSrc";
     private static final String PCEWEB_SET_DST = "pceTopovSetDst";
     private static final String PCEWEB_SET_PATH = "pceTopovSetMode";
-
+    private static final String PCEWEB_UPDATE_PATH_QUERY = "pceTopovUpdateQuery";
+    private static final String PCEWEB_UPDATE_PATH = "pceTopovUpdate";
+    private static final String PCEWEB_REMOVE_PATH_QUERY = "pceTopovRemQuery";
+    private static final String PCEWEB_REMOVE_PATH = "pceTopovRem";
+    private static final String PCEWEB_QUERY_TUNNELS = "pceTopovTunnelDisplay";
+    private static final String PCEWEB_SHOW_TUNNEL = "pceTopovShowTunnels";
+    private static final String PCEWEB_SHOW_TUNNEL_REMOVE = "pceTopovShowTunnelsRem";
     private static final String ID = "id";
-    private static final String MODE = "mode";
     private static final String TYPE = "type";
-    private static final String SWITCH = "switch";
-    private static final String ENDSTATION = "endstation";
-    public static final String DST = "Dst";
-    public static final String SRC = "Src";
+    private static final String ROUTER = "router";
+    private static final String DST = "Egress";
+    private static final String SRC = "Ingress";
+    private static final String BANDWIDTH = "bw";
+    private static final String BANDWIDTHTYPE = "bwtype";
+    private static final String COSTTYPE = "ctype";
+    private static final String LSPTYPE = "lsptype";
+    private static final String SRCID = "srid";
+    private static final String DSTID = "dsid";
+    private static final String TUNNEL_ID = "tunnelid";
+    private static final String TUNNEL_NAME = "tunnelname";
+    private static final String COST_TYPE_IGP = "igp";
+    private static final String COST_TYPE_TE = "te";
+    private static final String BANDWIDTH_TYPE_KBPS = "kbps";
+    private static final String BUFFER_ARRAY = "a";
+    private static final String BANDWIDTH_BPS = "BPS";
+    private static final String LSP_TYPE_CR = "cr";
+    private static final String LSP_TYPE_SRBE = "srbe";
+    private static final String LSP_TYPE_SRTE = "srte";
+    private static final String STRING_NULL = "null";
     // Delay for showHighlights event processing on GUI client side to
     // account for addLink animation.
-    public static final int DELAY_MS = 1100;
-
-    private static final String CLASS = "class";
-    private static final String UNKNOWN = "unknown";
-    private static final String DEVICE = "device";
+    private static final int DELAY_MS = 1100;
+    private static final double BANDWIDTH_KBPS = 1_000;
+    private static final double BANDWIDTH_MBPS = 1_000_000;
 
     private Set<Link> allPathLinks;
-    private boolean listenersRemoved;
-    private LinkWeight linkData;
     private int highlightDelay;
-
-    private final Logger log = LoggerFactory.getLogger(getClass());
-
-    private PathService pathService;
-
     private ElementId src, dst;
     private String srcType, dstType;
     private List<Path> paths;
     private int pathIndex;
 
+    private final Logger log = LoggerFactory.getLogger(getClass());
+    private final TopologyListener topologyListener = new InternalTopologyListener();
+    private final TunnelListener tunnelListener = new InnerPceWebTunnelListener();
+
     protected TopologyService topologyService;
+    protected TunnelService tunnelService;
+    protected PceService pceService;
     protected DeviceService deviceService;
-
-
     @Override
     public void init(UiConnection connection, ServiceDirectory directory) {
 
         super.init(connection, directory);
-        //TODO: Need add listeners.
-        //topologyService = directory.get(TopologyService.class);
-        //addListeners();
+        topologyService = directory.get(TopologyService.class);
+        tunnelService = directory.get(TunnelService.class);
+        pceService = directory.get(PceService.class);
+        deviceService = directory.get(DeviceService.class);
+        topologyService.addListener(topologyListener);
+        tunnelService.addListener(tunnelListener);
     }
 
     @Override
@@ -105,7 +139,19 @@
                 new ClearHandler(),
                 new SetSrcHandler(),
                 new SetDstHandler(),
-                new SetPathHandler());
+                new SetPathHandler(),
+                new UpdatePathQueryHandler(),
+                new UpdatePathHandler(),
+                new RemovePathQueryHandler(),
+                new RemovePathHandler(),
+                new ShowTunnelHandler());
+    }
+
+    @Override
+    public void destroy() {
+        topologyService.removeListener(topologyListener);
+        tunnelService.removeListener(tunnelListener);
+        super.destroy();
     }
 
     // Handler classes
@@ -137,7 +183,6 @@
 
         @Override
         public void process(long sid, ObjectNode payload) {
-            log.info("PCE WEB Set source process method invoked");
             String id = string(payload, ID);
             src = elementId(id);
             srcType = string(payload, TYPE);
@@ -146,7 +191,6 @@
             }
             sendMessage(TopoJson.highlightsMessage(addBadge(new Highlights(),
                     srcType, src.toString(), SRC)));
-
         }
     }
 
@@ -167,7 +211,6 @@
             if (src.equals(dst)) {
                 src = null;
             }
-
             sendMessage(TopoJson.highlightsMessage(addBadge(new Highlights(),
                     dstType, dst.toString(), DST)));
 
@@ -175,7 +218,7 @@
     }
 
     /**
-     * Handles the 'patchcalculation' event received from the client.
+     * Handles the 'path calculation' event received from the client.
      */
     private final class SetPathHandler extends RequestHandler {
 
@@ -185,15 +228,168 @@
 
         @Override
         public void process(long sid, ObjectNode payload) {
-            String mode = string(payload, MODE);
+            String bandWidth = string(payload, BANDWIDTH);
+            String bandWidthType = string(payload, BANDWIDTHTYPE);
+            String costType = string(payload, COSTTYPE);
+            String lspType = string(payload, LSPTYPE);
+            String tunnelName = string(payload, TUNNEL_NAME);
 
-            // TODO: Read user input[constraints] and call the path calculation based on
-            //given constrainsts.
-            findAndSendPaths();
+            if (tunnelName.equals(STRING_NULL)) {
+                log.error("tunnel name should not be empty");
+                return;
+            }
+
+            if (pceService == null) {
+                log.error("PCE service is not active");
+                return;
+            }
+
+            if (lspType == null) {
+                log.error("PCE setup path is failed.");
+            }
+
+            if ((src != null) && (dst != null)) {
+                findAndSendPaths(src, dst, bandWidth, bandWidthType, costType, lspType, tunnelName);
+            }
         }
     }
 
-    // === ------------
+    /**
+     * Handles the 'update path query' event received from the client.
+     */
+    private final class UpdatePathQueryHandler extends RequestHandler {
+
+        public UpdatePathQueryHandler() {
+            super(PCEWEB_UPDATE_PATH_QUERY);
+        }
+
+        @Override
+        public void process(long sid, ObjectNode payload) {
+            String srcId = string(payload, SRCID);
+            ElementId src = elementId(srcId);
+            String dstId = string(payload, DSTID);
+            ElementId dst = elementId(dstId);
+            Device srcDevice = deviceService.getDevice((DeviceId) src);
+            Device dstDevice = deviceService.getDevice((DeviceId) dst);
+
+            TunnelEndPoint tunSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                    .valueOf(srcDevice.annotations().value("lsrId")));
+            TunnelEndPoint tunDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                    .valueOf(dstDevice.annotations().value("lsrId")));
+
+            Collection<Tunnel> tunnelSet = tunnelService.queryTunnel(tunSrc, tunDst);
+            ObjectNode result = objectNode();
+            ArrayNode arrayNode = arrayNode();
+            for (Tunnel tunnel : tunnelSet) {
+                if (tunnel.type() == MPLS) {
+                    arrayNode.add(tunnel.tunnelId().toString());
+                }
+            }
+
+            result.putArray(BUFFER_ARRAY).addAll(arrayNode);
+            sendMessage(PCEWEB_SHOW_TUNNEL, sid, result);
+        }
+    }
+
+    /**
+     * Handles the 'update path' event received from the client.
+     */
+    private final class UpdatePathHandler extends RequestHandler {
+
+        public UpdatePathHandler() {
+            super(PCEWEB_UPDATE_PATH);
+        }
+
+        @Override
+        public void process(long sid, ObjectNode payload) {
+            String bandWidth = string(payload, BANDWIDTH);
+            String bandWidthType = string(payload, BANDWIDTHTYPE);
+            String costType = string(payload, COSTTYPE);
+            String tunnelId = string(payload, TUNNEL_ID);
+
+            if (tunnelId == null) {
+                log.error("PCE update path is failed.");
+            }
+
+            findAndSendPathsUpdate(bandWidth, bandWidthType, costType, tunnelId);
+        }
+    }
+
+    /**
+     * Handles the 'remove path query' event received from the client.
+     */
+    private final class RemovePathQueryHandler extends RequestHandler {
+
+        public RemovePathQueryHandler() {
+            super(PCEWEB_REMOVE_PATH_QUERY);
+        }
+
+        @Override
+        public void process(long sid, ObjectNode payload) {
+            String srcId = string(payload, SRCID);
+            ElementId src = elementId(srcId);
+            String dstId = string(payload, DSTID);
+            ElementId dst = elementId(dstId);
+
+            Device srcDevice = deviceService.getDevice((DeviceId) src);
+            Device dstDevice = deviceService.getDevice((DeviceId) dst);
+
+            TunnelEndPoint tunSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                    .valueOf(srcDevice.annotations().value("lsrId")));
+            TunnelEndPoint tunDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                    .valueOf(dstDevice.annotations().value("lsrId")));
+
+            Collection<Tunnel> tunnelSet = tunnelService.queryTunnel(tunSrc, tunDst);
+            ObjectNode result = objectNode();
+            ArrayNode arrayNode = arrayNode();
+
+            for (Tunnel tunnel : tunnelSet) {
+                if (tunnel.type() == MPLS) {
+                    arrayNode.add(tunnel.tunnelId().toString());
+                }
+            }
+
+            result.putArray(BUFFER_ARRAY).addAll(arrayNode);
+            sendMessage(PCEWEB_SHOW_TUNNEL_REMOVE, sid, result);
+        }
+    }
+
+    /**
+     * Handles the 'remove path' event received from the client.
+     */
+    private final class RemovePathHandler extends RequestHandler {
+
+        public RemovePathHandler() {
+            super(PCEWEB_REMOVE_PATH);
+        }
+
+        @Override
+        public void process(long sid, ObjectNode payload) {
+            String tunnelId = string(payload, TUNNEL_ID);
+
+            if (tunnelId == null) {
+                log.error("PCE update path is failed.");
+            }
+
+            findAndSendPathsRemove(tunnelId);
+        }
+    }
+
+    /**
+     * Handles the 'show the existed tunnels' event received from the client.
+     */
+    private final class ShowTunnelHandler extends RequestHandler {
+
+        public ShowTunnelHandler() {
+            super(PCEWEB_QUERY_TUNNELS);
+        }
+
+        @Override
+        public void process(long sid, ObjectNode payload) {
+            findTunnelAndHighlights();
+        }
+    }
+
     /**
      * provides the element id.
      */
@@ -204,45 +400,170 @@
             return HostId.hostId(id);
         }
     }
-    //TODO: Need to pass constraints to this method
-    private void findAndSendPaths() {
-        log.info("src={}; dst={};", src, dst);
-        if (src != null && dst != null) {
-            //TBD: Need to call pathcalulation API here
-            hilightAndSendPaths();
 
+    /**
+     * Handles the setup path and highlights the path.
+     *
+     * @param bandWidth
+     * @param bandWidthType is the kbps or mbps
+     * @param costType is igp or te
+     * @param lspType is WITH_SIGNALLING,WITHOUT_SIGNALLING_AND_WITHOUT_SR or SR_WITHOUT_SIGNALLING
+     * @param tunnelName tunnel id
+     */
+    private void findAndSendPaths(ElementId src, ElementId dst, String bandWidth, String bandWidthType,
+                                    String costType, String lspType, String tunnelName) {
+        log.debug("src={}; dst={};", src, dst);
+        boolean path;
+        List<Constraint> listConstrnt;
+
+        listConstrnt = addBandwidthCostTypeConstraints(bandWidth, bandWidthType, costType);
+
+        //LSP type
+        LspType lspTypeVal = null;
+        switch (lspType) {
+            case LSP_TYPE_CR:
+                lspTypeVal = LspType.WITH_SIGNALLING;
+                break;
+            case LSP_TYPE_SRBE:
+                lspTypeVal = LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
+                break;
+            case LSP_TYPE_SRTE:
+                lspTypeVal = LspType.SR_WITHOUT_SIGNALLING;
+                break;
+            default:
+                log.error("Invalid LSP type");
+                break;
         }
 
+        path = pceService.setupPath((DeviceId) src, (DeviceId) dst, tunnelName, listConstrnt, lspTypeVal);
+        if (!path) {
+             log.error("setup path is failed");
+             return;
+        }
+
+        return;
     }
 
-    //TODO: The below code is not used. Once get path from PCE app then below code will be use.
-    // the below code will get path and it will highlight the selected path.
-    //Currently primary path in use, there is no use of secondary path.
-    //secondary path need to remove based on path received by PCE app.
-    private ImmutableSet.Builder<Link> buildPaths(
-            ImmutableSet.Builder<Link> pathBuilder) {
+    /**
+     * Handles the update path and highlights the path.
+     *
+     * @param bandWidth bandWidth
+     * @param bandWidthType is the kbps or mbps
+     * @param costType is igp or te
+     * @param tunnelName tunnel id
+     */
+    private void findAndSendPathsUpdate(String bandWidth, String bandWidthType, String costType, String tunnelIdStr) {
+        if (tunnelIdStr != null) {
+            List<Constraint> listConstrnt;
+
+            if (tunnelIdStr.equals(STRING_NULL)) {
+                log.error("update path is failed");
+                return;
+            }
+
+            if (pceService == null) {
+                log.error("PCE service is not active");
+                return;
+            }
+
+            listConstrnt = addBandwidthCostTypeConstraints(bandWidth, bandWidthType, costType);
+            TunnelId tunnelId = TunnelId.valueOf(tunnelIdStr);
+            boolean path = pceService.updatePath(tunnelId, listConstrnt);
+
+            if (!path) {
+                log.error("update path is failed");
+                return;
+            }
+        }
+        return;
+    }
+
+    /**
+     * Handles the remove path and highlights the paths if existed.
+     *
+     * @param tunnelIdName tunnelId
+     */
+    private void findAndSendPathsRemove(String tunnelIdStr) {
+        if (tunnelIdStr != null) {
+            if (pceService == null) {
+                log.error("PCE service is not active");
+                return;
+            }
+
+            TunnelId tunnelId = TunnelId.valueOf(tunnelIdStr);
+            boolean path = pceService.releasePath(tunnelId);
+            if (!path) {
+                log.error("remove path is failed");
+                return;
+            }
+        }
+        return;
+    }
+
+    private ImmutableSet.Builder<Link> buildPaths(ImmutableSet.Builder<Link> pathBuilder) {
         paths.forEach(path -> path.links().forEach(pathBuilder::add));
         return pathBuilder;
     }
 
-    private ImmutableSet.Builder<Link> buildDisjointPaths(
-            ImmutableSet.Builder<Link> pathBuilder) {
-        paths.forEach(path -> {
-            DisjointPath dp = (DisjointPath) path;
-            pathBuilder.addAll(dp.primary().links());
-            pathBuilder.addAll(dp.backup().links());
-        });
-        return pathBuilder;
+    /**
+     * Handles the preparation of constraints list with given bandwidth and cost-type.
+     *
+     * @param bandWidth bandWidth
+     * @param bandWidthType is the kbps or mbps
+     * @param costType is igp or te
+     * @param listConstrnt list of constraints
+     * @return
+     */
+    private List<Constraint> addBandwidthCostTypeConstraints(String bandWidth,
+                                                             String bandWidthType,
+                                                             String costType) {
+        List<Constraint> listConstrnt = new LinkedList<>();
+        //bandwidth
+        double bwValue = 0.0;
+        if (!bandWidth.equals(STRING_NULL)) {
+            bwValue = Double.parseDouble(bandWidth);
+        }
+        if (bandWidthType.equals(BANDWIDTH_TYPE_KBPS)) {
+            bwValue = bwValue * BANDWIDTH_KBPS;
+        } else {
+            bwValue = bwValue * BANDWIDTH_MBPS;
+        }
+
+        //Cost type
+        CostConstraint.Type costTypeVal = null;
+        switch (costType) {
+        case COST_TYPE_IGP:
+            costTypeVal = CostConstraint.Type.COST;
+            break;
+        case COST_TYPE_TE:
+            costTypeVal = CostConstraint.Type.TE_COST;
+            break;
+        default:
+            log.error("Invalid cost type");
+            break;
+        }
+
+        if (bwValue != 0.0) {
+            listConstrnt.add(BandwidthConstraint.of(bwValue, DataRateUnit.valueOf(BANDWIDTH_BPS)));
+        }
+
+        if (costTypeVal != null) {
+            listConstrnt.add(CostConstraint.of(costTypeVal));
+        }
+
+        return listConstrnt;
     }
 
+    /**
+     * Handles the highlights of selected path.
+     */
     private void hilightAndSendPaths() {
         PceWebLinkMap linkMap = new PceWebLinkMap();
         allPathLinks.forEach(linkMap::add);
-
         Set<Link> selectedPathLinks;
 
-        selectedPathLinks = paths.isEmpty() ? ImmutableSet.of()
-                    : ImmutableSet.copyOf(paths.get(pathIndex).links());
+        selectedPathLinks = paths.isEmpty() ?
+                ImmutableSet.of() : ImmutableSet.copyOf(paths.get(pathIndex).links());
 
         Highlights highlights = new Highlights();
         if (highlightDelay > 0) {
@@ -261,16 +582,32 @@
         sendMessage(TopoJson.highlightsMessage(highlights));
     }
 
+    /**
+     *  Handles the addition of badge and highlights.
+     *
+     * @param highlights highlights
+     * @param type device type
+     * @param elemId device to be add badge
+     * @param src device to be add badge
+     * @return
+     */
     private Highlights addBadge(Highlights highlights, String type,
             String elemId, String src) {
-        if (SWITCH.equals(type)) {
+        if (ROUTER.equals(type)) {
             highlights = addDeviceBadge(highlights, elemId, src);
-        } else if (ENDSTATION.equals(type)) {
-            highlights = addHostBadge(highlights, elemId, src);
         }
+
         return highlights;
     }
 
+    /**
+     * Handles the badge add and highlights.
+     *
+     * @param h highlights
+     * @param elemId device to be add badge
+     * @param type device type
+     * @return highlights
+     */
     private Highlights addDeviceBadge(Highlights h, String elemId, String type) {
         DeviceHighlight dh = new DeviceHighlight(elemId);
         dh.setBadge(createBadge(type));
@@ -278,18 +615,59 @@
         return h;
     }
 
-    private Highlights addHostBadge(Highlights h, String elemId, String type) {
-        HostHighlight hh = new HostHighlight(elemId);
-        hh.setBadge(createBadge(type));
-        h.add(hh);
-        return h;
-    }
-
+    /**
+     * Handles the node badge add and highlights.
+     *
+     * @param type device type
+     * @return badge of given node
+     */
     private NodeBadge createBadge(String type) {
         return NodeBadge.text(type);
     }
 
-    //TODO: Listeners need to add.
-    //If topology changes then path need to be re calculate.
+    /**
+     * Handles the event of topology listeners.
+     */
+    private class InternalTopologyListener implements TopologyListener {
+        @Override
+        public void event(TopologyEvent event) {
+            highlightDelay = DELAY_MS;
+            findTunnelAndHighlights();
+            highlightDelay = 0;
+        }
+    }
 
+    /**
+     * Handles the event of tunnel listeners.
+     */
+    private class InnerPceWebTunnelListener implements TunnelListener {
+        @Override
+        public void event(TunnelEvent event) {
+            Tunnel tunnel = event.subject();
+            if (tunnel.type() == MPLS) {
+                highlightDelay = DELAY_MS;
+                findTunnelAndHighlights();
+                highlightDelay = 0;
+            }
+        }
+    }
+
+   /**
+     * Handles the event of topology listeners.
+    */
+    private void findTunnelAndHighlights() {
+        Collection<Tunnel> tunnelSet = null;
+        tunnelSet = tunnelService.queryTunnel(MPLS);
+        for (Tunnel tunnel : tunnelSet) {
+            if (tunnel.path() == null) {
+                log.info("path does not exist");
+                return;
+            }
+            paths.add(tunnel.path());
+        }
+
+        ImmutableSet.Builder<Link> builder = ImmutableSet.builder();
+        allPathLinks = buildPaths(builder).build();
+        hilightAndSendPaths();
+    }
 }
diff --git a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovOverlay.java b/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovOverlay.java
index 087f4bc..41f3243 100644
--- a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovOverlay.java
+++ b/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovOverlay.java
@@ -63,7 +63,6 @@
     public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
 
          pp.title(MY_TITLE);
-         log.info("Modify device details called.");
 
          DeviceService deviceService = AbstractShellCommand.get(DeviceService.class);
 
diff --git a/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopovDemo.js b/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopovDemo.js
index 096f872..e16e15b 100644
--- a/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopovDemo.js
+++ b/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopovDemo.js
@@ -21,16 +21,23 @@
 
     // injected refs
     var $log, fs, flash, wss, tps, ns, tds, ds;
-
+    var tunnelNameData, tunnelNameDataRemove;
    // constants
     var srcMessage = 'pceTopovSetSrc',
         dstMessage = 'pceTopovSetDst',
         clearMessage = 'pceTopovClear',
-        setModemsg =  'pceTopovSetMode',
-        L3dev = 'requestIpDevDetails';
+        setPathmsg =  'pceTopovSetMode',
+        updatePathmsgQuery = 'pceTopovUpdateQuery',
+        remPathmsgQuery = 'pceTopovRemQuery',
+        updatePathmsg = 'pceTopovUpdate',
+        remPathmsg = 'pceTopovRem',
+        showTunnelInfoMsg = 'pceTopovShowTunnels',
+        queryDisplayTunnelMsg = 'pceTopovTunnelDisplay',
+        showTunnelInfoRemoveMsg = 'pceTopovShowTunnelsRem';
     // internal state
     var currentMode = null;
-
+    var handlerMap = {},
+        handlerMapRem = {};
     // === ---------------------------
     // === Helper functions
 
@@ -58,153 +65,326 @@
         flash.flash('Cleared source and destination');
     }
 
-    function dOk() {
-        var bandWidth = d3.select('#band-width-box').property("checked");
-        var bandValue = null;
-        var bandType = null;
-
-        if (bandWidth) {
-
-            bandValue = d3.select('#band-width-value').property("value");
-
-            if (d3.select("#band-kpbs-val").property("checked")) {
-                bandType = 'kbps';
-            } else if (d3.select('#band-mpbs-val').property("checked")) {
-                bandType = 'mbps';
-            }
-        }
-
-        var costType = d3.select('#pce-cost-type').property("checked");
-        var costTypeVal = null;
-
-        if (costType) {
-
-            if (d3.select("#pce-cost-type-igp").property("checked")) {
-                costTypeVal = 'igp';
-            } else if (d3.select('#pce-cost-type-te').property("checked")) {
-               costTypeVal = 'te';
-            }
-       }
-
-       var lspType = d3.select('#pce-lsp-type').property("checked");
-       var lspTypeVal = null;
-
-       if (lspType) {
-
-           if (d3.select("#pce-lsp-type-cr").property("checked")) {
-               lspTypeVal = 'cr';
-           } else if (d3.select('#pce-lsp-type-srbe').property("checked")) {
-               lspTypeVal = 'srbe';
-           } else if (d3.select('#pce-lsp-type-srte').property("checked")) {
-               lspTypeVal = 'srte';
-           }
-       }
-
-         //TBD: Read the user inputs and need to send the event for calculating the path based on constrainsts.
-         // TBD: Need to read IGP cost type and LSP type.
-         //wss.sendEvent(setModemsg);
-         //flash.flash('creat path message');
-
-       $log.debug('Dialog OK button clicked');
-    }
-
     function dClose() {
         $log.debug('Dialog Close button clicked (or Esc pressed)');
     }
 
     function createUserText() {
-        var content = ds.createDiv();
-        var form = content.append('form');
-        var p = form.append('p');
+        var content = ds.createDiv('constraints-input'),
+            form = content.append('form'),
+            p = form.append('p');
+
+        function addAttribute(name, id, nameField, type) {
+            p.append('input').attr({
+                type: type,
+                name: name,
+                id: id
+            });
+
+            p.append('span').text(nameField);
+            p.append('br');
+        }
 
         //Add the bandwidth related inputs.
-        p.append('input').attr({
-            id: 'band-width-box',
-            type: 'checkbox',
-            name: 'band-width-name'
-        });
-        p.append('span').text('Band Width');
-        p.append('br');
-        p.append('input').attr({
-            id: 'band-width-value',
-            type: 'number',
-            name: 'band-width-value-name'
-        });
-        p.append('input').attr({
-            id: 'band-kpbs-val',
-            type: 'radio',
-            name: 'pce-band-type'
-        });
-        p.append('span').text('kpbs');
-        p.append('input').attr({
-            id: 'band-mpbs-val',
-            type: 'radio',
-            name: 'pce-band-type'
-        });
-        p.append('span').text('mpbs');
-        p.append('br');
-
+        addAttribute('band-width-name', 'band-width-box', 'Band Width', 'checkbox');
+        addAttribute('band-width-value-name', 'band-width-value', null, 'number');
+        addAttribute('pce-band-type', 'band-kpbs-val', 'kbps', 'radio');
+        addAttribute('pce-band-type', 'band-mpbs-val', 'mbps', 'radio');
         //Add the cost type related inputs.
-        p.append('input').attr({
-            id: 'pce-cost-type',
-            type: 'checkbox',
-            name: 'pce-cost-type-name'
-        });
-        p.append('span').text('Cost Type');
-        p.append('br');
-        p.append('input').attr({
-            id: 'pce-cost-type-igp',
-            type: 'radio',
-            name: 'pce-cost-type-valname'
-        });
-        p.append('span').text('IGP');
-        p.append('input').attr({
-            id: 'pce-cost-type-te',
-            type: 'radio',
-            name: 'pce-cost-type-valname'
-        });
-        p.append('span').text('TE');
-        p.append('br');
-
+        addAttribute('pce-cost-type-name', 'pce-cost-type', 'Cost Type', 'checkbox');
+        addAttribute('pce-cost-type-valname', 'pce-cost-type-igp', 'IGP', 'radio');
+        addAttribute('pce-cost-type-valname', 'pce-cost-type-te', 'TE', 'radio');
         //Add the LSP type related inputs.
-        p.append('input').attr({
-            id: 'pce-lsp-type',
-            type: 'checkbox',
-            name: 'pce-lsp-type-name'
-        });
-        p.append('span').text('Lsp Type');
-        p.append('br');
-        p.append('input').attr({
-            id: 'pce-lsp-type-cr',
-            type: 'radio',
-            name: 'pce-lsp-type-valname'
-        });
-        p.append('span').text('CR');
-        p.append('input').attr({
-            id: 'pce-lsp-type-srbe',
-            type: 'radio',
-            name: 'pce-lsp-type-valname'
-        });
-        p.append('span').text('SR BE');
-        p.append('input').attr({
-            id: 'pce-lsp-type-srte',
-            type: 'radio',
-            name: 'pce-lsp-type-valname'
-        });
-        p.append('span').text('SR TE');
+        addAttribute('pce-lsp-type-name', 'pce-lsp-type', 'Lsp Type', 'checkbox');
+        addAttribute('pce-lsp-type-valname', 'pce-lsp-type-cr', 'WITH SIGNALLING', 'radio');
+        addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srbe', 'WITHOUT SR WITHOUT SIGNALLING', 'radio');
+        addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srte', 'WITH SR WITHOUT SIGNALLING', 'radio');
+        //Add the tunnel name
+        addAttribute('pce-tunnel-name', 'pce-tunnel-name-id', 'Tunnel Name', 'text');
 
         return content;
     }
 
-    function setMode() {
+    function createUserTextUpdate(data) {
+        var content = ds.createDiv(),
+            form = content.append('form'),
+            p = form.append('p');
+
+        p.append('span').text('Tunnel IDs');
+        p.append('br');
+
+        data.a.forEach( function (val, idx) {
+            p.append('input').attr({
+                id: 'tunnel-id-'+idx,
+                type: 'radio',
+                name: 'tunnel-id-name',
+                value: val
+            });
+
+            p.append('span').text(val);
+            p.append('br');
+
+        } );
+
+        return content;
+    }
+
+    function createUserTextUpdatePathEvent() {
+        var content = ds.createDiv(),
+            form = content.append('form'),
+            p = form.append('p');
+
+        function addAttribute(name, id, nameField, type) {
+            p.append('input').attr({
+                type: type,
+                name: name,
+                id: id
+            });
+
+            p.append('span').text(nameField);
+            p.append('br');
+        }
+
+        //Add the bandwidth related inputs.
+        addAttribute('band-width-name', 'update-band-width-box', 'Band Width', 'checkbox');
+        addAttribute('band-width-value-name', 'update-band-width-value', null, 'number');
+        addAttribute('pce-band-type', 'update-band-kpbs-val', 'kbps', 'radio');
+        addAttribute('pce-band-type', 'update-band-mpbs-val', 'mbps', 'radio');
+        //Add the cost type related inputs.
+        addAttribute('pce-cost-type', 'update-pce-cost-type', 'Cost Type', 'checkbox');
+        addAttribute('pce-cost-type-value', 'update-pce-cost-type-igp', 'IGP', 'radio');
+        addAttribute('pce-cost-type-value', 'update-pce-cost-type-te', 'TE', 'radio');
+
+        return content;
+    }
+
+    function createUserTextRemove(data) {
+
+        var content = ds.createDiv(),
+            form = content.append('form'),
+            p = form.append('p');
+
+        p.append('span').text('Tunnel IDs');
+        p.append('br');
+
+        data.a.forEach( function (val, idx) {
+            p.append('input').attr({
+                id: 'tunnel-id-remove-'+idx,
+                type: 'checkbox',
+                name: 'tunnel-id-name-remove',
+                value: val
+            });
+
+            p.append('span').text(val);
+            p.append('br');
+        } );
+
+        return content;
+    }
+
+    function isChecked(viewId) {
+        return d3.select('#' + viewId).property('checked');
+    }
+
+    function getCheckedValue(viewId) {
+        return d3.select('#' + viewId).property('value');
+    }
+
+    function showTunnelInformation(data) {
+        wss.unbindHandlers(handlerMap);
+        tunnelNameData = data;
+
+        function dOkUpdate() {
+            var tdString = '' ;
+            tunnelNameData.a.forEach( function (val, idx) {
+                var tunnelName = isChecked('tunnel-id-'+idx);
+                if (tunnelName)
+                {
+                    tdString = val;
+                }
+            } );
+
+            if (tdString) {
+                constraintsUpdateDialog(tdString);
+            } else {
+                $log.debug("No tunnel id is selected.");
+            }
+
+            $log.debug('Dialog OK button clicked');
+        }
+
         tds.openDialog()
-        .setTitle('constraints user')
+            .setTitle('Available LSPs with selected device')
+            .addContent(createUserTextUpdate(data))
+            .addOkChained(dOkUpdate, 'GOTO Selection of constraints')
+            .addCancel(dClose, 'Close')
+            .bindKeys();
+    }
+
+    function constraintsUpdateDialog(tunnelId) {
+
+        // invoked when the OK button is pressed on this dialog
+        function dOkUpdateEvent() {
+            $log.debug('Select constraints for update path Dialog OK button pressed');
+
+            var bandWidth = isChecked('update-band-width-box'),
+                bandValue = null,
+                bandType = null;
+
+            if (bandWidth) {
+                bandValue = d3.select('#update-band-width-value');
+
+                if (isChecked('update-band-kpbs-val')) {
+                    bandType = 'kbps';
+                } else if (isChecked('update-band-mpbs-val')) {
+                    bandType = 'mbps';
+                }
+            }
+
+            var costType = isChecked('update-pce-cost-type'),
+                costTypeVal = null;
+
+            if (costType) {
+                if (isChecked('update-pce-cost-type-igp')) {
+                    costTypeVal = 'igp';
+                } else if (isChecked('update-pce-cost-type-te')) {
+                   costTypeVal = 'te';
+                }
+            }
+
+            wss.sendEvent(updatePathmsg, {
+                    bw: bandValue,
+                    ctype: costTypeVal,
+                    tunnelname: tunnelId
+            });
+
+            flash.flash('update path message');
+
+        }
+
+        tds.openDialog()
+            .setTitle('Select constraints for update path')
+            .addContent(createUserTextUpdatePathEvent())
+            .addCancel()
+            .addOk(dOkUpdateEvent, 'Update Path')     // NOTE: NOT the "chained" version!
+            .bindKeys();
+
+    }
+
+    function showTunnelInformationRemove(data) {
+
+        wss.unbindHandlers(handlerMapRem);
+        tunnelNameDataRemove = data;
+        tds.openDialog()
+            .setTitle('Available Tunnels for remove')
+            .addContent(createUserTextRemove(data))
+            .addOk(dOkRemove, 'Remove')
+            .addCancel(dClose, 'Close')
+            .bindKeys();
+    }
+
+    //setup path
+    function setMode() {
+
+        function dOk() {
+            var bandWidth = isChecked('band-width-box'),
+                bandValue = null,
+                bandType = null;
+
+            if (bandWidth) {
+                bandValue = getCheckedValue('band-width-value');
+
+                if (isChecked('band-kpbs-val')) {
+                    bandType = 'kbps';
+                } else if (isChecked('band-mpbs-val')) {
+                    bandType = 'mbps';
+                }
+            }
+
+            var costType = isChecked('pce-cost-type'),
+                costTypeVal = null;
+
+            if (costType) {
+                if (isChecked('pce-cost-type-igp')) {
+                    costTypeVal = 'igp';
+                } else if (isChecked('pce-cost-type-te')) {
+                   costTypeVal = 'te';
+                }
+            }
+
+            var lspType = isChecked('pce-lsp-type'),
+                lspTypeVal = null;
+
+            if (lspType) {
+                if (isChecked('pce-lsp-type-cr')) {
+                   lspTypeVal = 'cr';
+                } else if (isChecked('pce-lsp-type-srbe')) {
+                   lspTypeVal = 'srbe';
+                } else if (isChecked('pce-lsp-type-srte')) {
+                   lspTypeVal = 'srte';
+                }
+            }
+
+            wss.sendEvent(setPathmsg, {
+                bw: bandValue,
+                bwtype: bandType,
+                ctype: costTypeVal,
+                lsptype: lspTypeVal,
+                tunnelname: getCheckedValue('pce-tunnel-name-id')
+            });
+
+            flash.flash('create path message');
+            $log.debug('Dialog OK button clicked');
+        }
+
+        tds.openDialog()
+        .setTitle('constraints selection')
         .addContent(createUserText())
         .addOk(dOk, 'OK')
         .addCancel(dClose, 'Close')
         .bindKeys();
     }
 
+    function updatePath(node) {
+
+        wss.sendEvent(updatePathmsgQuery, {
+            srid: node[0],
+            dsid: node[1]
+        });
+
+        handlerMap[showTunnelInfoMsg] = showTunnelInformation;
+        wss.bindHandlers(handlerMap);
+
+        flash.flash('update path message');
+    }
+
+    function dOkRemove() {
+
+        tunnelNameDataRemove.a.forEach( function (val, idx) {
+            var tunnelNameVal = isChecked('tunnel-id-remove-'+idx);
+            if (tunnelNameVal) {
+                wss.sendEvent(remPathmsg, {
+                    tunnelid: val
+                });
+            }
+        } );
+
+        flash.flash('remove path message');
+    }
+
+    function remPath(node) {
+        wss.sendEvent(remPathmsgQuery, {
+            srid: node[0],
+            dsid: node[1]
+        });
+
+        handlerMapRem[showTunnelInfoRemoveMsg] = showTunnelInformationRemove;
+        wss.bindHandlers(handlerMapRem);
+    }
+
+  function queryTunnelDisplay() {
+        wss.sendEvent(queryDisplayTunnelMsg);
+    }
     // === ---------------------------
     // === Module Factory Definition
 
@@ -227,8 +407,10 @@
                 setSrc: setSrc,
                 setDst: setDst,
                 clear: clear,
-                setMode: setMode
-
+                setMode: setMode,
+                updatePath: updatePath,
+                remPath: remPath,
+                queryTunnelDisplay: queryTunnelDisplay
             };
         }]);
 }());
diff --git a/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopovOverlay.js b/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopovOverlay.js
index 63a4d2d..4ad40a0 100644
--- a/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopovOverlay.js
+++ b/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopovOverlay.js
@@ -34,7 +34,6 @@
         glyphId: 'topo',
         tooltip: 'PCE web Topo Overlay',
 
-
         activate: function () {
             $log.debug("PCE web topology overlay ACTIVATED");
         },
@@ -112,11 +111,32 @@
             },
             1: {
                 cb: function () {
-                    pps.setMode("shortest");
+                    pps.setMode();
                 },
-                tt: 'Select constraints for LSP',
+                tt: 'Setup path',
+                gid: 'plus'
+            },
+            2: {
+                cb: function () {
+                    pps.updatePath(selection);
+                },
+                tt: 'Update path',
                 gid: '*jp'
             },
+            3: {
+                cb: function () {
+                    pps.remPath(selection);
+                },
+                tt: 'Remove path',
+                gid: 'minus'
+            },
+            4: {
+                cb: function () {
+                    pps.queryTunnelDisplay();
+                },
+                tt: 'Show Tunnels',
+                gid: 'checkMark'
+            },
             0: {
                 cb: function () {
                     pps.clear();
@@ -126,7 +146,7 @@
             },
 
             _keyOrder: [
-                'openBracket', 'closeBracket', '1', '0'
+                'openBracket', 'closeBracket', '1', '2', '3', '4', '0'
             ]
         },
         hooks: {
@@ -145,6 +165,9 @@
             },
             single: function (data) {
                 selectionCallback(data);
+            },
+            multi: function (selectOrder) {
+                selectionCallback(selectOrder);
             }
         }
     };
diff --git a/apps/pce/pom.xml b/apps/pce/pom.xml
index 7ba4bca..e6e6163 100644
--- a/apps/pce/pom.xml
+++ b/apps/pce/pom.xml
@@ -21,6 +21,7 @@
         <groupId>org.onosproject</groupId>
         <artifactId>onos-apps</artifactId>
         <version>1.6.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
