ONOS-1326: Added support for observing when node liveness status was last updated. Useful for detecting/debugging stability issues.

Change-Id: I8ffebcf3a09a51c6e3e7526986a0f05530ed757f
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterService.java b/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
index 1d21de7..3fb007d 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
@@ -17,6 +17,8 @@
 
 import java.util.Set;
 
+import org.joda.time.DateTime;
+
 /**
  * Service for obtaining information about the individual nodes within
  * the controller cluster.
@@ -54,6 +56,14 @@
     ControllerNode.State getState(NodeId nodeId);
 
     /**
+     * Returns the system time when the availability state was last updated.
+     *
+     * @param nodeId controller node identifier
+     * @return system time when the availability state was last updated.
+     */
+    DateTime getLastUpdated(NodeId nodeId);
+
+    /**
      * Adds the specified cluster event listener.
      *
      * @param listener the cluster listener
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java b/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java
index bb0c91c..4229e6a 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterStore.java
@@ -15,11 +15,12 @@
  */
 package org.onosproject.cluster;
 
-import org.onosproject.store.Store;
-import org.onlab.packet.IpAddress;
-
 import java.util.Set;
 
+import org.joda.time.DateTime;
+import org.onlab.packet.IpAddress;
+import org.onosproject.store.Store;
+
 /**
  * Manages inventory of controller cluster nodes; not intended for direct use.
  */
@@ -56,6 +57,14 @@
     ControllerNode.State getState(NodeId nodeId);
 
     /**
+     * Returns the system when the availability state was last updated.
+     *
+     * @param nodeId controller node identifier
+     * @return system time when the availability state was last updated.
+     */
+    DateTime getLastUpdated(NodeId nodeId);
+
+    /**
      * Adds a new controller node to the cluster.
      *
      * @param nodeId  controller node identifier
diff --git a/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java b/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java
index 35b5a6d..5afaec6 100644
--- a/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java
@@ -17,6 +17,8 @@
 
 import java.util.Set;
 
+import org.joda.time.DateTime;
+
 /**
  * Test adapter for the cluster service.
  */
@@ -42,6 +44,11 @@
     }
 
     @Override
+    public DateTime getLastUpdated(NodeId nodeId) {
+        return null;
+    }
+
+    @Override
     public void addListener(ClusterEventListener listener) {
     }