Skip to content

Commit

Permalink
minor optimization for ranger plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
xianjingfeng committed Mar 28, 2024
1 parent cc50d8c commit fa58cfc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public class RangerDorisAccessController extends RangerAccessController {
// "ranger-doris-audit-log-flusher-timer", true);
// private RangerHiveAuditHandler auditHandler;

public RangerDorisAccessController(String serviceName) {
dorisPlugin = new RangerDorisPlugin(serviceName);
public RangerDorisAccessController(String serviceType) {
dorisPlugin = new RangerDorisPlugin(serviceType);
// auditHandler = new RangerHiveAuditHandler(dorisPlugin.getConfig());
// start a timed log flusher
// logFlushTimer.scheduleAtFixedRate(new RangerHiveAuditLogFlusher(auditHandler), 10, 20L, TimeUnit.SECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public class RangerHiveAccessController extends RangerAccessController {
private RangerHiveAuditHandler auditHandler;

public RangerHiveAccessController(Map<String, String> properties) {
String serviceName = properties.get("ranger.service.name");
hivePlugin = new RangerHivePlugin(serviceName);
String serviceType = properties.get("ranger.service.type");
hivePlugin = new RangerHivePlugin(serviceType);
auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
// start a timed log flusher
logFlushTimer.scheduleAtFixedRate(new RangerHiveAuditLogFlusher(auditHandler), 10, 20L, TimeUnit.SECONDS);
Expand Down Expand Up @@ -219,7 +219,6 @@ protected RangerAccessResultProcessor getAccessResultProcessor() {
// For test only
public static void main(String[] args) {
Map<String, String> properties = Maps.newHashMap();
properties.put("ranger.service.name", "hive");
RangerHiveAccessController ac = new RangerHiveAccessController(properties);
UserIdentity user = new UserIdentity("user1", "127.0.0.1");
user.setIsAnalyzed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ public RangerHiveAuditLogFlusher(RangerHiveAuditHandler auditHandler) {

@Override
public void run() {
while (true) {
this.auditHandler.flushAudit();

try {
Thread.sleep(20000);
} catch (InterruptedException e) {
log.info("error ", e);
}
}
this.auditHandler.flushAudit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import org.apache.ranger.plugin.service.RangerBasePlugin;

public class RangerHivePlugin extends RangerBasePlugin {
public RangerHivePlugin(String serviceName) {
super(serviceName, null, null);
public RangerHivePlugin(String serviceType) {
super(serviceType, null, null);
super.init();
}
}

0 comments on commit fa58cfc

Please sign in to comment.