Add invalidation mechanism for plugins 72/30472/2
authorZofia Abramowska <z.abramowska@samsung.com>
Tue, 18 Nov 2014 16:04:33 +0000 (17:04 +0100)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Mon, 24 Nov 2014 20:00:31 +0000 (12:00 -0800)
Every time the cynara storage is changed all data stored in
service and client plugins should be invalidated.

Change-Id: I7537aa8a6d3ea28efed0f3e0f986ae51d7f9d344

src/client-common/cache/CapacityCache.cpp
src/client-common/plugins/NaiveInterpreter.h
src/common/plugin/ExternalPluginInterface.h
src/common/plugin/PluginManager.cpp
src/common/plugin/PluginManager.h
src/service/logic/Logic.cpp

index 3174744..25ae6ad 100644 (file)
@@ -87,6 +87,10 @@ int CapacityCache::get(const ClientSession &session, const PolicyKey &key) {
 void CapacityCache::clear(void) {
     m_keyUsage.clear();
     m_keyValue.clear();
+    m_pluginManager.invalidateAll();
+    for (auto &plugin : m_plugins) {
+        plugin.second->invalidate();
+    }
 }
 
 std::string CapacityCache::keyToString(const PolicyKey &key) {
index 8099362..059554d 100644 (file)
@@ -48,6 +48,8 @@ public:
     const std::vector<PolicyType> &getSupportedPolicyTypes(void) {
         return s_supportedTypes;
     }
+
+    void invalidate(void) {}
 private:
     static const std::vector<PolicyType> s_supportedTypes;
 };
index bf3c7fe..ddd8363 100644 (file)
@@ -52,6 +52,13 @@ public:
      * Policy type supported by plugin.
      */
     virtual const std::vector<PolicyType> &getSupportedPolicyTypes(void) = 0;
+
+    /**
+     * Informs, that every data stored based on previously given input
+     * should be invalidated.
+     */
+    virtual void invalidate(void) = 0;
+
     virtual ~ExternalPluginInterface() {}
 };
 
index 8062683..c8a38c5 100644 (file)
@@ -65,6 +65,12 @@ ExternalPluginPtr PluginManager::getPlugin(PolicyType pType) {
     return m_plugins[pType];
 }
 
+void PluginManager::invalidateAll(void) {
+    for (auto &plugin : m_plugins) {
+        plugin.second->invalidate();
+    }
+}
+
 void PluginManager::loadPlugins(void) {
     struct dirent **nameList = NULL;
     int fileAmount = scandir(m_dir.c_str(), &nameList, pluginFilter, alphasort);
index c2372e6..8de33ae 100644 (file)
@@ -38,6 +38,7 @@ class PluginManager {
 public:
     PluginManager(const std::string &pluginDir);
     ExternalPluginPtr getPlugin(PolicyType pType);
+    void invalidateAll(void);
     ~PluginManager();
 
 private:
index 8f51af5..684eac3 100644 (file)
@@ -324,6 +324,7 @@ void Logic::contextClosed(RequestContextPtr context) {
 void Logic::onPoliciesChanged(void) {
     m_storage->save();
     m_socketManager->disconnectAllClients();
+    m_pluginManager->invalidateAll();
     //todo remove all saved contexts (if there will be any saved contexts)
 }