Fixing topology related internal interface/class tree

- Moved TopologyInternal to more appropriate place

 --- BaseInternalTopology (was TopologyInternal)
  |
  +-- ImmutableInternalTopology (new)
  |
  +-- MutableInternalTopology (new)

- Updated TopologyImpl, etc. to implement appropriate
  *InternalTopology interface

- Added interface adaptor BaseTopologyAdaptor
   BaseInternalTopology (self-contained) -> BaseTopology (object handle)

- TopologyObjects ({Switch,Port,Link,Host}Impl) is now common
  between Mutable and Immutable variant of Topology.
   There were locks for whole Topology, but there weren't any locks
   per TopologyObject. If these instances were on MutableTopology,
   then locking should happen outside these instance method calls.

ONOS-1925

Change-Id: I0a13b4ed4b5a66b7ea8c42212c9504e6bc83d853
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyImpl.java b/src/main/java/net/onrc/onos/core/topology/TopologyImpl.java
index b50bf48..d407064 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyImpl.java
@@ -33,7 +33,7 @@
 /**
  * Class to represent an instance of Topology Snapshot.
  */
-public class TopologyImpl implements MutableTopology, TopologyInternal {
+public class TopologyImpl implements MutableTopology, MutableInternalTopology {
 
     private static final Logger log = LoggerFactory.getLogger(TopologyImpl.class);
 
@@ -51,10 +51,10 @@
     private final ConcurrentMap<SwitchPort, ConcurrentMap<String, LinkEvent>> outgoingLinks;
     private final ConcurrentMap<SwitchPort, ConcurrentMap<String, LinkEvent>> incomingLinks;
 
-    private ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
-    private Lock readLock = readWriteLock.readLock();
+    private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
+    private final Lock readLock = readWriteLock.readLock();
     // TODO use the write lock after refactor
-    private Lock writeLock = readWriteLock.writeLock();
+    private final Lock writeLock = readWriteLock.writeLock();
 
     /**
      * Create an empty Topology.
@@ -429,6 +429,24 @@
     }
 
     @Override
+    public Collection<LinkEvent> getLinkEventsFrom(SwitchPort srcPort) {
+        ConcurrentMap<String, LinkEvent> links = this.outgoingLinks.get(srcPort);
+        if (links == null) {
+            return Collections.emptyList();
+        }
+        return Collections.unmodifiableCollection(links.values());
+    }
+
+    @Override
+    public Collection<LinkEvent> getLinkEventsTo(SwitchPort dstPort) {
+        ConcurrentMap<String, LinkEvent> links = this.incomingLinks.get(dstPort);
+        if (links == null) {
+            return Collections.emptyList();
+        }
+        return Collections.unmodifiableCollection(links.values());
+    }
+
+    @Override
     public Collection<LinkEvent> getLinkEvents(final LinkTuple linkId) {
         ConcurrentMap<String, LinkEvent> links = this.outgoingLinks.get(linkId.getSrc());
         if (links == null) {
@@ -454,6 +472,11 @@
     }
 
     @Override
+    public Collection<HostEvent> getHostEvents(SwitchPort port) {
+        return Collections.unmodifiableCollection(hosts.get(port));
+    }
+
+    @Override
     public Collection<HostEvent> getAllHostEvents() {
         return Collections.unmodifiableCollection(mac2Host.values());
     }