Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
b43d0f04
Commit
b43d0f04
authored
Sep 30, 2005
by
jonas@perch.ndb.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge perch.ndb.mysql.com:/home/jonas/src/mysql-5.0
into perch.ndb.mysql.com:/home/jonas/src/mysql-5.0-push
parents
a11dcd74
2722dff1
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
611 additions
and
82 deletions
+611
-82
include/my_sys.h
include/my_sys.h
+1
-0
mysql-test/r/ndb_config.result
mysql-test/r/ndb_config.result
+2
-0
mysql-test/std_data/ndb_config_mycnf1.cnf
mysql-test/std_data/ndb_config_mycnf1.cnf
+15
-0
mysql-test/t/ndb_config.test
mysql-test/t/ndb_config.test
+3
-0
mysys/default.c
mysys/default.c
+4
-0
ndb/src/mgmsrv/ConfigInfo.cpp
ndb/src/mgmsrv/ConfigInfo.cpp
+46
-6
ndb/src/mgmsrv/InitConfigFileParser.cpp
ndb/src/mgmsrv/InitConfigFileParser.cpp
+372
-9
ndb/src/mgmsrv/InitConfigFileParser.hpp
ndb/src/mgmsrv/InitConfigFileParser.hpp
+20
-2
ndb/src/mgmsrv/MgmtSrvr.cpp
ndb/src/mgmsrv/MgmtSrvr.cpp
+1
-3
ndb/src/mgmsrv/MgmtSrvrConfig.cpp
ndb/src/mgmsrv/MgmtSrvrConfig.cpp
+9
-1
ndb/src/mgmsrv/main.cpp
ndb/src/mgmsrv/main.cpp
+21
-3
ndb/tools/ndb_config.cpp
ndb/tools/ndb_config.cpp
+117
-58
No files found.
include/my_sys.h
View file @
b43d0f04
...
...
@@ -262,6 +262,7 @@ extern char wild_many,wild_one,wild_prefix;
extern
const
char
*
charsets_dir
;
extern
char
*
defaults_extra_file
;
extern
const
char
*
defaults_group_suffix
;
extern
const
char
*
defaults_file
;
extern
my_bool
timed_mutexes
;
...
...
mysql-test/r/ndb_config.result
View file @
b43d0f04
...
...
@@ -3,3 +3,5 @@ ndbd,1,localhost ndbd,2,localhost ndb_mgmd,3,localhost mysqld,4, mysqld,5, mysql
1 localhost 41943040 12582912
2 localhost 41943040 12582912
1 2
ndbd,1,localhost ndbd,2,localhost ndb_mgmd,3,localhost mysqld,4, mysqld,5, mysqld,6, mysqld,7,
ndbd,1,localhost,52428800,26214400 ndbd,2,localhost,52428800,36700160 ndbd,3,localhost,52428800,52428800 ndbd,4,localhost,52428800,52428800 ndb_mgmd,5,localhost,, mysqld,6,localhost,,
mysql-test/std_data/ndb_config_mycnf1.cnf
0 → 100644
View file @
b43d0f04
[cluster_config]
NoOfReplicas=1
DataMemory=50M
[cluster_config.jonas]
IndexMemory=50M
ndbd = localhost,localhost,localhost,localhost
ndb_mgmd = localhost
mysqld = localhost
[cluster_config.ndbd.1]
DataMemory=25M
[cluster_config.ndbd.2.jonas]
DataMemory=35M
mysql-test/t/ndb_config.test
View file @
b43d0f04
...
...
@@ -6,5 +6,8 @@
--
exec
$NDB_TOOLS_DIR
/
ndb_config
--
no
-
defaults
--
query
=
nodeid
,
host
,
DataMemory
,
IndexMemory
--
type
=
ndbd
2
>
/
dev
/
null
--
exec
$NDB_TOOLS_DIR
/
ndb_config
--
no
-
defaults
-
r
\
\n
-
f
" "
--
query
=
nodeid
,
host
,
DataMemory
,
IndexMemory
--
type
=
ndbd
2
>
/
dev
/
null
--
exec
$NDB_TOOLS_DIR
/
ndb_config
--
no
-
defaults
--
query
=
nodeid
--
type
=
ndbd
--
host
=
localhost
2
>
/
dev
/
null
--
exec
$NDB_TOOLS_DIR
/
ndb_config
--
no
-
defaults
--
query
=
type
,
nodeid
,
host
--
config
-
file
=
$NDB_BACKUP_DIR
/
config
.
ini
2
>
/
dev
/
null
# End of 4.1 tests
--
exec
$NDB_TOOLS_DIR
/
ndb_config
--
defaults
-
group
-
suffix
=.
jonas
--
defaults
-
file
=
$MYSQL_TEST_DIR
/
std_data
/
ndb_config_mycnf1
.
cnf
--
query
=
type
,
nodeid
,
host
,
IndexMemory
,
DataMemory
--
mycnf
2
>
/
dev
/
null
mysys/default.c
View file @
b43d0f04
...
...
@@ -42,6 +42,7 @@
#include <winbase.h>
#endif
const
char
*
defaults_file
=
0
;
const
char
*
defaults_group_suffix
=
0
;
char
*
defaults_extra_file
=
0
;
...
...
@@ -140,6 +141,9 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv,
if
(
forced_extra_defaults
)
defaults_extra_file
=
(
char
*
)
forced_extra_defaults
;
if
(
forced_default_file
)
defaults_file
=
forced_default_file
;
/*
We can only handle 'defaults-group-suffix' if we are called from
load_defaults() as otherwise we can't know the type of 'func_ctx'
...
...
ndb/src/mgmsrv/ConfigInfo.cpp
View file @
b43d0f04
...
...
@@ -241,6 +241,9 @@ struct DepricationTransform {
static
const
DepricationTransform
f_deprication
[]
=
{
{
DB_TOKEN
,
"Discless"
,
"Diskless"
,
0
,
1
},
{
DB_TOKEN
,
"Id"
,
"nodeid"
,
0
,
1
},
{
API_TOKEN
,
"Id"
,
"nodeid"
,
0
,
1
},
{
MGM_TOKEN
,
"Id"
,
"nodeid"
,
0
,
1
},
{
0
,
0
,
0
,
0
,
0
}
};
...
...
@@ -405,9 +408,21 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
0
,
0
},
{
CFG_NODE_ID
,
KEY_INTERNAL
,
"Id"
,
DB_TOKEN
,
""
,
ConfigInfo
::
CI_DEPRICATED
,
false
,
ConfigInfo
::
CI_INT
,
MANDATORY
,
"1"
,
STR_VALUE
(
MAX_NODES
)
},
{
CFG_NODE_ID
,
"nodeid"
,
DB_TOKEN
,
"Number identifying the database node ("
DB_TOKEN_PRINT
")"
,
ConfigInfo
::
CI_USED
,
false
,
...
...
@@ -1244,9 +1259,21 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
0
,
0
},
{
CFG_NODE_ID
,
KEY_INTERNAL
,
"Id"
,
API_TOKEN
,
""
,
ConfigInfo
::
CI_DEPRICATED
,
false
,
ConfigInfo
::
CI_INT
,
MANDATORY
,
"1"
,
STR_VALUE
(
MAX_NODES
)
},
{
CFG_NODE_ID
,
"nodeid"
,
API_TOKEN
,
"Number identifying application node ("
API_TOKEN_PRINT
")"
,
ConfigInfo
::
CI_USED
,
false
,
...
...
@@ -1375,9 +1402,21 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
0
,
0
},
{
CFG_NODE_ID
,
KEY_INTERNAL
,
"Id"
,
MGM_TOKEN
,
""
,
ConfigInfo
::
CI_DEPRICATED
,
false
,
ConfigInfo
::
CI_INT
,
MANDATORY
,
"1"
,
STR_VALUE
(
MAX_NODES
)
},
{
CFG_NODE_ID
,
"nodeid"
,
MGM_TOKEN
,
"Number identifying the management server node ("
MGM_TOKEN_PRINT
")"
,
ConfigInfo
::
CI_USED
,
false
,
...
...
@@ -2516,14 +2555,14 @@ bool
transformNode
(
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
data
){
Uint32
id
;
if
(
!
ctx
.
m_currentSection
->
get
(
"Id"
,
&
id
)){
if
(
!
ctx
.
m_currentSection
->
get
(
"
nodeid"
,
&
id
)
&&
!
ctx
.
m_currentSection
->
get
(
"
Id"
,
&
id
)){
Uint32
nextNodeId
=
1
;
ctx
.
m_userProperties
.
get
(
"NextNodeId"
,
&
nextNodeId
);
id
=
nextNodeId
;
while
(
ctx
.
m_userProperties
.
get
(
"AllocatedNodeId_"
,
id
,
&
id
))
id
++
;
ctx
.
m_userProperties
.
put
(
"NextNodeId"
,
id
+
1
,
true
);
ctx
.
m_currentSection
->
put
(
"
I
d"
,
id
);
ctx
.
m_currentSection
->
put
(
"
nodei
d"
,
id
);
#if 0
ctx.reportError("Mandatory parameter Id missing from section "
"[%s] starting at line: %d",
...
...
@@ -2531,7 +2570,7 @@ transformNode(InitConfigFileParser::Context & ctx, const char * data){
return false;
#endif
}
else
if
(
ctx
.
m_userProperties
.
get
(
"AllocatedNodeId_"
,
id
,
&
id
))
{
ctx
.
reportError
(
"Duplicate
I
d in section "
ctx
.
reportError
(
"Duplicate
nodei
d in section "
"[%s] starting at line: %d"
,
ctx
.
fname
,
ctx
.
m_sectionLineno
);
return
false
;
...
...
@@ -3356,6 +3395,7 @@ transform(InitConfigFileParser::Context & ctx,
PropertiesType
oldType
;
require
(
ctx
.
m_currentSection
->
getTypeOf
(
oldName
,
&
oldType
));
ConfigInfo
::
Type
newType
=
ctx
.
m_info
->
getType
(
ctx
.
m_currentInfo
,
newName
);
if
(
!
((
oldType
==
PropertiesType_Uint32
||
oldType
==
PropertiesType_Uint64
)
&&
(
newType
==
ConfigInfo
::
CI_INT
||
newType
==
ConfigInfo
::
CI_INT64
||
newType
==
ConfigInfo
::
CI_BOOL
))){
ndbout
<<
"oldType: "
<<
(
int
)
oldType
<<
", newType: "
<<
(
int
)
newType
<<
endl
;
...
...
ndb/src/mgmsrv/InitConfigFileParser.cpp
View file @
b43d0f04
...
...
@@ -31,8 +31,10 @@ static void require(bool v) { if(!v) abort();}
//****************************************************************************
// Ctor / Dtor
//****************************************************************************
InitConfigFileParser
::
InitConfigFileParser
(){
InitConfigFileParser
::
InitConfigFileParser
(
FILE
*
out
)
{
m_info
=
new
ConfigInfo
();
m_errstream
=
out
?
out
:
stdout
;
}
InitConfigFileParser
::~
InitConfigFileParser
()
{
...
...
@@ -42,11 +44,12 @@ InitConfigFileParser::~InitConfigFileParser() {
//****************************************************************************
// Read Config File
//****************************************************************************
InitConfigFileParser
::
Context
::
Context
(
const
ConfigInfo
*
info
)
InitConfigFileParser
::
Context
::
Context
(
const
ConfigInfo
*
info
,
FILE
*
out
)
:
m_userProperties
(
true
),
m_configValues
(
1000
,
20
)
{
m_config
=
new
Properties
(
true
);
m_defaults
=
new
Properties
(
true
);
m_errstream
=
out
;
}
InitConfigFileParser
::
Context
::~
Context
(){
...
...
@@ -61,10 +64,10 @@ Config *
InitConfigFileParser
::
parseConfig
(
const
char
*
filename
)
{
FILE
*
file
=
fopen
(
filename
,
"r"
);
if
(
file
==
0
){
ndbout
<<
"Error opening file: "
<<
filename
<<
endl
;
fprintf
(
m_errstream
,
"Error opening file: %s
\n
"
,
filename
)
;
return
0
;
}
Config
*
ret
=
parseConfig
(
file
);
fclose
(
file
);
return
ret
;
...
...
@@ -75,7 +78,7 @@ InitConfigFileParser::parseConfig(FILE * file) {
char
line
[
MAX_LINE_LENGTH
];
Context
ctx
(
m_info
);
Context
ctx
(
m_info
,
m_errstream
);
ctx
.
m_lineno
=
0
;
ctx
.
m_currentSection
=
0
;
...
...
@@ -160,6 +163,13 @@ InitConfigFileParser::parseConfig(FILE * file) {
ctx
.
reportError
(
"Could not store section of configuration file."
);
return
0
;
}
return
run_config_rules
(
ctx
);
}
Config
*
InitConfigFileParser
::
run_config_rules
(
Context
&
ctx
)
{
for
(
size_t
i
=
0
;
ConfigInfo
::
m_ConfigRules
[
i
].
m_configRule
!=
0
;
i
++
){
ctx
.
type
=
InitConfigFileParser
::
Undefined
;
ctx
.
m_currentSection
=
0
;
...
...
@@ -267,10 +277,10 @@ bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line)
}
if
(
status
==
ConfigInfo
::
CI_DEPRICATED
)
{
const
char
*
desc
=
m_info
->
getDescription
(
ctx
.
m_currentInfo
,
fname
);
if
(
desc
){
if
(
desc
&&
desc
[
0
]
){
ctx
.
reportWarning
(
"[%s] %s is depricated, use %s instead"
,
ctx
.
fname
,
fname
,
desc
);
}
else
{
}
else
if
(
desc
==
0
)
{
ctx
.
reportWarning
(
"[%s] %s is depricated"
,
ctx
.
fname
,
fname
);
}
}
...
...
@@ -571,8 +581,9 @@ InitConfigFileParser::Context::reportError(const char * fmt, ...){
va_start
(
ap
,
fmt
);
if
(
fmt
!=
0
)
BaseString
::
vsnprintf
(
buf
,
sizeof
(
buf
)
-
1
,
fmt
,
ap
);
ndbout
<<
"Error line "
<<
m_lineno
<<
": "
<<
buf
<<
endl
;
va_end
(
ap
);
fprintf
(
m_errstream
,
"Error line %d: %s
\n
"
,
m_lineno
,
buf
);
//m_currentSection->print();
}
...
...
@@ -585,6 +596,358 @@ InitConfigFileParser::Context::reportWarning(const char * fmt, ...){
va_start
(
ap
,
fmt
);
if
(
fmt
!=
0
)
BaseString
::
vsnprintf
(
buf
,
sizeof
(
buf
)
-
1
,
fmt
,
ap
);
ndbout
<<
"Warning line "
<<
m_lineno
<<
": "
<<
buf
<<
endl
;
va_end
(
ap
);
fprintf
(
m_errstream
,
"Warning line %d: %s
\n
"
,
m_lineno
,
buf
);
}
#include <my_sys.h>
#include <my_getopt.h>
static
int
order
=
1
;
static
my_bool
parse_mycnf_opt
(
int
,
const
struct
my_option
*
opt
,
char
*
value
)
{
if
(
opt
->
comment
)
((
struct
my_option
*
)
opt
)
->
app_type
++
;
else
((
struct
my_option
*
)
opt
)
->
app_type
=
order
++
;
return
0
;
}
bool
InitConfigFileParser
::
store_in_properties
(
Vector
<
struct
my_option
>&
options
,
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
name
)
{
for
(
unsigned
i
=
0
;
i
<
options
.
size
();
i
++
)
{
if
(
options
[
i
].
comment
&&
options
[
i
].
app_type
&&
strcmp
(
options
[
i
].
comment
,
name
)
==
0
)
{
Uint64
value_int
;
switch
(
options
[
i
].
var_type
){
case
GET_INT
:
value_int
=
*
(
Uint32
*
)
options
[
i
].
value
;
break
;
case
GET_LL
:
value_int
=
*
(
Uint64
*
)
options
[
i
].
value
;
break
;
case
GET_STR
:
ctx
.
m_currentSection
->
put
(
options
[
i
].
name
,
(
char
*
)
options
[
i
].
value
);
continue
;
default:
abort
();
}
const
char
*
fname
=
options
[
i
].
name
;
if
(
!
m_info
->
verify
(
ctx
.
m_currentInfo
,
fname
,
value_int
))
{
ctx
.
reportError
(
"Illegal value %lld for parameter %s.
\n
"
"Legal values are between %Lu and %Lu"
,
value_int
,
fname
,
m_info
->
getMin
(
ctx
.
m_currentInfo
,
fname
),
m_info
->
getMax
(
ctx
.
m_currentInfo
,
fname
));
return
false
;
}
if
(
options
[
i
].
var_type
==
GET_INT
)
ctx
.
m_currentSection
->
put
(
options
[
i
].
name
,
(
Uint32
)
value_int
);
else
ctx
.
m_currentSection
->
put
(
options
[
i
].
name
,
value_int
);
}
}
return
true
;
}
bool
InitConfigFileParser
::
handle_mycnf_defaults
(
Vector
<
struct
my_option
>&
options
,
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
name
)
{
strcpy
(
ctx
.
fname
,
name
);
ctx
.
type
=
InitConfigFileParser
::
DefaultSection
;
ctx
.
m_currentSection
=
new
Properties
(
true
);
ctx
.
m_userDefaults
=
NULL
;
require
((
ctx
.
m_currentInfo
=
m_info
->
getInfo
(
ctx
.
fname
))
!=
0
);
require
((
ctx
.
m_systemDefaults
=
m_info
->
getDefaults
(
ctx
.
fname
))
!=
0
);
if
(
store_in_properties
(
options
,
ctx
,
name
))
return
storeSection
(
ctx
);
return
false
;
}
static
int
load_defaults
(
Vector
<
struct
my_option
>&
options
,
const
char
*
groups
[])
{
int
argc
=
1
;
const
char
*
argv
[]
=
{
"ndb_mgmd"
,
0
,
0
,
0
,
0
};
BaseString
file
;
BaseString
extra_file
;
BaseString
group_suffix
;
const
char
*
save_file
=
defaults_file
;
char
*
save_extra_file
=
defaults_extra_file
;
const
char
*
save_group_suffix
=
defaults_group_suffix
;
if
(
defaults_file
)
{
file
.
assfmt
(
"--defaults-file=%s"
,
defaults_file
);
argv
[
argc
++
]
=
file
.
c_str
();
}
if
(
defaults_extra_file
)
{
extra_file
.
assfmt
(
"--defaults-extra-file=%s"
,
defaults_extra_file
);
argv
[
argc
++
]
=
extra_file
.
c_str
();
}
if
(
defaults_group_suffix
)
{
group_suffix
.
assfmt
(
"--defaults-group-suffix=%s"
,
defaults_group_suffix
);
argv
[
argc
++
]
=
group_suffix
.
c_str
();
}
char
**
tmp
=
(
char
**
)
argv
;
int
ret
=
load_defaults
(
"my"
,
groups
,
&
argc
,
&
tmp
);
defaults_file
=
save_file
;
defaults_extra_file
=
save_extra_file
;
defaults_group_suffix
=
save_group_suffix
;
if
(
ret
==
0
)
{
return
handle_options
(
&
argc
,
&
tmp
,
options
.
getBase
(),
parse_mycnf_opt
);
}
return
ret
;
}
bool
InitConfigFileParser
::
load_mycnf_groups
(
Vector
<
struct
my_option
>
&
options
,
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
name
,
const
char
*
groups
[])
{
unsigned
i
;
Vector
<
struct
my_option
>
copy
;
for
(
i
=
0
;
i
<
options
.
size
();
i
++
)
{
if
(
options
[
i
].
comment
&&
strcmp
(
options
[
i
].
comment
,
name
)
==
0
)
{
options
[
i
].
app_type
=
0
;
copy
.
push_back
(
options
[
i
]);
}
}
struct
my_option
end
;
bzero
(
&
end
,
sizeof
(
end
));
copy
.
push_back
(
end
);
if
(
load_defaults
(
copy
,
groups
))
return
false
;
return
store_in_properties
(
copy
,
ctx
,
name
);
}
Config
*
InitConfigFileParser
::
parse_mycnf
()
{
int
i
;
Config
*
res
=
0
;
Vector
<
struct
my_option
>
options
;
for
(
i
=
0
;
i
<
ConfigInfo
::
m_NoOfParams
;
i
++
)
{
if
(
strcmp
(
ConfigInfo
::
m_ParamInfo
[
i
].
_section
,
"DB"
)
==
0
||
strcmp
(
ConfigInfo
::
m_ParamInfo
[
i
].
_section
,
"API"
)
==
0
||
strcmp
(
ConfigInfo
::
m_ParamInfo
[
i
].
_section
,
"MGM"
)
==
0
)
{
struct
my_option
opt
;
bzero
(
&
opt
,
sizeof
(
opt
));
const
ConfigInfo
::
ParamInfo
&
param
=
ConfigInfo
::
m_ParamInfo
[
i
];
switch
(
param
.
_type
){
case
ConfigInfo
:
:
CI_BOOL
:
opt
.
value
=
(
gptr
*
)
malloc
(
sizeof
(
int
));
opt
.
var_type
=
GET_INT
;
break
;
case
ConfigInfo
:
:
CI_INT
:
opt
.
value
=
(
gptr
*
)
malloc
(
sizeof
(
int
));
opt
.
var_type
=
GET_INT
;
require
(
convertStringToUint64
(
param
.
_min
,
(
Uint64
&
)
opt
.
min_value
));
require
(
convertStringToUint64
(
param
.
_max
,
(
Uint64
&
)
opt
.
max_value
));
break
;
case
ConfigInfo
:
:
CI_INT64
:
opt
.
value
=
(
gptr
*
)
malloc
(
sizeof
(
Int64
));
opt
.
var_type
=
GET_LL
;
require
(
convertStringToUint64
(
param
.
_min
,
(
Uint64
&
)
opt
.
min_value
));
require
(
convertStringToUint64
(
param
.
_max
,
(
Uint64
&
)
opt
.
max_value
));
break
;
case
ConfigInfo
:
:
CI_STRING
:
opt
.
value
=
(
gptr
*
)
malloc
(
sizeof
(
char
*
));
opt
.
var_type
=
GET_STR
;
break
;
default:
continue
;
}
opt
.
name
=
param
.
_fname
;
opt
.
id
=
256
;
opt
.
app_type
=
0
;
opt
.
arg_type
=
REQUIRED_ARG
;
opt
.
comment
=
param
.
_section
;
options
.
push_back
(
opt
);
}
}
struct
my_option
*
ndbd
,
*
ndb_mgmd
,
*
mysqld
,
*
api
;
/**
* Add ndbd, ndb_mgmd, api/mysqld
*/
{
struct
my_option
opt
;
bzero
(
&
opt
,
sizeof
(
opt
));
opt
.
name
=
"ndbd"
;
opt
.
id
=
256
;
opt
.
value
=
(
gptr
*
)
malloc
(
sizeof
(
char
*
));
opt
.
var_type
=
GET_STR
;
opt
.
arg_type
=
REQUIRED_ARG
;
options
.
push_back
(
opt
);
ndbd
=
&
options
.
back
();
opt
.
name
=
"ndb_mgmd"
;
opt
.
id
=
256
;
opt
.
value
=
(
gptr
*
)
malloc
(
sizeof
(
char
*
));
opt
.
var_type
=
GET_STR
;
opt
.
arg_type
=
REQUIRED_ARG
;
options
.
push_back
(
opt
);
ndb_mgmd
=
&
options
.
back
();
opt
.
name
=
"mysqld"
;
opt
.
id
=
256
;
opt
.
value
=
(
gptr
*
)
malloc
(
sizeof
(
char
*
));
opt
.
var_type
=
GET_STR
;
opt
.
arg_type
=
REQUIRED_ARG
;
options
.
push_back
(
opt
);
mysqld
=
&
options
.
back
();
opt
.
name
=
"api"
;
opt
.
id
=
256
;
opt
.
value
=
(
gptr
*
)
malloc
(
sizeof
(
char
*
));
opt
.
var_type
=
GET_STR
;
opt
.
arg_type
=
REQUIRED_ARG
;
options
.
push_back
(
opt
);
api
=
&
options
.
back
();
bzero
(
&
opt
,
sizeof
(
opt
));
options
.
push_back
(
opt
);
}
Context
ctx
(
m_info
,
m_errstream
);
const
char
*
groups
[]
=
{
"cluster_config"
,
0
};
if
(
load_defaults
(
options
,
groups
))
goto
end
;
ctx
.
m_lineno
=
0
;
if
(
!
handle_mycnf_defaults
(
options
,
ctx
,
"DB"
))
goto
end
;
if
(
!
handle_mycnf_defaults
(
options
,
ctx
,
"API"
))
goto
end
;
if
(
!
handle_mycnf_defaults
(
options
,
ctx
,
"MGM"
))
goto
end
;
{
struct
sect
{
struct
my_option
*
src
;
const
char
*
name
;
}
sections
[]
=
{
{
ndb_mgmd
,
"MGM"
}
,{
ndbd
,
"DB"
}
,{
mysqld
,
"API"
}
,{
api
,
"API"
}
,{
0
,
0
},
{
0
,
0
}
};
for
(
i
=
0
;
sections
[
i
].
src
;
i
++
)
{
for
(
int
j
=
i
+
1
;
sections
[
j
].
src
;
j
++
)
{
if
(
sections
[
j
].
src
->
app_type
<
sections
[
i
].
src
->
app_type
)
{
sect
swap
=
sections
[
i
];
sections
[
i
]
=
sections
[
j
];
sections
[
j
]
=
swap
;
}
}
}
ctx
.
type
=
InitConfigFileParser
::
Section
;
ctx
.
m_sectionLineno
=
ctx
.
m_lineno
;
for
(
i
=
0
;
sections
[
i
].
src
;
i
++
)
{
if
(
sections
[
i
].
src
->
app_type
)
{
strcpy
(
ctx
.
fname
,
sections
[
i
].
name
);
BaseString
str
(
*
(
char
**
)
sections
[
i
].
src
->
value
);
Vector
<
BaseString
>
list
;
str
.
split
(
list
,
","
);
const
char
*
defaults_groups
[]
=
{
0
,
0
,
0
};
for
(
unsigned
j
=
0
;
j
<
list
.
size
();
j
++
)
{
BaseString
group_idx
;
BaseString
group_host
;
group_idx
.
assfmt
(
"%s.%s.%d"
,
groups
[
0
],
sections
[
i
].
src
->
name
,
j
+
1
);
group_host
.
assfmt
(
"%s.%s.%s"
,
groups
[
0
],
sections
[
i
].
src
->
name
,
list
[
j
].
c_str
());
defaults_groups
[
0
]
=
group_idx
.
c_str
();
if
(
list
[
j
].
length
())
defaults_groups
[
1
]
=
group_host
.
c_str
();
else
defaults_groups
[
1
]
=
0
;
ctx
.
m_currentSection
=
new
Properties
(
true
);
ctx
.
m_userDefaults
=
getSection
(
ctx
.
fname
,
ctx
.
m_defaults
);
require
((
ctx
.
m_currentInfo
=
m_info
->
getInfo
(
ctx
.
fname
))
!=
0
);
require
((
ctx
.
m_systemDefaults
=
m_info
->
getDefaults
(
ctx
.
fname
))
!=
0
);
ctx
.
m_currentSection
->
put
(
"HostName"
,
list
[
j
].
c_str
());
if
(
!
load_mycnf_groups
(
options
,
ctx
,
sections
[
i
].
name
,
defaults_groups
))
goto
end
;
if
(
!
storeSection
(
ctx
))
goto
end
;
}
}
}
}
res
=
run_config_rules
(
ctx
);
end:
for
(
i
=
0
;
options
[
i
].
name
;
i
++
)
free
(
options
[
i
].
value
);
return
res
;
}
template
class
Vector
<
struct
my_option
>;
#if 0
struct my_option
{
const char *name; /* Name of the option */
int id; /* unique id or short option */
const char *comment; /* option comment, for autom. --help */
gptr *value; /* The variable value */
gptr *u_max_value; /* The user def. max variable value */
const char **str_values; /* Pointer to possible values */
ulong var_type;
enum get_opt_arg_type arg_type;
longlong def_value; /* Default value */
longlong min_value; /* Min allowed value */
longlong max_value; /* Max allowed value */
longlong sub_size; /* Subtract this from given value */
long block_size; /* Value should be a mult. of this */
int app_type; /* To be used by an application */
};
#endif
ndb/src/mgmsrv/InitConfigFileParser.hpp
View file @
b43d0f04
...
...
@@ -34,11 +34,12 @@ class ConfigInfo;
* object if the config file has correct syntax and semantic.
*/
class
InitConfigFileParser
{
FILE
*
m_errstream
;
public:
/**
* Constructor
*/
InitConfigFileParser
();
InitConfigFileParser
(
FILE
*
errstream
=
stdout
);
~
InitConfigFileParser
();
/**
...
...
@@ -50,6 +51,7 @@ public:
*/
Config
*
parseConfig
(
FILE
*
file
);
Config
*
parseConfig
(
const
char
*
filename
);
Config
*
parse_mycnf
();
/**
* Parser context struct
...
...
@@ -60,7 +62,7 @@ public:
* Context = Which section in init config file we are currently parsing
*/
struct
Context
{
Context
(
const
ConfigInfo
*
);
Context
(
const
ConfigInfo
*
,
FILE
*
out
);
~
Context
();
ContextSectionType
type
;
///< Section type (e.g. default section,section)
...
...
@@ -82,6 +84,7 @@ public:
ConfigValuesFactory
m_configValues
;
//
public:
FILE
*
m_errstream
;
void
reportError
(
const
char
*
msg
,
...);
void
reportWarning
(
const
char
*
msg
,
...);
};
...
...
@@ -122,6 +125,21 @@ private:
* Information about parameters (min, max values etc)
*/
ConfigInfo
*
m_info
;
bool
handle_mycnf_defaults
(
Vector
<
struct
my_option
>&
options
,
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
name
);
bool
load_mycnf_groups
(
Vector
<
struct
my_option
>
&
options
,
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
name
,
const
char
*
groups
[]);
bool
store_in_properties
(
Vector
<
struct
my_option
>&
options
,
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
name
);
Config
*
run_config_rules
(
Context
&
ctx
);
};
#endif // InitConfigFileParser_H
ndb/src/mgmsrv/MgmtSrvr.cpp
View file @
b43d0f04
...
...
@@ -433,8 +433,6 @@ MgmtSrvr::MgmtSrvr(SocketServer *socket_server,
m_newConfig
=
NULL
;
if
(
config_filename
)
m_configFilename
.
assign
(
config_filename
);
else
m_configFilename
.
assign
(
"config.ini"
);
m_nextConfigGenerationNumber
=
0
;
...
...
@@ -469,7 +467,7 @@ MgmtSrvr::MgmtSrvr(SocketServer *socket_server,
_config
=
readConfig
();
if
(
_config
==
0
)
{
ndbout
<<
"Unable to read config file"
<<
endl
;
require
(
false
);
exit
(
-
1
);
}
}
...
...
ndb/src/mgmsrv/MgmtSrvrConfig.cpp
View file @
b43d0f04
...
...
@@ -274,7 +274,15 @@ Config *
MgmtSrvr
::
readConfig
()
{
Config
*
conf
;
InitConfigFileParser
parser
;
conf
=
parser
.
parseConfig
(
m_configFilename
.
c_str
());
if
(
m_configFilename
.
length
())
{
conf
=
parser
.
parseConfig
(
m_configFilename
.
c_str
());
}
else
{
ndbout_c
(
"Reading cluster configuration using my.cnf"
);
conf
=
parser
.
parse_mycnf
();
}
return
conf
;
}
...
...
ndb/src/mgmsrv/main.cpp
View file @
b43d0f04
...
...
@@ -102,6 +102,7 @@ static int opt_daemon; // NOT bool, bool need not be int
static
int
opt_non_interactive
;
static
int
opt_interactive
;
static
const
char
*
opt_config_filename
=
0
;
static
int
opt_mycnf
=
0
;
struct
MgmGlobals
{
MgmGlobals
();
...
...
@@ -166,6 +167,10 @@ static struct my_option my_long_options[] =
"Don't run as daemon, but don't read from stdin"
,
(
gptr
*
)
&
opt_non_interactive
,
(
gptr
*
)
&
opt_non_interactive
,
0
,
GET_BOOL
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
"mycnf"
,
256
,
"Read cluster config from my.cnf"
,
(
gptr
*
)
&
opt_mycnf
,
(
gptr
*
)
&
opt_mycnf
,
0
,
GET_BOOL
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
}
};
...
...
@@ -199,7 +204,7 @@ int main(int argc, char** argv)
#endif
global_mgmt_server_check
=
1
;
const
char
*
load_default_groups
[]
=
{
"mysql_cluster"
,
"ndb_mgmd"
,
0
};
load_defaults
(
"my"
,
load_default_groups
,
&
argc
,
&
argv
);
...
...
@@ -217,13 +222,26 @@ int main(int argc, char** argv)
opt_daemon
=
0
;
}
if
(
opt_mycnf
&&
opt_config_filename
)
{
ndbout_c
(
"Both --mycnf and -f is not supported"
);
return
0
;
}
if
(
opt_mycnf
==
0
&&
opt_config_filename
==
0
)
{
struct
stat
buf
;
if
(
stat
(
"config.ini"
,
&
buf
)
!=
-
1
)
opt_config_filename
=
"config.ini"
;
}
glob
->
socketServer
=
new
SocketServer
();
MgmApiService
*
mapi
=
new
MgmApiService
();
glob
->
mgmObject
=
new
MgmtSrvr
(
glob
->
socketServer
,
opt_config_filename
,
opt_connect_str
);
opt_config_filename
,
opt_connect_str
);
if
(
g_print_full_config
)
goto
the_end
;
...
...
ndb/tools/ndb_config.cpp
View file @
b43d0f04
...
...
@@ -40,6 +40,8 @@ static const char * g_type = 0;
static
const
char
*
g_host
=
0
;
static
const
char
*
g_field_delimiter
=
","
;
static
const
char
*
g_row_delimiter
=
" "
;
static
const
char
*
g_config_file
=
0
;
static
int
g_mycnf
=
0
;
int
g_print_full_config
,
opt_ndb_shm
;
my_bool
opt_core
;
...
...
@@ -90,6 +92,12 @@ static struct my_option my_long_options[] =
{
"rows"
,
'r'
,
"Row separator"
,
(
gptr
*
)
&
g_row_delimiter
,
(
gptr
*
)
&
g_row_delimiter
,
0
,
GET_STR
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
"config-file"
,
256
,
"Path to config.ini"
,
(
gptr
*
)
&
g_config_file
,
(
gptr
*
)
&
g_config_file
,
0
,
GET_STR
,
REQUIRED_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
"mycnf"
,
256
,
"Read config from my.cnf"
,
(
gptr
*
)
&
g_mycnf
,
(
gptr
*
)
&
g_mycnf
,
0
,
GET_BOOL
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
}
};
...
...
@@ -124,7 +132,7 @@ struct Match
{
int
m_key
;
BaseString
m_value
;
virtual
int
eval
(
NdbMgmHandle
,
const
Iter
&
);
virtual
int
eval
(
const
Iter
&
);
};
struct
Apply
...
...
@@ -132,18 +140,21 @@ struct Apply
Apply
()
{}
Apply
(
int
val
)
{
m_key
=
val
;}
int
m_key
;
virtual
int
apply
(
NdbMgmHandle
,
const
Iter
&
);
virtual
int
apply
(
const
Iter
&
);
};
struct
NodeTypeApply
:
public
Apply
{
virtual
int
apply
(
NdbMgmHandle
,
const
Iter
&
);
virtual
int
apply
(
const
Iter
&
);
};
static
int
parse_query
(
Vector
<
Apply
*>&
,
int
&
argc
,
char
**&
argv
);
static
int
parse_where
(
Vector
<
Match
*>&
,
int
&
argc
,
char
**&
argv
);
static
int
eval
(
NdbMgmHandle
,
const
Iter
&
,
const
Vector
<
Match
*>&
);
static
int
apply
(
NdbMgmHandle
,
const
Iter
&
,
const
Vector
<
Apply
*>&
);
static
int
eval
(
const
Iter
&
,
const
Vector
<
Match
*>&
);
static
int
apply
(
const
Iter
&
,
const
Vector
<
Apply
*>&
);
static
ndb_mgm_configuration
*
fetch_configuration
();
static
ndb_mgm_configuration
*
load_configuration
();
int
main
(
int
argc
,
char
**
argv
){
NDB_INIT
(
argv
[
0
]);
...
...
@@ -154,51 +165,16 @@ main(int argc, char** argv){
ndb_std_get_one_option
)))
return
-
1
;
NdbMgmHandle
mgm
=
ndb_mgm_create_handle
();
if
(
mgm
==
NULL
)
{
fprintf
(
stderr
,
"Cannot create handle to management server.
\n
"
);
exit
(
-
1
);
}
ndb_mgm_configuration
*
conf
=
0
;
ndb_mgm_set_error_stream
(
mgm
,
stderr
);
if
(
ndb_mgm_set_connectstring
(
mgm
,
g_connectstring
))
{
fprintf
(
stderr
,
"* %5d: %s
\n
"
,
ndb_mgm_get_latest_error
(
mgm
),
ndb_mgm_get_latest_error_msg
(
mgm
));
fprintf
(
stderr
,
"* %s"
,
ndb_mgm_get_latest_error_desc
(
mgm
));
exit
(
-
1
);
}
if
(
g_config_file
||
g_mycnf
)
conf
=
load_configuration
();
else
conf
=
fetch_configuration
();
if
(
ndb_mgm_connect
(
mgm
,
try_reconnect
-
1
,
5
,
1
))
{
fprintf
(
stderr
,
"Connect failed"
);
fprintf
(
stderr
,
" code: %d, msg: %s
\n
"
,
ndb_mgm_get_latest_error
(
mgm
),
ndb_mgm_get_latest_error_msg
(
mgm
));
exit
(
-
1
);
}
else
if
(
g_verbose
)
{
fprintf
(
stderr
,
"Connected to %s:%d
\n
"
,
ndb_mgm_get_connected_host
(
mgm
),
ndb_mgm_get_connected_port
(
mgm
));
}
ndb_mgm_configuration
*
conf
=
ndb_mgm_get_configuration
(
mgm
,
0
);
if
(
conf
==
0
)
{
fprintf
(
stderr
,
"Could not get configuration"
);
fprintf
(
stderr
,
"code: %d, msg: %s
\n
"
,
ndb_mgm_get_latest_error
(
mgm
),
ndb_mgm_get_latest_error_msg
(
mgm
));
exit
(
-
1
);
}
else
if
(
g_verbose
)
if
(
conf
==
0
)
{
fprintf
(
stderr
,
"Fetched configuration
\n
"
)
;
return
-
1
;
}
Vector
<
Apply
*>
select_list
;
...
...
@@ -224,12 +200,12 @@ main(int argc, char** argv){
iter
.
first
();
for
(
iter
.
first
();
iter
.
valid
();
iter
.
next
())
{
if
(
eval
(
mgm
,
iter
,
where_clause
))
if
(
eval
(
iter
,
where_clause
))
{
if
(
prev
)
printf
(
"%s"
,
g_row_delimiter
);
prev
=
true
;
apply
(
mgm
,
iter
,
select_list
);
apply
(
iter
,
select_list
);
}
}
printf
(
"
\n
"
);
...
...
@@ -323,11 +299,11 @@ template class Vector<Match*>;
static
int
eval
(
NdbMgmHandle
mgm
,
const
Iter
&
iter
,
const
Vector
<
Match
*>&
where
)
eval
(
const
Iter
&
iter
,
const
Vector
<
Match
*>&
where
)
{
for
(
unsigned
i
=
0
;
i
<
where
.
size
();
i
++
)
{
if
(
where
[
i
]
->
eval
(
mgm
,
iter
)
==
0
)
if
(
where
[
i
]
->
eval
(
iter
)
==
0
)
return
0
;
}
...
...
@@ -336,11 +312,11 @@ eval(NdbMgmHandle mgm, const Iter& iter, const Vector<Match*>& where)
static
int
apply
(
NdbMgmHandle
mgm
,
const
Iter
&
iter
,
const
Vector
<
Apply
*>&
list
)
apply
(
const
Iter
&
iter
,
const
Vector
<
Apply
*>&
list
)
{
for
(
unsigned
i
=
0
;
i
<
list
.
size
();
i
++
)
{
list
[
i
]
->
apply
(
mgm
,
iter
);
list
[
i
]
->
apply
(
iter
);
if
(
i
+
1
!=
list
.
size
())
printf
(
"%s"
,
g_field_delimiter
);
}
...
...
@@ -348,19 +324,19 @@ apply(NdbMgmHandle mgm, const Iter& iter, const Vector<Apply*>& list)
}
int
Match
::
eval
(
NdbMgmHandle
h
,
const
Iter
&
iter
)
Match
::
eval
(
const
Iter
&
iter
)
{
Uint32
val32
;
Uint64
val64
;
const
char
*
valc
;
if
(
iter
.
get
(
m_key
,
&
val32
)
==
0
)
{
if
(
atoi
(
m_value
.
c_str
())
!=
val32
)
if
(
atoi
(
m_value
.
c_str
())
!=
(
int
)
val32
)
return
0
;
}
else
if
(
iter
.
get
(
m_key
,
&
val64
)
==
0
)
{
if
(
strtoll
(
m_value
.
c_str
(),
(
char
**
)
NULL
,
10
)
!=
val64
)
if
(
strtoll
(
m_value
.
c_str
(),
(
char
**
)
NULL
,
10
)
!=
(
long
long
)
val64
)
return
0
;
}
else
if
(
iter
.
get
(
m_key
,
&
valc
)
==
0
)
...
...
@@ -376,7 +352,7 @@ Match::eval(NdbMgmHandle h, const Iter& iter)
}
int
Apply
::
apply
(
NdbMgmHandle
h
,
const
Iter
&
iter
)
Apply
::
apply
(
const
Iter
&
iter
)
{
Uint32
val32
;
Uint64
val64
;
...
...
@@ -397,7 +373,7 @@ Apply::apply(NdbMgmHandle h, const Iter& iter)
}
int
NodeTypeApply
::
apply
(
NdbMgmHandle
h
,
const
Iter
&
iter
)
NodeTypeApply
::
apply
(
const
Iter
&
iter
)
{
Uint32
val32
;
if
(
iter
.
get
(
CFG_TYPE_OF_SECTION
,
&
val32
)
==
0
)
...
...
@@ -406,3 +382,86 @@ NodeTypeApply::apply(NdbMgmHandle h, const Iter& iter)
}
return
0
;
}
ndb_mgm_configuration
*
fetch_configuration
()
{
ndb_mgm_configuration
*
conf
=
0
;
NdbMgmHandle
mgm
=
ndb_mgm_create_handle
();
if
(
mgm
==
NULL
)
{
fprintf
(
stderr
,
"Cannot create handle to management server.
\n
"
);
return
0
;
}
ndb_mgm_set_error_stream
(
mgm
,
stderr
);
if
(
ndb_mgm_set_connectstring
(
mgm
,
g_connectstring
))
{
fprintf
(
stderr
,
"* %5d: %s
\n
"
,
ndb_mgm_get_latest_error
(
mgm
),
ndb_mgm_get_latest_error_msg
(
mgm
));
fprintf
(
stderr
,
"* %s"
,
ndb_mgm_get_latest_error_desc
(
mgm
));
goto
noconnect
;
}
if
(
ndb_mgm_connect
(
mgm
,
try_reconnect
-
1
,
5
,
1
))
{
fprintf
(
stderr
,
"Connect failed"
);
fprintf
(
stderr
,
" code: %d, msg: %s
\n
"
,
ndb_mgm_get_latest_error
(
mgm
),
ndb_mgm_get_latest_error_msg
(
mgm
));
goto
noconnect
;
}
else
if
(
g_verbose
)
{
fprintf
(
stderr
,
"Connected to %s:%d
\n
"
,
ndb_mgm_get_connected_host
(
mgm
),
ndb_mgm_get_connected_port
(
mgm
));
}
conf
=
ndb_mgm_get_configuration
(
mgm
,
0
);
if
(
conf
==
0
)
{
fprintf
(
stderr
,
"Could not get configuration"
);
fprintf
(
stderr
,
"code: %d, msg: %s
\n
"
,
ndb_mgm_get_latest_error
(
mgm
),
ndb_mgm_get_latest_error_msg
(
mgm
));
}
else
if
(
g_verbose
)
{
fprintf
(
stderr
,
"Fetched configuration
\n
"
);
}
ndb_mgm_disconnect
(
mgm
);
noconnect:
ndb_mgm_destroy_handle
(
&
mgm
);
return
conf
;
}
#include <Config.hpp>
ndb_mgm_configuration
*
load_configuration
()
{
InitConfigFileParser
parser
(
stderr
);
if
(
g_config_file
)
{
if
(
g_verbose
)
fprintf
(
stderr
,
"Using config.ini : %s"
,
g_config_file
);
Config
*
conf
=
parser
.
parseConfig
(
g_config_file
);
if
(
conf
)
return
conf
->
m_configValues
;
}
if
(
g_verbose
)
fprintf
(
stderr
,
"Using my.cnf"
);
Config
*
conf
=
parser
.
parse_mycnf
();
if
(
conf
)
return
conf
->
m_configValues
;
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment