private void setupSessionIO(SessionState sessionState) { try { sessionState.in = null; // hive server's session input stream is not used sessionState.out = new SessionStream(System.out, true, StandardCharsets.UTF_8.name()); sessionState.info = new SessionStream(System.err, true, StandardCharsets.UTF_8.name()); sessionState.err = new SessionStream(System.err, true, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { LOG.error("Error creating PrintStream", e); e.printStackTrace(); sessionState.out = null; sessionState.info = null; sessionState.err = null; } }
protected final void printDirect(String out) { super.println(out); }
@Override public void flush() { output = new ArrayList<String>(); super.flush(); }
ss.in = System.in; try { ss.out = new SessionStream(System.out, true, "UTF-8"); ss.err = new SessionStream(System.err, true, "UTF-8"); } catch (UnsupportedEncodingException e) { System.exit(1); ss.err.println("The '-e' and '-f' options cannot be specified simultaneously"); printUsage(options, ss.err); sysExit(ss, 1); ss.err.println("Input file not found. (" + e.getMessage() + ")"); sysExit(ss, 1); } catch (IOException e) { ss.err.println("Could not open input file for reading. (" + e.getMessage() + ")"); sysExit(ss, 1);
@Override public void println(String out) { output.add(out); super.println(out); }
private void setupSessionIO(SessionState sessionState) { try { LOG.info("Putting temp output to file " + sessionState.getTmpOutputFile().toString() + " and error output to file " + sessionState.getTmpErrOutputFile().toString()); sessionState.in = null; // hive server's session input stream is not used // open a per-session file in auto-flush mode for writing temp results and tmp error output sessionState.out = new SessionStream( new FileOutputStream(sessionState.getTmpOutputFile()), true, StandardCharsets.UTF_8.name()); sessionState.err = new SessionStream( new FileOutputStream(sessionState.getTmpErrOutputFile()), true, StandardCharsets.UTF_8.name()); } catch (IOException e) { LOG.error("Error in creating temp output file ", e); // Close file streams to avoid resource leaking ServiceUtils.cleanup(LOG, parentSession.getSessionState().out, parentSession.getSessionState().err); try { sessionState.in = null; sessionState.out = new SessionStream(System.out, true, StandardCharsets.UTF_8.name()); sessionState.err = new SessionStream(System.err, true, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException ee) { LOG.error("Error creating PrintStream", e); ee.printStackTrace(); sessionState.out = null; sessionState.err = null; } } }
@Override public void flush() { if (byPass()) { super.flush(); } }
private void writeTestOutput(final String msg) { SessionState.get().out.println(msg); }
@Before public void setupTest() throws Exception { baos = new ByteArrayOutputStream(); state.out = new SessionStream(baos); processor = new SetProcessor(); }
public void fetchFinished() { if (!byPass()) { processFinal(); } super.flush(); fetchStarted = false; } }
private void writeTestOutput(final String msg) { SessionState.get().out.println(msg); }
try { ss.out = new SessionStream(System.out, true, StandardCharsets.UTF_8.name()); ss.info = new SessionStream(System.err, true, StandardCharsets.UTF_8.name()); ss.err = new CachingPrintStream(System.err, true, StandardCharsets.UTF_8.name());
private void runSetProcessor(String command) { processor.run(command); state.out.flush(); }
private void llapCachePurge(final SessionState ss, final LlapRegistryService llapRegistryService) throws Exception { ExecutorService executorService = Executors.newCachedThreadPool(); List<Future<Long>> futures = new ArrayList<>(); Collection<LlapServiceInstance> instances = llapRegistryService.getInstances().getAll(); for (LlapServiceInstance instance : instances) { futures.add(executorService.submit(new PurgeCallable(ss.getConf(), instance))); } int i = 0; for (LlapServiceInstance instance : instances) { Future<Long> future = futures.get(i); ss.out.println(Joiner.on("\t").join(instance.getHost(), future.get())); i++; } }
ss.err.flush(); String cmd_trimmed = HiveStringUtils.removeComments(cmd).trim(); String[] tokens = tokenizeCmd(cmd_trimmed);
@Override public CommandProcessorResponse run(String command) { SessionState ss = SessionState.get(); String[] tokens = command.split("\\s+"); SessionState.ResourceType t; if (tokens.length < 1 || (t = SessionState.find_resource_type(tokens[0])) == null) { String message = "Usage: list [" + StringUtils.join(SessionState.ResourceType.values(), "|") + "] [<value> [<value>]*]"; return new CommandProcessorResponse(1, message, null); } List<String> filter = null; if (tokens.length > 1) { filter = Arrays.asList(Arrays.copyOfRange(tokens, 1, tokens.length)); } Set<String> s = ss.list_resource(t, filter); if (s != null && !s.isEmpty()) { ss.out.println(StringUtils.join(s, "\n")); } return new CommandProcessorResponse(0, null, null, SCHEMA); }
private void dumpOption(String s) { SessionState ss = SessionState.get(); if (ss.getConf().isHiddenConfig(s)) { ss.out.println(s + " is a hidden config"); } else if (ss.getConf().get(s) != null) { if (ss.getConf().isEncodedPar(s)) { ss.out.println(s + "=" + HiveConf.EncoderDecoderFactory.URL_ENCODER_DECODER .decode(ss.getConf().get(s))); } else { ss.out.println(s + "=" + ss.getConf().get(s)); } } else if (ss.getHiveVariables().containsKey(s)) { ss.out.println(s + "=" + ss.getHiveVariables().get(s)); } else { ss.out.println(s + " is undefined"); } }
private CommandProcessorResponse getVariable(String varname) throws Exception { SessionState ss = SessionState.get(); if (varname.equals("silent")){ ss.out.println("silent" + "=" + ss.getIsSilent()); return createProcessorSuccessResponse(); if (result != null) { if(isHidden(propName)) { ss.out.println(SYSTEM_PREFIX + propName + " is a hidden config"); } else { ss.out.println(SYSTEM_PREFIX + propName + "=" + result); ss.out.println(propName + " is undefined as a system property"); return new CommandProcessorResponse(1); if (System.getenv(var) != null) { if(isHidden(var)) { ss.out.println(ENV_PREFIX + var + " is a hidden config"); } else { ss.out.println(ENV_PREFIX + var + "=" + System.getenv(var)); ss.out.println(varname + " is undefined as an environmental variable"); return new CommandProcessorResponse(1); String var = varname.substring(HIVECONF_PREFIX.length()); if (ss.getConf().isHiddenConfig(var)) { ss.out.println(HIVECONF_PREFIX + var + " is a hidden config"); return createProcessorSuccessResponse(); } if (ss.getConf().get(var) != null) { ss.out.println(HIVECONF_PREFIX + var + "=" + ss.getConf().get(var));
while (driver.getResults(res)) { for (String r : res) { ss.out.println(r); ss.err.println("Failed with exception " + e.getClass().getName() + ":" + e.getMessage() + "\n" + org.apache.hadoop.util.StringUtils.stringifyException(e)); ret = 1; if (end > start) { double timeTaken = (end - start) / 1000.0; ss.err.println("Time taken: " + timeTaken + " seconds");