0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
StatusManager.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #ifndef FsBroker_Lib_StatusManager_h
28 #define FsBroker_Lib_StatusManager_h
29 
30 #include <Common/Status.h>
31 
32 #include <cerrno>
33 #include <chrono>
34 #include <mutex>
35 
36 namespace Hypertable {
37 namespace FsBroker {
38 namespace Lib {
39 
42 
44  class StatusManager {
45  public:
46 
48  StatusManager();
49 
53  void set_read_status(Status::Code code, const std::string &text);
54 
58  void set_write_status(Status::Code code, const std::string &text);
59 
62  void set_read_error(int error);
63 
66  void set_write_error(int error);
67 
69  void clear_status();
70 
73  Status &get() { return m_status; }
74 
75  private:
76 
80  void set_status(Status::Code code, const std::string &text);
81 
84  void set_error(int error);
85 
88 
91 
93  std::chrono::steady_clock::time_point m_last_read_error;
94 
96  std::chrono::steady_clock::time_point m_last_write_error;
97 
100  };
101 
103 
104 }}}
105 
106 #endif // FsBroker_Lib_Broker_h
void set_status(Status::Code code, const std::string &text)
Sets status.
static std::mutex mutex
Definition: Logger.cc:43
Status::Code m_current_status
Current status.
Definition: StatusManager.h:99
Holds Nagios-style program status information.
Definition: Status.h:42
Declarations for Status.
Code
Enumeration for status codes.
Definition: Status.h:47
std::mutex m_mutex
Mutex for serializaing access to members
Definition: StatusManager.h:87
std::chrono::steady_clock::time_point m_last_write_error
Time of last reported write error.
Definition: StatusManager.h:96
void set_write_status(Status::Code code, const std::string &text)
Sets write status.
void set_read_status(Status::Code code, const std::string &text)
Sets read status.
std::chrono::steady_clock::time_point m_last_read_error
Time of last reported read error.
Definition: StatusManager.h:93
void set_error(int error)
Sets status to CRITICAL with status text associated with errno.
Manages file system broker status.
Definition: StatusManager.h:44
void set_write_error(int error)
Sets status to CRITICAL with status text associated with errno.
void set_read_error(int error)
Sets status to CRITICAL with status text associated with errno.
Hypertable definitions
Status m_status
Status information.
Definition: StatusManager.h:90
void clear_status()
Clears status by setting it to OK.