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

[fix](ranger) make RangerDorisAccessController as singleton to avoid more and more ranger policy refresher #45645

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class RangerCacheDorisAccessController extends CatalogCacheAccessControll

public RangerCacheDorisAccessController(String serviceName) {
this.cache = new RangerCache();
this.proxyController = new RangerDorisAccessController(serviceName, new RangerCacheInvalidateListener(cache));
this.proxyController = RangerDorisAccessController.getInstance(serviceName,
new RangerCacheInvalidateListener(cache));
this.cache.init(proxyController);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,36 @@
public class RangerDorisAccessController extends RangerAccessController {
private static final Logger LOG = LogManager.getLogger(RangerDorisAccessController.class);
private RangerBasePlugin dorisPlugin;

private static RangerDorisAccessController instance;

// private static ScheduledThreadPoolExecutor logFlushTimer = ThreadPoolManager.newDaemonScheduledThreadPool(1,
// "ranger-doris-audit-log-flusher-timer", true);
// private RangerHiveAuditHandler auditHandler;

public RangerDorisAccessController(String serviceName) {
private RangerDorisAccessController(String serviceName) {
this(serviceName, null);
}

public RangerDorisAccessController(String serviceName, RangerAuthContextListener rangerAuthContextListener) {
private RangerDorisAccessController(String serviceName, RangerAuthContextListener rangerAuthContextListener) {
dorisPlugin = new RangerDorisPlugin(serviceName, rangerAuthContextListener);
// auditHandler = new RangerHiveAuditHandler(dorisPlugin.getConfig());
// start a timed log flusher
// logFlushTimer.scheduleAtFixedRate(new RangerHiveAuditLogFlusher(auditHandler), 10, 20L, TimeUnit.SECONDS);
}

public static RangerDorisAccessController getInstance(String serviceName) {
return getInstance(serviceName, null);
}

public static synchronized RangerDorisAccessController getInstance(String serviceName,
RangerAuthContextListener rangerAuthContextListener) {
if (instance == null) {
instance = new RangerDorisAccessController(serviceName, rangerAuthContextListener);
}
return instance;
}

@VisibleForTesting
public RangerDorisAccessController(RangerBasePlugin plugin) {
dorisPlugin = plugin;
Expand Down
Loading