blob: 445c2d858a232544b6b7875617b89e7e014ecc89 [file] [log] [blame]
Jonathan Harte37e4e22014-05-13 19:12:02 -07001package net.onrc.onos.core.topology;
2
Yuta HIGUCHIbf0a8712014-06-30 18:59:46 -07003import org.apache.commons.lang.Validate;
4
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) {
Yuta HIGUCHIbf0a8712014-06-30 18:59:46 -070031 Validate.notNull(topology);
Jonathan Harte37e4e22014-05-13 19:12:02 -070032 this.topology = topology;
33 }
34
Yuta HIGUCHI8b389a72014-07-18 13:50:00 -070035 // TODO Add method to replace topology snapshot
36 // - Request TopologyManager for latest TopologyImpl and swap?
37 // - Make caller specify TopologyImpl instance?
38 // -
39
Praseed Balakrishnan57ed8432014-06-26 11:49:56 -070040
41 /**
42 * Returns the type of topology object.
43 *
44 * @return the type of the topology object
45 */
Yuta HIGUCHI692e68e2014-07-09 18:08:02 -070046 @Override
Praseed Balakrishnan57ed8432014-06-26 11:49:56 -070047 public abstract String getType();
48
49
Jonathan Harte37e4e22014-05-13 19:12:02 -070050}