public
HiveHistoryImpl(SessionState ss) {
try
{
console =
new
LogHelper(LOG);
String conf_file_loc = ss.getConf().getVar(
HiveConf.ConfVars.HIVEHISTORYFILELOC);
默认值是/tmp/${user.name}/目录
if
((conf_file_loc ==
null
) || conf_file_loc.length() ==
0
) {
console.printError(
"No history file location given"
);
return
;
}
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_sessionid_随机数.txt
}
while
(!
new
File(histFileName).createNewFile());
console.printInfo(
"Hive history file="
+ histFileName);
histStream =
new
PrintWriter(histFileName);
HashMap<String, String> hm =
new
HashMap<String, String>();
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));
}
}