/** * Creates a builder for RecordService planner client from the configuration. */ public static Builder getBuilder(Configuration conf) { RecordServicePlannerClient.Builder builder = new RecordServicePlannerClient.Builder(); int connectionTimeoutMs = conf.getInt( ConfVars.PLANNER_CONNECTION_TIMEOUT_MS_CONF.name, -1); int rpcTimeoutMs = conf.getInt(ConfVars.PLANNER_RPC_TIMEOUT_MS_CONF.name, -1); int maxAttempts = conf.getInt(ConfVars.PLANNER_RETRY_ATTEMPTS_CONF.name, -1); int sleepDurationMs = conf.getInt(ConfVars.PLANNER_RETRY_SLEEP_MS_CONF.name, -1); int maxTasks = conf.getInt(ConfVars.PLANNER_REQUEST_MAX_TASKS.name, -1); if (connectionTimeoutMs != -1) builder.setConnectionTimeoutMs(connectionTimeoutMs); if (rpcTimeoutMs != -1) builder.setRpcTimeoutMs(rpcTimeoutMs); if (maxAttempts != -1) builder.setMaxAttempts(maxAttempts); if (sleepDurationMs != -1) builder.setSleepDurationMs(sleepDurationMs); if (maxTasks != -1) builder.setMaxTasks(maxTasks); return builder; }
builder.setDelegationToken(TokenUtils.toDelegationToken(delegationToken)); } else if (kerberosPrincipal != null) { builder.setKerberosPrincipal(kerberosPrincipal); NetworkAddress hostPort = plannerHostPorts.get(i); try { planner = builder.connect(hostPort.hostname, hostPort.port); if (planner != null) return planner; } catch (RecordServiceException e) {
builder.setDelegatedUser(UserGroupInformation.getCurrentUser().getUserName());
public static void main(String[] args) throws RecordServiceException, IOException { String query = "select * from tpch.nation"; if (args.length == 2) query = args[1]; PlanRequestResult plan = new RecordServicePlannerClient.Builder() .planRequest(PLANNER_HOST, PLANNER_PORT, Request.createSqlRequest(query)); Schema avroSchema = SchemaUtils.convertSchema(plan.schema); System.out.println("Avro Schema:\n" + avroSchema); System.out.println("Records:"); for (int t = 0; t < plan.tasks.size(); ++t) { GenericRecords records = null; try { records = new GenericRecords(WorkerClientUtil.execTask(plan, t)); while (records.hasNext()) { GenericData.Record record = records.next(); System.out.println(record); } } finally { if (records != null) records.close(); } } } }