xrpld
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/beast/insight/Event.h>
6#include <xrpl/core/Job.h>
7#include <xrpl/core/JobTypeInfo.h>
8#include <xrpl/core/LoadMonitor.h>
9
10#include <utility>
11
12namespace xrpl {
13
15{
16private:
18
19 /* Support for insight */
21
22public:
23 /* The job category which we represent */
25
26 /* The number of jobs waiting */
27 int waiting{0};
28
29 /* The number presently running */
30 int running{0};
31
32 /* And the number we deferred executing because of job limits */
33 int deferred{0};
34
35 /* Notification callbacks */
38
40 JobTypeInfo const& info,
42 Logs& logs) noexcept
43 : load_(logs.journal("LoadMonitor")), collector_(std::move(collector)), info(info)
44
45 {
46 load_.setTargetLatency(info.getAverageLatency(), info.getPeakLatency());
47
48 if (!info.special())
49 {
50 dequeue = collector_->makeEvent(info.name() + "_q");
51 execute = collector_->makeEvent(info.name());
52 }
53 }
54
55 /* Not copy-constructible or assignable */
56 JobTypeData(JobTypeData const& other) = delete;
58 operator=(JobTypeData const& other) = delete;
59
60 [[nodiscard]] std::string
61 name() const
62 {
63 return info.name();
64 }
65
66 [[nodiscard]] JobType
67 type() const
68 {
69 return info.type();
70 }
71
74 {
75 return load_;
76 }
77
80 {
81 return load_.getStats();
82 }
83};
84
85} // namespace xrpl
std::shared_ptr< Collector > ptr
Definition Collector.h:29
A metric for reporting event timing.
Definition Event.h:22
Holds all the 'static' information about a job, which does not change.
Definition JobTypeInfo.h:15
Manages partitions for logging.
Definition Log.h:23
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
JobType
Definition Job.h:21
JobTypeData(JobTypeData const &other)=delete
beast::insight::Collector::ptr collector_
Definition JobTypeData.h:20
beast::insight::Event dequeue
Definition JobTypeData.h:36
LoadMonitor load_
Definition JobTypeData.h:17
beast::insight::Event execute
Definition JobTypeData.h:37
std::string name() const
Definition JobTypeData.h:61
JobType type() const
Definition JobTypeData.h:67
JobTypeInfo const & info
Definition JobTypeData.h:24
LoadMonitor::Stats stats()
Definition JobTypeData.h:79
JobTypeData & operator=(JobTypeData const &other)=delete
JobTypeData(JobTypeInfo const &info, beast::insight::Collector::ptr collector, Logs &logs) noexcept
Definition JobTypeData.h:39
LoadMonitor & load()
Definition JobTypeData.h:73