Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[orchagent]: Remove global lock caused by notifications running in another thread #478

Merged
merged 7 commits into from
Apr 19, 2018

Conversation

pavel-shirshov
Copy link
Contributor

What I did
I removed the notification handlers which were controlled by libsairedis and added direct support of notifications from ASIC_DB.

Why I did it
To remove global lock from orchagent.

How I verified it
Install into the switch and run it.
Also /var/log/syslog shows notifications from port status change.

orchagent/orch.h Outdated
@@ -152,7 +152,7 @@ class Orch

/* Run doTask against a specific executor */
virtual void doTask(Consumer &consumer) = 0;
virtual void doTask(NotificationConsumer &consumer) { }
virtual void doTask(NotificationConsumer &consumer, const std::string &name) { }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const std::string &name [](start = 56, length = 23)

can you add a comment on the name, what does this name use for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments added

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also renamed this parameter to more clear name

Copy link
Contributor

@lguohan lguohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@@ -25,8 +26,14 @@ FdbOrch::FdbOrch(DBConnector *db, string tableName, PortsOrch *port) :
{
m_portsOrch->attach(this);
auto consumer = new NotificationConsumer(db, "FLUSHFDBREQUEST");
auto fdbNotification = new Notifier(consumer, this);
auto fdbNotification = new Notifier(consumer, this, "FLUSHFDBREQUEST");
Copy link
Contributor

@qiluo-msft qiluo-msft Apr 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fdbNotification [](start = 9, length = 15)

Confused about fdbNotification vs fdb_notification. What is the diff? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed all the variable names for notification related stuff

@@ -25,8 +26,14 @@ FdbOrch::FdbOrch(DBConnector *db, string tableName, PortsOrch *port) :
{
m_portsOrch->attach(this);
auto consumer = new NotificationConsumer(db, "FLUSHFDBREQUEST");
auto fdbNotification = new Notifier(consumer, this);
auto fdbNotification = new Notifier(consumer, this, "FLUSHFDBREQUEST");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we define the notification events as enumerations and derive the names from them? This way, we can put them in a common place so no hardcode of strings from different places.
Also, it would make the addition of future events implementation easier in case we want to implement the existing notification events or new added events.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With enumerations we will have hardcoded enumerations.
I think in this case it's better to develop better abstraction than NotificationConsumer(). Currently it's connected too deep into Orch class (doTask methods for NotificationConsumer). We should decouple them from each other and implement doTask methods as a base class for Orch classes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree more changes is needed for a better abstraction than what we have today. but I am not sure if you are going to do it in this PR.
My point was, at least we should put the message types in a common place and reuse then on different places so you don't end up with mistype something and get run-time problem. enumerations will detect the errors during the build time not run time if you mistyped, also by putting things in the same place improves manageability and extendability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you that enumerations will work better here. But what I don't like with this approach is to have one common enum for all cases. I better prefer to have a separateenumeration for every class. Otherwise it's not clear what notifications could come to a target doTask.

Anyway, after Qi's comment I removed the string parameter. You can check new version of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your comments, anyway

@@ -2,8 +2,8 @@

class Notifier : public Executor {
public:
Notifier(NotificationConsumer *select, Orch *orch)
: Executor(select, orch)
Notifier(NotificationConsumer *select, Orch *orch, const std::string& notifier_name)
Copy link
Contributor

@qiluo-msft qiluo-msft Apr 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notifier_name [](start = 74, length = 13)

I notice there is a similar name at NotificationConsumer.m_channel. I prefer using that one instread of a new parameter. #Closed

Copy link
Contributor Author

@pavel-shirshov pavel-shirshov Apr 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to m_channel #Closed

Copy link
Contributor

@qiluo-msft qiluo-msft Apr 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me clarify. I mean you could use getNotificationConsumer()->m_channel internally, instead ask user provide a new argument.


In reply to: 182863130 [](ancestors = 182863130)

Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants