本文整理汇总了Python中mongo_connector.connector.Connector.oplog_checkpoint方法的典型用法代码示例。如果您正苦于以下问题:Python Connector.oplog_checkpoint方法的具体用法?Python Connector.oplog_checkpoint怎么用?Python Connector.oplog_checkpoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mongo_connector.connector.Connector
的用法示例。
在下文中一共展示了Connector.oplog_checkpoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_read_oplog_progress
# 需要导入模块: from mongo_connector.connector import Connector [as 别名]
# 或者: from mongo_connector.connector.Connector import oplog_checkpoint [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")
示例2: test_read_oplog_progress
# 需要导入模块: from mongo_connector.connector import Connector [as 别名]
# 或者: from mongo_connector.connector.Connector import oplog_checkpoint [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")
示例3: test_read_oplog_progress
# 需要导入模块: from mongo_connector.connector import Connector [as 别名]
# 或者: from mongo_connector.connector.Connector import oplog_checkpoint [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)