-
Notifications
You must be signed in to change notification settings - Fork 286
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
Improve sairedis notifications #10
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
456344d
Notifications should use ntf consumer and producer
kcudnik f773fba
Use SelectableEvent to notify thread end
kcudnik d6919b1
Remove signal handler
kcudnik 84ad499
Implement service_method_table
kcudnik 9e71dc4
Add getopt options
kcudnik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Implement service_method_table
- Loading branch information
commit 84ad4991c7c4323adbb71cdb49050fa3231767df
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -324,34 +324,67 @@ swss::ConsumerTable *getRequest = NULL; | |
swss::ProducerTable *getResponse = NULL; | ||
swss::NotificationProducer *notifications = NULL; | ||
|
||
const char* dummy_profile_get_value( | ||
const char* profile_get_value( | ||
_In_ sai_switch_profile_id_t profile_id, | ||
_In_ const char* variable) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
auto it = gProfileMap.find(variable); | ||
|
||
if (it == gProfileMap.end()) | ||
{ | ||
SWSS_LOG_INFO("%s: NULL", variable); | ||
return NULL; | ||
} | ||
|
||
return it->second.c_str(); | ||
SWSS_LOG_INFO("%s: %s", variable, it->second.c_str()); | ||
|
||
return it->second.c_str(); | ||
} | ||
|
||
int dummy_profile_get_next_value( | ||
std::map<std::string, std::string>::iterator gProfileIter = gProfileMap.begin(); | ||
|
||
int profile_get_next_value( | ||
_In_ sai_switch_profile_id_t profile_id, | ||
_Out_ const char** variable, | ||
_Out_ const char** value) | ||
{ | ||
UNREFERENCED_PARAMETER(profile_id); | ||
UNREFERENCED_PARAMETER(variable); | ||
UNREFERENCED_PARAMETER(value); | ||
SWSS_LOG_ENTER(); | ||
|
||
if (value == NULL) | ||
{ | ||
SWSS_LOG_INFO("resetting profile map iterator"); | ||
|
||
gProfileIter = gProfileMap.begin(); | ||
return 0; | ||
} | ||
|
||
if (variable == NULL) | ||
{ | ||
SWSS_LOG_WARN("variable is null"); | ||
return -1; | ||
} | ||
|
||
return -1; | ||
if (gProfileIter == gProfileMap.end()) | ||
{ | ||
SWSS_LOG_INFO("iterator reached end"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -> DEBUG level? |
||
return -1; | ||
} | ||
|
||
*variable = gProfileIter->first.c_str(); | ||
*value = gProfileIter->second.c_str(); | ||
|
||
SWSS_LOG_INFO("key: %s:%s", *variable, *value); | ||
|
||
gProfileIter++; | ||
|
||
return 0; | ||
} | ||
|
||
const service_method_table_t test_services = { | ||
dummy_profile_get_value, | ||
dummy_profile_get_next_value | ||
profile_get_value, | ||
profile_get_next_value | ||
}; | ||
|
||
sai_status_t handle_generic( | ||
|
@@ -681,12 +714,7 @@ sai_status_t processEvent(swss::ConsumerTable &consumer) | |
std::string str_object_type = key.substr(0, key.find(":")); | ||
std::string str_object_id = key.substr(key.find(":")+1); | ||
|
||
SWSS_LOG_INFO( | ||
"key: %s op: %s objtype: %s objid: %s", | ||
key.c_str(), | ||
op.c_str(), | ||
str_object_type.c_str(), | ||
str_object_id.c_str()); | ||
SWSS_LOG_INFO("key: %s op: %s", key.c_str(), op.c_str()); | ||
|
||
sai_common_api_t api = SAI_COMMON_API_MAX; | ||
|
||
|
@@ -766,7 +794,7 @@ sai_status_t processEvent(swss::ConsumerTable &consumer) | |
} | ||
else if (status != SAI_STATUS_SUCCESS) | ||
{ | ||
SWSS_LOG_ERROR("failed to execute api: %s: %u", op.c_str(), status); | ||
SWSS_LOG_ERROR("failed to execute api: %s: %d", op.c_str(), status); | ||
|
||
exit(EXIT_FAILURE); | ||
} | ||
|
@@ -915,6 +943,8 @@ int main(int argc, char **argv) | |
{ | ||
if (strcmp(argv[i],"--diag") == 0) | ||
{ | ||
SWSS_LOG_INFO("starting bcm diag shell thread"); | ||
|
||
std::thread bcm_diag_shell_thread = std::thread(sai_diag_shell); | ||
bcm_diag_shell_thread.detach(); | ||
break; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> DEBUG level?