[newOpenTAM] new Upgraded AFM and FlowStatisticService

New Upgraded AFM(Adaptive Flow Monitoring) and FlowStatisticService.
  .Reabsed from master 2016.12.06, and assumed avgPollInterval in FlowStatisticService with flowPollFrequency in case adativeFlowSampling is true or false
  .Fixed Yuta HIGUCHI comments, 2016.12.03
  .Fixed checkstyle warning
  .Rebased and added interrupted flag for exiting while() loop when IterruptException is caught in NewAdaptiveFlowStatsCollector.java

  .Fixed and added javadocs from Thomas Vachuska's comment
  .Removed synchronized block in OpenFlowRuleProvider.java for avoiding performance degradation
  .Rebased from master 2016.10.13 1.8.0.SNAPSHOT
  .Rebased from master 2016.09.09
  .Fixed Yuta HIGUCHI's comments
   (made default getFlowEntriesByLiveType interface,
    added checkArgument() for StoredFlowEntry,
    added @Deprecated annotation @deprecated javadoc,
    added Thread.currentThread.interrupt()
    and fixed Default Adaptive Flow Sampling value with false.)

  .Rebased from master branch
  .Fix typo in FlowRuleService.java comment line
  .Quick Bug fix in NewAdaptiveFlowStatCollector
  .master rebased for fixing build Failure
  .Removed synchronized block in FlowRuleProvider and NewAdaptiveFlowStatCollector for performance upgrade

  .Removed duplicated flow entries in NewAdaptiveFlowStatsCollector
  .Removed additional operation (add/remove/mod) of flow entry in OpenFlowRuleProvider
  .Set default adaptiveFlowSampling value with true
  .Added liveType (IMMEDIATE, SHORT, MID, LONG) member variable in FlowEntry
  .New added PollInterval static class for pollInterval value adjustment
  .Updated FlowEntryBuilder and FlowEntry constructor
  .Added liveType print in FlowListCommand CLI
  .Removed FlowStatisticStore, used existing StatisticStore
  .New added FlowEntryWithLoad for replacing the old TypedFlowEntryWithLoad
  .Added new interfaces in FlowStatisticService
  .Updated GetFlowStatistics CLI for using new interfaces
  .All Typedxxx classes are deprecated

  .new created review 9292 from review 9232
  .fixed Jian Li's review comment from review 9232
  .fixed Build failure in core/net/BUCK file

Change-Id: I7a0e39c5220a2b279b68a195347c183b5bdf1a49
diff --git a/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java b/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
index 9de96f9..bd7a246 100644
--- a/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
@@ -59,7 +59,7 @@
     public static final String ANY = "any";
 
     private static final String LONG_FORMAT = "    id=%s, state=%s, bytes=%s, "
-            + "packets=%s, duration=%s, priority=%s, tableId=%s, appId=%s, "
+            + "packets=%s, duration=%s, liveType=%s, priority=%s, tableId=%s, appId=%s, "
             + "payLoad=%s, selector=%s, treatment=%s";
 
     private static final String SHORT_FORMAT = "    %s, bytes=%s, packets=%s, "
@@ -237,7 +237,7 @@
             } else {
                 ApplicationId appId = coreService.getAppId(f.appId());
                 print(LONG_FORMAT, Long.toHexString(f.id().value()), f.state(),
-                        f.bytes(), f.packets(), f.life(), f.priority(), f.tableId(),
+                        f.bytes(), f.packets(), f.life(), f.liveType(), f.priority(), f.tableId(),
                         appId != null ? appId.name() : "<none>",
                         f.payLoad() == null ? null : f.payLoad().payLoad().toString(),
                         f.selector().criteria(), f.treatment());
diff --git a/cli/src/main/java/org/onosproject/cli/net/GetFlowStatisticsCommand.java b/cli/src/main/java/org/onosproject/cli/net/GetFlowStatisticsCommand.java
index a122204..6d9ff67 100644
--- a/cli/src/main/java/org/onosproject/cli/net/GetFlowStatisticsCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/GetFlowStatisticsCommand.java
@@ -26,11 +26,12 @@
 import org.onosproject.net.Port;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.flow.TypedStoredFlowEntry;
+import org.onosproject.net.flow.FlowEntry;
+import org.onosproject.net.flow.StoredFlowEntry;
 import org.onosproject.net.flow.instructions.Instruction;
+import org.onosproject.net.statistic.FlowEntryWithLoad;
 import org.onosproject.net.statistic.FlowStatisticService;
 import org.onosproject.net.statistic.SummaryFlowEntryWithLoad;
-import org.onosproject.net.statistic.TypedFlowEntryWithLoad;
 
 import java.util.List;
 import java.util.Map;
@@ -60,7 +61,7 @@
     boolean showAll = false;
 
     @Option(name = "-t", aliases = "--topn",
-            description = "Show flow stats topn",
+            description = "Show flow stats topn entry",
             required = false, multiValued = false)
     String showTopn = null;
 
@@ -115,7 +116,7 @@
         }
 
         // convert String to FlowLiveType and check validity
-        TypedStoredFlowEntry.FlowLiveType inLiveType;
+        FlowEntry.FlowLiveType inLiveType;
         if (flowLiveType == null) {
             inLiveType = null;
         } else {
@@ -147,20 +148,20 @@
             }
 
             // print show topn head line with type
-            print("deviceId=%s, show TOPN=%s flows, live type=%s, instruction type=%s",
+            print("deviceId=%s, show TOPN=%s flows, liveType=%s, instruction type=%s",
                     deviceUri,
                     Integer.toString(topn),
                     flowLiveType == null ? "ALL" : flowLiveType,
                     instructionType == null ? "ALL" : instructionType);
             if (ingressPortNumber == null) {
-                Map<ConnectPoint, List<TypedFlowEntryWithLoad>> typedFlowLoadMap =
+                Map<ConnectPoint, List<FlowEntryWithLoad>> typedFlowLoadMap =
                           flowStatsService.loadTopnByType(device, inLiveType, inInstructionType, topn);
                 // print all ports topn flows load for a given device
                 for (ConnectPoint cp : typedFlowLoadMap.keySet()) {
                     printPortFlowsLoad(cp, typedFlowLoadMap.get(cp));
                 }
             } else {
-                List<TypedFlowEntryWithLoad> typedFlowLoad =
+                List<FlowEntryWithLoad> typedFlowLoad =
                         flowStatsService.loadTopnByType(device, ingressPortNumber, inLiveType, inInstructionType, topn);
                 // print device/port topn flows load
                 ConnectPoint cp = new ConnectPoint(ingressDeviceId, ingressPortNumber);
@@ -168,19 +169,19 @@
             }
         } else if (showAll) { // is true?
             // print show all head line with type
-            print("deviceId=%s, show ALL flows, live type=%s, instruction type=%s",
+            print("deviceId=%s, show ALL flows, liveType=%s, instruction type=%s",
                     deviceUri,
                     flowLiveType == null ? "ALL" : flowLiveType,
                     instructionType == null ? "ALL" : instructionType);
             if (ingressPortNumber == null) {
-                Map<ConnectPoint, List<TypedFlowEntryWithLoad>> typedFlowLoadMap =
+                Map<ConnectPoint, List<FlowEntryWithLoad>> typedFlowLoadMap =
                         flowStatsService.loadAllByType(device, inLiveType, inInstructionType);
                 // print all ports all flows load for a given device
                 for (ConnectPoint cp : typedFlowLoadMap.keySet()) {
                     printPortFlowsLoad(cp, typedFlowLoadMap.get(cp));
                 }
             } else {
-                List<TypedFlowEntryWithLoad> typedFlowLoad =
+                List<FlowEntryWithLoad> typedFlowLoad =
                         flowStatsService.loadAllByType(device, ingressPortNumber, inLiveType, inInstructionType);
                 // print device/port all flows load
                 ConnectPoint cp = new ConnectPoint(ingressDeviceId, ingressPortNumber);
@@ -243,24 +244,24 @@
     }
 
     /**
-     * converts string of flow live type to FloeLiveType enum.
+     * converts string of flow live type to FlowLiveType enum.
      *
      * @param liveType string representing the flow live type
-     * @return TypedStoredFlowEntry.FlowLiveType
+     * @return FlowEntry.FlowLiveType
      */
-    private TypedStoredFlowEntry.FlowLiveType getFlowLiveType(String liveType) {
+    private FlowEntry.FlowLiveType getFlowLiveType(String liveType) {
         String liveTypeUC = liveType.toUpperCase();
 
         if (liveTypeUC.equals("IMMEDIATE")) {
-            return TypedStoredFlowEntry.FlowLiveType.IMMEDIATE_FLOW;
+            return FlowEntry.FlowLiveType.IMMEDIATE;
         } else if (liveTypeUC.equals("SHORT")) {
-            return TypedStoredFlowEntry.FlowLiveType.SHORT_FLOW;
+            return FlowEntry.FlowLiveType.SHORT;
         } else if (liveTypeUC.equals("MID")) {
-            return TypedStoredFlowEntry.FlowLiveType.MID_FLOW;
+            return FlowEntry.FlowLiveType.MID;
         } else if (liveTypeUC.equals("LONG")) {
-            return TypedStoredFlowEntry.FlowLiveType.LONG_FLOW;
+            return FlowEntry.FlowLiveType.LONG;
         } else if (liveTypeUC.equals("UNKNOWN")) {
-            return TypedStoredFlowEntry.FlowLiveType.UNKNOWN_FLOW;
+            return FlowEntry.FlowLiveType.UNKNOWN;
         } else {
             return null; // flow live type error
         }
@@ -294,16 +295,16 @@
         }
     }
 
-    private void printPortFlowsLoad(ConnectPoint cp, List<TypedFlowEntryWithLoad> typedFlowLoad) {
+    private void printPortFlowsLoad(ConnectPoint cp, List<FlowEntryWithLoad> typedFlowLoad) {
        print("  deviceId/Port=%s/%s, %s flows", cp.elementId(), cp.port(), typedFlowLoad.size());
-        for (TypedFlowEntryWithLoad tfel: typedFlowLoad) {
-            TypedStoredFlowEntry tfe =  tfel.typedStoredFlowEntry();
+        for (FlowEntryWithLoad fel: typedFlowLoad) {
+            StoredFlowEntry sfe =  fel.storedFlowEntry();
             print("    flowId=%s, state=%s, liveType=%s, life=%s -> %s",
-                    Long.toHexString(tfe.id().value()),
-                    tfe.state(),
-                    tfe.flowLiveType(),
-                    tfe.life(),
-                    tfel.load().isValid() ? tfel.load() : "Load{rate=0, NOT VALID}");
+                  Long.toHexString(sfe.id().value()),
+                  sfe.state(),
+                  sfe.liveType(),
+                  sfe.life(),
+                  fel.load().isValid() ? fel.load() : "Load{rate=0, NOT VALID}");
         }
     }