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


Python cqlbatch.Batch类代码示例

本文整理汇总了Python中otter.util.cqlbatch.Batch的典型用法代码示例。如果您正苦于以下问题:Python Batch类的具体用法?Python Batch怎么用?Python Batch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: create_scaling_group

    def create_scaling_group(self, log, tenant_id, config, launch, policies=None):
        """
        see :meth:`otter.models.interface.IScalingGroupCollection.create_scaling_group`
        """
        scaling_group_id = generate_key_str('scalinggroup')

        log.bind(tenant_id=tenant_id, scaling_group_id=scaling_group_id).msg("Creating scaling group")

        queries = [
            _cql_insert.format(cf=self.config_table, name=":scaling"),
            _cql_insert.format(cf=self.launch_table, name=":launch"),
            _cql_create_group_state.format(cf=self.state_table)]

        data = {"tenantId": tenant_id,
                "groupId": scaling_group_id,
                "scaling": serialize_json_data(config, 1),
                "launch": serialize_json_data(launch, 1),
                }

        outpolicies = {}
        _build_policies(policies, self.policies_table, self.event_table, queries, data,
                        outpolicies)

        b = Batch(queries, data,
                  consistency=get_consistency_level('create', 'group'))
        d = b.execute(self.connection)
        d.addCallback(lambda _: {
            'groupConfiguration': config,
            'launchConfiguration': launch,
            'scalingPolicies': outpolicies,
            'id': scaling_group_id
        })
        return d
开发者ID:danngrant,项目名称:otter,代码行数:33,代码来源:cass.py

示例2: create_scaling_group

    def create_scaling_group(self, log, tenant_id, config, launch, policies=None):
        """
        see :meth:`otter.models.interface.IScalingGroupCollection.create_scaling_group`
        """
        scaling_group_id = generate_key_str('scalinggroup')

        log.bind(tenant_id=tenant_id, scaling_group_id=scaling_group_id).msg("Creating scaling group")

        queries = [_cql_create_group.format(cf=self.group_table)]

        data = {"tenantId": tenant_id,
                "groupId": scaling_group_id,
                "group_config": serialize_json_data(config, 1),
                "launch_config": serialize_json_data(launch, 1),
                "active": '{}',
                "pending": '{}',
                "policyTouched": '{}',
                "paused": False,
                "created_at": datetime.utcnow()
                }

        outpolicies = {}
        _build_policies(policies, self.policies_table, self.event_table, queries, data,
                        outpolicies)

        b = Batch(queries, data,
                  consistency=get_consistency_level('create', 'group'))
        d = b.execute(self.connection)
        d.addCallback(lambda _: {
            'groupConfiguration': config,
            'launchConfiguration': launch,
            'scalingPolicies': outpolicies,
            'id': scaling_group_id
        })
        return d
开发者ID:michael-mcgrail-rackspace,项目名称:otter,代码行数:35,代码来源:cass.py

示例3: _do_update

 def _do_update(_):
     queries, data = list(), dict()
     for i, event in enumerate(update_events):
         polname = 'policy{}'.format(i)
         queries.append(_cql_insert_event_batch.format(cf=self.event_table, name=':' + polname))
         data.update({polname + key: event[key] for key in event})
     b = Batch(queries, data, get_consistency_level('insert', 'event'))
     return b.execute(self.connection)
开发者ID:RackerWilliams,项目名称:otter,代码行数:8,代码来源:cass.py

示例4: _do_update_config

        def _do_update_config(lastRev):
            queries = [_cql_update.format(cf=self.config_table, name=":scaling")]

            b = Batch(queries, {"tenantId": self.tenant_id,
                                "groupId": self.uuid,
                                "scaling": serialize_json_data(data, 1)},
                      consistency=get_consistency_level('update', 'partial'))
            return b.execute(self.connection)
开发者ID:danngrant,项目名称:otter,代码行数:8,代码来源:cass.py

示例5: _do_update_policy

 def _do_update_policy(_):
     queries = [_cql_update_policy.format(cf=self.policies_table, name=":policy")]
     b = Batch(queries, {"tenantId": self.tenant_id,
                         "groupId": self.uuid,
                         "policyId": policy_id,
                         "policy": serialize_json_data(data, 1)},
               consistency=get_consistency_level('update', 'policy'))
     return b.execute(self.connection)
开发者ID:RackerWilliams,项目名称:otter,代码行数:8,代码来源:cass.py

示例6: _do_update_launch

        def _do_update_launch(lastRev):
            queries = [_cql_update.format(cf=self.group_table, column='launch_config',
                                          name=":launch")]

            b = Batch(queries, {"tenantId": self.tenant_id,
                                "groupId": self.uuid,
                                "launch": serialize_json_data(data, 1)},
                      consistency=get_consistency_level('update', 'partial'))
            d = b.execute(self.connection)
            return d
开发者ID:RackerWilliams,项目名称:otter,代码行数:10,代码来源:cass.py

示例7: _do_delete

 def _do_delete(_):
     queries = [
         _cql_delete_all_in_policy.format(cf=self.policies_table),
         _cql_delete_all_in_policy.format(cf=self.webhooks_table),
         _cql_delete_policy_events.format(cf=self.event_table)]
     b = Batch(queries, {"tenantId": self.tenant_id,
                         "groupId": self.uuid,
                         "policyId": policy_id},
               consistency=get_consistency_level('delete', 'policy'))
     return b.execute(self.connection)
开发者ID:RackerWilliams,项目名称:otter,代码行数:10,代码来源:cass.py

示例8: test_batch

 def test_batch(self):
     """
     Test a simple batch
     """
     batch = Batch(['INSERT * INTO BLAH', 'INSERT * INTO BLOO'], {})
     d = batch.execute(self.connection)
     self.successResultOf(d)
     expected = 'BEGIN BATCH INSERT * INTO BLAH'
     expected += ' INSERT * INTO BLOO APPLY BATCH;'
     self.connection.execute.assert_called_once_with(expected, {},
                                                     ConsistencyLevel.ONE)
开发者ID:dwcramer,项目名称:otter,代码行数:11,代码来源:test_cqlbatch.py

示例9: test_batch_ts

 def test_batch_ts(self):
     """
     Test a simple batch with timestamp set
     """
     batch = Batch(['INSERT * INTO BLAH'], {}, timestamp=123)
     d = batch.execute(self.connection)
     self.successResultOf(d)
     expected = 'BEGIN BATCH USING TIMESTAMP 123'
     expected += ' INSERT * INTO BLAH APPLY BATCH;'
     self.connection.execute.assert_called_once_with(expected, {},
                                                     ConsistencyLevel.ONE)
开发者ID:dwcramer,项目名称:otter,代码行数:11,代码来源:test_cqlbatch.py

示例10: _do_create_pol

        def _do_create_pol(lastRev):
            queries = []
            cqldata = {"tenantId": self.tenant_id,
                       "groupId": self.uuid}

            outpolicies = _build_policies(data, self.policies_table,
                                          self.event_table, queries, cqldata)

            b = Batch(queries, cqldata,
                      consistency=get_consistency_level('create', 'policy'))
            d = b.execute(self.connection)
            return d.addCallback(lambda _: outpolicies)
开发者ID:RackerWilliams,项目名称:otter,代码行数:12,代码来源:cass.py

示例11: test_batch_consistency

 def test_batch_consistency(self):
     """
     Test a simple batch with consistency set
     """
     batch = Batch(['INSERT * INTO BLAH'], {},
                   consistency=ConsistencyLevel.QUORUM)
     d = batch.execute(self.connection)
     self.successResultOf(d)
     expected = 'BEGIN BATCH'
     expected += ' INSERT * INTO BLAH APPLY BATCH;'
     self.connection.execute.assert_called_once_with(
         expected, {}, ConsistencyLevel.QUORUM)
开发者ID:dwcramer,项目名称:otter,代码行数:12,代码来源:test_cqlbatch.py

示例12: test_batch_param

 def test_batch_param(self):
     """
     Test a simple batch with params
     """
     params = {"blah": "ff"}
     batch = Batch(['INSERT :blah INTO BLAH', 'INSERT * INTO BLOO'],
                   params)
     d = batch.execute(self.connection)
     self.successResultOf(d)
     expected = 'BEGIN BATCH INSERT :blah INTO BLAH'
     expected += ' INSERT * INTO BLOO APPLY BATCH;'
     self.connection.execute.assert_called_once_with(expected, params,
                                                     ConsistencyLevel.ONE)
开发者ID:dwcramer,项目名称:otter,代码行数:13,代码来源:test_cqlbatch.py

示例13: _do_create

        def _do_create(lastRev):
            queries = []
            cql_params = {"tenantId": self.tenant_id,
                          "groupId": self.uuid,
                          "policyId": policy_id}

            output = _build_webhooks(data, self.webhooks_table, queries,
                                     cql_params)

            b = Batch(queries, cql_params,
                      consistency=get_consistency_level('create', 'webhook'))
            d = b.execute(self.connection)
            return d.addCallback(lambda _: output)
开发者ID:RackerWilliams,项目名称:otter,代码行数:13,代码来源:cass.py

示例14: update_events_trigger

 def update_events_trigger(self, policy_and_triggers):
     """
     see :meth:`otter.models.interface.IScalingScheduleCollection.update_events_trigger`
     """
     queries = []
     data = {}
     for i, (policy_id, trigger) in enumerate(policy_and_triggers):
         queries.append(_cql_update_event.format(cf=self.event_table,
                                                 trigger=':trigger{0}'.format(i),
                                                 policy_id=':policyid{0}'.format(i)))
         data.update({'trigger{0}'.format(i): trigger,
                      'policyid{0}'.format(i): policy_id})
     b = Batch(queries, data, get_consistency_level('update', 'events'))
     return b.execute(self.connection)
开发者ID:danngrant,项目名称:otter,代码行数:14,代码来源:cass.py

示例15: _do_update_launch

        def _do_update_launch(lastRev):
            if "type" in lastRev:
                if lastRev["type"] != data["type"]:
                    raise ValidationError("Cannot change type of a scaling policy")

            queries = [_cql_update_policy.format(cf=self.policies_table, name=":policy")]

            b = Batch(queries, {"tenantId": self.tenant_id,
                                "groupId": self.uuid,
                                "policyId": policy_id,
                                "policy": serialize_json_data(data, 1)},
                      consistency=get_consistency_level('update', 'policy'))
            d = b.execute(self.connection)
            return d
开发者ID:apurvvkumaria,项目名称:otter,代码行数:14,代码来源:cass.py


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