|
|
|
@@ -103,7 +103,7 @@ ge::Status Analyzer::Initialize() { |
|
|
|
// Initialize file |
|
|
|
string real_path = RealPath(kFilePath.c_str()); |
|
|
|
if (real_path.empty()) { |
|
|
|
GELOGE(FAILED, "[Check][AnalyzerFilePath] File path is empty, path invalid!"); |
|
|
|
GELOGE(FAILED, "[Check][AnalyzeFilePath] File path is empty, path invalid!"); |
|
|
|
return FAILED; |
|
|
|
} |
|
|
|
json_file_name_ = real_path + "/" + kAnalyzeFile; |
|
|
|
@@ -186,11 +186,11 @@ ge::Status Analyzer::CreateAnalyzerFile() { |
|
|
|
std::lock_guard<std::mutex> lg(file_mutex_); |
|
|
|
int fd = open(json_file_name_.c_str(), O_WRONLY | O_CREAT | O_TRUNC, kFileAuthority); |
|
|
|
if (fd < 0) { |
|
|
|
GELOGE(INTERNAL_ERROR, "[FileOpen][AnalyzerFile]Fail to open the file [%s].", json_file_name_.c_str()); |
|
|
|
GELOGE(INTERNAL_ERROR, "[FileOpen][AnalyzeFile]Fail to open the analyze file [%s].", json_file_name_.c_str()); |
|
|
|
return INTERNAL_ERROR; |
|
|
|
} |
|
|
|
if (close(fd) != 0) { |
|
|
|
GELOGE(INTERNAL_ERROR, "[FileClose][AnalyzerFile]Fail to close the file [%s].", json_file_name_.c_str()); |
|
|
|
GELOGE(INTERNAL_ERROR, "[FileClose][AnalyzeFile]Fail to close the analyze file [%s].", json_file_name_.c_str()); |
|
|
|
return INTERNAL_ERROR; |
|
|
|
} |
|
|
|
is_json_file_create_ = true; |
|
|
|
@@ -211,7 +211,7 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_ |
|
|
|
std::lock_guard<std::mutex> lg(file_mutex_); |
|
|
|
json_file_.open(json_file_name_, std::ios::app); |
|
|
|
if (!json_file_.is_open()) { |
|
|
|
GELOGE(FAILED, "[Check][AnalyzerFile]analyzer file does not exist [%s].", json_file_name_.c_str()); |
|
|
|
GELOGE(FAILED, "[Check][AnalyzeFile]analyze file does not exist [%s].", json_file_name_.c_str()); |
|
|
|
return PARAM_INVALID; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -221,7 +221,7 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_ |
|
|
|
try { |
|
|
|
json_file_ << jsn.dump(kJsonDumpLevel) << std::endl; |
|
|
|
} catch (nlohmann::detail::type_error &e) { |
|
|
|
GELOGE(FAILED, "[Json.dump][GraphInfo]json.dump to file [%s] failed because [%s], session_id:%lu, graph_id:%lu.", json_file_name_.c_str(), e.what(), session_id, graph_id); |
|
|
|
GELOGE(FAILED, "[Json.dump][GraphInfo]json.dump to analyze file [%s] failed because [%s], session_id:%lu, graph_id:%lu.", json_file_name_.c_str(), e.what(), session_id, graph_id); |
|
|
|
ret_failed = true; |
|
|
|
} |
|
|
|
json_file_.close(); |
|
|
|
|