/** * Get the plan request result. */ public PlanRequestResult planRequest(String hostname, int port, Request request) throws IOException, RecordServiceException { try { client_.connect(hostname, port); return client_.planRequest(request); } finally { client_.close(); } }
/** * Opens a connection to the RecordServicePlanner. * Will retry maxAttempts_ if it got SERVICE_BUSY error. */ private void connect(String hostname, int port) throws IOException, RecordServiceException { connect(hostname, port, maxAttempts_); }
planner = PlanUtil.getPlanner( jobConf, builder, plannerHostPorts, kerberosPrincipal, credentials); result = planner.planRequest(request); if (planner.isKerberosAuthenticated()) { TokenUtils.fromTDelegationToken(planner.getDelegationToken("")); credentials.addToken(DelegationTokenIdentifier.DELEGATION_KIND, delegationToken); throw new IOException(e); } finally { if (planner != null) planner.close();
validateIsConnected(); TGetSchemaResult result; TException firstException = null; try { if (!connected) { connected = waitAndReconnect(); if (!connected) continue; if (firstException == null) firstException = e; LOG.warn("Failed to getSchema: ", e); sleepForRetry(); break; default: handleThriftException(firstException, "Could not get schema."); throw new RuntimeException(firstException);
close(); if (i + 1 < maxAttempts && e.code == TErrorCode.SERVICE_BUSY) { sleepForRetry(); continue; + hostname + ":" + port + " is rejected. ", e); } catch (TTransportException e) { close(); if (e.getType() == TTransportException.END_OF_FILE) { TRecordServiceException ex = new TRecordServiceException(); throw new IOException(errorMsg, e); } catch (TException e) { close(); String errorMsg = "Could not get service protocol version. It's likely " + "the service at " + hostname + ":" + port + " is not running the " +
sleepForRetry(); try { Socket socket = LOG.debug("Socket is closed, will reconnect to {}:{}", socket.getInetAddress().getHostAddress(), socket.getPort()); connect(socket.getInetAddress().getHostAddress(), socket.getPort(), 1);
/** * Returns the protocol version of the connected service. */ public ProtocolVersion getProtocolVersion() throws RuntimeException { validateIsConnected(); return protocolVersion_; }
validateIsConnected(); try { if (!connected) { connected = waitAndReconnect(); if (!connected) continue; if (firstException == null) firstException = e; LOG.warn("Failed to planRequest: ", e); sleepForRetry(); break; default: handleThriftException(firstException, "Could not plan request."); throw new RuntimeException(firstException);