def initializeHandler(cls, serviceInfo): multiPath = PathFinder.getDatabaseSection("Accounting/MultiDB") cls.__acDB = MultiAccountingDB(multiPath, readOnly=True) # Get data location reportSection = serviceInfo["serviceSectionPath"] dataPath = gConfig.getValue("%s/DataLocation" % reportSection, "data/accountingGraphs") dataPath = dataPath.strip() if "/" != dataPath[0]: dataPath = os.path.realpath("%s/%s" % (gConfig.getValue( "/LocalSite/InstancePath", rootPath), dataPath)) gLogger.info("Data will be written into %s" % dataPath) mkDir(dataPath) try: testFile = "%s/acc.jarl.test" % dataPath with open(testFile, "w"): pass os.unlink(testFile) except IOError: gLogger.fatal("Can't write to %s" % dataPath) return S_ERROR("Data location is not writable") gDataCache.setGraphsLocation(dataPath) gMonitor.registerActivity("plotsDrawn", "Drawn plot images", "Accounting reports", "plots", gMonitor.OP_SUM) gMonitor.registerActivity("reportsRequested", "Generated reports", "Accounting reports", "reports", gMonitor.OP_SUM) return S_OK()
def initializeHandler( cls, serviceInfo ): multiPath = PathFinder.getDatabaseSection( "Accounting/MultiDB" ) cls.__acDB = MultiAccountingDB( multiPath, readOnly = True ) #Get data location reportSection = serviceInfo[ 'serviceSectionPath' ] dataPath = gConfig.getValue( "%s/DataLocation" % reportSection, "data/accountingGraphs" ) dataPath = dataPath.strip() if "/" != dataPath[0]: dataPath = os.path.realpath( "%s/%s" % ( gConfig.getValue( '/LocalSite/InstancePath', rootPath ), dataPath ) ) gLogger.info( "Data will be written into %s" % dataPath ) try: os.makedirs( dataPath ) except: pass try: testFile = "%s/acc.jarl.test" % dataPath fd = file( testFile, "w" ) fd.close() os.unlink( testFile ) except IOError: gLogger.fatal( "Can't write to %s" % dataPath ) return S_ERROR( "Data location is not writable" ) gDataCache.setGraphsLocation( dataPath ) gMonitor.registerActivity( "plotsDrawn", "Drawn plot images", "Accounting reports", "plots", gMonitor.OP_SUM ) gMonitor.registerActivity( "reportsRequested", "Generated reports", "Accounting reports", "reports", gMonitor.OP_SUM ) return S_OK()
def initializeHandler( cls, svcInfoDict ): multiPath = PathFinder.getDatabaseSection( "Accounting/MultiDB" ) cls.__acDB = MultiAccountingDB( multiPath ) cls.__acDB.autoCompactDB() result = cls.__acDB.markAllPendingRecordsAsNotTaken() if not result[ 'OK' ]: return result gThreadScheduler.addPeriodicTask( 60, cls.__acDB.loadPendingRecords ) return S_OK()
def initializeHandler(cls, svcInfoDict): multiPath = PathFinder.getDatabaseSection("Accounting/MultiDB") cls.__acDB = MultiAccountingDB(multiPath) # we can run multiple services in read only mode. In that case we do not bucket cls.runBucketing = getServiceOption(svcInfoDict, "RunBucketing", True) if cls.runBucketing: cls.__acDB.autoCompactDB() # pylint: disable=no-member result = cls.__acDB.markAllPendingRecordsAsNotTaken() # pylint: disable=no-member if not result["OK"]: return result gThreadScheduler.addPeriodicTask(60, cls.__acDB.loadPendingRecords) # pylint: disable=no-member return S_OK()
def initializeHandler( cls, svcInfoDict ): multiPath = PathFinder.getDatabaseSection( "Accounting/MultiDB" ) cls.__acDB = MultiAccountingDB( multiPath ) #we can run multiple services in read only mode. In that case we do not bucket cls.runBucketing = getServiceOption( svcInfoDict, 'RunBucketing', True ) if cls.runBucketing: cls.__acDB.autoCompactDB() #pylint: disable=no-member result = cls.__acDB.markAllPendingRecordsAsNotTaken() #pylint: disable=no-member if not result[ 'OK' ]: return result gThreadScheduler.addPeriodicTask( 60, cls.__acDB.loadPendingRecords ) #pylint: disable=no-member return S_OK()
def initializeHandler(cls, serviceInfo): multiPath = PathFinder.getDatabaseSection("Accounting/MultiDB") cls.__acDB = MultiAccountingDB(multiPath, readOnly=True) # Get data location reportSection = serviceInfo["serviceSectionPath"] dataPath = gConfig.getValue("%s/DataLocation" % reportSection, "data/accountingGraphs") dataPath = dataPath.strip() if "/" != dataPath[0]: dataPath = os.path.realpath(f"{rootPath}/{dataPath}") gLogger.info(f"Data will be written into {dataPath}") mkDir(dataPath) try: testFile = "%s/acc.jarl.test" % dataPath with open(testFile, "w"): pass os.unlink(testFile) except IOError: gLogger.fatal("Can't write to %s" % dataPath) return S_ERROR("Data location is not writable") gDataCache.setGraphsLocation(dataPath) return S_OK()