Revision cb9432cc snf-pithos-backend/pithos/backends/lib/hashfiler/mapper.py

b/snf-pithos-backend/pithos/backends/lib/hashfiler/mapper.py
32 32
# or implied, of GRNET S.A.
33 33

  
34 34
from filemapper import FileMapper
35
from binascii import hexlify
36

  
37
from archipelago.common import (
38
        Request,
39
        xseg_reply_info,
40
        xseg_reply_map,
41
        xseg_reply_map_scatterlist,
42
        string_at,
43
        )
44

  
45
import ctypes
46

  
47
from pithos.workers import (
48
        glue,
49
        monkey,
50
        )
51

  
52
monkey.patch_Request()
35 53

  
36 54

  
37 55
class Mapper(object):
......
58 76
        """
59 77
        return self.fmap.map_retr(maphash, blkoff, nr)
60 78

  
79
    def map_retr_archip(self, maphash, size):
80
        ioctx_pool = glue.WorkerGlue.ioctx_pool
81
        dst_port = 1001
82
        ioctx = ioctx_pool.pool_get()
83
        maphash = maphash.split(":")[1]
84
        req = Request.get_mapr_request(ioctx, dst_port, maphash, offset=0, size=size)
85
        req.submit()
86
        req.wait()
87
        ret = req.success()
88
        if ret:
89
            data =  req.get_data(xseg_reply_map)
90
            Segsarray = xseg_reply_map_scatterlist * data.contents.cnt
91
            segs = Segsarray.from_address(ctypes.addressof(data.contents.segs))
92
            req.put()
93
        else:
94
            req.put()
95
            ioctx_pool.pool_put(ioctx)
96
        ioctx_pool.pool_put(ioctx)
97
        return [string_at(segs[idx].target)  for idx in xrange(len(segs)) ]
98

  
61 99
    def map_stor(self, maphash, hashes=(), blkoff=0, create=1):
62 100
        """Store hashes in the given hashes map."""
63 101
        if self.rmap:

Also available in: Unified diff