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#include <xrpl/basics/UptimeClock.h>
25#include <xrpl/beast/utility/Journal.h>
26#include <chrono>
27#include <mutex>
28
29namespace ripple {
30
31// Monitors load levels and response times
32
33// VFALCO TODO Rename this. Having both LoadManager and LoadMonitor is
34// confusing.
35//
37{
38public:
39 explicit LoadMonitor(beast::Journal j);
40
41 void
42 addLoadSample(LoadEvent const& sample);
43
44 void
45 addSamples(int count, std::chrono::milliseconds latency);
46
47 void
51
52 bool
54
55 // VFALCO TODO make this return the values in a struct.
56 struct Stats
57 {
58 Stats();
59
64 };
65
66 Stats
67 getStats();
68
69 bool
70 isOver();
71
72private:
73 void
74 update();
75
77
86};
87
88} // namespace ripple
89
90#endif
A generic endpoint for log messages.
Definition: Journal.h:59
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:80
std::uint64_t mCounts
Definition: LoadMonitor.h:78
void addLoadSample(LoadEvent const &sample)
beast::Journal const j_
Definition: LoadMonitor.h:85
std::chrono::milliseconds mTargetLatencyAvg
Definition: LoadMonitor.h:82
std::chrono::milliseconds mLatencyMSPeak
Definition: LoadMonitor.h:81
std::mutex mutex_
Definition: LoadMonitor.h:76
bool isOverTarget(std::chrono::milliseconds avg, std::chrono::milliseconds peak)
std::chrono::milliseconds mTargetLatencyPk
Definition: LoadMonitor.h:83
UptimeClock::time_point mLastUpdate
Definition: LoadMonitor.h:84
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
std::chrono::milliseconds latencyAvg
Definition: LoadMonitor.h:61
std::chrono::milliseconds latencyPeak
Definition: LoadMonitor.h:62