in pkg/mgmapi/config_reader.go [199:275]
func (cr *configReader) readConfig(sectionTypeFilter cfgSectionType, fromNodeId, configKey uint32) configValue {
// Start reading the header.
//
// Magic Word (2 words) - ignored
// Header section (7 words) :
// 1. Total length in words of configuration binary
// 2. Configuration binary version (this is version 2)
// 3. Number of default sections in configuration binary
// - Data node defaults
// - API node defaults
// - MGM server node defaults
// - TCP communication defaults
// - SHM communication defaults
// So, the value is always 5 in this version
// 4. Number of data nodes
// 5. Number of API nodes
// 6. Number of MGM server nodes
// 7. Number of communication sections
// read the header - starts after the magic word
cr.offset = 8
defer func() {
// reset offset after reading
cr.offset = 0
}()
cr.totalLengthInWords = cr.readUint32()
cr.version = cr.readUint32()
// configReader can handle only version 2
if cr.version != 2 {
debug.Panic("unexpected version in get config reply")
return nil
}
cr.numOfDefaultSections = cr.readUint32()
for i := 0; i < 3; i++ {
cr.numOfNodes += cr.readUint32()
}
cr.numOfCommSections = cr.readUint32()
// Start reading the sections
//
// 1. The default sections
// - Data node defaults
// - API node defaults
// - MGM server node defaults
// - TCP communication defaults
// - SHM communication defaults
// 2. System section
// 3. Node sections
// (Ordered based on node ids of nodes of all types)
// 4. Communication sections - ignored
// start reading the sections
// default sections
for ds := 0; ds < int(cr.numOfDefaultSections); ds++ {
// no need to handle the return value as the reading has to continue anyways
cr.readEntryFromSection(false, sectionTypeFilter, 0, configKey)
}
// system section
if cr.readEntryFromSection(false, sectionTypeFilter, 0, configKey) {
return cr.value
}
// node sections
for n := 0; n < int(cr.numOfNodes); n++ {
if cr.readEntryFromSection(true, sectionTypeFilter, fromNodeId, configKey) {
return cr.value
}
}
// control should never reach here if the method is used right
debug.Panic("failed to find the desired config key")
return nil
}