mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-29 07:25:51 +00:00
Factor out UptimeTimer from LoadManager
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "Config.h"
|
||||
#include "Application.h"
|
||||
|
||||
/*
|
||||
static volatile int* uptimePtr = NULL;
|
||||
|
||||
int upTime()
|
||||
@@ -17,10 +18,11 @@ int upTime()
|
||||
return *uptimePtr;
|
||||
return static_cast<int>(time(NULL) - firstCall);
|
||||
}
|
||||
*/
|
||||
|
||||
LoadManager::LoadManager(int creditRate, int creditLimit, int debitWarn, int debitLimit) :
|
||||
mCreditRate(creditRate), mCreditLimit(creditLimit), mDebitWarn(debitWarn), mDebitLimit(debitLimit),
|
||||
mShutdown(false), mArmed(false), mUptime(0), mDeadLock(0), mCosts(LT_MAX)
|
||||
mShutdown(false), mArmed(false), /*mUptime(0),*/ mDeadLock(0), mCosts(LT_MAX)
|
||||
{
|
||||
addLoadCost(LoadCost(LT_InvalidRequest, -10, LC_CPU | LC_Network));
|
||||
addLoadCost(LoadCost(LT_RequestNoReply, -1, LC_CPU | LC_Disk));
|
||||
@@ -39,19 +41,22 @@ LoadManager::LoadManager(int creditRate, int creditLimit, int debitWarn, int deb
|
||||
|
||||
void LoadManager::init()
|
||||
{
|
||||
/*
|
||||
if (uptimePtr == NULL)
|
||||
uptimePtr = static_cast<volatile int *>(&mUptime);
|
||||
*/
|
||||
UptimeTimer::getInstance().beginManualUpdates ();
|
||||
|
||||
boost::thread(boost::bind(&LoadManager::threadEntry, this)).detach();
|
||||
}
|
||||
|
||||
LoadManager::~LoadManager()
|
||||
{
|
||||
/*
|
||||
if (uptimePtr == &mUptime)
|
||||
uptimePtr = NULL;
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mLock);
|
||||
mShutdown = true;
|
||||
}
|
||||
*/
|
||||
UptimeTimer::getInstance().endManualUpdates ();
|
||||
|
||||
do
|
||||
{
|
||||
@@ -68,7 +73,8 @@ LoadManager::~LoadManager()
|
||||
void LoadManager::noDeadLock()
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mLock);
|
||||
mDeadLock = mUptime;
|
||||
//mDeadLock = mUptime;
|
||||
mDeadLock = UptimeTimer::getInstance ().getElapsedSeconds ();
|
||||
}
|
||||
|
||||
int LoadManager::getCreditRate() const
|
||||
@@ -342,9 +348,11 @@ void LoadManager::threadEntry()
|
||||
mShutdown = false;
|
||||
return;
|
||||
}
|
||||
++mUptime;
|
||||
|
||||
//++mUptime;
|
||||
UptimeTimer::getInstance ().incrementElapsedTime ();
|
||||
|
||||
int dlTime = mUptime - mDeadLock;
|
||||
int dlTime = UptimeTimer::getInstance ().getElapsedSeconds () - mDeadLock;
|
||||
if (mArmed && (dlTime >= 10))
|
||||
{
|
||||
if ((dlTime % 10) == 0)
|
||||
|
||||
@@ -102,9 +102,11 @@ protected:
|
||||
bool mShutdown;
|
||||
bool mArmed;
|
||||
|
||||
/*
|
||||
int mSpace1[4]; // We want mUptime to have its own cache line
|
||||
int mUptime;
|
||||
int mSpace2[4];
|
||||
*/
|
||||
|
||||
int mDeadLock; // Detect server deadlocks
|
||||
|
||||
|
||||
@@ -55,6 +55,15 @@ public:
|
||||
static std::vector< std::pair<std::string, std::string> > getSeverities();
|
||||
|
||||
private:
|
||||
/** Retrieve file name from a log partition.
|
||||
|
||||
Key must have this shape:
|
||||
|
||||
struct Key
|
||||
{
|
||||
static char const* getFileName ();
|
||||
};
|
||||
*/
|
||||
template <class Key>
|
||||
inline static LogPartition getFileName ()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user