MCPcopy
hub / github.com/yougov/mongo-connector / update_checkpoint

Method update_checkpoint

mongo_connector/oplog_manager.py:786–804  ·  view source on GitHub ↗

Store the current checkpoint in the oplog progress dictionary.

(self, checkpoint)

Source from the content-addressed store, hash-verified

784 return cursor, cursor_empty
785
786 def update_checkpoint(self, checkpoint):
787 """Store the current checkpoint in the oplog progress dictionary.
788 """
789 if checkpoint is not None and checkpoint != self.checkpoint:
790 self.checkpoint = checkpoint
791 with self.oplog_progress as oplog_prog:
792 oplog_dict = oplog_prog.get_dict()
793 # If we have the repr of our oplog collection
794 # in the dictionary, remove it and replace it
795 # with our replica set name.
796 # This allows an easy upgrade path from mongo-connector 2.3.
797 # For an explanation of the format change, see the comment in
798 # read_last_checkpoint.
799 oplog_dict.pop(str(self.oplog), None)
800 oplog_dict[self.replset_name] = checkpoint
801 LOG.debug("OplogThread: oplog checkpoint updated to %s",
802 checkpoint)
803 else:
804 LOG.debug("OplogThread: no checkpoint to update.")
805
806 def read_last_checkpoint(self):
807 """Read the last checkpoint from the oplog progress dictionary.

Callers 7

runMethod · 0.95
init_cursorMethod · 0.95
test_init_cursorMethod · 0.80
test_init_cursorMethod · 0.80
test_init_cursorMethod · 0.80

Calls 1

get_dictMethod · 0.80

Tested by 5

test_init_cursorMethod · 0.64
test_init_cursorMethod · 0.64
test_init_cursorMethod · 0.64