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


Python DatastoreDistributed.get_table_prefix方法代码示例

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


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

示例1: test_apply_txn_changes

# 需要导入模块: from appscale.datastore.datastore_distributed import DatastoreDistributed [as 别名]
# 或者: from appscale.datastore.datastore_distributed.DatastoreDistributed import get_table_prefix [as 别名]
  def test_apply_txn_changes(self):
    app = 'guestbook'
    txn = 1
    entity = self.get_new_entity_proto(app, *self.BASIC_ENTITY[1:])

    db_batch = flexmock()
    db_batch.should_receive('get_transaction_metadata').and_return({
      'puts': {entity.key().Encode(): entity.Encode()},
      'deletes': [],
      'tasks': [],
      'reads': set(),
      'start': datetime.datetime.utcnow(),
      'is_xg': False,
    })
    db_batch.should_receive('valid_data_version').and_return(True)
    db_batch.should_receive('group_updates').and_return([])

    db_batch.should_receive('get_indices').and_return([])

    transaction_manager = flexmock()
    dd = DatastoreDistributed(db_batch, transaction_manager,
                              self.get_zookeeper())
    prefix = dd.get_table_prefix(entity)
    entity_key = get_entity_key(prefix, entity.key().path())
    db_batch.should_receive('batch_get_entity').and_return({entity_key: {}})
    db_batch.should_receive('batch_mutate')

    entity_lock = flexmock(EntityLock)
    entity_lock.should_receive('acquire')
    entity_lock.should_receive('release')

    dd.apply_txn_changes(app, txn)
开发者ID:cdonati,项目名称:appscale,代码行数:34,代码来源:test_datastore_server.py

示例2: test_delete_entities_txn

# 需要导入模块: from appscale.datastore.datastore_distributed import DatastoreDistributed [as 别名]
# 或者: from appscale.datastore.datastore_distributed.DatastoreDistributed import get_table_prefix [as 别名]
  def test_delete_entities_txn(self):
    app = 'guestbook'
    txn_hash = {'root_key': 1}
    txn_str = '1'.zfill(ID_KEY_LENGTH)
    entity = self.get_new_entity_proto(app, *self.BASIC_ENTITY[1:])

    db_batch = flexmock()
    db_batch.should_receive('valid_data_version').and_return(True)
    dd = DatastoreDistributed(db_batch, None)

    keys = [entity.key()]
    prefix = dd.get_table_prefix(entity.key())
    entity_key = get_entity_key(prefix, entity.key().path())
    encoded_path = str(encode_index_pb(entity.key().path()))
    txn_keys = [dd._SEPARATOR.join([app, txn_str, '', encoded_path])]
    txn_values = {
      txn_keys[0]: {
        dbconstants.TRANSACTIONS_SCHEMA[0]: dbconstants.TxnActions.DELETE,
        dbconstants.TRANSACTIONS_SCHEMA[1]: entity_key,
        dbconstants.TRANSACTIONS_SCHEMA[2]: ''
      }
    }

    flexmock(dd).should_receive('get_root_key').and_return('root_key')

    db_batch.should_receive('batch_put_entity').with_args(
      dbconstants.TRANSACTIONS_TABLE,
      txn_keys,
      dbconstants.TRANSACTIONS_SCHEMA,
      txn_values,
      ttl=TX_TIMEOUT * 2
    )
    dd.delete_entities_txn(app, keys, txn_hash)
开发者ID:menivaitsi,项目名称:appscale,代码行数:35,代码来源:test_datastore_server.py

示例3: test_get_table_prefix

# 需要导入模块: from appscale.datastore.datastore_distributed import DatastoreDistributed [as 别名]
# 或者: from appscale.datastore.datastore_distributed.DatastoreDistributed import get_table_prefix [as 别名]
 def test_get_table_prefix(self):
   db_batch = flexmock()
   db_batch.should_receive('valid_data_version').and_return(True)
   db_batch.should_receive("batch_put_entity").and_return(None)
   zookeeper = flexmock()
   zookeeper.should_receive("acquire_lock").and_return(True)
   zookeeper.should_receive("release_lock").and_return(True)
   dd = DatastoreDistributed(db_batch, zookeeper)
   item = Item(key_name="Bob", name="Bob", _app="hello")
   key = db.model_to_protobuf(item)
   self.assertEquals(dd.get_table_prefix(key), "hello\x00")
开发者ID:menivaitsi,项目名称:appscale,代码行数:13,代码来源:test_datastore_server.py

示例4: test_get_table_prefix

# 需要导入模块: from appscale.datastore.datastore_distributed import DatastoreDistributed [as 别名]
# 或者: from appscale.datastore.datastore_distributed.DatastoreDistributed import get_table_prefix [as 别名]
  def test_get_table_prefix(self):
    db_batch = flexmock()
    db_batch.should_receive('valid_data_version_sync').and_return(True)

    zk_client = flexmock()
    zk_client.should_receive('add_listener')

    zookeeper = flexmock(handle=zk_client)
    transaction_manager = flexmock()
    dd = DatastoreDistributed(db_batch, transaction_manager, zookeeper)
    item = Item(key_name="Bob", name="Bob", _app="hello")
    key = db.model_to_protobuf(item)
    self.assertEquals(dd.get_table_prefix(key), "hello\x00")
开发者ID:AppScale,项目名称:appscale,代码行数:15,代码来源:test_datastore_server.py

示例5: test_apply_txn_changes

# 需要导入模块: from appscale.datastore.datastore_distributed import DatastoreDistributed [as 别名]
# 或者: from appscale.datastore.datastore_distributed.DatastoreDistributed import get_table_prefix [as 别名]
  def test_apply_txn_changes(self):
    app = 'guestbook'
    txn = 1
    entity = self.get_new_entity_proto(app, *self.BASIC_ENTITY[1:])

    async_metadata = gen.Future()
    async_metadata.set_result({
      'puts': {entity.key().Encode(): entity.Encode()},
      'deletes': [],
      'tasks': [],
      'reads': set(),
      'start': datetime.datetime.utcnow(),
      'is_xg': False,
    })

    db_batch = flexmock()
    db_batch.should_receive('get_transaction_metadata').\
      and_return(async_metadata)
    db_batch.should_receive('valid_data_version_sync').and_return(True)
    db_batch.should_receive('group_updates').and_return([])

    transaction_manager = flexmock(
      delete_transaction_id=lambda project_id, txid: None,
      set_groups=lambda project_id, txid, groups: None)
    dd = DatastoreDistributed(db_batch, transaction_manager,
                              self.get_zookeeper())
    dd.index_manager = flexmock(
      projects={'guestbook': flexmock(indexes_pb=[])})
    prefix = dd.get_table_prefix(entity)
    entity_key = get_entity_key(prefix, entity.key().path())

    async_result = gen.Future()
    async_result.set_result({entity_key: {}})

    db_batch.should_receive('batch_get_entity').and_return(async_result)
    db_batch.should_receive('normal_batch').and_return(ASYNC_NONE)

    async_true = gen.Future()
    async_true.set_result(True)
    entity_lock = flexmock(EntityLock)
    entity_lock.should_receive('acquire').and_return(async_true)
    entity_lock.should_receive('release')

    yield dd.apply_txn_changes(app, txn)
开发者ID:AppScale,项目名称:appscale,代码行数:46,代码来源:test_datastore_server.py

示例6: test_apply_txn_changes

# 需要导入模块: from appscale.datastore.datastore_distributed import DatastoreDistributed [as 别名]
# 或者: from appscale.datastore.datastore_distributed.DatastoreDistributed import get_table_prefix [as 别名]
  def test_apply_txn_changes(self):
    app = 'guestbook'
    txn = 1
    entity = self.get_new_entity_proto(app, *self.BASIC_ENTITY[1:])

    db_batch = flexmock()
    db_batch.should_receive('valid_data_version').and_return(True)
    db_batch.should_receive('range_query').and_return([{
      'txn_entity_1': {'operation': dbconstants.TxnActions.PUT,
                       'operand': entity.Encode()}
    }])

    db_batch.should_receive('get_indices').and_return([])

    dd = DatastoreDistributed(db_batch, None)
    prefix = dd.get_table_prefix(entity)
    entity_key = get_entity_key(prefix, entity.key().path())
    db_batch.should_receive('batch_get_entity').and_return({entity_key: {}})
    db_batch.should_receive('batch_mutate')

    dd.apply_txn_changes(app, txn)
开发者ID:menivaitsi,项目名称:appscale,代码行数:23,代码来源:test_datastore_server.py


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