Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
1.8.0, 2.0.0
-
None
-
None
Description
Sentry code uses Java java.lang.Reflect.Proxy class in several places:
SentryHDFSServiceClientFactory
uses this to modify behavior in HA case.
SentryServiceClientFactory
uses it to modify behavior in connection pool or Ha case:
public static SentryPolicyServiceClient create(Configuration conf) throws Exception { boolean haEnabled = conf.getBoolean(ClientConfig.SERVER_HA_ENABLED, false); boolean pooled = conf.getBoolean(ClientConfig.SENTRY_POOL_ENABLED, false); if (pooled) { return (SentryPolicyServiceClient) Proxy .newProxyInstance(SentryPolicyServiceClientDefaultImpl.class.getClassLoader(), SentryPolicyServiceClientDefaultImpl.class.getInterfaces(), new PoolClientInvocationHandler(conf)); } else if (haEnabled) { return (SentryPolicyServiceClient) Proxy .newProxyInstance(SentryPolicyServiceClientDefaultImpl.class.getClassLoader(), SentryPolicyServiceClientDefaultImpl.class.getInterfaces(), new HAClientInvocationHandler(conf)); } else { return new SentryPolicyServiceClientDefaultImpl(conf); } }
SentryServiceClientPoolFactory
uses it to modify behavior in HA case.
This seems to be an abuse of the Proxy interface and some simpler solution should be possible. We should investigate.
Note that in sentry-ha-redesign branch there is only one use in
SentryPolicyServiceClient
that is used to adjust behavior for pooled vs retry behaviors:
public static SentryPolicyServiceClient create(Configuration conf) throws Exception { boolean pooled = conf.getBoolean( ClientConfig.SENTRY_POOL_ENABLED, ClientConfig.SENTRY_POOL_ENABLED_DEFAULT); if (pooled) { return (SentryPolicyServiceClient) Proxy .newProxyInstance(SentryPolicyServiceClientDefaultImpl.class.getClassLoader(), SentryPolicyServiceClientDefaultImpl.class.getInterfaces(), new PoolClientInvocationHandler(conf)); } else { return (SentryPolicyServiceClient) Proxy .newProxyInstance(SentryPolicyServiceClientDefaultImpl.class.getClassLoader(), SentryPolicyServiceClientDefaultImpl.class.getInterfaces(), new RetryClientInvocationHandler(conf)); } }
Again, a more straightforward solution should be possible.
Attachments
Issue Links
- is related to
-
SENTRY-1580 Provide pooled client connection model with HA
- Resolved
- relates to
-
SENTRY-872 Uber jira for HMS HA + Sentry HA redesign
- Resolved