Jonathan Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.topology; |
| 2 | |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 3 | import static com.google.common.base.Preconditions.checkNotNull; |
Yuta HIGUCHI | bf0a871 | 2014-06-30 18:59:46 -0700 | [diff] [blame] | 4 | |
Jonathan Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 5 | |
Yuta HIGUCHI | c45e0b6 | 2014-06-24 22:34:20 -0700 | [diff] [blame] | 6 | /** |
| 7 | * Base class for Topology Objects. |
| 8 | */ |
Yuta HIGUCHI | 692e68e | 2014-07-09 18:08:02 -0700 | [diff] [blame] | 9 | public abstract class TopologyObject implements ITopologyElement { |
Jonathan Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 10 | |
Yuta HIGUCHI | c45e0b6 | 2014-06-24 22:34:20 -0700 | [diff] [blame] | 11 | /** |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 12 | * Topology snapshot this object belongs to. |
Yuta HIGUCHI | c45e0b6 | 2014-06-24 22:34:20 -0700 | [diff] [blame] | 13 | */ |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 14 | 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 Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 24 | |
Yuta HIGUCHI | c45e0b6 | 2014-06-24 22:34:20 -0700 | [diff] [blame] | 25 | /** |
| 26 | * Constructor. |
| 27 | * |
| 28 | * @param topology Topology instance this object belongs to |
| 29 | */ |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 30 | protected TopologyObject(TopologyInternal topology) { |
Pavlin Radoslavov | a5637c0 | 2014-07-30 15:55:11 -0700 | [diff] [blame] | 31 | this.topology = checkNotNull(topology); |
Jonathan Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 32 | } |
| 33 | |
Yuta HIGUCHI | 8b389a7 | 2014-07-18 13:50:00 -0700 | [diff] [blame] | 34 | // TODO Add method to replace topology snapshot |
| 35 | // - Request TopologyManager for latest TopologyImpl and swap? |
| 36 | // - Make caller specify TopologyImpl instance? |
| 37 | // - |
| 38 | |
Praseed Balakrishnan | 57ed843 | 2014-06-26 11:49:56 -0700 | [diff] [blame] | 39 | |
| 40 | /** |
| 41 | * Returns the type of topology object. |
| 42 | * |
| 43 | * @return the type of the topology object |
| 44 | */ |
Yuta HIGUCHI | 692e68e | 2014-07-09 18:08:02 -0700 | [diff] [blame] | 45 | @Override |
Praseed Balakrishnan | 57ed843 | 2014-06-26 11:49:56 -0700 | [diff] [blame] | 46 | public abstract String getType(); |
| 47 | |
| 48 | |
Jonathan Hart | e37e4e2 | 2014-05-13 19:12:02 -0700 | [diff] [blame] | 49 | } |