Esempio n. 1
0
 private void setupSessionIO(SessionState sessionState) {
   try {
     sessionState.in = null; // hive server's session input stream is not used
     sessionState.out = new PrintStream(System.out, true, CharEncoding.UTF_8);
     sessionState.info = new PrintStream(System.err, true, CharEncoding.UTF_8);
     sessionState.err = new PrintStream(System.err, true, CharEncoding.UTF_8);
   } catch (UnsupportedEncodingException e) {
     LOG.error("Error creating PrintStream", e);
     e.printStackTrace();
     sessionState.out = null;
     sessionState.info = null;
     sessionState.err = null;
   }
 }
    /** A constructor. */
    public HiveServerHandler() throws MetaException {
      super(HiveServer.class.getName());

      isHiveQuery = false;
      SessionState session = new SessionState(new HiveConf(SessionState.class));
      SessionState.start(session);
      session.in = null;
      session.out = null;
      session.err = null;
      driver = new Driver();
    }
 private void setupSessionIO(SessionState sessionState) {
   try {
     LOG.info("Putting temp output to file " + sessionState.getTmpOutputFile().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
     sessionState.out =
         new PrintStream(new FileOutputStream(sessionState.getTmpOutputFile()), true, "UTF-8");
     // TODO: for hadoop jobs, progress is printed out to session.err,
     // we should find a way to feed back job progress to client
     sessionState.err = new PrintStream(System.err, true, "UTF-8");
   } catch (IOException e) {
     LOG.error("Error in creating temp output file ", e);
     try {
       sessionState.in = null;
       sessionState.out = new PrintStream(System.out, true, "UTF-8");
       sessionState.err = new PrintStream(System.err, true, "UTF-8");
     } catch (UnsupportedEncodingException ee) {
       LOG.error("Error creating PrintStream", e);
       ee.printStackTrace();
       sessionState.out = null;
       sessionState.err = null;
     }
   }
 }