| | |
| | | |
| | | // Read the DS info entries, first read number of them |
| | | int nDsInfo = scanner.nextByte(); |
| | | final Map<Integer, DSInfo> replicaInfos = new HashMap<>(Math.max(0, nDsInfo)); |
| | | final Map<Integer, DSInfo> newReplicaInfos = new HashMap<>(Math.max(0, nDsInfo)); |
| | | while (nDsInfo > 0 && !scanner.isEmpty()) |
| | | { |
| | | final DSInfo dsInfo = nextDSInfo(scanner, version); |
| | | replicaInfos.put(dsInfo.getDsId(), dsInfo); |
| | | newReplicaInfos.put(dsInfo.getDsId(), dsInfo); |
| | | nDsInfo--; |
| | | } |
| | | |
| | | // Read the RS info entries |
| | | int nRsInfo = scanner.nextByte(); |
| | | final List<RSInfo> rsInfos = new ArrayList<>(Math.max(0, nRsInfo)); |
| | | final List<RSInfo> newRsInfos = new ArrayList<>(Math.max(0, nRsInfo)); |
| | | while (nRsInfo > 0 && !scanner.isEmpty()) |
| | | { |
| | | rsInfos.add(nextRSInfo(scanner, version)); |
| | | newRsInfos.add(nextRSInfo(scanner, version)); |
| | | nRsInfo--; |
| | | } |
| | | |
| | | this.replicaInfos = Collections.unmodifiableMap(replicaInfos); |
| | | this.rsInfos = Collections.unmodifiableList(rsInfos); |
| | | this.replicaInfos = Collections.unmodifiableMap(newReplicaInfos); |
| | | this.rsInfos = Collections.unmodifiableList(newRsInfos); |
| | | } |
| | | |
| | | private DSInfo nextDSInfo(ByteArrayScanner scanner, short version) |