[ 
https://issues.apache.org/jira/browse/SENTRY-1593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15959800#comment-15959800
 ] 

Alexander Kolbasov commented on SENTRY-1593:
--------------------------------------------

I would suggest a bit different class structure. For the base class used by 
various default implementations:

{code}
/**
 * General representation of transport connection to Sentry
 */
public interface SentrySocket extends AutoCloseable {
  /**
   * Connect to the Sentry server
   * @throws IOException
   */
  void connect() throws IOException;
}
{code}

Specific implementations would loke like this:

{code}
public class SentryGenericServiceClientDefaultImpl
        implements SentryGenericServiceClient, SentrySocket {
{code}

The SentryServiceClientTransportDefaultImpl can be renamed to a stand-alone 
class

{code}
**
 * Generate Thrift transports suitable for talking to Sentry
 */
public final class SentryTransportFactory {
...
  public TTransport connect() throws IOException {
   // Connect to one of multiple servers
  }
{code}

Specific impl classes will the do

{code}
  private final SentryTransportFactory transportFactory;
 ...
// Constructor
transportFactory = new SentryTransportFactory(conf, transportConfig);
...
  @Override
  public void connect() throws IOException {
    if (isOpen()) {
      return;
    }

    transport = transportFactory.connect();

...

  @Override
  public void close() {
    transport.close();
  }
{code}

And the RetryClientInvocationHandler will do

{code}
    while (retryCount < retries) {
      // Connect to a sentry server if not connected yet.
      try {
        client.connect();
      } catch (IOException e) {
        // Increase the retry num
        // Retry when the exception is caused by connection problem.
        retryCount++;
        client.close();
        continue;
      }
...
{code}

> Implement client failover for Generic and NN clients
> ----------------------------------------------------
>
>                 Key: SENTRY-1593
>                 URL: https://issues.apache.org/jira/browse/SENTRY-1593
>             Project: Sentry
>          Issue Type: Sub-task
>          Components: Sentry
>    Affects Versions: sentry-ha-redesign
>            Reporter: Alexander Kolbasov
>            Assignee: kalyan kumar kalvagadda
>            Priority: Blocker
>              Labels: HA
>             Fix For: sentry-ha-redesign
>
>         Attachments: old_service_client_class_diagram.png, 
> SENTRY-1593.001-sentry-ha-redesign.patch, 
> SENTRY-1593.002-sentry-ha-redesign.patch, 
> SENTRY-1593.003-sentry-ha-redesign.patch, 
> SENTRY-1593.004-sentry-ha-redesign.patch, 
> SENTRY-1593.005-sentry-ha-redesign.patch, 
> SENTRY-1593.006-sentry-ha-redesign.patch, service_client_class_diagram.png
>
>
> We need to have client failover logic for Generic service clients and Name 
> Node clients. Currently only db policy clients have it implemented.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to