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
1e6f1907
Commit
1e6f1907
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-4.1
into perch.ndb.mysql.com:/home/jonas/src/mysql-5.0
parents
035673c3
a30faa3b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
119 additions
and
70 deletions
+119
-70
mysql-test/r/ndb_config.result
mysql-test/r/ndb_config.result
+1
-0
mysql-test/t/ndb_config.test
mysql-test/t/ndb_config.test
+1
-0
ndb/src/mgmsrv/InitConfigFileParser.cpp
ndb/src/mgmsrv/InitConfigFileParser.cpp
+12
-7
ndb/src/mgmsrv/InitConfigFileParser.hpp
ndb/src/mgmsrv/InitConfigFileParser.hpp
+4
-2
ndb/tools/ndb_config.cpp
ndb/tools/ndb_config.cpp
+101
-61
No files found.
mysql-test/r/ndb_config.result
View file @
1e6f1907
...
...
@@ -3,3 +3,4 @@ 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, mysqld,4, mysqld,5, mysqld,6, mysqld,7,
mysql-test/t/ndb_config.test
View file @
1e6f1907
...
...
@@ -6,5 +6,6 @@
--
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
ndb/src/mgmsrv/InitConfigFileParser.cpp
View file @
1e6f1907
...
...
@@ -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
;
...
...
@@ -578,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();
}
...
...
@@ -592,8 +596,9 @@ 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>
...
...
ndb/src/mgmsrv/InitConfigFileParser.hpp
View file @
1e6f1907
...
...
@@ -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
();
/**
...
...
@@ -61,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)
...
...
@@ -83,6 +84,7 @@ public:
ConfigValuesFactory
m_configValues
;
//
public:
FILE
*
m_errstream
;
void
reportError
(
const
char
*
msg
,
...);
void
reportWarning
(
const
char
*
msg
,
...);
};
...
...
ndb/tools/ndb_config.cpp
View file @
1e6f1907
...
...
@@ -40,6 +40,7 @@ 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
;
int
g_print_full_config
,
opt_ndb_shm
;
my_bool
opt_core
;
...
...
@@ -90,6 +91,9 @@ 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
},
{
0
,
0
,
0
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
}
};
...
...
@@ -124,7 +128,7 @@ struct Match
{
int
m_key
;
BaseString
m_value
;
virtual
int
eval
(
NdbMgmHandle
,
const
Iter
&
);
virtual
int
eval
(
const
Iter
&
);
};
struct
Apply
...
...
@@ -132,18 +136,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,52 +161,12 @@ 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_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
);
}
ndb_mgm_configuration
*
conf
=
0
;
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
)
{
fprintf
(
stderr
,
"Fetched configuration
\n
"
);
}
if
(
g_config_file
)
conf
=
load_configuration
();
else
conf
=
fetch_configuration
();
Vector
<
Apply
*>
select_list
;
Vector
<
Match
*>
where_clause
;
...
...
@@ -224,12 +191,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 +290,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 +303,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 +315,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 +343,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 +364,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 +373,76 @@ 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_verbose
)
fprintf
(
stderr
,
"Using config.ini : %s"
,
g_config_file
);
Config
*
conf
=
parser
.
parseConfig
(
g_config_file
);
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