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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
def unpack(self, reader): data = Data() data.type = packet_types.FS_STORE_OK return data
def unpack(self,reader): data = Data() data.type = packet_types.FS_ERR_NODATASERVERS return data
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
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
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
def unpack(self,reader): data = Data() data.type = packet_types.FS_STORE_OK return data
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
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
def unpack(self, reader): data = Data() data.type = packet_types.FS_ERR_NO_REPLICAS return data
def unpack(self,reader): data = Data() data.type = packet_types.FS_ERR_NO_REPLICAS return data
def unpack(self,reader): data = Data() data.type = packet_types.FS_ERR_PATH_NOT_FOUND return data
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
def unpack(self, reader): data = Data() data.type = packet_types.FS_ERR_NODATASERVERS return data
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
def unpack(self, reader): data = Data() data.type = packet_types.ACK return data
def unpack(self, data): data = Data() (oid, ) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str))) data.oid = oid return data
def unpack(self,reader): data = Data() data.type = packet_types.ACK return data
def unpack(self, reader): data = Data() data.type = packet_types.FS_ERR_PATH_NOT_FOUND return data
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
def unpack(self,data): data = Data() (oid,) = struct.unpack(self.format_str, reader.read(struct.calcsize(self.format_str))) data.oid = oid return data
def unpack(self, reader): data = Data() data.type = packet_types.FS_ERR_CREATE return data
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