public static CLIServiceClientWrapper newRetryingCLIServiceClient(HiveConf conf) throws HiveSQLException { RetryingThriftCLIServiceClient retryClient = new RetryingThriftCLIServiceClient(conf); TTransport tTransport = retryClient .connectWithRetry(conf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_CONNECTION_RETRY_LIMIT)); ICLIService cliService = (ICLIService) Proxy.newProxyInstance(RetryingThriftCLIServiceClient.class.getClassLoader(), CLIServiceClient.class.getInterfaces(), retryClient); return new CLIServiceClientWrapper(cliService, tTransport, conf); }
@Override public Object invoke(Object o, Method method, Object[] args) throws Throwable { int attempts = 0; while (true) { attempts++; InvocationResult invokeResult = invokeInternal(method, args); if (invokeResult.success) { return invokeResult.result; } // Error because of thrift client, we have to recreate base object connectWithRetry(conf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_CONNECTION_RETRY_LIMIT)); if (attempts >= retryLimit) { LOG.error(method.getName() + " failed after " + attempts + " retries.", invokeResult.exception); throw invokeResult.exception; } LOG.warn("Last call ThriftCLIServiceClient." + method.getName() + " failed, attempts = " + attempts, invokeResult.exception); Thread.sleep(retryDelaySeconds * 1000); } }
public static CLIServiceClientWrapper newRetryingCLIServiceClient(HiveConf conf) throws HiveSQLException { RetryingThriftCLIServiceClient retryClient = new RetryingThriftCLIServiceClient(conf); TTransport tTransport = retryClient .connectWithRetry(conf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_CONNECTION_RETRY_LIMIT)); ICLIService cliService = (ICLIService) Proxy.newProxyInstance(RetryingThriftCLIServiceClient.class.getClassLoader(), CLIServiceClient.class.getInterfaces(), retryClient); return new CLIServiceClientWrapper(cliService, tTransport, conf); }
@Override public Object invoke(Object o, Method method, Object[] args) throws Throwable { int attempts = 0; while (true) { attempts++; InvocationResult invokeResult = invokeInternal(method, args); if (invokeResult.success) { return invokeResult.result; } // Error because of thrift client, we have to recreate base object connectWithRetry(conf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_CONNECTION_RETRY_LIMIT)); if (attempts >= retryLimit) { LOG.error(method.getName() + " failed after " + attempts + " retries.", invokeResult.exception); throw invokeResult.exception; } LOG.warn("Last call ThriftCLIServiceClient." + method.getName() + " failed, attempts = " + attempts, invokeResult.exception); Thread.sleep(retryDelaySeconds * 1000); } }