Added a new module: ONOS intent metrics application

It can be used as an Intent-related event and event metrics collector.
It can be loaded by one of the following two (new) features:
     onos-app-metrics, onos-app-metrics-intent

After loading the module, it subscribes for intent-related events
and keeps the following state:
 (a) The last 100 events
 (b) The timestamp of the last event (ms after epoch) as observed by this
     module for each event type: SUBMITTED, INSTALLED, WITHDRAWN.
     The missing event type is the equivalent of "Withdraw Requested"
 (c) The rate of each intent event type: count, median rate, average rate
      over the last 1, 5 or 15 minutes

The following CLI commands are added:
 * onos:intents-events
   Shows the last 100 intent events
 * onos:intents-events-metrics
   Shows the timestamp of the last event (ms after epoch) as observed by
   this module for each event type, and the rate of the topology
   events (for each event type): see (b) and (c) above

Change-Id: I9f23e9086bbd433b8f24283539abdeb97e199e2e
diff --git a/apps/metrics/intent/src/main/java/org/onlab/onos/metrics/intent/IntentMetricsService.java b/apps/metrics/intent/src/main/java/org/onlab/onos/metrics/intent/IntentMetricsService.java
new file mode 100644
index 0000000..4acd00f
--- /dev/null
+++ b/apps/metrics/intent/src/main/java/org/onlab/onos/metrics/intent/IntentMetricsService.java
@@ -0,0 +1,85 @@
+package org.onlab.onos.metrics.intent;
+
+import java.util.List;
+
+import com.codahale.metrics.Gauge;
+import com.codahale.metrics.Meter;
+import org.onlab.onos.net.intent.IntentEvent;
+
+/**
+ * Service interface exported by IntentMetrics.
+ */
+public interface IntentMetricsService {
+    /**
+     * Gets the last saved intent events.
+     *
+     * @return the last saved intent events.
+     */
+    public List<IntentEvent> getEvents();
+
+    /**
+     * Gets the Metrics' Gauge for the intent SUBMITTED event timestamp
+     * (ms from the epoch).
+     *
+     * @return the Metrics' Gauge for the intent SUBMITTED event timestamp
+     * (ms from the epoch)
+     */
+    public Gauge<Long> intentSubmittedTimestampEpochMsGauge();
+
+    /**
+     * Gets the Metrics' Gauge for the intent INSTALLED event timestamp
+     * (ms from the epoch).
+     *
+     * @return the Metrics' Gauge for the intent INSTALLED event timestamp
+     * (ms from the epoch)
+     */
+    public Gauge<Long> intentInstalledTimestampEpochMsGauge();
+
+    /**
+     * Gets the Metrics' Gauge for the intent WITHDRAW_REQUESTED event
+     * timestamp (ms from the epoch).
+     *
+     * TODO: This intent event is not implemented yet.
+     *
+     * @return the Metrics' Gauge for the intent WITHDRAW_REQUESTED event
+     * timestamp (ms from the epoch)
+     */
+    public Gauge<Long> intentWithdrawRequestedTimestampEpochMsGauge();
+
+    /**
+     * Gets the Metrics' Gauge for the intent WITHDRAWN event timestamp
+     * (ms from the epoch).
+     *
+     * @return the Metrics' Gauge for the intent WITHDRAWN event timestamp
+     * (ms from the epoch)
+     */
+    public Gauge<Long> intentWithdrawnTimestampEpochMsGauge();
+
+    /**
+     * Gets the Metrics' Meter for the submitted intents event rate.
+     *
+     * @return the Metrics' Meter for the submitted intents event rate
+     */
+    public Meter intentSubmittedRateMeter();
+
+    /**
+     * Gets the Metrics' Meter for the installed intents event rate.
+     *
+     * @return the Metrics' Meter for the installed intent event rate
+     */
+    public Meter intentInstalledRateMeter();
+
+    /**
+     * Gets the Metrics' Meter for the withdraw requested intents event rate.
+     *
+     * @return the Metrics' Meter for the withdraw requested intents event rate
+     */
+    public Meter intentWithdrawRequestedRateMeter();
+
+    /**
+     * Gets the Metrics' Meter for the withdraw completed intents event rate.
+     *
+     * @return the Metrics' Meter for the withdraw completed intents event rate
+     */
+    public Meter intentWithdrawnRateMeter();
+}