~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/src/mgmsrv/Config.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#include "Config.hpp"
 
17
#include <ctype.h>
 
18
#include <string.h>
 
19
#include "MgmtErrorReporter.hpp"
 
20
#include <Properties.hpp>
 
21
 
 
22
//*****************************************************************************
 
23
//  Ctor / Dtor
 
24
//*****************************************************************************
 
25
 
 
26
Config::Config() {
 
27
  m_oldConfig = 0;
 
28
  m_configValues = 0;
 
29
}
 
30
 
 
31
Config::~Config() {
 
32
  if(m_configValues != 0){
 
33
    free(m_configValues);
 
34
  }
 
35
 
 
36
  if(m_oldConfig != 0)
 
37
    delete m_oldConfig;
 
38
}
 
39
 
 
40
/*****************************************************************************/
 
41
 
 
42
void 
 
43
Config::printAllNameValuePairs(NdbOut &out,
 
44
                               const Properties *prop,
 
45
                               const char* s) const {
 
46
  Properties::Iterator it(prop);
 
47
  const Properties * section = m_info.getInfo(s);
 
48
  for (const char* n = it.first(); n != NULL; n = it.next()) {
 
49
    Uint32 int_value;
 
50
    const char* str_value;
 
51
    Uint64 int_64;
 
52
 
 
53
    if(!section->contains(n))
 
54
      continue;
 
55
    if (m_info.getStatus(section, n) == ConfigInfo::CI_INTERNAL) 
 
56
      continue;
 
57
    if (m_info.getStatus(section, n) == ConfigInfo::CI_DEPRICATED)
 
58
      continue;
 
59
    if (m_info.getStatus(section, n) == ConfigInfo::CI_NOTIMPLEMENTED)
 
60
      continue;
 
61
 
 
62
    out << n << ": ";
 
63
 
 
64
    switch (m_info.getType(section, n)) {
 
65
    case ConfigInfo::CI_INT:
 
66
      MGM_REQUIRE(prop->get(n, &int_value)); 
 
67
      out << int_value;
 
68
      break;
 
69
 
 
70
    case ConfigInfo::CI_INT64:
 
71
      MGM_REQUIRE(prop->get(n, &int_64)); 
 
72
      out << int_64;
 
73
      break;
 
74
      
 
75
    case ConfigInfo::CI_BOOL:
 
76
      MGM_REQUIRE(prop->get(n, &int_value)); 
 
77
      if (int_value) {
 
78
        out << "Y";
 
79
      } else {
 
80
        out << "N";
 
81
      }
 
82
      break;
 
83
    case ConfigInfo::CI_STRING:
 
84
      MGM_REQUIRE(prop->get(n, &str_value)); 
 
85
      out << str_value;
 
86
      break;
 
87
    case ConfigInfo::CI_SECTION:
 
88
      out << "SECTION";
 
89
      break;
 
90
    }      
 
91
    out << endl;
 
92
  }
 
93
}
 
94
 
 
95
/*****************************************************************************/
 
96
   
 
97
void Config::printConfigFile(NdbOut &out) const {
 
98
#if 0
 
99
  Uint32 noOfNodes, noOfConnections, noOfComputers;
 
100
  MGM_REQUIRE(get("NoOfNodes", &noOfNodes));
 
101
  MGM_REQUIRE(get("NoOfConnections", &noOfConnections));
 
102
  MGM_REQUIRE(get("NoOfComputers", &noOfComputers));
 
103
 
 
104
  out << 
 
105
    "######################################################################" <<
 
106
    endl <<
 
107
    "#" << endl <<
 
108
    "#  NDB Cluster  System configuration" << endl <<
 
109
    "#" << endl <<
 
110
    "######################################################################" <<
 
111
    endl << 
 
112
    "# No of nodes (DB, API or MGM):  " << noOfNodes << endl <<
 
113
    "# No of connections:             " << noOfConnections << endl <<
 
114
    "######################################################################" <<
 
115
    endl;
 
116
 
 
117
  /**************************
 
118
   * Print COMPUTER configs *
 
119
   **************************/
 
120
  const char * name;
 
121
  Properties::Iterator it(this);
 
122
  for(name = it.first(); name != NULL; name = it.next()){
 
123
    if(strncasecmp("Computer_", name, 9) == 0){ 
 
124
      
 
125
      const Properties *prop;
 
126
      out << endl << "[COMPUTER]" << endl;
 
127
      MGM_REQUIRE(get(name, &prop));
 
128
      printAllNameValuePairs(out, prop, "COMPUTER");
 
129
      
 
130
      out << endl <<
 
131
        "###################################################################" <<
 
132
        endl;
 
133
 
 
134
    } else if(strncasecmp("Node_", name, 5) == 0){
 
135
      /**********************
 
136
       * Print NODE configs *
 
137
       **********************/
 
138
      const Properties *prop;
 
139
      const char *s;
 
140
 
 
141
      MGM_REQUIRE(get(name, &prop));
 
142
      MGM_REQUIRE(prop->get("Type", &s));
 
143
      out << endl << "[" << s << "]" << endl;
 
144
      printAllNameValuePairs(out, prop, s);
 
145
 
 
146
      out << endl <<
 
147
        "###################################################################" <<
 
148
        endl;
 
149
    } else if(strncasecmp("Connection_", name, 11) == 0){
 
150
      /****************************
 
151
       * Print CONNECTION configs *
 
152
       ****************************/
 
153
      const Properties *prop;
 
154
      const char *s;
 
155
 
 
156
      MGM_REQUIRE(get(name, &prop));
 
157
      MGM_REQUIRE(prop->get("Type", &s));
 
158
      out << endl << "[" << s << "]" << endl;
 
159
      printAllNameValuePairs(out, prop, s);
 
160
      
 
161
      out << endl <<
 
162
        "###################################################################" <<
 
163
        endl;
 
164
    } else if(strncasecmp("SYSTEM", name, strlen("SYSTEM")) == 0) {
 
165
      /************************
 
166
       * Print SYSTEM configs *
 
167
       ************************/
 
168
      const Properties *prop;
 
169
 
 
170
      MGM_REQUIRE(get(name, &prop));
 
171
      out << endl << "[SYSTEM]" << endl;
 
172
      printAllNameValuePairs(out, prop, "SYSTEM");
 
173
      
 
174
      out << endl <<
 
175
        "###################################################################" <<
 
176
        endl;
 
177
    }
 
178
  }
 
179
#endif
 
180
}