blob: e0d27561194a3465ca084614bef38a3e1bf74aca [file] [log] [blame]
Ayaka Koshibe8b3270f2014-09-22 13:44:42 -07001package org.onlab.onos.cluster;
2
3import org.onlab.onos.event.AbstractEvent;
4import org.onlab.onos.net.DeviceId;
5
6/**
7 * Describes infrastructure device event.
8 */
9public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceId> {
10
11 InstanceId master;
12
13 /**
14 * Type of mastership events.
15 */
16 public enum Type {
17 /**
18 * Signifies that the master for a device has changed.
19 */
20 MASTER_CHANGED
21 }
22
23 /**
24 * Creates an event of a given type and for the specified device, master,
25 * and the current time.
26 *
27 * @param type device event type
28 * @param device event device subject
29 * @param master master ID subject
30 */
31 protected MastershipEvent(Type type, DeviceId device, InstanceId master) {
32 super(type, device);
33 this.master = master;
34 }
35
36 /**
37 * Creates an event of a given type and for the specified device, master,
38 * and time.
39 *
40 * @param type mastership event type
41 * @param device event device subject
42 * @param master master ID subject
43 * @param time occurrence time
44 */
45 protected MastershipEvent(Type type, DeviceId device, InstanceId master, long time) {
46 super(type, device, time);
47 this.master = master;
48 }
49
50 /**
51 * Returns the current master's ID as a subject.
52 *
53 * @return master ID subject
54 */
55 public InstanceId master() {
56 return master;
57 }
58}