Showing
84 changed files
with
2207 additions
and
102 deletions
1 | +package org.onlab.onos.net.proxyarp; | ||
2 | + | ||
3 | +import org.onlab.packet.Ethernet; | ||
4 | +import org.onlab.packet.IpPrefix; | ||
5 | + | ||
6 | +/** | ||
7 | + * Service for processing arp requests on behalf of applications. | ||
8 | + */ | ||
9 | +public interface ProxyArpService { | ||
10 | + | ||
11 | + /** | ||
12 | + * Returns whether this particular ip address is known to the system. | ||
13 | + * | ||
14 | + * @param addr | ||
15 | + * a ip address | ||
16 | + * @return true if know, false otherwise | ||
17 | + */ | ||
18 | + boolean known(IpPrefix addr); | ||
19 | + | ||
20 | + /** | ||
21 | + * Sends a reply for a given request. If the host is not known then the arp | ||
22 | + * will be flooded at all edge ports. | ||
23 | + * | ||
24 | + * @param request | ||
25 | + * an arp request | ||
26 | + */ | ||
27 | + void reply(Ethernet request); | ||
28 | + | ||
29 | +} |
1 | +package org.onlab.onos.store; | ||
2 | + | ||
3 | +import org.onlab.onos.cluster.MastershipTerm; | ||
4 | +import org.onlab.onos.net.DeviceId; | ||
5 | + | ||
6 | +// TODO: Consider renaming to DeviceClockService? | ||
7 | +/** | ||
8 | + * Interface for a logical clock service that vends per device timestamps. | ||
9 | + */ | ||
10 | +public interface ClockService { | ||
11 | + | ||
12 | + /** | ||
13 | + * Returns a new timestamp for the specified deviceId. | ||
14 | + * @param deviceId device identifier. | ||
15 | + * @return timestamp. | ||
16 | + */ | ||
17 | + public Timestamp getTimestamp(DeviceId deviceId); | ||
18 | + | ||
19 | + // TODO: Should this be here or separate as Admin service, etc.? | ||
20 | + /** | ||
21 | + * Updates the mastership term for the specified deviceId. | ||
22 | + * @param deviceId device identifier. | ||
23 | + * @param term mastership term. | ||
24 | + */ | ||
25 | + public void setMastershipTerm(DeviceId deviceId, MastershipTerm term); | ||
26 | +} |
... | @@ -40,13 +40,14 @@ | ... | @@ -40,13 +40,14 @@ |
40 | Currently required for DistributedDeviceManagerTest. --> | 40 | Currently required for DistributedDeviceManagerTest. --> |
41 | <dependency> | 41 | <dependency> |
42 | <groupId>org.onlab.onos</groupId> | 42 | <groupId>org.onlab.onos</groupId> |
43 | - <artifactId>onos-core-store</artifactId> | 43 | + <artifactId>onos-core-hz-net</artifactId> |
44 | <version>${project.version}</version> | 44 | <version>${project.version}</version> |
45 | <scope>test</scope> | 45 | <scope>test</scope> |
46 | </dependency> | 46 | </dependency> |
47 | <dependency> | 47 | <dependency> |
48 | <groupId>org.onlab.onos</groupId> | 48 | <groupId>org.onlab.onos</groupId> |
49 | - <artifactId>onos-core-store</artifactId> | 49 | + <!-- FIXME: should be somewhere else --> |
50 | + <artifactId>onos-core-hz-common</artifactId> | ||
50 | <version>${project.version}</version> | 51 | <version>${project.version}</version> |
51 | <classifier>tests</classifier> | 52 | <classifier>tests</classifier> |
52 | <scope>test</scope> | 53 | <scope>test</scope> | ... | ... |
... | @@ -16,6 +16,7 @@ import org.onlab.onos.cluster.ClusterService; | ... | @@ -16,6 +16,7 @@ import org.onlab.onos.cluster.ClusterService; |
16 | import org.onlab.onos.cluster.MastershipEvent; | 16 | import org.onlab.onos.cluster.MastershipEvent; |
17 | import org.onlab.onos.cluster.MastershipListener; | 17 | import org.onlab.onos.cluster.MastershipListener; |
18 | import org.onlab.onos.cluster.MastershipService; | 18 | import org.onlab.onos.cluster.MastershipService; |
19 | +import org.onlab.onos.cluster.MastershipTerm; | ||
19 | import org.onlab.onos.event.AbstractListenerRegistry; | 20 | import org.onlab.onos.event.AbstractListenerRegistry; |
20 | import org.onlab.onos.event.EventDeliveryService; | 21 | import org.onlab.onos.event.EventDeliveryService; |
21 | import org.onlab.onos.net.Device; | 22 | import org.onlab.onos.net.Device; |
... | @@ -36,6 +37,7 @@ import org.onlab.onos.net.device.DeviceStoreDelegate; | ... | @@ -36,6 +37,7 @@ import org.onlab.onos.net.device.DeviceStoreDelegate; |
36 | import org.onlab.onos.net.device.PortDescription; | 37 | import org.onlab.onos.net.device.PortDescription; |
37 | import org.onlab.onos.net.provider.AbstractProviderRegistry; | 38 | import org.onlab.onos.net.provider.AbstractProviderRegistry; |
38 | import org.onlab.onos.net.provider.AbstractProviderService; | 39 | import org.onlab.onos.net.provider.AbstractProviderService; |
40 | +import org.onlab.onos.store.ClockService; | ||
39 | import org.slf4j.Logger; | 41 | import org.slf4j.Logger; |
40 | 42 | ||
41 | /** | 43 | /** |
... | @@ -44,8 +46,8 @@ import org.slf4j.Logger; | ... | @@ -44,8 +46,8 @@ import org.slf4j.Logger; |
44 | @Component(immediate = true) | 46 | @Component(immediate = true) |
45 | @Service | 47 | @Service |
46 | public class DeviceManager | 48 | public class DeviceManager |
47 | -extends AbstractProviderRegistry<DeviceProvider, DeviceProviderService> | 49 | + extends AbstractProviderRegistry<DeviceProvider, DeviceProviderService> |
48 | -implements DeviceService, DeviceAdminService, DeviceProviderRegistry { | 50 | + implements DeviceService, DeviceAdminService, DeviceProviderRegistry { |
49 | 51 | ||
50 | private static final String DEVICE_ID_NULL = "Device ID cannot be null"; | 52 | private static final String DEVICE_ID_NULL = "Device ID cannot be null"; |
51 | private static final String PORT_NUMBER_NULL = "Port number cannot be null"; | 53 | private static final String PORT_NUMBER_NULL = "Port number cannot be null"; |
... | @@ -55,8 +57,8 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { | ... | @@ -55,8 +57,8 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { |
55 | 57 | ||
56 | private final Logger log = getLogger(getClass()); | 58 | private final Logger log = getLogger(getClass()); |
57 | 59 | ||
58 | - protected final AbstractListenerRegistry<DeviceEvent, DeviceListener> | 60 | + protected final AbstractListenerRegistry<DeviceEvent, DeviceListener> listenerRegistry = |
59 | - listenerRegistry = new AbstractListenerRegistry<>(); | 61 | + new AbstractListenerRegistry<>(); |
60 | 62 | ||
61 | private final DeviceStoreDelegate delegate = new InternalStoreDelegate(); | 63 | private final DeviceStoreDelegate delegate = new InternalStoreDelegate(); |
62 | 64 | ||
... | @@ -74,6 +76,9 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { | ... | @@ -74,6 +76,9 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { |
74 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 76 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
75 | protected MastershipService mastershipService; | 77 | protected MastershipService mastershipService; |
76 | 78 | ||
79 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
80 | + protected ClockService clockService; | ||
81 | + | ||
77 | @Activate | 82 | @Activate |
78 | public void activate() { | 83 | public void activate() { |
79 | store.setDelegate(delegate); | 84 | store.setDelegate(delegate); |
... | @@ -164,7 +169,8 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { | ... | @@ -164,7 +169,8 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { |
164 | } | 169 | } |
165 | 170 | ||
166 | @Override | 171 | @Override |
167 | - protected DeviceProviderService createProviderService(DeviceProvider provider) { | 172 | + protected DeviceProviderService createProviderService( |
173 | + DeviceProvider provider) { | ||
168 | return new InternalDeviceProviderService(provider); | 174 | return new InternalDeviceProviderService(provider); |
169 | } | 175 | } |
170 | 176 | ||
... | @@ -178,14 +184,16 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { | ... | @@ -178,14 +184,16 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { |
178 | } | 184 | } |
179 | 185 | ||
180 | @Override | 186 | @Override |
181 | - public void deviceConnected(DeviceId deviceId, DeviceDescription deviceDescription) { | 187 | + public void deviceConnected(DeviceId deviceId, |
188 | + DeviceDescription deviceDescription) { | ||
182 | checkNotNull(deviceId, DEVICE_ID_NULL); | 189 | checkNotNull(deviceId, DEVICE_ID_NULL); |
183 | checkNotNull(deviceDescription, DEVICE_DESCRIPTION_NULL); | 190 | checkNotNull(deviceDescription, DEVICE_DESCRIPTION_NULL); |
184 | checkValidity(); | 191 | checkValidity(); |
185 | DeviceEvent event = store.createOrUpdateDevice(provider().id(), | 192 | DeviceEvent event = store.createOrUpdateDevice(provider().id(), |
186 | deviceId, deviceDescription); | 193 | deviceId, deviceDescription); |
187 | 194 | ||
188 | - // If there was a change of any kind, trigger role selection process. | 195 | + // If there was a change of any kind, trigger role selection |
196 | + // process. | ||
189 | if (event != null) { | 197 | if (event != null) { |
190 | log.info("Device {} connected", deviceId); | 198 | log.info("Device {} connected", deviceId); |
191 | mastershipService.requestRoleFor(deviceId); | 199 | mastershipService.requestRoleFor(deviceId); |
... | @@ -207,25 +215,30 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { | ... | @@ -207,25 +215,30 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { |
207 | } | 215 | } |
208 | 216 | ||
209 | @Override | 217 | @Override |
210 | - public void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) { | 218 | + public void updatePorts(DeviceId deviceId, |
219 | + List<PortDescription> portDescriptions) { | ||
211 | checkNotNull(deviceId, DEVICE_ID_NULL); | 220 | checkNotNull(deviceId, DEVICE_ID_NULL); |
212 | - checkNotNull(portDescriptions, "Port descriptions list cannot be null"); | 221 | + checkNotNull(portDescriptions, |
222 | + "Port descriptions list cannot be null"); | ||
213 | checkValidity(); | 223 | checkValidity(); |
214 | - List<DeviceEvent> events = store.updatePorts(deviceId, portDescriptions); | 224 | + List<DeviceEvent> events = store.updatePorts(deviceId, |
225 | + portDescriptions); | ||
215 | for (DeviceEvent event : events) { | 226 | for (DeviceEvent event : events) { |
216 | post(event); | 227 | post(event); |
217 | } | 228 | } |
218 | } | 229 | } |
219 | 230 | ||
220 | @Override | 231 | @Override |
221 | - public void portStatusChanged(DeviceId deviceId, PortDescription portDescription) { | 232 | + public void portStatusChanged(DeviceId deviceId, |
233 | + PortDescription portDescription) { | ||
222 | checkNotNull(deviceId, DEVICE_ID_NULL); | 234 | checkNotNull(deviceId, DEVICE_ID_NULL); |
223 | checkNotNull(portDescription, PORT_DESCRIPTION_NULL); | 235 | checkNotNull(portDescription, PORT_DESCRIPTION_NULL); |
224 | checkValidity(); | 236 | checkValidity(); |
225 | - DeviceEvent event = store.updatePortStatus(deviceId, portDescription); | 237 | + DeviceEvent event = store.updatePortStatus(deviceId, |
238 | + portDescription); | ||
226 | if (event != null) { | 239 | if (event != null) { |
227 | - log.info("Device {} port {} status changed", deviceId, | 240 | + log.info("Device {} port {} status changed", deviceId, event |
228 | - event.port().number()); | 241 | + .port().number()); |
229 | post(event); | 242 | post(event); |
230 | } | 243 | } |
231 | } | 244 | } |
... | @@ -233,8 +246,8 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { | ... | @@ -233,8 +246,8 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { |
233 | @Override | 246 | @Override |
234 | public void unableToAssertRole(DeviceId deviceId, MastershipRole role) { | 247 | public void unableToAssertRole(DeviceId deviceId, MastershipRole role) { |
235 | // FIXME: implement response to this notification | 248 | // FIXME: implement response to this notification |
236 | - log.warn("Failed to assert role [{}] onto Device {}", | 249 | + log.warn("Failed to assert role [{}] onto Device {}", role, |
237 | - role, deviceId); | 250 | + deviceId); |
238 | } | 251 | } |
239 | } | 252 | } |
240 | 253 | ||
... | @@ -246,10 +259,14 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { | ... | @@ -246,10 +259,14 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { |
246 | } | 259 | } |
247 | 260 | ||
248 | // Intercepts mastership events | 261 | // Intercepts mastership events |
249 | - private class InternalMastershipListener implements MastershipListener { | 262 | + private class InternalMastershipListener |
263 | + implements MastershipListener { | ||
250 | @Override | 264 | @Override |
251 | public void event(MastershipEvent event) { | 265 | public void event(MastershipEvent event) { |
252 | if (event.master().equals(clusterService.getLocalNode().id())) { | 266 | if (event.master().equals(clusterService.getLocalNode().id())) { |
267 | + MastershipTerm term = mastershipService.requestTermService() | ||
268 | + .getMastershipTerm(event.subject()); | ||
269 | + clockService.setMastershipTerm(event.subject(), term); | ||
253 | applyRole(event.subject(), MastershipRole.MASTER); | 270 | applyRole(event.subject(), MastershipRole.MASTER); |
254 | } else { | 271 | } else { |
255 | applyRole(event.subject(), MastershipRole.STANDBY); | 272 | applyRole(event.subject(), MastershipRole.STANDBY); |
... | @@ -258,7 +275,8 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { | ... | @@ -258,7 +275,8 @@ implements DeviceService, DeviceAdminService, DeviceProviderRegistry { |
258 | } | 275 | } |
259 | 276 | ||
260 | // Store delegate to re-post events emitted from the store. | 277 | // Store delegate to re-post events emitted from the store. |
261 | - private class InternalStoreDelegate implements DeviceStoreDelegate { | 278 | + private class InternalStoreDelegate |
279 | + implements DeviceStoreDelegate { | ||
262 | @Override | 280 | @Override |
263 | public void notify(DeviceEvent event) { | 281 | public void notify(DeviceEvent event) { |
264 | post(event); | 282 | post(event); | ... | ... |
1 | +package org.onlab.onos.proxyarp.impl; | ||
2 | + | ||
3 | +import static com.google.common.base.Preconditions.checkArgument; | ||
4 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
5 | + | ||
6 | +import java.nio.ByteBuffer; | ||
7 | +import java.util.Set; | ||
8 | + | ||
9 | +import org.apache.felix.scr.annotations.Reference; | ||
10 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
11 | +import org.onlab.onos.net.Host; | ||
12 | +import org.onlab.onos.net.flow.DefaultTrafficTreatment; | ||
13 | +import org.onlab.onos.net.flow.TrafficTreatment; | ||
14 | +import org.onlab.onos.net.host.HostService; | ||
15 | +import org.onlab.onos.net.packet.DefaultOutboundPacket; | ||
16 | +import org.onlab.onos.net.packet.PacketService; | ||
17 | +import org.onlab.onos.net.proxyarp.ProxyArpService; | ||
18 | +import org.onlab.onos.net.topology.TopologyService; | ||
19 | +import org.onlab.packet.ARP; | ||
20 | +import org.onlab.packet.Ethernet; | ||
21 | +import org.onlab.packet.IpPrefix; | ||
22 | +import org.onlab.packet.VlanId; | ||
23 | + | ||
24 | +public class ProxyArpManager implements ProxyArpService { | ||
25 | + | ||
26 | + private static final String MAC_ADDR_NULL = "Mac address cannot be null."; | ||
27 | + private static final String REQUEST_NULL = "Arp request cannot be null."; | ||
28 | + private static final String REQUEST_NOT_ARP = "Ethernet frame does not contain ARP request."; | ||
29 | + private static final String NOT_ARP_REQUEST = "ARP is not a request."; | ||
30 | + | ||
31 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
32 | + protected HostService hostService; | ||
33 | + | ||
34 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
35 | + protected PacketService packetService; | ||
36 | + | ||
37 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
38 | + protected TopologyService topologyService; | ||
39 | + | ||
40 | + @Override | ||
41 | + public boolean known(IpPrefix addr) { | ||
42 | + checkNotNull(MAC_ADDR_NULL, addr); | ||
43 | + Set<Host> hosts = hostService.getHostsByIp(addr); | ||
44 | + return !hosts.isEmpty(); | ||
45 | + } | ||
46 | + | ||
47 | + @Override | ||
48 | + public void reply(Ethernet request) { | ||
49 | + checkNotNull(REQUEST_NULL, request); | ||
50 | + checkArgument(request.getEtherType() == Ethernet.TYPE_ARP, | ||
51 | + REQUEST_NOT_ARP); | ||
52 | + ARP arp = (ARP) request.getPayload(); | ||
53 | + checkArgument(arp.getOpCode() == ARP.OP_REQUEST, NOT_ARP_REQUEST); | ||
54 | + | ||
55 | + VlanId vlan = VlanId.vlanId(request.getVlanID()); | ||
56 | + Set<Host> hosts = hostService.getHostsByIp(IpPrefix.valueOf(arp | ||
57 | + .getTargetProtocolAddress())); | ||
58 | + | ||
59 | + Host h = null; | ||
60 | + for (Host host : hosts) { | ||
61 | + if (host.vlan().equals(vlan)) { | ||
62 | + h = host; | ||
63 | + break; | ||
64 | + } | ||
65 | + } | ||
66 | + | ||
67 | + if (h == null) { | ||
68 | + flood(request); | ||
69 | + return; | ||
70 | + } | ||
71 | + | ||
72 | + Ethernet arpReply = buildArpReply(h, request); | ||
73 | + // TODO: check send status with host service. | ||
74 | + TrafficTreatment.Builder builder = new DefaultTrafficTreatment.Builder(); | ||
75 | + builder.setOutput(h.location().port()); | ||
76 | + packetService.emit(new DefaultOutboundPacket(h.location().deviceId(), | ||
77 | + builder.build(), ByteBuffer.wrap(arpReply.serialize()))); | ||
78 | + } | ||
79 | + | ||
80 | + private void flood(Ethernet request) { | ||
81 | + // TODO: flood on all edge ports. | ||
82 | + } | ||
83 | + | ||
84 | + private Ethernet buildArpReply(Host h, Ethernet request) { | ||
85 | + Ethernet eth = new Ethernet(); | ||
86 | + eth.setDestinationMACAddress(request.getSourceMACAddress()); | ||
87 | + eth.setSourceMACAddress(h.mac().getAddress()); | ||
88 | + eth.setEtherType(Ethernet.TYPE_ARP); | ||
89 | + ARP arp = new ARP(); | ||
90 | + arp.setOpCode(ARP.OP_REPLY); | ||
91 | + arp.setSenderHardwareAddress(h.mac().getAddress()); | ||
92 | + arp.setTargetHardwareAddress(request.getSourceMACAddress()); | ||
93 | + | ||
94 | + arp.setTargetProtocolAddress(((ARP) request.getPayload()) | ||
95 | + .getSenderProtocolAddress()); | ||
96 | + arp.setSenderProtocolAddress(h.ipAddresses().iterator().next().toInt()); | ||
97 | + eth.setPayload(arp); | ||
98 | + return eth; | ||
99 | + } | ||
100 | +} |
... | @@ -32,9 +32,9 @@ import org.onlab.onos.net.device.DeviceService; | ... | @@ -32,9 +32,9 @@ import org.onlab.onos.net.device.DeviceService; |
32 | import org.onlab.onos.net.device.PortDescription; | 32 | import org.onlab.onos.net.device.PortDescription; |
33 | import org.onlab.onos.net.provider.AbstractProvider; | 33 | import org.onlab.onos.net.provider.AbstractProvider; |
34 | import org.onlab.onos.net.provider.ProviderId; | 34 | import org.onlab.onos.net.provider.ProviderId; |
35 | +import org.onlab.onos.store.common.StoreManager; | ||
36 | +import org.onlab.onos.store.common.TestStoreManager; | ||
35 | import org.onlab.onos.store.device.impl.DistributedDeviceStore; | 37 | import org.onlab.onos.store.device.impl.DistributedDeviceStore; |
36 | -import org.onlab.onos.store.impl.StoreManager; | ||
37 | -import org.onlab.onos.store.impl.TestStoreManager; | ||
38 | import org.onlab.packet.IpPrefix; | 38 | import org.onlab.packet.IpPrefix; |
39 | 39 | ||
40 | import java.util.ArrayList; | 40 | import java.util.ArrayList; | ... | ... |
core/store/dist/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
5 | + <modelVersion>4.0.0</modelVersion> | ||
6 | + | ||
7 | + <parent> | ||
8 | + <groupId>org.onlab.onos</groupId> | ||
9 | + <artifactId>onos-core-store</artifactId> | ||
10 | + <version>1.0.0-SNAPSHOT</version> | ||
11 | + <relativePath>../pom.xml</relativePath> | ||
12 | + </parent> | ||
13 | + | ||
14 | + <artifactId>onos-core-dist</artifactId> | ||
15 | + <packaging>bundle</packaging> | ||
16 | + | ||
17 | + <description>ONOS Gossip based distributed store subsystems</description> | ||
18 | + | ||
19 | + <dependencies> | ||
20 | + <dependency> | ||
21 | + <groupId>org.onlab.onos</groupId> | ||
22 | + <artifactId>onos-api</artifactId> | ||
23 | + </dependency> | ||
24 | + <dependency> | ||
25 | + <groupId>org.onlab.onos</groupId> | ||
26 | + <artifactId>onos-core-serializers</artifactId> | ||
27 | + <version>${project.version}</version> | ||
28 | + </dependency> | ||
29 | + <dependency> | ||
30 | + <groupId>org.apache.felix</groupId> | ||
31 | + <artifactId>org.apache.felix.scr.annotations</artifactId> | ||
32 | + </dependency> | ||
33 | + <dependency> | ||
34 | + <groupId>de.javakaffee</groupId> | ||
35 | + <artifactId>kryo-serializers</artifactId> | ||
36 | + </dependency> | ||
37 | + </dependencies> | ||
38 | + | ||
39 | + <build> | ||
40 | + <plugins> | ||
41 | + <plugin> | ||
42 | + <groupId>org.apache.felix</groupId> | ||
43 | + <artifactId>maven-scr-plugin</artifactId> | ||
44 | + </plugin> | ||
45 | + </plugins> | ||
46 | + </build> | ||
47 | + | ||
48 | +</project> |
1 | +package org.onlab.onos.store.device.impl; | ||
2 | + | ||
3 | +import static org.slf4j.LoggerFactory.getLogger; | ||
4 | + | ||
5 | +import java.util.concurrent.ConcurrentHashMap; | ||
6 | +import java.util.concurrent.ConcurrentMap; | ||
7 | +import java.util.concurrent.atomic.AtomicInteger; | ||
8 | + | ||
9 | +import org.apache.felix.scr.annotations.Activate; | ||
10 | +import org.apache.felix.scr.annotations.Component; | ||
11 | +import org.apache.felix.scr.annotations.Deactivate; | ||
12 | +import org.apache.felix.scr.annotations.Service; | ||
13 | +import org.onlab.onos.cluster.MastershipTerm; | ||
14 | +import org.onlab.onos.net.DeviceId; | ||
15 | +import org.onlab.onos.store.ClockService; | ||
16 | +import org.onlab.onos.store.Timestamp; | ||
17 | +import org.onlab.onos.store.impl.OnosTimestamp; | ||
18 | +import org.slf4j.Logger; | ||
19 | + | ||
20 | +@Component(immediate = true) | ||
21 | +@Service | ||
22 | +public class OnosClockService implements ClockService { | ||
23 | + | ||
24 | + private final Logger log = getLogger(getClass()); | ||
25 | + | ||
26 | + // TODO: Implement per device ticker that is reset to 0 at the beginning of a new term. | ||
27 | + private final AtomicInteger ticker = new AtomicInteger(0); | ||
28 | + private ConcurrentMap<DeviceId, MastershipTerm> deviceMastershipTerms = new ConcurrentHashMap<>(); | ||
29 | + | ||
30 | + @Activate | ||
31 | + public void activate() { | ||
32 | + log.info("Started"); | ||
33 | + } | ||
34 | + | ||
35 | + @Deactivate | ||
36 | + public void deactivate() { | ||
37 | + log.info("Stopped"); | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public Timestamp getTimestamp(DeviceId deviceId) { | ||
42 | + MastershipTerm term = deviceMastershipTerms.get(deviceId); | ||
43 | + if (term == null) { | ||
44 | + throw new IllegalStateException("Requesting timestamp for a deviceId without mastership"); | ||
45 | + } | ||
46 | + return new OnosTimestamp(term.termNumber(), ticker.incrementAndGet()); | ||
47 | + } | ||
48 | + | ||
49 | + @Override | ||
50 | + public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) { | ||
51 | + deviceMastershipTerms.put(deviceId, term); | ||
52 | + } | ||
53 | +} |
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/OnosDistributedDeviceStore.java
0 → 100644
1 | +package org.onlab.onos.store.device.impl; | ||
2 | + | ||
3 | +import static com.google.common.base.Predicates.notNull; | ||
4 | +import static com.google.common.base.Preconditions.checkState; | ||
5 | + | ||
6 | +import com.google.common.collect.FluentIterable; | ||
7 | +import com.google.common.collect.ImmutableSet; | ||
8 | +import com.google.common.collect.ImmutableSet.Builder; | ||
9 | + | ||
10 | +import org.apache.felix.scr.annotations.Activate; | ||
11 | +import org.apache.felix.scr.annotations.Component; | ||
12 | +import org.apache.felix.scr.annotations.Deactivate; | ||
13 | +import org.apache.felix.scr.annotations.Reference; | ||
14 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
15 | +import org.apache.felix.scr.annotations.Service; | ||
16 | +import org.onlab.onos.net.DefaultDevice; | ||
17 | +import org.onlab.onos.net.DefaultPort; | ||
18 | +import org.onlab.onos.net.Device; | ||
19 | +import org.onlab.onos.net.DeviceId; | ||
20 | +import org.onlab.onos.net.Port; | ||
21 | +import org.onlab.onos.net.PortNumber; | ||
22 | +import org.onlab.onos.net.device.DeviceDescription; | ||
23 | +import org.onlab.onos.net.device.DeviceEvent; | ||
24 | +import org.onlab.onos.net.device.DeviceStore; | ||
25 | +import org.onlab.onos.net.device.DeviceStoreDelegate; | ||
26 | +import org.onlab.onos.net.device.PortDescription; | ||
27 | +import org.onlab.onos.net.provider.ProviderId; | ||
28 | +import org.onlab.onos.store.AbstractStore; | ||
29 | +import org.onlab.onos.store.ClockService; | ||
30 | +import org.onlab.onos.store.Timestamp; | ||
31 | +import org.slf4j.Logger; | ||
32 | + | ||
33 | +import java.util.ArrayList; | ||
34 | +import java.util.Collections; | ||
35 | +import java.util.HashMap; | ||
36 | +import java.util.HashSet; | ||
37 | +import java.util.Iterator; | ||
38 | +import java.util.List; | ||
39 | +import java.util.Map; | ||
40 | +import java.util.Objects; | ||
41 | +import java.util.Set; | ||
42 | +import java.util.concurrent.ConcurrentHashMap; | ||
43 | + | ||
44 | +import static com.google.common.base.Preconditions.checkArgument; | ||
45 | +import static org.onlab.onos.net.device.DeviceEvent.Type.*; | ||
46 | +import static org.slf4j.LoggerFactory.getLogger; | ||
47 | + | ||
48 | +/** | ||
49 | + * Manages inventory of infrastructure devices using a protocol that takes into consideration | ||
50 | + * the order in which device events occur. | ||
51 | + */ | ||
52 | +@Component(immediate = true) | ||
53 | +@Service | ||
54 | +public class OnosDistributedDeviceStore | ||
55 | + extends AbstractStore<DeviceEvent, DeviceStoreDelegate> | ||
56 | + implements DeviceStore { | ||
57 | + | ||
58 | + private final Logger log = getLogger(getClass()); | ||
59 | + | ||
60 | + public static final String DEVICE_NOT_FOUND = "Device with ID %s not found"; | ||
61 | + | ||
62 | + private ConcurrentHashMap<DeviceId, VersionedValue<Device>> devices; | ||
63 | + private ConcurrentHashMap<DeviceId, Map<PortNumber, VersionedValue<Port>>> devicePorts; | ||
64 | + | ||
65 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
66 | + protected ClockService clockService; | ||
67 | + | ||
68 | + @Activate | ||
69 | + public void activate() { | ||
70 | + | ||
71 | + devices = new ConcurrentHashMap<>(); | ||
72 | + devicePorts = new ConcurrentHashMap<>(); | ||
73 | + | ||
74 | + log.info("Started"); | ||
75 | + } | ||
76 | + | ||
77 | + @Deactivate | ||
78 | + public void deactivate() { | ||
79 | + log.info("Stopped"); | ||
80 | + } | ||
81 | + | ||
82 | + @Override | ||
83 | + public int getDeviceCount() { | ||
84 | + return devices.size(); | ||
85 | + } | ||
86 | + | ||
87 | + @Override | ||
88 | + public Iterable<Device> getDevices() { | ||
89 | + // TODO builder v.s. copyOf. Guava semms to be using copyOf? | ||
90 | + // FIXME: synchronize. | ||
91 | + Builder<Device> builder = ImmutableSet.builder(); | ||
92 | + for (VersionedValue<? extends Device> device : devices.values()) { | ||
93 | + builder.add(device.entity()); | ||
94 | + } | ||
95 | + return builder.build(); | ||
96 | + } | ||
97 | + | ||
98 | + @Override | ||
99 | + public Device getDevice(DeviceId deviceId) { | ||
100 | + return devices.get(deviceId).entity(); | ||
101 | + } | ||
102 | + | ||
103 | + @Override | ||
104 | + public DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId, | ||
105 | + DeviceDescription deviceDescription) { | ||
106 | + Timestamp now = clockService.getTimestamp(deviceId); | ||
107 | + VersionedValue<Device> device = devices.get(deviceId); | ||
108 | + | ||
109 | + if (device == null) { | ||
110 | + return createDevice(providerId, deviceId, deviceDescription, now); | ||
111 | + } | ||
112 | + | ||
113 | + checkState(now.compareTo(device.timestamp()) > 0, | ||
114 | + "Existing device has a timestamp in the future!"); | ||
115 | + | ||
116 | + return updateDevice(providerId, device.entity(), deviceDescription, now); | ||
117 | + } | ||
118 | + | ||
119 | + // Creates the device and returns the appropriate event if necessary. | ||
120 | + private DeviceEvent createDevice(ProviderId providerId, DeviceId deviceId, | ||
121 | + DeviceDescription desc, Timestamp timestamp) { | ||
122 | + DefaultDevice device = new DefaultDevice(providerId, deviceId, desc.type(), | ||
123 | + desc.manufacturer(), | ||
124 | + desc.hwVersion(), desc.swVersion(), | ||
125 | + desc.serialNumber()); | ||
126 | + | ||
127 | + devices.put(deviceId, new VersionedValue<Device>(device, true, timestamp)); | ||
128 | + // FIXME: broadcast a message telling peers of a device event. | ||
129 | + return new DeviceEvent(DEVICE_ADDED, device, null); | ||
130 | + } | ||
131 | + | ||
132 | + // Updates the device and returns the appropriate event if necessary. | ||
133 | + private DeviceEvent updateDevice(ProviderId providerId, Device device, | ||
134 | + DeviceDescription desc, Timestamp timestamp) { | ||
135 | + // We allow only certain attributes to trigger update | ||
136 | + if (!Objects.equals(device.hwVersion(), desc.hwVersion()) || | ||
137 | + !Objects.equals(device.swVersion(), desc.swVersion())) { | ||
138 | + | ||
139 | + Device updated = new DefaultDevice(providerId, device.id(), | ||
140 | + desc.type(), | ||
141 | + desc.manufacturer(), | ||
142 | + desc.hwVersion(), | ||
143 | + desc.swVersion(), | ||
144 | + desc.serialNumber()); | ||
145 | + devices.put(device.id(), new VersionedValue<Device>(updated, true, timestamp)); | ||
146 | + // FIXME: broadcast a message telling peers of a device event. | ||
147 | + return new DeviceEvent(DeviceEvent.Type.DEVICE_UPDATED, updated, null); | ||
148 | + } | ||
149 | + | ||
150 | + // Otherwise merely attempt to change availability | ||
151 | + DefaultDevice updated = new DefaultDevice(providerId, device.id(), | ||
152 | + desc.type(), | ||
153 | + desc.manufacturer(), | ||
154 | + desc.hwVersion(), | ||
155 | + desc.swVersion(), | ||
156 | + desc.serialNumber()); | ||
157 | + | ||
158 | + VersionedValue<Device> oldDevice = devices.put(device.id(), | ||
159 | + new VersionedValue<Device>(updated, true, timestamp)); | ||
160 | + if (!oldDevice.isUp()) { | ||
161 | + return new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device, null); | ||
162 | + } else { | ||
163 | + return null; | ||
164 | + } | ||
165 | + } | ||
166 | + | ||
167 | + @Override | ||
168 | + public DeviceEvent markOffline(DeviceId deviceId) { | ||
169 | + VersionedValue<Device> device = devices.get(deviceId); | ||
170 | + boolean willRemove = device != null && device.isUp(); | ||
171 | + if (!willRemove) { | ||
172 | + return null; | ||
173 | + } | ||
174 | + Timestamp timestamp = clockService.getTimestamp(deviceId); | ||
175 | + if (replaceIfLatest(device.entity(), false, timestamp)) { | ||
176 | + return new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device.entity(), null); | ||
177 | + } | ||
178 | + return null; | ||
179 | + } | ||
180 | + | ||
181 | + // Replace existing value if its timestamp is older. | ||
182 | + private synchronized boolean replaceIfLatest(Device device, boolean isUp, Timestamp timestamp) { | ||
183 | + VersionedValue<Device> existingValue = devices.get(device.id()); | ||
184 | + if (timestamp.compareTo(existingValue.timestamp()) > 0) { | ||
185 | + devices.put(device.id(), new VersionedValue<Device>(device, isUp, timestamp)); | ||
186 | + return true; | ||
187 | + } | ||
188 | + return false; | ||
189 | + } | ||
190 | + | ||
191 | + @Override | ||
192 | + public List<DeviceEvent> updatePorts(DeviceId deviceId, | ||
193 | + List<PortDescription> portDescriptions) { | ||
194 | + List<DeviceEvent> events = new ArrayList<>(); | ||
195 | + synchronized (this) { | ||
196 | + VersionedValue<Device> device = devices.get(deviceId); | ||
197 | + checkArgument(device != null, DEVICE_NOT_FOUND, deviceId); | ||
198 | + Map<PortNumber, VersionedValue<Port>> ports = getPortMap(deviceId); | ||
199 | + Timestamp timestamp = clockService.getTimestamp(deviceId); | ||
200 | + | ||
201 | + // Add new ports | ||
202 | + Set<PortNumber> processed = new HashSet<>(); | ||
203 | + for (PortDescription portDescription : portDescriptions) { | ||
204 | + VersionedValue<Port> port = ports.get(portDescription.portNumber()); | ||
205 | + if (port == null) { | ||
206 | + events.add(createPort(device, portDescription, ports, timestamp)); | ||
207 | + } | ||
208 | + checkState(timestamp.compareTo(port.timestamp()) > 0, | ||
209 | + "Existing port state has a timestamp in the future!"); | ||
210 | + events.add(updatePort(device, port, portDescription, ports, timestamp)); | ||
211 | + processed.add(portDescription.portNumber()); | ||
212 | + } | ||
213 | + | ||
214 | + updatePortMap(deviceId, ports); | ||
215 | + | ||
216 | + events.addAll(pruneOldPorts(device.entity(), ports, processed)); | ||
217 | + } | ||
218 | + return FluentIterable.from(events).filter(notNull()).toList(); | ||
219 | + } | ||
220 | + | ||
221 | + // Creates a new port based on the port description adds it to the map and | ||
222 | + // Returns corresponding event. | ||
223 | + //@GuardedBy("this") | ||
224 | + private DeviceEvent createPort(VersionedValue<Device> device, PortDescription portDescription, | ||
225 | + Map<PortNumber, VersionedValue<Port>> ports, Timestamp timestamp) { | ||
226 | + Port port = new DefaultPort(device.entity(), portDescription.portNumber(), | ||
227 | + portDescription.isEnabled()); | ||
228 | + ports.put(port.number(), new VersionedValue<Port>(port, true, timestamp)); | ||
229 | + updatePortMap(device.entity().id(), ports); | ||
230 | + return new DeviceEvent(PORT_ADDED, device.entity(), port); | ||
231 | + } | ||
232 | + | ||
233 | + // Checks if the specified port requires update and if so, it replaces the | ||
234 | + // existing entry in the map and returns corresponding event. | ||
235 | + //@GuardedBy("this") | ||
236 | + private DeviceEvent updatePort(VersionedValue<Device> device, VersionedValue<Port> port, | ||
237 | + PortDescription portDescription, | ||
238 | + Map<PortNumber, VersionedValue<Port>> ports, | ||
239 | + Timestamp timestamp) { | ||
240 | + if (port.entity().isEnabled() != portDescription.isEnabled()) { | ||
241 | + VersionedValue<Port> updatedPort = new VersionedValue<Port>( | ||
242 | + new DefaultPort(device.entity(), portDescription.portNumber(), | ||
243 | + portDescription.isEnabled()), | ||
244 | + portDescription.isEnabled(), | ||
245 | + timestamp); | ||
246 | + ports.put(port.entity().number(), updatedPort); | ||
247 | + updatePortMap(device.entity().id(), ports); | ||
248 | + return new DeviceEvent(PORT_UPDATED, device.entity(), updatedPort.entity()); | ||
249 | + } | ||
250 | + return null; | ||
251 | + } | ||
252 | + | ||
253 | + // Prunes the specified list of ports based on which ports are in the | ||
254 | + // processed list and returns list of corresponding events. | ||
255 | + //@GuardedBy("this") | ||
256 | + private List<DeviceEvent> pruneOldPorts(Device device, | ||
257 | + Map<PortNumber, VersionedValue<Port>> ports, | ||
258 | + Set<PortNumber> processed) { | ||
259 | + List<DeviceEvent> events = new ArrayList<>(); | ||
260 | + Iterator<PortNumber> iterator = ports.keySet().iterator(); | ||
261 | + while (iterator.hasNext()) { | ||
262 | + PortNumber portNumber = iterator.next(); | ||
263 | + if (!processed.contains(portNumber)) { | ||
264 | + events.add(new DeviceEvent(PORT_REMOVED, device, | ||
265 | + ports.get(portNumber).entity())); | ||
266 | + iterator.remove(); | ||
267 | + } | ||
268 | + } | ||
269 | + if (!events.isEmpty()) { | ||
270 | + updatePortMap(device.id(), ports); | ||
271 | + } | ||
272 | + return events; | ||
273 | + } | ||
274 | + | ||
275 | + // Gets the map of ports for the specified device; if one does not already | ||
276 | + // exist, it creates and registers a new one. | ||
277 | + // WARN: returned value is a copy, changes made to the Map | ||
278 | + // needs to be written back using updatePortMap | ||
279 | + //@GuardedBy("this") | ||
280 | + private Map<PortNumber, VersionedValue<Port>> getPortMap(DeviceId deviceId) { | ||
281 | + Map<PortNumber, VersionedValue<Port>> ports = devicePorts.get(deviceId); | ||
282 | + if (ports == null) { | ||
283 | + ports = new HashMap<>(); | ||
284 | + // this probably is waste of time in most cases. | ||
285 | + updatePortMap(deviceId, ports); | ||
286 | + } | ||
287 | + return ports; | ||
288 | + } | ||
289 | + | ||
290 | + //@GuardedBy("this") | ||
291 | + private void updatePortMap(DeviceId deviceId, Map<PortNumber, VersionedValue<Port>> ports) { | ||
292 | + devicePorts.put(deviceId, ports); | ||
293 | + } | ||
294 | + | ||
295 | + @Override | ||
296 | + public DeviceEvent updatePortStatus(DeviceId deviceId, | ||
297 | + PortDescription portDescription) { | ||
298 | + VersionedValue<Device> device = devices.get(deviceId); | ||
299 | + checkArgument(device != null, DEVICE_NOT_FOUND, deviceId); | ||
300 | + Map<PortNumber, VersionedValue<Port>> ports = getPortMap(deviceId); | ||
301 | + VersionedValue<Port> port = ports.get(portDescription.portNumber()); | ||
302 | + Timestamp timestamp = clockService.getTimestamp(deviceId); | ||
303 | + return updatePort(device, port, portDescription, ports, timestamp); | ||
304 | + } | ||
305 | + | ||
306 | + @Override | ||
307 | + public List<Port> getPorts(DeviceId deviceId) { | ||
308 | + Map<PortNumber, VersionedValue<Port>> versionedPorts = devicePorts.get(deviceId); | ||
309 | + if (versionedPorts == null) { | ||
310 | + return Collections.emptyList(); | ||
311 | + } | ||
312 | + List<Port> ports = new ArrayList<>(); | ||
313 | + for (VersionedValue<Port> port : versionedPorts.values()) { | ||
314 | + ports.add(port.entity()); | ||
315 | + } | ||
316 | + return ports; | ||
317 | + } | ||
318 | + | ||
319 | + @Override | ||
320 | + public Port getPort(DeviceId deviceId, PortNumber portNumber) { | ||
321 | + Map<PortNumber, VersionedValue<Port>> ports = devicePorts.get(deviceId); | ||
322 | + return ports == null ? null : ports.get(portNumber).entity(); | ||
323 | + } | ||
324 | + | ||
325 | + @Override | ||
326 | + public boolean isAvailable(DeviceId deviceId) { | ||
327 | + return devices.get(deviceId).isUp(); | ||
328 | + } | ||
329 | + | ||
330 | + @Override | ||
331 | + public DeviceEvent removeDevice(DeviceId deviceId) { | ||
332 | + VersionedValue<Device> previousDevice = devices.remove(deviceId); | ||
333 | + return previousDevice == null ? null : | ||
334 | + new DeviceEvent(DEVICE_REMOVED, previousDevice.entity(), null); | ||
335 | + } | ||
336 | +} |
1 | +package org.onlab.onos.store.device.impl; | ||
2 | + | ||
3 | +import org.onlab.onos.store.Timestamp; | ||
4 | + | ||
5 | +/** | ||
6 | + * Wrapper class for a entity that is versioned | ||
7 | + * and can either be up or down. | ||
8 | + * | ||
9 | + * @param <T> type of the value. | ||
10 | + */ | ||
11 | +public class VersionedValue<T> { | ||
12 | + private final T entity; | ||
13 | + private final Timestamp timestamp; | ||
14 | + private final boolean isUp; | ||
15 | + | ||
16 | + public VersionedValue(T entity, boolean isUp, Timestamp timestamp) { | ||
17 | + this.entity = entity; | ||
18 | + this.isUp = isUp; | ||
19 | + this.timestamp = timestamp; | ||
20 | + } | ||
21 | + | ||
22 | + /** | ||
23 | + * Returns the value. | ||
24 | + * @return value. | ||
25 | + */ | ||
26 | + public T entity() { | ||
27 | + return entity; | ||
28 | + } | ||
29 | + | ||
30 | + /** | ||
31 | + * Tells whether the entity is up or down. | ||
32 | + * @return true if up, false otherwise. | ||
33 | + */ | ||
34 | + public boolean isUp() { | ||
35 | + return isUp; | ||
36 | + } | ||
37 | + | ||
38 | + /** | ||
39 | + * Returns the timestamp (version) associated with this entity. | ||
40 | + * @return timestamp. | ||
41 | + */ | ||
42 | + public Timestamp timestamp() { | ||
43 | + return timestamp; | ||
44 | + } | ||
45 | +} |
1 | package org.onlab.onos.store.impl; | 1 | package org.onlab.onos.store.impl; |
2 | 2 | ||
3 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
4 | import static com.google.common.base.Preconditions.checkArgument; | 3 | import static com.google.common.base.Preconditions.checkArgument; |
5 | 4 | ||
6 | import java.util.Objects; | 5 | import java.util.Objects; |
7 | 6 | ||
8 | -import org.onlab.onos.net.ElementId; | ||
9 | import org.onlab.onos.store.Timestamp; | 7 | import org.onlab.onos.store.Timestamp; |
10 | 8 | ||
11 | import com.google.common.base.MoreObjects; | 9 | import com.google.common.base.MoreObjects; |
... | @@ -14,22 +12,20 @@ import com.google.common.collect.ComparisonChain; | ... | @@ -14,22 +12,20 @@ import com.google.common.collect.ComparisonChain; |
14 | // If it is store specific, implement serializable interfaces? | 12 | // If it is store specific, implement serializable interfaces? |
15 | /** | 13 | /** |
16 | * Default implementation of Timestamp. | 14 | * Default implementation of Timestamp. |
15 | + * TODO: Better documentation. | ||
17 | */ | 16 | */ |
18 | public final class OnosTimestamp implements Timestamp { | 17 | public final class OnosTimestamp implements Timestamp { |
19 | 18 | ||
20 | - private final ElementId id; | ||
21 | private final int termNumber; | 19 | private final int termNumber; |
22 | private final int sequenceNumber; | 20 | private final int sequenceNumber; |
23 | 21 | ||
24 | /** | 22 | /** |
25 | * Default version tuple. | 23 | * Default version tuple. |
26 | * | 24 | * |
27 | - * @param id identifier of the element | ||
28 | * @param termNumber the mastership termNumber | 25 | * @param termNumber the mastership termNumber |
29 | * @param sequenceNumber the sequenceNumber number within the termNumber | 26 | * @param sequenceNumber the sequenceNumber number within the termNumber |
30 | */ | 27 | */ |
31 | - public OnosTimestamp(ElementId id, int termNumber, int sequenceNumber) { | 28 | + public OnosTimestamp(int termNumber, int sequenceNumber) { |
32 | - this.id = checkNotNull(id); | ||
33 | this.termNumber = termNumber; | 29 | this.termNumber = termNumber; |
34 | this.sequenceNumber = sequenceNumber; | 30 | this.sequenceNumber = sequenceNumber; |
35 | } | 31 | } |
... | @@ -38,9 +34,6 @@ public final class OnosTimestamp implements Timestamp { | ... | @@ -38,9 +34,6 @@ public final class OnosTimestamp implements Timestamp { |
38 | public int compareTo(Timestamp o) { | 34 | public int compareTo(Timestamp o) { |
39 | checkArgument(o instanceof OnosTimestamp, "Must be OnosTimestamp", o); | 35 | checkArgument(o instanceof OnosTimestamp, "Must be OnosTimestamp", o); |
40 | OnosTimestamp that = (OnosTimestamp) o; | 36 | OnosTimestamp that = (OnosTimestamp) o; |
41 | - checkArgument(this.id.equals(that.id), | ||
42 | - "Cannot compare version for different element this:%s, that:%s", | ||
43 | - this, that); | ||
44 | 37 | ||
45 | return ComparisonChain.start() | 38 | return ComparisonChain.start() |
46 | .compare(this.termNumber, that.termNumber) | 39 | .compare(this.termNumber, that.termNumber) |
... | @@ -50,7 +43,7 @@ public final class OnosTimestamp implements Timestamp { | ... | @@ -50,7 +43,7 @@ public final class OnosTimestamp implements Timestamp { |
50 | 43 | ||
51 | @Override | 44 | @Override |
52 | public int hashCode() { | 45 | public int hashCode() { |
53 | - return Objects.hash(id, termNumber, sequenceNumber); | 46 | + return Objects.hash(termNumber, sequenceNumber); |
54 | } | 47 | } |
55 | 48 | ||
56 | @Override | 49 | @Override |
... | @@ -62,30 +55,19 @@ public final class OnosTimestamp implements Timestamp { | ... | @@ -62,30 +55,19 @@ public final class OnosTimestamp implements Timestamp { |
62 | return false; | 55 | return false; |
63 | } | 56 | } |
64 | OnosTimestamp that = (OnosTimestamp) obj; | 57 | OnosTimestamp that = (OnosTimestamp) obj; |
65 | - return Objects.equals(this.id, that.id) && | 58 | + return Objects.equals(this.termNumber, that.termNumber) && |
66 | - Objects.equals(this.termNumber, that.termNumber) && | ||
67 | Objects.equals(this.sequenceNumber, that.sequenceNumber); | 59 | Objects.equals(this.sequenceNumber, that.sequenceNumber); |
68 | } | 60 | } |
69 | 61 | ||
70 | @Override | 62 | @Override |
71 | public String toString() { | 63 | public String toString() { |
72 | return MoreObjects.toStringHelper(getClass()) | 64 | return MoreObjects.toStringHelper(getClass()) |
73 | - .add("id", id) | ||
74 | .add("termNumber", termNumber) | 65 | .add("termNumber", termNumber) |
75 | .add("sequenceNumber", sequenceNumber) | 66 | .add("sequenceNumber", sequenceNumber) |
76 | .toString(); | 67 | .toString(); |
77 | } | 68 | } |
78 | 69 | ||
79 | /** | 70 | /** |
80 | - * Returns the element. | ||
81 | - * | ||
82 | - * @return element identifier | ||
83 | - */ | ||
84 | - public ElementId id() { | ||
85 | - return id; | ||
86 | - } | ||
87 | - | ||
88 | - /** | ||
89 | * Returns the termNumber. | 71 | * Returns the termNumber. |
90 | * | 72 | * |
91 | * @return termNumber | 73 | * @return termNumber | ... | ... |
1 | package org.onlab.onos.store.serializers; | 1 | package org.onlab.onos.store.serializers; |
2 | 2 | ||
3 | -import org.onlab.onos.net.ElementId; | ||
4 | import org.onlab.onos.store.impl.OnosTimestamp; | 3 | import org.onlab.onos.store.impl.OnosTimestamp; |
5 | 4 | ||
6 | import com.esotericsoftware.kryo.Kryo; | 5 | import com.esotericsoftware.kryo.Kryo; |
... | @@ -20,18 +19,17 @@ public class OnosTimestampSerializer extends Serializer<OnosTimestamp> { | ... | @@ -20,18 +19,17 @@ public class OnosTimestampSerializer extends Serializer<OnosTimestamp> { |
20 | // non-null, immutable | 19 | // non-null, immutable |
21 | super(false, true); | 20 | super(false, true); |
22 | } | 21 | } |
22 | + | ||
23 | @Override | 23 | @Override |
24 | public void write(Kryo kryo, Output output, OnosTimestamp object) { | 24 | public void write(Kryo kryo, Output output, OnosTimestamp object) { |
25 | - kryo.writeClassAndObject(output, object.id()); | ||
26 | output.writeInt(object.termNumber()); | 25 | output.writeInt(object.termNumber()); |
27 | output.writeInt(object.sequenceNumber()); | 26 | output.writeInt(object.sequenceNumber()); |
28 | } | 27 | } |
29 | 28 | ||
30 | @Override | 29 | @Override |
31 | public OnosTimestamp read(Kryo kryo, Input input, Class<OnosTimestamp> type) { | 30 | public OnosTimestamp read(Kryo kryo, Input input, Class<OnosTimestamp> type) { |
32 | - ElementId id = (ElementId) kryo.readClassAndObject(input); | ||
33 | final int term = input.readInt(); | 31 | final int term = input.readInt(); |
34 | final int sequence = input.readInt(); | 32 | final int sequence = input.readInt(); |
35 | - return new OnosTimestamp(id, term, sequence); | 33 | + return new OnosTimestamp(term, sequence); |
36 | } | 34 | } |
37 | } | 35 | } | ... | ... |
core/store/hz/cluster/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
5 | + <modelVersion>4.0.0</modelVersion> | ||
6 | + | ||
7 | + <parent> | ||
8 | + <groupId>org.onlab.onos</groupId> | ||
9 | + <artifactId>onos-core-hz</artifactId> | ||
10 | + <version>1.0.0-SNAPSHOT</version> | ||
11 | + <relativePath>../pom.xml</relativePath> | ||
12 | + </parent> | ||
13 | + | ||
14 | + <artifactId>onos-core-hz-cluster</artifactId> | ||
15 | + <packaging>bundle</packaging> | ||
16 | + | ||
17 | + <description>ONOS Hazelcast based distributed store subsystems</description> | ||
18 | + | ||
19 | + <dependencies> | ||
20 | + <dependency> | ||
21 | + <groupId>org.onlab.onos</groupId> | ||
22 | + <artifactId>onos-api</artifactId> | ||
23 | + </dependency> | ||
24 | + <dependency> | ||
25 | + <groupId>org.onlab.onos</groupId> | ||
26 | + <artifactId>onos-core-serializers</artifactId> | ||
27 | + <version>${project.version}</version> | ||
28 | + </dependency> | ||
29 | + <dependency> | ||
30 | + <groupId>org.onlab.onos</groupId> | ||
31 | + <artifactId>onos-core-hz-common</artifactId> | ||
32 | + <version>${project.version}</version> | ||
33 | + </dependency> | ||
34 | + <dependency> | ||
35 | + <groupId>org.onlab.onos</groupId> | ||
36 | + <artifactId>onos-core-hz-common</artifactId> | ||
37 | + <classifier>tests</classifier> | ||
38 | + <scope>test</scope> | ||
39 | + <version>${project.version}</version> | ||
40 | + </dependency> | ||
41 | + <dependency> | ||
42 | + <groupId>org.apache.felix</groupId> | ||
43 | + <artifactId>org.apache.felix.scr.annotations</artifactId> | ||
44 | + </dependency> | ||
45 | + <dependency> | ||
46 | + <groupId>com.hazelcast</groupId> | ||
47 | + <artifactId>hazelcast</artifactId> | ||
48 | + </dependency> | ||
49 | + <dependency> | ||
50 | + <groupId>de.javakaffee</groupId> | ||
51 | + <artifactId>kryo-serializers</artifactId> | ||
52 | + </dependency> | ||
53 | + </dependencies> | ||
54 | + | ||
55 | + <build> | ||
56 | + <plugins> | ||
57 | + <plugin> | ||
58 | + <groupId>org.apache.felix</groupId> | ||
59 | + <artifactId>maven-scr-plugin</artifactId> | ||
60 | + </plugin> | ||
61 | + </plugins> | ||
62 | + </build> | ||
63 | + | ||
64 | +</project> |
... | @@ -8,6 +8,7 @@ import com.hazelcast.core.Member; | ... | @@ -8,6 +8,7 @@ import com.hazelcast.core.Member; |
8 | import com.hazelcast.core.MemberAttributeEvent; | 8 | import com.hazelcast.core.MemberAttributeEvent; |
9 | import com.hazelcast.core.MembershipEvent; | 9 | import com.hazelcast.core.MembershipEvent; |
10 | import com.hazelcast.core.MembershipListener; | 10 | import com.hazelcast.core.MembershipListener; |
11 | + | ||
11 | import org.apache.felix.scr.annotations.Activate; | 12 | import org.apache.felix.scr.annotations.Activate; |
12 | import org.apache.felix.scr.annotations.Component; | 13 | import org.apache.felix.scr.annotations.Component; |
13 | import org.apache.felix.scr.annotations.Deactivate; | 14 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -18,9 +19,9 @@ import org.onlab.onos.cluster.ClusterStoreDelegate; | ... | @@ -18,9 +19,9 @@ import org.onlab.onos.cluster.ClusterStoreDelegate; |
18 | import org.onlab.onos.cluster.ControllerNode; | 19 | import org.onlab.onos.cluster.ControllerNode; |
19 | import org.onlab.onos.cluster.DefaultControllerNode; | 20 | import org.onlab.onos.cluster.DefaultControllerNode; |
20 | import org.onlab.onos.cluster.NodeId; | 21 | import org.onlab.onos.cluster.NodeId; |
21 | -import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache; | 22 | +import org.onlab.onos.store.common.AbsentInvalidatingLoadingCache; |
22 | -import org.onlab.onos.store.impl.AbstractDistributedStore; | 23 | +import org.onlab.onos.store.common.AbstractHazelcastStore; |
23 | -import org.onlab.onos.store.impl.OptionalCacheLoader; | 24 | +import org.onlab.onos.store.common.OptionalCacheLoader; |
24 | import org.onlab.packet.IpPrefix; | 25 | import org.onlab.packet.IpPrefix; |
25 | 26 | ||
26 | import java.util.Map; | 27 | import java.util.Map; |
... | @@ -38,7 +39,7 @@ import static org.onlab.onos.cluster.ControllerNode.State; | ... | @@ -38,7 +39,7 @@ import static org.onlab.onos.cluster.ControllerNode.State; |
38 | @Component(immediate = true) | 39 | @Component(immediate = true) |
39 | @Service | 40 | @Service |
40 | public class DistributedClusterStore | 41 | public class DistributedClusterStore |
41 | - extends AbstractDistributedStore<ClusterEvent, ClusterStoreDelegate> | 42 | + extends AbstractHazelcastStore<ClusterEvent, ClusterStoreDelegate> |
42 | implements ClusterStore { | 43 | implements ClusterStore { |
43 | 44 | ||
44 | private IMap<byte[], byte[]> rawNodes; | 45 | private IMap<byte[], byte[]> rawNodes; | ... | ... |
... | @@ -21,9 +21,9 @@ import org.onlab.onos.cluster.MastershipTerm; | ... | @@ -21,9 +21,9 @@ import org.onlab.onos.cluster.MastershipTerm; |
21 | import org.onlab.onos.cluster.NodeId; | 21 | import org.onlab.onos.cluster.NodeId; |
22 | import org.onlab.onos.net.DeviceId; | 22 | import org.onlab.onos.net.DeviceId; |
23 | import org.onlab.onos.net.MastershipRole; | 23 | import org.onlab.onos.net.MastershipRole; |
24 | -import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache; | 24 | +import org.onlab.onos.store.common.AbsentInvalidatingLoadingCache; |
25 | -import org.onlab.onos.store.impl.AbstractDistributedStore; | 25 | +import org.onlab.onos.store.common.AbstractHazelcastStore; |
26 | -import org.onlab.onos.store.impl.OptionalCacheLoader; | 26 | +import org.onlab.onos.store.common.OptionalCacheLoader; |
27 | 27 | ||
28 | import com.google.common.base.Optional; | 28 | import com.google.common.base.Optional; |
29 | import com.google.common.cache.LoadingCache; | 29 | import com.google.common.cache.LoadingCache; |
... | @@ -36,7 +36,7 @@ import com.hazelcast.core.IMap; | ... | @@ -36,7 +36,7 @@ import com.hazelcast.core.IMap; |
36 | @Component(immediate = true) | 36 | @Component(immediate = true) |
37 | @Service | 37 | @Service |
38 | public class DistributedMastershipStore | 38 | public class DistributedMastershipStore |
39 | -extends AbstractDistributedStore<MastershipEvent, MastershipStoreDelegate> | 39 | +extends AbstractHazelcastStore<MastershipEvent, MastershipStoreDelegate> |
40 | implements MastershipStore { | 40 | implements MastershipStore { |
41 | 41 | ||
42 | private IMap<byte[], byte[]> rawMasters; | 42 | private IMap<byte[], byte[]> rawMasters; | ... | ... |
core/store/hz/common/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
5 | + <modelVersion>4.0.0</modelVersion> | ||
6 | + | ||
7 | + <parent> | ||
8 | + <groupId>org.onlab.onos</groupId> | ||
9 | + <artifactId>onos-core-hz</artifactId> | ||
10 | + <version>1.0.0-SNAPSHOT</version> | ||
11 | + <relativePath>../pom.xml</relativePath> | ||
12 | + </parent> | ||
13 | + | ||
14 | + <artifactId>onos-core-hz-common</artifactId> | ||
15 | + <packaging>bundle</packaging> | ||
16 | + | ||
17 | + <description>ONOS Hazelcast based distributed store subsystems</description> | ||
18 | + | ||
19 | + <dependencies> | ||
20 | + <dependency> | ||
21 | + <groupId>org.onlab.onos</groupId> | ||
22 | + <artifactId>onos-api</artifactId> | ||
23 | + </dependency> | ||
24 | + <dependency> | ||
25 | + <groupId>org.onlab.onos</groupId> | ||
26 | + <artifactId>onos-core-serializers</artifactId> | ||
27 | + <version>${project.version}</version> | ||
28 | + </dependency> | ||
29 | + <dependency> | ||
30 | + <groupId>org.apache.felix</groupId> | ||
31 | + <artifactId>org.apache.felix.scr.annotations</artifactId> | ||
32 | + </dependency> | ||
33 | + <dependency> | ||
34 | + <groupId>com.hazelcast</groupId> | ||
35 | + <artifactId>hazelcast</artifactId> | ||
36 | + </dependency> | ||
37 | + <dependency> | ||
38 | + <groupId>de.javakaffee</groupId> | ||
39 | + <artifactId>kryo-serializers</artifactId> | ||
40 | + </dependency> | ||
41 | + </dependencies> | ||
42 | + | ||
43 | + <build> | ||
44 | + <plugins> | ||
45 | + <plugin> | ||
46 | + <groupId>org.apache.felix</groupId> | ||
47 | + <artifactId>maven-scr-plugin</artifactId> | ||
48 | + </plugin> | ||
49 | + </plugins> | ||
50 | + </build> | ||
51 | + | ||
52 | +</project> |
1 | -package org.onlab.onos.store.impl; | 1 | +package org.onlab.onos.store.common; |
2 | 2 | ||
3 | import com.google.common.base.Optional; | 3 | import com.google.common.base.Optional; |
4 | import com.google.common.cache.LoadingCache; | 4 | import com.google.common.cache.LoadingCache; |
... | @@ -6,6 +6,7 @@ import com.hazelcast.core.EntryAdapter; | ... | @@ -6,6 +6,7 @@ import com.hazelcast.core.EntryAdapter; |
6 | import com.hazelcast.core.EntryEvent; | 6 | import com.hazelcast.core.EntryEvent; |
7 | import com.hazelcast.core.HazelcastInstance; | 7 | import com.hazelcast.core.HazelcastInstance; |
8 | import com.hazelcast.core.MapEvent; | 8 | import com.hazelcast.core.MapEvent; |
9 | + | ||
9 | import org.apache.felix.scr.annotations.Activate; | 10 | import org.apache.felix.scr.annotations.Activate; |
10 | import org.apache.felix.scr.annotations.Component; | 11 | import org.apache.felix.scr.annotations.Component; |
11 | import org.apache.felix.scr.annotations.Reference; | 12 | import org.apache.felix.scr.annotations.Reference; |
... | @@ -13,7 +14,6 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; | ... | @@ -13,7 +14,6 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; |
13 | import org.onlab.onos.event.Event; | 14 | import org.onlab.onos.event.Event; |
14 | import org.onlab.onos.store.AbstractStore; | 15 | import org.onlab.onos.store.AbstractStore; |
15 | import org.onlab.onos.store.StoreDelegate; | 16 | import org.onlab.onos.store.StoreDelegate; |
16 | -import org.onlab.onos.store.common.StoreService; | ||
17 | import org.slf4j.Logger; | 17 | import org.slf4j.Logger; |
18 | 18 | ||
19 | import static com.google.common.base.Preconditions.checkNotNull; | 19 | import static com.google.common.base.Preconditions.checkNotNull; |
... | @@ -23,7 +23,7 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -23,7 +23,7 @@ import static org.slf4j.LoggerFactory.getLogger; |
23 | * Abstraction of a distributed store based on Hazelcast. | 23 | * Abstraction of a distributed store based on Hazelcast. |
24 | */ | 24 | */ |
25 | @Component(componentAbstract = true) | 25 | @Component(componentAbstract = true) |
26 | -public abstract class AbstractDistributedStore<E extends Event, D extends StoreDelegate<E>> | 26 | +public abstract class AbstractHazelcastStore<E extends Event, D extends StoreDelegate<E>> |
27 | extends AbstractStore<E, D> { | 27 | extends AbstractStore<E, D> { |
28 | 28 | ||
29 | protected final Logger log = getLogger(getClass()); | 29 | protected final Logger log = getLogger(getClass()); | ... | ... |
1 | -package org.onlab.onos.store.impl; | 1 | +package org.onlab.onos.store.common; |
2 | 2 | ||
3 | import static com.google.common.base.Preconditions.checkNotNull; | 3 | import static com.google.common.base.Preconditions.checkNotNull; |
4 | 4 | ||
5 | -import org.onlab.onos.store.common.StoreService; | ||
6 | - | ||
7 | import com.google.common.base.Optional; | 5 | import com.google.common.base.Optional; |
8 | import com.google.common.cache.CacheLoader; | 6 | import com.google.common.cache.CacheLoader; |
9 | import com.hazelcast.core.IMap; | 7 | import com.hazelcast.core.IMap; | ... | ... |
1 | -package org.onlab.onos.store.impl; | 1 | +package org.onlab.onos.store.common; |
2 | 2 | ||
3 | import com.hazelcast.config.Config; | 3 | import com.hazelcast.config.Config; |
4 | import com.hazelcast.config.FileSystemXmlConfig; | 4 | import com.hazelcast.config.FileSystemXmlConfig; |
... | @@ -27,7 +27,6 @@ import org.onlab.onos.net.MastershipRole; | ... | @@ -27,7 +27,6 @@ import org.onlab.onos.net.MastershipRole; |
27 | import org.onlab.onos.net.Port; | 27 | import org.onlab.onos.net.Port; |
28 | import org.onlab.onos.net.PortNumber; | 28 | import org.onlab.onos.net.PortNumber; |
29 | import org.onlab.onos.net.provider.ProviderId; | 29 | import org.onlab.onos.net.provider.ProviderId; |
30 | -import org.onlab.onos.store.common.StoreService; | ||
31 | import org.onlab.onos.store.serializers.ConnectPointSerializer; | 30 | import org.onlab.onos.store.serializers.ConnectPointSerializer; |
32 | import org.onlab.onos.store.serializers.DefaultLinkSerializer; | 31 | import org.onlab.onos.store.serializers.DefaultLinkSerializer; |
33 | import org.onlab.onos.store.serializers.DefaultPortSerializer; | 32 | import org.onlab.onos.store.serializers.DefaultPortSerializer; |
... | @@ -35,7 +34,6 @@ import org.onlab.onos.store.serializers.DeviceIdSerializer; | ... | @@ -35,7 +34,6 @@ import org.onlab.onos.store.serializers.DeviceIdSerializer; |
35 | import org.onlab.onos.store.serializers.IpPrefixSerializer; | 34 | import org.onlab.onos.store.serializers.IpPrefixSerializer; |
36 | import org.onlab.onos.store.serializers.LinkKeySerializer; | 35 | import org.onlab.onos.store.serializers.LinkKeySerializer; |
37 | import org.onlab.onos.store.serializers.NodeIdSerializer; | 36 | import org.onlab.onos.store.serializers.NodeIdSerializer; |
38 | -import org.onlab.onos.store.serializers.OnosTimestampSerializer; | ||
39 | import org.onlab.onos.store.serializers.PortNumberSerializer; | 37 | import org.onlab.onos.store.serializers.PortNumberSerializer; |
40 | import org.onlab.onos.store.serializers.ProviderIdSerializer; | 38 | import org.onlab.onos.store.serializers.ProviderIdSerializer; |
41 | import org.onlab.packet.IpPrefix; | 39 | import org.onlab.packet.IpPrefix; |
... | @@ -102,7 +100,6 @@ public class StoreManager implements StoreService { | ... | @@ -102,7 +100,6 @@ public class StoreManager implements StoreService { |
102 | .register(DeviceId.class, new DeviceIdSerializer()) | 100 | .register(DeviceId.class, new DeviceIdSerializer()) |
103 | .register(PortNumber.class, new PortNumberSerializer()) | 101 | .register(PortNumber.class, new PortNumberSerializer()) |
104 | .register(DefaultPort.class, new DefaultPortSerializer()) | 102 | .register(DefaultPort.class, new DefaultPortSerializer()) |
105 | - .register(OnosTimestamp.class, new OnosTimestampSerializer()) | ||
106 | .register(LinkKey.class, new LinkKeySerializer()) | 103 | .register(LinkKey.class, new LinkKeySerializer()) |
107 | .register(ConnectPoint.class, new ConnectPointSerializer()) | 104 | .register(ConnectPoint.class, new ConnectPointSerializer()) |
108 | .register(DefaultLink.class, new DefaultLinkSerializer()) | 105 | .register(DefaultLink.class, new DefaultLinkSerializer()) | ... | ... |
core/store/hz/net/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
5 | + <modelVersion>4.0.0</modelVersion> | ||
6 | + | ||
7 | + <parent> | ||
8 | + <groupId>org.onlab.onos</groupId> | ||
9 | + <artifactId>onos-core-hz</artifactId> | ||
10 | + <version>1.0.0-SNAPSHOT</version> | ||
11 | + <relativePath>../pom.xml</relativePath> | ||
12 | + </parent> | ||
13 | + | ||
14 | + <artifactId>onos-core-hz-net</artifactId> | ||
15 | + <packaging>bundle</packaging> | ||
16 | + | ||
17 | + <description>ONOS Hazelcast based distributed store subsystems</description> | ||
18 | + | ||
19 | + <dependencies> | ||
20 | + <dependency> | ||
21 | + <groupId>org.onlab.onos</groupId> | ||
22 | + <artifactId>onos-api</artifactId> | ||
23 | + </dependency> | ||
24 | + <dependency> | ||
25 | + <groupId>org.onlab.onos</groupId> | ||
26 | + <artifactId>onos-core-serializers</artifactId> | ||
27 | + <version>${project.version}</version> | ||
28 | + </dependency> | ||
29 | + <dependency> | ||
30 | + <groupId>org.onlab.onos</groupId> | ||
31 | + <artifactId>onos-core-hz-common</artifactId> | ||
32 | + <version>${project.version}</version> | ||
33 | + </dependency> | ||
34 | + <dependency> | ||
35 | + <groupId>org.onlab.onos</groupId> | ||
36 | + <artifactId>onos-core-hz-common</artifactId> | ||
37 | + <classifier>tests</classifier> | ||
38 | + <scope>test</scope> | ||
39 | + <version>${project.version}</version> | ||
40 | + </dependency> | ||
41 | + <dependency> | ||
42 | + <groupId>org.apache.felix</groupId> | ||
43 | + <artifactId>org.apache.felix.scr.annotations</artifactId> | ||
44 | + </dependency> | ||
45 | + <dependency> | ||
46 | + <groupId>com.hazelcast</groupId> | ||
47 | + <artifactId>hazelcast</artifactId> | ||
48 | + </dependency> | ||
49 | + <dependency> | ||
50 | + <groupId>de.javakaffee</groupId> | ||
51 | + <artifactId>kryo-serializers</artifactId> | ||
52 | + </dependency> | ||
53 | + </dependencies> | ||
54 | + | ||
55 | + <build> | ||
56 | + <plugins> | ||
57 | + <plugin> | ||
58 | + <groupId>org.apache.felix</groupId> | ||
59 | + <artifactId>maven-scr-plugin</artifactId> | ||
60 | + </plugin> | ||
61 | + </plugins> | ||
62 | + </build> | ||
63 | + | ||
64 | +</project> |
1 | package org.onlab.onos.store.device.impl; | 1 | package org.onlab.onos.store.device.impl; |
2 | 2 | ||
3 | import static com.google.common.base.Predicates.notNull; | 3 | import static com.google.common.base.Predicates.notNull; |
4 | + | ||
4 | import com.google.common.base.Optional; | 5 | import com.google.common.base.Optional; |
5 | import com.google.common.cache.LoadingCache; | 6 | import com.google.common.cache.LoadingCache; |
6 | import com.google.common.collect.FluentIterable; | 7 | import com.google.common.collect.FluentIterable; |
... | @@ -26,9 +27,9 @@ import org.onlab.onos.net.device.DeviceStore; | ... | @@ -26,9 +27,9 @@ import org.onlab.onos.net.device.DeviceStore; |
26 | import org.onlab.onos.net.device.DeviceStoreDelegate; | 27 | import org.onlab.onos.net.device.DeviceStoreDelegate; |
27 | import org.onlab.onos.net.device.PortDescription; | 28 | import org.onlab.onos.net.device.PortDescription; |
28 | import org.onlab.onos.net.provider.ProviderId; | 29 | import org.onlab.onos.net.provider.ProviderId; |
29 | -import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache; | 30 | +import org.onlab.onos.store.common.AbsentInvalidatingLoadingCache; |
30 | -import org.onlab.onos.store.impl.AbstractDistributedStore; | 31 | +import org.onlab.onos.store.common.AbstractHazelcastStore; |
31 | -import org.onlab.onos.store.impl.OptionalCacheLoader; | 32 | +import org.onlab.onos.store.common.OptionalCacheLoader; |
32 | import org.slf4j.Logger; | 33 | import org.slf4j.Logger; |
33 | 34 | ||
34 | import java.util.ArrayList; | 35 | import java.util.ArrayList; |
... | @@ -52,7 +53,7 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -52,7 +53,7 @@ import static org.slf4j.LoggerFactory.getLogger; |
52 | @Component(immediate = true) | 53 | @Component(immediate = true) |
53 | @Service | 54 | @Service |
54 | public class DistributedDeviceStore | 55 | public class DistributedDeviceStore |
55 | - extends AbstractDistributedStore<DeviceEvent, DeviceStoreDelegate> | 56 | + extends AbstractHazelcastStore<DeviceEvent, DeviceStoreDelegate> |
56 | implements DeviceStore { | 57 | implements DeviceStore { |
57 | 58 | ||
58 | private final Logger log = getLogger(getClass()); | 59 | private final Logger log = getLogger(getClass()); | ... | ... |
1 | +package org.onlab.onos.store.device.impl; | ||
2 | + | ||
3 | +import org.apache.felix.scr.annotations.Component; | ||
4 | +import org.apache.felix.scr.annotations.Service; | ||
5 | +import org.onlab.onos.cluster.MastershipTerm; | ||
6 | +import org.onlab.onos.net.DeviceId; | ||
7 | +import org.onlab.onos.store.ClockService; | ||
8 | +import org.onlab.onos.store.Timestamp; | ||
9 | + | ||
10 | +// FIXME: Code clone in onos-core-trivial, onos-core-hz-net | ||
11 | +/** | ||
12 | + * Dummy implementation of {@link ClockService}. | ||
13 | + */ | ||
14 | +@Component(immediate = true) | ||
15 | +@Service | ||
16 | +public class NoOpClockService implements ClockService { | ||
17 | + | ||
18 | + @Override | ||
19 | + public Timestamp getTimestamp(DeviceId deviceId) { | ||
20 | + return new Timestamp() { | ||
21 | + | ||
22 | + @Override | ||
23 | + public int compareTo(Timestamp o) { | ||
24 | + throw new IllegalStateException("Never expected to be used."); | ||
25 | + } | ||
26 | + }; | ||
27 | + } | ||
28 | + | ||
29 | + @Override | ||
30 | + public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) { | ||
31 | + } | ||
32 | +} |
core/store/hz/net/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
0 → 100644
1 | +package org.onlab.onos.store.flow.impl; | ||
2 | + | ||
3 | +import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_ADDED; | ||
4 | +import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_REMOVED; | ||
5 | +import static org.slf4j.LoggerFactory.getLogger; | ||
6 | + | ||
7 | +import java.util.Collection; | ||
8 | +import java.util.Collections; | ||
9 | + | ||
10 | +import org.apache.felix.scr.annotations.Activate; | ||
11 | +import org.apache.felix.scr.annotations.Component; | ||
12 | +import org.apache.felix.scr.annotations.Deactivate; | ||
13 | +import org.apache.felix.scr.annotations.Service; | ||
14 | +import org.onlab.onos.ApplicationId; | ||
15 | +import org.onlab.onos.net.DeviceId; | ||
16 | +import org.onlab.onos.net.flow.DefaultFlowRule; | ||
17 | +import org.onlab.onos.net.flow.FlowRule; | ||
18 | +import org.onlab.onos.net.flow.FlowRule.FlowRuleState; | ||
19 | +import org.onlab.onos.net.flow.FlowRuleEvent; | ||
20 | +import org.onlab.onos.net.flow.FlowRuleEvent.Type; | ||
21 | +import org.onlab.onos.net.flow.FlowRuleStore; | ||
22 | +import org.onlab.onos.net.flow.FlowRuleStoreDelegate; | ||
23 | +import org.onlab.onos.store.AbstractStore; | ||
24 | +import org.slf4j.Logger; | ||
25 | + | ||
26 | +import com.google.common.collect.ArrayListMultimap; | ||
27 | +import com.google.common.collect.ImmutableSet; | ||
28 | +import com.google.common.collect.Multimap; | ||
29 | + | ||
30 | +/** | ||
31 | + * Manages inventory of flow rules using trivial in-memory implementation. | ||
32 | + */ | ||
33 | +//FIXME: I LIE I AM NOT DISTRIBUTED | ||
34 | +@Component(immediate = true) | ||
35 | +@Service | ||
36 | +public class DistributedFlowRuleStore | ||
37 | +extends AbstractStore<FlowRuleEvent, FlowRuleStoreDelegate> | ||
38 | +implements FlowRuleStore { | ||
39 | + | ||
40 | + private final Logger log = getLogger(getClass()); | ||
41 | + | ||
42 | + // store entries as a pile of rules, no info about device tables | ||
43 | + private final Multimap<DeviceId, FlowRule> flowEntries = | ||
44 | + ArrayListMultimap.<DeviceId, FlowRule>create(); | ||
45 | + | ||
46 | + private final Multimap<ApplicationId, FlowRule> flowEntriesById = | ||
47 | + ArrayListMultimap.<ApplicationId, FlowRule>create(); | ||
48 | + | ||
49 | + @Activate | ||
50 | + public void activate() { | ||
51 | + log.info("Started"); | ||
52 | + } | ||
53 | + | ||
54 | + @Deactivate | ||
55 | + public void deactivate() { | ||
56 | + log.info("Stopped"); | ||
57 | + } | ||
58 | + | ||
59 | + | ||
60 | + @Override | ||
61 | + public synchronized FlowRule getFlowRule(FlowRule rule) { | ||
62 | + for (FlowRule f : flowEntries.get(rule.deviceId())) { | ||
63 | + if (f.equals(rule)) { | ||
64 | + return f; | ||
65 | + } | ||
66 | + } | ||
67 | + return null; | ||
68 | + } | ||
69 | + | ||
70 | + @Override | ||
71 | + public synchronized Iterable<FlowRule> getFlowEntries(DeviceId deviceId) { | ||
72 | + Collection<FlowRule> rules = flowEntries.get(deviceId); | ||
73 | + if (rules == null) { | ||
74 | + return Collections.emptyList(); | ||
75 | + } | ||
76 | + return ImmutableSet.copyOf(rules); | ||
77 | + } | ||
78 | + | ||
79 | + @Override | ||
80 | + public synchronized Iterable<FlowRule> getFlowEntriesByAppId(ApplicationId appId) { | ||
81 | + Collection<FlowRule> rules = flowEntriesById.get(appId); | ||
82 | + if (rules == null) { | ||
83 | + return Collections.emptyList(); | ||
84 | + } | ||
85 | + return ImmutableSet.copyOf(rules); | ||
86 | + } | ||
87 | + | ||
88 | + @Override | ||
89 | + public synchronized void storeFlowRule(FlowRule rule) { | ||
90 | + FlowRule f = new DefaultFlowRule(rule, FlowRuleState.PENDING_ADD); | ||
91 | + DeviceId did = f.deviceId(); | ||
92 | + if (!flowEntries.containsEntry(did, f)) { | ||
93 | + flowEntries.put(did, f); | ||
94 | + flowEntriesById.put(rule.appId(), f); | ||
95 | + } | ||
96 | + } | ||
97 | + | ||
98 | + @Override | ||
99 | + public synchronized void deleteFlowRule(FlowRule rule) { | ||
100 | + FlowRule f = new DefaultFlowRule(rule, FlowRuleState.PENDING_REMOVE); | ||
101 | + DeviceId did = f.deviceId(); | ||
102 | + | ||
103 | + /* | ||
104 | + * find the rule and mark it for deletion. | ||
105 | + * Ultimately a flow removed will come remove it. | ||
106 | + */ | ||
107 | + | ||
108 | + if (flowEntries.containsEntry(did, f)) { | ||
109 | + //synchronized (flowEntries) { | ||
110 | + flowEntries.remove(did, f); | ||
111 | + flowEntries.put(did, f); | ||
112 | + flowEntriesById.remove(rule.appId(), rule); | ||
113 | + //} | ||
114 | + } | ||
115 | + } | ||
116 | + | ||
117 | + @Override | ||
118 | + public synchronized FlowRuleEvent addOrUpdateFlowRule(FlowRule rule) { | ||
119 | + DeviceId did = rule.deviceId(); | ||
120 | + | ||
121 | + // check if this new rule is an update to an existing entry | ||
122 | + if (flowEntries.containsEntry(did, rule)) { | ||
123 | + //synchronized (flowEntries) { | ||
124 | + // Multimaps support duplicates so we have to remove our rule | ||
125 | + // and replace it with the current version. | ||
126 | + flowEntries.remove(did, rule); | ||
127 | + flowEntries.put(did, rule); | ||
128 | + //} | ||
129 | + return new FlowRuleEvent(Type.RULE_UPDATED, rule); | ||
130 | + } | ||
131 | + | ||
132 | + flowEntries.put(did, rule); | ||
133 | + return new FlowRuleEvent(RULE_ADDED, rule); | ||
134 | + } | ||
135 | + | ||
136 | + @Override | ||
137 | + public synchronized FlowRuleEvent removeFlowRule(FlowRule rule) { | ||
138 | + //synchronized (this) { | ||
139 | + if (flowEntries.remove(rule.deviceId(), rule)) { | ||
140 | + return new FlowRuleEvent(RULE_REMOVED, rule); | ||
141 | + } else { | ||
142 | + return null; | ||
143 | + } | ||
144 | + //} | ||
145 | + } | ||
146 | + | ||
147 | + | ||
148 | + | ||
149 | + | ||
150 | + | ||
151 | + | ||
152 | + | ||
153 | +} |
1 | +package org.onlab.onos.store.host.impl; | ||
2 | + | ||
3 | +import static org.onlab.onos.net.host.HostEvent.Type.HOST_ADDED; | ||
4 | +import static org.onlab.onos.net.host.HostEvent.Type.HOST_MOVED; | ||
5 | +import static org.onlab.onos.net.host.HostEvent.Type.HOST_REMOVED; | ||
6 | +import static org.onlab.onos.net.host.HostEvent.Type.HOST_UPDATED; | ||
7 | +import static org.slf4j.LoggerFactory.getLogger; | ||
8 | + | ||
9 | +import java.util.Collections; | ||
10 | +import java.util.HashSet; | ||
11 | +import java.util.Map; | ||
12 | +import java.util.Set; | ||
13 | +import java.util.concurrent.ConcurrentHashMap; | ||
14 | + | ||
15 | +import org.apache.felix.scr.annotations.Activate; | ||
16 | +import org.apache.felix.scr.annotations.Component; | ||
17 | +import org.apache.felix.scr.annotations.Deactivate; | ||
18 | +import org.apache.felix.scr.annotations.Service; | ||
19 | +import org.onlab.onos.net.ConnectPoint; | ||
20 | +import org.onlab.onos.net.DefaultHost; | ||
21 | +import org.onlab.onos.net.DeviceId; | ||
22 | +import org.onlab.onos.net.Host; | ||
23 | +import org.onlab.onos.net.HostId; | ||
24 | +import org.onlab.onos.net.host.HostDescription; | ||
25 | +import org.onlab.onos.net.host.HostEvent; | ||
26 | +import org.onlab.onos.net.host.HostStore; | ||
27 | +import org.onlab.onos.net.host.HostStoreDelegate; | ||
28 | +import org.onlab.onos.net.host.PortAddresses; | ||
29 | +import org.onlab.onos.net.provider.ProviderId; | ||
30 | +import org.onlab.onos.store.AbstractStore; | ||
31 | +import org.onlab.packet.IpPrefix; | ||
32 | +import org.onlab.packet.MacAddress; | ||
33 | +import org.onlab.packet.VlanId; | ||
34 | +import org.slf4j.Logger; | ||
35 | + | ||
36 | +import com.google.common.collect.HashMultimap; | ||
37 | +import com.google.common.collect.ImmutableSet; | ||
38 | +import com.google.common.collect.Multimap; | ||
39 | +import com.google.common.collect.Sets; | ||
40 | + | ||
41 | +/** | ||
42 | + * Manages inventory of end-station hosts using trivial in-memory | ||
43 | + * implementation. | ||
44 | + */ | ||
45 | +//FIXME: I LIE I AM NOT DISTRIBUTED | ||
46 | +@Component(immediate = true) | ||
47 | +@Service | ||
48 | +public class DistributedHostStore | ||
49 | +extends AbstractStore<HostEvent, HostStoreDelegate> | ||
50 | +implements HostStore { | ||
51 | + | ||
52 | + private final Logger log = getLogger(getClass()); | ||
53 | + | ||
54 | + // Host inventory | ||
55 | + private final Map<HostId, Host> hosts = new ConcurrentHashMap<>(); | ||
56 | + | ||
57 | + // Hosts tracked by their location | ||
58 | + private final Multimap<ConnectPoint, Host> locations = HashMultimap.create(); | ||
59 | + | ||
60 | + private final Map<ConnectPoint, PortAddresses> portAddresses = | ||
61 | + new ConcurrentHashMap<>(); | ||
62 | + | ||
63 | + @Activate | ||
64 | + public void activate() { | ||
65 | + log.info("Started"); | ||
66 | + } | ||
67 | + | ||
68 | + @Deactivate | ||
69 | + public void deactivate() { | ||
70 | + log.info("Stopped"); | ||
71 | + } | ||
72 | + | ||
73 | + @Override | ||
74 | + public HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId, | ||
75 | + HostDescription hostDescription) { | ||
76 | + Host host = hosts.get(hostId); | ||
77 | + if (host == null) { | ||
78 | + return createHost(providerId, hostId, hostDescription); | ||
79 | + } | ||
80 | + return updateHost(providerId, host, hostDescription); | ||
81 | + } | ||
82 | + | ||
83 | + // creates a new host and sends HOST_ADDED | ||
84 | + private HostEvent createHost(ProviderId providerId, HostId hostId, | ||
85 | + HostDescription descr) { | ||
86 | + DefaultHost newhost = new DefaultHost(providerId, hostId, | ||
87 | + descr.hwAddress(), | ||
88 | + descr.vlan(), | ||
89 | + descr.location(), | ||
90 | + descr.ipAddresses()); | ||
91 | + synchronized (this) { | ||
92 | + hosts.put(hostId, newhost); | ||
93 | + locations.put(descr.location(), newhost); | ||
94 | + } | ||
95 | + return new HostEvent(HOST_ADDED, newhost); | ||
96 | + } | ||
97 | + | ||
98 | + // checks for type of update to host, sends appropriate event | ||
99 | + private HostEvent updateHost(ProviderId providerId, Host host, | ||
100 | + HostDescription descr) { | ||
101 | + DefaultHost updated; | ||
102 | + HostEvent event; | ||
103 | + if (!host.location().equals(descr.location())) { | ||
104 | + updated = new DefaultHost(providerId, host.id(), | ||
105 | + host.mac(), | ||
106 | + host.vlan(), | ||
107 | + descr.location(), | ||
108 | + host.ipAddresses()); | ||
109 | + event = new HostEvent(HOST_MOVED, updated); | ||
110 | + | ||
111 | + } else if (!(host.ipAddresses().equals(descr.ipAddresses()))) { | ||
112 | + updated = new DefaultHost(providerId, host.id(), | ||
113 | + host.mac(), | ||
114 | + host.vlan(), | ||
115 | + descr.location(), | ||
116 | + descr.ipAddresses()); | ||
117 | + event = new HostEvent(HOST_UPDATED, updated); | ||
118 | + } else { | ||
119 | + return null; | ||
120 | + } | ||
121 | + synchronized (this) { | ||
122 | + hosts.put(host.id(), updated); | ||
123 | + locations.remove(host.location(), host); | ||
124 | + locations.put(updated.location(), updated); | ||
125 | + } | ||
126 | + return event; | ||
127 | + } | ||
128 | + | ||
129 | + @Override | ||
130 | + public HostEvent removeHost(HostId hostId) { | ||
131 | + synchronized (this) { | ||
132 | + Host host = hosts.remove(hostId); | ||
133 | + if (host != null) { | ||
134 | + locations.remove((host.location()), host); | ||
135 | + return new HostEvent(HOST_REMOVED, host); | ||
136 | + } | ||
137 | + return null; | ||
138 | + } | ||
139 | + } | ||
140 | + | ||
141 | + @Override | ||
142 | + public int getHostCount() { | ||
143 | + return hosts.size(); | ||
144 | + } | ||
145 | + | ||
146 | + @Override | ||
147 | + public Iterable<Host> getHosts() { | ||
148 | + return Collections.unmodifiableSet(new HashSet<>(hosts.values())); | ||
149 | + } | ||
150 | + | ||
151 | + @Override | ||
152 | + public Host getHost(HostId hostId) { | ||
153 | + return hosts.get(hostId); | ||
154 | + } | ||
155 | + | ||
156 | + @Override | ||
157 | + public Set<Host> getHosts(VlanId vlanId) { | ||
158 | + Set<Host> vlanset = new HashSet<>(); | ||
159 | + for (Host h : hosts.values()) { | ||
160 | + if (h.vlan().equals(vlanId)) { | ||
161 | + vlanset.add(h); | ||
162 | + } | ||
163 | + } | ||
164 | + return vlanset; | ||
165 | + } | ||
166 | + | ||
167 | + @Override | ||
168 | + public Set<Host> getHosts(MacAddress mac) { | ||
169 | + Set<Host> macset = new HashSet<>(); | ||
170 | + for (Host h : hosts.values()) { | ||
171 | + if (h.mac().equals(mac)) { | ||
172 | + macset.add(h); | ||
173 | + } | ||
174 | + } | ||
175 | + return macset; | ||
176 | + } | ||
177 | + | ||
178 | + @Override | ||
179 | + public Set<Host> getHosts(IpPrefix ip) { | ||
180 | + Set<Host> ipset = new HashSet<>(); | ||
181 | + for (Host h : hosts.values()) { | ||
182 | + if (h.ipAddresses().contains(ip)) { | ||
183 | + ipset.add(h); | ||
184 | + } | ||
185 | + } | ||
186 | + return ipset; | ||
187 | + } | ||
188 | + | ||
189 | + @Override | ||
190 | + public Set<Host> getConnectedHosts(ConnectPoint connectPoint) { | ||
191 | + return ImmutableSet.copyOf(locations.get(connectPoint)); | ||
192 | + } | ||
193 | + | ||
194 | + @Override | ||
195 | + public Set<Host> getConnectedHosts(DeviceId deviceId) { | ||
196 | + Set<Host> hostset = new HashSet<>(); | ||
197 | + for (ConnectPoint p : locations.keySet()) { | ||
198 | + if (p.deviceId().equals(deviceId)) { | ||
199 | + hostset.addAll(locations.get(p)); | ||
200 | + } | ||
201 | + } | ||
202 | + return hostset; | ||
203 | + } | ||
204 | + | ||
205 | + @Override | ||
206 | + public void updateAddressBindings(PortAddresses addresses) { | ||
207 | + synchronized (portAddresses) { | ||
208 | + PortAddresses existing = portAddresses.get(addresses.connectPoint()); | ||
209 | + if (existing == null) { | ||
210 | + portAddresses.put(addresses.connectPoint(), addresses); | ||
211 | + } else { | ||
212 | + Set<IpPrefix> union = Sets.union(existing.ips(), addresses.ips()) | ||
213 | + .immutableCopy(); | ||
214 | + | ||
215 | + MacAddress newMac = (addresses.mac() == null) ? existing.mac() | ||
216 | + : addresses.mac(); | ||
217 | + | ||
218 | + PortAddresses newAddresses = | ||
219 | + new PortAddresses(addresses.connectPoint(), union, newMac); | ||
220 | + | ||
221 | + portAddresses.put(newAddresses.connectPoint(), newAddresses); | ||
222 | + } | ||
223 | + } | ||
224 | + } | ||
225 | + | ||
226 | + @Override | ||
227 | + public void removeAddressBindings(PortAddresses addresses) { | ||
228 | + synchronized (portAddresses) { | ||
229 | + PortAddresses existing = portAddresses.get(addresses.connectPoint()); | ||
230 | + if (existing != null) { | ||
231 | + Set<IpPrefix> difference = | ||
232 | + Sets.difference(existing.ips(), addresses.ips()).immutableCopy(); | ||
233 | + | ||
234 | + // If they removed the existing mac, set the new mac to null. | ||
235 | + // Otherwise, keep the existing mac. | ||
236 | + MacAddress newMac = existing.mac(); | ||
237 | + if (addresses.mac() != null && addresses.mac().equals(existing.mac())) { | ||
238 | + newMac = null; | ||
239 | + } | ||
240 | + | ||
241 | + PortAddresses newAddresses = | ||
242 | + new PortAddresses(addresses.connectPoint(), difference, newMac); | ||
243 | + | ||
244 | + portAddresses.put(newAddresses.connectPoint(), newAddresses); | ||
245 | + } | ||
246 | + } | ||
247 | + } | ||
248 | + | ||
249 | + @Override | ||
250 | + public void clearAddressBindings(ConnectPoint connectPoint) { | ||
251 | + synchronized (portAddresses) { | ||
252 | + portAddresses.remove(connectPoint); | ||
253 | + } | ||
254 | + } | ||
255 | + | ||
256 | + @Override | ||
257 | + public Set<PortAddresses> getAddressBindings() { | ||
258 | + synchronized (portAddresses) { | ||
259 | + return new HashSet<>(portAddresses.values()); | ||
260 | + } | ||
261 | + } | ||
262 | + | ||
263 | + @Override | ||
264 | + public PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint) { | ||
265 | + PortAddresses addresses; | ||
266 | + | ||
267 | + synchronized (portAddresses) { | ||
268 | + addresses = portAddresses.get(connectPoint); | ||
269 | + } | ||
270 | + | ||
271 | + if (addresses == null) { | ||
272 | + addresses = new PortAddresses(connectPoint, null, null); | ||
273 | + } | ||
274 | + | ||
275 | + return addresses; | ||
276 | + } | ||
277 | + | ||
278 | +} |
... | @@ -10,6 +10,7 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -10,6 +10,7 @@ import static org.slf4j.LoggerFactory.getLogger; |
10 | 10 | ||
11 | import java.util.HashSet; | 11 | import java.util.HashSet; |
12 | import java.util.Set; | 12 | import java.util.Set; |
13 | + | ||
13 | import org.apache.felix.scr.annotations.Activate; | 14 | import org.apache.felix.scr.annotations.Activate; |
14 | import org.apache.felix.scr.annotations.Component; | 15 | import org.apache.felix.scr.annotations.Component; |
15 | import org.apache.felix.scr.annotations.Deactivate; | 16 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -24,9 +25,9 @@ import org.onlab.onos.net.link.LinkEvent; | ... | @@ -24,9 +25,9 @@ import org.onlab.onos.net.link.LinkEvent; |
24 | import org.onlab.onos.net.link.LinkStore; | 25 | import org.onlab.onos.net.link.LinkStore; |
25 | import org.onlab.onos.net.link.LinkStoreDelegate; | 26 | import org.onlab.onos.net.link.LinkStoreDelegate; |
26 | import org.onlab.onos.net.provider.ProviderId; | 27 | import org.onlab.onos.net.provider.ProviderId; |
27 | -import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache; | 28 | +import org.onlab.onos.store.common.AbsentInvalidatingLoadingCache; |
28 | -import org.onlab.onos.store.impl.AbstractDistributedStore; | 29 | +import org.onlab.onos.store.common.AbstractHazelcastStore; |
29 | -import org.onlab.onos.store.impl.OptionalCacheLoader; | 30 | +import org.onlab.onos.store.common.OptionalCacheLoader; |
30 | import org.slf4j.Logger; | 31 | import org.slf4j.Logger; |
31 | 32 | ||
32 | import com.google.common.base.Optional; | 33 | import com.google.common.base.Optional; |
... | @@ -43,7 +44,7 @@ import com.hazelcast.core.IMap; | ... | @@ -43,7 +44,7 @@ import com.hazelcast.core.IMap; |
43 | @Component(immediate = true) | 44 | @Component(immediate = true) |
44 | @Service | 45 | @Service |
45 | public class DistributedLinkStore | 46 | public class DistributedLinkStore |
46 | - extends AbstractDistributedStore<LinkEvent, LinkStoreDelegate> | 47 | + extends AbstractHazelcastStore<LinkEvent, LinkStoreDelegate> |
47 | implements LinkStore { | 48 | implements LinkStore { |
48 | 49 | ||
49 | private final Logger log = getLogger(getClass()); | 50 | private final Logger log = getLogger(getClass()); | ... | ... |
1 | +package org.onlab.onos.store.topology.impl; | ||
2 | + | ||
3 | +import com.google.common.collect.ImmutableMap; | ||
4 | +import com.google.common.collect.ImmutableSet; | ||
5 | +import com.google.common.collect.ImmutableSetMultimap; | ||
6 | +import org.onlab.graph.DijkstraGraphSearch; | ||
7 | +import org.onlab.graph.GraphPathSearch; | ||
8 | +import org.onlab.graph.TarjanGraphSearch; | ||
9 | +import org.onlab.onos.net.AbstractModel; | ||
10 | +import org.onlab.onos.net.ConnectPoint; | ||
11 | +import org.onlab.onos.net.DefaultPath; | ||
12 | +import org.onlab.onos.net.DeviceId; | ||
13 | +import org.onlab.onos.net.Link; | ||
14 | +import org.onlab.onos.net.Path; | ||
15 | +import org.onlab.onos.net.provider.ProviderId; | ||
16 | +import org.onlab.onos.net.topology.ClusterId; | ||
17 | +import org.onlab.onos.net.topology.DefaultTopologyCluster; | ||
18 | +import org.onlab.onos.net.topology.DefaultTopologyVertex; | ||
19 | +import org.onlab.onos.net.topology.GraphDescription; | ||
20 | +import org.onlab.onos.net.topology.LinkWeight; | ||
21 | +import org.onlab.onos.net.topology.Topology; | ||
22 | +import org.onlab.onos.net.topology.TopologyCluster; | ||
23 | +import org.onlab.onos.net.topology.TopologyEdge; | ||
24 | +import org.onlab.onos.net.topology.TopologyGraph; | ||
25 | +import org.onlab.onos.net.topology.TopologyVertex; | ||
26 | + | ||
27 | +import java.util.ArrayList; | ||
28 | +import java.util.List; | ||
29 | +import java.util.Map; | ||
30 | +import java.util.Set; | ||
31 | + | ||
32 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
33 | +import static com.google.common.collect.ImmutableSetMultimap.Builder; | ||
34 | +import static org.onlab.graph.GraphPathSearch.Result; | ||
35 | +import static org.onlab.graph.TarjanGraphSearch.SCCResult; | ||
36 | +import static org.onlab.onos.net.Link.Type.INDIRECT; | ||
37 | + | ||
38 | +/** | ||
39 | + * Default implementation of the topology descriptor. This carries the | ||
40 | + * backing topology data. | ||
41 | + */ | ||
42 | +public class DefaultTopology extends AbstractModel implements Topology { | ||
43 | + | ||
44 | + private static final DijkstraGraphSearch<TopologyVertex, TopologyEdge> DIJKSTRA = | ||
45 | + new DijkstraGraphSearch<>(); | ||
46 | + private static final TarjanGraphSearch<TopologyVertex, TopologyEdge> TARJAN = | ||
47 | + new TarjanGraphSearch<>(); | ||
48 | + | ||
49 | + private static final ProviderId PID = new ProviderId("core", "org.onlab.onos.net"); | ||
50 | + | ||
51 | + private final long time; | ||
52 | + private final TopologyGraph graph; | ||
53 | + | ||
54 | + private final SCCResult<TopologyVertex, TopologyEdge> clusterResults; | ||
55 | + private final ImmutableMap<DeviceId, Result<TopologyVertex, TopologyEdge>> results; | ||
56 | + private final ImmutableSetMultimap<PathKey, Path> paths; | ||
57 | + | ||
58 | + private final ImmutableMap<ClusterId, TopologyCluster> clusters; | ||
59 | + private final ImmutableSet<ConnectPoint> infrastructurePoints; | ||
60 | + private final ImmutableSetMultimap<ClusterId, ConnectPoint> broadcastSets; | ||
61 | + | ||
62 | + private ImmutableMap<DeviceId, TopologyCluster> clustersByDevice; | ||
63 | + private ImmutableSetMultimap<TopologyCluster, DeviceId> devicesByCluster; | ||
64 | + private ImmutableSetMultimap<TopologyCluster, Link> linksByCluster; | ||
65 | + | ||
66 | + | ||
67 | + /** | ||
68 | + * Creates a topology descriptor attributed to the specified provider. | ||
69 | + * | ||
70 | + * @param providerId identity of the provider | ||
71 | + * @param description data describing the new topology | ||
72 | + */ | ||
73 | + DefaultTopology(ProviderId providerId, GraphDescription description) { | ||
74 | + super(providerId); | ||
75 | + this.time = description.timestamp(); | ||
76 | + | ||
77 | + // Build the graph | ||
78 | + this.graph = new DefaultTopologyGraph(description.vertexes(), | ||
79 | + description.edges()); | ||
80 | + | ||
81 | + this.results = searchForShortestPaths(); | ||
82 | + this.paths = buildPaths(); | ||
83 | + | ||
84 | + this.clusterResults = searchForClusters(); | ||
85 | + this.clusters = buildTopologyClusters(); | ||
86 | + | ||
87 | + buildIndexes(); | ||
88 | + | ||
89 | + this.broadcastSets = buildBroadcastSets(); | ||
90 | + this.infrastructurePoints = findInfrastructurePoints(); | ||
91 | + } | ||
92 | + | ||
93 | + @Override | ||
94 | + public long time() { | ||
95 | + return time; | ||
96 | + } | ||
97 | + | ||
98 | + @Override | ||
99 | + public int clusterCount() { | ||
100 | + return clusters.size(); | ||
101 | + } | ||
102 | + | ||
103 | + @Override | ||
104 | + public int deviceCount() { | ||
105 | + return graph.getVertexes().size(); | ||
106 | + } | ||
107 | + | ||
108 | + @Override | ||
109 | + public int linkCount() { | ||
110 | + return graph.getEdges().size(); | ||
111 | + } | ||
112 | + | ||
113 | + @Override | ||
114 | + public int pathCount() { | ||
115 | + return paths.size(); | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * Returns the backing topology graph. | ||
120 | + * | ||
121 | + * @return topology graph | ||
122 | + */ | ||
123 | + TopologyGraph getGraph() { | ||
124 | + return graph; | ||
125 | + } | ||
126 | + | ||
127 | + /** | ||
128 | + * Returns the set of topology clusters. | ||
129 | + * | ||
130 | + * @return set of clusters | ||
131 | + */ | ||
132 | + Set<TopologyCluster> getClusters() { | ||
133 | + return ImmutableSet.copyOf(clusters.values()); | ||
134 | + } | ||
135 | + | ||
136 | + /** | ||
137 | + * Returns the specified topology cluster. | ||
138 | + * | ||
139 | + * @param clusterId cluster identifier | ||
140 | + * @return topology cluster | ||
141 | + */ | ||
142 | + TopologyCluster getCluster(ClusterId clusterId) { | ||
143 | + return clusters.get(clusterId); | ||
144 | + } | ||
145 | + | ||
146 | + /** | ||
147 | + * Returns the topology cluster that contains the given device. | ||
148 | + * | ||
149 | + * @param deviceId device identifier | ||
150 | + * @return topology cluster | ||
151 | + */ | ||
152 | + TopologyCluster getCluster(DeviceId deviceId) { | ||
153 | + return clustersByDevice.get(deviceId); | ||
154 | + } | ||
155 | + | ||
156 | + /** | ||
157 | + * Returns the set of cluster devices. | ||
158 | + * | ||
159 | + * @param cluster topology cluster | ||
160 | + * @return cluster devices | ||
161 | + */ | ||
162 | + Set<DeviceId> getClusterDevices(TopologyCluster cluster) { | ||
163 | + return devicesByCluster.get(cluster); | ||
164 | + } | ||
165 | + | ||
166 | + /** | ||
167 | + * Returns the set of cluster links. | ||
168 | + * | ||
169 | + * @param cluster topology cluster | ||
170 | + * @return cluster links | ||
171 | + */ | ||
172 | + Set<Link> getClusterLinks(TopologyCluster cluster) { | ||
173 | + return linksByCluster.get(cluster); | ||
174 | + } | ||
175 | + | ||
176 | + /** | ||
177 | + * Indicates whether the given point is an infrastructure link end-point. | ||
178 | + * | ||
179 | + * @param connectPoint connection point | ||
180 | + * @return true if infrastructure | ||
181 | + */ | ||
182 | + boolean isInfrastructure(ConnectPoint connectPoint) { | ||
183 | + return infrastructurePoints.contains(connectPoint); | ||
184 | + } | ||
185 | + | ||
186 | + /** | ||
187 | + * Indicates whether the given point is part of a broadcast set. | ||
188 | + * | ||
189 | + * @param connectPoint connection point | ||
190 | + * @return true if in broadcast set | ||
191 | + */ | ||
192 | + boolean isBroadcastPoint(ConnectPoint connectPoint) { | ||
193 | + // Any non-infrastructure, i.e. edge points are assumed to be OK. | ||
194 | + if (!isInfrastructure(connectPoint)) { | ||
195 | + return true; | ||
196 | + } | ||
197 | + | ||
198 | + // Find the cluster to which the device belongs. | ||
199 | + TopologyCluster cluster = clustersByDevice.get(connectPoint.deviceId()); | ||
200 | + if (cluster == null) { | ||
201 | + throw new IllegalArgumentException("No cluster found for device " + connectPoint.deviceId()); | ||
202 | + } | ||
203 | + | ||
204 | + // If the broadcast set is null or empty, or if the point explicitly | ||
205 | + // belongs to it, return true; | ||
206 | + Set<ConnectPoint> points = broadcastSets.get(cluster.id()); | ||
207 | + return points == null || points.isEmpty() || points.contains(connectPoint); | ||
208 | + } | ||
209 | + | ||
210 | + /** | ||
211 | + * Returns the size of the cluster broadcast set. | ||
212 | + * | ||
213 | + * @param clusterId cluster identifier | ||
214 | + * @return size of the cluster broadcast set | ||
215 | + */ | ||
216 | + int broadcastSetSize(ClusterId clusterId) { | ||
217 | + return broadcastSets.get(clusterId).size(); | ||
218 | + } | ||
219 | + | ||
220 | + /** | ||
221 | + * Returns the set of pre-computed shortest paths between source and | ||
222 | + * destination devices. | ||
223 | + * | ||
224 | + * @param src source device | ||
225 | + * @param dst destination device | ||
226 | + * @return set of shortest paths | ||
227 | + */ | ||
228 | + Set<Path> getPaths(DeviceId src, DeviceId dst) { | ||
229 | + return paths.get(new PathKey(src, dst)); | ||
230 | + } | ||
231 | + | ||
232 | + /** | ||
233 | + * Computes on-demand the set of shortest paths between source and | ||
234 | + * destination devices. | ||
235 | + * | ||
236 | + * @param src source device | ||
237 | + * @param dst destination device | ||
238 | + * @return set of shortest paths | ||
239 | + */ | ||
240 | + Set<Path> getPaths(DeviceId src, DeviceId dst, LinkWeight weight) { | ||
241 | + GraphPathSearch.Result<TopologyVertex, TopologyEdge> result = | ||
242 | + DIJKSTRA.search(graph, new DefaultTopologyVertex(src), | ||
243 | + new DefaultTopologyVertex(dst), weight); | ||
244 | + ImmutableSet.Builder<Path> builder = ImmutableSet.builder(); | ||
245 | + for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) { | ||
246 | + builder.add(networkPath(path)); | ||
247 | + } | ||
248 | + return builder.build(); | ||
249 | + } | ||
250 | + | ||
251 | + | ||
252 | + // Searches the graph for all shortest paths and returns the search results. | ||
253 | + private ImmutableMap<DeviceId, Result<TopologyVertex, TopologyEdge>> searchForShortestPaths() { | ||
254 | + ImmutableMap.Builder<DeviceId, Result<TopologyVertex, TopologyEdge>> builder = ImmutableMap.builder(); | ||
255 | + | ||
256 | + // Search graph paths for each source to all destinations. | ||
257 | + LinkWeight weight = new HopCountLinkWeight(graph.getVertexes().size()); | ||
258 | + for (TopologyVertex src : graph.getVertexes()) { | ||
259 | + builder.put(src.deviceId(), DIJKSTRA.search(graph, src, null, weight)); | ||
260 | + } | ||
261 | + return builder.build(); | ||
262 | + } | ||
263 | + | ||
264 | + // Builds network paths from the graph path search results | ||
265 | + private ImmutableSetMultimap<PathKey, Path> buildPaths() { | ||
266 | + Builder<PathKey, Path> builder = ImmutableSetMultimap.builder(); | ||
267 | + for (DeviceId deviceId : results.keySet()) { | ||
268 | + Result<TopologyVertex, TopologyEdge> result = results.get(deviceId); | ||
269 | + for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) { | ||
270 | + builder.put(new PathKey(path.src().deviceId(), path.dst().deviceId()), | ||
271 | + networkPath(path)); | ||
272 | + } | ||
273 | + } | ||
274 | + return builder.build(); | ||
275 | + } | ||
276 | + | ||
277 | + // Converts graph path to a network path with the same cost. | ||
278 | + private Path networkPath(org.onlab.graph.Path<TopologyVertex, TopologyEdge> path) { | ||
279 | + List<Link> links = new ArrayList<>(); | ||
280 | + for (TopologyEdge edge : path.edges()) { | ||
281 | + links.add(edge.link()); | ||
282 | + } | ||
283 | + return new DefaultPath(PID, links, path.cost()); | ||
284 | + } | ||
285 | + | ||
286 | + | ||
287 | + // Searches for SCC clusters in the network topology graph using Tarjan | ||
288 | + // algorithm. | ||
289 | + private SCCResult<TopologyVertex, TopologyEdge> searchForClusters() { | ||
290 | + return TARJAN.search(graph, new NoIndirectLinksWeight()); | ||
291 | + } | ||
292 | + | ||
293 | + // Builds the topology clusters and returns the id-cluster bindings. | ||
294 | + private ImmutableMap<ClusterId, TopologyCluster> buildTopologyClusters() { | ||
295 | + ImmutableMap.Builder<ClusterId, TopologyCluster> clusterBuilder = ImmutableMap.builder(); | ||
296 | + SCCResult<TopologyVertex, TopologyEdge> result = | ||
297 | + TARJAN.search(graph, new NoIndirectLinksWeight()); | ||
298 | + | ||
299 | + // Extract both vertexes and edges from the results; the lists form | ||
300 | + // pairs along the same index. | ||
301 | + List<Set<TopologyVertex>> clusterVertexes = result.clusterVertexes(); | ||
302 | + List<Set<TopologyEdge>> clusterEdges = result.clusterEdges(); | ||
303 | + | ||
304 | + // Scan over the lists and create a cluster from the results. | ||
305 | + for (int i = 0, n = result.clusterCount(); i < n; i++) { | ||
306 | + Set<TopologyVertex> vertexSet = clusterVertexes.get(i); | ||
307 | + Set<TopologyEdge> edgeSet = clusterEdges.get(i); | ||
308 | + | ||
309 | + ClusterId cid = ClusterId.clusterId(i); | ||
310 | + DefaultTopologyCluster cluster = | ||
311 | + new DefaultTopologyCluster(cid, vertexSet.size(), edgeSet.size(), | ||
312 | + findRoot(vertexSet).deviceId()); | ||
313 | + clusterBuilder.put(cid, cluster); | ||
314 | + } | ||
315 | + return clusterBuilder.build(); | ||
316 | + } | ||
317 | + | ||
318 | + // Finds the vertex whose device id is the lexicographical minimum in the | ||
319 | + // specified set. | ||
320 | + private TopologyVertex findRoot(Set<TopologyVertex> vertexSet) { | ||
321 | + TopologyVertex minVertex = null; | ||
322 | + for (TopologyVertex vertex : vertexSet) { | ||
323 | + if (minVertex == null || | ||
324 | + minVertex.deviceId().toString() | ||
325 | + .compareTo(minVertex.deviceId().toString()) < 0) { | ||
326 | + minVertex = vertex; | ||
327 | + } | ||
328 | + } | ||
329 | + return minVertex; | ||
330 | + } | ||
331 | + | ||
332 | + // Processes a map of broadcast sets for each cluster. | ||
333 | + private ImmutableSetMultimap<ClusterId, ConnectPoint> buildBroadcastSets() { | ||
334 | + Builder<ClusterId, ConnectPoint> builder = ImmutableSetMultimap.builder(); | ||
335 | + for (TopologyCluster cluster : clusters.values()) { | ||
336 | + addClusterBroadcastSet(cluster, builder); | ||
337 | + } | ||
338 | + return builder.build(); | ||
339 | + } | ||
340 | + | ||
341 | + // Finds all broadcast points for the cluster. These are those connection | ||
342 | + // points which lie along the shortest paths between the cluster root and | ||
343 | + // all other devices within the cluster. | ||
344 | + private void addClusterBroadcastSet(TopologyCluster cluster, | ||
345 | + Builder<ClusterId, ConnectPoint> builder) { | ||
346 | + // Use the graph root search results to build the broadcast set. | ||
347 | + Result<TopologyVertex, TopologyEdge> result = results.get(cluster.root()); | ||
348 | + for (Map.Entry<TopologyVertex, Set<TopologyEdge>> entry : result.parents().entrySet()) { | ||
349 | + TopologyVertex vertex = entry.getKey(); | ||
350 | + | ||
351 | + // Ignore any parents that lead outside the cluster. | ||
352 | + if (clustersByDevice.get(vertex.deviceId()) != cluster) { | ||
353 | + continue; | ||
354 | + } | ||
355 | + | ||
356 | + // Ignore any back-link sets that are empty. | ||
357 | + Set<TopologyEdge> parents = entry.getValue(); | ||
358 | + if (parents.isEmpty()) { | ||
359 | + continue; | ||
360 | + } | ||
361 | + | ||
362 | + // Use the first back-link source and destinations to add to the | ||
363 | + // broadcast set. | ||
364 | + Link link = parents.iterator().next().link(); | ||
365 | + builder.put(cluster.id(), link.src()); | ||
366 | + builder.put(cluster.id(), link.dst()); | ||
367 | + } | ||
368 | + } | ||
369 | + | ||
370 | + // Collects and returns an set of all infrastructure link end-points. | ||
371 | + private ImmutableSet<ConnectPoint> findInfrastructurePoints() { | ||
372 | + ImmutableSet.Builder<ConnectPoint> builder = ImmutableSet.builder(); | ||
373 | + for (TopologyEdge edge : graph.getEdges()) { | ||
374 | + builder.add(edge.link().src()); | ||
375 | + builder.add(edge.link().dst()); | ||
376 | + } | ||
377 | + return builder.build(); | ||
378 | + } | ||
379 | + | ||
380 | + // Builds cluster-devices, cluster-links and device-cluster indexes. | ||
381 | + private void buildIndexes() { | ||
382 | + // Prepare the index builders | ||
383 | + ImmutableMap.Builder<DeviceId, TopologyCluster> clusterBuilder = ImmutableMap.builder(); | ||
384 | + ImmutableSetMultimap.Builder<TopologyCluster, DeviceId> devicesBuilder = ImmutableSetMultimap.builder(); | ||
385 | + ImmutableSetMultimap.Builder<TopologyCluster, Link> linksBuilder = ImmutableSetMultimap.builder(); | ||
386 | + | ||
387 | + // Now scan through all the clusters | ||
388 | + for (TopologyCluster cluster : clusters.values()) { | ||
389 | + int i = cluster.id().index(); | ||
390 | + | ||
391 | + // Scan through all the cluster vertexes. | ||
392 | + for (TopologyVertex vertex : clusterResults.clusterVertexes().get(i)) { | ||
393 | + devicesBuilder.put(cluster, vertex.deviceId()); | ||
394 | + clusterBuilder.put(vertex.deviceId(), cluster); | ||
395 | + } | ||
396 | + | ||
397 | + // Scan through all the cluster edges. | ||
398 | + for (TopologyEdge edge : clusterResults.clusterEdges().get(i)) { | ||
399 | + linksBuilder.put(cluster, edge.link()); | ||
400 | + } | ||
401 | + } | ||
402 | + | ||
403 | + // Finalize all indexes. | ||
404 | + clustersByDevice = clusterBuilder.build(); | ||
405 | + devicesByCluster = devicesBuilder.build(); | ||
406 | + linksByCluster = linksBuilder.build(); | ||
407 | + } | ||
408 | + | ||
409 | + // Link weight for measuring link cost as hop count with indirect links | ||
410 | + // being as expensive as traversing the entire graph to assume the worst. | ||
411 | + private static class HopCountLinkWeight implements LinkWeight { | ||
412 | + private final int indirectLinkCost; | ||
413 | + | ||
414 | + HopCountLinkWeight(int indirectLinkCost) { | ||
415 | + this.indirectLinkCost = indirectLinkCost; | ||
416 | + } | ||
417 | + | ||
418 | + @Override | ||
419 | + public double weight(TopologyEdge edge) { | ||
420 | + // To force preference to use direct paths first, make indirect | ||
421 | + // links as expensive as the linear vertex traversal. | ||
422 | + return edge.link().type() == INDIRECT ? indirectLinkCost : 1; | ||
423 | + } | ||
424 | + } | ||
425 | + | ||
426 | + // Link weight for preventing traversal over indirect links. | ||
427 | + private static class NoIndirectLinksWeight implements LinkWeight { | ||
428 | + @Override | ||
429 | + public double weight(TopologyEdge edge) { | ||
430 | + return edge.link().type() == INDIRECT ? -1 : 1; | ||
431 | + } | ||
432 | + } | ||
433 | + | ||
434 | + @Override | ||
435 | + public String toString() { | ||
436 | + return toStringHelper(this) | ||
437 | + .add("time", time) | ||
438 | + .add("clusters", clusterCount()) | ||
439 | + .add("devices", deviceCount()) | ||
440 | + .add("links", linkCount()) | ||
441 | + .add("pathCount", pathCount()) | ||
442 | + .toString(); | ||
443 | + } | ||
444 | +} |
core/store/hz/net/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopologyGraph.java
0 → 100644
1 | +package org.onlab.onos.store.topology.impl; | ||
2 | + | ||
3 | +import org.onlab.graph.AdjacencyListsGraph; | ||
4 | +import org.onlab.onos.net.topology.TopologyEdge; | ||
5 | +import org.onlab.onos.net.topology.TopologyGraph; | ||
6 | +import org.onlab.onos.net.topology.TopologyVertex; | ||
7 | + | ||
8 | +import java.util.Set; | ||
9 | + | ||
10 | +/** | ||
11 | + * Default implementation of an immutable topology graph based on a generic | ||
12 | + * implementation of adjacency lists graph. | ||
13 | + */ | ||
14 | +public class DefaultTopologyGraph | ||
15 | + extends AdjacencyListsGraph<TopologyVertex, TopologyEdge> | ||
16 | + implements TopologyGraph { | ||
17 | + | ||
18 | + /** | ||
19 | + * Creates a topology graph comprising of the specified vertexes and edges. | ||
20 | + * | ||
21 | + * @param vertexes set of graph vertexes | ||
22 | + * @param edges set of graph edges | ||
23 | + */ | ||
24 | + public DefaultTopologyGraph(Set<TopologyVertex> vertexes, Set<TopologyEdge> edges) { | ||
25 | + super(vertexes, edges); | ||
26 | + } | ||
27 | + | ||
28 | +} |
core/store/hz/net/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java
0 → 100644
1 | +package org.onlab.onos.store.topology.impl; | ||
2 | + | ||
3 | +import static org.slf4j.LoggerFactory.getLogger; | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | +import java.util.Set; | ||
7 | + | ||
8 | +import org.apache.felix.scr.annotations.Activate; | ||
9 | +import org.apache.felix.scr.annotations.Component; | ||
10 | +import org.apache.felix.scr.annotations.Deactivate; | ||
11 | +import org.apache.felix.scr.annotations.Service; | ||
12 | +import org.onlab.onos.event.Event; | ||
13 | +import org.onlab.onos.net.ConnectPoint; | ||
14 | +import org.onlab.onos.net.DeviceId; | ||
15 | +import org.onlab.onos.net.Link; | ||
16 | +import org.onlab.onos.net.Path; | ||
17 | +import org.onlab.onos.net.provider.ProviderId; | ||
18 | +import org.onlab.onos.net.topology.ClusterId; | ||
19 | +import org.onlab.onos.net.topology.GraphDescription; | ||
20 | +import org.onlab.onos.net.topology.LinkWeight; | ||
21 | +import org.onlab.onos.net.topology.Topology; | ||
22 | +import org.onlab.onos.net.topology.TopologyCluster; | ||
23 | +import org.onlab.onos.net.topology.TopologyEvent; | ||
24 | +import org.onlab.onos.net.topology.TopologyGraph; | ||
25 | +import org.onlab.onos.net.topology.TopologyStore; | ||
26 | +import org.onlab.onos.net.topology.TopologyStoreDelegate; | ||
27 | +import org.onlab.onos.store.AbstractStore; | ||
28 | +import org.slf4j.Logger; | ||
29 | + | ||
30 | +/** | ||
31 | + * Manages inventory of topology snapshots using trivial in-memory | ||
32 | + * structures implementation. | ||
33 | + */ | ||
34 | +//FIXME: I LIE I AM NOT DISTRIBUTED | ||
35 | +@Component(immediate = true) | ||
36 | +@Service | ||
37 | +public class DistributedTopologyStore | ||
38 | +extends AbstractStore<TopologyEvent, TopologyStoreDelegate> | ||
39 | +implements TopologyStore { | ||
40 | + | ||
41 | + private final Logger log = getLogger(getClass()); | ||
42 | + | ||
43 | + private volatile DefaultTopology current; | ||
44 | + | ||
45 | + @Activate | ||
46 | + public void activate() { | ||
47 | + log.info("Started"); | ||
48 | + } | ||
49 | + | ||
50 | + @Deactivate | ||
51 | + public void deactivate() { | ||
52 | + log.info("Stopped"); | ||
53 | + } | ||
54 | + @Override | ||
55 | + public Topology currentTopology() { | ||
56 | + return current; | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public boolean isLatest(Topology topology) { | ||
61 | + // Topology is current only if it is the same as our current topology | ||
62 | + return topology == current; | ||
63 | + } | ||
64 | + | ||
65 | + @Override | ||
66 | + public TopologyGraph getGraph(Topology topology) { | ||
67 | + return defaultTopology(topology).getGraph(); | ||
68 | + } | ||
69 | + | ||
70 | + @Override | ||
71 | + public Set<TopologyCluster> getClusters(Topology topology) { | ||
72 | + return defaultTopology(topology).getClusters(); | ||
73 | + } | ||
74 | + | ||
75 | + @Override | ||
76 | + public TopologyCluster getCluster(Topology topology, ClusterId clusterId) { | ||
77 | + return defaultTopology(topology).getCluster(clusterId); | ||
78 | + } | ||
79 | + | ||
80 | + @Override | ||
81 | + public Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster) { | ||
82 | + return defaultTopology(topology).getClusterDevices(cluster); | ||
83 | + } | ||
84 | + | ||
85 | + @Override | ||
86 | + public Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster) { | ||
87 | + return defaultTopology(topology).getClusterLinks(cluster); | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
91 | + public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst) { | ||
92 | + return defaultTopology(topology).getPaths(src, dst); | ||
93 | + } | ||
94 | + | ||
95 | + @Override | ||
96 | + public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, | ||
97 | + LinkWeight weight) { | ||
98 | + return defaultTopology(topology).getPaths(src, dst, weight); | ||
99 | + } | ||
100 | + | ||
101 | + @Override | ||
102 | + public boolean isInfrastructure(Topology topology, ConnectPoint connectPoint) { | ||
103 | + return defaultTopology(topology).isInfrastructure(connectPoint); | ||
104 | + } | ||
105 | + | ||
106 | + @Override | ||
107 | + public boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint) { | ||
108 | + return defaultTopology(topology).isBroadcastPoint(connectPoint); | ||
109 | + } | ||
110 | + | ||
111 | + @Override | ||
112 | + public TopologyEvent updateTopology(ProviderId providerId, | ||
113 | + GraphDescription graphDescription, | ||
114 | + List<Event> reasons) { | ||
115 | + // First off, make sure that what we're given is indeed newer than | ||
116 | + // what we already have. | ||
117 | + if (current != null && graphDescription.timestamp() < current.time()) { | ||
118 | + return null; | ||
119 | + } | ||
120 | + | ||
121 | + // Have the default topology construct self from the description data. | ||
122 | + DefaultTopology newTopology = | ||
123 | + new DefaultTopology(providerId, graphDescription); | ||
124 | + | ||
125 | + // Promote the new topology to current and return a ready-to-send event. | ||
126 | + synchronized (this) { | ||
127 | + current = newTopology; | ||
128 | + return new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, current); | ||
129 | + } | ||
130 | + } | ||
131 | + | ||
132 | + // Validates the specified topology and returns it as a default | ||
133 | + private DefaultTopology defaultTopology(Topology topology) { | ||
134 | + if (topology instanceof DefaultTopology) { | ||
135 | + return (DefaultTopology) topology; | ||
136 | + } | ||
137 | + throw new IllegalArgumentException("Topology class " + topology.getClass() + | ||
138 | + " not supported"); | ||
139 | + } | ||
140 | + | ||
141 | +} |
1 | +package org.onlab.onos.store.topology.impl; | ||
2 | + | ||
3 | +import org.onlab.onos.net.DeviceId; | ||
4 | + | ||
5 | +import java.util.Objects; | ||
6 | + | ||
7 | +/** | ||
8 | + * Key for filing pre-computed paths between source and destination devices. | ||
9 | + */ | ||
10 | +class PathKey { | ||
11 | + private final DeviceId src; | ||
12 | + private final DeviceId dst; | ||
13 | + | ||
14 | + /** | ||
15 | + * Creates a path key from the given source/dest pair. | ||
16 | + * @param src source device | ||
17 | + * @param dst destination device | ||
18 | + */ | ||
19 | + PathKey(DeviceId src, DeviceId dst) { | ||
20 | + this.src = src; | ||
21 | + this.dst = dst; | ||
22 | + } | ||
23 | + | ||
24 | + @Override | ||
25 | + public int hashCode() { | ||
26 | + return Objects.hash(src, dst); | ||
27 | + } | ||
28 | + | ||
29 | + @Override | ||
30 | + public boolean equals(Object obj) { | ||
31 | + if (this == obj) { | ||
32 | + return true; | ||
33 | + } | ||
34 | + if (obj instanceof PathKey) { | ||
35 | + final PathKey other = (PathKey) obj; | ||
36 | + return Objects.equals(this.src, other.src) && Objects.equals(this.dst, other.dst); | ||
37 | + } | ||
38 | + return false; | ||
39 | + } | ||
40 | +} |
... | @@ -32,9 +32,9 @@ import org.onlab.onos.net.device.DeviceEvent; | ... | @@ -32,9 +32,9 @@ import org.onlab.onos.net.device.DeviceEvent; |
32 | import org.onlab.onos.net.device.DeviceStoreDelegate; | 32 | import org.onlab.onos.net.device.DeviceStoreDelegate; |
33 | import org.onlab.onos.net.device.PortDescription; | 33 | import org.onlab.onos.net.device.PortDescription; |
34 | import org.onlab.onos.net.provider.ProviderId; | 34 | import org.onlab.onos.net.provider.ProviderId; |
35 | +import org.onlab.onos.store.common.StoreManager; | ||
35 | import org.onlab.onos.store.common.StoreService; | 36 | import org.onlab.onos.store.common.StoreService; |
36 | -import org.onlab.onos.store.impl.StoreManager; | 37 | +import org.onlab.onos.store.common.TestStoreManager; |
37 | -import org.onlab.onos.store.impl.TestStoreManager; | ||
38 | 38 | ||
39 | import com.google.common.collect.Iterables; | 39 | import com.google.common.collect.Iterables; |
40 | import com.google.common.collect.Sets; | 40 | import com.google.common.collect.Sets; | ... | ... |
... | @@ -26,9 +26,9 @@ import org.onlab.onos.net.link.DefaultLinkDescription; | ... | @@ -26,9 +26,9 @@ import org.onlab.onos.net.link.DefaultLinkDescription; |
26 | import org.onlab.onos.net.link.LinkEvent; | 26 | import org.onlab.onos.net.link.LinkEvent; |
27 | import org.onlab.onos.net.link.LinkStoreDelegate; | 27 | import org.onlab.onos.net.link.LinkStoreDelegate; |
28 | import org.onlab.onos.net.provider.ProviderId; | 28 | import org.onlab.onos.net.provider.ProviderId; |
29 | +import org.onlab.onos.store.common.StoreManager; | ||
29 | import org.onlab.onos.store.common.StoreService; | 30 | import org.onlab.onos.store.common.StoreService; |
30 | -import org.onlab.onos.store.impl.StoreManager; | 31 | +import org.onlab.onos.store.common.TestStoreManager; |
31 | -import org.onlab.onos.store.impl.TestStoreManager; | ||
32 | 32 | ||
33 | import com.google.common.collect.Iterables; | 33 | import com.google.common.collect.Iterables; |
34 | import com.hazelcast.config.Config; | 34 | import com.hazelcast.config.Config; | ... | ... |
core/store/hz/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
3 | + <modelVersion>4.0.0</modelVersion> | ||
4 | + | ||
5 | + <parent> | ||
6 | + <groupId>org.onlab.onos</groupId> | ||
7 | + <artifactId>onos-core-store</artifactId> | ||
8 | + <version>1.0.0-SNAPSHOT</version> | ||
9 | + <relativePath>../pom.xml</relativePath> | ||
10 | + </parent> | ||
11 | + | ||
12 | + <artifactId>onos-core-hz</artifactId> | ||
13 | + <packaging>pom</packaging> | ||
14 | + | ||
15 | + <description>ONOS Core Hazelcast Store subsystem</description> | ||
16 | + | ||
17 | + <modules> | ||
18 | + <module>common</module> | ||
19 | + <module>cluster</module> | ||
20 | + <module>net</module> | ||
21 | + </modules> | ||
22 | + | ||
23 | + <dependencies> | ||
24 | + <dependency> | ||
25 | + <groupId>com.google.guava</groupId> | ||
26 | + <artifactId>guava</artifactId> | ||
27 | + </dependency> | ||
28 | + <dependency> | ||
29 | + <groupId>org.onlab.onos</groupId> | ||
30 | + <artifactId>onlab-misc</artifactId> | ||
31 | + </dependency> | ||
32 | + <dependency> | ||
33 | + <groupId>org.onlab.onos</groupId> | ||
34 | + <artifactId>onlab-junit</artifactId> | ||
35 | + </dependency> | ||
36 | + <dependency> | ||
37 | + <groupId>com.hazelcast</groupId> | ||
38 | + <artifactId>hazelcast</artifactId> | ||
39 | + </dependency> | ||
40 | + </dependencies> | ||
41 | + | ||
42 | + <build> | ||
43 | + <plugins> | ||
44 | + <plugin> | ||
45 | + <groupId>org.apache.felix</groupId> | ||
46 | + <artifactId>maven-bundle-plugin</artifactId> | ||
47 | + </plugin> | ||
48 | + </plugins> | ||
49 | + </build> | ||
50 | + | ||
51 | +</project> |
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
3 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
5 | <modelVersion>4.0.0</modelVersion> | 3 | <modelVersion>4.0.0</modelVersion> |
6 | 4 | ||
7 | <parent> | 5 | <parent> |
... | @@ -12,34 +10,41 @@ | ... | @@ -12,34 +10,41 @@ |
12 | </parent> | 10 | </parent> |
13 | 11 | ||
14 | <artifactId>onos-core-store</artifactId> | 12 | <artifactId>onos-core-store</artifactId> |
15 | - <packaging>bundle</packaging> | 13 | + <packaging>pom</packaging> |
16 | 14 | ||
17 | - <description>ONOS distributed store subsystems</description> | 15 | + <description>ONOS Core Store subsystem</description> |
16 | + | ||
17 | + <modules> | ||
18 | + <module>trivial</module> | ||
19 | + <module>dist</module> | ||
20 | + <module>hz</module> | ||
21 | + <module>serializers</module> | ||
22 | + </modules> | ||
18 | 23 | ||
19 | <dependencies> | 24 | <dependencies> |
20 | <dependency> | 25 | <dependency> |
26 | + <groupId>com.google.guava</groupId> | ||
27 | + <artifactId>guava</artifactId> | ||
28 | + </dependency> | ||
29 | + <dependency> | ||
21 | <groupId>org.onlab.onos</groupId> | 30 | <groupId>org.onlab.onos</groupId> |
22 | - <artifactId>onos-api</artifactId> | 31 | + <artifactId>onlab-misc</artifactId> |
23 | </dependency> | 32 | </dependency> |
24 | <dependency> | 33 | <dependency> |
25 | - <groupId>org.apache.felix</groupId> | 34 | + <groupId>org.onlab.onos</groupId> |
26 | - <artifactId>org.apache.felix.scr.annotations</artifactId> | 35 | + <artifactId>onlab-junit</artifactId> |
27 | </dependency> | 36 | </dependency> |
28 | <dependency> | 37 | <dependency> |
29 | <groupId>com.hazelcast</groupId> | 38 | <groupId>com.hazelcast</groupId> |
30 | <artifactId>hazelcast</artifactId> | 39 | <artifactId>hazelcast</artifactId> |
31 | </dependency> | 40 | </dependency> |
32 | - <dependency> | ||
33 | - <groupId>de.javakaffee</groupId> | ||
34 | - <artifactId>kryo-serializers</artifactId> | ||
35 | - </dependency> | ||
36 | </dependencies> | 41 | </dependencies> |
37 | 42 | ||
38 | <build> | 43 | <build> |
39 | <plugins> | 44 | <plugins> |
40 | <plugin> | 45 | <plugin> |
41 | <groupId>org.apache.felix</groupId> | 46 | <groupId>org.apache.felix</groupId> |
42 | - <artifactId>maven-scr-plugin</artifactId> | 47 | + <artifactId>maven-bundle-plugin</artifactId> |
43 | </plugin> | 48 | </plugin> |
44 | </plugins> | 49 | </plugins> |
45 | </build> | 50 | </build> | ... | ... |
core/store/serializers/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
5 | + <modelVersion>4.0.0</modelVersion> | ||
6 | + | ||
7 | + <parent> | ||
8 | + <groupId>org.onlab.onos</groupId> | ||
9 | + <artifactId>onos-core-store</artifactId> | ||
10 | + <version>1.0.0-SNAPSHOT</version> | ||
11 | + <relativePath>../pom.xml</relativePath> | ||
12 | + </parent> | ||
13 | + | ||
14 | + <artifactId>onos-core-serializers</artifactId> | ||
15 | + <packaging>bundle</packaging> | ||
16 | + | ||
17 | + <description>Serializers for ONOS classes</description> | ||
18 | + | ||
19 | + <dependencies> | ||
20 | + <dependency> | ||
21 | + <groupId>org.onlab.onos</groupId> | ||
22 | + <artifactId>onos-api</artifactId> | ||
23 | + </dependency> | ||
24 | + <dependency> | ||
25 | + <groupId>org.apache.felix</groupId> | ||
26 | + <artifactId>org.apache.felix.scr.annotations</artifactId> | ||
27 | + </dependency> | ||
28 | + <dependency> | ||
29 | + <groupId>de.javakaffee</groupId> | ||
30 | + <artifactId>kryo-serializers</artifactId> | ||
31 | + </dependency> | ||
32 | + </dependencies> | ||
33 | + | ||
34 | + <build> | ||
35 | + <plugins> | ||
36 | + <plugin> | ||
37 | + <groupId>org.apache.felix</groupId> | ||
38 | + <artifactId>maven-scr-plugin</artifactId> | ||
39 | + </plugin> | ||
40 | + </plugins> | ||
41 | + </build> | ||
42 | + | ||
43 | +</project> |
... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
6 | 6 | ||
7 | <parent> | 7 | <parent> |
8 | <groupId>org.onlab.onos</groupId> | 8 | <groupId>org.onlab.onos</groupId> |
9 | - <artifactId>onos-core</artifactId> | 9 | + <artifactId>onos-core-store</artifactId> |
10 | <version>1.0.0-SNAPSHOT</version> | 10 | <version>1.0.0-SNAPSHOT</version> |
11 | <relativePath>../pom.xml</relativePath> | 11 | <relativePath>../pom.xml</relativePath> |
12 | </parent> | 12 | </parent> | ... | ... |
1 | +package org.onlab.onos.net.trivial.impl; | ||
2 | + | ||
3 | +import org.apache.felix.scr.annotations.Component; | ||
4 | +import org.apache.felix.scr.annotations.Service; | ||
5 | +import org.onlab.onos.cluster.MastershipTerm; | ||
6 | +import org.onlab.onos.net.DeviceId; | ||
7 | +import org.onlab.onos.store.ClockService; | ||
8 | +import org.onlab.onos.store.Timestamp; | ||
9 | + | ||
10 | +//FIXME: Code clone in onos-core-trivial, onos-core-hz-net | ||
11 | +/** | ||
12 | + * Dummy implementation of {@link ClockService}. | ||
13 | + */ | ||
14 | +@Component(immediate = true) | ||
15 | +@Service | ||
16 | +public class NoOpClockService implements ClockService { | ||
17 | + | ||
18 | + @Override | ||
19 | + public Timestamp getTimestamp(DeviceId deviceId) { | ||
20 | + return new Timestamp() { | ||
21 | + | ||
22 | + @Override | ||
23 | + public int compareTo(Timestamp o) { | ||
24 | + throw new IllegalStateException("Never expected to be used."); | ||
25 | + } | ||
26 | + }; | ||
27 | + } | ||
28 | + | ||
29 | + @Override | ||
30 | + public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) { | ||
31 | + } | ||
32 | +} |
... | @@ -49,7 +49,20 @@ | ... | @@ -49,7 +49,20 @@ |
49 | description="ONOS core components"> | 49 | description="ONOS core components"> |
50 | <feature>onos-api</feature> | 50 | <feature>onos-api</feature> |
51 | <bundle>mvn:org.onlab.onos/onos-core-net/1.0.0-SNAPSHOT</bundle> | 51 | <bundle>mvn:org.onlab.onos/onos-core-net/1.0.0-SNAPSHOT</bundle> |
52 | - <bundle>mvn:org.onlab.onos/onos-core-store/1.0.0-SNAPSHOT</bundle> | 52 | + <bundle>mvn:org.onlab.onos/onos-core-hz-common/1.0.0-SNAPSHOT</bundle> |
53 | + <bundle>mvn:org.onlab.onos/onos-core-serializers/1.0.0-SNAPSHOT</bundle> | ||
54 | + <bundle>mvn:org.onlab.onos/onos-core-hz-cluster/1.0.0-SNAPSHOT</bundle> | ||
55 | + <bundle>mvn:org.onlab.onos/onos-core-hz-net/1.0.0-SNAPSHOT</bundle> | ||
56 | + </feature> | ||
57 | + | ||
58 | + <feature name="onos-core-dist" version="1.0.0" | ||
59 | + description="ONOS core components"> | ||
60 | + <feature>onos-api</feature> | ||
61 | + <bundle>mvn:org.onlab.onos/onos-core-net/1.0.0-SNAPSHOT</bundle> | ||
62 | + <bundle>mvn:org.onlab.onos/onos-core-hz-common/1.0.0-SNAPSHOT</bundle> | ||
63 | + <bundle>mvn:org.onlab.onos/onos-core-serializers/1.0.0-SNAPSHOT</bundle> | ||
64 | + <bundle>mvn:org.onlab.onos/onos-core-hz-cluster/1.0.0-SNAPSHOT</bundle> | ||
65 | + <bundle>mvn:org.onlab.onos/onos-core-dist/1.0.0-SNAPSHOT</bundle> | ||
53 | </feature> | 66 | </feature> |
54 | 67 | ||
55 | <feature name="onos-core-trivial" version="1.0.0" | 68 | <feature name="onos-core-trivial" version="1.0.0" | ... | ... |
1 | -<project> | 1 | +<?xml version="1.0" encoding="UTF-8"?> |
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4_0_0.xsd"> | ||
2 | <modelVersion>4.0.0</modelVersion> | 5 | <modelVersion>4.0.0</modelVersion> |
3 | <groupId>org.onlab.tools</groupId> | 6 | <groupId>org.onlab.tools</groupId> |
4 | <artifactId>onos-build-conf</artifactId> | 7 | <artifactId>onos-build-conf</artifactId> | ... | ... |
tools/test/bin/onos-start-network
0 → 100755
1 | +#!/bin/bash | ||
2 | +#------------------------------------------------------------------------------- | ||
3 | +# Verifies connectivity to each node in ONOS cell. | ||
4 | +#------------------------------------------------------------------------------- | ||
5 | + | ||
6 | +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 | ||
7 | +. $ONOS_ROOT/tools/build/envDefaults | ||
8 | + | ||
9 | +SSHCMD="ssh -o PasswordAuthentication=no" | ||
10 | +SCPCMD="scp -q -o PasswordAuthentication=no" | ||
11 | + | ||
12 | +echo "Copying topology files to mininet vm." | ||
13 | +$SSHCMD -n $ONOS_USER@$OCN mkdir -p topos | ||
14 | +$SCPCMD $ONOS_ROOT/tools/test/topos/* $ONOS_USER@$OCN:topos/ | ||
15 | + | ||
16 | +echo "Starting Network." | ||
17 | +$SSHCMD -t $ONOS_USER@$OCN sudo python topos/sol.py $(env | sort | egrep "OC[0-9]+" | cut -d= -f2) |
... | @@ -2,4 +2,4 @@ | ... | @@ -2,4 +2,4 @@ |
2 | * Mechanism to transfer messages over network using IO loop and | 2 | * Mechanism to transfer messages over network using IO loop and |
3 | * message stream, backed by NIO byte buffers. | 3 | * message stream, backed by NIO byte buffers. |
4 | */ | 4 | */ |
5 | -package org.onlab.nio; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
5 | +package org.onlab.nio; | ... | ... |
-
Please register or login to post a comment