当前位置: 首页>>代码示例>>Python>>正文


Python DataOperation.commit方法代码示例

本文整理汇总了Python中DIRAC.AccountingSystem.Client.Types.DataOperation.DataOperation.commit方法的典型用法代码示例。如果您正苦于以下问题:Python DataOperation.commit方法的具体用法?Python DataOperation.commit怎么用?Python DataOperation.commit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.AccountingSystem.Client.Types.DataOperation.DataOperation的用法示例。


在下文中一共展示了DataOperation.commit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __sendAccounting

# 需要导入模块: from DIRAC.AccountingSystem.Client.Types.DataOperation import DataOperation [as 别名]
# 或者: from DIRAC.AccountingSystem.Client.Types.DataOperation.DataOperation import commit [as 别名]
  def __sendAccounting( ftsJob, ownerDN ):
    """ prepare and send DataOperation to AccouringDB """

    dataOp = DataOperation()
    dataOp.setStartTime( fromString( ftsJob.SubmitTime ) )
    dataOp.setEndTime( fromString( ftsJob.LastUpdate ) )

    accountingDict = dict()
    accountingDict["OperationType"] = "ReplicateAndRegister"

    username = getUsernameForDN( ownerDN )
    if not username["OK"]:
      username = ownerDN
    else:
      username = username["Value"]

    accountingDict["User"] = username
    accountingDict["Protocol"] = "FTS"

    # accountingDict['RegistrationTime'] = 0
    # accountingDict['RegistrationOK'] = 0
    # accountingDict['RegistrationTotal'] = 0

    accountingDict["TransferOK"] = len( [ f for f in ftsJob if f.Status == "Finished" ] )
    accountingDict["TransferTotal"] = len( ftsJob )
    accountingDict["TransferSize"] = ftsJob.Size
    accountingDict["FinalStatus"] = ftsJob.Status
    accountingDict["Source"] = ftsJob.SourceSE
    accountingDict["Destination"] = ftsJob.TargetSE

    dt = ftsJob.LastUpdate - ftsJob.SubmitTime
    transferTime = dt.days * 86400 + dt.seconds
    accountingDict["TransferTime"] = transferTime
    dataOp.setValuesFromDict( accountingDict )
    dataOp.commit()
开发者ID:IgorPelevanyuk,项目名称:DIRAC,代码行数:37,代码来源:FTSAgent.py

示例2: __sendAccounting

# 需要导入模块: from DIRAC.AccountingSystem.Client.Types.DataOperation import DataOperation [as 别名]
# 或者: from DIRAC.AccountingSystem.Client.Types.DataOperation.DataOperation import commit [as 别名]
  def __sendAccounting( self, regSuc, regTotal, regTime, transEndTime, transDict ):
    """ send accounting record

    :param self: self reference
    :param regSuc: number of files successfully registered
    :param regTotal: number of files attepted to register
    :param regTime: time stamp at the end of registration
    :param transEndTime: time stamp at the end of FTS job
    :param dict transDict: dict holding couters for files being transerred, their sizes and successfull transfers
    """

    submitTime = fromString( self.submitTime )
    oAccounting = DataOperation()
    dt = transEndTime - submitTime
    transferTime = dt.days * 86400 + dt.seconds
    if 'fts3' in self.ftsServer and transferTime < 0:
      import datetime
      while transferTime < 0:
        # Shift by one hour until transfer time is positive (ugly fix for FTS3 bug)
        transferTime += 3600
        submitTime -= datetime.timedelta( 0, 3600 )
      self.log.verbose( 'Fixed UTC submit time... Submit: %s, end: %s' % ( submitTime, transEndTime ) )
    oAccounting.setEndTime( transEndTime )
    oAccounting.setStartTime( submitTime )

    accountingDict = {}
    accountingDict['OperationType'] = 'replicateAndRegister'
    result = getProxyInfo()
    if not result['OK']:
      userName = 'system'
    else:
      userName = result['Value'].get( 'username', 'unknown' )
    accountingDict['User'] = userName
    accountingDict['Protocol'] = 'FTS' if 'fts3' not in self.ftsServer else 'FTS3'
    accountingDict['RegistrationTime'] = regTime
    accountingDict['RegistrationOK'] = regSuc
    accountingDict['RegistrationTotal'] = regTotal
    accountingDict['TransferOK'] = transDict['transOK']
    accountingDict['TransferTotal'] = transDict['transTotal']
    accountingDict['TransferSize'] = transDict['transSize']
    accountingDict['FinalStatus'] = self.requestStatus
    accountingDict['Source'] = self.sourceSE
    accountingDict['Destination'] = self.targetSE
    accountingDict['TransferTime'] = transferTime
    oAccounting.setValuesFromDict( accountingDict )
    self.log.verbose( "Attempting to commit accounting message..." )
    oAccounting.commit()
    self.log.verbose( "...committed." )
    return S_OK()
开发者ID:SimonBidwell,项目名称:DIRAC,代码行数:51,代码来源:FTSRequest.py

示例3: __sendAccounting

# 需要导入模块: from DIRAC.AccountingSystem.Client.Types.DataOperation import DataOperation [as 别名]
# 或者: from DIRAC.AccountingSystem.Client.Types.DataOperation.DataOperation import commit [as 别名]
 def __sendAccounting( self, regSuc, regTotal, regTime, transEndTime ):
   transSuc = 0
   transSize = 0
   missingSize = []
   for lfn in self.fileDict.keys():
     if self.fileDict[lfn].get( 'Status' ) == 'Finished':
       transSuc += 1
       if not self.catalogMetadata.has_key( lfn ):
         missingSize.append( lfn )
   if missingSize:
     self.__updateMetadataCache( missingSize )
   for lfn in self.fileDict.keys():
     if self.fileDict[lfn].get( 'Status' ) == 'Finished':
       transSize += self.catalogMetadata[lfn]['Size']
   transTotal = 0
   for state in ( self.statusSummary.keys() ):
     transTotal += self.statusSummary[state]
   submitTime = fromString( self.submitTime )
   endTime = fromString( transEndTime )
   oAccounting = DataOperation()
   #oAccounting.setEndTime(endTime)
   oAccounting.setEndTime( transEndTime )
   oAccounting.setStartTime( submitTime )
   accountingDict = {}
   accountingDict['OperationType'] = 'replicateAndRegister'
   accountingDict['User'] = 'acsmith'
   accountingDict['Protocol'] = 'FTS'
   accountingDict['RegistrationTime'] = regTime
   accountingDict['RegistrationOK'] = regSuc
   accountingDict['RegistrationTotal'] = regTotal
   accountingDict['TransferOK'] = transSuc
   accountingDict['TransferTotal'] = transTotal
   accountingDict['TransferSize'] = transSize
   accountingDict['FinalStatus'] = self.requestStatus
   accountingDict['Source'] = self.sourceSE
   accountingDict['Destination'] = self.targetSE
   c = transEndTime - submitTime
   transferTime = c.days * 86400 + c.seconds
   accountingDict['TransferTime'] = transferTime
   oAccounting.setValuesFromDict( accountingDict )
   gLogger.verbose( "Attempting to commit accounting message..." )
   oAccounting.commit()
   gLogger.verbose( "...committed." )
   return S_OK()
开发者ID:caitriana,项目名称:DIRAC,代码行数:46,代码来源:FTSRequest.py

示例4: __sendAccounting

# 需要导入模块: from DIRAC.AccountingSystem.Client.Types.DataOperation import DataOperation [as 别名]
# 或者: from DIRAC.AccountingSystem.Client.Types.DataOperation.DataOperation import commit [as 别名]
  def __sendAccounting( self, regSuc, regTotal, regTime, transEndTime, transDict ):
    """ send accounting record

    :param self: self reference
    :param regSuc: number of files successfully registered
    :param regTotal: number of files attepted to register
    :param regTime: time stamp at the end of registration
    :param transEndTime: time stamp at the end of FTS job
    :param dict transDict: dict holding couters for files being transerred, their sizes and successfull transfers
    """

    oAccounting = DataOperation()
    oAccounting.setEndTime( transEndTime )
    oAccounting.setStartTime( self.submitTime )

    accountingDict = {}
    accountingDict['OperationType'] = 'replicateAndRegister'
    result = getProxyInfo()
    if not result['OK']:
      userName = 'system'
    else:
      userName = result['Value'].get( 'username', 'unknown' )
    accountingDict['User'] = userName
    accountingDict['Protocol'] = 'FTS' if 'fts3' not in self.ftsServer else 'FTS3'
    accountingDict['RegistrationTime'] = regTime
    accountingDict['RegistrationOK'] = regSuc
    accountingDict['RegistrationTotal'] = regTotal
    accountingDict['TransferOK'] = transDict['transOK']
    accountingDict['TransferTotal'] = transDict['transTotal']
    accountingDict['TransferSize'] = transDict['transSize']
    accountingDict['FinalStatus'] = self.requestStatus
    accountingDict['Source'] = self.sourceSE
    accountingDict['Destination'] = self.targetSE
    accountingDict['TransferTime'] = self.transferTime
    oAccounting.setValuesFromDict( accountingDict )
    self.log.verbose( "Attempting to commit accounting message..." )
    oAccounting.commit()
    self.log.verbose( "...committed." )
    return S_OK()
开发者ID:Teddy22,项目名称:DIRAC,代码行数:41,代码来源:FTSRequest.py

示例5: __sendAccounting

# 需要导入模块: from DIRAC.AccountingSystem.Client.Types.DataOperation import DataOperation [as 别名]
# 或者: from DIRAC.AccountingSystem.Client.Types.DataOperation.DataOperation import commit [as 别名]
  def __sendAccounting( ftsJob, ownerDN ):
    """ prepare and send DataOperation to AccouringDB """

    dataOp = DataOperation()
    dataOp.setStartTime( fromString( ftsJob.SubmitTime ) )
    dataOp.setEndTime( fromString( ftsJob.LastUpdate ) )

    accountingDict = dict()
    accountingDict["OperationType"] = "ReplicateAndRegister"

    username = getUsernameForDN( ownerDN )
    if not username["OK"]:
      username = ownerDN
    else:
      username = username["Value"]

    accountingDict["User"] = username
    accountingDict["Protocol"] = "FTS3" if 'fts3' in ftsJob.FTSServer.lower() else 'FTS'
    accountingDict['ExecutionSite'] = ftsJob.FTSServer

    accountingDict['RegistrationTime'] = ftsJob._regTime
    accountingDict['RegistrationOK'] = ftsJob._regSuccess
    accountingDict['RegistrationTotal'] = ftsJob._regTotal

    accountingDict["TransferOK"] = len( [ f for f in ftsJob if f.Status in FTSFile.SUCCESS_STATES ] )
    accountingDict["TransferTotal"] = len( ftsJob )
    accountingDict["TransferSize"] = ftsJob.Size - ftsJob.FailedSize
    accountingDict["FinalStatus"] = ftsJob.Status
    accountingDict["Source"] = ftsJob.SourceSE
    accountingDict["Destination"] = ftsJob.TargetSE

    # dt = ftsJob.LastUpdate - ftsJob.SubmitTime
    # transferTime = dt.days * 86400 + dt.seconds
    # accountingDict["TransferTime"] = transferTime
    accountingDict['TransferTime'] = sum( [int( f._duration ) for f in ftsJob if f.Status in FTSFile.SUCCESS_STATES ] )
    dataOp.setValuesFromDict( accountingDict )
    dataOp.commit()
开发者ID:JanEbbing,项目名称:DIRAC,代码行数:39,代码来源:FTSAgent.py

示例6: __sendAccounting

# 需要导入模块: from DIRAC.AccountingSystem.Client.Types.DataOperation import DataOperation [as 别名]
# 或者: from DIRAC.AccountingSystem.Client.Types.DataOperation.DataOperation import commit [as 别名]
  def __sendAccounting( self, regSuc, regTotal, regTime, transEndTime, transDict ):
    """ send accounting record

    :param self: self reference
    :param regSuc: number of files successfully registered
    :param regTotal: number of files attepted to register 
    :param regTime: time stamp at the end of registration 
    :param transEndTime: time stamp at the end of FTS job
    :param dict transDict: dict holding couters for files being transerred, their sizes and successfull transfers 
    """

    submitTime = fromString( self.submitTime )
    oAccounting = DataOperation()
    oAccounting.setEndTime( transEndTime )
    oAccounting.setStartTime( submitTime )

    accountingDict = {}
    accountingDict['OperationType'] = 'replicateAndRegister'
    accountingDict['User'] = 'acsmith'
    accountingDict['Protocol'] = 'FTS'
    accountingDict['RegistrationTime'] = regTime
    accountingDict['RegistrationOK'] = regSuc
    accountingDict['RegistrationTotal'] = regTotal
    accountingDict['TransferOK'] = transDict['transOK']
    accountingDict['TransferTotal'] = transDict['transTotal']
    accountingDict['TransferSize'] = transDict['transSize']
    accountingDict['FinalStatus'] = self.requestStatus
    accountingDict['Source'] = self.sourceSE
    accountingDict['Destination'] = self.targetSE
    dt = transEndTime - submitTime
    transferTime = dt.days * 86400 + dt.seconds
    accountingDict['TransferTime'] = transferTime
    oAccounting.setValuesFromDict( accountingDict )
    self.log.verbose( "Attempting to commit accounting message..." )
    oAccounting.commit()
    self.log.verbose( "...committed." )
    return S_OK()
开发者ID:msapunov,项目名称:DIRAC,代码行数:39,代码来源:FTSRequest.py


注:本文中的DIRAC.AccountingSystem.Client.Types.DataOperation.DataOperation.commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。