Skip to content

Commit

Permalink
Set Executor name as constructor phase
Browse files Browse the repository at this point in the history
Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
  • Loading branch information
jipanyang committed Aug 9, 2018
1 parent 5a114a3 commit 2bee552
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 53 deletions.
13 changes: 6 additions & 7 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ bool AclRuleDTelFlowWatchListEntry::validateAddAction(string attr_name, string a
sai_object_id_t session_oid;

if (!m_pDTelOrch ||
(attr_name != ACTION_DTEL_FLOW_OP &&
(attr_name != ACTION_DTEL_FLOW_OP &&
attr_name != ACTION_DTEL_INT_SESSION &&
attr_name != ACTION_DTEL_FLOW_SAMPLE_PERCENT &&
attr_name != ACTION_DTEL_REPORT_ALL_PACKETS))
Expand Down Expand Up @@ -1360,7 +1360,7 @@ bool AclRuleDTelFlowWatchListEntry::validateAddAction(string attr_name, string a
value.aclaction.parameter.booldata = (attr_value == DTEL_ENABLED) ? true : false;
value.aclaction.enable = (attr_value == DTEL_ENABLED) ? true : false;
}

m_actions[aclDTelActionLookup[attr_name]] = value;

return true;
Expand Down Expand Up @@ -1518,7 +1518,7 @@ bool AclRuleDTelDropWatchListEntry::validateAddAction(string attr_name, string a

value.aclaction.parameter.booldata = (attr_value == DTEL_ENABLED) ? true : false;
value.aclaction.enable = (attr_value == DTEL_ENABLED) ? true : false;

m_actions[aclDTelActionLookup[attr_name]] = value;

return true;
Expand Down Expand Up @@ -1697,9 +1697,8 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
// initialized before thread start.
auto interv = timespec { .tv_sec = COUNTERS_READ_INTERVAL, .tv_nsec = 0 };
auto timer = new SelectableTimer(interv);
auto executor = new ExecutableTimer(timer, this);
executor->setName("ACL_POLL_TIMER");
Orch::addExecutor("", executor);
auto executor = new ExecutableTimer(timer, this, "ACL_POLL_TIMER");
Orch::addExecutor(executor);
timer->start();
}

Expand Down Expand Up @@ -2436,7 +2435,7 @@ sai_status_t AclOrch::createDTelWatchListTables()
SWSS_LOG_INFO("Successfully created ACL table %s, oid: %lX", flowWLTable.description.c_str(), table_oid);

/* Create Drop watchlist ACL table */

table_attrs.clear();

dropWLTable.id = TABLE_TYPE_DTEL_DROP_WATCHLIST;
Expand Down
5 changes: 2 additions & 3 deletions orchagent/countercheckorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ CounterCheckOrch::CounterCheckOrch(DBConnector *db, vector<string> &tableNames):

auto interv = timespec { .tv_sec = COUNTER_CHECK_POLL_TIMEOUT_SEC, .tv_nsec = 0 };
auto timer = new SelectableTimer(interv);
auto executor = new ExecutableTimer(timer, this);
executor->setName("MC_COUNTERS_POLL");
Orch::addExecutor("MC_COUNTERS_POLL", executor);
auto executor = new ExecutableTimer(timer, this, "MC_COUNTERS_POLL");
Orch::addExecutor(executor);
timer->start();
}

Expand Down
5 changes: 2 additions & 3 deletions orchagent/crmorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,8 @@ CrmOrch::CrmOrch(DBConnector *db, string tableName):
// The CRM stats needs to be populated again
m_countersCrmTable->del(CRM_COUNTERS_TABLE_KEY);

auto executor = new ExecutableTimer(m_timer.get(), this);
executor->setName("CRM_COUNTERS_POLL");
Orch::addExecutor("CRM_COUNTERS_POLL", executor);
auto executor = new ExecutableTimer(m_timer.get(), this, "CRM_COUNTERS_POLL");
Orch::addExecutor(executor);
m_timer->start();
}

Expand Down
10 changes: 4 additions & 6 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@ FdbOrch::FdbOrch(DBConnector *db, string tableName, PortsOrch *port) :
{
m_portsOrch->attach(this);
m_flushNotificationsConsumer = new NotificationConsumer(db, "FLUSHFDBREQUEST");
auto flushNotifier = new Notifier(m_flushNotificationsConsumer, this);
flushNotifier->setName("FLUSHFDBREQUEST");
Orch::addExecutor("", flushNotifier);
auto flushNotifier = new Notifier(m_flushNotificationsConsumer, this, "FLUSHFDBREQUEST");
Orch::addExecutor(flushNotifier);

/* Add FDB notifications support from ASIC */
DBConnector *notificationsDb = new DBConnector(ASIC_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
m_fdbNotificationConsumer = new swss::NotificationConsumer(notificationsDb, "NOTIFICATIONS");
auto fdbNotifier = new Notifier(m_fdbNotificationConsumer, this);
fdbNotifier->setName("FDB_NOTIFICATIONS");
Orch::addExecutor("FDB_NOTIFICATIONS", fdbNotifier);
auto fdbNotifier = new Notifier(m_fdbNotificationConsumer, this, "FDB_NOTIFICATIONS");
Orch::addExecutor(fdbNotifier);

addExistingData(tableName);
}
Expand Down
4 changes: 2 additions & 2 deletions orchagent/notifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

class Notifier : public Executor {
public:
Notifier(NotificationConsumer *select, Orch *orch)
: Executor(select, orch)
Notifier(NotificationConsumer *select, Orch *orch, const string &name)
: Executor(select, orch, name)
{
}

Expand Down
8 changes: 4 additions & 4 deletions orchagent/orch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,18 +461,18 @@ void Orch::addConsumer(DBConnector *db, string tableName, int pri)
{
if (db->getDbId() == CONFIG_DB || db->getDbId() == STATE_DB)
{
addExecutor(tableName, new Consumer(new SubscriberStateTable(db, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, pri), this));
addExecutor(new Consumer(new SubscriberStateTable(db, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, pri), this, tableName));
}
else
{
addExecutor(tableName, new Consumer(new ConsumerStateTable(db, tableName, gBatchSize, pri), this));
addExecutor(new Consumer(new ConsumerStateTable(db, tableName, gBatchSize, pri), this, tableName));
}
}

void Orch::addExecutor(string executorName, Executor* executor)
void Orch::addExecutor(Executor* executor)
{
m_consumerMap.emplace(std::piecewise_construct,
std::forward_as_tuple(executorName),
std::forward_as_tuple(executor->getName()),
std::forward_as_tuple(executor));
}

Expand Down
19 changes: 5 additions & 14 deletions orchagent/orch.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ class Orch;
class Executor : public Selectable
{
public:
Executor(Selectable *selectable, Orch *orch)
Executor(Selectable *selectable, Orch *orch, const string &name)
: m_selectable(selectable)
, m_orch(orch)
, m_name(name)
{
}

Expand All @@ -95,10 +96,6 @@ class Executor : public Selectable
{
return m_name;
}
virtual void setName(string name)
{
m_name = name;
}

protected:
Selectable *m_selectable;
Expand All @@ -113,8 +110,8 @@ class Executor : public Selectable

class Consumer : public Executor {
public:
Consumer(ConsumerTableBase *select, Orch *orch)
: Executor(select, orch)
Consumer(ConsumerTableBase *select, Orch *orch, const string &name)
: Executor(select, orch, name)
{
}

Expand All @@ -128,12 +125,6 @@ class Consumer : public Executor {
return getConsumerTable()->getTableName();
}


string getName() const
{
return getConsumerTable()->getTableName();
}

int getDbId() const
{
return getConsumerTable()->getDbId();
Expand Down Expand Up @@ -205,7 +196,7 @@ class Orch
ref_resolve_status resolveFieldRefArray(type_map&, const string&, KeyOpFieldsValuesTuple&, vector<sai_object_id_t>&);

/* Note: consumer will be owned by this class */
void addExecutor(string executorName, Executor* executor);
void addExecutor(Executor* executor);
Executor *getExecutor(string executorName);
private:
void addConsumer(DBConnector *db, string tableName, int pri = default_orch_pri);
Expand Down
10 changes: 4 additions & 6 deletions orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,15 +668,13 @@ PfcWdSwOrch<DropHandler, ForwardHandler>::PfcWdSwOrch(
auto consumer = new swss::NotificationConsumer(
PfcWdSwOrch<DropHandler, ForwardHandler>::getCountersDb().get(),
"PFC_WD");
auto wdNotification = new Notifier(consumer, this);
wdNotification->setName("PFC_WD");
Orch::addExecutor("PFC_WD", wdNotification);
auto wdNotification = new Notifier(consumer, this, "PFC_WD");
Orch::addExecutor(wdNotification);

auto interv = timespec { .tv_sec = COUNTER_CHECK_POLL_TIMEOUT_SEC, .tv_nsec = 0 };
auto timer = new SelectableTimer(interv);
auto executor = new ExecutableTimer(timer, this);
executor->setName("PFC_WD_COUNTERS_POLL");
Orch::addExecutor("PFC_WD_COUNTERS_POLL", executor);
auto executor = new ExecutableTimer(timer, this, "PFC_WD_COUNTERS_POLL");
Orch::addExecutor(executor);
timer->start();
}

Expand Down
5 changes: 2 additions & 3 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,8 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
/* Add port oper status notification support */
DBConnector *notificationsDb = new DBConnector(ASIC_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
m_portStatusNotificationConsumer = new swss::NotificationConsumer(notificationsDb, "NOTIFICATIONS");
auto portStatusNotificatier = new Notifier(m_portStatusNotificationConsumer, this);
portStatusNotificatier->setName("PORT_STATUS_NOTIFICATIONS");
Orch::addExecutor("PORT_STATUS_NOTIFICATIONS", portStatusNotificatier);
auto portStatusNotificatier = new Notifier(m_portStatusNotificationConsumer, this, "PORT_STATUS_NOTIFICATIONS");
Orch::addExecutor(portStatusNotificatier);

// Try warm start
bake();
Expand Down
5 changes: 2 additions & 3 deletions orchagent/switchorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ SwitchOrch::SwitchOrch(DBConnector *db, string tableName) :
m_db(db)
{
m_restartCheckNotificationConsumer = new NotificationConsumer(db, "RESTARTCHECK");
auto restartCheckNotifier = new Notifier(m_restartCheckNotificationConsumer, this);
restartCheckNotifier->setName("RESTARTCHECK");
Orch::addExecutor("RESTARTCHECK", restartCheckNotifier);
auto restartCheckNotifier = new Notifier(m_restartCheckNotificationConsumer, this, "RESTARTCHECK");
Orch::addExecutor(restartCheckNotifier);
}

void SwitchOrch::doTask(Consumer &consumer)
Expand Down
4 changes: 2 additions & 2 deletions orchagent/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace swss {
class ExecutableTimer : public Executor
{
public:
ExecutableTimer(SelectableTimer *timer, Orch *orch)
: Executor(timer, orch)
ExecutableTimer(SelectableTimer *timer, Orch *orch, const string &name)
: Executor(timer, orch, name)
{
}

Expand Down

0 comments on commit 2bee552

Please sign in to comment.