rippled
Loading...
Searching...
No Matches
JobTypeData.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_JOBTYPEDATA_H_INCLUDED
21#define RIPPLE_CORE_JOBTYPEDATA_H_INCLUDED
22
23#include <xrpld/core/JobTypeInfo.h>
24
25#include <xrpl/basics/Log.h>
26#include <xrpl/beast/insight/Collector.h>
27
28namespace ripple {
29
31{
32private:
34
35 /* Support for insight */
37
38public:
39 /* The job category which we represent */
41
42 /* The number of jobs waiting */
44
45 /* The number presently running */
47
48 /* And the number we deferred executing because of job limits */
50
51 /* Notification callbacks */
54
56 JobTypeInfo const& info_,
57 beast::insight::Collector::ptr const& collector,
58 Logs& logs) noexcept
59 : m_load(logs.journal("LoadMonitor"))
60 , m_collector(collector)
61 , info(info_)
62 , waiting(0)
63 , running(0)
64 , deferred(0)
65 {
68
69 if (!info.special())
70 {
71 dequeue = m_collector->make_event(info.name() + "_q");
72 execute = m_collector->make_event(info.name());
73 }
74 }
75
76 /* Not copy-constructible or assignable */
77 JobTypeData(JobTypeData const& other) = delete;
79 operator=(JobTypeData const& other) = delete;
80
82 name() const
83 {
84 return info.name();
85 }
86
88 type() const
89 {
90 return info.type();
91 }
92
95 {
96 return m_load;
97 }
98
101 {
102 return m_load.getStats();
103 }
104};
105
106} // namespace ripple
107
108#endif
A metric for reporting event timing.
Definition: Event.h:41
Holds all the 'static' information about a job, which does not change.
Definition: JobTypeInfo.h:29
std::chrono::milliseconds getPeakLatency() const
Definition: JobTypeInfo.h:94
JobType type() const
Definition: JobTypeInfo.h:64
bool special() const
Definition: JobTypeInfo.h:82
std::chrono::milliseconds getAverageLatency() const
Definition: JobTypeInfo.h:88
std::string const & name() const
Definition: JobTypeInfo.h:70
void setTargetLatency(std::chrono::milliseconds avg, std::chrono::milliseconds pk)
Manages partitions for logging.
Definition: Log.h:51
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
JobType
Definition: Job.h:35
std::string name() const
Definition: JobTypeData.h:82
JobTypeData & operator=(JobTypeData const &other)=delete
LoadMonitor m_load
Definition: JobTypeData.h:33
LoadMonitor & load()
Definition: JobTypeData.h:94
JobTypeData(JobTypeData const &other)=delete
JobType type() const
Definition: JobTypeData.h:88
JobTypeInfo const & info
Definition: JobTypeData.h:40
beast::insight::Collector::ptr m_collector
Definition: JobTypeData.h:36
beast::insight::Event execute
Definition: JobTypeData.h:53
beast::insight::Event dequeue
Definition: JobTypeData.h:52
LoadMonitor::Stats stats()
Definition: JobTypeData.h:100
JobTypeData(JobTypeInfo const &info_, beast::insight::Collector::ptr const &collector, Logs &logs) noexcept
Definition: JobTypeData.h:55