Github user jihoonson commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/556#discussion_r29338237
  
    --- Diff: 
tajo-catalog/tajo-catalog-client/src/main/java/org/apache/tajo/catalog/AbstractCatalogClient.java
 ---
    @@ -64,32 +69,44 @@ public AbstractCatalogClient(TajoConf conf, 
InetSocketAddress catalogServerAddr)
       }
     
       private InetSocketAddress getCatalogServerAddr() {
    -    if (catalogServerAddr == null) {
    -      return null;
    +    if (!conf.getBoolVar(TajoConf.ConfVars.TAJO_MASTER_HA_ENABLE)) {
    +      return catalogServerAddr;
         } else {
    +      return serviceTracker.getCatalogAddress();
    +    }
    +  }
     
    -      if (!conf.getBoolVar(TajoConf.ConfVars.TAJO_MASTER_HA_ENABLE)) {
    -        return catalogServerAddr;
    -      } else {
    -        return serviceTracker.getCatalogAddress();
    +  public synchronized NettyClientBase getCatalogConnection() throws 
ServiceException {
    +    if (client == null || !client.isConnected()) {
    +      try {
    +        RpcClientManager.cleanup(client);
    +
    +        int retry = conf.getInt(RpcConstants.RPC_CLIENT_RETRY_MAX, 
RpcConstants.DEFAULT_RPC_RETRIES);
    +        int timeout = conf.getInt(RpcConstants.RPC_CLIENT_TIMEOUT_SECS, 0);
    +        this.client = manager.newClient(getCatalogServerAddr(), 
CatalogProtocol.class, false, retry, timeout,
    +            TimeUnit.SECONDS, false);
    +      } catch (Exception e) {
    +        throw new ServiceException(e);
           }
         }
    +    return client;
    +  }
    +
    +  @Override
    +  public void close() {
    +    RpcClientManager.cleanup(client);
       }
     
       @Override
       public final Boolean createTablespace(final String tablespaceName, final 
String tablespaceUri) {
         try {
    -      return new ServerCallable<Boolean>(manager, getCatalogServerAddr(), 
CatalogProtocol.class, false) {
    -        public Boolean call(NettyClientBase client) throws 
ServiceException {
    -          CatalogProtocolService.BlockingInterface stub = getStub(client);
    +      CatalogProtocolService.BlockingInterface stub = getStub();
     
    -          CreateTablespaceRequest.Builder builder = 
CreateTablespaceRequest.newBuilder();
    -          builder.setTablespaceName(tablespaceName);
    -          builder.setTablespaceUri(tablespaceUri);
    -          return stub.createTablespace(null, builder.build()).getValue();
    -        }
    -      }.withRetries();
    -    } catch (ServiceException e) {
    +      CreateTablespaceRequest.Builder builder = 
CreateTablespaceRequest.newBuilder();
    +      builder.setTablespaceName(tablespaceName);
    +      builder.setTablespaceUri(tablespaceUri);
    +      return stub.createTablespace(null, builder.build()).getValue();
    +    } catch (Exception e) {
    --- End diff --
    
    Exception seems too broad. How about catching ServiceException?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to