Adding persistence to the gossip application store.
Change-Id: Ib1382f9d1009297dde902f0d3e0daf27596587c5
diff --git a/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java b/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java
index 9003f0d..d60f74b 100644
--- a/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java
+++ b/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java
@@ -121,6 +121,17 @@
}
/**
+ * Returns the timestamp in millis since start of epoch, of when the
+ * specified application was last modified or changed state.
+ *
+ * @param appName application name
+ * @return number of millis since start of epoch
+ */
+ public long getUpdateTime(String appName) {
+ return appFile(appName, APP_XML).lastModified();
+ }
+
+ /**
* Loads the application descriptor from the specified application archive
* stream and saves the stream in the appropriate application archive
* directory.
@@ -313,7 +324,7 @@
*/
protected boolean setActive(String appName) {
try {
- return appFile(appName, "active").createNewFile();
+ return appFile(appName, "active").createNewFile() && updateTime(appName);
} catch (IOException e) {
throw new ApplicationException("Unable to mark app as active", e);
}
@@ -326,7 +337,17 @@
* @return true if file was deleted
*/
protected boolean clearActive(String appName) {
- return appFile(appName, "active").delete();
+ return appFile(appName, "active").delete() && updateTime(appName);
+ }
+
+ /**
+ * Updates the time-stamp of the app descriptor file.
+ *
+ * @param appName application name
+ * @return true if the app descriptor was updated
+ */
+ private boolean updateTime(String appName) {
+ return appFile(appName, APP_XML).setLastModified(System.currentTimeMillis());
}
/**