moving around Madan's pieces
update features.xml to use hazelcast distributed bundle for now Change-Id: I806dc7f9f2f1db1fdfa8e16f083025888b237937
Showing
14 changed files
with
119 additions
and
49 deletions
1 | -package org.onlab.onos.store.common; | 1 | +package org.onlab.onos.store; |
2 | 2 | ||
3 | import org.onlab.onos.cluster.MastershipTerm; | 3 | import org.onlab.onos.cluster.MastershipTerm; |
4 | import org.onlab.onos.net.DeviceId; | 4 | import org.onlab.onos.net.DeviceId; |
5 | -import org.onlab.onos.store.Timestamp; | ||
6 | 5 | ||
6 | +// TODO: Consider renaming to DeviceClockService? | ||
7 | /** | 7 | /** |
8 | * Interface for a logical clock service that vends per device timestamps. | 8 | * Interface for a logical clock service that vends per device timestamps. |
9 | */ | 9 | */ |
10 | public interface ClockService { | 10 | public interface ClockService { |
11 | - | 11 | + |
12 | /** | 12 | /** |
13 | * Returns a new timestamp for the specified deviceId. | 13 | * Returns a new timestamp for the specified deviceId. |
14 | * @param deviceId device identifier. | 14 | * @param deviceId device identifier. |
15 | * @return timestamp. | 15 | * @return timestamp. |
16 | */ | 16 | */ |
17 | public Timestamp getTimestamp(DeviceId deviceId); | 17 | public Timestamp getTimestamp(DeviceId deviceId); |
18 | - | 18 | + |
19 | + // TODO: Should this be here or separate as Admin service, etc.? | ||
19 | /** | 20 | /** |
20 | * Updates the mastership term for the specified deviceId. | 21 | * Updates the mastership term for the specified deviceId. |
21 | * @param deviceId device identifier. | 22 | * @param deviceId device identifier. | ... | ... |
... | @@ -37,7 +37,7 @@ import org.onlab.onos.net.device.DeviceStoreDelegate; | ... | @@ -37,7 +37,7 @@ import org.onlab.onos.net.device.DeviceStoreDelegate; |
37 | import org.onlab.onos.net.device.PortDescription; | 37 | import org.onlab.onos.net.device.PortDescription; |
38 | import org.onlab.onos.net.provider.AbstractProviderRegistry; | 38 | import org.onlab.onos.net.provider.AbstractProviderRegistry; |
39 | import org.onlab.onos.net.provider.AbstractProviderService; | 39 | import org.onlab.onos.net.provider.AbstractProviderService; |
40 | -import org.onlab.onos.store.common.ClockService; | 40 | +import org.onlab.onos.store.ClockService; |
41 | import org.slf4j.Logger; | 41 | import org.slf4j.Logger; |
42 | 42 | ||
43 | /** | 43 | /** | ... | ... |
... | @@ -12,21 +12,21 @@ import org.apache.felix.scr.annotations.Deactivate; | ... | @@ -12,21 +12,21 @@ import org.apache.felix.scr.annotations.Deactivate; |
12 | import org.apache.felix.scr.annotations.Service; | 12 | import org.apache.felix.scr.annotations.Service; |
13 | import org.onlab.onos.cluster.MastershipTerm; | 13 | import org.onlab.onos.cluster.MastershipTerm; |
14 | import org.onlab.onos.net.DeviceId; | 14 | import org.onlab.onos.net.DeviceId; |
15 | +import org.onlab.onos.store.ClockService; | ||
15 | import org.onlab.onos.store.Timestamp; | 16 | import org.onlab.onos.store.Timestamp; |
16 | -import org.onlab.onos.store.common.ClockService; | ||
17 | import org.onlab.onos.store.impl.OnosTimestamp; | 17 | import org.onlab.onos.store.impl.OnosTimestamp; |
18 | import org.slf4j.Logger; | 18 | import org.slf4j.Logger; |
19 | 19 | ||
20 | @Component(immediate = true) | 20 | @Component(immediate = true) |
21 | @Service | 21 | @Service |
22 | public class OnosClockService implements ClockService { | 22 | public class OnosClockService implements ClockService { |
23 | - | 23 | + |
24 | private final Logger log = getLogger(getClass()); | 24 | private final Logger log = getLogger(getClass()); |
25 | 25 | ||
26 | // TODO: Implement per device ticker that is reset to 0 at the beginning of a new term. | 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); | 27 | private final AtomicInteger ticker = new AtomicInteger(0); |
28 | private ConcurrentMap<DeviceId, MastershipTerm> deviceMastershipTerms = new ConcurrentHashMap<>(); | 28 | private ConcurrentMap<DeviceId, MastershipTerm> deviceMastershipTerms = new ConcurrentHashMap<>(); |
29 | - | 29 | + |
30 | @Activate | 30 | @Activate |
31 | public void activate() { | 31 | public void activate() { |
32 | log.info("Started"); | 32 | log.info("Started"); |
... | @@ -36,7 +36,7 @@ public class OnosClockService implements ClockService { | ... | @@ -36,7 +36,7 @@ public class OnosClockService implements ClockService { |
36 | public void deactivate() { | 36 | public void deactivate() { |
37 | log.info("Stopped"); | 37 | log.info("Stopped"); |
38 | } | 38 | } |
39 | - | 39 | + |
40 | @Override | 40 | @Override |
41 | public Timestamp getTimestamp(DeviceId deviceId) { | 41 | public Timestamp getTimestamp(DeviceId deviceId) { |
42 | MastershipTerm term = deviceMastershipTerms.get(deviceId); | 42 | MastershipTerm term = deviceMastershipTerms.get(deviceId); | ... | ... |
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 | +import static com.google.common.base.Preconditions.checkState; | ||
4 | 5 | ||
5 | -import com.google.common.base.Preconditions; | ||
6 | import com.google.common.collect.FluentIterable; | 6 | import com.google.common.collect.FluentIterable; |
7 | import com.google.common.collect.ImmutableSet; | 7 | import com.google.common.collect.ImmutableSet; |
8 | import com.google.common.collect.ImmutableSet.Builder; | 8 | import com.google.common.collect.ImmutableSet.Builder; |
... | @@ -25,9 +25,9 @@ import org.onlab.onos.net.device.DeviceStore; | ... | @@ -25,9 +25,9 @@ import org.onlab.onos.net.device.DeviceStore; |
25 | import org.onlab.onos.net.device.DeviceStoreDelegate; | 25 | import org.onlab.onos.net.device.DeviceStoreDelegate; |
26 | import org.onlab.onos.net.device.PortDescription; | 26 | import org.onlab.onos.net.device.PortDescription; |
27 | import org.onlab.onos.net.provider.ProviderId; | 27 | import org.onlab.onos.net.provider.ProviderId; |
28 | +import org.onlab.onos.store.AbstractStore; | ||
29 | +import org.onlab.onos.store.ClockService; | ||
28 | import org.onlab.onos.store.Timestamp; | 30 | import org.onlab.onos.store.Timestamp; |
29 | -import org.onlab.onos.store.common.ClockService; | ||
30 | -import org.onlab.onos.store.impl.AbstractDistributedStore; | ||
31 | import org.slf4j.Logger; | 31 | import org.slf4j.Logger; |
32 | 32 | ||
33 | import java.util.ArrayList; | 33 | import java.util.ArrayList; |
... | @@ -52,7 +52,7 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -52,7 +52,7 @@ import static org.slf4j.LoggerFactory.getLogger; |
52 | @Component(immediate = true) | 52 | @Component(immediate = true) |
53 | @Service | 53 | @Service |
54 | public class OnosDistributedDeviceStore | 54 | public class OnosDistributedDeviceStore |
55 | - extends AbstractDistributedStore<DeviceEvent, DeviceStoreDelegate> | 55 | + extends AbstractStore<DeviceEvent, DeviceStoreDelegate> |
56 | implements DeviceStore { | 56 | implements DeviceStore { |
57 | 57 | ||
58 | private final Logger log = getLogger(getClass()); | 58 | private final Logger log = getLogger(getClass()); |
... | @@ -61,21 +61,19 @@ public class OnosDistributedDeviceStore | ... | @@ -61,21 +61,19 @@ public class OnosDistributedDeviceStore |
61 | 61 | ||
62 | private ConcurrentHashMap<DeviceId, VersionedValue<Device>> devices; | 62 | private ConcurrentHashMap<DeviceId, VersionedValue<Device>> devices; |
63 | private ConcurrentHashMap<DeviceId, Map<PortNumber, VersionedValue<Port>>> devicePorts; | 63 | private ConcurrentHashMap<DeviceId, Map<PortNumber, VersionedValue<Port>>> devicePorts; |
64 | - | 64 | + |
65 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 65 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
66 | protected ClockService clockService; | 66 | protected ClockService clockService; |
67 | 67 | ||
68 | - @Override | ||
69 | @Activate | 68 | @Activate |
70 | public void activate() { | 69 | public void activate() { |
71 | - super.activate(); | ||
72 | 70 | ||
73 | devices = new ConcurrentHashMap<>(); | 71 | devices = new ConcurrentHashMap<>(); |
74 | devicePorts = new ConcurrentHashMap<>(); | 72 | devicePorts = new ConcurrentHashMap<>(); |
75 | 73 | ||
76 | log.info("Started"); | 74 | log.info("Started"); |
77 | } | 75 | } |
78 | - | 76 | + |
79 | @Deactivate | 77 | @Deactivate |
80 | public void deactivate() { | 78 | public void deactivate() { |
81 | log.info("Stopped"); | 79 | log.info("Stopped"); |
... | @@ -107,12 +105,13 @@ public class OnosDistributedDeviceStore | ... | @@ -107,12 +105,13 @@ public class OnosDistributedDeviceStore |
107 | DeviceDescription deviceDescription) { | 105 | DeviceDescription deviceDescription) { |
108 | Timestamp now = clockService.getTimestamp(deviceId); | 106 | Timestamp now = clockService.getTimestamp(deviceId); |
109 | VersionedValue<Device> device = devices.get(deviceId); | 107 | VersionedValue<Device> device = devices.get(deviceId); |
110 | - | 108 | + |
111 | if (device == null) { | 109 | if (device == null) { |
112 | return createDevice(providerId, deviceId, deviceDescription, now); | 110 | return createDevice(providerId, deviceId, deviceDescription, now); |
113 | } | 111 | } |
114 | - | 112 | + |
115 | - Preconditions.checkState(now.compareTo(device.timestamp()) > 0, "Existing device has a timestamp in the future!"); | 113 | + checkState(now.compareTo(device.timestamp()) > 0, |
114 | + "Existing device has a timestamp in the future!"); | ||
116 | 115 | ||
117 | return updateDevice(providerId, device.entity(), deviceDescription, now); | 116 | return updateDevice(providerId, device.entity(), deviceDescription, now); |
118 | } | 117 | } |
... | @@ -156,7 +155,8 @@ public class OnosDistributedDeviceStore | ... | @@ -156,7 +155,8 @@ public class OnosDistributedDeviceStore |
156 | desc.swVersion(), | 155 | desc.swVersion(), |
157 | desc.serialNumber()); | 156 | desc.serialNumber()); |
158 | 157 | ||
159 | - VersionedValue<Device> oldDevice = devices.put(device.id(), new VersionedValue<Device>(updated, true, timestamp)); | 158 | + VersionedValue<Device> oldDevice = devices.put(device.id(), |
159 | + new VersionedValue<Device>(updated, true, timestamp)); | ||
160 | if (!oldDevice.isUp()) { | 160 | if (!oldDevice.isUp()) { |
161 | return new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device, null); | 161 | return new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device, null); |
162 | } else { | 162 | } else { |
... | @@ -168,21 +168,20 @@ public class OnosDistributedDeviceStore | ... | @@ -168,21 +168,20 @@ public class OnosDistributedDeviceStore |
168 | public DeviceEvent markOffline(DeviceId deviceId) { | 168 | public DeviceEvent markOffline(DeviceId deviceId) { |
169 | VersionedValue<Device> device = devices.get(deviceId); | 169 | VersionedValue<Device> device = devices.get(deviceId); |
170 | boolean willRemove = device != null && device.isUp(); | 170 | boolean willRemove = device != null && device.isUp(); |
171 | - if (!willRemove) return null; | 171 | + if (!willRemove) { |
172 | + return null; | ||
173 | + } | ||
172 | Timestamp timestamp = clockService.getTimestamp(deviceId); | 174 | Timestamp timestamp = clockService.getTimestamp(deviceId); |
173 | - if (replaceIfLatest(device.entity(), false, timestamp)) | 175 | + if (replaceIfLatest(device.entity(), false, timestamp)) { |
174 | - { | ||
175 | return new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device.entity(), null); | 176 | return new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device.entity(), null); |
176 | } | 177 | } |
177 | return null; | 178 | return null; |
178 | } | 179 | } |
179 | - | 180 | + |
180 | // Replace existing value if its timestamp is older. | 181 | // Replace existing value if its timestamp is older. |
181 | - private synchronized boolean replaceIfLatest(Device device, boolean isUp, Timestamp timestamp) | 182 | + private synchronized boolean replaceIfLatest(Device device, boolean isUp, Timestamp timestamp) { |
182 | - { | ||
183 | VersionedValue<Device> existingValue = devices.get(device.id()); | 183 | VersionedValue<Device> existingValue = devices.get(device.id()); |
184 | - if (timestamp.compareTo(existingValue.timestamp()) > 0) | 184 | + if (timestamp.compareTo(existingValue.timestamp()) > 0) { |
185 | - { | ||
186 | devices.put(device.id(), new VersionedValue<Device>(device, isUp, timestamp)); | 185 | devices.put(device.id(), new VersionedValue<Device>(device, isUp, timestamp)); |
187 | return true; | 186 | return true; |
188 | } | 187 | } |
... | @@ -203,8 +202,11 @@ public class OnosDistributedDeviceStore | ... | @@ -203,8 +202,11 @@ public class OnosDistributedDeviceStore |
203 | Set<PortNumber> processed = new HashSet<>(); | 202 | Set<PortNumber> processed = new HashSet<>(); |
204 | for (PortDescription portDescription : portDescriptions) { | 203 | for (PortDescription portDescription : portDescriptions) { |
205 | VersionedValue<Port> port = ports.get(portDescription.portNumber()); | 204 | VersionedValue<Port> port = ports.get(portDescription.portNumber()); |
206 | - if (port == null) events.add(createPort(device, portDescription, ports, timestamp)); | 205 | + if (port == null) { |
207 | - Preconditions.checkState(timestamp.compareTo(port.timestamp()) > 0, "Existing port state has a timestamp in the future!"); | 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!"); | ||
208 | events.add(updatePort(device, port, portDescription, ports, timestamp)); | 210 | events.add(updatePort(device, port, portDescription, ports, timestamp)); |
209 | processed.add(portDescription.portNumber()); | 211 | processed.add(portDescription.portNumber()); |
210 | } | 212 | } |
... | @@ -304,8 +306,10 @@ public class OnosDistributedDeviceStore | ... | @@ -304,8 +306,10 @@ public class OnosDistributedDeviceStore |
304 | @Override | 306 | @Override |
305 | public List<Port> getPorts(DeviceId deviceId) { | 307 | public List<Port> getPorts(DeviceId deviceId) { |
306 | Map<PortNumber, VersionedValue<Port>> versionedPorts = devicePorts.get(deviceId); | 308 | Map<PortNumber, VersionedValue<Port>> versionedPorts = devicePorts.get(deviceId); |
307 | - if (versionedPorts == null) return Collections.emptyList(); | 309 | + if (versionedPorts == null) { |
308 | - List<Port> ports = new ArrayList<Port>(); | 310 | + return Collections.emptyList(); |
311 | + } | ||
312 | + List<Port> ports = new ArrayList<>(); | ||
309 | for (VersionedValue<Port> port : versionedPorts.values()) { | 313 | for (VersionedValue<Port> port : versionedPorts.values()) { |
310 | ports.add(port.entity()); | 314 | ports.add(port.entity()); |
311 | } | 315 | } | ... | ... |
... | @@ -3,7 +3,7 @@ package org.onlab.onos.store.device.impl; | ... | @@ -3,7 +3,7 @@ package org.onlab.onos.store.device.impl; |
3 | import org.onlab.onos.store.Timestamp; | 3 | import org.onlab.onos.store.Timestamp; |
4 | 4 | ||
5 | /** | 5 | /** |
6 | - * Wrapper class for a entity that is versioned | 6 | + * Wrapper class for a entity that is versioned |
7 | * and can either be up or down. | 7 | * and can either be up or down. |
8 | * | 8 | * |
9 | * @param <T> type of the value. | 9 | * @param <T> type of the value. |
... | @@ -12,13 +12,13 @@ public class VersionedValue<T> { | ... | @@ -12,13 +12,13 @@ public class VersionedValue<T> { |
12 | private final T entity; | 12 | private final T entity; |
13 | private final Timestamp timestamp; | 13 | private final Timestamp timestamp; |
14 | private final boolean isUp; | 14 | private final boolean isUp; |
15 | - | 15 | + |
16 | public VersionedValue(T entity, boolean isUp, Timestamp timestamp) { | 16 | public VersionedValue(T entity, boolean isUp, Timestamp timestamp) { |
17 | this.entity = entity; | 17 | this.entity = entity; |
18 | this.isUp = isUp; | 18 | this.isUp = isUp; |
19 | this.timestamp = timestamp; | 19 | this.timestamp = timestamp; |
20 | } | 20 | } |
21 | - | 21 | + |
22 | /** | 22 | /** |
23 | * Returns the value. | 23 | * Returns the value. |
24 | * @return value. | 24 | * @return value. |
... | @@ -26,7 +26,7 @@ public class VersionedValue<T> { | ... | @@ -26,7 +26,7 @@ public class VersionedValue<T> { |
26 | public T entity() { | 26 | public T entity() { |
27 | return entity; | 27 | return entity; |
28 | } | 28 | } |
29 | - | 29 | + |
30 | /** | 30 | /** |
31 | * Tells whether the entity is up or down. | 31 | * Tells whether the entity is up or down. |
32 | * @return true if up, false otherwise. | 32 | * @return true if up, false otherwise. |
... | @@ -34,7 +34,7 @@ public class VersionedValue<T> { | ... | @@ -34,7 +34,7 @@ public class VersionedValue<T> { |
34 | public boolean isUp() { | 34 | public boolean isUp() { |
35 | return isUp; | 35 | return isUp; |
36 | } | 36 | } |
37 | - | 37 | + |
38 | /** | 38 | /** |
39 | * Returns the timestamp (version) associated with this entity. | 39 | * Returns the timestamp (version) associated with this entity. |
40 | * @return timestamp. | 40 | * @return timestamp. | ... | ... |
... | @@ -84,4 +84,4 @@ public final class OnosTimestamp implements Timestamp { | ... | @@ -84,4 +84,4 @@ public final class OnosTimestamp implements Timestamp { |
84 | public int sequenceNumber() { | 84 | public int sequenceNumber() { |
85 | return sequenceNumber; | 85 | return sequenceNumber; |
86 | } | 86 | } |
87 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
87 | +} | ... | ... |
... | @@ -19,7 +19,7 @@ import org.onlab.onos.cluster.ControllerNode; | ... | @@ -19,7 +19,7 @@ import org.onlab.onos.cluster.ControllerNode; |
19 | import org.onlab.onos.cluster.DefaultControllerNode; | 19 | import org.onlab.onos.cluster.DefaultControllerNode; |
20 | import org.onlab.onos.cluster.NodeId; | 20 | import org.onlab.onos.cluster.NodeId; |
21 | import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache; | 21 | import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache; |
22 | -import org.onlab.onos.store.impl.AbstractDistributedStore; | 22 | +import org.onlab.onos.store.impl.AbstractHazelcastStore; |
23 | import org.onlab.onos.store.impl.OptionalCacheLoader; | 23 | import org.onlab.onos.store.impl.OptionalCacheLoader; |
24 | import org.onlab.packet.IpPrefix; | 24 | import org.onlab.packet.IpPrefix; |
25 | 25 | ||
... | @@ -38,7 +38,7 @@ import static org.onlab.onos.cluster.ControllerNode.State; | ... | @@ -38,7 +38,7 @@ import static org.onlab.onos.cluster.ControllerNode.State; |
38 | @Component(immediate = true) | 38 | @Component(immediate = true) |
39 | @Service | 39 | @Service |
40 | public class DistributedClusterStore | 40 | public class DistributedClusterStore |
41 | - extends AbstractDistributedStore<ClusterEvent, ClusterStoreDelegate> | 41 | + extends AbstractHazelcastStore<ClusterEvent, ClusterStoreDelegate> |
42 | implements ClusterStore { | 42 | implements ClusterStore { |
43 | 43 | ||
44 | private IMap<byte[], byte[]> rawNodes; | 44 | private IMap<byte[], byte[]> rawNodes; | ... | ... |
... | @@ -22,7 +22,7 @@ import org.onlab.onos.cluster.NodeId; | ... | @@ -22,7 +22,7 @@ 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.impl.AbsentInvalidatingLoadingCache; |
25 | -import org.onlab.onos.store.impl.AbstractDistributedStore; | 25 | +import org.onlab.onos.store.impl.AbstractHazelcastStore; |
26 | import org.onlab.onos.store.impl.OptionalCacheLoader; | 26 | import org.onlab.onos.store.impl.OptionalCacheLoader; |
27 | 27 | ||
28 | import com.google.common.base.Optional; | 28 | import com.google.common.base.Optional; |
... | @@ -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; | ... | ... |
1 | +package org.onlab.onos.store.common; | ||
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 | ||
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 | +} |
... | @@ -27,7 +27,7 @@ import org.onlab.onos.net.device.DeviceStoreDelegate; | ... | @@ -27,7 +27,7 @@ import org.onlab.onos.net.device.DeviceStoreDelegate; |
27 | import org.onlab.onos.net.device.PortDescription; | 27 | import org.onlab.onos.net.device.PortDescription; |
28 | import org.onlab.onos.net.provider.ProviderId; | 28 | import org.onlab.onos.net.provider.ProviderId; |
29 | import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache; | 29 | import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache; |
30 | -import org.onlab.onos.store.impl.AbstractDistributedStore; | 30 | +import org.onlab.onos.store.impl.AbstractHazelcastStore; |
31 | import org.onlab.onos.store.impl.OptionalCacheLoader; | 31 | import org.onlab.onos.store.impl.OptionalCacheLoader; |
32 | import org.slf4j.Logger; | 32 | import org.slf4j.Logger; |
33 | 33 | ||
... | @@ -52,7 +52,7 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -52,7 +52,7 @@ import static org.slf4j.LoggerFactory.getLogger; |
52 | @Component(immediate = true) | 52 | @Component(immediate = true) |
53 | @Service | 53 | @Service |
54 | public class DistributedDeviceStore | 54 | public class DistributedDeviceStore |
55 | - extends AbstractDistributedStore<DeviceEvent, DeviceStoreDelegate> | 55 | + extends AbstractHazelcastStore<DeviceEvent, DeviceStoreDelegate> |
56 | implements DeviceStore { | 56 | implements DeviceStore { |
57 | 57 | ||
58 | private final Logger log = getLogger(getClass()); | 58 | private final Logger log = getLogger(getClass()); | ... | ... |
... | @@ -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()); | ... | ... |
... | @@ -25,7 +25,7 @@ import org.onlab.onos.net.link.LinkStore; | ... | @@ -25,7 +25,7 @@ import org.onlab.onos.net.link.LinkStore; |
25 | import org.onlab.onos.net.link.LinkStoreDelegate; | 25 | import org.onlab.onos.net.link.LinkStoreDelegate; |
26 | import org.onlab.onos.net.provider.ProviderId; | 26 | import org.onlab.onos.net.provider.ProviderId; |
27 | import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache; | 27 | import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache; |
28 | -import org.onlab.onos.store.impl.AbstractDistributedStore; | 28 | +import org.onlab.onos.store.impl.AbstractHazelcastStore; |
29 | import org.onlab.onos.store.impl.OptionalCacheLoader; | 29 | import org.onlab.onos.store.impl.OptionalCacheLoader; |
30 | import org.slf4j.Logger; | 30 | import org.slf4j.Logger; |
31 | 31 | ||
... | @@ -43,7 +43,7 @@ import com.hazelcast.core.IMap; | ... | @@ -43,7 +43,7 @@ import com.hazelcast.core.IMap; |
43 | @Component(immediate = true) | 43 | @Component(immediate = true) |
44 | @Service | 44 | @Service |
45 | public class DistributedLinkStore | 45 | public class DistributedLinkStore |
46 | - extends AbstractDistributedStore<LinkEvent, LinkStoreDelegate> | 46 | + extends AbstractHazelcastStore<LinkEvent, LinkStoreDelegate> |
47 | implements LinkStore { | 47 | implements LinkStore { |
48 | 48 | ||
49 | private final Logger log = getLogger(getClass()); | 49 | private final Logger log = getLogger(getClass()); | ... | ... |
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 | ||
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 | +} |
... | @@ -48,7 +48,8 @@ | ... | @@ -48,7 +48,8 @@ |
48 | description="ONOS core components"> | 48 | description="ONOS core components"> |
49 | <feature>onos-api</feature> | 49 | <feature>onos-api</feature> |
50 | <bundle>mvn:org.onlab.onos/onos-core-net/1.0.0-SNAPSHOT</bundle> | 50 | <bundle>mvn:org.onlab.onos/onos-core-net/1.0.0-SNAPSHOT</bundle> |
51 | - <bundle>mvn:org.onlab.onos/onos-core-store/1.0.0-SNAPSHOT</bundle> | 51 | + <bundle>mvn:org.onlab.onos/onos-core-hz/1.0.0-SNAPSHOT</bundle> |
52 | + <bundle>mvn:org.onlab.onos/onos-core-serializers/1.0.0-SNAPSHOT</bundle> | ||
52 | </feature> | 53 | </feature> |
53 | 54 | ||
54 | <feature name="onos-core-trivial" version="1.0.0" | 55 | <feature name="onos-core-trivial" version="1.0.0" | ... | ... |
-
Please register or login to post a comment