Kea 2.5.8
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
15namespace isc {
16namespace stats {
17
19class DuplicateStat : public Exception {
20public:
21 DuplicateStat(const char* file, size_t line, const char* what) :
22 isc::Exception(file, line, what) {}
23};
24
32public:
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
78private:
79
81 std::map<std::string, ObservationPtr> stats_;
82};
83
85typedef boost::shared_ptr<StatContext> StatContextPtr;
86
87};
88};
89
90#endif // CONTEXT_H
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Exception indicating that a given statistic is duplicated.
Definition: context.h:19
DuplicateStat(const char *file, size_t line, const char *what)
Definition: context.h:21
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:29
boost::shared_ptr< Observation > ObservationPtr
Observation pointer.
Definition: observation.h:479
boost::shared_ptr< StatContext > StatContextPtr
Pointer to the statistics context.
Definition: context.h:85
std::chrono::system_clock::duration StatsDuration
Defines duration type.
Definition: observation.h:43
Defines the logger used by the top-level component of kea-lfc.
Statistics context.
Definition: context.h:31
bool del(const std::string &name)
Attempts to delete an observation.
Definition: context.cc:41
void clear()
Removes all observations.
Definition: context.cc:56
void setMaxSampleAgeAll(const StatsDuration &duration)
Sets duration for all observations.
Definition: context.cc:90
void resetAll()
Resets all observations.
Definition: context.cc:61
isc::data::ConstElementPtr getAll() const
Returns a map with all observations.
Definition: context.cc:70
void add(const ObservationPtr &obs)
Adds a new observation.
Definition: context.cc:30
void setMaxSampleCountAll(uint32_t max_samples)
Sets max sample count for all observations.
Definition: context.cc:81
ObservationPtr get(const std::string &name) const
Attempts to get an observation.
Definition: context.cc:21
size_t size()
Returns the number of observations.
Definition: context.cc:51