xuyaxiu 发表于 2018-10-30 12:17:24

实现hive proxy2-hive操作hadoop时使用用户的地方

public HiveHistoryImpl(SessionState ss) {  
try {
  
    console = new LogHelper(LOG);
  
    String conf_file_loc = ss.getConf().getVar(
  
      HiveConf.ConfVars.HIVEHISTORYFILELOC);
  
//HIVEHISTORYFILELOC("hive.querylog.location", System.getProperty("java.io.tmpdir") + File.separator + System.getProperty("user.name")),
  
默认值是/tmp/${user.name}/目录
  
    if ((conf_file_loc == null) || conf_file_loc.length() == 0) {
  
      console.printError("No history file location given");
  
      return;
  
    }
  
    // Create directory
  
    File histDir = new File(conf_file_loc);
  
    if (!histDir.exists()) { //创建日志目录
  
      if (!histDir.mkdirs()) {
  
      console.printError("Unable to create log directory " + conf_file_loc);
  
      return;
  
      }
  
    }
  
    do {
  
      histFileName = conf_file_loc + File.separator + "hive_job_log_" + ss.getSessionId() + "_"
  
      + Math.abs(randGen.nextInt()) + ".txt";
  
// 日志文件的完整路径 比如 /tmp/hdfs/hive_job_log_4f96f470-a6c1-41ae-9d30-def308e5412f_564454280.txt
  
/tmp/hdfs/hive_job_log_sessionid_随机数.txt
  
    } while (! new File(histFileName).createNewFile());
  
    console.printInfo("Hive history file=" + histFileName);
  
    histStream = new PrintWriter(histFileName);
  
    HashMap hm = new HashMap();
  
    hm.put(Keys.SESSION_ID.name(), ss.getSessionId());
  
    log(RecordTypes.SessionStart, hm);
  
} catch (IOException e) {
  
    console.printError("FAILED: Failed to open Query Log : " + histFileName
  
      + " " + e.getMessage(), "\n"
  
      + org.apache.hadoop.util.StringUtils.stringifyException(e));
  
}
  
}


页: [1]
查看完整版本: 实现hive proxy2-hive操作hadoop时使用用户的地方