alshabib
Committed by Gerrit Code Review

Making the vtn resource app distributed

Change-Id: I9dace80c9a0e563451fc033b73e313c4935d73f7

making tenant network manager distributed

Change-Id: I306fc933ff1b28a01511d0d7ec12da47dda21b6e

making the virtual port manager distributed

Change-Id: Iaf28f21351508773064f6b6d9be361165d73ec3d
......@@ -45,6 +45,11 @@
<artifactId>onlab-junit</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-core-serializers</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
......
......@@ -15,25 +15,34 @@
*/
package org.onosproject.vtnrsc.subnet.impl;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Collections;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
import org.onosproject.vtnrsc.AllocationPool;
import org.onosproject.vtnrsc.HostRoute;
import org.onosproject.vtnrsc.Subnet;
import org.onosproject.vtnrsc.SubnetId;
import org.onosproject.vtnrsc.TenantId;
import org.onosproject.vtnrsc.TenantNetworkId;
import org.onosproject.vtnrsc.subnet.SubnetService;
import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
import org.slf4j.Logger;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Provides implementation of the Subnet service.
*/
......@@ -43,26 +52,49 @@ public class SubnetManager implements SubnetService {
private static final String SUBNET_ID_NULL = "Subnet ID cannot be null";
private static final String SUBNET_NOT_NULL = "Subnet cannot be null";
private static final String SUBNET = "vtn-subnet-store";
private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
private final Logger log = getLogger(getClass());
protected ConcurrentHashMap<SubnetId, Subnet> subnetStore =
new ConcurrentHashMap<>();
protected Map<SubnetId, Subnet> subnetStore;
protected ApplicationId appId;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService storageService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected TenantNetworkService tenantNetworkService;
@Activate
public void activate() {
log.info("SubnetManager started");
appId = coreService.registerApplication(VTNRSC_APP);
subnetStore = storageService.<SubnetId, Subnet>consistentMapBuilder()
.withName(SUBNET)
.withApplicationId(appId)
.withPurgeOnUninstall()
.withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
Subnet.class,
SubnetId.class,
TenantNetworkId.class,
TenantId.class,
HostRoute.class,
Subnet.Mode.class,
AllocationPool.class))
.build().asJavaMap();
log.info("Started");
}
@Deactivate
public void deactivate() {
subnetStore.clear();
log.info("SubnetManager stopped");
log.info("Stopped");
}
@Override
......
......@@ -15,21 +15,32 @@
*/
package org.onosproject.vtnrsc.tenantnetwork.impl;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Collections;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
import org.onosproject.vtnrsc.PhysicalNetwork;
import org.onosproject.vtnrsc.SegmentationId;
import org.onosproject.vtnrsc.TenantId;
import org.onosproject.vtnrsc.TenantNetwork;
import org.onosproject.vtnrsc.TenantNetworkId;
import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
import org.slf4j.Logger;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Provides implementation of the tenantNetworkService.
*/
......@@ -39,20 +50,44 @@ public class TenantNetworkManager implements TenantNetworkService {
private static final String NETWORK_ID_NULL = "Network ID cannot be null";
private static final String NETWORK_NOT_NULL = "Network ID cannot be null";
private static final String TENANTNETWORK = "vtn-tenant-network-store";
private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
protected ConcurrentHashMap<TenantNetworkId, TenantNetwork> networkIdAsKeyStore =
new ConcurrentHashMap<>();
protected Map<TenantNetworkId, TenantNetwork> networkIdAsKeyStore;
protected ApplicationId appId;
private final Logger log = getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService storageService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@Activate
public void activate() {
appId = coreService.registerApplication(VTNRSC_APP);
networkIdAsKeyStore = storageService.<TenantNetworkId, TenantNetwork>consistentMapBuilder()
.withName(TENANTNETWORK)
.withApplicationId(appId)
.withPurgeOnUninstall()
.withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
TenantNetworkId.class,
TenantNetwork.State.class,
TenantId.class,
TenantNetwork.Type.class,
PhysicalNetwork.class,
SegmentationId.class))
.build().asJavaMap();
log.info("Started");
}
@Deactivate
public void deactivate() {
networkIdAsKeyStore.clear();
log.info("Stopped");
}
......
......@@ -15,20 +15,24 @@
*/
package org.onosproject.vtnrsc.virtualport.impl;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.IpAddress;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.net.DeviceId;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
import org.onosproject.vtnrsc.AllowedAddressPair;
import org.onosproject.vtnrsc.BindingHostId;
import org.onosproject.vtnrsc.FixedIp;
import org.onosproject.vtnrsc.SecurityGroup;
import org.onosproject.vtnrsc.SubnetId;
import org.onosproject.vtnrsc.TenantId;
import org.onosproject.vtnrsc.TenantNetworkId;
import org.onosproject.vtnrsc.VirtualPort;
......@@ -38,6 +42,13 @@ import org.onosproject.vtnrsc.virtualport.VirtualPortService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Provides implementation of the VirtualPort APIs.
*/
......@@ -47,21 +58,48 @@ public class VirtualPortManager implements VirtualPortService {
private final Logger log = LoggerFactory.getLogger(getClass());
private static final String VIRTUALPORT = "vtn-virtual-port";
private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
private static final String VIRTUALPORT_ID_NULL = "VirtualPort ID cannot be null";
private static final String VIRTUALPORT_NOT_NULL = "VirtualPort cannot be null";
private static final String TENANTID_NOT_NULL = "TenantId cannot be null";
private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null";
private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null";
protected ConcurrentHashMap<VirtualPortId, VirtualPort> vPortStore =
new ConcurrentHashMap<>();
protected Map<VirtualPortId, VirtualPort> vPortStore;
protected ApplicationId appId;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService storageService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected TenantNetworkService networkService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@Activate
public void activate() {
appId = coreService.registerApplication(VTNRSC_APP);
vPortStore = storageService.<VirtualPortId, VirtualPort>consistentMapBuilder()
.withName(VIRTUALPORT)
.withApplicationId(appId)
.withPurgeOnUninstall()
.withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
VirtualPortId.class,
TenantNetworkId.class,
VirtualPort.State.class,
TenantId.class,
AllowedAddressPair.class,
FixedIp.class,
BindingHostId.class,
SecurityGroup.class,
SubnetId.class,
IpAddress.class))
.build().asJavaMap();
log.info("Started");
}
......