• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python direct_client.direct_delete_object函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: reap_object

    def reap_object(self, account, container, container_partition,
                    container_nodes, obj):
        """
        Deletes the given object by issuing a delete request to each node for
        the object. The format of the delete request is such that each object
        server will update a corresponding container server, removing the
        object from the container's listing.

        This function returns nothing and should raise no exception but only
        update various self.stats_* values for what occurs.

        :param account: The name of the account for the object.
        :param container: The name of the container for the object.
        :param container_partition: The partition for the container on the
                                    container ring.
        :param container_nodes: The primary node dicts for the container.
        :param obj: The name of the object to delete.

        * See also: :func:`swift.common.ring.Ring.get_nodes` for a description
          of the container node dicts.
        """
        container_nodes = list(container_nodes)
        part, nodes = self.get_object_ring().get_nodes(account, container, obj)
        successes = 0
        failures = 0
        for node in nodes:
            cnode = container_nodes.pop()
            try:
                direct_delete_object(
                    node, part, account, container, obj,
                    conn_timeout=self.conn_timeout,
                    response_timeout=self.node_timeout,
                    headers={'X-Container-Host': '%(ip)s:%(port)s' % cnode,
                             'X-Container-Partition': str(container_partition),
                             'X-Container-Device': cnode['device']})
                successes += 1
                self.stats_return_codes[2] = \
                    self.stats_return_codes.get(2, 0) + 1
                self.logger.increment('return_codes.2')
            except ClientException, err:
                if self.logger.getEffectiveLevel() <= DEBUG:
                    self.logger.exception(
                        _('Exception with %(ip)s:%(port)s/%(device)s'), node)
                failures += 1
                self.logger.increment('objects_failures')
                self.stats_return_codes[err.http_status / 100] = \
                    self.stats_return_codes.get(err.http_status / 100, 0) + 1
                self.logger.increment(
                    'return_codes.%d' % (err.http_status / 100,))
            if successes > failures:
                self.stats_objects_deleted += 1
                self.logger.increment('objects_deleted')
            elif not successes:
                self.stats_objects_remaining += 1
                self.logger.increment('objects_remaining')
            else:
                self.stats_objects_possibly_remaining += 1
                self.logger.increment('objects_possibly_remaining')
开发者ID:ChenZhengtongnju,项目名称:swift,代码行数:58,代码来源:reaper.py


示例2: test_direct_delete_object_error

 def test_direct_delete_object_error(self):
     with mocked_http_conn(503) as conn:
         with self.assertRaises(ClientException) as raised:
             direct_client.direct_delete_object(
                 self.node, self.part, self.account, self.container,
                 self.obj)
         self.assertEqual(conn.method, 'DELETE')
         self.assertEqual(conn.path, self.obj_path)
     self.assertEqual(raised.exception.http_status, 503)
     self.assertTrue('DELETE' in str(raised.exception))
开发者ID:jgmerritt,项目名称:swift,代码行数:10,代码来源:test_direct_client.py


示例3: test_direct_delete_object_with_timestamp

 def test_direct_delete_object_with_timestamp(self):
     # ensure timestamp is different from any that might be auto-generated
     timestamp = Timestamp(time.time() - 100)
     headers = {'X-Timestamp': timestamp.internal}
     with mocked_http_conn(200) as conn:
         direct_client.direct_delete_object(
             self.node, self.part, self.account, self.container, self.obj,
             headers=headers)
         self.assertEqual(conn.method, 'DELETE')
         self.assertEqual(conn.path, self.obj_path)
         self.assertTrue('X-Timestamp' in conn.req_headers)
         self.assertEqual(timestamp, conn.req_headers['X-Timestamp'])
开发者ID:aureliengoulon,项目名称:swift,代码行数:12,代码来源:test_direct_client.py


示例4: test_direct_delete_object

    def test_direct_delete_object(self):
        node = {'ip': '1.2.3.4', 'port': '6000', 'device': 'sda'}
        part = '0'
        account = 'a'
        container = 'c'
        name = 'o'

        was_http_connector = direct_client.http_connect
        direct_client.http_connect = mock_http_connect(200)

        direct_client.direct_delete_object(node, part, account, container, name)

        direct_client.http_connect = was_http_connector
开发者ID:zhouyuan,项目名称:swift,代码行数:13,代码来源:test_direct_client.py


示例5: test_direct_delete_object_error

 def test_direct_delete_object_error(self):
     with mocked_http_conn(503) as conn:
         try:
             direct_client.direct_delete_object(
                 self.node, self.part, self.account, self.container,
                 self.obj)
         except ClientException as err:
             pass
         else:
             self.fail('ClientException not raised')
         self.assertEqual(conn.method, 'DELETE')
         self.assertEqual(conn.path, self.obj_path)
     self.assertEqual(err.http_status, 503)
     self.assertTrue('DELETE' in str(err))
开发者ID:aureliengoulon,项目名称:swift,代码行数:14,代码来源:test_direct_client.py


示例6: _run

 def _run(self, thread):
     if time.time() - self.heartbeat >= 15:
         self.heartbeat = time.time()
         self._log_status("DEL")
     device, partition, name, container_name = self.names.pop()
     with self.connection() as conn:
         try:
             if self.use_proxy:
                 client.delete_object(self.url, self.token, container_name, name, http_conn=conn)
             else:
                 node = {"ip": self.ip, "port": self.port, "device": device}
                 direct_client.direct_delete_object(node, partition, self.account, container_name, name)
         except client.ClientException, e:
             self.logger.debug(str(e))
             self.failures += 1
开发者ID:Gaurav-Gangalwar,项目名称:UFO,代码行数:15,代码来源:bench.py


示例7: test_direct_delete_object

 def test_direct_delete_object(self):
     with mocked_http_conn(200) as conn:
         resp = direct_client.direct_delete_object(
             self.node, self.part, self.account, self.container, self.obj)
         self.assertEqual(conn.method, 'DELETE')
         self.assertEqual(conn.path, self.obj_path)
     self.assertEqual(resp, None)
开发者ID:aureliengoulon,项目名称:swift,代码行数:7,代码来源:test_direct_client.py


示例8: reap_object

    def reap_object(self, account, container, container_partition,
                    container_nodes, obj, policy_index):
        """
        Deletes the given object by issuing a delete request to each node for
        the object. The format of the delete request is such that each object
        server will update a corresponding container server, removing the
        object from the container's listing.

        This function returns nothing and should raise no exception but only
        update various self.stats_* values for what occurs.

        :param account: The name of the account for the object.
        :param container: The name of the container for the object.
        :param container_partition: The partition for the container on the
                                    container ring.
        :param container_nodes: The primary node dicts for the container.
        :param obj: The name of the object to delete.
        :param policy_index: The storage policy index of the object's container

        * See also: :func:`swift.common.ring.Ring.get_nodes` for a description
          of the container node dicts.
        """
        cnodes = itertools.cycle(container_nodes)
        try:
            ring = self.get_object_ring(policy_index)
        except PolicyError:
            self.stats_objects_remaining += 1
            self.logger.increment('objects_remaining')
            return
        part, nodes = ring.get_nodes(account, container, obj)
        successes = 0
        failures = 0
        timestamp = Timestamp.now()

        for node in nodes:
            cnode = next(cnodes)
            try:
                direct_delete_object(
                    node, part, account, container, obj,
                    conn_timeout=self.conn_timeout,
                    response_timeout=self.node_timeout,
                    headers={'X-Container-Host': '%(ip)s:%(port)s' % cnode,
                             'X-Container-Partition': str(container_partition),
                             'X-Container-Device': cnode['device'],
                             'X-Backend-Storage-Policy-Index': policy_index,
                             'X-Timestamp': timestamp.internal})
                successes += 1
                self.stats_return_codes[2] = \
                    self.stats_return_codes.get(2, 0) + 1
                self.logger.increment('return_codes.2')
            except ClientException as err:
                if self.logger.getEffectiveLevel() <= DEBUG:
                    self.logger.exception(
                        _('Exception with %(ip)s:%(port)s/%(device)s'), node)
                failures += 1
                self.logger.increment('objects_failures')
                self.stats_return_codes[err.http_status // 100] = \
                    self.stats_return_codes.get(err.http_status // 100, 0) + 1
                self.logger.increment(
                    'return_codes.%d' % (err.http_status // 100,))
            except (Timeout, socket.error) as err:
                failures += 1
                self.logger.increment('objects_failures')
                self.logger.error(
                    _('Timeout Exception with %(ip)s:%(port)s/%(device)s'),
                    node)
            if successes > failures:
                self.stats_objects_deleted += 1
                self.logger.increment('objects_deleted')
            elif not successes:
                self.stats_objects_remaining += 1
                self.logger.increment('objects_remaining')
            else:
                self.stats_objects_possibly_remaining += 1
                self.logger.increment('objects_possibly_remaining')
开发者ID:jgmerritt,项目名称:swift,代码行数:75,代码来源:reaper.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap