[ONOS-5731] Implement skeleton of VirtualNetworkPacketManager

Changes
1. Added VirtualNetworkPacketManager
2. Added VirtualNetworkPacketStore interface and impl class
3. Added VirtualPacketStore impl
4. Simple test cases are added

Todo
1. More test cases

Change-Id: I86f0484a9ee038dab8716703f0e5e41cbcf30cb1
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/AbstractVnetService.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/AbstractVnetService.java
index 2eac0af..3700e28 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/AbstractVnetService.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/AbstractVnetService.java
@@ -16,7 +16,6 @@
 
 package org.onosproject.incubator.net.virtual;
 
-import org.onlab.osgi.DefaultServiceDirectory;
 import org.onlab.osgi.ServiceDirectory;
 
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -38,7 +37,7 @@
         checkNotNull(networkId, NETWORK_NULL);
         this.manager = manager;
         this.networkId = networkId;
-        this.serviceDirectory = new DefaultServiceDirectory();
+        this.serviceDirectory = manager.getServiceDirectory();
     }
 
     @Override
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkPacketStore.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkPacketStore.java
new file mode 100644
index 0000000..320424b
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkPacketStore.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2016-present 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.virtual;
+
+import org.onosproject.net.packet.OutboundPacket;
+import org.onosproject.net.packet.PacketEvent;
+import org.onosproject.net.packet.PacketRequest;
+import org.onosproject.net.packet.PacketStoreDelegate;
+
+import java.util.List;
+
+public interface VirtualNetworkPacketStore
+        extends VirtualStore<PacketEvent, PacketStoreDelegate> {
+    /**
+     * Decides which instance should emit the packet and forwards the packet to
+     * that instance. The relevant PacketManager is notified via the
+     * PacketStoreDelegate that it should emit the packet.
+     *
+     * @param networkId a virtual network identifier
+     * @param packet the packet to emit
+     */
+    void emit(NetworkId networkId, OutboundPacket packet);
+
+    /**
+     * Requests intercept of packets that match the given selector.
+     *
+     * @param networkId a virtual network identifier
+     * @param request a packet request
+     */
+    void requestPackets(NetworkId networkId, PacketRequest request);
+
+    /**
+     * Cancels intercept of packets that match the given selector.
+     *
+     * @param networkId a virtual network identifier
+     * @param request a packet request
+     */
+    void cancelPackets(NetworkId networkId, PacketRequest request);
+
+    /**
+     * Obtains all existing requests in the system.
+     *
+     * @param networkId a virtual network identifier
+     * @return list of packet requests in order of priority
+     */
+    List<PacketRequest> existingRequests(NetworkId networkId);
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkService.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkService.java
index 2e852e8..21f721c 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkService.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkService.java
@@ -17,6 +17,7 @@
 
 import com.google.common.annotations.Beta;
 import org.onlab.osgi.ServiceDirectory;
+import org.onosproject.core.ApplicationId;
 import org.onosproject.net.DeviceId;
 
 import java.util.Set;
@@ -112,4 +113,12 @@
      * @return a service directory
      */
     ServiceDirectory getServiceDirectory();
+
+    /**
+     * Returns the application identifier for a virtual network.
+     *
+     * @param networkId network identifier
+     * @return an representative application identifier for a virtual network
+     */
+    ApplicationId getVirtualNetworkApplicationId(NetworkId networkId);
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/provider/VirtualPacketProviderService.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/provider/VirtualPacketProviderService.java
index 28272d6..9facc1b 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/provider/VirtualPacketProviderService.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/provider/VirtualPacketProviderService.java
@@ -15,7 +15,6 @@
  */
 package org.onosproject.incubator.net.virtual.provider;
 
-import org.onosproject.incubator.net.virtual.NetworkId;
 import org.onosproject.net.packet.PacketContext;
 
 /**
@@ -29,9 +28,8 @@
      * This processing will be done synchronously, i.e. run-to-completion.
      * This context is translated with virtual concepts.
      *
-     * @param networkId the virtual network ID which will handle the packet context
      * @param context inbound packet context
      */
-    void processPacket(NetworkId networkId, PacketContext context);
+    void processPacket(PacketContext context);
 
 }
diff --git a/incubator/api/src/test/java/org/onosproject/incubator/net/virtual/event/AbstractVirtualListenerManagerTest.java b/incubator/api/src/test/java/org/onosproject/incubator/net/virtual/event/AbstractVirtualListenerManagerTest.java
index 33fce56..1195e69 100644
--- a/incubator/api/src/test/java/org/onosproject/incubator/net/virtual/event/AbstractVirtualListenerManagerTest.java
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/virtual/event/AbstractVirtualListenerManagerTest.java
@@ -22,6 +22,7 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.onlab.osgi.ServiceDirectory;
+import org.onosproject.core.ApplicationId;
 import org.onosproject.event.AbstractEvent;
 import org.onosproject.event.Event;
 import org.onosproject.event.EventDeliveryService;
@@ -295,6 +296,11 @@
         public ServiceDirectory getServiceDirectory() {
             return serviceDirectory;
         }
+
+        @Override
+        public ApplicationId getVirtualNetworkApplicationId(NetworkId networkId) {
+            return null;
+        }
     }
 
     private  class TestServiceDirectory implements ServiceDirectory {