0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ServerState.cc
Go to the documentation of this file.
1 /*
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 #include <Common/Compat.h>
29 
30 #include "ServerState.h"
31 
32 #include <Common/Logger.h>
33 
34 using namespace Hypertable;
35 using namespace std;
36 
39  for (int i=0; i<SystemVariable::COUNT; i++) {
40  spec.code = i;
42  m_specs.push_back(spec);
43  }
44 }
45 
47  return m_specs[SystemVariable::READONLY].value;
48 }
49 
50 void ServerState::set(int64_t generation, const std::vector<SystemVariable::Spec> &specs) {
51  lock_guard<mutex> lock(m_mutex);
52  if (generation > m_generation) {
53  for (auto &spec : specs) {
54  if (spec.code < (int)m_specs.size())
55  m_specs[spec.code].value = spec.value;
56  else
57  HT_WARNF("Attempt to set unknown server state variable %d to %s",
58  spec.code, spec.value ? "true" : "false");
59  }
60  m_generation = generation;
61  }
62 }
bool readonly()
Returns value of READONLY variable.
Definition: ServerState.cc:46
void set(int64_t generation, const std::vector< SystemVariable::Spec > &specs)
Sets state variables.
Definition: ServerState.cc:50
#define HT_WARNF(msg,...)
Definition: Logger.h:290
int32_t code
Variable code.
bool default_value(int var_code)
Returns default value for given variable.
STL namespace.
Logging routines and macros.
ServerState()
Constructor.
Definition: ServerState.cc:37
Compatibility Macros for C/C++.
Holds a variable code and boolean value.
Hypertable definitions
Declarations for ServerState.