Detangling incubator: virtual nets, tunnels, resource labels, oh my

- virtual networking moved to /apps/virtual; with CLI & REST API
- tunnels and labels moved to /apps/tunnel; with CLI & REST API; UI disabled for now
- protobuf/models moved to /core/protobuf/models
- defunct grpc/rpc registry stuff left under /graveyard
- compile dependencies on /incubator moved to respective modules for compilation
- run-time dependencies will need to be re-tested for dependent apps

- /graveyard will be removed in not-too-distant future

Change-Id: I0a0b995c635487edcf95a352f50dd162186b0b39
diff --git a/core/net/BUILD b/core/net/BUILD
index 571c45a..fc6c46d 100644
--- a/core/net/BUILD
+++ b/core/net/BUILD
@@ -1,9 +1,6 @@
 COMPILE_DEPS = CORE_DEPS + JACKSON + METRICS + KRYO + [
     "//core/common:onos-core-common",
-    "//incubator/api:onos-incubator-api",
     "//utils/rest:onlab-rest",
-    "//incubator/net:onos-incubator-net",
-    "//incubator/store:onos-incubator-store",
     "//core/store/serializers:onos-core-serializers",
     "//core/store/primitives:onos-core-primitives",
     "@org_osgi_service_cm//jar",
diff --git a/core/net/src/main/java/org/onosproject/net/config/impl/BasicNetworkConfigs.java b/core/net/src/main/java/org/onosproject/net/config/impl/BasicNetworkConfigs.java
index f5791de..a5d06a8 100644
--- a/core/net/src/main/java/org/onosproject/net/config/impl/BasicNetworkConfigs.java
+++ b/core/net/src/main/java/org/onosproject/net/config/impl/BasicNetworkConfigs.java
@@ -17,7 +17,7 @@
 
 import com.google.common.collect.ImmutableSet;
 import org.onosproject.core.CoreService;
-import org.onosproject.incubator.net.config.basics.PortDescriptionsConfig;
+import org.onosproject.net.config.basics.PortDescriptionsConfig;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.HostId;
diff --git a/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java b/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
index 4caf74e..98880db 100644
--- a/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
+++ b/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
@@ -23,7 +23,7 @@
 import org.onlab.util.Tools;
 import org.onosproject.cluster.ClusterService;
 import org.onosproject.cluster.NodeId;
-import org.onosproject.incubator.net.config.basics.PortDescriptionsConfig;
+import org.onosproject.net.config.basics.PortDescriptionsConfig;
 import org.onosproject.mastership.MastershipEvent;
 import org.onosproject.mastership.MastershipListener;
 import org.onosproject.mastership.MastershipService;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/VirtualNetworkIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/VirtualNetworkIntentCompiler.java
deleted file mode 100644
index 3222714..0000000
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/VirtualNetworkIntentCompiler.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * 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.net.intent.impl.compiler;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onlab.osgi.ServiceDirectory;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.virtual.NetworkId;
-import org.onosproject.incubator.net.virtual.VirtualNetworkIntent;
-import org.onosproject.incubator.net.virtual.VirtualNetworkService;
-import org.onosproject.incubator.net.virtual.VirtualNetworkStore;
-import org.onosproject.incubator.net.virtual.VirtualPort;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.FilteredConnectPoint;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentCompilationException;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.Key;
-import org.onosproject.net.intent.PointToPointIntent;
-import org.onosproject.net.topology.TopologyService;
-import org.slf4j.Logger;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * An intent compiler for {@link org.onosproject.incubator.net.virtual.VirtualNetworkIntent}.
- */
-@Component(immediate = true)
-public class VirtualNetworkIntentCompiler
-        extends ConnectivityIntentCompiler<VirtualNetworkIntent> {
-
-    private final Logger log = getLogger(getClass());
-
-    private static final String NETWORK_ID = "networkId=";
-    protected static final String KEY_FORMAT = "{" + NETWORK_ID + "%s, src=%s, dst=%s}";
-
-    protected ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY)
-    protected VirtualNetworkService manager;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY)
-    protected IntentService intentService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY)
-    protected VirtualNetworkStore store;
-
-
-    @Activate
-    public void activate() {
-        intentManager.registerCompiler(VirtualNetworkIntent.class, this);
-    }
-
-    @Deactivate
-    public void deactivate() {
-        intentManager.unregisterCompiler(VirtualNetworkIntent.class);
-    }
-
-    @Override
-    public List<Intent> compile(VirtualNetworkIntent intent, List<Intent> installable) {
-
-        log.debug("Compiling intent: " + intent);
-        List<Intent> intents = new ArrayList<>();
-        Optional<Path> path = getPaths(intent).stream()
-                .findFirst();
-        if (path != null && path.isPresent()) {
-            List<Link> links = path.get().links();
-
-            // First create an intent between the intent ingress CP and the first link source CP,
-            // only if the two CPs are not the same.
-            Link firstLink = links.get(0);
-            if (!intent.ingressPoint().equals(firstLink.src())) {
-                intents.add(createPtPtIntent(intent, intent.ingressPoint(), firstLink.src()));
-            }
-
-            // Next create an intent between the intent egress CP and the last link destination CP,
-            // only if the two CPs are not the same.
-            Link lastLink = links.get(links.size() - 1);
-            if (!intent.egressPoint().equals(lastLink.dst())) {
-                intents.add(createPtPtIntent(intent, lastLink.dst(), intent.egressPoint()));
-            }
-
-            // Now loop through all of the virtual links in the path and create an intent.
-            // An intent is also created connecting two virtual links.
-            final int[] index = {0};
-            links.forEach(link -> {
-                intents.add(createPtPtIntent(intent, link.src(), link.dst()));
-                if (index[0] > 0) {
-                    Link previousLink = links.get(index[0] - 1);
-                    intents.add(createPtPtIntent(intent, previousLink.dst(), link.src()));
-                }
-                index[0]++;
-            });
-        } else {
-            throw new IntentCompilationException("Unable to find a path for intent " + intent);
-        }
-
-        return intents;
-    }
-
-    /**
-     * Returns the paths for the virtual network intent.
-     *
-     * @param intent virtual network intent
-     * @return set of paths
-     */
-    private Set<Path> getPaths(VirtualNetworkIntent intent) {
-
-        TopologyService topologyService = manager.get(intent.networkId(), TopologyService.class);
-        if (topologyService == null) {
-            throw new IntentCompilationException("topologyService is null");
-        }
-        return topologyService.getPaths(topologyService.currentTopology(),
-                                        intent.ingressPoint().deviceId(), intent.egressPoint().deviceId());
-    }
-
-    /**
-     * Encodes the key using the network identifier, application identifier, source and destination
-     * connect points.
-     *
-     * @param networkId     virtual network identifier
-     * @param applicationId application identifier
-     * @param src           source connect point
-     * @param dst           destination connect point
-     * @return encoded key
-     */
-
-    private static Key encodeKey(NetworkId networkId, ApplicationId applicationId, ConnectPoint src, ConnectPoint dst) {
-        String key = String.format(KEY_FORMAT, networkId, src, dst);
-        return Key.of(key, applicationId);
-    }
-
-    /**
-     * Creates a point-to-point intent using the virtual network intent between the source and destination
-     * connect point.
-     *
-     * @param intent virtual network intent
-     * @param src    source connect point
-     * @param dst    destination connect point
-     * @return point to point intent
-     */
-    private Intent createPtPtIntent(VirtualNetworkIntent intent, ConnectPoint src, ConnectPoint dst) {
-        ConnectPoint ingressPoint = mapVirtualToPhysicalPort(intent.networkId(), src);
-        ConnectPoint egressPoint = mapVirtualToPhysicalPort(intent.networkId(), dst);
-        Key intentKey = encodeKey(intent.networkId(), intent.appId(), ingressPoint, egressPoint);
-
-        // TODO Currently there can only be one intent between the ingress and egress across
-        // all virtual networks. We may want to support multiple intents between the same src/dst pairs.
-        PointToPointIntent physicalIntent = PointToPointIntent.builder()
-                .key(intentKey)
-                .appId(intent.appId())
-                .filteredIngressPoint(new FilteredConnectPoint(ingressPoint))
-                .filteredEgressPoint(new FilteredConnectPoint(egressPoint))
-                .constraints(intent.constraints())
-                .selector(intent.selector())
-                .treatment(intent.treatment())
-                .resourceGroup(intent.resourceGroup())
-                .build();
-        log.debug("Submitting physical intent: " + physicalIntent);
-        intentService.submit(physicalIntent);
-
-        // Store the physical intent against this virtual intent.
-        store.addTunnelId(intent, TunnelId.valueOf(physicalIntent.key().toString()));
-
-        return physicalIntent;
-    }
-
-    /**
-     * Maps the virtual connect point to a physical connect point.
-     *
-     * @param networkId virtual network identifier
-     * @param virtualCp virtual connect point
-     * @return physical connect point
-     */
-    private ConnectPoint mapVirtualToPhysicalPort(NetworkId networkId, ConnectPoint virtualCp) {
-        Set<VirtualPort> ports = manager.getVirtualPorts(networkId, virtualCp.deviceId());
-        for (VirtualPort port : ports) {
-            if (port.element().id().equals(virtualCp.elementId()) &&
-                    port.number().equals(virtualCp.port())) {
-                return new ConnectPoint(port.realizedBy().deviceId(), port.realizedBy().port());
-            }
-        }
-        return null;
-    }
-}
-
diff --git a/core/net/src/main/java/org/onosproject/net/statistic/impl/PortStatisticsManager.java b/core/net/src/main/java/org/onosproject/net/statistic/impl/PortStatisticsManager.java
new file mode 100644
index 0000000..da41750
--- /dev/null
+++ b/core/net/src/main/java/org/onosproject/net/statistic/impl/PortStatisticsManager.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.net.statistic.impl;
+
+import com.google.common.collect.Maps;
+import org.onosproject.net.statistic.PortStatisticsService;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.device.DeviceEvent;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.device.PortStatistics;
+import org.onosproject.net.statistic.DefaultLoad;
+import org.onosproject.net.statistic.Load;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.slf4j.Logger;
+
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static org.onosproject.net.PortNumber.portNumber;
+import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED;
+import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_REMOVED;
+import static org.onosproject.net.device.DeviceEvent.Type.PORT_STATS_UPDATED;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Implementation of the port statistics service.
+ */
+@Component(immediate = true, service = PortStatisticsService.class)
+public class PortStatisticsManager implements PortStatisticsService {
+
+    private final Logger log = getLogger(getClass());
+
+    private static final long POLL_FREQUENCY = 10_000; // milliseconds
+    private static final long STALE_LIMIT = (long) (1.5 * POLL_FREQUENCY);
+    private static final int SECOND = 1_000; // milliseconds
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    protected DeviceService deviceService;
+
+    private final DeviceListener deviceListener = new InternalDeviceListener();
+
+    private Map<ConnectPoint, DataPoint> current = Maps.newConcurrentMap();
+    private Map<ConnectPoint, DataPoint> previous = Maps.newConcurrentMap();
+
+    @Activate
+    public void activate() {
+        deviceService.addListener(deviceListener);
+        log.info("Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        deviceService.removeListener(deviceListener);
+        log.info("Stopped");
+    }
+
+    @Override
+    public Load load(ConnectPoint connectPoint) {
+        return load(connectPoint, MetricType.BYTES);
+    }
+
+    @Override
+    public Load load(ConnectPoint connectPoint, MetricType metricType) {
+        DataPoint c = current.get(connectPoint);
+        DataPoint p = previous.get(connectPoint);
+        long now = System.currentTimeMillis();
+
+        if (c != null && p != null && (now - c.time < STALE_LIMIT)) {
+            if (c.time > p.time + SECOND) {
+                long cve = getEgressValue(c.stats, metricType);
+                long cvi = getIngressValue(c.stats, metricType);
+                long pve = getEgressValue(p.stats, metricType);
+                long pvi = getIngressValue(p.stats, metricType);
+                //Use max of either Tx or Rx load as the total load of a port
+                Load load = null;
+                if (cve >= pve) {
+                    load = new DefaultLoad(cve, pve, (int) (c.time - p.time) / SECOND);
+                }
+                if (cvi >= pvi) {
+                    Load rcvLoad = new DefaultLoad(cvi, pvi, (int) (c.time - p.time) / SECOND);
+                    load = ((load == null) || (rcvLoad.rate() > load.rate())) ? rcvLoad : load;
+                }
+                return load;
+            }
+        }
+        return null;
+    }
+
+    private long getEgressValue(PortStatistics stats, MetricType metricType) {
+        return metricType == MetricType.BYTES ? stats.bytesSent() : stats.packetsSent();
+    }
+
+    private long getIngressValue(PortStatistics stats, MetricType metricType) {
+        return metricType == MetricType.BYTES ? stats.bytesReceived() : stats.packetsReceived();
+    }
+
+    // Monitors port stats update messages.
+    private class InternalDeviceListener implements DeviceListener {
+        @Override
+        public void event(DeviceEvent event) {
+            DeviceEvent.Type type = event.type();
+            DeviceId deviceId = event.subject().id();
+            if (type == PORT_STATS_UPDATED) {
+                // Update port load
+                updateDeviceData(deviceId);
+
+            } else if (type == DEVICE_REMOVED ||
+                    (type == DEVICE_AVAILABILITY_CHANGED &&
+                            !deviceService.isAvailable(deviceId))) {
+                // Clean-up all port loads
+                pruneDeviceData(deviceId);
+            }
+        }
+    }
+
+    // Updates the port stats for the specified device
+    private void updateDeviceData(DeviceId deviceId) {
+        deviceService.getPortStatistics(deviceId)
+                .forEach(stats -> updatePortData(deviceId, stats));
+    }
+
+    // Updates the port stats for the specified port
+    private void updatePortData(DeviceId deviceId, PortStatistics stats) {
+        ConnectPoint cp = new ConnectPoint(deviceId, portNumber(stats.port()));
+        DataPoint c = current.get(cp);
+
+        // Create a new data point and make it the current one
+        current.put(cp, new DataPoint(stats));
+
+        // If we have a current data point, demote it to previous
+        if (c != null) {
+            previous.put(cp, c);
+        }
+    }
+
+    // Cleans all port loads for the specified device
+    private void pruneDeviceData(DeviceId deviceId) {
+        pruneMap(current, deviceId);
+        pruneMap(previous, deviceId);
+    }
+
+    private void pruneMap(Map<ConnectPoint, DataPoint> map, DeviceId deviceId) {
+        map.keySet().stream().filter(cp -> deviceId.equals(cp.deviceId()))
+                .collect(Collectors.toSet()).forEach(map::remove);
+    }
+
+    // Auxiliary data point to track when we receive different samples.
+    private class DataPoint {
+        long time;
+        PortStatistics stats;
+
+        DataPoint(PortStatistics stats) {
+            time = System.currentTimeMillis();
+            this.stats = stats;
+        }
+    }
+
+}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/VirtualNetworkIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/VirtualNetworkIntentCompilerTest.java
deleted file mode 100644
index 0af5742..0000000
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/VirtualNetworkIntentCompilerTest.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * 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.net.intent.impl.compiler;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.osgi.TestServiceDirectory;
-import org.onosproject.TestApplicationId;
-import org.onosproject.common.event.impl.TestEventDispatcher;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.core.CoreServiceAdapter;
-import org.onosproject.core.IdGenerator;
-import org.onosproject.incubator.net.virtual.TenantId;
-import org.onosproject.incubator.net.virtual.VirtualDevice;
-import org.onosproject.incubator.net.virtual.VirtualLink;
-import org.onosproject.incubator.net.virtual.VirtualNetwork;
-import org.onosproject.incubator.net.virtual.VirtualNetworkIntent;
-import org.onosproject.incubator.net.virtual.VirtualNetworkService;
-import org.onosproject.incubator.net.virtual.VirtualNetworkStore;
-import org.onosproject.incubator.net.virtual.impl.VirtualNetworkManager;
-import org.onosproject.incubator.store.virtual.impl.DistributedVirtualNetworkStore;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultPort;
-import org.onosproject.net.Link;
-import org.onosproject.net.NetTestTools;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.TestDeviceParams;
-import org.onosproject.net.intent.FakeIntentManager;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentExtensionService;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.Key;
-import org.onosproject.net.intent.MockIdGenerator;
-import org.onosproject.net.intent.TestableIntentService;
-import org.onosproject.store.service.TestStorageService;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
-import static org.junit.Assert.assertEquals;
-import static org.onlab.junit.TestUtils.TestUtilsException;
-import static org.onlab.junit.TestUtils.setField;
-
-/**
- * Junit tests for virtual network intent compiler.
- */
-public class VirtualNetworkIntentCompilerTest extends TestDeviceParams {
-
-    private CoreService coreService;
-    private TestableIntentService intentService = new FakeIntentManager();
-    private IntentExtensionService intentExtensionService;
-    private VirtualNetworkIntentCompiler compiler;
-    private VirtualNetworkManager manager;
-    private DistributedVirtualNetworkStore virtualNetworkManagerStore;
-    private ServiceDirectory testDirectory;
-
-    private final String tenantIdValue1 = "TENANT_ID1";
-    private static final ApplicationId APP_ID =
-            new TestApplicationId("test");
-
-    private ConnectPoint cp1;
-    private ConnectPoint cp2;
-    private ConnectPoint cp3;
-    private ConnectPoint cp4;
-    private ConnectPoint cp5;
-    private ConnectPoint cp6;
-    private VirtualLink link1;
-    private VirtualLink link2;
-    private VirtualLink link3;
-    private VirtualLink link4;
-    private VirtualLink link5;
-    private VirtualLink link6;
-
-    @Before
-    public void setUp() throws TestUtilsException {
-        virtualNetworkManagerStore = new DistributedVirtualNetworkStore();
-
-        coreService = new TestCoreService();
-
-        MockIdGenerator.cleanBind();
-
-        setField(virtualNetworkManagerStore, "coreService", coreService);
-        setField(virtualNetworkManagerStore, "storageService", new TestStorageService());
-        virtualNetworkManagerStore.activate();
-
-        manager = new VirtualNetworkManager();
-        manager.setStore(virtualNetworkManagerStore);
-        setField(manager, "coreService", coreService);
-        NetTestTools.injectEventDispatcher(manager, new TestEventDispatcher());
-        manager.activate();
-
-        // Register a compiler and an installer both setup for success.
-        intentExtensionService = intentService;
-
-        testDirectory = new TestServiceDirectory()
-                .add(VirtualNetworkService.class, manager)
-                .add(VirtualNetworkStore.class, virtualNetworkManagerStore)
-                .add(IntentService.class, intentService);
-        setField(manager, "serviceDirectory", testDirectory);
-
-        compiler = new VirtualNetworkIntentCompiler();
-        compiler.manager = manager;
-        compiler.intentService = intentService;
-        compiler.store = virtualNetworkManagerStore;
-        compiler.intentManager = intentExtensionService;
-        compiler.serviceDirectory = testDirectory;
-    }
-
-    @After
-    public void tearDown() {
-        manager.deactivate();
-        MockIdGenerator.unbind();
-    }
-
-    /**
-     * Method to create the virtual network for further testing.
-     *
-     * @return virtual network
-     */
-    private VirtualNetwork setupVirtualNetworkTopology() {
-        manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
-        VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
-        VirtualDevice virtualDevice1 =
-                manager.createVirtualDevice(virtualNetwork.id(), DID1);
-        VirtualDevice virtualDevice2 =
-                manager.createVirtualDevice(virtualNetwork.id(), DID2);
-        VirtualDevice virtualDevice3 =
-                manager.createVirtualDevice(virtualNetwork.id(), DID3);
-        VirtualDevice virtualDevice4 =
-                manager.createVirtualDevice(virtualNetwork.id(), DID4);
-
-        Port port1 = new DefaultPort(virtualDevice1, PortNumber.portNumber(1), true);
-        cp1 = new ConnectPoint(virtualDevice1.id(), port1.number());
-        manager.createVirtualPort(virtualNetwork.id(), virtualDevice1.id(), port1.number(), cp1);
-
-        Port port2 = new DefaultPort(virtualDevice1, PortNumber.portNumber(2), true);
-        cp2 = new ConnectPoint(virtualDevice1.id(), port2.number());
-        manager.createVirtualPort(virtualNetwork.id(), virtualDevice1.id(), port2.number(), cp2);
-
-        Port port3 = new DefaultPort(virtualDevice2, PortNumber.portNumber(3), true);
-        cp3 = new ConnectPoint(virtualDevice2.id(), port3.number());
-        manager.createVirtualPort(virtualNetwork.id(), virtualDevice2.id(), port3.number(), cp3);
-
-        Port port4 = new DefaultPort(virtualDevice2, PortNumber.portNumber(4), true);
-        cp4 = new ConnectPoint(virtualDevice2.id(), port4.number());
-        manager.createVirtualPort(virtualNetwork.id(), virtualDevice2.id(), port4.number(), cp4);
-
-        Port port5 = new DefaultPort(virtualDevice3, PortNumber.portNumber(5), true);
-        cp5 = new ConnectPoint(virtualDevice3.id(), port5.number());
-        manager.createVirtualPort(virtualNetwork.id(), virtualDevice3.id(), port5.number(), cp5);
-
-        Port port6 = new DefaultPort(virtualDevice3, PortNumber.portNumber(6), true);
-        cp6 = new ConnectPoint(virtualDevice3.id(), port6.number());
-        manager.createVirtualPort(virtualNetwork.id(), virtualDevice3.id(), port6.number(), cp6);
-
-        link1 = manager.createVirtualLink(virtualNetwork.id(), cp1, cp3);
-        virtualNetworkManagerStore.updateLink(link1, link1.tunnelId(), Link.State.ACTIVE);
-        link2 = manager.createVirtualLink(virtualNetwork.id(), cp3, cp1);
-        virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.ACTIVE);
-        link3 = manager.createVirtualLink(virtualNetwork.id(), cp4, cp5);
-        virtualNetworkManagerStore.updateLink(link3, link3.tunnelId(), Link.State.ACTIVE);
-        link4 = manager.createVirtualLink(virtualNetwork.id(), cp5, cp4);
-        virtualNetworkManagerStore.updateLink(link4, link4.tunnelId(), Link.State.ACTIVE);
-
-        return virtualNetwork;
-    }
-
-    /**
-     * Tests the virtual network intent compiler.
-     */
-    @Test
-    public void testCompiler() {
-        compiler.activate();
-        VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
-
-        Key intentKey = Key.of("test", APP_ID);
-
-        VirtualNetworkIntent virtualIntent = VirtualNetworkIntent.builder()
-                .networkId(virtualNetwork.id())
-                .key(intentKey)
-                .appId(APP_ID)
-                .ingressPoint(cp2)
-                .egressPoint(cp6)
-                .build();
-
-        List<Intent> compiled = compiler.compile(virtualIntent, Collections.emptyList());
-        assertEquals("The virtual intents size is not as expected.", 5, compiled.size());
-
-        compiler.deactivate();
-    }
-
-
-    /**
-     * Core service test class.
-     */
-    private class TestCoreService extends CoreServiceAdapter {
-
-        @Override
-        public IdGenerator getIdGenerator(String topic) {
-            return new IdGenerator() {
-                private AtomicLong counter = new AtomicLong(0);
-
-                @Override
-                public long getNewId() {
-                    return counter.getAndIncrement();
-                }
-            };
-        }
-    }
-
-}
diff --git a/core/net/src/test/java/org/onosproject/net/meter/impl/MeterManagerTest.java b/core/net/src/test/java/org/onosproject/net/meter/impl/MeterManagerTest.java
index ea21b9f..030b9e6 100644
--- a/core/net/src/test/java/org/onosproject/net/meter/impl/MeterManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/meter/impl/MeterManagerTest.java
@@ -33,7 +33,6 @@
 import org.onosproject.cluster.DefaultControllerNode;
 import org.onosproject.cluster.NodeId;
 import org.onosproject.common.event.impl.TestEventDispatcher;
-import org.onosproject.incubator.store.meter.impl.DistributedMeterStore;
 import org.onosproject.mastership.MastershipServiceAdapter;
 import org.onosproject.net.AnnotationKeys;
 import org.onosproject.net.DefaultAnnotations;
@@ -71,6 +70,7 @@
 import org.onosproject.net.pi.PiPipeconfServiceAdapter;
 import org.onosproject.net.provider.AbstractProvider;
 import org.onosproject.net.provider.ProviderId;
+import org.onosproject.store.meter.impl.DistributedMeterStore;
 import org.onosproject.store.service.Serializer;
 import org.onosproject.store.service.TestStorageService;