You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sentry.apache.org by "Alexander Kolbasov (JIRA)" <ji...@apache.org> on 2016/12/29 22:26:58 UTC
[jira] [Commented] (SENTRY-1579) Sentry should avoid using Proxy
[ https://issues.apache.org/jira/browse/SENTRY-1579?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15786273#comment-15786273 ]
Alexander Kolbasov commented on SENTRY-1579:
--------------------------------------------
[~misha@cloudera.com] FYI.
> Sentry should avoid using Proxy
> -------------------------------
>
> Key: SENTRY-1579
> URL: https://issues.apache.org/jira/browse/SENTRY-1579
> Project: Sentry
> Issue Type: Improvement
> Components: Sentry
> Affects Versions: 1.8.0, sentry-ha-redesign
> Reporter: Alexander Kolbasov
> Priority: Minor
>
> Sentry code uses Java java.lang.Reflect.Proxy class in several places:
> {code}SentryHDFSServiceClientFactory{code} uses this to modify behavior in HA case.
> {code}SentryServiceClientFactory{code} uses it to modify behavior in connection pool or Ha case:
> {code}
> 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);
> }
> }
> {code}
> {code}SentryServiceClientPoolFactory{code} 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 {code}SentryPolicyServiceClient{code} that is used to adjust behavior for pooled vs retry behaviors:
> {code}
> 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));
> }
> }
> {code}
> Again, a more straightforward solution should be possible.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)