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

RANGER-4876: Plugin Analytics #369

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

fateh288
Copy link
Contributor

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.

@@ -86,6 +87,7 @@ public RangerBasePlugin(String serviceType, String serviceName, String appId) {
}

public RangerBasePlugin(RangerPluginConfig pluginConfig) {
this.pluginAnalytics = new RangerPluginAnalytics();

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.

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 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) {

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 ?.

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 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){

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 ?

Copy link
Contributor Author

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants