[ONOS-1959][ONOS-2007][ONOS-2008][ONOS-2009][ONOS-2010][ONOS-2011][ONOS-2016][ONOS-2017][ONOS-2018]
1.fix bug in query subscription command in Tunnel management
2.add RemoveTunnelByIdCommand
3.add UpdateTunnelBandWithCommand
4.add QueryAllTunnelsCommand
5.add queryAllTunnels api in TunnelService and TunnelStore
6.store the Path of the tunnel in the store
7.remove to check parameters iif they are null in the construtors of
DefaultTunnel.e.g
8.add the method of querying in SB
9.Fix the bug that the src/dst end point of Vlan-type tunnel is the
instance of OpticalTunnelEndPoint
10. invert the verb-noun into noun-verb for tunnel commands and label
commands

Change-Id: I90378b37c2bc73b58e6f8f234f009d64f07f758e
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultOpticalTunnelEndPoint.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultOpticalTunnelEndPoint.java
index c6e4119..f80dfac 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultOpticalTunnelEndPoint.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultOpticalTunnelEndPoint.java
@@ -15,7 +15,6 @@
  */
 package org.onosproject.incubator.net.tunnel;
 
-import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.MoreObjects.toStringHelper;
 
 import java.util.Objects;
@@ -55,9 +54,6 @@
                         Optional<PortNumber> number, Optional<OpticalTunnelEndPoint> parentPoint,
                         Type type, OpticalLogicId id, boolean isGlobal, Annotations... annotations) {
         super(providerId, annotations);
-        checkNotNull(type, "type cannot be null");
-        checkNotNull(id, "id cannot be null");
-        checkNotNull(isGlobal, "isGlobal cannot be null");
         this.elementId = elementId;
         this.portNumber = number;
         this.parentPoint = parentPoint;
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultTunnel.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultTunnel.java
old mode 100644
new mode 100755
index 62a5dcb..5f448e0
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultTunnel.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultTunnel.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Open Networking Laboratory
+ * Copyright 2014-2015 Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,10 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.onosproject.incubator.net.tunnel;
 
-import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.MoreObjects.toStringHelper;
 
 import java.util.Objects;
@@ -25,6 +23,7 @@
 import org.onosproject.net.AbstractModel;
 import org.onosproject.net.Annotations;
 import org.onosproject.net.NetworkResource;
+import org.onosproject.net.Path;
 import org.onosproject.net.provider.ProviderId;
 
 /**
@@ -43,6 +42,7 @@
     private final TunnelId tunnelId; // tunnel identify generated by
                                      // ONOS as primary key
     private final TunnelName tunnelName; // name of a tunnel
+    private final Path path;
 
     /**
      * Creates an active infrastructure tunnel using the supplied information.
@@ -54,14 +54,15 @@
      * @param groupId groupId
      * @param tunnelId tunnelId
      * @param tunnelName tunnel name
+     * @param path the path of tunnel
      * @param annotations optional key/value annotations
      */
     public DefaultTunnel(ProviderId producerName, TunnelEndPoint src,
                          TunnelEndPoint dst, Type type, DefaultGroupId groupId,
-                         TunnelId tunnelId, TunnelName tunnelName,
+                         TunnelId tunnelId, TunnelName tunnelName, Path path,
                          Annotations... annotations) {
         this(producerName, src, dst, type, Tunnel.State.ACTIVE, groupId,
-             tunnelId, tunnelName, annotations);
+             tunnelId, tunnelName, path, annotations);
     }
 
     /**
@@ -75,18 +76,14 @@
      * @param groupId groupId
      * @param tunnelId tunnelId
      * @param tunnelName tunnel name
+     * @param path the path of tunnel
      * @param annotations optional key/value annotations
      */
     public DefaultTunnel(ProviderId producerName, TunnelEndPoint src,
                          TunnelEndPoint dst, Type type, State state,
                          DefaultGroupId groupId, TunnelId tunnelId,
-                         TunnelName tunnelName, Annotations... annotations) {
+                         TunnelName tunnelName, Path path, Annotations... annotations) {
         super(producerName, annotations);
-        checkNotNull(producerName, "producerName cannot be null");
-        checkNotNull(src, "src cannot be null");
-        checkNotNull(dst, "dst cannot be null");
-        checkNotNull(type, "type cannot be null");
-        checkNotNull(state, "state cannot be null");
         this.src = src;
         this.dst = dst;
         this.type = type;
@@ -94,6 +91,7 @@
         this.groupId = groupId;
         this.tunnelId = tunnelId;
         this.tunnelName = tunnelName;
+        this.path = path;
     }
 
     @Override
@@ -136,10 +134,16 @@
         return tunnelName;
     }
 
+
+    @Override
+    public Path path() {
+        return path;
+    }
+
     @Override
     public int hashCode() {
         return Objects.hash(src, dst, type, groupId, tunnelId, tunnelName,
-                            state);
+                            state, path);
     }
 
     @Override
@@ -155,7 +159,8 @@
                     && Objects.equals(this.groupId, other.groupId)
                     && Objects.equals(this.tunnelId, other.tunnelId)
                     && Objects.equals(this.tunnelName, other.tunnelName)
-                    && Objects.equals(this.state, other.state);
+                    && Objects.equals(this.state, other.state)
+                    && Objects.equals(this.path, other.path);
         }
         return false;
     }
@@ -165,7 +170,7 @@
         return toStringHelper(this).add("src", src).add("dst", dst)
                 .add("type", type).add("state", state).add("groupId", groupId)
                 .add("producerTunnelId", tunnelId)
-                .add("tunnelName", tunnelName).toString();
+                .add("tunnelName", tunnelName)
+                .add("path", path).toString();
     }
-
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultTunnelDescription.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultTunnelDescription.java
old mode 100644
new mode 100755
index e4c4d89..347021d
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultTunnelDescription.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultTunnelDescription.java
@@ -13,12 +13,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.onosproject.incubator.net.tunnel;
 
-import static com.google.common.base.Preconditions.checkNotNull;
 import org.onosproject.core.DefaultGroupId;
 import org.onosproject.net.AbstractDescription;
+import org.onosproject.net.Path;
 import org.onosproject.net.SparseAnnotations;
 import org.onosproject.net.provider.ProviderId;
 
@@ -39,6 +38,7 @@
     // tunnel producer
     private final ProviderId producerName; // tunnel producer name
     private final TunnelName tunnelName; // name of a tunnel
+    private final Path path;
 
     /**
      * Creates a tunnel description using the supplied information.
@@ -50,6 +50,7 @@
      * @param groupId groupId
      * @param producerName tunnel producer
      * @param tunnelName tunnel name
+     * @param path the path of tunnel
      * @param annotations optional key/value annotations
      */
     public DefaultTunnelDescription(TunnelId id, TunnelEndPoint src,
@@ -57,12 +58,9 @@
                                     DefaultGroupId groupId,
                                     ProviderId producerName,
                                     TunnelName tunnelName,
+                                    Path path,
                                     SparseAnnotations... annotations) {
         super(annotations);
-        checkNotNull(producerName, "producerName cannot be null");
-        checkNotNull(src, "src cannot be null");
-        checkNotNull(dst, "dst cannot be null");
-        checkNotNull(type, "type cannot be null");
         this.tunnelId = id;
         this.src = src;
         this.dst = dst;
@@ -70,6 +68,7 @@
         this.groupId = groupId;
         this.producerName = producerName;
         this.tunnelName = tunnelName;
+        this.path = path;
     }
 
     @Override
@@ -107,6 +106,12 @@
         return tunnelName;
     }
 
+
+    @Override
+    public Path path() {
+        return path;
+    }
+
     @Override
     public String toString() {
         return MoreObjects.toStringHelper(this)
@@ -117,7 +122,7 @@
                 .add("tunnelName", tunnelName())
                 .add("producerName", producerName())
                 .add("groupId", groupId())
+                .add("path", path)
                 .toString();
     }
-
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/Tunnel.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/Tunnel.java
old mode 100644
new mode 100755
index 8b80b86..edbbe1b
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/Tunnel.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/Tunnel.java
@@ -13,12 +13,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.onosproject.incubator.net.tunnel;
 
 import org.onosproject.core.DefaultGroupId;
 import org.onosproject.net.Annotated;
 import org.onosproject.net.NetworkResource;
+import org.onosproject.net.Path;
 import org.onosproject.net.Provided;
 
 /**
@@ -144,4 +144,10 @@
      */
     NetworkResource resource();
 
+    /**
+     * Returns the path of the tunnel.
+     *
+     * @return the path of the tunnel
+     */
+    Path path();
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelDescription.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelDescription.java
old mode 100644
new mode 100755
index eca8fdd..dbcbc63
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelDescription.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelDescription.java
@@ -13,14 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.onosproject.incubator.net.tunnel;
 
 import org.onosproject.core.DefaultGroupId;
+import org.onosproject.incubator.net.tunnel.Tunnel.Type;
 import org.onosproject.net.Annotated;
 import org.onosproject.net.Description;
+import org.onosproject.net.Path;
 import org.onosproject.net.provider.ProviderId;
-import org.onosproject.incubator.net.tunnel.Tunnel.Type;
 
 /**
  * Describes a tunnel.
@@ -75,4 +75,11 @@
      * @return Tunnel Name
      */
     TunnelName tunnelName();
+
+    /**
+     * Returns the path of the tunnel.
+     *
+     * @return the path of the tunnel
+     */
+    Path path();
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelId.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelId.java
index b596700..0cbad8c 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelId.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelId.java
@@ -16,7 +16,6 @@
 
 package org.onosproject.incubator.net.tunnel;
 
-import static com.google.common.base.Preconditions.checkArgument;
 
 /**
  * Representation of a Tunnel Id.
@@ -35,8 +34,7 @@
     }
 
     public static TunnelId valueOf(String value) {
-        checkArgument(value.startsWith("0x"));
-         return new TunnelId(Long.parseLong(value.substring("0x".length()), 16));
+         return new TunnelId(Long.parseLong(value));
     }
 
     /**
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelProvider.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelProvider.java
index f01bb61..1107fc1 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelProvider.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelProvider.java
@@ -102,4 +102,12 @@
      * @param tunnel tunnel information
      */
     void tunnelUpdated(TunnelDescription tunnel);
+
+    /**
+     * Signals that the a tunnel was queried.
+     * It's used by producers.
+     * @param tunnelId tunnel identity
+     * @return tunnel entity
+     */
+    Tunnel tunnelQueryById(TunnelId tunnelId);
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelProviderService.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelProviderService.java
index 9049299..84f8f24 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelProviderService.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelProviderService.java
@@ -45,4 +45,12 @@
      */
     void tunnelUpdated(TunnelDescription tunnel);
 
+    /**
+     * Signals that the a tunnel was queried.
+     *
+     * @param tunnelId tunnel identity
+     * @return tunnel entity
+     */
+    Tunnel tunnelQueryById(TunnelId tunnelId);
+
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelService.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelService.java
index f2611fa..3cce69b 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelService.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelService.java
@@ -13,12 +13,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.onosproject.incubator.net.tunnel;
 
 import java.util.Collection;
 
 import org.onosproject.core.ApplicationId;
+import org.onosproject.incubator.net.tunnel.Tunnel.Type;
 import org.onosproject.net.Annotations;
 
 /**
@@ -83,7 +83,7 @@
      * @return collection of available Tunnels
      */
     Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src,
-                                       TunnelEndPoint dst, Tunnel.Type type,
+                                       TunnelEndPoint dst, Type type,
                                        Annotations... annotations);
 
     /**
@@ -122,7 +122,7 @@
      * @return success or fail
      */
     boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src,
-                              TunnelEndPoint dst, Tunnel.Type type,
+                              TunnelEndPoint dst, Type type,
                               Annotations... annotations);
 
     /**
@@ -160,7 +160,7 @@
      * @param type tunnel type
      * @return Collection of tunnels
      */
-    Collection<Tunnel> queryTunnel(Tunnel.Type type);
+    Collection<Tunnel> queryTunnel(Type type);
 
     /**
      * Returns all tunnels between source point and destination point.
@@ -174,6 +174,13 @@
     /**
      * Returns all tunnels.
      *
+     * @return Collection of tunnels
+     */
+    Collection<Tunnel> queryAllTunnels();
+
+    /**
+     * Returns all tunnels.
+     *
      * @return all tunnels
      */
     int tunnelCount();
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelStore.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelStore.java
index 3286ef2..b773611 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelStore.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelStore.java
@@ -13,15 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.onosproject.incubator.net.tunnel;
 
 import java.util.Collection;
 
 import org.onosproject.core.ApplicationId;
+import org.onosproject.incubator.net.tunnel.Tunnel.Type;
 import org.onosproject.net.Annotations;
 import org.onosproject.net.provider.ProviderId;
-import org.onosproject.incubator.net.tunnel.Tunnel.Type;
 import org.onosproject.store.Store;
 
 /**
@@ -215,6 +214,13 @@
 
     /**
      * Returns all tunnels.
+     *
+     * @return Collection of tunnels
+     */
+    Collection<Tunnel> queryAllTunnels();
+
+    /**
+     * Returns all tunnels.
      * @return all tunnels
      */
     int tunnelCount();
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/DefaultTunnelTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/DefaultTunnelTest.java
index bab9ff0..ae94991 100644
--- a/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/DefaultTunnelTest.java
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/DefaultTunnelTest.java
@@ -1,19 +1,3 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
 package org.onosproject.incubator.net.tunnel;
 
 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
@@ -50,13 +34,13 @@
         ProviderId producerName2 = new ProviderId("producer2", "13");
         Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
                                       Tunnel.State.ACTIVE, groupId, tunnelId,
-                                      tunnelName);
+                                      tunnelName, null);
         Tunnel p2 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
                                       Tunnel.State.ACTIVE, groupId, tunnelId,
-                                      tunnelName);
+                                      tunnelName, null);
         Tunnel p3 = new DefaultTunnel(producerName2, src, dst, Tunnel.Type.OCH,
                                       Tunnel.State.ACTIVE, groupId, tunnelId,
-                                      tunnelName);
+                                      tunnelName, null);
         new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3)
                 .testEquals();
     }
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/TunnelEventTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/TunnelEventTest.java
index 6f330a7..a58e10b 100644
--- a/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/TunnelEventTest.java
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/tunnel/TunnelEventTest.java
@@ -1,19 +1,3 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
 package org.onosproject.incubator.net.tunnel;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -53,7 +37,7 @@
         ProviderId producerName1 = new ProviderId("producer1", "13");
         Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
                                       Tunnel.State.ACTIVE, groupId, tunnelId,
-                                      tunnelName);
+                                      tunnelName, null);
         TunnelEvent e1 = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, p1);
         assertThat(e1, is(notNullValue()));
         assertThat(e1.type(), is(TunnelEvent.Type.TUNNEL_ADDED));
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/resource/label/impl/LabelResourceManager.java b/incubator/net/src/main/java/org/onosproject/incubator/net/resource/label/impl/LabelResourceManager.java
index 94daed0..2836ea5 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/resource/label/impl/LabelResourceManager.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/resource/label/impl/LabelResourceManager.java
@@ -91,9 +91,9 @@
         checkNotNull(deviceId, "deviceId is not null");
         checkNotNull(beginLabel, "beginLabel is not null");
         checkNotNull(endLabel, "beginLabel is not null");
-        checkArgument(beginLabel.labelId() < 0 || endLabel.labelId() < 0,
+        checkArgument(beginLabel.labelId() >= 0 || endLabel.labelId() >= 0,
                       "The value of beginLabel and the value of endLabel must be both positive number.");
-        checkArgument(beginLabel.labelId() > endLabel.labelId(),
+        checkArgument(beginLabel.labelId() <= endLabel.labelId(),
                       "The value of endLabel must be greater than the value of endLabel.");
         return store.createDevicePool(deviceId, beginLabel, endLabel);
     }
@@ -103,10 +103,10 @@
                                     LabelResourceId endLabel) {
         checkNotNull(beginLabel, "beginLabel is not null");
         checkNotNull(endLabel, "beginLabel is not null");
-        checkArgument(beginLabel.labelId() < 0 || endLabel.labelId() < 0,
-                      "The value of beginLabel and the value of endLabel must be both positive number.");
-        checkArgument(beginLabel.labelId() > endLabel.labelId(),
-                      "The value of endLabel must be greater than the value of endLabel.");
+        checkArgument(beginLabel.labelId() >= 0 && endLabel.labelId() >= 0,
+                "The value of beginLabel and the value of endLabel must be both positive number.");
+        checkArgument(beginLabel.labelId() <= endLabel.labelId(),
+                "The value of endLabel must be greater than the value of endLabel.");
         return store.createGlobalPool(beginLabel, endLabel);
     }
 
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/tunnel/impl/TunnelManager.java b/incubator/net/src/main/java/org/onosproject/incubator/net/tunnel/impl/TunnelManager.java
index c2c9975..3350cd1 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/tunnel/impl/TunnelManager.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/tunnel/impl/TunnelManager.java
@@ -13,7 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.onosproject.incubator.net.tunnel.impl;
 
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -31,14 +30,9 @@
 import org.onosproject.core.ApplicationId;
 import org.onosproject.event.EventDeliveryService;
 import org.onosproject.event.ListenerRegistry;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.Path;
-import org.onosproject.net.provider.AbstractProviderRegistry;
-import org.onosproject.net.provider.AbstractProviderService;
-import org.onosproject.net.provider.ProviderId;
 import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.tunnel.Tunnel;
 import org.onosproject.incubator.net.tunnel.Tunnel.Type;
+import org.onosproject.incubator.net.tunnel.Tunnel;
 import org.onosproject.incubator.net.tunnel.TunnelAdminService;
 import org.onosproject.incubator.net.tunnel.TunnelDescription;
 import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
@@ -53,6 +47,11 @@
 import org.onosproject.incubator.net.tunnel.TunnelStore;
 import org.onosproject.incubator.net.tunnel.TunnelStoreDelegate;
 import org.onosproject.incubator.net.tunnel.TunnelSubscription;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.Path;
+import org.onosproject.net.provider.AbstractProviderRegistry;
+import org.onosproject.net.provider.AbstractProviderService;
+import org.onosproject.net.provider.ProviderId;
 import org.slf4j.Logger;
 
 /**
@@ -277,6 +276,12 @@
         return store.queryTunnel(src, dst);
     }
 
+
+    @Override
+    public Collection<Tunnel> queryAllTunnels() {
+        return store.queryAllTunnels();
+    }
+
     @Override
     public int tunnelCount() {
         return store.tunnelCount();
@@ -313,6 +318,7 @@
                                                     tunnel.groupId(),
                                                     tunnel.id(),
                                                     tunnel.tunnelName(),
+                                                    tunnel.path(),
                                                     tunnel.annotations());
             return store.createOrUpdateTunnel(storedTunnel);
         }
@@ -325,6 +331,7 @@
                                                     tunnel.groupId(),
                                                     tunnel.id(),
                                                     tunnel.tunnelName(),
+                                                    tunnel.path(),
                                                     tunnel.annotations());
             store.createOrUpdateTunnel(storedTunnel);
         }
@@ -333,18 +340,28 @@
         public void tunnelRemoved(TunnelDescription tunnel) {
             if (tunnel.id() != null) {
                 store.deleteTunnel(tunnel.id());
+                return;
             }
             if (tunnel.src() != null && tunnel.dst() != null
                     && tunnel.type() != null) {
                 store.deleteTunnel(tunnel.src(), tunnel.dst(), tunnel.type(),
                                    provider().id());
+                return;
             }
             if (tunnel.src() != null && tunnel.dst() != null
                     && tunnel.type() == null) {
                 store.deleteTunnel(tunnel.src(), tunnel.dst(), provider().id());
+                return;
             }
         }
 
+
+        @Override
+        public Tunnel tunnelQueryById(TunnelId tunnelId) {
+            return store.queryTunnel(tunnelId);
+        }
+
+
     }
 
     private class InternalStoreDelegate implements TunnelStoreDelegate {
@@ -355,4 +372,5 @@
             }
         }
     }
+
 }
diff --git a/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/DistributedLabelResourceStore.java b/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/DistributedLabelResourceStore.java
index 09a558d..bc1edf1 100644
--- a/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/DistributedLabelResourceStore.java
+++ b/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/DistributedLabelResourceStore.java
@@ -15,7 +15,6 @@
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
@@ -25,9 +24,6 @@
 import org.apache.felix.scr.annotations.Service;
 import org.onlab.util.KryoNamespace;
 import org.onosproject.cluster.ClusterService;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DeviceService;
 import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
 import org.onosproject.incubator.net.resource.label.LabelResource;
 import org.onosproject.incubator.net.resource.label.LabelResourceDelegate;
@@ -37,6 +33,9 @@
 import org.onosproject.incubator.net.resource.label.LabelResourcePool;
 import org.onosproject.incubator.net.resource.label.LabelResourceRequest;
 import org.onosproject.incubator.net.resource.label.LabelResourceStore;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.device.DeviceService;
 import org.onosproject.store.AbstractStore;
 import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
 import org.onosproject.store.cluster.messaging.ClusterMessage;
@@ -44,11 +43,10 @@
 import org.onosproject.store.flow.ReplicaInfo;
 import org.onosproject.store.flow.ReplicaInfoService;
 import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.serializers.KryoSerializer;
-import org.onosproject.store.serializers.custom.DistributedStoreSerializers;
 import org.onosproject.store.service.ConsistentMap;
 import org.onosproject.store.service.Serializer;
 import org.onosproject.store.service.StorageService;
+import org.onosproject.store.service.Versioned;
 import org.slf4j.Logger;
 
 import com.google.common.collect.ImmutableSet;
@@ -67,9 +65,6 @@
     private static final String POOL_MAP_NAME = "labelresourcepool";
 
     private static final String GLOBAL_RESOURCE_POOL_DEVICE_ID = "global_resource_pool_device_id";
-    // primary data:
-    // read/write needs to be locked
-    private final ReentrantReadWriteLock resourcePoolLock = new ReentrantReadWriteLock();
 
     private ConsistentMap<DeviceId, LabelResourcePool> resourcePool = null;
 
@@ -92,41 +87,24 @@
     private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 8;
     private static final long PEER_REQUEST_TIMEOUT_MS = 5000;
 
-    protected static final KryoSerializer SERIALIZER = new KryoSerializer() {
-        @Override
-        protected void setupKryoPool() {
-            serializerPool = KryoNamespace.newBuilder()
-                    .register(DistributedStoreSerializers.STORE_COMMON)
-                    .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN)
+    private static final Serializer SERIALIZER = Serializer
+            .using(new KryoNamespace.Builder().register(KryoNamespaces.API)
                     .register(LabelResourceEvent.class)
                     .register(LabelResourcePool.class).register(DeviceId.class)
                     .register(LabelResourceRequest.class)
                     .register(LabelResourceRequest.Type.class)
                     .register(LabelResourceEvent.Type.class)
                     .register(DefaultLabelResource.class)
-                    .register(LabelResourceId.class).build();
-        }
-    };
+                    .register(LabelResourceId.class)
+                    .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID).build());
 
     @Activate
     public void activate() {
 
         resourcePool = storageService
                 .<DeviceId, LabelResourcePool>consistentMapBuilder()
-                .withName(POOL_MAP_NAME).withSerializer(new Serializer() {
-                    KryoNamespace kryo = new KryoNamespace.Builder()
-                            .register(KryoNamespaces.API).build();
-
-                    @Override
-                    public <T> byte[] encode(T object) {
-                        return kryo.serialize(object);
-                    }
-
-                    @Override
-                    public <T> T decode(byte[] bytes) {
-                        return kryo.deserialize(bytes);
-                    }
-                }).withPartitionsDisabled().build();
+                .withName(POOL_MAP_NAME).withSerializer(SERIALIZER)
+                .withPartitionsDisabled().build();
         messageHandlingExecutor = Executors
                 .newFixedThreadPool(MESSAGE_HANDLER_THREAD_POOL_SIZE,
                                     groupedThreads("onos/store/flow",
@@ -142,7 +120,7 @@
                                        log.trace("received get flow entry request for {}",
                                                  operation);
                                        boolean b = internalCreate(operation);
-                                           message.respond(SERIALIZER.encode(b));
+                                       message.respond(SERIALIZER.encode(b));
                                    }
                                }, messageHandlingExecutor);
         clusterCommunicator
@@ -156,7 +134,7 @@
                                        log.trace("received get flow entry request for {}",
                                                  deviceId);
                                        boolean b = internalDestroy(deviceId);
-                                           message.respond(SERIALIZER.encode(b));
+                                       message.respond(SERIALIZER.encode(b));
                                    }
                                }, messageHandlingExecutor);
         clusterCommunicator
@@ -170,8 +148,8 @@
                                        log.trace("received get flow entry request for {}",
                                                  request);
                                        final Collection<LabelResource> resource = internalApply(request);
-                                           message.respond(SERIALIZER
-                                                   .encode(resource));
+                                       message.respond(SERIALIZER
+                                               .encode(resource));
                                    }
                                }, messageHandlingExecutor);
         clusterCommunicator
@@ -185,8 +163,8 @@
                                        log.trace("received get flow entry request for {}",
                                                  request);
                                        final boolean isSuccess = internalRelease(request);
-                                           message.respond(SERIALIZER
-                                                   .encode(isSuccess));
+                                       message.respond(SERIALIZER
+                                               .encode(isSuccess));
                                    }
                                }, messageHandlingExecutor);
         log.info("Started");
@@ -256,18 +234,16 @@
     }
 
     private boolean internalCreate(LabelResourcePool pool) {
-        resourcePoolLock.writeLock().lock();
-        LabelResourcePool poolOld = resourcePool.get(pool.deviceId()).value();
+        Versioned<LabelResourcePool> poolOld = resourcePool
+                .get(pool.deviceId());
         if (poolOld == null) {
             resourcePool.put(pool.deviceId(), pool);
-            resourcePoolLock.writeLock().unlock();
             LabelResourceEvent event = new LabelResourceEvent(
                                                               Type.POOL_CREATED,
                                                               pool);
             notifyDelegate(event);
             return true;
         }
-        resourcePoolLock.writeLock().unlock();
         return false;
     }
 
@@ -301,12 +277,12 @@
     }
 
     private boolean internalDestroy(DeviceId deviceId) {
-        LabelResourcePool poolOld = resourcePool.get(deviceId).value();
+        Versioned<LabelResourcePool> poolOld = resourcePool.get(deviceId);
         if (poolOld != null) {
             resourcePool.remove(deviceId);
             LabelResourceEvent event = new LabelResourceEvent(
                                                               Type.POOL_CREATED,
-                                                              poolOld);
+                                                              poolOld.value());
             notifyDelegate(event);
         }
         log.info("success to destroy the label resource pool of device id {}",
@@ -349,15 +325,14 @@
     }
 
     private Collection<LabelResource> internalApply(LabelResourceRequest request) {
-        resourcePoolLock.writeLock().lock();
         DeviceId deviceId = request.deviceId();
         long applyNum = request.applyNum();
-        LabelResourcePool pool = resourcePool.get(deviceId).value();
+        Versioned<LabelResourcePool> poolOld = resourcePool.get(deviceId);
+        LabelResourcePool pool = poolOld.value();
         Collection<LabelResource> result = new HashSet<LabelResource>();
         long freeNum = this.getFreeNumOfDevicePool(deviceId);
         if (applyNum > freeNum) {
             log.info("the free number of the label resource pool of deviceId {} is not enough.");
-            resourcePoolLock.writeLock().unlock();
             return Collections.emptyList();
         }
         Set<LabelResource> releaseLabels = new HashSet<LabelResource>(
@@ -393,7 +368,6 @@
                                                           current, freeLabel);
         resourcePool.put(deviceId, newPool);
         log.info("success to apply label resource");
-        resourcePoolLock.writeLock().unlock();
         return result;
     }
 
@@ -440,12 +414,11 @@
     }
 
     private boolean internalRelease(LabelResourceRequest request) {
-        resourcePoolLock.writeLock().lock();
         DeviceId deviceId = request.deviceId();
         Collection<LabelResource> release = request.releaseCollection();
-        LabelResourcePool pool = resourcePool.get(deviceId).value();
+        Versioned<LabelResourcePool> poolOld = resourcePool.get(deviceId);
+        LabelResourcePool pool = poolOld.value();
         if (pool == null) {
-            resourcePoolLock.writeLock().unlock();
             log.info("the label resource pool of device id {} does not exist");
             return false;
         }
@@ -480,34 +453,34 @@
                                                           current, s);
         resourcePool.put(deviceId, newPool);
         log.info("success to release label resource");
-        resourcePoolLock.writeLock().unlock();
         return true;
     }
 
     @Override
     public boolean isDevicePoolFull(DeviceId deviceId) {
-        LabelResourcePool pool = resourcePool.get(deviceId).value();
+        Versioned<LabelResourcePool> pool = resourcePool.get(deviceId);
         if (pool == null) {
             return true;
         }
-        return pool.currentUsedMaxLabelId() == pool.endLabel()
-                && pool.releaseLabelId().size() == 0 ? true : false;
+        return pool.value().currentUsedMaxLabelId() == pool.value().endLabel()
+                && pool.value().releaseLabelId().size() == 0 ? true : false;
     }
 
     @Override
     public long getFreeNumOfDevicePool(DeviceId deviceId) {
-        LabelResourcePool pool = resourcePool.get(deviceId).value();
+        Versioned<LabelResourcePool> pool = resourcePool.get(deviceId);
         if (pool == null) {
             return 0;
         }
-        return pool.endLabel().labelId()
-                - pool.currentUsedMaxLabelId().labelId()
-                + pool.releaseLabelId().size();
+        return pool.value().endLabel().labelId()
+                - pool.value().currentUsedMaxLabelId().labelId()
+                + pool.value().releaseLabelId().size();
     }
 
     @Override
     public LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId) {
-        return resourcePool.get(deviceId).value();
+        Versioned<LabelResourcePool> pool = resourcePool.get(deviceId);
+        return pool == null ? null : pool.value();
     }
 
     @Override
@@ -564,8 +537,7 @@
 
     private <T> T complete(Future<T> future) {
         try {
-            return future.get(PEER_REQUEST_TIMEOUT_MS,
-                                                TimeUnit.MILLISECONDS);
+            return future.get(PEER_REQUEST_TIMEOUT_MS, TimeUnit.MILLISECONDS);
         } catch (InterruptedException e) {
             Thread.currentThread().interrupt();
             log.error("Interrupted while waiting for operation to complete.", e);
diff --git a/incubator/store/src/main/java/org/onosproject/incubator/store/tunnel/impl/DistributedTunnelStore.java b/incubator/store/src/main/java/org/onosproject/incubator/store/tunnel/impl/DistributedTunnelStore.java
index b49743c..7d99586 100644
--- a/incubator/store/src/main/java/org/onosproject/incubator/store/tunnel/impl/DistributedTunnelStore.java
+++ b/incubator/store/src/main/java/org/onosproject/incubator/store/tunnel/impl/DistributedTunnelStore.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Open Networking Laboratory
+ * Copyright 2014-2015 Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,7 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.onosproject.incubator.store.tunnel.impl;
 
 import static org.slf4j.LoggerFactory.getLogger;
@@ -37,8 +36,6 @@
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
 import org.onosproject.core.IdGenerator;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.provider.ProviderId;
 import org.onosproject.incubator.net.tunnel.DefaultTunnel;
 import org.onosproject.incubator.net.tunnel.Tunnel;
 import org.onosproject.incubator.net.tunnel.Tunnel.Type;
@@ -49,6 +46,10 @@
 import org.onosproject.incubator.net.tunnel.TunnelStore;
 import org.onosproject.incubator.net.tunnel.TunnelStoreDelegate;
 import org.onosproject.incubator.net.tunnel.TunnelSubscription;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.provider.ProviderId;
 import org.onosproject.store.AbstractStore;
 import org.onosproject.store.app.GossipApplicationStore.InternalState;
 import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
@@ -126,6 +127,10 @@
                 .<Tunnel.Type, Set<TunnelId>>eventuallyConsistentMapBuilder()
                 .withName("type_tunnel").withSerializer(serializer)
                 .withClockService(new WallclockClockManager<>()).build();
+        orderRelationship = storageService
+                .<ApplicationId, Set<TunnelSubscription>>eventuallyConsistentMapBuilder()
+                .withName("type_tunnel").withSerializer(serializer)
+                .withClockService(new WallclockClockManager<>()).build();
         idGenerator = coreService.getIdGenerator(runnelOpTopoic);
         log.info("Started");
     }
@@ -148,13 +153,15 @@
                 log.info("This tunnel[" + tunnel.tunnelId() + "] is not available.");
                 return tunnel.tunnelId();
             }
-            Tunnel newT = new DefaultTunnel(tunnel.providerId(), tunnel.src(),
-                                            tunnel.dst(), tunnel.type(),
-                                            tunnel.state(), tunnel.groupId(),
+            DefaultAnnotations oldAnno = (DefaultAnnotations) old.annotations();
+            SparseAnnotations newAnno = (SparseAnnotations) tunnel.annotations();
+            Tunnel newT = new DefaultTunnel(old.providerId(), old.src(),
+                                            old.dst(), old.type(),
+                                            old.state(), old.groupId(),
                                             old.tunnelId(),
-                                            tunnel.tunnelName(),
-                                            tunnel.annotations());
-            tunnelIdAsKeyStore.remove(tunnel.tunnelId());
+                                            old.tunnelName(),
+                                            old.path(),
+                                            DefaultAnnotations.merge(oldAnno, newAnno));
             tunnelIdAsKeyStore.put(tunnel.tunnelId(), newT);
             TunnelEvent event = new TunnelEvent(
                                                 TunnelEvent.Type.TUNNEL_UPDATED,
@@ -168,6 +175,7 @@
                                             tunnel.state(), tunnel.groupId(),
                                             tunnelId,
                                             tunnel.tunnelName(),
+                                            tunnel.path(),
                                             tunnel.annotations());
             TunnelKey key = TunnelKey.tunnelKey(tunnel.src(), tunnel.dst());
             tunnelIdAsKeyStore.put(tunnelId, newT);
@@ -463,6 +471,11 @@
     }
 
     @Override
+    public Collection<Tunnel> queryAllTunnels() {
+        return tunnelIdAsKeyStore.values();
+    }
+
+    @Override
     public int tunnelCount() {
         return tunnelIdAsKeyStore.size();
     }
@@ -515,5 +528,4 @@
                     .add("dst", dst).toString();
         }
     }
-
 }