Iterate over file and find any sharding related information
(self)
| 589 | return None |
| 590 | |
| 591 | def _find_sharding_info(self): |
| 592 | """ |
| 593 | Iterate over file and find any sharding related information |
| 594 | """ |
| 595 | self._shards = [] |
| 596 | self._chunks_moved_from = [] |
| 597 | self._chunks_moved_to = [] |
| 598 | self._chunk_splits = [] |
| 599 | |
| 600 | prev_line = "" |
| 601 | |
| 602 | for line in self.filehandle: |
| 603 | if isinstance(line, bytes): |
| 604 | line = line.decode("utf-8", "replace") |
| 605 | |
| 606 | if self.binary == "mongos": |
| 607 | |
| 608 | if "Starting new replica set monitor for" in line: |
| 609 | if "[mongosMain]" in line: |
| 610 | match = re.search("for (?P<csrsName>\w+)/" |
| 611 | "(?P<replSetMembers>\S+)", line) |
| 612 | if match: |
| 613 | csrs_info = (match.group('csrsName'), |
| 614 | match.group('replSetMembers')) |
| 615 | self._csrs = csrs_info |
| 616 | else: |
| 617 | match = re.search("for (?P<shardName>\w+)/" |
| 618 | "(?P<replSetMembers>\S+)", line) |
| 619 | if match: |
| 620 | shard_info = (match.group('shardName'), |
| 621 | match.group('replSetMembers')) |
| 622 | self._shards.append(shard_info) |
| 623 | |
| 624 | elif self.binary == "mongod": |
| 625 | logevent = LogEvent(line) |
| 626 | if "New replica set config in use" in line: |
| 627 | |
| 628 | if "configsvr: true" in line: |
| 629 | match = re.search(' _id: "(?P<replSet>\S+)".*' |
| 630 | 'members: (?P<replSetMembers>[^]]+ ])', line) |
| 631 | if match: |
| 632 | self._csrs = ( |
| 633 | match.group('replSet'), |
| 634 | match.group('replSetMembers') |
| 635 | ) |
| 636 | |
| 637 | if "Starting new replica set monitor for" in line: |
| 638 | match = re.search("for (?P<replSet>\w+)/" |
| 639 | "(?P<replSetMembers>\S+)", line) |
| 640 | if match: |
| 641 | if self._csrs and match.group('replSet') != self._csrs[0]: |
| 642 | self._shards.append(( |
| 643 | match.group('replSet'), |
| 644 | match.group('replSetMembers') |
| 645 | )) |
| 646 | elif not self._csrs: |
| 647 | self._csrs = ( |
| 648 | match.group('replSet'), |
no test coverage detected