blob: b83c99b8c7766435ff6be97346d79f5cd50935fb [file] [log] [blame]
Jonathan Harte37e4e22014-05-13 19:12:02 -07001package net.onrc.onos.core.topology;
2
Pavlin Radoslavova5637c02014-07-30 15:55:11 -07003import static com.google.common.base.Preconditions.checkNotNull;
Yuta HIGUCHIbf0a8712014-06-30 18:59:46 -07004
Jonathan Harte37e4e22014-05-13 19:12:02 -07005
Yuta HIGUCHIc45e0b62014-06-24 22:34:20 -07006/**
7 * Base class for Topology Objects.
8 */
Yuta HIGUCHI692e68e2014-07-09 18:08:02 -07009public abstract class TopologyObject implements ITopologyElement {
Jonathan Harte37e4e22014-05-13 19:12:02 -070010
Yuta HIGUCHIc45e0b62014-06-24 22:34:20 -070011 /**
Yuta HIGUCHI8b389a72014-07-18 13:50:00 -070012 * Topology snapshot this object belongs to.
Yuta HIGUCHIc45e0b62014-06-24 22:34:20 -070013 */
Yuta HIGUCHI8b389a72014-07-18 13:50:00 -070014 protected volatile TopologyInternal topology;
15
16 // XXX Updater to be used once we implement snapshot update.
17 // Should it be static or not.
18 // static: Low memory consumption, but higher contention on atomic update
19 // non-static: Updater per instance, but less chance of contention
20// private static final AtomicReferenceFieldUpdater<TopologyObject, TopologyImpl>
21// TOPOLOGY_UPDATER =
22// AtomicReferenceFieldUpdater.newUpdater(
23// TopologyObject.class, TopologyImpl.class, "topology");
Jonathan Harte37e4e22014-05-13 19:12:02 -070024
Yuta HIGUCHIc45e0b62014-06-24 22:34:20 -070025 /**
26 * Constructor.
27 *
28 * @param topology Topology instance this object belongs to
29 */
Yuta HIGUCHI8b389a72014-07-18 13:50:00 -070030 protected TopologyObject(TopologyInternal topology) {
Pavlin Radoslavova5637c02014-07-30 15:55:11 -070031 this.topology = checkNotNull(topology);
Jonathan Harte37e4e22014-05-13 19:12:02 -070032 }
33
Yuta HIGUCHI8b389a72014-07-18 13:50:00 -070034 // TODO Add method to replace topology snapshot
35 // - Request TopologyManager for latest TopologyImpl and swap?
36 // - Make caller specify TopologyImpl instance?
37 // -
38
Praseed Balakrishnan57ed8432014-06-26 11:49:56 -070039
40 /**
41 * Returns the type of topology object.
42 *
43 * @return the type of the topology object
44 */
Yuta HIGUCHI692e68e2014-07-09 18:08:02 -070045 @Override
Praseed Balakrishnan57ed8432014-06-26 11:49:56 -070046 public abstract String getType();
47
48
Jonathan Harte37e4e22014-05-13 19:12:02 -070049}