-
Notifications
You must be signed in to change notification settings - Fork 979
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
RANGER-4876: Plugin Analytics #369
base: master
Are you sure you want to change the base?
Conversation
…nd log periodically
@@ -86,6 +87,7 @@ public RangerBasePlugin(String serviceType, String serviceName, String appId) { | |||
} | |||
|
|||
public RangerBasePlugin(RangerPluginConfig pluginConfig) { | |||
this.pluginAnalytics = new RangerPluginAnalytics(); |
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.
RangerBasePlugin has 6 constructor, "pluginAnalytics " instance variable is not getting initialised from all 6 code paths. Please do let me know if i am looking the wrong code base.
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.
I see just 4 constructors - line 511, 515, 519 and 565 - in RangerBasePlugin.java
@vyommani Can you point to the other 2 constructors you are seeing ?
Constructor 1: Always calls constructor 3
Constructor 2: Always calls constructor 4
So I added pluginAnalytics function calls only for constructor 3 and constructor 4.
Adding it to all the 4 constructors would result in double counting
@@ -494,6 +497,9 @@ public void cleanup() { | |||
if (policyEngine != null) { | |||
((RangerPolicyEngineImpl) policyEngine).releaseResources(true); | |||
} | |||
if (pluginAnalytics!=null) { |
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.
do we need null check ?.
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.
I was adding it as a safety net based on other surrounding variables such as policyEnginer. Not really required. Removed it on second thoughts since it is never set to null unlike policyEngine.
scheduler.shutdown(); | ||
statusHandler.cancel(true); | ||
} | ||
catch (Exception e){ |
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.
can you please replace "Exception e" to the specific exception which are thrown from try block ?
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.
Fixed. No exception thrown by these functions according to the documentation
…() does not throw any exception according to documentation
Accumulate count of isAccessAllowed and log periodically
What changes were proposed in this pull request?
The new class is meant to keep running count of how many times a plugin is called by a service and logs then periodically (every 300 seconds). Count is reset after logging.
How was this patch tested?
Tested in HDFS plugin, log with analytics prints every 300 seconds.