Mercurial > hg > release > thermostat-0.7
changeset 62:c1cc0b37e8c1
Local agent clears data on shutdown.
author | Jon VanAlten <jon.vanalten@redhat.com> |
---|---|
date | Tue, 31 Jan 2012 16:56:48 -0500 |
parents | a4ac69374d2f |
children | ce467a831e45 |
files | src/com/redhat/thermostat/agent/Agent.java src/com/redhat/thermostat/agent/storage/MongoStorage.java src/com/redhat/thermostat/agent/storage/Storage.java |
diffstat | 3 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/com/redhat/thermostat/agent/Agent.java Tue Jan 31 12:01:59 2012 -0500 +++ b/src/com/redhat/thermostat/agent/Agent.java Tue Jan 31 16:56:48 2012 -0500 @@ -118,6 +118,9 @@ configWatcherThread = null; storage.removeAgentInformation(); stopBackends(); + if (config.getLocalMode()) { + storage.purge(); + } } else { logger.warning("Attempt to stop agent which is not active"); }
--- a/src/com/redhat/thermostat/agent/storage/MongoStorage.java Tue Jan 31 12:01:59 2012 -0500 +++ b/src/com/redhat/thermostat/agent/storage/MongoStorage.java Tue Jan 31 16:56:48 2012 -0500 @@ -284,4 +284,11 @@ // TODO check which processes are already being listened to. return result; } + + public void purge() { + BasicDBObject deleteKey = getAgentDBObject(); + for (DBCollection coll : collectionCache.values()) { + coll.remove(deleteKey); + } + } }
--- a/src/com/redhat/thermostat/agent/storage/Storage.java Tue Jan 31 12:01:59 2012 -0500 +++ b/src/com/redhat/thermostat/agent/storage/Storage.java Tue Jan 31 16:56:48 2012 -0500 @@ -93,4 +93,8 @@ protected abstract void updateChunkImpl(Chunk chunk); + /* Drop all data related to the currently running agent. + */ + public abstract void purge(); + }