NCBI C++ ToolKit
ns_alert.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef NETSCHEDULE_ALERT__HPP
2 #define NETSCHEDULE_ALERT__HPP
3 
4 /* $Id: ns_alert.hpp 84290 2018-10-31 14:21:21Z satskyse $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Sergey Satskiy
30  *
31  * File Description:
32  * Net schedule server alerts
33  *
34  */
35 
36 
37 #include "ns_precise_time.hpp"
38 #include <corelib/ncbimtx.hpp>
39 
40 #include <map>
41 
42 
44 
45 
46 enum EAlertType {
47  eUnknown = -1,
50  ePidFile = 2,
52  eAccess = 4,
54  eReinit = 6,
55  eNoDump = 7,
61 };
62 
64  eNotFound = 0,
66  eAcknowledged = 2
67 };
68 
69 
71 {
74  bool m_On;
75  size_t m_Count; // total, i.e. since startup
76  size_t m_CountSinceAck; // since acknowledge
77  string m_User;
78  string m_Message;
79 
84  {}
85 
86  string Serialize(void) const;
87 };
88 
89 
90 
91 
92 class CNSAlerts
93 {
94  public:
95  void Register(enum EAlertType alert_type, const string & message);
96  enum EAlertAckResult Acknowledge(const string & alert_id,
97  const string & user);
98  enum EAlertAckResult Acknowledge(enum EAlertType alert_type,
99  const string & user);
100  string GetURLEncoded(void) const;
101  string Serialize(void) const;
102 
103  private:
105  map< enum EAlertType,
107 
108  enum EAlertType x_IdToType(const string & alert_id) const;
109  string x_TypeToId(enum EAlertType type) const;
110 };
111 
112 
113 
115 
116 #endif /* NETSCHEDULE_ALERT__HPP */
117 
CFastMutex –.
Definition: ncbimtx.hpp:667
string GetURLEncoded(void) const
Definition: ns_alert.cpp:164
CFastMutex m_Lock
Definition: ns_alert.hpp:104
string Serialize(void) const
Definition: ns_alert.cpp:185
enum EAlertAckResult Acknowledge(const string &alert_id, const string &user)
Definition: ns_alert.cpp:109
enum EAlertType x_IdToType(const string &alert_id) const
Definition: ns_alert.cpp:142
string x_TypeToId(enum EAlertType type) const
Definition: ns_alert.cpp:152
void Register(enum EAlertType alert_type, const string &message)
Definition: ns_alert.cpp:84
map< enum EAlertType, SNSAlertAttributes > m_Alerts
Definition: ns_alert.hpp:106
Definition: map.hpp:338
#define true
Definition: bool.h:35
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
Multi-threading – mutexes; rw-locks; semaphore.
EAlertAckResult
Definition: ns_alert.hpp:63
@ eAcknowledged
Definition: ns_alert.hpp:66
@ eNotFound
Definition: ns_alert.hpp:64
@ eAlreadyAcknowledged
Definition: ns_alert.hpp:65
EAlertType
Definition: ns_alert.hpp:46
@ eConfigOutOfSync
Definition: ns_alert.hpp:53
@ eMaxQueues
Definition: ns_alert.hpp:57
@ eReinit
Definition: ns_alert.hpp:54
@ eStartupConfig
Definition: ns_alert.hpp:48
@ ePidFile
Definition: ns_alert.hpp:50
@ eStartAfterCrash
Definition: ns_alert.hpp:51
@ eDumpSpaceError
Definition: ns_alert.hpp:59
@ eUnknown
Definition: ns_alert.hpp:47
@ eDumpLoadError
Definition: ns_alert.hpp:58
@ eAccess
Definition: ns_alert.hpp:52
@ eReconfigure
Definition: ns_alert.hpp:49
@ eDumpError
Definition: ns_alert.hpp:56
@ eNoDump
Definition: ns_alert.hpp:55
@ eDataDirRemoveError
Definition: ns_alert.hpp:60
string Serialize(void) const
Definition: ns_alert.cpp:64
CNSPreciseTime m_AcknowledgedTimestamp
Definition: ns_alert.hpp:73
CNSPreciseTime m_LastDetectedTimestamp
Definition: ns_alert.hpp:72
size_t m_CountSinceAck
Definition: ns_alert.hpp:76
Definition: type.c:6
Modified on Sun Apr 21 03:42:49 2024 by modify_doxy.py rev. 669887