rippled
Loading...
Searching...
No Matches
LoadMonitor.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_CORE_LOADMONITOR_H_INCLUDED
21#define RIPPLE_CORE_LOADMONITOR_H_INCLUDED
22
23#include <xrpld/core/LoadEvent.h>
24
25#include <xrpl/basics/UptimeClock.h>
26#include <xrpl/beast/utility/Journal.h>
27
28#include <chrono>
29#include <mutex>
30
31namespace ripple {
32
33// Monitors load levels and response times
34
35// VFALCO TODO Rename this. Having both LoadManager and LoadMonitor is
36// confusing.
37//
39{
40public:
41 explicit LoadMonitor(beast::Journal j);
42
43 void
44 addLoadSample(LoadEvent const& sample);
45
46 void
47 addSamples(int count, std::chrono::milliseconds latency);
48
49 void
53
54 bool
56
57 // VFALCO TODO make this return the values in a struct.
58 struct Stats
59 {
60 Stats();
61
66 };
67
68 Stats
69 getStats();
70
71 bool
72 isOver();
73
74private:
75 void
76 update();
77
79
88};
89
90} // namespace ripple
91
92#endif
A generic endpoint for log messages.
Definition: Journal.h:60
void setTargetLatency(std::chrono::milliseconds avg, std::chrono::milliseconds pk)
void addSamples(int count, std::chrono::milliseconds latency)
std::chrono::milliseconds mLatencyMSAvg
Definition: LoadMonitor.h:82
std::uint64_t mCounts
Definition: LoadMonitor.h:80
void addLoadSample(LoadEvent const &sample)
beast::Journal const j_
Definition: LoadMonitor.h:87
std::chrono::milliseconds mTargetLatencyAvg
Definition: LoadMonitor.h:84
std::chrono::milliseconds mLatencyMSPeak
Definition: LoadMonitor.h:83
std::mutex mutex_
Definition: LoadMonitor.h:78
bool isOverTarget(std::chrono::milliseconds avg, std::chrono::milliseconds peak)
std::chrono::milliseconds mTargetLatencyPk
Definition: LoadMonitor.h:85
UptimeClock::time_point mLastUpdate
Definition: LoadMonitor.h:86
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:25
std::chrono::milliseconds latencyAvg
Definition: LoadMonitor.h:63
std::chrono::milliseconds latencyPeak
Definition: LoadMonitor.h:64