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