MXS-1777 Cosmetic changes based on code reviews.
This commit is contained in:
@ -28,13 +28,14 @@ public:
|
|||||||
int num_samples() const;
|
int num_samples() const;
|
||||||
void reset();
|
void reset();
|
||||||
CumulativeAverage& operator+=(const CumulativeAverage& rhs);
|
CumulativeAverage& operator+=(const CumulativeAverage& rhs);
|
||||||
CumulativeAverage operator+(const CumulativeAverage& rhs) const;
|
|
||||||
private:
|
private:
|
||||||
double m_ave = 0;
|
double m_ave = 0;
|
||||||
int m_num_samples = 0;
|
int m_num_samples = 0;
|
||||||
int m_num_last_added = 0;
|
int m_num_last_added = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CumulativeAverage operator+(const CumulativeAverage& rhs, const CumulativeAverage& lhs);
|
||||||
|
|
||||||
/** Exponential Moving Average. */
|
/** Exponential Moving Average. */
|
||||||
class EMAverage
|
class EMAverage
|
||||||
{
|
{
|
||||||
@ -54,9 +55,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
const double m_min_alpha;
|
const double m_min_alpha;
|
||||||
const double m_max_alpha;
|
const double m_max_alpha;
|
||||||
int m_sample_max;
|
int m_sample_max;
|
||||||
int m_num_samples = 0;
|
int m_num_samples = 0;
|
||||||
double m_ave = 0;
|
double m_ave = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // maxbase
|
} // maxbase
|
||||||
|
@ -43,15 +43,15 @@ int CumulativeAverage::num_samples() const
|
|||||||
return m_num_samples;
|
return m_num_samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
CumulativeAverage &CumulativeAverage::operator+=(const CumulativeAverage &rhs)
|
CumulativeAverage &CumulativeAverage::operator+=(const CumulativeAverage& rhs)
|
||||||
{
|
{
|
||||||
this->add(rhs.m_ave, rhs.m_num_samples);
|
this->add(rhs.m_ave, rhs.m_num_samples);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CumulativeAverage CumulativeAverage::operator+(const CumulativeAverage &rhs) const
|
CumulativeAverage operator+(const CumulativeAverage& lhs, const CumulativeAverage& rhs)
|
||||||
{
|
{
|
||||||
return CumulativeAverage(*this) += rhs;
|
return CumulativeAverage(lhs) += rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CumulativeAverage::reset()
|
void CumulativeAverage::reset()
|
||||||
@ -84,7 +84,7 @@ void EMAverage::add(double ave, int num_samples)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EMAverage::add(const CumulativeAverage &ca)
|
void EMAverage::add(const CumulativeAverage& ca)
|
||||||
{
|
{
|
||||||
add(ca.average(), ca.num_samples());
|
add(ca.average(), ca.num_samples());
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ static const MXS_ENUM_VALUE slave_selection_criteria_values[] =
|
|||||||
{"LEAST_ROUTER_CONNECTIONS", LEAST_ROUTER_CONNECTIONS},
|
{"LEAST_ROUTER_CONNECTIONS", LEAST_ROUTER_CONNECTIONS},
|
||||||
{"LEAST_BEHIND_MASTER", LEAST_BEHIND_MASTER},
|
{"LEAST_BEHIND_MASTER", LEAST_BEHIND_MASTER},
|
||||||
{"LEAST_CURRENT_OPERATIONS", LEAST_CURRENT_OPERATIONS},
|
{"LEAST_CURRENT_OPERATIONS", LEAST_CURRENT_OPERATIONS},
|
||||||
{"LOWEST_RESPONSE_TIME", LOWEST_RESPONSE_TIME},
|
{"LOWEST_RESPONSE_TIME", LOWEST_RESPONSE_TIME},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user