0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SystemState.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; version 3 of the
9  * 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 
28 #ifndef Hypertable_Master_SystemState_h
29 #define Hypertable_Master_SystemState_h
30 
31 #include <vector>
32 
35 
36 #include "NotificationMessage.h"
37 
38 namespace Hypertable {
39 
45  class SystemState : public MetaLog::Entity {
46  public:
47 
56  SystemState();
57 
61  SystemState(const MetaLog::EntityHeader &header_);
62 
64  virtual ~SystemState() { }
65 
76  bool admin_set(const std::vector<SystemVariable::Spec> &specs);
77 
89  bool admin_set(int code, bool value);
90 
106  bool auto_set(int code, bool value, const String &reason);
107 
117  void get(std::vector<SystemVariable::Spec> &specs, uint64_t *generation);
118 
124  bool get_notifications(std::vector<NotificationMessage> &notifications);
125 
132  void get_non_default(std::vector<SystemVariable::Spec> &specs,
133  uint64_t *generation=0);
134 
138  const String name() override { return "SystemState"; }
139 
143  void display(std::ostream &os) override;
144 
152  void decode(const uint8_t **bufp, size_t *remainp,
153  uint16_t definition_version) override;
154 
155  private:
156 
157  uint8_t encoding_version() const override;
158 
159  size_t encoded_length_internal() const override;
160 
161  void encode_internal(uint8_t **bufp) const override;
162 
163  void decode_internal(uint8_t version, const uint8_t **bufp,
164  size_t *remainp) override;
165 
166  void decode_old(const uint8_t **bufp, size_t *remainp);
167 
169  uint64_t m_generation;
170 
172  std::vector<SystemVariable::Spec> m_admin_specified;
173 
175  std::vector<int32_t> m_admin_last_notification;
176 
178  std::vector<SystemVariable::Spec> m_auto_specified;
179 
181  std::vector<int32_t> m_auto_last_notification;
182 
184  std::vector<NotificationMessage> m_notifications;
185 
188  };
189 
191  typedef std::shared_ptr<SystemState> SystemStatePtr;
192 
195 }
196 
197 #endif // Hypertable_Master_SystemState_h
void display(std::ostream &os) override
Return textual representation of entity state.
Definition: SystemState.cc:178
std::vector< int32_t > m_auto_last_notification
Last notification times for auto set variables.
Definition: SystemState.h:181
void decode(const uint8_t **bufp, size_t *remainp, uint16_t definition_version) override
Decodes system state.
Definition: SystemState.cc:188
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
const String name() override
Return name of entity.
Definition: SystemState.h:138
void decode_internal(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Reads serialized representation of object from a buffer.
Definition: SystemState.cc:227
Declarations for SystemVariable.
bool admin_set(const std::vector< SystemVariable::Spec > &specs)
Set a vector of variables by administrator.
Definition: SystemState.cc:54
std::shared_ptr< SystemState > SystemStatePtr
Shared smart pointer to SystemState.
Definition: SystemState.h:191
std::vector< NotificationMessage > m_notifications
Pending notification messages.
Definition: SystemState.h:184
Base class for MetaLog entities.
Definition: MetaLogEntity.h:62
uint64_t m_generation
Generation number incremented with each state change.
Definition: SystemState.h:169
void get_non_default(std::vector< SystemVariable::Spec > &specs, uint64_t *generation=0)
Get system state variables that are not set to their default value.
Definition: SystemState.cc:157
size_t encoded_length_internal() const override
Returns internal serialized length.
Definition: SystemState.cc:202
virtual ~SystemState()
Destructor.
Definition: SystemState.h:64
Holds persistent global system state.
Definition: SystemState.h:45
Declarations for MetaLog::Entity.
Declarations for NotificationMessage This file contains declarations for NotificationMessage, a class for holding a notification message to be delivered to the administrator.
std::vector< int32_t > m_admin_last_notification
Last notification times for admin set variables.
Definition: SystemState.h:175
void decode_old(const uint8_t **bufp, size_t *remainp)
Definition: SystemState.cc:263
Hypertable definitions
std::vector< SystemVariable::Spec > m_auto_specified
Automatically set state variables.
Definition: SystemState.h:178
bool auto_set(int code, bool value, const String &reason)
Set a variable by automated condition.
Definition: SystemState.cc:105
SystemState()
Constructor.
Definition: SystemState.cc:33
void encode_internal(uint8_t **bufp) const override
Writes serialized representation of object to a buffer.
Definition: SystemState.cc:213
int32_t m_notification_interval
Notification interval in seconds.
Definition: SystemState.h:187
std::vector< SystemVariable::Spec > m_admin_specified
Administratively set state variables.
Definition: SystemState.h:172
uint8_t encoding_version() const override
Returns encoding version.
Definition: SystemState.cc:198
bool get_notifications(std::vector< NotificationMessage > &notifications)
Get pending notifications.
Definition: SystemState.cc:149