17 #include <boost/foreach.hpp>
24 using std::stringstream;
33 if (e == 0)
return "";
36 ss <<
"Error(" << e <<
"): " << strerror_r(e, buf, 1024);
42 if (tables_missing_stats.empty())
return string(
"");
43 ss <<
"WARNING: The following tables are missing relevant table and/or column "
45 for (
int i = 0; i < tables_missing_stats.size(); ++i) {
46 const TTableName& table_name = tables_missing_stats[i];
47 if (i != 0) ss <<
",";
48 ss << table_name.db_name <<
"." << table_name.table_name;
55 message_(strings::Substitute(g_ErrorCodes_constants.TErrorMessage[error_])) {}
59 message_(strings::Substitute(g_ErrorCodes_constants.TErrorMessage[error_],
64 message_(strings::Substitute(g_ErrorCodes_constants.TErrorMessage[error_],
70 message_(strings::Substitute(g_ErrorCodes_constants.TErrorMessage[error_],
76 message_(strings::Substitute(g_ErrorCodes_constants.TErrorMessage[error_],
77 arg0, arg1, arg2, arg3)) {}
82 message_(strings::Substitute(g_ErrorCodes_constants.TErrorMessage[error_],
83 arg0, arg1, arg2, arg3, arg4)) {}
89 message_(strings::Substitute(g_ErrorCodes_constants.TErrorMessage[error_],
90 arg0, arg1, arg2, arg3, arg4, arg5)) {}
96 message_(strings::Substitute(g_ErrorCodes_constants.TErrorMessage[error_],
97 arg0, arg1, arg2, arg3, arg4, arg5, arg6)) {}
103 message_(strings::Substitute(g_ErrorCodes_constants.TErrorMessage[error_],
104 arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)) {}
111 message_(strings::Substitute(g_ErrorCodes_constants.TErrorMessage[error_],
112 arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)) {}
119 message_(strings::Substitute(g_ErrorCodes_constants.TErrorMessage[error_],
120 arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)) {}
127 ErrorCodesConstants error_strings;
130 m.
message_ = strings::Substitute(error_strings.TErrorMessage[m.
error_],
131 arg0, arg1, arg2, arg3, arg4, arg5,
132 arg6, arg7, arg8, arg9);
137 BOOST_FOREACH(
const ErrorLogMap::value_type& v, errors) {
138 if (v.first == TErrorCode::GENERAL) {
139 BOOST_FOREACH(
const string& s, v.second.messages) {
140 *stream << s <<
"\n";
143 *stream << v.second.messages.front();
144 if (v.second.count < 2) {
147 *stream <<
" (1 of " << v.second.count <<
" similar)\n";
160 BOOST_FOREACH(
const ErrorLogMap::value_type& v, right) {
162 if (v.first == TErrorCode::GENERAL) {
163 (*left)[v.first].messages.insert(
164 (*left)[v.first].messages.end(), v.second.messages.begin(),
165 v.second.messages.end());
167 if ((*left).count(v.first) > 0) {
168 (*left)[v.first].count += v.second.count;
170 (*left)[v.first].messages.push_back(v.second.messages.front());
171 (*left)[v.first].count = v.second.count;
178 if (e.
error() == TErrorCode::GENERAL) {
179 (*map)[e.
error()].messages.push_back(e.
msg());
181 ErrorLogMap::iterator it = map->find(e.
error());
182 if (it != map->end()) {
183 ++(it->second.count);
185 (*map)[e.
error()].messages.push_back(e.
msg());
186 (*map)[e.
error()].count = 1;
192 ErrorLogMap::const_iterator cit = errors.find(TErrorCode::GENERAL);
193 size_t general_errors = cit != errors.end() ?
194 errors.find(TErrorCode::GENERAL)->second.messages.size() - 1 : 0;
195 return errors.size() + general_errors;
const std::string & msg() const
Returns the formatted error string.
string GetTablesMissingStatsWarning(const vector< TTableName > &tables_missing_stats)
string PrintErrorMapToString(const ErrorLogMap &errors)
TErrorCode::type error() const
void MergeErrorMaps(ErrorLogMap *left, const ErrorLogMap &right)
void AppendError(ErrorLogMap *map, const ErrorMsg &e)
size_t ErrorCount(const ErrorLogMap &errors)
static ErrorMsg Init(TErrorCode::type error, const ArgType &arg0=ArgType::NoArg, const ArgType &arg1=ArgType::NoArg, const ArgType &arg2=ArgType::NoArg, const ArgType &arg3=ArgType::NoArg, const ArgType &arg4=ArgType::NoArg, const ArgType &arg5=ArgType::NoArg, const ArgType &arg6=ArgType::NoArg, const ArgType &arg7=ArgType::NoArg, const ArgType &arg8=ArgType::NoArg, const ArgType &arg9=ArgType::NoArg)
strings::internal::SubstituteArg ArgType
void PrintErrorMap(ostream *stream, const ErrorLogMap &errors)
ErrorMsg()
Trivial constructor.
std::map< TErrorCode::type, TErrorLogEntry > ErrorLogMap
Tracks log messages per error code.