public
HiveHistoryImpl(SessionStatess){
try
{
console=
new
LogHelper(LOG);
Stringconf_file_loc=ss.getConf().getVar(
HiveConf.ConfVars.HIVEHISTORYFILELOC);
默认值是/tmp/${user.name}/目录
if
((conf_file_loc==
null
)||conf_file_loc.length()==
0
){
console.printError(
"Nohistoryfilelocationgiven"
);
return
;
}
FilehistDir=
new
File(conf_file_loc);
if
(!histDir.exists()){
if
(!histDir.mkdirs()){
console.printError(
"Unabletocreatelogdirectory"
+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(
"Hivehistoryfile="
+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
(IOExceptione){
console.printError(
"FAILED:FailedtoopenQueryLog:"
+histFileName
+
""
+e.getMessage(),
"\n"
+org.apache.hadoop.util.StringUtils.stringifyException(e));
}
}