| 150 | } |
| 151 | |
| 152 | private RaftConfig(Document xml, String filename, Element self) { |
| 153 | XmlDocument = xml; |
| 154 | XmlFileName = filename; |
| 155 | Self = self; |
| 156 | Name = self.getAttribute("Name"); |
| 157 | |
| 158 | var attr = self.getAttribute("DbHome"); |
| 159 | if (!attr.isEmpty()) |
| 160 | DbHome = attr; |
| 161 | if (DbHome == null) |
| 162 | DbHome = Name.replace(':', '_'); |
| 163 | |
| 164 | attr = self.getAttribute("AppendEntriesTimeout"); |
| 165 | if (!attr.isEmpty()) |
| 166 | AppendEntriesTimeout = Integer.parseInt(attr); |
| 167 | attr = self.getAttribute("LeaderHeartbeatTimer"); |
| 168 | if (!attr.isEmpty()) |
| 169 | LeaderHeartbeatTimer = Integer.parseInt(attr); |
| 170 | attr = self.getAttribute("MaxAppendEntriesCount"); |
| 171 | if (!attr.isEmpty()) |
| 172 | MaxAppendEntriesCount = Integer.parseInt(attr); |
| 173 | attr = self.getAttribute("SnapshotMinLogCount"); |
| 174 | if (!attr.isEmpty()) |
| 175 | SnapshotMinLogCount = Integer.parseInt(attr); |
| 176 | attr = self.getAttribute("SnapshotHourOfDay"); |
| 177 | if (!attr.isEmpty()) |
| 178 | SnapshotHourOfDay = Integer.parseInt(attr); |
| 179 | attr = self.getAttribute("SnapshotMinute"); |
| 180 | if (!attr.isEmpty()) |
| 181 | SnapshotMinute = Integer.parseInt(attr); |
| 182 | attr = self.getAttribute("ElectionRandomMax"); |
| 183 | if (!attr.isEmpty()) |
| 184 | ElectionRandomMax = Integer.parseInt(attr); |
| 185 | attr = self.getAttribute("BackgroundApplyCount"); |
| 186 | if (!attr.isEmpty()) |
| 187 | BackgroundApplyCount = Integer.parseInt(attr); |
| 188 | attr = self.getAttribute("UniqueRequestExpiredDays"); |
| 189 | if (!attr.isEmpty()) |
| 190 | UniqueRequestExpiredDays = Integer.parseInt(attr); |
| 191 | |
| 192 | NodeList childNodes = self.getChildNodes(); |
| 193 | for (int i = 0, n = childNodes.getLength(); i < n; i++) { |
| 194 | var node = childNodes.item(i); |
| 195 | if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE) |
| 196 | continue; |
| 197 | Element e = (Element)node; |
| 198 | if ("node".equals(e.getTagName())) |
| 199 | AddNode(new Node(e)); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | public void Verify() { |
| 204 | if (AppendEntriesTimeout < 1000) |