Kea  1.9.9-git
context.h
Go to the documentation of this file.
1 // Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef CONTEXT_H
8 #define CONTEXT_H
9 
10 #include <stats/observation.h>
11 #include <boost/shared_ptr.hpp>
12 #include <mutex>
13 #include <string>
14 
15 namespace isc {
16 namespace stats {
17 
19 class DuplicateStat : public Exception {
20 public:
21  DuplicateStat(const char* file, size_t line, const char* what) :
22  isc::Exception(file, line, what) {}
23 };
24 
31 struct StatContext {
32 public:
33 
38  ObservationPtr get(const std::string& name) const;
39 
44  void add(const ObservationPtr& obs);
45 
50  bool del(const std::string& name);
51 
55  size_t size();
56 
58  void clear();
59 
61  void resetAll();
62 
66  void setMaxSampleCountAll(uint32_t max_samples);
67 
71  void setMaxSampleAgeAll(const StatsDuration& duration);
72 
77 
78 private:
79 
81  std::map<std::string, ObservationPtr> stats_;
82 };
83 
85 typedef boost::shared_ptr<StatContext> StatContextPtr;
86 
87 };
88 };
89 
90 #endif // CONTEXT_H
boost::shared_ptr< StatContext > StatContextPtr
Pointer to the statistics context.
Definition: context.h:85
void setMaxSampleAgeAll(const StatsDuration &duration)
Sets duration for all observations.
Definition: context.cc:90
void resetAll()
Resets all observations.
Definition: context.cc:61
void clear()
Removes all observations.
Definition: context.cc:56
Exception indicating that a given statistic is duplicated.
Definition: context.h:19
std::chrono::system_clock::duration StatsDuration
Defines duration type.
Definition: observation.h:39
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
Statistics context.
Definition: context.h:31
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
size_t size()
Returns the number of observations.
Definition: context.cc:51
void add(const ObservationPtr &obs)
Adds a new observation.
Definition: context.cc:30
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
DuplicateStat(const char *file, size_t line, const char *what)
Definition: context.h:21
bool del(const std::string &name)
Attempts to delete an observation.
Definition: context.cc:41
isc::data::ConstElementPtr getAll() const
Returns a map with all observations.
Definition: context.cc:70
boost::shared_ptr< Observation > ObservationPtr
Observation pointer.
Definition: observation.h:440
void setMaxSampleCountAll(uint32_t max_samples)
Sets max sample count for all observations.
Definition: context.cc:81