functional stats service

Change-Id: I90de3aa5d7721db8ef6a154e122af8b446243f60
diff --git a/core/api/src/main/java/org/onlab/onos/net/statistic/DefaultLoad.java b/core/api/src/main/java/org/onlab/onos/net/statistic/DefaultLoad.java
new file mode 100644
index 0000000..1826dde
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/statistic/DefaultLoad.java
@@ -0,0 +1,56 @@
+package org.onlab.onos.net.statistic;
+
+import org.onlab.onos.net.flow.FlowRuleProvider;
+
+/**
+ * Implementation of a load.
+ */
+public class DefaultLoad implements Load {
+
+    private final boolean isValid;
+    private final long current;
+    private final long previous;
+    private final long time;
+
+    /**
+     * Creates an invalid load.
+     */
+    public DefaultLoad() {
+        this.isValid = false;
+        this.time = System.currentTimeMillis();
+        this.current = -1;
+        this.previous = -1;
+    }
+
+    /**
+     * Creates a load value from the parameters.
+     * @param current the current value
+     * @param previous the previous value
+     */
+    public DefaultLoad(long current, long previous) {
+        this.current = current;
+        this.previous = previous;
+        this.time = System.currentTimeMillis();
+        this.isValid = true;
+    }
+
+    @Override
+    public long rate() {
+        return (current - previous) / FlowRuleProvider.POLL_INTERVAL;
+    }
+
+    @Override
+    public long latest() {
+        return current;
+    }
+
+    @Override
+    public boolean isValid() {
+        return isValid;
+    }
+
+    @Override
+    public long time() {
+        return time;
+    }
+}
diff --git a/core/api/src/main/java/org/onlab/onos/net/statistic/Load.java b/core/api/src/main/java/org/onlab/onos/net/statistic/Load.java
index 534b10c..b609f2b 100644
--- a/core/api/src/main/java/org/onlab/onos/net/statistic/Load.java
+++ b/core/api/src/main/java/org/onlab/onos/net/statistic/Load.java
@@ -6,15 +6,27 @@
 public interface Load {
 
     /**
-     * Obtain the current observed rate on a link.
+     * Obtain the current observed rate (in bytes/s) on a link.
      * @return long value
      */
     long rate();
 
     /**
-     * Obtain the latest counter viewed on that link.
+     * Obtain the latest bytes counter viewed on that link.
      * @return long value
      */
     long latest();
 
+    /**
+     * Indicates whether this load was built on valid values.
+     * @return boolean
+     */
+    boolean isValid();
+
+    /**
+     * Returns when this value was seen.
+     * @return epoch time
+     */
+    long time();
+
 }