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
Showing
4 changed files
with
138 additions
and
28 deletions
... | @@ -45,6 +45,11 @@ | ... | @@ -45,6 +45,11 @@ |
45 | <artifactId>onlab-junit</artifactId> | 45 | <artifactId>onlab-junit</artifactId> |
46 | <version>${project.version}</version> | 46 | <version>${project.version}</version> |
47 | </dependency> | 47 | </dependency> |
48 | + <dependency> | ||
49 | + <groupId>org.onosproject</groupId> | ||
50 | + <artifactId>onos-core-serializers</artifactId> | ||
51 | + <version>${project.version}</version> | ||
52 | + </dependency> | ||
48 | </dependencies> | 53 | </dependencies> |
49 | 54 | ||
50 | 55 | ... | ... |
... | @@ -15,25 +15,34 @@ | ... | @@ -15,25 +15,34 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.vtnrsc.subnet.impl; | 16 | package org.onosproject.vtnrsc.subnet.impl; |
17 | 17 | ||
18 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
19 | -import static org.slf4j.LoggerFactory.getLogger; | ||
20 | - | ||
21 | -import java.util.Collections; | ||
22 | -import java.util.concurrent.ConcurrentHashMap; | ||
23 | - | ||
24 | import org.apache.felix.scr.annotations.Activate; | 18 | import org.apache.felix.scr.annotations.Activate; |
25 | import org.apache.felix.scr.annotations.Component; | 19 | import org.apache.felix.scr.annotations.Component; |
26 | import org.apache.felix.scr.annotations.Deactivate; | 20 | import org.apache.felix.scr.annotations.Deactivate; |
27 | import org.apache.felix.scr.annotations.Reference; | 21 | import org.apache.felix.scr.annotations.Reference; |
28 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
29 | import org.apache.felix.scr.annotations.Service; | 23 | import org.apache.felix.scr.annotations.Service; |
24 | +import org.onosproject.core.ApplicationId; | ||
25 | +import org.onosproject.core.CoreService; | ||
26 | +import org.onosproject.store.serializers.KryoNamespaces; | ||
27 | +import org.onosproject.store.service.Serializer; | ||
30 | import org.onosproject.store.service.StorageService; | 28 | import org.onosproject.store.service.StorageService; |
29 | +import org.onosproject.vtnrsc.AllocationPool; | ||
30 | +import org.onosproject.vtnrsc.HostRoute; | ||
31 | import org.onosproject.vtnrsc.Subnet; | 31 | import org.onosproject.vtnrsc.Subnet; |
32 | import org.onosproject.vtnrsc.SubnetId; | 32 | import org.onosproject.vtnrsc.SubnetId; |
33 | +import org.onosproject.vtnrsc.TenantId; | ||
34 | +import org.onosproject.vtnrsc.TenantNetworkId; | ||
33 | import org.onosproject.vtnrsc.subnet.SubnetService; | 35 | import org.onosproject.vtnrsc.subnet.SubnetService; |
34 | import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService; | 36 | import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService; |
35 | import org.slf4j.Logger; | 37 | import org.slf4j.Logger; |
36 | 38 | ||
39 | +import java.util.Arrays; | ||
40 | +import java.util.Collections; | ||
41 | +import java.util.Map; | ||
42 | + | ||
43 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
44 | +import static org.slf4j.LoggerFactory.getLogger; | ||
45 | + | ||
37 | /** | 46 | /** |
38 | * Provides implementation of the Subnet service. | 47 | * Provides implementation of the Subnet service. |
39 | */ | 48 | */ |
... | @@ -43,26 +52,49 @@ public class SubnetManager implements SubnetService { | ... | @@ -43,26 +52,49 @@ public class SubnetManager implements SubnetService { |
43 | 52 | ||
44 | private static final String SUBNET_ID_NULL = "Subnet ID cannot be null"; | 53 | private static final String SUBNET_ID_NULL = "Subnet ID cannot be null"; |
45 | private static final String SUBNET_NOT_NULL = "Subnet cannot be null"; | 54 | private static final String SUBNET_NOT_NULL = "Subnet cannot be null"; |
55 | + private static final String SUBNET = "vtn-subnet-store"; | ||
56 | + private static final String VTNRSC_APP = "org.onosproject.vtnrsc"; | ||
57 | + | ||
46 | 58 | ||
47 | private final Logger log = getLogger(getClass()); | 59 | private final Logger log = getLogger(getClass()); |
48 | 60 | ||
49 | - protected ConcurrentHashMap<SubnetId, Subnet> subnetStore = | 61 | + protected Map<SubnetId, Subnet> subnetStore; |
50 | - new ConcurrentHashMap<>(); | 62 | + protected ApplicationId appId; |
63 | + | ||
51 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 64 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
52 | protected StorageService storageService; | 65 | protected StorageService storageService; |
53 | 66 | ||
54 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 67 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
68 | + protected CoreService coreService; | ||
69 | + | ||
70 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
55 | protected TenantNetworkService tenantNetworkService; | 71 | protected TenantNetworkService tenantNetworkService; |
56 | 72 | ||
57 | @Activate | 73 | @Activate |
58 | public void activate() { | 74 | public void activate() { |
59 | - log.info("SubnetManager started"); | 75 | + |
76 | + appId = coreService.registerApplication(VTNRSC_APP); | ||
77 | + | ||
78 | + subnetStore = storageService.<SubnetId, Subnet>consistentMapBuilder() | ||
79 | + .withName(SUBNET) | ||
80 | + .withApplicationId(appId) | ||
81 | + .withPurgeOnUninstall() | ||
82 | + .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API), | ||
83 | + Subnet.class, | ||
84 | + SubnetId.class, | ||
85 | + TenantNetworkId.class, | ||
86 | + TenantId.class, | ||
87 | + HostRoute.class, | ||
88 | + Subnet.Mode.class, | ||
89 | + AllocationPool.class)) | ||
90 | + .build().asJavaMap(); | ||
91 | + | ||
92 | + log.info("Started"); | ||
60 | } | 93 | } |
61 | 94 | ||
62 | @Deactivate | 95 | @Deactivate |
63 | public void deactivate() { | 96 | public void deactivate() { |
64 | - subnetStore.clear(); | 97 | + log.info("Stopped"); |
65 | - log.info("SubnetManager stopped"); | ||
66 | } | 98 | } |
67 | 99 | ||
68 | @Override | 100 | @Override | ... | ... |
... | @@ -15,21 +15,32 @@ | ... | @@ -15,21 +15,32 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.vtnrsc.tenantnetwork.impl; | 16 | package org.onosproject.vtnrsc.tenantnetwork.impl; |
17 | 17 | ||
18 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
19 | -import static org.slf4j.LoggerFactory.getLogger; | ||
20 | - | ||
21 | -import java.util.Collections; | ||
22 | -import java.util.concurrent.ConcurrentHashMap; | ||
23 | - | ||
24 | import org.apache.felix.scr.annotations.Activate; | 18 | import org.apache.felix.scr.annotations.Activate; |
25 | import org.apache.felix.scr.annotations.Component; | 19 | import org.apache.felix.scr.annotations.Component; |
26 | import org.apache.felix.scr.annotations.Deactivate; | 20 | import org.apache.felix.scr.annotations.Deactivate; |
21 | +import org.apache.felix.scr.annotations.Reference; | ||
22 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
27 | import org.apache.felix.scr.annotations.Service; | 23 | import org.apache.felix.scr.annotations.Service; |
24 | +import org.onosproject.core.ApplicationId; | ||
25 | +import org.onosproject.core.CoreService; | ||
26 | +import org.onosproject.store.serializers.KryoNamespaces; | ||
27 | +import org.onosproject.store.service.Serializer; | ||
28 | +import org.onosproject.store.service.StorageService; | ||
29 | +import org.onosproject.vtnrsc.PhysicalNetwork; | ||
30 | +import org.onosproject.vtnrsc.SegmentationId; | ||
31 | +import org.onosproject.vtnrsc.TenantId; | ||
28 | import org.onosproject.vtnrsc.TenantNetwork; | 32 | import org.onosproject.vtnrsc.TenantNetwork; |
29 | import org.onosproject.vtnrsc.TenantNetworkId; | 33 | import org.onosproject.vtnrsc.TenantNetworkId; |
30 | import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService; | 34 | import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService; |
31 | import org.slf4j.Logger; | 35 | import org.slf4j.Logger; |
32 | 36 | ||
37 | +import java.util.Arrays; | ||
38 | +import java.util.Collections; | ||
39 | +import java.util.Map; | ||
40 | + | ||
41 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
42 | +import static org.slf4j.LoggerFactory.getLogger; | ||
43 | + | ||
33 | /** | 44 | /** |
34 | * Provides implementation of the tenantNetworkService. | 45 | * Provides implementation of the tenantNetworkService. |
35 | */ | 46 | */ |
... | @@ -39,20 +50,44 @@ public class TenantNetworkManager implements TenantNetworkService { | ... | @@ -39,20 +50,44 @@ public class TenantNetworkManager implements TenantNetworkService { |
39 | 50 | ||
40 | private static final String NETWORK_ID_NULL = "Network ID cannot be null"; | 51 | private static final String NETWORK_ID_NULL = "Network ID cannot be null"; |
41 | private static final String NETWORK_NOT_NULL = "Network ID cannot be null"; | 52 | private static final String NETWORK_NOT_NULL = "Network ID cannot be null"; |
53 | + private static final String TENANTNETWORK = "vtn-tenant-network-store"; | ||
54 | + private static final String VTNRSC_APP = "org.onosproject.vtnrsc"; | ||
42 | 55 | ||
43 | - protected ConcurrentHashMap<TenantNetworkId, TenantNetwork> networkIdAsKeyStore = | 56 | + protected Map<TenantNetworkId, TenantNetwork> networkIdAsKeyStore; |
44 | - new ConcurrentHashMap<>(); | 57 | + protected ApplicationId appId; |
45 | 58 | ||
46 | private final Logger log = getLogger(getClass()); | 59 | private final Logger log = getLogger(getClass()); |
47 | 60 | ||
61 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
62 | + protected StorageService storageService; | ||
63 | + | ||
64 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
65 | + protected CoreService coreService; | ||
66 | + | ||
67 | + | ||
48 | @Activate | 68 | @Activate |
49 | public void activate() { | 69 | public void activate() { |
70 | + | ||
71 | + appId = coreService.registerApplication(VTNRSC_APP); | ||
72 | + | ||
73 | + networkIdAsKeyStore = storageService.<TenantNetworkId, TenantNetwork>consistentMapBuilder() | ||
74 | + .withName(TENANTNETWORK) | ||
75 | + .withApplicationId(appId) | ||
76 | + .withPurgeOnUninstall() | ||
77 | + .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API), | ||
78 | + TenantNetworkId.class, | ||
79 | + TenantNetwork.State.class, | ||
80 | + TenantId.class, | ||
81 | + TenantNetwork.Type.class, | ||
82 | + PhysicalNetwork.class, | ||
83 | + SegmentationId.class)) | ||
84 | + .build().asJavaMap(); | ||
85 | + | ||
50 | log.info("Started"); | 86 | log.info("Started"); |
51 | } | 87 | } |
52 | 88 | ||
53 | @Deactivate | 89 | @Deactivate |
54 | public void deactivate() { | 90 | public void deactivate() { |
55 | - networkIdAsKeyStore.clear(); | ||
56 | log.info("Stopped"); | 91 | log.info("Stopped"); |
57 | } | 92 | } |
58 | 93 | ... | ... |
... | @@ -15,20 +15,24 @@ | ... | @@ -15,20 +15,24 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.vtnrsc.virtualport.impl; | 16 | package org.onosproject.vtnrsc.virtualport.impl; |
17 | 17 | ||
18 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
19 | - | ||
20 | -import java.util.Collection; | ||
21 | -import java.util.Collections; | ||
22 | -import java.util.concurrent.ConcurrentHashMap; | ||
23 | - | ||
24 | import org.apache.felix.scr.annotations.Activate; | 18 | import org.apache.felix.scr.annotations.Activate; |
25 | import org.apache.felix.scr.annotations.Component; | 19 | import org.apache.felix.scr.annotations.Component; |
26 | import org.apache.felix.scr.annotations.Deactivate; | 20 | import org.apache.felix.scr.annotations.Deactivate; |
27 | import org.apache.felix.scr.annotations.Reference; | 21 | import org.apache.felix.scr.annotations.Reference; |
28 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
29 | import org.apache.felix.scr.annotations.Service; | 23 | import org.apache.felix.scr.annotations.Service; |
24 | +import org.onlab.packet.IpAddress; | ||
25 | +import org.onosproject.core.ApplicationId; | ||
26 | +import org.onosproject.core.CoreService; | ||
30 | import org.onosproject.net.DeviceId; | 27 | import org.onosproject.net.DeviceId; |
28 | +import org.onosproject.store.serializers.KryoNamespaces; | ||
29 | +import org.onosproject.store.service.Serializer; | ||
31 | import org.onosproject.store.service.StorageService; | 30 | import org.onosproject.store.service.StorageService; |
31 | +import org.onosproject.vtnrsc.AllowedAddressPair; | ||
32 | +import org.onosproject.vtnrsc.BindingHostId; | ||
33 | +import org.onosproject.vtnrsc.FixedIp; | ||
34 | +import org.onosproject.vtnrsc.SecurityGroup; | ||
35 | +import org.onosproject.vtnrsc.SubnetId; | ||
32 | import org.onosproject.vtnrsc.TenantId; | 36 | import org.onosproject.vtnrsc.TenantId; |
33 | import org.onosproject.vtnrsc.TenantNetworkId; | 37 | import org.onosproject.vtnrsc.TenantNetworkId; |
34 | import org.onosproject.vtnrsc.VirtualPort; | 38 | import org.onosproject.vtnrsc.VirtualPort; |
... | @@ -38,6 +42,13 @@ import org.onosproject.vtnrsc.virtualport.VirtualPortService; | ... | @@ -38,6 +42,13 @@ import org.onosproject.vtnrsc.virtualport.VirtualPortService; |
38 | import org.slf4j.Logger; | 42 | import org.slf4j.Logger; |
39 | import org.slf4j.LoggerFactory; | 43 | import org.slf4j.LoggerFactory; |
40 | 44 | ||
45 | +import java.util.Arrays; | ||
46 | +import java.util.Collection; | ||
47 | +import java.util.Collections; | ||
48 | +import java.util.Map; | ||
49 | + | ||
50 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
51 | + | ||
41 | /** | 52 | /** |
42 | * Provides implementation of the VirtualPort APIs. | 53 | * Provides implementation of the VirtualPort APIs. |
43 | */ | 54 | */ |
... | @@ -47,21 +58,48 @@ public class VirtualPortManager implements VirtualPortService { | ... | @@ -47,21 +58,48 @@ public class VirtualPortManager implements VirtualPortService { |
47 | 58 | ||
48 | private final Logger log = LoggerFactory.getLogger(getClass()); | 59 | private final Logger log = LoggerFactory.getLogger(getClass()); |
49 | 60 | ||
61 | + private static final String VIRTUALPORT = "vtn-virtual-port"; | ||
62 | + private static final String VTNRSC_APP = "org.onosproject.vtnrsc"; | ||
63 | + | ||
50 | private static final String VIRTUALPORT_ID_NULL = "VirtualPort ID cannot be null"; | 64 | private static final String VIRTUALPORT_ID_NULL = "VirtualPort ID cannot be null"; |
51 | private static final String VIRTUALPORT_NOT_NULL = "VirtualPort cannot be null"; | 65 | private static final String VIRTUALPORT_NOT_NULL = "VirtualPort cannot be null"; |
52 | private static final String TENANTID_NOT_NULL = "TenantId cannot be null"; | 66 | private static final String TENANTID_NOT_NULL = "TenantId cannot be null"; |
53 | private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null"; | 67 | private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null"; |
54 | private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null"; | 68 | private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null"; |
55 | 69 | ||
56 | - protected ConcurrentHashMap<VirtualPortId, VirtualPort> vPortStore = | 70 | + protected Map<VirtualPortId, VirtualPort> vPortStore; |
57 | - new ConcurrentHashMap<>(); | 71 | + protected ApplicationId appId; |
72 | + | ||
58 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 73 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
59 | protected StorageService storageService; | 74 | protected StorageService storageService; |
75 | + | ||
60 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 76 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
61 | protected TenantNetworkService networkService; | 77 | protected TenantNetworkService networkService; |
62 | 78 | ||
79 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
80 | + protected CoreService coreService; | ||
81 | + | ||
63 | @Activate | 82 | @Activate |
64 | public void activate() { | 83 | public void activate() { |
84 | + | ||
85 | + appId = coreService.registerApplication(VTNRSC_APP); | ||
86 | + | ||
87 | + vPortStore = storageService.<VirtualPortId, VirtualPort>consistentMapBuilder() | ||
88 | + .withName(VIRTUALPORT) | ||
89 | + .withApplicationId(appId) | ||
90 | + .withPurgeOnUninstall() | ||
91 | + .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API), | ||
92 | + VirtualPortId.class, | ||
93 | + TenantNetworkId.class, | ||
94 | + VirtualPort.State.class, | ||
95 | + TenantId.class, | ||
96 | + AllowedAddressPair.class, | ||
97 | + FixedIp.class, | ||
98 | + BindingHostId.class, | ||
99 | + SecurityGroup.class, | ||
100 | + SubnetId.class, | ||
101 | + IpAddress.class)) | ||
102 | + .build().asJavaMap(); | ||
65 | log.info("Started"); | 103 | log.info("Started"); |
66 | } | 104 | } |
67 | 105 | ... | ... |
-
Please register or login to post a comment