コード例 #1
0
ファイル: slowdown.py プロジェクト: dpgoetz/slowdown
 def get_slowdown_data(self):
     if time() - self.last_get > 10:
         try:
             self._slowdown_data = json.load(open(self.data_file))
         except (ValueError, IOError):
             self._slowdown_data = {}
         self.last_get = time()
     return self._slowdown_data
コード例 #2
0
ファイル: server.py プロジェクト: atulshridhar/swift
 def REPLICATE(self, req):
     """
     Handle HTTP REPLICATE request (json-encoded RPC calls for replication.)
     """
     post_args = split_and_validate_path(req, 3)
     drive, partition, hash = post_args
     if self.mount_check and not check_mount(self.root, drive):
         return HTTPInsufficientStorage(drive=drive, request=req)
     try:
         args = json.load(req.environ['wsgi.input'])
     except ValueError, err:
         return HTTPBadRequest(body=str(err), content_type='text/plain')
コード例 #3
0
ファイル: server.py プロジェクト: r0mik/swift
 def REPLICATE(self, req):
     """
     Handle HTTP REPLICATE request (json-encoded RPC calls for replication.)
     """
     post_args = split_and_validate_path(req, 3)
     drive, partition, hash = post_args
     if self.mount_check and not check_mount(self.root, drive):
         return HTTPInsufficientStorage(drive=drive, request=req)
     try:
         args = json.load(req.environ['wsgi.input'])
     except ValueError, err:
         return HTTPBadRequest(body=str(err), content_type='text/plain')
コード例 #4
0
ファイル: server.py プロジェクト: steveruckdashel/swift
 def REPLICATE(self, req):
     """
     Handle HTTP REPLICATE request.
     Handler for RPC calls for account replication.
     """
     post_args = split_and_validate_path(req, 3)
     drive, partition, hash = post_args
     if self.mount_check and not check_mount(self.root, drive):
         return HTTPInsufficientStorage(drive=drive, request=req)
     try:
         args = json.load(req.environ["wsgi.input"])
     except ValueError as err:
         return HTTPBadRequest(body=str(err), content_type="text/plain")
     ret = self.replicator_rpc.dispatch(post_args, args)
     ret.request = req
     return ret
コード例 #5
0
ファイル: server.py プロジェクト: yinyalan/swift
 def REPLICATE(self, req):
     """
     Handle HTTP REPLICATE request.
     Handler for RPC calls for account replication.
     """
     post_args = split_and_validate_path(req, 3)
     drive, partition, hash = post_args
     if not check_drive(self.root, drive, self.mount_check):
         return HTTPInsufficientStorage(drive=drive, request=req)
     try:
         args = json.load(req.environ['wsgi.input'])
     except ValueError as err:
         return HTTPBadRequest(body=str(err), content_type='text/plain')
     ret = self.replicator_rpc.dispatch(post_args, args)
     ret.request = req
     return ret
コード例 #6
0
ファイル: recon.py プロジェクト: zhanghua/swift
    def _from_recon_cache(self, cache_keys, cache_file, openr=open):
        """retrieve values from a recon cache file

        :params cache_keys: list of cache items to retrieve
        :params cache_file: cache file to retrieve items from.
        :params openr: open to use [for unittests]
        :return: dict of cache items and their value or none if not found
        """
        try:
            with openr(cache_file, 'r') as f:
                recondata = json.load(f)
                return dict((key, recondata.get(key)) for key in cache_keys)
        except IOError:
            self.logger.exception(_('Error reading recon cache file'))
        except ValueError:
            self.logger.exception(_('Error parsing recon cache file'))
        except Exception:
            self.logger.exception(_('Error retrieving recon data'))
        return dict((key, None) for key in cache_keys)
コード例 #7
0
ファイル: recon.py プロジェクト: CiscoAS/swift
    def _from_recon_cache(self, cache_keys, cache_file, openr=open):
        """retrieve values from a recon cache file

        :params cache_keys: list of cache items to retrieve
        :params cache_file: cache file to retrieve items from.
        :params openr: open to use [for unittests]
        :return: dict of cache items and their value or none if not found
        """
        try:
            with openr(cache_file, 'r') as f:
                recondata = json.load(f)
                return dict((key, recondata.get(key)) for key in cache_keys)
        except IOError:
            self.logger.exception(_('Error reading recon cache file'))
        except ValueError:
            self.logger.exception(_('Error parsing recon cache file'))
        except Exception:
            self.logger.exception(_('Error retrieving recon data'))
        return dict((key, None) for key in cache_keys)
コード例 #8
0
ファイル: server.py プロジェクト: waiterZen/swift
        Handler for RPC calls for account replication.
        """
        start_time = time.time()
        try:
            post_args = split_path(unquote(req.path), 3)
            drive, partition, hash = post_args
            validate_device_partition(drive, partition)
        except ValueError, err:
            self.logger.increment('REPLICATE.errors')
            return HTTPBadRequest(body=str(err), content_type='text/plain',
                                  request=req)
        if self.mount_check and not check_mount(self.root, drive):
            self.logger.increment('REPLICATE.errors')
            return HTTPInsufficientStorage(drive=drive, request=req)
        try:
            args = json.load(req.environ['wsgi.input'])
        except ValueError, err:
            self.logger.increment('REPLICATE.errors')
            return HTTPBadRequest(body=str(err), content_type='text/plain')
        ret = self.replicator_rpc.dispatch(post_args, args)
        ret.request = req
        self.logger.timing_since('REPLICATE.timing', start_time)
        return ret

    @public
    def POST(self, req):
        """Handle HTTP POST request."""
        start_time = time.time()
        try:
            drive, part, account = split_path(unquote(req.path), 3)
            validate_device_partition(drive, part)
コード例 #9
0
ファイル: server.py プロジェクト: DylanYu/swift
    @public
    @timing_stats
    def REPLICATE(self, req):
        """
        Handle HTTP REPLICATE request (json-encoded RPC calls for replication.)
        """
        try:
            post_args = split_path(unquote(req.path), 3)
            drive, partition, hash = post_args
            validate_device_partition(drive, partition)
        except ValueError, err:
            return HTTPBadRequest(body=str(err), content_type="text/plain", request=req)
        if self.mount_check and not check_mount(self.root, drive):
            return HTTPInsufficientStorage(drive=drive, request=req)
        try:
            args = json.load(req.environ["wsgi.input"])
        except ValueError, err:
            return HTTPBadRequest(body=str(err), content_type="text/plain")
        ret = self.replicator_rpc.dispatch(post_args, args)
        ret.request = req
        return ret

    @public
    @timing_stats
    def POST(self, req):
        """Handle HTTP POST request."""
        try:
            drive, part, account, container = split_path(unquote(req.path), 4)
            validate_device_partition(drive, part)
        except ValueError, err:
            return HTTPBadRequest(body=str(err), content_type="text/plain", request=req)