1
/* Copyright (C) 2003 MySQL AB
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.
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.
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 */
17
#include <ndb_global.h>
21
#include <Sysfile.hpp>
24
usage(const char * prg){
25
ndbout << "Usage " << prg
26
<< " P[0-1].sysfile" << endl;
30
Sysfile::ActiveStatus NodeStatus;
35
NSString NodeStatusStrings[] = {
36
{ Sysfile::NS_Active, "Active " },
37
{ Sysfile::NS_ActiveMissed_1, "Active missed 1" },
38
{ Sysfile::NS_ActiveMissed_2, "Active missed 2" },
39
{ Sysfile::NS_ActiveMissed_3, "Active missed 3" },
40
{ Sysfile::NS_HotSpare, "Hot spare " },
41
{ Sysfile::NS_NotActive_NotTakenOver, "Not active " },
42
{ Sysfile::NS_TakeOver, "Take over " },
43
{ Sysfile::NS_NotActive_TakenOver, "Taken over " },
44
{ Sysfile::NS_NotDefined, "Not defined " },
45
{ Sysfile::NS_Standby, "Stand by " }
49
char * getNSString(Uint32 ns){
50
for(Uint32 i = 0; i<(sizeof(NodeStatusStrings)/sizeof(NSString)); i++)
51
if((Uint32)NodeStatusStrings[i].NodeStatus == ns)
52
return NodeStatusStrings[i].desc;
53
return "<Unknown state>";
57
fill(const char * buf, int mod){
58
int len = strlen(buf)+1;
60
while((len % mod) != 0){
67
print(const char * filename, const Sysfile * sysfile){
69
ndbout << "----- Sysfile: " << filename
70
<< " seq: " << hex << sysfile->m_restart_seq
72
ndbout << "Initial start ongoing: "
73
<< Sysfile::getInitialStartOngoing(sysfile->systemRestartBits)
76
ndbout << "Restart Ongoing: "
77
<< Sysfile::getRestartOngoing(sysfile->systemRestartBits)
80
ndbout << "LCP Ongoing: "
81
<< Sysfile::getLCPOngoing(sysfile->systemRestartBits)
85
ndbout << "-- Global Checkpoint Identities: --" << endl;
86
sprintf(buf, "keepGCI = %u", sysfile->keepGCI);
88
ndbout << " -- Tail of REDO log" << endl;
90
sprintf(buf, "oldestRestorableGCI = %u", sysfile->oldestRestorableGCI);
92
ndbout << " -- " << endl;
94
sprintf(buf, "newestRestorableGCI = %u", sysfile->newestRestorableGCI);
96
ndbout << " -- " << endl;
98
sprintf(buf, "latestLCP = %u", sysfile->latestLCP_ID);
100
ndbout << " -- " << endl;
102
ndbout << "-- Node status: --" << endl;
103
for(int i = 1; i < MAX_NDB_NODES; i++){
104
if(Sysfile::getNodeStatus(i, sysfile->nodeStatus) !=Sysfile::NS_NotDefined){
106
"Node %.2d -- %s GCP: %d, NodeGroup: %d, TakeOverNode: %d, "
109
getNSString(Sysfile::getNodeStatus(i,sysfile->nodeStatus)),
110
sysfile->lastCompletedGCI[i],
111
Sysfile::getNodeGroup(i, sysfile->nodeGroups),
112
Sysfile::getTakeOverNode(i, sysfile->takeOver),
113
BitmaskImpl::get(NdbNodeBitmask::Size,
114
sysfile->lcpActive, i) != 0 ? "yes" : "no");
115
ndbout << buf << endl;
120
NDB_COMMAND(printSysfile,
121
"printSysfile", "printSysfile", "Prints a sysfile", 16384){
127
for(int i = 1; i<argc; i++){
128
const char * filename = argv[i];
131
const int res = stat(filename, &sbuf);
133
ndbout << "Could not find file: \"" << filename << "\"" << endl;
136
const Uint32 bytes = sbuf.st_size;
138
Uint32 * buf = new Uint32[bytes/4+1];
140
FILE * f = fopen(filename, "rb");
142
ndbout << "Failed to open file" << endl;
146
Uint32 sz = fread(buf, 1, bytes, f);
149
ndbout << "Failure while reading file" << endl;
154
print(filename, (Sysfile *)&buf[0]);