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; } }
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; } } }
@Before public void setupTest() throws Exception { baos = new ByteArrayOutputStream(); state.out = new SessionStream(baos); processor = new SetProcessor(); }
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);
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());