/** * Returns the protocol version of the connected service. */ public ProtocolVersion getProtocolVersion() throws RuntimeException { validateIsConnected(); return protocolVersion_; }
/** * Executes the task asynchronously, returning the handle to the client. */ public TaskState execTask(Task task) throws RecordServiceException, IOException { validateIsConnected(); return execTaskInternal(task, 0); }
/** * Closes the underlying transport, used to simulate an error with the service * connection. */ public void closeTask(TaskState handle) { validateIsConnected(); if (activeTasks_.containsKey(handle.handle_)) { LOG.info("Closing RecordServiceWorker task: " + handle.handle_); try { workerClient_.CloseTask(handle.handle_); } catch (TException e) { LOG.warn( "Failed to close task handle=" + handle.handle_ + " reason=" + e.getMessage()); } activeTasks_.remove(handle.handle_); } }
/** * Executes the task asynchronously, returning a Rows object that can be * used to fetch results. */ public Records execAndFetch(Task task) throws RecordServiceException, IOException { validateIsConnected(); TaskState result = execTaskInternal(task, 0); Records records = null; try { records = new Records(this, result); return records; } finally { if (records == null) closeTask(result); } }
/** * Gets status on the current task executing. */ public TaskStatus getTaskStatus(TaskState handle) throws RecordServiceException, IOException { validateIsConnected(); validateHandleIsActive(handle); LOG.debug("Calling getTaskStatus(): " + handle.handle_); TException firstException = null; boolean connected = true; for (int i = 0; i < maxAttempts_; ++i) { try { if (!connected) { connected = waitAndReconnect(); if (!connected) continue; } return new TaskStatus(workerClient_.GetTaskStatus(handle.handle_)); } catch (TException e) { if (firstException == null) firstException = e; connected = false; } } handleThriftException(firstException, "Could not call getTaskStatus."); throw new RuntimeException("Could not get task status."); }
validateIsConnected(); validateHandleIsActive(state); TException firstException = null;