当前位置: 首页>>代码示例>>Python>>正文


Python Connector.read_oplog_progress方法代码示例

本文整理汇总了Python中mongo_connector.connector.Connector.read_oplog_progress方法的典型用法代码示例。如果您正苦于以下问题:Python Connector.read_oplog_progress方法的具体用法?Python Connector.read_oplog_progress怎么用?Python Connector.read_oplog_progress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mongo_connector.connector.Connector的用法示例。


在下文中一共展示了Connector.read_oplog_progress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_read_oplog_progress

# 需要导入模块: from mongo_connector.connector import Connector [as 别名]
# 或者: from mongo_connector.connector.Connector import read_oplog_progress [as 别名]
    def test_read_oplog_progress(self):
        """Test read_oplog_progress
        """

        conn = Connector(
            address='%s:%d' % (mongo_host, self.primary_p),
            oplog_checkpoint=None,
            target_url=None,
            ns_set=['test.test'],
            u_key='_id',
            auth_key=None
        )

        #testing with no file
        self.assertEqual(conn.read_oplog_progress(), None)

        try:
            os.unlink("temp_config.txt")
        except OSError:
            pass
        open("temp_config.txt", "w").close()

        conn.oplog_checkpoint = "temp_config.txt"

        #testing with empty file
        self.assertEqual(conn.read_oplog_progress(), None)

        oplog_dict = conn.oplog_progress.get_dict()

        #add a value to the file, delete the dict, and then read in the value
        oplog_dict['oplog1'] = Timestamp(12, 34)
        conn.write_oplog_progress()
        del oplog_dict['oplog1']

        self.assertEqual(len(oplog_dict), 0)

        conn.read_oplog_progress()

        oplog_dict = conn.oplog_progress.get_dict()
        self.assertTrue('oplog1' in oplog_dict.keys())
        self.assertTrue(oplog_dict['oplog1'], Timestamp(12, 34))

        oplog_dict['oplog1'] = Timestamp(55, 11)

        #see if oplog progress dict is properly updated
        conn.read_oplog_progress()
        self.assertTrue(oplog_dict['oplog1'], Timestamp(55, 11))

        os.unlink("temp_config.txt")
开发者ID:Branor,项目名称:mongo-connector,代码行数:51,代码来源:test_mongo_connector.py

示例2: test_read_oplog_progress

# 需要导入模块: from mongo_connector.connector import Connector [as 别名]
# 或者: from mongo_connector.connector.Connector import read_oplog_progress [as 别名]
    def test_read_oplog_progress(self):
        """Test read_oplog_progress
        """

        conn = Connector(
            mongo_address=self.repl_set.uri,
            oplog_checkpoint=None,
            ns_set=['test.test'],
            **connector_opts
        )

        #testing with no file
        self.assertEqual(conn.read_oplog_progress(), None)

        try:
            os.unlink("temp_oplog.timestamp")
        except OSError:
            pass
        open("temp_oplog.timestamp", "w").close()

        conn.oplog_checkpoint = "temp_oplog.timestamp"

        #testing with empty file
        self.assertEqual(conn.read_oplog_progress(), None)

        oplog_dict = conn.oplog_progress.get_dict()

        #add a value to the file, delete the dict, and then read in the value
        oplog_dict['oplog1'] = Timestamp(12, 34)
        conn.write_oplog_progress()
        del oplog_dict['oplog1']

        self.assertEqual(len(oplog_dict), 0)

        conn.read_oplog_progress()
        oplog_dict = conn.oplog_progress.get_dict()

        self.assertTrue('oplog1' in oplog_dict.keys())
        self.assertTrue(oplog_dict['oplog1'], Timestamp(12, 34))

        oplog_dict['oplog1'] = Timestamp(55, 11)

        #see if oplog progress dict is properly updated
        conn.read_oplog_progress()
        self.assertTrue(oplog_dict['oplog1'], Timestamp(55, 11))

        os.unlink("temp_oplog.timestamp")
开发者ID:757113854,项目名称:mongo-connector,代码行数:49,代码来源:test_mongo_connector.py

示例3: test_read_oplog_progress

# 需要导入模块: from mongo_connector.connector import Connector [as 别名]
# 或者: from mongo_connector.connector.Connector import read_oplog_progress [as 别名]
    def test_read_oplog_progress(self):
        """Test read_oplog_progress
        """

        conn = Connector(
            address=MAIN_ADDRESS,
            oplog_checkpoint=None,
            target_url=None,
            ns_set=['test.test'],
            u_key='_id',
            auth_key=None
        )

        #testing with no file
        self.assertEqual(conn.read_oplog_progress(), None)

        os.system('touch %s' % (TEMP_CONFIG))
        conn.oplog_checkpoint = TEMP_CONFIG

        #testing with empty file
        self.assertEqual(conn.read_oplog_progress(), None)

        oplog_dict = conn.oplog_progress.get_dict()

        #add a value to the file, delete the dict, and then read in the value
        oplog_dict['oplog1'] = Timestamp(12, 34)
        conn.write_oplog_progress()
        del oplog_dict['oplog1']

        self.assertEqual(len(oplog_dict), 0)

        conn.read_oplog_progress()

        self.assertTrue('oplog1' in oplog_dict.keys())
        self.assertTrue(oplog_dict['oplog1'], Timestamp(12, 34))

        oplog_dict['oplog1'] = Timestamp(55, 11)

        #see if oplog progress dict is properly updated
        conn.read_oplog_progress()
        self.assertTrue(oplog_dict['oplog1'], Timestamp(55, 11))

        os.system('rm ' + TEMP_CONFIG)
开发者ID:korczis,项目名称:mongo-connector,代码行数:45,代码来源:test_mongo_connector.py


注:本文中的mongo_connector.connector.Connector.read_oplog_progress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。