本文整理汇总了Python中WMComponent.DBS3Buffer.DBSBufferUtil.DBSBufferUtil.setBlockFiles方法的典型用法代码示例。如果您正苦于以下问题:Python DBSBufferUtil.setBlockFiles方法的具体用法?Python DBSBufferUtil.setBlockFiles怎么用?Python DBSBufferUtil.setBlockFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMComponent.DBS3Buffer.DBSBufferUtil.DBSBufferUtil
的用法示例。
在下文中一共展示了DBSBufferUtil.setBlockFiles方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testDualUpload
# 需要导入模块: from WMComponent.DBS3Buffer.DBSBufferUtil import DBSBufferUtil [as 别名]
# 或者: from WMComponent.DBS3Buffer.DBSBufferUtil.DBSBufferUtil import setBlockFiles [as 别名]
def testDualUpload(self):
"""
_testDualUpload_
Verify that the dual upload mode works correctly.
"""
self.dbsApi = DbsApi(url = self.dbsUrl)
config = self.getConfig(dbs3UploadOnly = True)
dbsUploader = DBSUploadPoller(config = config)
dbsUtil = DBSBufferUtil()
# First test verifies that uploader will poll and then not do anything
# as the database is empty.
dbsUploader.algorithm()
acqEra = "Summer%s" % (int(time.time()))
parentFiles = self.createParentFiles(acqEra)
(moreParentFiles, childFiles) = \
self.createFilesWithChildren(parentFiles, acqEra)
allFiles = parentFiles + moreParentFiles
allBlocks = []
for i in range(4):
blockName = parentFiles[0]["datasetPath"] + "#" + makeUUID()
dbsBlock = DBSBlock(blockName, "malpaquet", 1)
dbsBlock.status = "Open"
dbsUtil.createBlocks([dbsBlock])
for file in allFiles[i * 5 : (i * 5) + 5]:
dbsBlock.addFile(file)
dbsUtil.setBlockFiles({"block": blockName, "filelfn": file["lfn"]})
if i < 2:
dbsBlock.status = "InDBS"
dbsUtil.updateBlocks([dbsBlock])
dbsUtil.updateFileStatus([dbsBlock], "InDBS")
allBlocks.append(dbsBlock)
blockName = childFiles[0]["datasetPath"] + "#" + makeUUID()
dbsBlock = DBSBlock(blockName, "malpaquet", 1)
dbsBlock.status = "InDBS"
dbsUtil.createBlocks([dbsBlock])
for file in childFiles:
dbsBlock.addFile(file)
dbsUtil.setBlockFiles({"block": blockName, "filelfn": file["lfn"]})
dbsUtil.updateFileStatus([dbsBlock], "InDBS")
dbsUploader.algorithm()
time.sleep(5)
dbsUploader.algorithm()
time.sleep(5)
self.verifyData(parentFiles[0]["datasetPath"], parentFiles)
# Change the status of the rest of the parent blocks so we can upload
# them and the children.
for dbsBlock in allBlocks:
dbsBlock.status = "InDBS"
dbsUtil.updateBlocks([dbsBlock])
dbsUploader.algorithm()
time.sleep(5)
self.verifyData(parentFiles[0]["datasetPath"], parentFiles + moreParentFiles)
# Run the uploader one more time to upload the children.
dbsUploader.algorithm()
time.sleep(5)
self.verifyData(childFiles[0]["datasetPath"], childFiles)
return
示例2: DBSUploadPoller
# 需要导入模块: from WMComponent.DBS3Buffer.DBSBufferUtil import DBSBufferUtil [as 别名]
# 或者: from WMComponent.DBS3Buffer.DBSBufferUtil.DBSBufferUtil import setBlockFiles [as 别名]
#.........这里部分代码省略.........
# New block that needs to be added to DBSBuffer.
createInDBSBuffer.append(block)
# Build the pool if it was closed
if len(self.pool) == 0:
self.setupPool()
# First handle new and updated blocks
try:
myThread.transaction.begin()
self.dbsUtil.createBlocks(blocks = createInDBSBuffer)
self.dbsUtil.updateBlocks(blocks = updateInDBSBuffer)
myThread.transaction.commit()
except WMException:
myThread.transaction.rollback()
raise
except Exception as ex:
msg = "Unhandled exception while writing new blocks into DBSBuffer\n"
msg += str(ex)
logging.error(msg)
logging.debug("Blocks for DBSBuffer: %s\n" % createInDBSBuffer)
logging.debug("Blocks for Update: %s\n" % updateInDBSBuffer)
myThread.transaction.rollback()
raise DBSUploadException(msg)
# Update block status in the block cache. Mark the blocks that we have
# added to DBSBuffer as being in DBSBuffer.
for block in createInDBSBuffer:
self.blockCache.get(block.getName()).inBuff = True
# Record new file/block associations in DBSBuffer.
try:
myThread.transaction.begin()
self.dbsUtil.setBlockFiles(binds = self.filesToUpdate)
self.filesToUpdate = []
myThread.transaction.commit()
except WMException:
myThread.transaction.rollback()
raise
except Exception as ex:
msg = "Unhandled exception while setting blocks in files.\n"
msg += str(ex)
logging.error(msg)
logging.debug("Files to Update: %s\n" % self.filesToUpdate)
myThread.transaction.rollback()
raise DBSUploadException(msg)
# Finally upload blocks to DBS.
for block in createInDBS:
if len(block.files) < 1:
# What are we doing?
logging.debug("Skipping empty block")
continue
if block.getDataset() == None:
# Then we have to fix the dataset
dbsFile = block.files[0]
block.setDataset(datasetName = dbsFile['datasetPath'],
primaryType = self.primaryDatasetType,
datasetType = self.datasetType,
physicsGroup = dbsFile.get('physicsGroup', None),
prep_id = dbsFile.get('prep_id', None))
logging.debug("Found block %s in blocks" % block.getName())
block.setPhysicsGroup(group = self.physicsGroup)
encodedBlock = block.convertToDBSBlock()
logging.info("About to insert block %s" % block.getName())