本文整理汇总了Python中DIRAC.DataManagementSystem.Client.DataIntegrityClient.DataIntegrityClient.setReplicaProblematic方法的典型用法代码示例。如果您正苦于以下问题:Python DataIntegrityClient.setReplicaProblematic方法的具体用法?Python DataIntegrityClient.setReplicaProblematic怎么用?Python DataIntegrityClient.setReplicaProblematic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.DataManagementSystem.Client.DataIntegrityClient.DataIntegrityClient
的用法示例。
在下文中一共展示了DataIntegrityClient.setReplicaProblematic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MigrationMonitoringAgent
# 需要导入模块: from DIRAC.DataManagementSystem.Client.DataIntegrityClient import DataIntegrityClient [as 别名]
# 或者: from DIRAC.DataManagementSystem.Client.DataIntegrityClient.DataIntegrityClient import setReplicaProblematic [as 别名]
#.........这里部分代码省略.........
if not res['OK']:
return res
files = res['Value']
pfnIDs = {}
if len( files.keys() ) > 0:
for fileID, metadataDict in files.items():
pfn = metadataDict['PFN']
pfnIDs[pfn] = fileID
return S_OK( {'PFNIDs':pfnIDs, 'Files':files} )
def __getCatalogFileMetadata( self, files ):
lfnFileID = {}
metadataToObtain = []
for fileID, metadata in files.items():
if not ( metadata['Size'] and metadata['Checksum'] ):
lfn = metadata['LFN']
metadataToObtain.append( lfn )
lfnFileID[lfn] = fileID
if not metadataToObtain:
return S_OK()
res = self.ReplicaManager.getCatalogFileMetadata( metadataToObtain )
if not res['OK']:
gLogger.error( "__getCatalogFileMetadata: Failed to obtain file metadata", res['Message'] )
return res
successful = res['Value']['Successful']
failed = res['Value']['Failed']
terminalIDs = []
problematicFiles = []
for lfn, error in failed.items():
gLogger.error( "__getCatalogFileMetadata: Failed to get file metadata", "%s %s" % ( lfn, error ) )
if re.search( "No such file or directory", error ):
fileID = lfnFileID[lfn]
lfn = files[fileID]['LFN']
pfn = files[fileID]['PFN']
se = files[fileID]['SE']
problematicFiles.append( lfn )
terminalIDs.append( fileID )
if terminalIDs:
self.__reportProblematicFiles( problematicFiles, 'LFNCatalogMissing' )
self.__setMigratingReplicaStatus( terminalIDs, 'Failed' )
fileMetadata = {}
for lfn, metadata in successful.items():
size = metadata['Size']
checksum = metadata['CheckSumValue']
fileMetadata[lfnFileID[lfn]] = {'Size':size, 'Checksum':checksum}
return S_OK( fileMetadata )
def __setMigratingReplicaStatus( self, fileIDs, status ):
gLogger.info( "__setMigratingReplicaStatus: Attempting to update %s files to '%s'" % ( len( fileIDs ), status ) )
res = self.MigrationMonitoringDB.setMigratingReplicaStatus( fileIDs, status )
if not res['OK']:
gLogger.info( "__setMigratingReplicaStatus: Failed to update status of files", res['Message'] )
else:
gLogger.info( "__setMigratingReplicaStatus: Successfully updated status of files" )
def __reportProblematicFiles( self, lfns, reason ):
gLogger.info( '__reportProblematicFiles: The following %s files were found with %s' % ( len( lfns ), reason ) )
for lfn in sortList( lfns ):
gLogger.info( lfn )
res = self.DataIntegrityClient.setFileProblematic( lfns, reason, sourceComponent = 'MigrationMonitoringAgent' )
if not res['OK']:
gLogger.info( '__reportProblematicFiles: Failed to update integrity DB with files', res['Message'] )
else:
gLogger.info( '__reportProblematicFiles: Successfully updated integrity DB with files' )
def __reportProblematicReplicas( self, replicaTuples ):
gLogger.info( '__reportProblematicReplicas: The following %s files being reported to integrity DB:' % ( len( replicaTuples ) ) )
for lfn, pfn, se, reason in sortList( replicaTuples ):
if lfn:
gLogger.info( lfn )
else:
gLogger.info( pfn )
res = self.DataIntegrityClient.setReplicaProblematic( replicaTuples, sourceComponent = 'MigrationMonitoringAgent' )
if not res['OK']:
gLogger.info( '__reportProblematicReplicas: Failed to update integrity DB with replicas', res['Message'] )
else:
gLogger.info( '__reportProblematicReplicas: Successfully updated integrity DB with replicas' )
def __initialiseAccountingObject( self, operation, se, startTime, endTime, size ):
accountingDict = {}
accountingDict['OperationType'] = operation
accountingDict['User'] = self.userName
accountingDict['Protocol'] = 'SRM'
accountingDict['RegistrationTime'] = 0.0
accountingDict['RegistrationOK'] = 0
accountingDict['RegistrationTotal'] = 0
accountingDict['TransferTotal'] = 1
accountingDict['TransferOK'] = 1
accountingDict['TransferSize'] = size
timeDiff = endTime - startTime
transferTime = ( timeDiff.days * 86400 ) + ( timeDiff.seconds ) + ( timeDiff.microseconds / 1000000.0 )
accountingDict['TransferTime'] = transferTime
accountingDict['FinalStatus'] = 'Successful'
accountingDict['Source'] = siteName()
accountingDict['Destination'] = se
oDataOperation = DataOperation()
oDataOperation.setEndTime( endTime )
oDataOperation.setStartTime( startTime )
oDataOperation.setValuesFromDict( accountingDict )
return oDataOperation