[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/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java
index a770e97..943ad84 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java
@@ -29,31 +29,85 @@
 
     private static final Logger log = getLogger(DefaultFlowEntry.class);
 
+    private static final long DEFAULT_LAST_SEEN = -1;
+    private static final int DEFAULT_ERR_CODE = -1;
+    private static final int DEFAULT_ERR_TYPE = -1;
+
     /* Stored in nanoseconds (allows for 292 years) */
     private long life;
 
     private long packets;
     private long bytes;
     private FlowEntryState state;
+    private FlowLiveType liveType;
 
-    private long lastSeen = -1;
+    private long lastSeen = DEFAULT_LAST_SEEN;
 
     private final int errType;
 
     private final int errCode;
 
+    /**
+     * Creates a flow entry of flow table specified with the flow rule, state
+     * and statistic information.
+     *
+     * @param rule the flow rule
+     * @param state the flow state
+     * @param life the duration second of flow
+     * @param lifeTimeUnit life time unit
+     * @param packets the number of packets of this flow
+     * @param bytes the the number of bytes of this flow
+     */
     public DefaultFlowEntry(FlowRule rule, FlowEntryState state,
                             long life, TimeUnit lifeTimeUnit, long packets, long bytes) {
         super(rule);
         this.state = state;
         this.life = lifeTimeUnit.toNanos(life);
+        this.liveType = FlowLiveType.UNKNOWN;
         this.packets = packets;
         this.bytes = bytes;
-        this.errCode = -1;
-        this.errType = -1;
+        this.errCode = DEFAULT_ERR_CODE;
+        this.errType = DEFAULT_ERR_TYPE;
         this.lastSeen = System.currentTimeMillis();
     }
 
+    /**
+     * Creates a flow entry of flow table specified with the flow rule, state
+     * and statistic information.
+     *
+     * @param rule the flow rule
+     * @param state the flow state
+     * @param life the duration second of flow
+     * @param lifeTimeUnit life time unit
+     * @param liveType the flow live type, i.e., IMMEDIATE, SHORT, MID, LONG
+     * @param packets the number of packets of this flow
+     * @param bytes the the number of bytes of this flow
+     */
+    public DefaultFlowEntry(FlowRule rule, FlowEntryState state,
+                            long life, TimeUnit lifeTimeUnit, FlowLiveType liveType,
+                            long packets, long bytes) {
+        this(rule, state, life, lifeTimeUnit, packets, bytes);
+        this.liveType = liveType;
+    }
+
+    /**
+     * Creates a flow entry of flow table specified with the flow rule, state,
+     * live type and statistic information.
+     *
+     * @param rule the flow rule
+     * @param state the flow state
+     * @param lifeSecs the duration second of flow
+     * @param liveType the flow live type, i.e., IMMEDIATE, SHORT, MID, LONG
+     * @param packets the number of packets of this flow
+     * @param bytes the the number of bytes of this flow
+     */
+    public DefaultFlowEntry(FlowRule rule, FlowEntryState state,
+                            long lifeSecs, FlowLiveType liveType,
+                            long packets, long bytes) {
+        this(rule, state, lifeSecs, SECONDS, packets, bytes);
+        this.liveType = liveType;
+    }
+
     public DefaultFlowEntry(FlowRule rule, FlowEntryState state,
                             long lifeSecs, long packets, long bytes) {
         this(rule, state, lifeSecs, SECONDS, packets, bytes);
@@ -63,6 +117,14 @@
         this(rule, FlowEntryState.PENDING_ADD, 0, 0, 0);
     }
 
+    /**
+     * Creates a flow entry of flow table specified with the flow rule, state,
+     * live type and statistic information.
+     *
+     * @param rule the flow rule
+     * @param errType the error type
+     * @param errCode the error code
+     */
     public DefaultFlowEntry(FlowRule rule, int errType, int errCode) {
         super(rule);
         this.state = FlowEntryState.FAILED;
@@ -82,6 +144,11 @@
     }
 
     @Override
+    public FlowLiveType liveType() {
+        return liveType;
+    }
+
+    @Override
     public long packets() {
         return packets;
     }
@@ -122,6 +189,11 @@
     }
 
     @Override
+    public void setLiveType(FlowLiveType liveType) {
+        this.liveType = liveType;
+    }
+
+    @Override
     public void setPackets(long packets) {
         this.packets = packets;
     }
@@ -146,6 +218,13 @@
         return toStringHelper(this)
                 .add("rule", super.toString())
                 .add("state", state)
+                .add("life", life)
+                .add("liveType", liveType)
+                .add("packets", packets)
+                .add("bytes", bytes)
+                .add("errCode", errCode)
+                .add("errType", errType)
+                .add("lastSeen", lastSeen)
                 .toString();
     }
 }