Added support for replicating device offline topology events: Added missing files
Showing
2 changed files
with
77 additions
and
0 deletions
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceOfflineEvent.java
0 → 100644
1 | +package org.onlab.onos.store.device.impl; | ||
2 | + | ||
3 | +import org.onlab.onos.net.DeviceId; | ||
4 | +import org.onlab.onos.store.Timestamp; | ||
5 | + | ||
6 | +/** | ||
7 | + * Information published by GossipDeviceStore to notify peers of a device | ||
8 | + * going offline. | ||
9 | + */ | ||
10 | +public class InternalDeviceOfflineEvent { | ||
11 | + | ||
12 | + private final DeviceId deviceId; | ||
13 | + private final Timestamp timestamp; | ||
14 | + | ||
15 | + /** | ||
16 | + * Creates a InternalDeviceOfflineEvent. | ||
17 | + * @param deviceId identifier of device going offline. | ||
18 | + * @param timestamp timestamp of when the device went offline. | ||
19 | + */ | ||
20 | + public InternalDeviceOfflineEvent(DeviceId deviceId, Timestamp timestamp) { | ||
21 | + this.deviceId = deviceId; | ||
22 | + this.timestamp = timestamp; | ||
23 | + } | ||
24 | + | ||
25 | + public DeviceId deviceId() { | ||
26 | + return deviceId; | ||
27 | + } | ||
28 | + | ||
29 | + public Timestamp timestamp() { | ||
30 | + return timestamp; | ||
31 | + } | ||
32 | + | ||
33 | + // for serializer | ||
34 | + @SuppressWarnings("unused") | ||
35 | + private InternalDeviceOfflineEvent() { | ||
36 | + deviceId = null; | ||
37 | + timestamp = null; | ||
38 | + } | ||
39 | +} |
1 | +package org.onlab.onos.store.device.impl; | ||
2 | + | ||
3 | +import org.onlab.onos.net.DeviceId; | ||
4 | +import org.onlab.onos.store.Timestamp; | ||
5 | + | ||
6 | +import com.esotericsoftware.kryo.Kryo; | ||
7 | +import com.esotericsoftware.kryo.Serializer; | ||
8 | +import com.esotericsoftware.kryo.io.Input; | ||
9 | +import com.esotericsoftware.kryo.io.Output; | ||
10 | + | ||
11 | +/** | ||
12 | + * Kryo Serializer for {@link InternalDeviceOfflineEvent}. | ||
13 | + */ | ||
14 | +public class InternalDeviceOfflineEventSerializer extends Serializer<InternalDeviceOfflineEvent> { | ||
15 | + | ||
16 | + /** | ||
17 | + * Creates a serializer for {@link InternalDeviceOfflineEvent}. | ||
18 | + */ | ||
19 | + public InternalDeviceOfflineEventSerializer() { | ||
20 | + // does not accept null | ||
21 | + super(false); | ||
22 | + } | ||
23 | + | ||
24 | + @Override | ||
25 | + public void write(Kryo kryo, Output output, InternalDeviceOfflineEvent event) { | ||
26 | + kryo.writeClassAndObject(output, event.deviceId()); | ||
27 | + kryo.writeClassAndObject(output, event.timestamp()); | ||
28 | + } | ||
29 | + | ||
30 | + @Override | ||
31 | + public InternalDeviceOfflineEvent read(Kryo kryo, Input input, | ||
32 | + Class<InternalDeviceOfflineEvent> type) { | ||
33 | + DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input); | ||
34 | + Timestamp timestamp = (Timestamp) kryo.readClassAndObject(input); | ||
35 | + | ||
36 | + return new InternalDeviceOfflineEvent(deviceId, timestamp); | ||
37 | + } | ||
38 | +} |
-
Please register or login to post a comment