[jira] [Assigned] (SENTRY-1579) Sentry should avoid using Proxy

2017-03-31 Thread Alexander Kolbasov (JIRA)

 [ 
https://issues.apache.org/jira/browse/SENTRY-1579?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alexander Kolbasov reassigned SENTRY-1579:
--

Assignee: (was: Alexander Kolbasov)

> 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.15#6346)


[jira] [Assigned] (SENTRY-1579) Sentry should avoid using Proxy

2017-01-13 Thread Alexander Kolbasov (JIRA)

 [ 
https://issues.apache.org/jira/browse/SENTRY-1579?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alexander Kolbasov reassigned SENTRY-1579:
--

Assignee: Alexander Kolbasov

> 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
>Assignee: 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)