From eb9a19b571f851870fdd2cf4c1702c1ec5dcb545 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Tue, 22 Aug 2017 01:26:51 +0000 Subject: [PATCH] Refactor TableConsumable --- orchagent/orch.cpp | 2 +- orchagent/orch.h | 9 +++++---- orchagent/orchdaemon.cpp | 7 ++++--- orchagent/orchdaemon.h | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index fcb29aceaa2..94ba72261f9 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -59,7 +59,7 @@ vector Orch::getSelectables() return selectables; } -bool Orch::hasSelectable(ConsumerStateTable *selectable) const +bool Orch::hasSelectable(TableConsumable *selectable) const { for(auto it : m_consumerMap) { if (it.second.m_consumer == selectable) { diff --git a/orchagent/orch.h b/orchagent/orch.h index 096eea8361e..2869c3d1720 100644 --- a/orchagent/orch.h +++ b/orchagent/orch.h @@ -10,8 +10,9 @@ extern "C" { } #include "dbconnector.h" +#include "table.h" +#include "consumertable.h" #include "consumerstatetable.h" -#include "producerstatetable.h" using namespace std; using namespace swss; @@ -40,8 +41,8 @@ typedef pair type_map_pair; typedef map SyncMap; struct Consumer { - Consumer(ConsumerStateTable* consumer) :m_consumer(consumer) { } - ConsumerStateTable* m_consumer; + Consumer(TableConsumable* consumer) : m_consumer(consumer) { } + TableConsumable* m_consumer; /* Store the latest 'golden' status */ SyncMap m_toSync; }; @@ -65,7 +66,7 @@ class Orch virtual ~Orch(); vector getSelectables(); - bool hasSelectable(ConsumerStateTable* s) const; + bool hasSelectable(TableConsumable* s) const; bool execute(string tableName); /* Iterate all consumers in m_consumerMap and run doTask(Consumer) */ diff --git a/orchagent/orchdaemon.cpp b/orchagent/orchdaemon.cpp index fca6deb3e43..b9a2846b08d 100644 --- a/orchagent/orchdaemon.cpp +++ b/orchagent/orchdaemon.cpp @@ -138,8 +138,9 @@ void OrchDaemon::start() continue; } - Orch *o = getOrchByConsumer((ConsumerStateTable *)s); - o->execute(((ConsumerStateTable *)s)->getTableName()); + TableConsumable *c = (TableConsumable *)s; + Orch *o = getOrchByConsumer(c); + o->execute(c->getTableName()); /* After each iteration, periodically check all m_toSync map to * execute all the remaining tasks that need to be retried. */ @@ -151,7 +152,7 @@ void OrchDaemon::start() } } -Orch *OrchDaemon::getOrchByConsumer(ConsumerStateTable *c) +Orch *OrchDaemon::getOrchByConsumer(TableConsumable *c) { SWSS_LOG_ENTER(); diff --git a/orchagent/orchdaemon.h b/orchagent/orchdaemon.h index 36ae5d22e31..aea2dddb3d0 100644 --- a/orchagent/orchdaemon.h +++ b/orchagent/orchdaemon.h @@ -34,7 +34,7 @@ class OrchDaemon std::vector m_orchList; Select *m_select; - Orch *getOrchByConsumer(ConsumerStateTable *c); + Orch *getOrchByConsumer(TableConsumable *c); void flush(); };