[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/statistic/PollInterval.java b/core/api/src/main/java/org/onosproject/net/statistic/PollInterval.java
new file mode 100644
index 0000000..ca19b58
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/statistic/PollInterval.java
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2014-2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.statistic;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * Default polling interval values.
+ */
+public final class PollInterval {
+    private static final long DEFAULT_POLL_INTERVAL = 10;
+    private static final long DEFAULT_MID_POLL_INTERVAL = 20;
+    private static final long DEFAULT_LONG_POLL_INTERVAL = 30;
+    private static final long DEFAULT_ENTIRE_POLL_INTERVAL = 60;
+
+    private static PollInterval pollIntervalInstance =
+            new PollInterval(DEFAULT_POLL_INTERVAL,
+                             DEFAULT_MID_POLL_INTERVAL,
+                             DEFAULT_LONG_POLL_INTERVAL,
+                             DEFAULT_ENTIRE_POLL_INTERVAL);
+
+    /**
+     * Indicates the flow statistics poll interval in seconds.
+     */
+    private long pollInterval = DEFAULT_POLL_INTERVAL;
+    // same as IMMEDIATE and SHORT flow live type
+
+    // These may be used in NewFlowStatsCollector
+    private long midPollInterval = DEFAULT_MID_POLL_INTERVAL; // default is 2*pollInterval
+    private long longPollInterval = DEFAULT_LONG_POLL_INTERVAL; // default is 3*pollInterval
+    private long entirePollInterval = DEFAULT_ENTIRE_POLL_INTERVAL; // default is 6*pollInterval
+
+    /**
+     * Returns the singleton PollInterval instance class for FlowStatisticService and other statistic services.
+     * This instance is only used Adaptive Flow Sampling(adaptiveFlowSampling) mode is enabled(true).
+     *
+     * @return the singleton PollInterval instance class
+     */
+    public static PollInterval getInstance() {
+        return pollIntervalInstance;
+    }
+
+    /**
+     * Creates an default poll interval.
+     */
+    protected PollInterval() {
+        this.pollInterval = DEFAULT_POLL_INTERVAL;
+        this.midPollInterval = DEFAULT_MID_POLL_INTERVAL;
+        this.longPollInterval = DEFAULT_LONG_POLL_INTERVAL;
+        this.entirePollInterval = DEFAULT_ENTIRE_POLL_INTERVAL;
+    }
+
+    // Public construction is prohibited
+    /**
+     * Creates a poll interval from the parameters.
+     *
+     * @param pollInterval  the poll interval value
+     * @param midPollInterval the mid poll interval value
+     * @param longPollInterval the long poll interval value
+     * @param entirePollInterval the entire poll interval value
+     */
+    private PollInterval(long pollInterval, long midPollInterval,
+                               long longPollInterval, long entirePollInterval) {
+        checkArgument(pollInterval > 0, "Poll interval must be greater than 0");
+        checkArgument(midPollInterval > 0 && midPollInterval > pollInterval,
+                      "Mid poll interval must be greater than 0 and pollInterval");
+        checkArgument(longPollInterval > 0 && longPollInterval > midPollInterval,
+                      "Long poll interval must be greater than 0 and midPollInterval");
+        checkArgument(entirePollInterval > 0 && entirePollInterval > longPollInterval,
+                      "Entire poll interval must be greater than 0 and longPollInterval");
+
+        this.pollInterval = pollInterval;
+        this.midPollInterval = midPollInterval;
+        this.longPollInterval = longPollInterval;
+        this.entirePollInterval = entirePollInterval;
+    }
+
+    /**
+     * Sets the poll interval in seconds. Used solely for the purpose of
+     * computing the load.
+     *
+     * @param newPollInterval poll interval duration in seconds
+     */
+    public void setPollInterval(long newPollInterval) {
+        checkArgument(newPollInterval > 0, "Poll interval must be greater than 0");
+
+        pollInterval = newPollInterval;
+    }
+
+    /**
+     * Sets the mid poll interval in seconds. Used solely for the purpose of
+     * computing the load.
+     *
+     * @param newPollInterval poll interval duration in seconds
+     */
+    public void setMidPollInterval(long newPollInterval) {
+        checkArgument(newPollInterval > 0 && newPollInterval > pollInterval,
+                      "Mid poll interval must be greater than 0 and pollInterval");
+
+        midPollInterval = newPollInterval;
+    }
+
+    /**
+     * Sets the long poll interval in seconds. Used solely for the purpose of
+     * computing the load.
+     *
+     * @param newPollInterval poll interval duration in seconds
+     */
+    public void setLongPollInterval(long newPollInterval) {
+        checkArgument(newPollInterval > 0 && newPollInterval > midPollInterval,
+                      "Long poll interval must be greater than 0 and midPollInterval");
+
+        longPollInterval = newPollInterval;
+    }
+
+    /**
+     * Sets the entire poll interval in seconds. Used solely for the purpose of
+     * computing the load.
+     *
+     * @param newPollInterval poll interval duration in seconds
+     */
+    public void setEntirePollInterval(long newPollInterval) {
+        checkArgument(newPollInterval > 0 && newPollInterval > longPollInterval,
+                      "Entire poll interval must be greater than 0 and longPollInterval");
+
+        entirePollInterval = newPollInterval;
+    }
+
+    /**
+     * Returns default poll interval value in seconds.
+     *
+     * @return default poll interval
+     */
+    public long getPollInterval() {
+        return pollInterval;
+    }
+
+    /**
+     * Returns mid poll interval value in seconds.
+     *
+     * @return mid poll interval
+     */
+    public long getMidPollInterval() {
+        return midPollInterval;
+    }
+
+    /**
+     * Returns long poll interval value in seconds.
+     *
+     * @return long poll interval
+     */
+    public long getLongPollInterval() {
+        return longPollInterval;
+    }
+
+    /**
+     * Returns entire poll interval value in seconds.
+     *
+     * @return entire poll interval
+     */
+    public long getEntirePollInterval() {
+        return entirePollInterval;
+    }
+
+    /**
+     * Returns average poll interval value in seconds.
+     *
+     * @return average poll interval
+     */
+    public long getAvgPollInterval() {
+        return (pollInterval + midPollInterval + longPollInterval) / 3;
+    }
+}