10 # Include file that sets the following environment variables:
11 # MTR_NDB_NO_OF_NODES - Number of ndb[mt]d data nodes
12 # MTR_NDB_NO_OF_REPLICAS - Number of replicas
13 # MTR_NDB_MAX_NO_OF_TABLES - Max number of tables
14 # MTR_NDB_MAX_NO_OF_ORDERED_INDEXES - Max number of ordered indexes
15 # MTR_NDB_DATA_MEMORY - Data memory per node
16 # MTR_NDB_INDEX_MEMORY - Index memory per node
17 # MTR_NDB_USABLE_DATA_MEMORY - Data memory available for user (#nodes * data_memory / #replicas)
18 # MTR_NDB_USABLE_INDEX_MEMORY - Index memory available for user (#nodes * index_memory / #replicas)
24 my $vardir = $ENV{MYSQLTEST_VARDIR} or die
"Need MYSQLTEST_VARDIR";
25 my $mysql_test_dir = $ENV{MYSQL_TEST_DIR} or die
"Need MYSQL_TEST_DIR";
26 my $basedir = dirname($mysql_test_dir);
27 my $ndb_connectstring = $ENV{NDB_CONNECTSTRING} or die
"Need NDB_CONNECTSTRING";
30 # Check if the needed jars are available
32 my $ndb_config = my_find_file($basedir,
33 [
"storage/ndb/tools",
"bin"],
34 [
"ndb_config",
"ndb_config.exe"], NOT_REQUIRED);
36 my $fields =
"NoOfReplicas,MaxNoOfTables,MaxNoOfOrderedIndexes,DataMemory,IndexMemory";
37 my $cmd =
"$ndb_config --ndb-connectstring='$ndb_connectstring' -q '$fields' -f ',' -r '\\n'";
38 print
"Calling ndb_config: '$cmd'\n";
42 my $no_of_replicas = 0;
43 my $max_no_of_tables = 0;
44 my $max_no_of_ordered_indexes = 0;
48 foreach my $line (split(
"\n", $output)) {
50 next
if ($line =~ m/^,+$/g);
55 # Same on each line (node)
56 ($no_of_replicas, $max_no_of_tables, $max_no_of_ordered_indexes, $data_memory, $index_memory) = split(
',', $line);
59 my $usable_data_memory = 0;
60 my $usable_index_memory = 0;
62 if ($no_of_replicas > 0) {
63 $usable_data_memory = $no_of_nodes * $data_memory / $no_of_replicas;
64 $usable_index_memory = $no_of_nodes * $index_memory / $no_of_replicas;
66 die
"Failed to parse ndb_config output - could not get number of replicas";
72 my $cmd =
"$ndb_config --ndb-connectstring='$ndb_connectstring' -q 'NodeId' -f '' -r ',' --type=$type";
75 my @nums = split(
',', $output);
76 my @sorted = sort(@nums);
77 return ($sorted[0], $sorted[scalar(@sorted) - 1]);
80 my ($first_ndbd_nodeid, $last_ndbd_nodeid) = get_first_last(
'ndbd');
81 my ($first_mgmd_nodeid, $last_mgmd_nodeid) = get_first_last(
'ndb_mgmd');
83 my $file_name =
"$vardir/tmp/ndb_info_result.inc";
84 my $F = IO::File->new($file_name,
'w') or die
"Could not open '$file_name' for writing";
85 print $F
"--let \$MTR_NDB_NO_OF_NODES= $no_of_nodes\n";
86 print $F
"--let \$MTR_NDB_NO_OF_REPLICAS= $no_of_replicas\n";
87 print $F
"--let \$MTR_NDB_MAX_NO_OF_TABLES= $max_no_of_tables\n";
88 print $F
"--let \$MTR_NDB_MAX_NO_OF_ORDERED_INDEXES= $max_no_of_ordered_indexes\n";
89 print $F
"--let \$MTR_NDB_DATA_MEMORY= $data_memory\n";
90 print $F
"--let \$MTR_NDB_INDEX_MEMORY= $index_memory\n";
91 print $F
"--let \$MTR_NDB_USABLE_DATA_MEMORY= $usable_data_memory\n";
92 print $F
"--let \$MTR_NDB_USABLE_INDEX_MEMORY= $usable_index_memory\n";
93 print $F
"--let \$MTR_NDB_FIRST_NDBD_NODEID= $first_ndbd_nodeid\n";
94 print $F
"--let \$MTR_NDB_LAST_NDBD_NODEID= $last_ndbd_nodeid\n";
95 print $F
"--let \$MTR_NDB_FIRST_MGMD_NODEID= $first_mgmd_nodeid\n";
96 print $F
"--let \$MTR_NDB_LAST_MGMD_NODEID= $last_mgmd_nodeid\n";
101 --source $MYSQLTEST_VARDIR/tmp/ndb_info_result.inc