Beispiel #1
0
def downloadFile(setting, metadata):
    '''Workflow of Download file.'''
    if setting.deduplication == False:
        #Acquire read lock if using ZooKeeper:
        #if setting.zookeeper: setting.zk.getReadLock(metadata) #cq
        #Download metadata:
        storage.downloadMetadata(setting, metadata)
        #Update metadata for requesting chunks for decode:
        coding.updateMetadataForDecode(setting, metadata, 'download')
        #Download chunk files:
        storage.downloadFile(setting, metadata)
        #Release read lock:
        #if setting.zookeeper: setting.zk.releaseReadLock(metadata) #cq
        #Decode file:
        coding.decodeFile(setting, metadata, 'download')
    else:
        retState = storage.detectPointer(setting,metadata)
        if retState == False:
            '''The file detected is non_dup or org file'''
            storage.downloadMetadata(setting, metadata)
            coding.updateMetadataForDecode(setting, metadata, 'download')
            storage.downloadFile(setting, metadata)
            coding.decodeFile(setting, metadata, 'download')
        else:
            '''The file detected is a leaf'''
            storage.downloadPointer(setting,metadata)
            targetFile = storage.getPointerContent(setting, metadata)
            targetMetadata = common.FileMetadata(targetFile,0,setting.totalnode,setting.coding)
            storage.downloadMetadata(setting, targetMetadata)
            coding.updateMetadataForDecode(setting, targetMetadata, 'download')
            storage.downloadFile(setting, targetMetadata)
            coding.decodeFile(setting,targetMetadata, 'download')
            storage.genPtLocalFile(setting,targetMetadata,metadata)
Beispiel #2
0
def downloadFile(setting, metadata):
    '''Workflow of Download file.'''
    if setting.deduplication == False:
        #Acquire read lock if using ZooKeeper:
        #if setting.zookeeper: setting.zk.getReadLock(metadata) #cq
        #Download metadata:
        storage.downloadMetadata(setting, metadata)
        #Update metadata for requesting chunks for decode:
        coding.updateMetadataForDecode(setting, metadata, 'download')
        #Download chunk files:
        storage.downloadFile(setting, metadata)
        #Release read lock:
        #if setting.zookeeper: setting.zk.releaseReadLock(metadata) #cq
        #Decode file:
        coding.decodeFile(setting, metadata, 'download')
    else:
        retState = storage.detectPointer(setting, metadata)
        if retState == False:
            '''The file detected is non_dup or org file'''
            storage.downloadMetadata(setting, metadata)
            coding.updateMetadataForDecode(setting, metadata, 'download')
            storage.downloadFile(setting, metadata)
            coding.decodeFile(setting, metadata, 'download')
        else:
            '''The file detected is a leaf'''
            storage.downloadPointer(setting, metadata)
            targetFile = storage.getPointerContent(setting, metadata)
            targetMetadata = common.FileMetadata(targetFile, 0,
                                                 setting.totalnode,
                                                 setting.coding)
            storage.downloadMetadata(setting, targetMetadata)
            coding.updateMetadataForDecode(setting, targetMetadata, 'download')
            storage.downloadFile(setting, targetMetadata)
            coding.decodeFile(setting, targetMetadata, 'download')
            storage.genPtLocalFile(setting, targetMetadata, metadata)
Beispiel #3
0
def rebuildFile(settingOld, settingNew, metadata, filename):
    '''Workflow of File rebuid.'''
    if settingNew.deduplication == False:
        #Acquire write lock if using ZooKeeper:
        #if settingOld.zookeeper: settingOld.zk.getWriteLock(metadata) #cq
        #Download metadata:
        print "downloadMetadata"
        storage.downloadMetadata(settingOld, metadata)
        #Update metadata for repair:
        print "updateMetadataForDecode"
        coding.updateMetadataForDecode(settingOld, metadata, 'repair')
        #Download file chunks:
        print "downloadFile"
        storage.downloadFile(settingOld, metadata)
        #Reapir file:
        print "repair File"
        coding.repairFile(settingOld, settingNew, metadata)
        #Upload repaired chunks:
        print "upload file and metadata"
        storage.uploadFileAndMetadata(settingNew, metadata, 'repair')
        #Release write lock:
        #if settingOld.zookeeper: settingOld.zk.releaseWriteLock(metadata) #cq
        coding.decodeFile(settingNew, metadata, 'download')
    else:
        retState = storage.detectPointer(settingNew, metadata)
        if retState == False:
            #org or non_dup
           print "rebuild org or non_dup %s" % (metadata.filename)
           storage.downloadMetadata(settingOld, metadata)
           coding.updateMetadataForDecode(settingOld, metadata, 'repair')
           storage.downloadFile(settingOld, metadata)
           coding.repairFile(settingOld, settingNew, metadata)
           storage.uploadFileAndMetadata(settingNew, metadata, 'repair')
           coding.decodeFile(settingNew, metadata, 'download')
        else:
            print "rebuild pointer %s" % (metadata.filename)
            storage.repairPointer(settingOld, settingNew, metadata)
Beispiel #4
0
def rebuildFile(settingOld, settingNew, metadata, filename):
    '''Workflow of File rebuid.'''
    if settingNew.deduplication == False:
        #Acquire write lock if using ZooKeeper:
        #if settingOld.zookeeper: settingOld.zk.getWriteLock(metadata) #cq
        #Download metadata:
        print "downloadMetadata"
        storage.downloadMetadata(settingOld, metadata)
        #Update metadata for repair:
        print "updateMetadataForDecode"
        coding.updateMetadataForDecode(settingOld, metadata, 'repair')
        #Download file chunks:
        print "downloadFile"
        storage.downloadFile(settingOld, metadata)
        #Reapir file:
        print "repair File"
        coding.repairFile(settingOld, settingNew, metadata)
        #Upload repaired chunks:
        print "upload file and metadata"
        storage.uploadFileAndMetadata(settingNew, metadata, 'repair')
        #Release write lock:
        #if settingOld.zookeeper: settingOld.zk.releaseWriteLock(metadata) #cq
        coding.decodeFile(settingNew, metadata, 'download')
    else:
        retState = storage.detectPointer(settingNew, metadata)
        if retState == False:
            #org or non_dup
            print "rebuild org or non_dup %s" % (metadata.filename)
            storage.downloadMetadata(settingOld, metadata)
            coding.updateMetadataForDecode(settingOld, metadata, 'repair')
            storage.downloadFile(settingOld, metadata)
            coding.repairFile(settingOld, settingNew, metadata)
            storage.uploadFileAndMetadata(settingNew, metadata, 'repair')
            coding.decodeFile(settingNew, metadata, 'download')
        else:
            print "rebuild pointer %s" % (metadata.filename)
            storage.repairPointer(settingOld, settingNew, metadata)