{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/carbon-analytics-common/pulls/comments/37339896","id":37339896,"diff_hunk":"@@ -239,7 +248,8 @@ protected void sendEvent(Event event) {\n             statisticsMonitor.incrementRequest();\n         }\n         //in distributed mode if events are duplicated in cluster, send event only if the node is receiver coordinator\n-        if (!(mode == Mode.Distributed) || !isEventDuplicatedInCluster || EventReceiverServiceValueHolder.getCarbonEventReceiverManagementService().isReceiverCoordinator()) {\n+        if ((!(mode == Mode.Distributed) || !isEventDuplicatedInCluster || EventReceiverServiceValueHolder.getCarbonEventReceiverManagementService().isReceiverCoordinator())\n+                        && !isManagerNode) {","path":"components/event-receiver/org.wso2.carbon.event.receiver.core/src/main/java/org/wso2/carbon/event/receiver/core/internal/EventReceiver.java","position":36,"original_position":36,"commit_id":"c3f56b0c0707942d4baffa79192d4907793fd36f","original_commit_id":"c3f56b0c0707942d4baffa79192d4907793fd36f","user":{"login":"lasanthafdo","id":4602737,"avatar_url":"https://avatars.githubusercontent.com/u/4602737?v=3","gravatar_id":"","url":"https://api.github.com/users/lasanthafdo","html_url":"https://github.com/lasanthafdo","followers_url":"https://api.github.com/users/lasanthafdo/followers","following_url":"https://api.github.com/users/lasanthafdo/following{/other_user}","gists_url":"https://api.github.com/users/lasanthafdo/gists{/gist_id}","starred_url":"https://api.github.com/users/lasanthafdo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lasanthafdo/subscriptions","organizations_url":"https://api.github.com/users/lasanthafdo/orgs","repos_url":"https://api.github.com/users/lasanthafdo/repos","events_url":"https://api.github.com/users/lasanthafdo/events{/privacy}","received_events_url":"https://api.github.com/users/lasanthafdo/received_events","type":"User","site_admin":false},"body":"@dilini-muthumala \r\nDilini, can we optimize the logic of the if condition so that !isManagerNode is checked only if CEP is running in distributed mode? Checking 'isManagerNode' with an && means that the right operand will still be evaluated if left operand is true. But I think the || conditions have been used here so that if a true condition is matched, the expression becomes true immediately. So can we restructure the if as below? \r\n```java\r\n    if (mode != Mode.Distributed || !isManagerNode && (!isEventDuplicatedInCluster || isReceiverCoordinator))\r\n```\r\nThis way, the isManagerNode check won't happen in non-distributed mode, which might be a minor optimization, but useful since this is in the critical path of sending events. WDYT?\r\n\r\nAlso, if it is possible to pre-calculate some of these boolean variable combinations in distributed mode, we might be able to reduce the evaluations at the time of sending events. Can you see if it is possible to pre-calculate some of these and variables and optimize this if condition? Some variables such as mode, isEventDuplicatedInCluster won't change within the lifetime of the EventReceiver instance AFAIU, so we might be able to pre-calculate a boolean var accordingly and check that instead of checking multiple conditions at the time of sending the event.","created_at":"2015-08-18T19:07:19Z","updated_at":"2015-08-18T19:07:19Z","html_url":"https://github.com/wso2/carbon-analytics-common/pull/101#discussion_r37339896","pull_request_url":"https://api.github.com/repos/wso2/carbon-analytics-common/pulls/101","_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-analytics-common/pulls/comments/37339896"},"html":{"href":"https://github.com/wso2/carbon-analytics-common/pull/101#discussion_r37339896"},"pull_request":{"href":"https://api.github.com/repos/wso2/carbon-analytics-common/pulls/101"}}},"pull_request":{"url":"https://api.github.com/repos/wso2/carbon-analytics-common/pulls/101","id":42728857,"html_url":"https://github.com/wso2/carbon-analytics-common/pull/101","diff_url":"https://github.com/wso2/carbon-analytics-common/pull/101.diff","patch_url":"https://github.com/wso2/carbon-analytics-common/pull/101.patch","issue_url":"https://api.github.com/repos/wso2/carbon-analytics-common/issues/101","number":101,"state":"open","locked":false,"title":"Fixing CEP-1274 + some other improvements","user":{"login":"dilini-muthumala","id":7592890,"avatar_url":"https://avatars.githubusercontent.com/u/7592890?v=3","gravatar_id":"","url":"https://api.github.com/users/dilini-muthumala","html_url":"https://github.com/dilini-muthumala","followers_url":"https://api.github.com/users/dilini-muthumala/followers","following_url":"https://api.github.com/users/dilini-muthumala/following{/other_user}","gists_url":"https://api.github.com/users/dilini-muthumala/gists{/gist_id}","starred_url":"https://api.github.com/users/dilini-muthumala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dilini-muthumala/subscriptions","organizations_url":"https://api.github.com/users/dilini-muthumala/orgs","repos_url":"https://api.github.com/users/dilini-muthumala/repos","events_url":"https://api.github.com/users/dilini-muthumala/events{/privacy}","received_events_url":"https://api.github.com/users/dilini-muthumala/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-18T17:59:52Z","updated_at":"2015-08-18T19:07:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bccb3db20204da2667532cf45f2b689a923ba5bd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wso2/carbon-analytics-common/pulls/101/commits","review_comments_url":"https://api.github.com/repos/wso2/carbon-analytics-common/pulls/101/comments","review_comment_url":"https://api.github.com/repos/wso2/carbon-analytics-common/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/carbon-analytics-common/issues/101/comments","statuses_url":"https://api.github.com/repos/wso2/carbon-analytics-common/statuses/c3f56b0c0707942d4baffa79192d4907793fd36f","head":{"label":"dilini-muthumala:master","ref":"master","sha":"c3f56b0c0707942d4baffa79192d4907793fd36f","user":{"login":"dilini-muthumala","id":7592890,"avatar_url":"https://avatars.githubusercontent.com/u/7592890?v=3","gravatar_id":"","url":"https://api.github.com/users/dilini-muthumala","html_url":"https://github.com/dilini-muthumala","followers_url":"https://api.github.com/users/dilini-muthumala/followers","following_url":"https://api.github.com/users/dilini-muthumala/following{/other_user}","gists_url":"https://api.github.com/users/dilini-muthumala/gists{/gist_id}","starred_url":"https://api.github.com/users/dilini-muthumala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dilini-muthumala/subscriptions","organizations_url":"https://api.github.com/users/dilini-muthumala/orgs","repos_url":"https://api.github.com/users/dilini-muthumala/repos","events_url":"https://api.github.com/users/dilini-muthumala/events{/privacy}","received_events_url":"https://api.github.com/users/dilini-muthumala/received_events","type":"User","site_admin":false},"repo":{"id":32571808,"name":"carbon-analytics-common","full_name":"dilini-muthumala/carbon-analytics-common","owner":{"login":"dilini-muthumala","id":7592890,"avatar_url":"https://avatars.githubusercontent.com/u/7592890?v=3","gravatar_id":"","url":"https://api.github.com/users/dilini-muthumala","html_url":"https://github.com/dilini-muthumala","followers_url":"https://api.github.com/users/dilini-muthumala/followers","following_url":"https://api.github.com/users/dilini-muthumala/following{/other_user}","gists_url":"https://api.github.com/users/dilini-muthumala/gists{/gist_id}","starred_url":"https://api.github.com/users/dilini-muthumala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dilini-muthumala/subscriptions","organizations_url":"https://api.github.com/users/dilini-muthumala/orgs","repos_url":"https://api.github.com/users/dilini-muthumala/repos","events_url":"https://api.github.com/users/dilini-muthumala/events{/privacy}","received_events_url":"https://api.github.com/users/dilini-muthumala/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dilini-muthumala/carbon-analytics-common","description":"","fork":true,"url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common","forks_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/forks","keys_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/teams","hooks_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/hooks","issue_events_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/issues/events{/number}","events_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/events","assignees_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/assignees{/user}","branches_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/branches{/branch}","tags_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/tags","blobs_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/git/refs{/sha}","trees_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/statuses/{sha}","languages_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/languages","stargazers_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/stargazers","contributors_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/contributors","subscribers_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/subscribers","subscription_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/subscription","commits_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/commits{/sha}","git_commits_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/git/commits{/sha}","comments_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/comments{/number}","issue_comment_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/issues/comments{/number}","contents_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/contents/{+path}","compare_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/merges","archive_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/downloads","issues_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/issues{/number}","pulls_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/pulls{/number}","milestones_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/milestones{/number}","notifications_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/labels{/name}","releases_url":"https://api.github.com/repos/dilini-muthumala/carbon-analytics-common/releases{/id}","created_at":"2015-03-20T08:23:49Z","updated_at":"2015-04-08T12:21:15Z","pushed_at":"2015-08-18T17:58:01Z","git_url":"git://github.com/dilini-muthumala/carbon-analytics-common.git","ssh_url":"git@github.com:dilini-muthumala/carbon-analytics-common.git","clone_url":"https://github.com/dilini-muthumala/carbon-analytics-common.git","svn_url":"https://github.com/dilini-muthumala/carbon-analytics-common","homepage":null,"size":5255,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wso2:master","ref":"master","sha":"041f560a118dbbcef0eeb774fceec77c13263423","user":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"repo":{"id":31999455,"name":"carbon-analytics-common","full_name":"wso2/carbon-analytics-common","owner":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2/carbon-analytics-common","description":"","fork":false,"url":"https://api.github.com/repos/wso2/carbon-analytics-common","forks_url":"https://api.github.com/repos/wso2/carbon-analytics-common/forks","keys_url":"https://api.github.com/repos/wso2/carbon-analytics-common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/carbon-analytics-common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/carbon-analytics-common/teams","hooks_url":"https://api.github.com/repos/wso2/carbon-analytics-common/hooks","issue_events_url":"https://api.github.com/repos/wso2/carbon-analytics-common/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/carbon-analytics-common/events","assignees_url":"https://api.github.com/repos/wso2/carbon-analytics-common/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/carbon-analytics-common/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/carbon-analytics-common/tags","blobs_url":"https://api.github.com/repos/wso2/carbon-analytics-common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/carbon-analytics-common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/carbon-analytics-common/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/carbon-analytics-common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/carbon-analytics-common/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/carbon-analytics-common/languages","stargazers_url":"https://api.github.com/repos/wso2/carbon-analytics-common/stargazers","contributors_url":"https://api.github.com/repos/wso2/carbon-analytics-common/contributors","subscribers_url":"https://api.github.com/repos/wso2/carbon-analytics-common/subscribers","subscription_url":"https://api.github.com/repos/wso2/carbon-analytics-common/subscription","commits_url":"https://api.github.com/repos/wso2/carbon-analytics-common/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/carbon-analytics-common/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/carbon-analytics-common/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/carbon-analytics-common/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/carbon-analytics-common/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/carbon-analytics-common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/carbon-analytics-common/merges","archive_url":"https://api.github.com/repos/wso2/carbon-analytics-common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/carbon-analytics-common/downloads","issues_url":"https://api.github.com/repos/wso2/carbon-analytics-common/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/carbon-analytics-common/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/carbon-analytics-common/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/carbon-analytics-common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/carbon-analytics-common/labels{/name}","releases_url":"https://api.github.com/repos/wso2/carbon-analytics-common/releases{/id}","created_at":"2015-03-11T05:08:43Z","updated_at":"2015-05-08T12:25:51Z","pushed_at":"2015-08-18T17:59:53Z","git_url":"git://github.com/wso2/carbon-analytics-common.git","ssh_url":"git@github.com:wso2/carbon-analytics-common.git","clone_url":"https://github.com/wso2/carbon-analytics-common.git","svn_url":"https://github.com/wso2/carbon-analytics-common","homepage":null,"size":14187,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":1,"forks":20,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-analytics-common/pulls/101"},"html":{"href":"https://github.com/wso2/carbon-analytics-common/pull/101"},"issue":{"href":"https://api.github.com/repos/wso2/carbon-analytics-common/issues/101"},"comments":{"href":"https://api.github.com/repos/wso2/carbon-analytics-common/issues/101/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/carbon-analytics-common/pulls/101/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/carbon-analytics-common/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/carbon-analytics-common/pulls/101/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/carbon-analytics-common/statuses/c3f56b0c0707942d4baffa79192d4907793fd36f"}}}}