rippled
Loading...
Searching...
No Matches
JobTypeData.h
1#pragma once
2
3#include <xrpl/basics/Log.h>
4#include <xrpl/beast/insight/Collector.h>
5#include <xrpl/core/JobTypeInfo.h>
6
7namespace xrpl {
8
10{
11private:
13
14 /* Support for insight */
16
17public:
18 /* The job category which we represent */
20
21 /* The number of jobs waiting */
22 int waiting{0};
23
24 /* The number presently running */
25 int running{0};
26
27 /* And the number we deferred executing because of job limits */
28 int deferred{0};
29
30 /* Notification callbacks */
33
35 JobTypeInfo const& info_,
36 beast::insight::Collector::ptr const& collector,
37 Logs& logs) noexcept
38 : m_load(logs.journal("LoadMonitor")), m_collector(collector), info(info_)
39
40 {
42
43 if (!info.special())
44 {
45 dequeue = m_collector->make_event(info.name() + "_q");
46 execute = m_collector->make_event(info.name());
47 }
48 }
49
50 /* Not copy-constructible or assignable */
51 JobTypeData(JobTypeData const& other) = delete;
53 operator=(JobTypeData const& other) = delete;
54
56 name() const
57 {
58 return info.name();
59 }
60
62 type() const
63 {
64 return info.type();
65 }
66
69 {
70 return m_load;
71 }
72
75 {
76 return m_load.getStats();
77 }
78};
79
80} // namespace xrpl
A metric for reporting event timing.
Definition Event.h:21
Holds all the 'static' information about a job, which does not change.
Definition JobTypeInfo.h:9
std::string const & name() const
Definition JobTypeInfo.h:50
std::chrono::milliseconds getPeakLatency() const
Definition JobTypeInfo.h:74
bool special() const
Definition JobTypeInfo.h:62
JobType type() const
Definition JobTypeInfo.h:44
std::chrono::milliseconds getAverageLatency() const
Definition JobTypeInfo.h:68
void setTargetLatency(std::chrono::milliseconds avg, std::chrono::milliseconds pk)
Manages partitions for logging.
Definition Log.h:32
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
JobType
Definition Job.h:14
JobTypeData(JobTypeData const &other)=delete
JobTypeData(JobTypeInfo const &info_, beast::insight::Collector::ptr const &collector, Logs &logs) noexcept
Definition JobTypeData.h:34
beast::insight::Event dequeue
Definition JobTypeData.h:31
beast::insight::Event execute
Definition JobTypeData.h:32
std::string name() const
Definition JobTypeData.h:56
JobType type() const
Definition JobTypeData.h:62
JobTypeInfo const & info
Definition JobTypeData.h:19
LoadMonitor::Stats stats()
Definition JobTypeData.h:74
beast::insight::Collector::ptr m_collector
Definition JobTypeData.h:15
JobTypeData & operator=(JobTypeData const &other)=delete
LoadMonitor m_load
Definition JobTypeData.h:12
LoadMonitor & load()
Definition JobTypeData.h:68