[ONOS-4227] Port chain updated to store classifier and forwarder devices

Change-Id: Ibd772e8d524efbe8fc9a11e5091b5510a57e4f66
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortChain.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortChain.java
index c454635..879c7ea 100644
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortChain.java
+++ b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortChain.java
@@ -26,6 +26,8 @@
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.onosproject.net.DeviceId;
+
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 
@@ -43,7 +45,8 @@
 
     private final Map<FiveTuple, LoadBalanceId> sfcLoadBalanceIdMap = new ConcurrentHashMap<>();
     private final Map<LoadBalanceId, List<PortPairId>> sfcLoadBalancePathMap = new ConcurrentHashMap<>();
-
+    private final Map<LoadBalanceId, List<DeviceId>> sfcClassifiersMap = new ConcurrentHashMap<>();
+    private final Map<LoadBalanceId, List<DeviceId>> sfcForwardersMap = new ConcurrentHashMap<>();
     /**
      * Default constructor to create port chain.
      *
@@ -122,6 +125,40 @@
     }
 
     @Override
+    public void addSfcClassifiers(LoadBalanceId id, List<DeviceId> classifierList) {
+        this.sfcClassifiersMap.put(id, classifierList);
+    }
+
+    @Override
+    public void addSfcForwarders(LoadBalanceId id, List<DeviceId> forwarderList) {
+        this.sfcForwardersMap.put(id, forwarderList);
+    }
+
+    @Override
+    public void removeSfcClassifiers(LoadBalanceId id, List<DeviceId> classifierList) {
+        List<DeviceId> list = getSfcClassifiers(id);
+        list.removeAll(classifierList);
+        this.sfcForwardersMap.put(id, list);
+    }
+
+    @Override
+    public void removeSfcForwarders(LoadBalanceId id, List<DeviceId> forwarderList) {
+        List<DeviceId> list = getSfcForwarders(id);
+        list.removeAll(forwarderList);
+        this.sfcForwardersMap.put(id, list);
+    }
+
+    @Override
+    public List<DeviceId> getSfcClassifiers(LoadBalanceId id) {
+        return ImmutableList.copyOf(this.sfcClassifiersMap.get(id));
+    }
+
+    @Override
+    public List<DeviceId> getSfcForwarders(LoadBalanceId id) {
+        return ImmutableList.copyOf(this.sfcForwardersMap.get(id));
+    }
+
+    @Override
     public LoadBalanceId getLoadBalanceId(FiveTuple fiveTuple) {
         return this.sfcLoadBalanceIdMap.get(fiveTuple);
     }
@@ -132,6 +169,11 @@
     }
 
     @Override
+    public Set<LoadBalanceId> getLoadBalancePathMapKeys() {
+        return ImmutableSet.copyOf(sfcLoadBalancePathMap.keySet());
+    }
+
+    @Override
     public List<PortPairId> getLoadBalancePath(LoadBalanceId id) {
         return ImmutableList.copyOf(this.sfcLoadBalancePathMap.get(id));
     }
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChain.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChain.java
index 8a4bb95..2906411 100644
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChain.java
+++ b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChain.java
@@ -19,6 +19,8 @@
 import java.util.Optional;
 import java.util.Set;
 
+import org.onosproject.net.DeviceId;
+
 /**
  * Abstraction of an entity providing Port Chain information.
  * A Port Chain (Service Function Path) consists of
@@ -82,7 +84,55 @@
                             List<PortPairId> path);
 
     /**
-     * Get the load balance id from five tuple.
+     * Adds sfc classifiers to the given load balance id for a port chain.
+     *
+     * @param id load balance path identifier
+     * @param classifierList list of classifier devices
+     */
+    void addSfcClassifiers(LoadBalanceId id, List<DeviceId> classifierList);
+
+    /**
+     * Adds sfc forwarders to the given load balance id for a port chain.
+     *
+     * @param id load balance path identifier
+     * @param forwarderList list of forwarder devices
+     */
+    void addSfcForwarders(LoadBalanceId id, List<DeviceId> forwarderList);
+
+    /**
+     * Removes sfc classifiers to the given load balance id for a port chain.
+     *
+     * @param id load balance path identifier
+     * @param classifierList list of classifier devices
+     */
+    void removeSfcClassifiers(LoadBalanceId id, List<DeviceId> classifierList);
+
+    /**
+     * Removes sfc forwarders to the given load balance id for a port chain.
+     *
+     * @param id load balance path identifier
+     * @param forwarderList list of forwarder devices
+     */
+    void removeSfcForwarders(LoadBalanceId id, List<DeviceId> forwarderList);
+
+    /**
+     * Returns sfc classifiers to the given load balance id for a port chain.
+     *
+     * @param id load balance path identifier
+     * @return list of classifier devices
+     */
+    List<DeviceId> getSfcClassifiers(LoadBalanceId id);
+
+    /**
+     * Returns sfc forwarders to the given load balance id for a port chain.
+     *
+     * @param id load balance path identifier
+     * @return list of forwarder devices
+     */
+    List<DeviceId> getSfcForwarders(LoadBalanceId id);
+
+    /**
+     * Returns the load balance id from five tuple.
      *
      * @param fiveTuple five tuple from the packet
      * @return load balance identifier for the given packet
@@ -90,14 +140,21 @@
     LoadBalanceId getLoadBalanceId(FiveTuple fiveTuple);
 
     /**
-     * Get the keys set from load balanced id map.
+     * Returns the keys set from load balance id map.
      *
      * @return set of five tuple info
      */
     Set<FiveTuple> getLoadBalanceIdMapKeys();
 
     /**
-     * Get the load balanced path from load balance Id.
+     * Returns the keys set from load balance path map.
+     *
+     * @return set of load balance id's
+     */
+    Set<LoadBalanceId> getLoadBalancePathMapKeys();
+
+    /**
+     * Returns the load balanced path from load balance Id.
      *
      * @param id load balance id.
      * @return path containing list of port pairs
@@ -105,7 +162,7 @@
     List<PortPairId> getLoadBalancePath(LoadBalanceId id);
 
     /**
-     * Get the load balanced path from five tuple.
+     * Returns the load balanced path from five tuple.
      *
      * @param fiveTuple five tuple from the packet
      * @return path containing list of port pairs
@@ -113,7 +170,7 @@
     List<PortPairId> getLoadBalancePath(FiveTuple fiveTuple);
 
     /**
-     * Get the no of load balance paths created.
+     * Returns the no of load balance paths created.
      *
      * @return size of load balanced paths
      */