Example #1
0
 def unpack(self,reader):
     oid = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data()        
     data.oid = oid
     data.type = packet_types.FS_DELETE_DONE
     
     return data
Example #2
0
    def unpack(self, reader):
        data = Data()
        (oid, version, num_blocks) = struct.unpack(
            self.format_str, reader.read(struct.calcsize(self.format_str)))

        blocks = []
        for i in range(num_blocks):
            (block_id, version, offset, length, serverid, ip,
             port) = struct.unpack(
                 self.child_format_str,
                 reader.read(struct.calcsize(self.child_format_str)))
            ip = socket.inet_ntoa(ip)
            block_data = Data(
                params={
                    'block_id': block_id,
                    'version': version,
                    'offset': offset,
                    'length': length,
                    'serverid': serverid,
                    'ip': ip,
                    'port': port
                })
            blocks.append(block_data)

        data[blocks] = blocks
        data.type = packet_types.FS_WRITE_OK

        return data
Example #3
0
 def unpack(self,reader):
     (oid, block_id, length,version,offset) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
         
     data = Data(params={'oid':oid,'block_id':block_id,'length':length,'version':version,'offset':offset})
     data.type = packet_types.FS_STORE_BLOCK
                 
     return data
Example #4
0
 def unpack(self,reader):
     
     (oid,block_id,version,serverid,ip,port) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     ip = socket.inet_ntoa(ip)
     data = Data(params={'oid':oid,'block_id':block_id, 'version':version,'serverid':serverid,'ip':ip,'port':ip})
     data.type = packet_types.FS_REPLICATE_DONE
     return data
Example #5
0
 def unpack(self,reader):
     (oid, version) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     
     data = Data(params={'oid':oid,'version':version})
     data.type = packet_types.FS_END_WRITE
             
     return data
Example #6
0
 def unpack(self,reader):
     data = Data()        
     path = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     data.path = self._short_string(path[0])
     data.type = packet_types.FS_STAT_FILE
     
     return data
Example #7
0
 def unpack(self, reader):
     data = Data()
     (oid,block_id) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     data.oid = oid
     data.block_id = block_id
     data.type = packet_types.FS_GET_BLOCK_REPLICAS
     return data
Example #8
0
    def unpack(self, reader):
        (oid, version) = struct.unpack(
            self.format_str, reader.read(struct.calcsize(self.format_str)))

        data = Data(params={'oid': oid, 'version': version})
        data.type = packet_types.FS_WRITE_READY
        return data
Example #9
0
    def unpack(self, reader):
        path = struct.unpack(self.format_str,
                             reader.read(struct.calcsize(self.format_str)))
        data = Data()
        data.path = self._short_string(path[0])
        data.type = packet_types.FS_DELETE_FILE

        return data
Example #10
0
 def unpack(self,reader):
     (oid,block_id) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data()        
     data.oid = oid
     data.block_id = block_id
     data.type = packet_types.FS_BLOCK_DELETED
     
     return data
Example #11
0
 def unpack(self, reader):
     (oid, ip,
      port) = struct.unpack(self.format_str,
                            reader.read(struct.calcsize(self.format_str)))
     ip = socket.inet_ntoa(ip)
     data = Data(params={'oid': oid, 'ip': ip, 'port': port})
     data.type = packet_types.FS_ERR_DATASERVER_FAILED
     return data
Example #12
0
    def unpack(self, reader):
        oid = struct.unpack(self.format_str,
                            reader.read(struct.calcsize(self.format_str)))
        data = Data()
        data.oid = oid
        data.type = packet_types.FS_DELETE_DONE

        return data
Example #13
0
 def unpack(self, reader):
     data = Data()
     (oid, block_id) = struct.unpack(
         self.format_str, reader.read(struct.calcsize(self.format_str)))
     data.oid = oid
     data.block_id = block_id
     data.type = packet_types.FS_GET_BLOCK_REPLICAS
     return data
Example #14
0
    def unpack(self,reader):
        
        (ip, port, serverid, oid, version, block_size) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
        ip = socket.inet_ntoa(ip)

        data = Data(params={'ip':ip,'port':port,'serverid':serverid,'oid':oid,'version':version,'block_size':block_size})
        data.type = packet_types.FS_CREATE_OK
                
        return data
Example #15
0
    def unpack(self, reader):
        (oid, block_id) = struct.unpack(
            self.format_str, reader.read(struct.calcsize(self.format_str)))
        data = Data()
        data.oid = oid
        data.block_id = block_id
        data.type = packet_types.FS_BLOCK_DELETED

        return data
Example #16
0
 def unpack(self,reader):
     data = Data()
     (ip, port, serverid) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     ip = socket.inet_ntoa(ip)
     data.ip = ip
     data.port = port
     data.serverid = "%s" % serverid
     data.type = packet_types.ANNOUNCE
     return data
Example #17
0
 def unpack(self, reader):
     (oid, block_id, version) = struct.unpack(
         self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data(params={
         'oid': oid,
         'block_id': block_id,
         'version': version
     })
     data.type = packet_types.FS_VERSION_UPDATED
     return data
Example #18
0
 def unpack(self, reader):
     (src_path, dest_path) = struct.unpack(
         self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data(
         params={
             'src_path': self._short_string(src_path),
             'dest_path': self._short_string(dest_path)
         })
     data.type = packet_types.FS_ERR_RENAME
     return data
Example #19
0
    def unpack(self, reader):
        (path, offset,
         length) = struct.unpack(self.format_str,
                                 reader.read(struct.calcsize(self.format_str)))
        data = Data(params={
            'path': self._short_string(path),
            'offset': offset,
            'length': length
        })
        data.type = packet_types.FS_WRITE_FILE

        return data
Example #20
0
 def unpack(self, reader):
     (oid, block_id, version, serverid) = struct.unpack(
         self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data(
         params={
             'oid': oid,
             'block_id': block_id,
             'version': version,
             'serverid': serverid
         })
     data.type = packet_types.FS_GET_LOCK
     return data
Example #21
0
 def unpack(self,reader):
     """Extracts data from an heartbeat packet"""
 
     (ip, port, serverid) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     ip = socket.inet_ntoa(ip)
     
     data = Data()
     data.ip = ip
     data.port = port
     data.serverid = "%s" % serverid
     data.type = packet_types.CHK_DONE
             
     return data
Example #22
0
    def unpack(self, reader):

        (oid, block_id, version,
         length) = struct.unpack(self.format_str,
                                 reader.read(struct.calcsize(self.format_str)))
        data = Data(params={
            'oid': oid,
            'block_id': block_id,
            'version': version,
            'length': length
        })
        data.type = packet_types.FS_REQUEST_OK
        return data
Example #23
0
 def unpack(self, reader):
     (oid, block_id, length, ver, serverid,
      offset) = struct.unpack(self.format_str,
                              reader.read(struct.calcsize(self.format_str)))
     data = Data(
         params={
             'oid': oid,
             'block_id': block_id,
             'length': length,
             'version': ver,
             'serverid': serverid,
             'offset': offset
         })
     data.type = packet_types.FS_BLOCK_STORED
     return data
Example #24
0
 def unpack(self,reader):
     data = Data()        
     (oid,version,num_blocks) = struct.unpack(self.format_str,reader.read(struct.calcsize(self.format_str)))
     
     blocks = []
     for i in range(num_blocks):
         (block_id, version, offset, length, serverid, ip, port) = struct.unpack(self.child_format_str, reader.read(struct.calcsize(self.child_format_str)))
         ip = socket.inet_ntoa(ip)
         block_data = Data(params={'block_id':block_id,'version':version,'offset':offset,'length':length,'serverid':serverid,'ip':ip,'port':port})
         blocks.append(block_data)
         
     data[blocks] = blocks
     data.type = packet_types.FS_WRITE_OK
     
     return data
Example #25
0
 def unpack(self, reader):
     (serverid, oid, block_id, version, offset, length,
      block_size) = struct.unpack(
          self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data(
         params={
             'serverid': serverid,
             'oid': oid,
             'block_id': block_id,
             'version': version,
             'offset': offset,
             'length': length,
             'block_size': block_size
         })
     data.type = packet_types.FS_MODIFY_DONE
     return data
Example #26
0
    def unpack(self, reader):

        (oid, block_id, version, serverid, ip,
         port) = struct.unpack(self.format_str,
                               reader.read(struct.calcsize(self.format_str)))
        ip = socket.inet_ntoa(ip)
        data = Data(
            params={
                'oid': oid,
                'block_id': block_id,
                'version': version,
                'serverid': serverid,
                'ip': ip,
                'port': ip
            })
        data.type = packet_types.FS_REPLICATE_DONE
        return data
Example #27
0
    def unpack(self, reader):

        (ip, port, serverid, oid, version, block_size) = struct.unpack(
            self.format_str, reader.read(struct.calcsize(self.format_str)))
        ip = socket.inet_ntoa(ip)

        data = Data(
            params={
                'ip': ip,
                'port': port,
                'serverid': serverid,
                'oid': oid,
                'version': version,
                'block_size': block_size
            })
        data.type = packet_types.FS_CREATE_OK

        return data
Example #28
0
    def unpack(self,reader):
        
        (oid,num_blocks,version,size,type,parent,block_size,path,) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
        path = self._short_string(path)
        data = Data(params={'oid':oid,'num_blocks':num_blocks,'path':path,'version':version,'size':size,'file_type':type,'parent':parent,'block_size':block_size})

        if data.file_type == 0:
            (children_len,) = struct.unpack(self.child_format_str, reader.read(struct.calcsize(self.child_format_str)))
            
            childs = []
            for i in range(children_len):
                
                (oid,num_blocks,version,size,type,parent,block_size,path,) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
                path = self._short_string(path)
                child = Data(params={'oid':oid,'num_blocks':num_blocks,'path':path,'version':version,'size':size,'file_type':type,'parent':parent,'block_size':block_size})
                childs.append(child)

            data.children = childs
        
        data.type = packet_types.FS_FILE_INFO
        
        return data
Example #29
0
    def unpack(self, reader):

        (file_type, path, block_size, replicas) = struct.unpack(
            self.format_str, reader.read(struct.calcsize(self.format_str)))

        data = Data()
        data.file_type = file_type
        data.path = self._short_string(path)  #self._short_string(path)
        data.block_size = block_size
        data.replicas = replicas
        data.type = packet_types.FS_CREATE

        return data
Example #30
0
 def unpack(self, reader):
     data = Data()
     (ip, port, serverid) = struct.unpack(
         self.format_str, reader.read(struct.calcsize(self.format_str)))
     ip = socket.inet_ntoa(ip)
     data.ip = ip
     data.port = port
     data.serverid = "%s" % serverid
     data.type = packet_types.ANNOUNCE
     return data
Example #31
0
    def unpack(self, reader):

        (file_type, path, block_size, replicas) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))

        data = Data()
        data.file_type = file_type
        data.path = self._short_string(path) #self._short_string(path)
        data.block_size = block_size
        data.replicas = replicas
        data.type = packet_types.FS_CREATE
        
        return data
Example #32
0
 def unpack(self, reader):
     (oid,block_id,length) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data()
     data.oid = oid
     data.block_id = block_id
     
     data.replicas = {}
     
     for i in range(length):
         (key,val) = struct.unpack(self.child_format_str, reader.read(struct.calcsize(self.child_format_str)))
         data.replicas[key] = val
     
     data.type = packet_types.FS_BLOCK_REPLICAS
     return data
Example #33
0
 def unpack(self, reader):
     (oid,version,length) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data()
     data.oid = oid
     data.version = version
     
     data.blocks = {}
     
     for i in range(length):
         (key,val) = struct.unpack(self.child_format_str, reader.read(struct.calcsize(self.child_format_str)))
         data.blocks[key] = val
     
     data.type = packet_types.FS_OID_BLOCKS
     return data
Example #34
0
    def unpack(self, reader):
        """Extracts data from an heartbeat packet"""

        (ip, port, serverid) = struct.unpack(
            self.format_str, reader.read(struct.calcsize(self.format_str)))
        ip = socket.inet_ntoa(ip)

        data = Data()
        data.ip = ip
        data.port = port
        data.serverid = "%s" % serverid
        data.type = packet_types.CHK_DONE

        return data
Example #35
0
    def unpack(self, reader):
        (oid, version,
         length) = struct.unpack(self.format_str,
                                 reader.read(struct.calcsize(self.format_str)))
        data = Data()
        data.oid = oid
        data.version = version

        data.blocks = {}

        for i in range(length):
            (key, val) = struct.unpack(
                self.child_format_str,
                reader.read(struct.calcsize(self.child_format_str)))
            data.blocks[key] = val

        data.type = packet_types.FS_OID_BLOCKS
        return data
Example #36
0
    def unpack(self, reader):
        (oid, block_id,
         length) = struct.unpack(self.format_str,
                                 reader.read(struct.calcsize(self.format_str)))
        data = Data()
        data.oid = oid
        data.block_id = block_id

        data.replicas = {}

        for i in range(length):
            (key, val) = struct.unpack(
                self.child_format_str,
                reader.read(struct.calcsize(self.child_format_str)))
            data.replicas[key] = val

        data.type = packet_types.FS_BLOCK_REPLICAS
        return data
Example #37
0
 def unpack(self, reader):
     (oid, length, version) = struct.unpack(
         self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data(params={'oid': oid, 'length': length, 'version': version})
     data.type = packet_types.FS_NODE_CREATED
     return data
Example #38
0
 def unpack(self, reader):
     data = Data()
     data.type = packet_types.FS_STORE_OK
     return data
Example #39
0
    def unpack(self,reader):
        data = Data()
        data.type = packet_types.FS_ERR_NODATASERVERS

        return data
Example #40
0
 def unpack(self,reader):
     (src_path, dest_path) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data(params={'src_path':self._short_string(src_path), 'dest_path':self._short_string(dest_path)})
     data.type = packet_types.FS_ERR_RENAME
     return data
Example #41
0
 def unpack(self,reader):
     
     (oid,block_id,version) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data(params={'oid':oid,'block_id':block_id,'version':version})
     data.type = packet_types.FS_ERR_LOCK_DENIED
     return data
Example #42
0
 def unpack(self, reader):
     (oid, version) = struct.unpack(
         self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data(params={'oid': oid, 'version': version})
     data.type = packet_types.FS_ERR_BUFFER_OUT_OF_RANGE
     return data
Example #43
0
 def unpack(self,reader):
     data = Data()
     data.type = packet_types.FS_STORE_OK
     return data
Example #44
0
    def unpack(self,reader):
        (oid,block_id,version,serverid) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
        data = Data(params={'oid':oid,'block_id':block_id,'version':version,'serverid':serverid})
        data.type = packet_types.CURR_BLOCK

        return data
Example #45
0
 def unpack(self,reader):
     (path,offset,length) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data(params={'path':self._short_string(path),'offset':offset,'length':length})
     data.type = packet_types.FS_WRITE_FILE
     
     return data
Example #46
0
    def unpack(self, reader):
        data = Data()
        data.type = packet_types.FS_ERR_NO_REPLICAS

        return data
Example #47
0
    def unpack(self,reader):
        data = Data()
        data.type = packet_types.FS_ERR_NO_REPLICAS

        return data
Example #48
0
    def unpack(self,reader):
        data = Data()
        data.type = packet_types.FS_ERR_PATH_NOT_FOUND

        return data
Example #49
0
    def unpack(self,reader):

        (oid, block_id, version, length) = struct.unpack(self.format_str,reader.read(struct.calcsize(self.format_str)))
        data = Data(params={'oid':oid,'block_id':block_id,'version':version,'length':length})
        data.type = packet_types.FS_REQUEST_OK
        return data
Example #50
0
    def unpack(self, reader):
        data = Data()
        data.type = packet_types.FS_ERR_NODATASERVERS

        return data
Example #51
0
 def unpack(self,reader):
     (serverid,oid,block_id,version,offset,length,block_size) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data(params={'serverid':serverid,'oid':oid,'block_id':block_id,'version':version,'offset':offset,'length':length,'block_size':block_size})
     data.type = packet_types.FS_MODIFY_DONE
     return data
Example #52
0
 def unpack(self, reader):
     data = Data()
     data.type = packet_types.ACK
     return data
Example #53
0
 def unpack(self, data):
     data = Data()
     (oid, ) = struct.unpack(self.format_str,
                             reader.read(struct.calcsize(self.format_str)))
     data.oid = oid
     return data
Example #54
0
 def unpack(self,reader):
     data = Data()
     data.type = packet_types.ACK
     return data
Example #55
0
    def unpack(self, reader):
        data = Data()
        data.type = packet_types.FS_ERR_PATH_NOT_FOUND

        return data
Example #56
0
 def unpack(self,reader):
     (oid,ip,port) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     ip = socket.inet_ntoa(ip)
     data = Data(params={'oid':oid,'ip':ip,'port':port})
     data.type = packet_types.FS_ERR_DATASERVER_FAILED
     return data
Example #57
0
 def unpack(self,data):
     data = Data()
     (oid,) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     data.oid = oid
     return data
Example #58
0
    def unpack(self, reader):
        data = Data()
        data.type = packet_types.FS_ERR_CREATE

        return data
Example #59
0
 def unpack(self, reader):
     (oid,length,version) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str)))
     data = Data(params={'oid':oid,'length':length,'version':version})
     data.type = packet_types.FS_NODE_CREATED
     return data
Example #60
0
    def unpack(self, reader):
        data = Data()
        data.type = packet_types.FS_ERR_CREATE

        return data