[ONOS-5686] Re-naming and re-constructing virtual network classes
Changes.
1. Named *Service classes in the impementation package re-named as
*Manager
2. VirtualTopologyProvider is renamed as DefaultVirtualNetworkProvider
Change-Id: Ic8663aee793d0b8f87ffea3df7f71c8ac77362ca
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VnetService.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VnetService.java
similarity index 83%
rename from incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VnetService.java
rename to incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VnetService.java
index 7c83f75..f4b1bd8 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VnetService.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VnetService.java
@@ -14,14 +14,11 @@
* limitations under the License.
*/
-package org.onosproject.incubator.net.virtual.impl;
-
-import org.onosproject.incubator.net.virtual.VirtualNetwork;
+package org.onosproject.incubator.net.virtual;
/**
* Virtual network service interface.
*/
-interface VnetService {
+public interface VnetService {
VirtualNetwork network();
-
}
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkDeviceService.java b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkDeviceManager.java
similarity index 86%
rename from incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkDeviceService.java
rename to incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkDeviceManager.java
index c466502..81bf123 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkDeviceService.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkDeviceManager.java
@@ -22,6 +22,7 @@
import org.onosproject.incubator.net.virtual.VirtualNetwork;
import org.onosproject.incubator.net.virtual.VirtualNetworkService;
import org.onosproject.incubator.net.virtual.VirtualPort;
+import org.onosproject.incubator.net.virtual.VnetService;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.MastershipRole;
@@ -41,7 +42,8 @@
/**
* Device service implementation built on the virtual network service.
*/
-public class VirtualNetworkDeviceService extends AbstractListenerManager<DeviceEvent, DeviceListener>
+public class VirtualNetworkDeviceManager
+ extends AbstractListenerManager<DeviceEvent, DeviceListener>
implements DeviceService, VnetService {
private static final String NETWORK_NULL = "Network ID cannot be null";
@@ -58,7 +60,8 @@
* @param virtualNetworkManager virtual network manager service
* @param network virtual network
*/
- public VirtualNetworkDeviceService(VirtualNetworkService virtualNetworkManager, VirtualNetwork network) {
+ public VirtualNetworkDeviceManager(VirtualNetworkService virtualNetworkManager,
+ VirtualNetwork network) {
checkNotNull(network, NETWORK_NULL);
this.network = network;
this.manager = virtualNetworkManager;
@@ -71,7 +74,8 @@
@Override
public Iterable<Device> getDevices() {
- return manager.getVirtualDevices(this.network.id()).stream().collect(Collectors.toSet());
+ return manager.getVirtualDevices(
+ this.network.id()).stream().collect(Collectors.toSet());
}
@Override
@@ -96,7 +100,8 @@
@Override
public Device getDevice(DeviceId deviceId) {
checkNotNull(deviceId, DEVICE_NULL);
- Optional<VirtualDevice> foundDevice = manager.getVirtualDevices(this.network.id())
+ Optional<VirtualDevice> foundDevice =
+ manager.getVirtualDevices(this.network.id())
.stream()
.filter(device -> deviceId.equals(device.id()))
.findFirst();
@@ -136,7 +141,8 @@
}
@Override
- public PortStatistics getStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
+ public PortStatistics getStatisticsForPort(DeviceId deviceId,
+ PortNumber portNumber) {
checkNotNull(deviceId, DEVICE_NULL);
checkNotNull(deviceId, PORT_NUMBER_NULL);
// TODO not supported at the moment.
@@ -144,7 +150,8 @@
}
@Override
- public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId, PortNumber portNumber) {
+ public PortStatistics getDeltaStatisticsForPort(DeviceId deviceId,
+ PortNumber portNumber) {
checkNotNull(deviceId, DEVICE_NULL);
checkNotNull(deviceId, PORT_NUMBER_NULL);
// TODO not supported at the moment.
@@ -155,7 +162,8 @@
public Port getPort(DeviceId deviceId, PortNumber portNumber) {
checkNotNull(deviceId, DEVICE_NULL);
- Optional<VirtualPort> foundPort = manager.getVirtualPorts(this.network.id(), deviceId)
+ Optional<VirtualPort> foundPort =
+ manager.getVirtualPorts(this.network.id(), deviceId)
.stream()
.filter(port -> port.number().equals(portNumber))
.findFirst();
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkHostService.java b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkHostManager.java
similarity index 90%
rename from incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkHostService.java
rename to incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkHostManager.java
index 6642c5a..92c165f7 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkHostService.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkHostManager.java
@@ -23,6 +23,7 @@
import org.onosproject.incubator.net.virtual.VirtualHost;
import org.onosproject.incubator.net.virtual.VirtualNetwork;
import org.onosproject.incubator.net.virtual.VirtualNetworkService;
+import org.onosproject.incubator.net.virtual.VnetService;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Host;
@@ -43,7 +44,8 @@
/**
* Host service implementation built on the virtual network service.
*/
-public class VirtualNetworkHostService extends AbstractListenerManager<HostEvent, HostListener>
+public class VirtualNetworkHostManager
+ extends AbstractListenerManager<HostEvent, HostListener>
implements HostService, VnetService {
private static final String NETWORK_NULL = "Network ID cannot be null";
@@ -58,7 +60,8 @@
* @param virtualNetworkManager virtual network manager service
* @param network virtual network
*/
- public VirtualNetworkHostService(VirtualNetworkService virtualNetworkManager, VirtualNetwork network) {
+ public VirtualNetworkHostManager(VirtualNetworkService virtualNetworkManager,
+ VirtualNetwork network) {
checkNotNull(network, NETWORK_NULL);
this.network = network;
this.manager = virtualNetworkManager;
@@ -78,7 +81,8 @@
@Override
public Host getHost(HostId hostId) {
checkNotNull(hostId, HOST_NULL);
- Optional<VirtualHost> foundHost = manager.getVirtualHosts(this.network.id())
+ Optional<VirtualHost> foundHost =
+ manager.getVirtualHosts(this.network.id())
.stream()
.filter(host -> hostId.equals(host.id()))
.findFirst();
@@ -94,7 +98,8 @@
* @return collection of virtual hosts.
*/
private Collection<Host> getHostsColl() {
- return manager.getVirtualHosts(this.network.id()).stream().collect(Collectors.toSet());
+ return manager.getVirtualHosts(this.network.id())
+ .stream().collect(Collectors.toSet());
}
/**
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentService.java b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentManager.java
similarity index 96%
rename from incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentService.java
rename to incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentManager.java
index dc75b04..7b00e1d 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentService.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentManager.java
@@ -24,6 +24,7 @@
import org.onosproject.incubator.net.virtual.VirtualNetworkService;
import org.onosproject.incubator.net.virtual.VirtualNetworkStore;
import org.onosproject.incubator.net.virtual.VirtualPort;
+import org.onosproject.incubator.net.virtual.VnetService;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Port;
@@ -48,7 +49,8 @@
/**
* Intent service implementation built on the virtual network service.
*/
-public class VirtualNetworkIntentService extends AbstractListenerManager<IntentEvent, IntentListener>
+public class VirtualNetworkIntentManager
+ extends AbstractListenerManager<IntentEvent, IntentListener>
implements IntentService, VnetService {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -76,7 +78,8 @@
* @param network virtual network
* @param serviceDirectory service directory
*/
- public VirtualNetworkIntentService(VirtualNetworkService virtualNetworkManager, VirtualNetwork network,
+ public VirtualNetworkIntentManager(VirtualNetworkService virtualNetworkManager,
+ VirtualNetwork network,
ServiceDirectory serviceDirectory) {
checkNotNull(network, NETWORK_NULL);
this.network = network;
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkLinkService.java b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkLinkManager.java
similarity index 92%
rename from incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkLinkService.java
rename to incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkLinkManager.java
index 7af0267..b89a06f 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkLinkService.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkLinkManager.java
@@ -20,6 +20,7 @@
import org.onosproject.incubator.net.virtual.VirtualLink;
import org.onosproject.incubator.net.virtual.VirtualNetwork;
import org.onosproject.incubator.net.virtual.VirtualNetworkService;
+import org.onosproject.incubator.net.virtual.VnetService;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
@@ -36,7 +37,8 @@
/**
* Link service implementation built on the virtual network service.
*/
-public class VirtualNetworkLinkService extends AbstractListenerManager<LinkEvent, LinkListener>
+public class VirtualNetworkLinkManager
+ extends AbstractListenerManager<LinkEvent, LinkListener>
implements LinkService, VnetService {
private static final String NETWORK_NULL = "Network ID cannot be null";
@@ -52,7 +54,8 @@
* @param virtualNetworkManager virtual network manager service
* @param network virtual network
*/
- public VirtualNetworkLinkService(VirtualNetworkService virtualNetworkManager, VirtualNetwork network) {
+ public VirtualNetworkLinkManager(VirtualNetworkService virtualNetworkManager,
+ VirtualNetwork network) {
checkNotNull(network, NETWORK_NULL);
this.network = network;
this.manager = virtualNetworkManager;
@@ -70,7 +73,8 @@
@Override
public Iterable<Link> getLinks() {
- return manager.getVirtualLinks(this.network.id()).stream().collect(Collectors.toSet());
+ return manager.getVirtualLinks(this.network.id())
+ .stream().collect(Collectors.toSet());
}
@Override
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManager.java b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManager.java
index b75c2d5..8ef2b52 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManager.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManager.java
@@ -45,6 +45,7 @@
import org.onosproject.incubator.net.virtual.VirtualNetworkStore;
import org.onosproject.incubator.net.virtual.VirtualNetworkStoreDelegate;
import org.onosproject.incubator.net.virtual.VirtualPort;
+import org.onosproject.incubator.net.virtual.VnetService;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.HostId;
@@ -76,9 +77,10 @@
@Component(immediate = true)
@Service
public class VirtualNetworkManager
- extends AbstractListenerProviderRegistry<VirtualNetworkEvent, VirtualNetworkListener,
- VirtualNetworkProvider, VirtualNetworkProviderService>
- implements VirtualNetworkService, VirtualNetworkAdminService, VirtualNetworkProviderRegistry {
+ extends AbstractListenerProviderRegistry<VirtualNetworkEvent,
+ VirtualNetworkListener, VirtualNetworkProvider, VirtualNetworkProviderService>
+ implements VirtualNetworkService, VirtualNetworkAdminService,
+ VirtualNetworkProviderRegistry {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -93,7 +95,8 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected IntentService intentService;
- private final InternalVirtualIntentListener intentListener = new InternalVirtualIntentListener();
+ private final InternalVirtualIntentListener intentListener =
+ new InternalVirtualIntentListener();
private VirtualNetworkStoreDelegate delegate = this::post;
@@ -178,8 +181,9 @@
}
@Override
- public VirtualHost createVirtualHost(NetworkId networkId, HostId hostId, MacAddress mac,
- VlanId vlan, HostLocation location, Set<IpAddress> ips) {
+ public VirtualHost createVirtualHost(NetworkId networkId, HostId hostId,
+ MacAddress mac, VlanId vlan,
+ HostLocation location, Set<IpAddress> ips) {
checkNotNull(networkId, NETWORK_NULL);
checkNotNull(hostId, DEVICE_NULL);
return store.addHost(networkId, hostId, mac, vlan, location, ips);
@@ -251,7 +255,8 @@
}
@Override
- public void removeVirtualLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst) {
+ public void removeVirtualLink(NetworkId networkId, ConnectPoint src,
+ ConnectPoint dst) {
checkNotNull(networkId, NETWORK_NULL);
checkNotNull(src, LINK_POINT_NULL);
checkNotNull(dst, LINK_POINT_NULL);
@@ -279,7 +284,8 @@
}
@Override
- public void removeVirtualPort(NetworkId networkId, DeviceId deviceId, PortNumber portNumber) {
+ public void removeVirtualPort(NetworkId networkId, DeviceId deviceId,
+ PortNumber portNumber) {
checkNotNull(networkId, NETWORK_NULL);
checkNotNull(deviceId, DEVICE_NULL);
checkNotNull(portNumber, "Port number cannot be null");
@@ -374,17 +380,18 @@
checkNotNull(network, NETWORK_NULL);
VnetService service;
if (serviceKey.serviceClass.equals(DeviceService.class)) {
- service = new VirtualNetworkDeviceService(this, network);
+ service = new VirtualNetworkDeviceManager(this, network);
} else if (serviceKey.serviceClass.equals(LinkService.class)) {
- service = new VirtualNetworkLinkService(this, network);
+ service = new VirtualNetworkLinkManager(this, network);
} else if (serviceKey.serviceClass.equals(TopologyService.class)) {
- service = new VirtualNetworkTopologyService(this, network);
+ service = new VirtualNetworkTopologyManager(this, network);
} else if (serviceKey.serviceClass.equals(IntentService.class)) {
- service = new VirtualNetworkIntentService(this, network, new DefaultServiceDirectory());
+ service = new VirtualNetworkIntentManager(
+ this, network, new DefaultServiceDirectory());
} else if (serviceKey.serviceClass.equals(HostService.class)) {
- service = new VirtualNetworkHostService(this, network);
+ service = new VirtualNetworkHostManager(this, network);
} else if (serviceKey.serviceClass.equals(PathService.class)) {
- service = new VirtualNetworkPathService(this, network);
+ service = new VirtualNetworkPathManager(this, network);
} else {
return null;
}
@@ -406,6 +413,7 @@
* @param serviceClass service class
*/
public ServiceKey(NetworkId networkId, Class serviceClass) {
+
checkNotNull(networkId, NETWORK_NULL);
this.networkId = networkId;
this.serviceClass = serviceClass;
@@ -434,6 +442,7 @@
* Internal intent event listener.
*/
private class InternalVirtualIntentListener implements IntentListener {
+
@Override
public void event(IntentEvent event) {
@@ -481,7 +490,8 @@
@Override
- protected VirtualNetworkProviderService createProviderService(VirtualNetworkProvider provider) {
+ protected VirtualNetworkProviderService
+ createProviderService(VirtualNetworkProvider provider) {
return new InternalVirtualNetworkProviderService(provider);
}
@@ -502,7 +512,6 @@
@Override
public void topologyChanged(Set<Set<ConnectPoint>> clusters) {
-
Set<TenantId> tenantIds = getTenantIds();
tenantIds.forEach(tenantId -> {
Set<VirtualNetwork> virtualNetworks = getVirtualNetworks(tenantId);
@@ -511,10 +520,13 @@
Set<VirtualLink> virtualLinks = getVirtualLinks(virtualNetwork.id());
virtualLinks.forEach(virtualLink -> {
- if (isVirtualLinkInCluster(virtualNetwork.id(), virtualLink, clusters)) {
- store.updateLink(virtualLink, virtualLink.tunnelId(), Link.State.ACTIVE);
+ if (isVirtualLinkInCluster(virtualNetwork.id(),
+ virtualLink, clusters)) {
+ store.updateLink(virtualLink, virtualLink.tunnelId(),
+ Link.State.ACTIVE);
} else {
- store.updateLink(virtualLink, virtualLink.tunnelId(), Link.State.INACTIVE);
+ store.updateLink(virtualLink, virtualLink.tunnelId(),
+ Link.State.INACTIVE);
}
});
});
@@ -522,7 +534,8 @@
}
/**
- * Determines if the virtual link (both source and destination connect point) is in a cluster.
+ * Determines if the virtual link (both source and destination connect point)
+ * is in a cluster.
*
* @param networkId virtual network identifier
* @param virtualLink virtual link
@@ -531,8 +544,10 @@
*/
private boolean isVirtualLinkInCluster(NetworkId networkId, VirtualLink virtualLink,
Set<Set<ConnectPoint>> clusters) {
- ConnectPoint srcPhysicalCp = mapVirtualToPhysicalPort(networkId, virtualLink.src());
- ConnectPoint dstPhysicalCp = mapVirtualToPhysicalPort(networkId, virtualLink.dst());
+ ConnectPoint srcPhysicalCp =
+ mapVirtualToPhysicalPort(networkId, virtualLink.src());
+ ConnectPoint dstPhysicalCp =
+ mapVirtualToPhysicalPort(networkId, virtualLink.dst());
final boolean[] foundSrc = {false};
final boolean[] foundDst = {false};
@@ -552,8 +567,8 @@
}
@Override
- public void tunnelUp(NetworkId networkId, ConnectPoint src, ConnectPoint dst, TunnelId tunnelId) {
-
+ public void tunnelUp(NetworkId networkId, ConnectPoint src,
+ ConnectPoint dst, TunnelId tunnelId) {
ConnectPoint srcVirtualCp = mapPhysicalToVirtualToPort(networkId, src);
ConnectPoint dstVirtualCp = mapPhysicalToVirtualToPort(networkId, dst);
if ((srcVirtualCp == null) || (dstVirtualCp == null)) {
@@ -567,7 +582,8 @@
}
@Override
- public void tunnelDown(NetworkId networkId, ConnectPoint src, ConnectPoint dst, TunnelId tunnelId) {
+ public void tunnelDown(NetworkId networkId, ConnectPoint src,
+ ConnectPoint dst, TunnelId tunnelId) {
ConnectPoint srcVirtualCp = mapPhysicalToVirtualToPort(networkId, src);
ConnectPoint dstVirtualCp = mapPhysicalToVirtualToPort(networkId, dst);
if ((srcVirtualCp == null) || (dstVirtualCp == null)) {
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathService.java b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathManager.java
similarity index 86%
rename from incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathService.java
rename to incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathManager.java
index 62f3bdf..ad81141 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathService.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathManager.java
@@ -17,6 +17,7 @@
import org.onosproject.incubator.net.virtual.VirtualNetwork;
import org.onosproject.incubator.net.virtual.VirtualNetworkService;
+import org.onosproject.incubator.net.virtual.VnetService;
import org.onosproject.net.DisjointPath;
import org.onosproject.net.ElementId;
import org.onosproject.net.Link;
@@ -35,7 +36,8 @@
/**
* Path service implementation built on the virtual network service.
*/
-public class VirtualNetworkPathService extends AbstractPathService
+public class VirtualNetworkPathManager
+ extends AbstractPathService
implements PathService, VnetService {
private static final String NETWORK_NULL = "Network ID cannot be null";
@@ -49,7 +51,8 @@
* @param network virtual network
*/
- public VirtualNetworkPathService(VirtualNetworkService virtualNetworkManager, VirtualNetwork network) {
+ public VirtualNetworkPathManager(VirtualNetworkService virtualNetworkManager,
+ VirtualNetwork network) {
checkNotNull(network, NETWORK_NULL);
this.network = network;
topologyService = virtualNetworkManager.get(network.id(), TopologyService.class);
@@ -67,7 +70,8 @@
}
@Override
- public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, Map<Link, Object> riskProfile) {
+ public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst,
+ Map<Link, Object> riskProfile) {
return getDisjointPaths(src, dst, null, riskProfile);
}
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyService.java b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManager.java
similarity index 90%
rename from incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyService.java
rename to incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManager.java
index 972b5dc..e49fa6f 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyService.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManager.java
@@ -20,6 +20,7 @@
import org.onosproject.event.AbstractListenerManager;
import org.onosproject.incubator.net.virtual.VirtualNetwork;
import org.onosproject.incubator.net.virtual.VirtualNetworkService;
+import org.onosproject.incubator.net.virtual.VnetService;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
@@ -47,7 +48,8 @@
/**
* Topology service implementation built on the virtual network service.
*/
-public class VirtualNetworkTopologyService extends AbstractListenerManager<TopologyEvent, TopologyListener>
+public class VirtualNetworkTopologyManager
+ extends AbstractListenerManager<TopologyEvent, TopologyListener>
implements TopologyService, VnetService {
private static final String NETWORK_NULL = "Network ID cannot be null";
@@ -67,7 +69,8 @@
* @param virtualNetworkManager virtual network manager service
* @param network virtual network
*/
- public VirtualNetworkTopologyService(VirtualNetworkService virtualNetworkManager, VirtualNetwork network) {
+ public VirtualNetworkTopologyManager(VirtualNetworkService virtualNetworkManager,
+ VirtualNetwork network) {
checkNotNull(network, NETWORK_NULL);
this.network = network;
this.manager = virtualNetworkManager;
@@ -82,15 +85,18 @@
.stream()
.collect(Collectors.toSet());
- DefaultGraphDescription graph = new DefaultGraphDescription(System.nanoTime(), System.currentTimeMillis(),
- devices, links);
+ DefaultGraphDescription graph =
+ new DefaultGraphDescription(System.nanoTime(),
+ System.currentTimeMillis(),
+ devices, links);
return new DefaultTopology(PID, graph);
}
@Override
public boolean isLatest(Topology topology) {
Topology currentTopology = currentTopology();
- return defaultTopology(topology).getGraph().equals(defaultTopology(currentTopology).getGraph());
+ return defaultTopology(topology).getGraph()
+ .equals(defaultTopology(currentTopology).getGraph());
}
@Override
@@ -152,7 +158,8 @@
}
@Override
- public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
+ public Set<DisjointPath> getDisjointPaths(Topology topology, DeviceId src,
+ DeviceId dst, LinkWeight weight) {
checkNotNull(src, DEVICE_ID_NULL);
checkNotNull(dst, DEVICE_ID_NULL);
checkNotNull(weight, LINK_WEIGHT_NULL);
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyProvider.java b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/provider/DefaultVirtualNetworkProvider.java
similarity index 90%
rename from incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyProvider.java
rename to incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/provider/DefaultVirtualNetworkProvider.java
index d2e0b26..3e42579 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyProvider.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/provider/DefaultVirtualNetworkProvider.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.incubator.net.virtual.impl;
+package org.onosproject.incubator.net.virtual.impl.provider;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
@@ -53,9 +53,10 @@
*/
@Component(immediate = true)
@Service
-public class VirtualNetworkTopologyProvider extends AbstractProvider implements VirtualNetworkProvider {
+public class DefaultVirtualNetworkProvider
+ extends AbstractProvider implements VirtualNetworkProvider {
- private final Logger log = getLogger(VirtualNetworkTopologyProvider.class);
+ private final Logger log = getLogger(DefaultVirtualNetworkProvider.class);
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected VirtualNetworkProviderRegistry providerRegistry;
@@ -72,7 +73,7 @@
/**
* Default constructor.
*/
- public VirtualNetworkTopologyProvider() {
+ public DefaultVirtualNetworkProvider() {
super(DefaultVirtualLink.PID);
}
@@ -138,12 +139,13 @@
* @param topology the default topology
* @return set of set of interconnected connect points.
*/
- protected Set<Set<ConnectPoint>> getConnectPoints(Topology topology) {
+ public Set<Set<ConnectPoint>> getConnectPoints(Topology topology) {
Set<Set<ConnectPoint>> clusters = new HashSet<>();
Set<TopologyCluster> topologyClusters = topologyService.getClusters(topology);
topologyClusters.forEach(topologyCluster -> {
Set<ConnectPoint> connectPointSet = new HashSet<>();
- Set<Link> clusterLinks = topologyService.getClusterLinks(topology, topologyCluster);
+ Set<Link> clusterLinks =
+ topologyService.getClusterLinks(topology, topologyCluster);
clusterLinks.forEach(link -> {
connectPointSet.add(link.src());
connectPointSet.add(link.dst());
@@ -162,7 +164,8 @@
@Override
public void event(TopologyEvent event) {
// Perform processing off the listener thread.
- executor.submit(() -> providerService.topologyChanged(getConnectPoints(event.subject())));
+ executor.submit(() -> providerService
+ .topologyChanged(getConnectPoints(event.subject())));
}
@Override
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VnetService.java b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/provider/package-info.java
similarity index 74%
copy from incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VnetService.java
copy to incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/provider/package-info.java
index 7c83f75..48c02d5 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VnetService.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/provider/package-info.java
@@ -14,14 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.incubator.net.virtual.impl;
-
-import org.onosproject.incubator.net.virtual.VirtualNetwork;
-
/**
- * Virtual network service interface.
+ * Network virtualization provider implementations.
*/
-interface VnetService {
- VirtualNetwork network();
-
-}
+package org.onosproject.incubator.net.virtual.impl.provider;
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkDeviceServiceTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkDeviceManagerTest.java
similarity index 98%
rename from incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkDeviceServiceTest.java
rename to incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkDeviceManagerTest.java
index b682d05..41b3925 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkDeviceServiceTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkDeviceManagerTest.java
@@ -49,7 +49,7 @@
/**
* Junit tests for VirtualNetworkDeviceService.
*/
-public class VirtualNetworkDeviceServiceTest extends TestDeviceParams {
+public class VirtualNetworkDeviceManagerTest extends TestDeviceParams {
private final String tenantIdValue1 = "TENANT_ID1";
private VirtualNetworkManager manager;
@@ -61,9 +61,9 @@
public void setUp() throws Exception {
virtualNetworkManagerStore = new DistributedVirtualNetworkStore();
- coreService = new VirtualNetworkDeviceServiceTest.TestCoreService();
+ coreService = new VirtualNetworkDeviceManagerTest.TestCoreService();
virtualNetworkManagerStore.setCoreService(coreService);
- TestUtils.setField(coreService, "coreService", new VirtualNetworkDeviceServiceTest.TestCoreService());
+ TestUtils.setField(coreService, "coreService", new VirtualNetworkDeviceManagerTest.TestCoreService());
TestUtils.setField(virtualNetworkManagerStore, "storageService", new TestStorageService());
virtualNetworkManagerStore.activate();
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkHostServiceTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkHostManagerTest.java
similarity index 98%
rename from incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkHostServiceTest.java
rename to incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkHostManagerTest.java
index fa21998..ca1a314 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkHostServiceTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkHostManagerTest.java
@@ -45,7 +45,7 @@
/**
* Junit tests for VirtualNetworkHostService.
*/
-public class VirtualNetworkHostServiceTest extends TestDeviceParams {
+public class VirtualNetworkHostManagerTest extends TestDeviceParams {
private final String tenantIdValue1 = "TENANT_ID1";
private VirtualNetworkManager manager;
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentServiceTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentManagerTest.java
similarity index 97%
rename from incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentServiceTest.java
rename to incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentManagerTest.java
index 1e7625d..9bc3d84 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentServiceTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkIntentManagerTest.java
@@ -77,7 +77,7 @@
/**
* Junit tests for VirtualNetworkIntentService.
*/
-public class VirtualNetworkIntentServiceTest extends TestDeviceParams {
+public class VirtualNetworkIntentManagerTest extends TestDeviceParams {
private final String tenantIdValue1 = "TENANT_ID1";
private static final ApplicationId APP_ID =
@@ -100,7 +100,7 @@
private static DistributedVirtualNetworkStore virtualNetworkManagerStore;
private CoreService coreService;
private TestableIntentService intentService = new FakeIntentManager();
- private VirtualNetworkIntentService vnetIntentService;
+ private VirtualNetworkIntentManager vnetIntentService;
private TestIntentCompiler compiler = new TestIntentCompiler();
private IntentExtensionService intentExtensionService;
private WorkPartitionService workPartitionService;
@@ -117,13 +117,13 @@
public void setUp() throws Exception {
virtualNetworkManagerStore = new DistributedVirtualNetworkStore();
- coreService = new VirtualNetworkIntentServiceTest.TestCoreService();
+ coreService = new VirtualNetworkIntentManagerTest.TestCoreService();
Intent.unbindIdGenerator(idGenerator);
Intent.bindIdGenerator(idGenerator);
virtualNetworkManagerStore.setCoreService(coreService);
- TestUtils.setField(coreService, "coreService", new VirtualNetworkIntentServiceTest.TestCoreService());
+ TestUtils.setField(coreService, "coreService", new VirtualNetworkIntentManagerTest.TestCoreService());
TestUtils.setField(virtualNetworkManagerStore, "storageService", new TestStorageService());
virtualNetworkManagerStore.activate();
@@ -212,7 +212,7 @@
link4 = manager.createVirtualLink(virtualNetwork.id(), cp5, cp4);
virtualNetworkManagerStore.updateLink(link4, link4.tunnelId(), Link.State.ACTIVE);
- vnetIntentService = new VirtualNetworkIntentService(manager, virtualNetwork, testDirectory);
+ vnetIntentService = new VirtualNetworkIntentManager(manager, virtualNetwork, testDirectory);
vnetIntentService.intentService = intentService;
vnetIntentService.store = virtualNetworkManagerStore;
vnetIntentService.partitionService = workPartitionService;
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkLinkServiceTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkLinkManagerTest.java
similarity index 98%
rename from incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkLinkServiceTest.java
rename to incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkLinkManagerTest.java
index 53b21d7..7615fe7 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkLinkServiceTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkLinkManagerTest.java
@@ -49,7 +49,7 @@
/**
* Junit tests for VirtualNetworkLinkService.
*/
-public class VirtualNetworkLinkServiceTest extends TestDeviceParams {
+public class VirtualNetworkLinkManagerTest extends TestDeviceParams {
private final String tenantIdValue1 = "TENANT_ID1";
@@ -62,9 +62,9 @@
public void setUp() throws Exception {
virtualNetworkManagerStore = new DistributedVirtualNetworkStore();
- coreService = new VirtualNetworkLinkServiceTest.TestCoreService();
+ coreService = new VirtualNetworkLinkManagerTest.TestCoreService();
virtualNetworkManagerStore.setCoreService(coreService);
- TestUtils.setField(coreService, "coreService", new VirtualNetworkLinkServiceTest.TestCoreService());
+ TestUtils.setField(coreService, "coreService", new VirtualNetworkLinkManagerTest.TestCoreService());
TestUtils.setField(virtualNetworkManagerStore, "storageService", new TestStorageService());
virtualNetworkManagerStore.activate();
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManagerTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManagerTest.java
index 81fbdf5..dafd1f7 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManagerTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManagerTest.java
@@ -40,6 +40,7 @@
import org.onosproject.incubator.net.virtual.VirtualNetworkListener;
import org.onosproject.incubator.net.virtual.VirtualNetworkProviderService;
import org.onosproject.incubator.net.virtual.VirtualPort;
+import org.onosproject.incubator.net.virtual.impl.provider.DefaultVirtualNetworkProvider;
import org.onosproject.incubator.store.virtual.impl.DistributedVirtualNetworkStore;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
@@ -74,7 +75,7 @@
private final String tenantIdValue2 = "TENANT_ID2";
private VirtualNetworkManager manager;
- private VirtualNetworkTopologyProvider topologyProvider;
+ private DefaultVirtualNetworkProvider topologyProvider;
private DistributedVirtualNetworkStore virtualNetworkManagerStore;
private CoreService coreService;
private TestListener listener = new TestListener();
@@ -93,7 +94,8 @@
coreService = new TestCoreService();
virtualNetworkManagerStore.setCoreService(coreService);
TestUtils.setField(coreService, "coreService", new TestCoreService());
- TestUtils.setField(virtualNetworkManagerStore, "storageService", new TestStorageService());
+ TestUtils.setField(virtualNetworkManagerStore, "storageService",
+ new TestStorageService());
virtualNetworkManagerStore.activate();
manager = new VirtualNetworkManager();
@@ -138,8 +140,10 @@
assertTrue("The tenantId set should be empty.", tenantIdCollection.isEmpty());
// Validate that the events were all received in the correct order.
- validateEvents(VirtualNetworkEvent.Type.TENANT_UNREGISTERED, VirtualNetworkEvent.Type.TENANT_REGISTERED,
- VirtualNetworkEvent.Type.TENANT_REGISTERED, VirtualNetworkEvent.Type.TENANT_UNREGISTERED,
+ validateEvents(VirtualNetworkEvent.Type.TENANT_UNREGISTERED,
+ VirtualNetworkEvent.Type.TENANT_REGISTERED,
+ VirtualNetworkEvent.Type.TENANT_REGISTERED,
+ VirtualNetworkEvent.Type.TENANT_UNREGISTERED,
VirtualNetworkEvent.Type.TENANT_UNREGISTERED);
}
@@ -184,9 +188,12 @@
assertTrue("The virtual network set should be empty.", virtualNetworks.isEmpty());
// Validate that the events were all received in the correct order.
- validateEvents(VirtualNetworkEvent.Type.TENANT_REGISTERED, VirtualNetworkEvent.Type.NETWORK_ADDED,
- VirtualNetworkEvent.Type.NETWORK_ADDED, VirtualNetworkEvent.Type.NETWORK_REMOVED,
- VirtualNetworkEvent.Type.NETWORK_REMOVED, VirtualNetworkEvent.Type.NETWORK_ADDED,
+ validateEvents(VirtualNetworkEvent.Type.TENANT_REGISTERED,
+ VirtualNetworkEvent.Type.NETWORK_ADDED,
+ VirtualNetworkEvent.Type.NETWORK_ADDED,
+ VirtualNetworkEvent.Type.NETWORK_REMOVED,
+ VirtualNetworkEvent.Type.NETWORK_REMOVED,
+ VirtualNetworkEvent.Type.NETWORK_ADDED,
VirtualNetworkEvent.Type.NETWORK_REMOVED);
}
@@ -207,7 +214,9 @@
@Test(expected = IllegalStateException.class)
public void testCreateVirtualDeviceWithNoNetwork() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
- VirtualNetwork virtualNetwork = new DefaultVirtualNetwork(NetworkId.NONE, TenantId.tenantId(tenantIdValue1));
+ VirtualNetwork virtualNetwork =
+ new DefaultVirtualNetwork(NetworkId.NONE,
+ TenantId.tenantId(tenantIdValue1));
manager.createVirtualDevice(virtualNetwork.id(), DID1);
}
@@ -218,8 +227,10 @@
@Test
public void testAddRemoveVirtualDevice() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
- VirtualNetwork virtualNetwork1 = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
- VirtualNetwork virtualNetwork2 = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
+ VirtualNetwork virtualNetwork1 =
+ manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
+ VirtualNetwork virtualNetwork2 =
+ manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
manager.createVirtualDevice(virtualNetwork1.id(), DID1);
manager.createVirtualDevice(virtualNetwork2.id(), DID2);
@@ -246,7 +257,8 @@
assertTrue("The virtual device set should be empty.", virtualDevices1.isEmpty());
// Validate that the events were all received in the correct order.
- validateEvents(VirtualNetworkEvent.Type.TENANT_REGISTERED, VirtualNetworkEvent.Type.NETWORK_ADDED,
+ validateEvents(VirtualNetworkEvent.Type.TENANT_REGISTERED,
+ VirtualNetworkEvent.Type.NETWORK_ADDED,
VirtualNetworkEvent.Type.NETWORK_ADDED);
}
@@ -256,7 +268,8 @@
@Test(expected = NullPointerException.class)
public void testCreateNullVirtualHost() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
- VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
+ VirtualNetwork virtualNetwork =
+ manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
manager.createVirtualHost(virtualNetwork.id(), null, null, null, null, null);
}
@@ -267,7 +280,8 @@
@Test(expected = IllegalStateException.class)
public void testCreateVirtualHostWithNoNetwork() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
- VirtualNetwork virtualNetwork = new DefaultVirtualNetwork(NetworkId.NONE, TenantId.tenantId(tenantIdValue1));
+ VirtualNetwork virtualNetwork =
+ new DefaultVirtualNetwork(NetworkId.NONE, TenantId.tenantId(tenantIdValue1));
manager.createVirtualHost(virtualNetwork.id(), HID1, null, null, null, null);
}
@@ -278,8 +292,10 @@
@Test
public void testAddRemoveVirtualHost() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
- VirtualNetwork virtualNetwork1 = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
- VirtualNetwork virtualNetwork2 = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
+ VirtualNetwork virtualNetwork1 =
+ manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
+ VirtualNetwork virtualNetwork2 =
+ manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
manager.createVirtualHost(virtualNetwork1.id(), HID1, MAC1, VLAN1, LOC1, IPSET1);
manager.createVirtualHost(virtualNetwork2.id(), HID2, MAC2, VLAN2, LOC2, IPSET2);
@@ -300,7 +316,9 @@
assertTrue("The virtual host set should be empty.", virtualHosts1.isEmpty());
// Add/remove the virtual host again.
- VirtualHost virtualHost = manager.createVirtualHost(virtualNetwork1.id(), HID1, MAC1, VLAN1, LOC1, IPSET1);
+ VirtualHost virtualHost =
+ manager.createVirtualHost(virtualNetwork1.id(),
+ HID1, MAC1, VLAN1, LOC1, IPSET1);
manager.removeVirtualHost(virtualHost.networkId(), virtualHost.id());
virtualHosts1 = manager.getVirtualHosts(virtualNetwork1.id());
assertTrue("The virtual host set should be empty.", virtualHosts1.isEmpty());
@@ -312,7 +330,8 @@
@Test
public void testAddRemoveVirtualLink() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
- VirtualNetwork virtualNetwork1 = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
+ VirtualNetwork virtualNetwork1 =
+ manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
VirtualDevice srcVirtualDevice =
manager.createVirtualDevice(virtualNetwork1.id(), DID1);
VirtualDevice dstVirtualDevice =
@@ -353,7 +372,8 @@
@Test(expected = IllegalStateException.class)
public void testAddSameVirtualLink() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
- VirtualNetwork virtualNetwork1 = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
+ VirtualNetwork virtualNetwork1 =
+ manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
VirtualDevice srcVirtualDevice =
manager.createVirtualDevice(virtualNetwork1.id(), DID1);
VirtualDevice dstVirtualDevice =
@@ -376,13 +396,16 @@
@Test
public void testAddRemoveVirtualPort() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
- VirtualNetwork virtualNetwork1 = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
+ VirtualNetwork virtualNetwork1 =
+ manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
VirtualDevice virtualDevice =
manager.createVirtualDevice(virtualNetwork1.id(), DID1);
ConnectPoint cp = new ConnectPoint(virtualDevice.id(), PortNumber.portNumber(1));
- manager.createVirtualPort(virtualNetwork1.id(), virtualDevice.id(), PortNumber.portNumber(1), cp);
- manager.createVirtualPort(virtualNetwork1.id(), virtualDevice.id(), PortNumber.portNumber(2), cp);
+ manager.createVirtualPort(virtualNetwork1.id(),
+ virtualDevice.id(), PortNumber.portNumber(1), cp);
+ manager.createVirtualPort(virtualNetwork1.id(),
+ virtualDevice.id(), PortNumber.portNumber(2), cp);
Set<VirtualPort> virtualPorts = manager.getVirtualPorts(virtualNetwork1.id(), virtualDevice.id());
assertNotNull("The virtual port set should not be null", virtualPorts);
@@ -399,9 +422,11 @@
assertTrue("The virtual port set should be empty.", virtualPorts.isEmpty());
// Add/remove the virtual port again.
- VirtualPort virtualPort = manager.createVirtualPort(virtualNetwork1.id(), virtualDevice.id(),
+ VirtualPort virtualPort =
+ manager.createVirtualPort(virtualNetwork1.id(), virtualDevice.id(),
PortNumber.portNumber(1), cp);
- manager.removeVirtualPort(virtualNetwork1.id(), (DeviceId) virtualPort.element().id(), virtualPort.number());
+ manager.removeVirtualPort(virtualNetwork1.id(),
+ (DeviceId) virtualPort.element().id(), virtualPort.number());
virtualPorts = manager.getVirtualPorts(virtualNetwork1.id(), virtualDevice.id());
assertTrue("The virtual port set should be empty.", virtualPorts.isEmpty());
}
@@ -428,7 +453,8 @@
@Test
public void testAddOrUpdateIntent() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
- VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
+ VirtualNetwork virtualNetwork =
+ manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
ConnectPoint cp1 = new ConnectPoint(DID1, P1);
ConnectPoint cp2 = new ConnectPoint(DID2, P1);
@@ -442,13 +468,17 @@
// Add the intent to the store.
manager.store.addOrUpdateIntent(virtualIntent, IntentState.INSTALL_REQ);
- assertEquals("The intent size should match.", 1, manager.store.getIntents().size());
- assertNotNull("The intent should not be null.", manager.store.getIntent(virtualIntent.key()));
+ assertEquals("The intent size should match.", 1,
+ manager.store.getIntents().size());
+ assertNotNull("The intent should not be null.",
+ manager.store.getIntent(virtualIntent.key()));
// remove the intent from the store.
manager.store.removeIntent(virtualIntent.key());
- assertTrue("The intents should be empty.", manager.store.getIntents().isEmpty());
- assertNull("The intent should be null.", manager.store.getIntent(virtualIntent.key()));
+ assertTrue("The intents should be empty.",
+ manager.store.getIntents().isEmpty());
+ assertNull("The intent should be null.",
+ manager.store.getIntent(virtualIntent.key()));
}
/**
@@ -488,11 +518,13 @@
TunnelId tunnelId = TunnelId.valueOf("virtual tunnel");
// Add the intent to tunnelID mapping to the store.
manager.store.addTunnelId(virtualIntent, tunnelId);
- assertEquals("The tunnels size should match.", 1, manager.store.getTunnelIds(virtualIntent).size());
+ assertEquals("The tunnels size should match.", 1,
+ manager.store.getTunnelIds(virtualIntent).size());
// Remove the intent to tunnelID mapping from the store.
manager.store.removeTunnelId(virtualIntent, tunnelId);
- assertTrue("The tunnels should be empty.", manager.store.getTunnelIds(virtualIntent).isEmpty());
+ assertTrue("The tunnels should be empty.",
+ manager.store.getTunnelIds(virtualIntent).isEmpty());
}
@@ -501,7 +533,8 @@
**/
private VirtualNetwork setupVirtualNetworkTopology() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
- VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
+ VirtualNetwork virtualNetwork =
+ manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
VirtualDevice virtualDevice1 =
manager.createVirtualDevice(virtualNetwork.id(), DID1);
@@ -564,8 +597,13 @@
virtualNetworkManagerStore.updateLink(link6, link6.tunnelId(), Link.State.ACTIVE);
topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
- topologyProvider = new VirtualNetworkTopologyProvider();
- topologyProvider.topologyService = topologyService;
+ topologyProvider = new DefaultVirtualNetworkProvider();
+ try {
+ TestUtils.setField(topologyProvider, "topologyService", topologyService);
+ } catch (TestUtils.TestUtilsException e) {
+ e.printStackTrace();
+ }
+// topologyProvider.topologyService = topologyService;
return virtualNetwork;
}
@@ -576,10 +614,12 @@
@Test
public void testTopologyChanged() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
- VirtualNetworkProviderService providerService = manager.createProviderService(topologyProvider);
+ VirtualNetworkProviderService providerService =
+ manager.createProviderService(topologyProvider);
// Initial setup is two clusters of devices/links.
- assertEquals("The cluster count did not match.", 2, topologyService.currentTopology().clusterCount());
+ assertEquals("The cluster count did not match.", 2,
+ topologyService.currentTopology().clusterCount());
// Adding this link will join the two clusters together.
List<Event> reasons = new ArrayList<>();
@@ -593,7 +633,8 @@
// Validate that all links are still active.
manager.getVirtualLinks(virtualNetwork.id()).forEach(virtualLink -> {
- assertTrue("The virtual link should be active.", virtualLink.state().equals(Link.State.ACTIVE));
+ assertTrue("The virtual link should be active.",
+ virtualLink.state().equals(Link.State.ACTIVE));
});
virtualNetworkManagerStore.updateLink(link, link.tunnelId(), Link.State.INACTIVE);
@@ -602,7 +643,8 @@
// Validate that all links are active again.
manager.getVirtualLinks(virtualNetwork.id()).forEach(virtualLink -> {
- assertTrue("The virtual link should be active.", virtualLink.state().equals(Link.State.ACTIVE));
+ assertTrue("The virtual link should be active.",
+ virtualLink.state().equals(Link.State.ACTIVE));
});
}
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathServiceTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathManagerTest.java
similarity index 98%
rename from incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathServiceTest.java
rename to incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathManagerTest.java
index 9a1faf7..0a8ecf6 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathServiceTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkPathManagerTest.java
@@ -49,7 +49,7 @@
/**
* Junit tests for VirtualNetworkPathService.
*/
-public class VirtualNetworkPathServiceTest extends TestDeviceParams {
+public class VirtualNetworkPathManagerTest extends TestDeviceParams {
private final String tenantIdValue1 = "TENANT_ID1";
private VirtualNetworkManager manager;
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyServiceTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManagerTest.java
similarity index 98%
rename from incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyServiceTest.java
rename to incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManagerTest.java
index 35ed039..1072f2a 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyServiceTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyManagerTest.java
@@ -57,7 +57,7 @@
/**
* Junit tests for VirtualNetworkTopologyService.
*/
-public class VirtualNetworkTopologyServiceTest extends TestDeviceParams {
+public class VirtualNetworkTopologyManagerTest extends TestDeviceParams {
private final String tenantIdValue1 = "TENANT_ID1";
@@ -70,9 +70,9 @@
public void setUp() throws Exception {
virtualNetworkManagerStore = new DistributedVirtualNetworkStore();
- coreService = new VirtualNetworkTopologyServiceTest.TestCoreService();
+ coreService = new VirtualNetworkTopologyManagerTest.TestCoreService();
virtualNetworkManagerStore.setCoreService(coreService);
- TestUtils.setField(coreService, "coreService", new VirtualNetworkTopologyServiceTest.TestCoreService());
+ TestUtils.setField(coreService, "coreService", new VirtualNetworkTopologyManagerTest.TestCoreService());
TestUtils.setField(virtualNetworkManagerStore, "storageService", new TestStorageService());
virtualNetworkManagerStore.activate();
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyProviderTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/provider/VirtualNetworkTopologyProviderTest.java
similarity index 91%
rename from incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyProviderTest.java
rename to incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/provider/VirtualNetworkTopologyProviderTest.java
index d95aaf2..882aef5 100644
--- a/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkTopologyProviderTest.java
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/virtual/impl/provider/VirtualNetworkTopologyProviderTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.incubator.net.virtual.impl;
+package org.onosproject.incubator.net.virtual.impl.provider;
import org.junit.After;
import org.junit.Before;
@@ -34,6 +34,7 @@
import org.onosproject.incubator.net.virtual.VirtualNetworkProvider;
import org.onosproject.incubator.net.virtual.VirtualNetworkProviderRegistry;
import org.onosproject.incubator.net.virtual.VirtualNetworkProviderService;
+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.Link;
@@ -84,7 +85,7 @@
private VirtualNetworkManager manager;
private DistributedVirtualNetworkStore virtualNetworkManagerStore;
private CoreService coreService;
- private VirtualNetworkTopologyProvider topologyProvider;
+ private DefaultVirtualNetworkProvider topologyProvider;
private TopologyService topologyService;
private TestableIntentService intentService = new FakeIntentManager();
private final VirtualNetworkRegistryAdapter virtualNetworkRegistry = new VirtualNetworkRegistryAdapter();
@@ -102,14 +103,14 @@
coreService = new VirtualNetworkTopologyProviderTest.TestCoreService();
- virtualNetworkManagerStore.setCoreService(coreService);
- TestUtils.setField(coreService, "coreService", new VirtualNetworkTopologyProviderTest.TestCoreService());
- TestUtils.setField(virtualNetworkManagerStore, "storageService", new TestStorageService());
+ TestUtils.setField(virtualNetworkManagerStore, "coreService", coreService);
+ TestUtils.setField(virtualNetworkManagerStore, "storageService",
+ new TestStorageService());
virtualNetworkManagerStore.activate();
manager = new VirtualNetworkManager();
- manager.store = virtualNetworkManagerStore;
- manager.intentService = intentService;
+ TestUtils.setField(manager, "store", virtualNetworkManagerStore);
+ TestUtils.setField(manager, "intentService", intentService);
NetTestTools.injectEventDispatcher(manager, new TestEventDispatcher());
manager.activate();
@@ -117,7 +118,7 @@
virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
- topologyProvider = new VirtualNetworkTopologyProvider();
+ topologyProvider = new DefaultVirtualNetworkProvider();
topologyProvider.topologyService = topologyService;
topologyProvider.providerRegistry = virtualNetworkRegistry;
topologyProvider.activate();
@@ -232,8 +233,9 @@
topologyProvider.isTraversable(new ConnectPoint(cp1.elementId(), cp1.port()),
new ConnectPoint(cp5.elementId(), cp5.port())));
assertFalse("These two connect points should not be traversable.",
- topologyProvider.isTraversable(new ConnectPoint(virtualDevice1.id(), PortNumber.portNumber(1)),
- new ConnectPoint(virtualDevice4.id(), PortNumber.portNumber(6))));
+ topologyProvider.isTraversable(
+ new ConnectPoint(virtualDevice1.id(), PortNumber.portNumber(1)),
+ new ConnectPoint(virtualDevice4.id(), PortNumber.portNumber(6))));
}
/**
@@ -242,7 +244,8 @@
@Test
public void testTopologyChanged() {
// Initial setup is two clusters of devices/links.
- assertEquals("The cluster count did not match.", 2, topologyService.currentTopology().clusterCount());
+ assertEquals("The cluster count did not match.", 2,
+ topologyService.currentTopology().clusterCount());
// Adding this link will join the two clusters together.
List<Event> reasons = new ArrayList<>();
@@ -272,12 +275,14 @@
// Validate that the topology changed method received a single cluster of connect points.
// This means that the two previous clusters have now joined into a single cluster.
assertEquals("The cluster count did not match.", 1, this.clusters.size());
- assertEquals("The cluster count did not match.", 1, topologyService.currentTopology().clusterCount());
+ assertEquals("The cluster count did not match.", 1,
+ topologyService.currentTopology().clusterCount());
// Now remove the virtual link to split it back into two clusters.
manager.removeVirtualLink(virtualNetwork.id(), link.src(), link.dst());
manager.removeVirtualLink(virtualNetwork.id(), link2.src(), link2.dst());
- assertEquals("The cluster count did not match.", 2, topologyService.currentTopology().clusterCount());
+ assertEquals("The cluster count did not match.", 2,
+ topologyService.currentTopology().clusterCount());
reasons = new ArrayList<>();
reasons.add(new LinkEvent(LinkEvent.Type.LINK_REMOVED, link));
@@ -350,11 +355,13 @@
}
@Override
- public void tunnelUp(NetworkId networkId, ConnectPoint src, ConnectPoint dst, TunnelId tunnelId) {
+ public void tunnelUp(NetworkId networkId, ConnectPoint src,
+ ConnectPoint dst, TunnelId tunnelId) {
}
@Override
- public void tunnelDown(NetworkId networkId, ConnectPoint src, ConnectPoint dst, TunnelId tunnelId) {
+ public void tunnelDown(NetworkId networkId, ConnectPoint src,
+ ConnectPoint dst, TunnelId tunnelId) {
}
}