Add uptimes to device and cluster REST APIs
Change-Id: I0ccdf4e33135be4bcfd1674a76ff4b39e992268b
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 1a75e5f..54f23cd 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterService.java
@@ -20,6 +20,7 @@
import java.util.Set;
import org.joda.time.DateTime;
+import org.onlab.util.Tools;
import org.onosproject.core.Version;
import org.onosproject.event.ListenerService;
@@ -82,6 +83,21 @@
}
/**
+ * Returns a human readable form of the system time when the availability state was last updated.
+ *
+ * @param nodeId controller node identifier
+ * @return human readable string for system time when the availability state was last updated.
+ */
+ default String localStatus(NodeId nodeId) {
+ Instant lastUpdated = getLastUpdatedInstant(nodeId);
+ String timeAgo = "Never";
+ if (lastUpdated != null) {
+ timeAgo = Tools.timeAgo(lastUpdated.toEpochMilli());
+ }
+ return timeAgo;
+ }
+
+ /**
* Returns the system time when the availability state was last updated.
*
* @param nodeId controller node identifier