def shutdown(): # Shutdown method for all repgistries in order from Ganga.Utility.logging import getLogger logger = getLogger() logger.info('Registry Shutdown') #import traceback #traceback.print_stack() # Flush all repos before we shut them down flush_all() # shutting down the prep registry (i.e. shareref table) first is necessary to allow the closedown() # method to perform actions on the box and/or job registries. logger.debug(started_registries) all_registries = getRegistries() try: if 'prep' in started_registries: registry = getRegistry('prep') registry.shutdown() # in case this is called repeatedly, only call shutdown once started_registries.remove(registry.name) except Exception as err: logger.error("Err: %s" % err) logger.error("Failed to Shutdown prep Repository!!! please check for stale lock files") logger.error("Trying to shutdown cleanly regardless") for registry in getRegistries(): thisName = registry.name try: if not thisName in started_registries: continue # in case this is called repeatedly, only call shutdown once started_registries.remove(thisName) registry.shutdown() # flush and release locks except Exception as x: logger.error("Failed to Shutdown Repository: %s !!! please check for stale lock files" % thisName) logger.error("%s" % x) logger.error("Trying to Shutdown cleanly regardless") for registry in all_registries: my_reg = [registry] if hasattr(registry, 'metadata'): if registry.metadata: my_reg.append(registry.metadata) assigned_attrs = ['location', 'type'] for this_reg in my_reg: for attr in assigned_attrs: if hasattr(registry, attr): delattr(registry, attr) from Ganga.Core.GangaRepository.SessionLock import removeGlobalSessionFiles, removeGlobalSessionFileHandlers removeGlobalSessionFileHandlers() removeGlobalSessionFiles() removeRegistries()
def updateLocksNow(): # Update all of the file locks for the registries logger.debug("Updating timestamp of Lock files") for registry in getRegistries(): registry.updateLocksNow() return
def bootstrap(): oldJobs = getOldJobs() retval = [] for registry in getRegistries(): if registry.name in started_registries: continue registry.type = config["repositorytype"] registry.location = getLocalRoot() registry.startup() logger.debug("started " + registry.info(full=False)) if registry.name == "prep": registry.print_other_sessions() started_registries.append(registry.name) retval.append((registry.name, registry.getProxy(), registry.doc)) if registry.name in oldJobs: for j in oldJobs[registry.name]: j._index_cache = None if not j.id in registry: registry._add(j, force_index = j.id) else: logger.warning("Import Collision at id %i, appending job to the end...", j.id) registry._add(j) import atexit atexit.register(shutdown) logger.debug(started_registries) return retval
def shutdown(): logger.debug("registry shutdown") # shutting down the prep registry (i.e. shareref table) first is necessary to allow the closedown() # method to perform actions on the box and/or job registries. logger.debug(started_registries) try: if "prep" in started_registries: registry = getRegistry("prep") registry.shutdown() # in case this is called repeatedly, only call shutdown once started_registries.remove(registry.name) except: logger.error("Failed to Shutdown prep Repository!!! please check for stale lock files") logger.error("Trying to shutdown cleanly regardless") pass for registry in getRegistries(): thisName = registry.name try: if not thisName in started_registries: continue # in case this is called repeatedly, only call shutdown once started_registries.remove(thisName) registry.shutdown() # flush and release locks except Exception as x: logger.error("Failed to Shutdown Repository: %s !!! please check for stale lock files" % thisName) logger.error("%s" % str(x)) logger.error("Trying to Shutdown cleanly regardless") pass from Ganga.Core.GangaRepository.SessionLock import removeGlobalSessionFiles, removeGlobalSessionFileHandlers removeGlobalSessionFileHandlers() removeGlobalSessionFiles()
def bootstrap_getreg(): # Get the list of registries sorted in the bootstrap way # ALEX added this as need to ensure that prep registry is started up BEFORE job or template # or even named templated registries as the _auto__init from job will require the prep registry to # already be ready. This showed up when adding the named templates. def prep_filter(x, y): if x.name == 'prep': return -1 return 1 return [registry for registry in sorted(getRegistries(), prep_filter)]
def flush_all(): from Ganga.Utility.logging import getLogger logger = getLogger() logger.debug("Flushing All repositories") for registry in getRegistries(): thisName = registry.name try: logger.debug("Flushing: %s" % thisName) registry._flush() except Exception as err: logger.debug("Failed to flush: %s" % str(thisName)) logger.debug("Err: %s" % str(err))
def flush_all(): from Ganga.Utility.logging import getLogger logger = getLogger() logger.debug("Flushing All repositories") for registry in getRegistries(): thisName = registry.name try: if registry.hasStarted() is True: logger.debug("Flushing: %s" % thisName) registry._flush() except Exception as err: logger.debug("Failed to flush: %s" % str(thisName)) logger.debug("Err: %s" % str(err))
def shutdown(): logger.debug('registry shutdown') #shutting down the prep registry (i.e. shareref table) first is necessary to allow the closedown() #method to perform actions on the box and/or job registries. logger.debug(started_registries) if 'prep' in started_registries: registry = getRegistry('prep') registry.shutdown() started_registries.remove(registry.name) # in case this is called repeatedly, only call shutdown once for registry in getRegistries(): if not registry.name in started_registries: continue started_registries.remove(registry.name) # in case this is called repeatedly, only call shutdown once registry.shutdown() # flush and release locks
def flush_all(): # Flush all registries in their current state with all dirty knowledge going to disk from Ganga.Utility.logging import getLogger logger = getLogger() logger.debug("Flushing All repositories") for registry in getRegistries(): thisName = registry.name try: if registry.hasStarted() is True: logger.debug("Flushing: %s" % thisName) registry.flush_all() except Exception as err: logger.debug("Failed to flush: %s" % thisName) logger.debug("Err: %s" % err)
def bootstrap(): retval = [] try: checkDiskQuota() except GangaException as err: raise err except Exception as err: logger.error("Disk quota check failed due to: %s" % str(err)) # ALEX added this as need to ensure that prep registry is started up BEFORE job or template # or even named templated registries as the _auto__init from job will require the prep registry to # already be ready. This showed up when adding the named templates. def prep_filter(x, y): if x.name == 'prep': return -1 return 1 for registry in sorted(getRegistries(), prep_filter): if registry.name in started_registries: continue if not hasattr(registry, 'type'): registry.type = config["repositorytype"] if not hasattr(registry, 'location'): registry.location = getLocalRoot() registry.startup() logger.debug("started " + registry.info(full=False)) if registry.name == "prep": registry.print_other_sessions() started_registries.append(registry.name) retval.append((registry.name, registry.getProxy(), registry.doc)) #import atexit #atexit.register(shutdown) #logger.debug("Registries: %s" % str(started_registries)) return retval
def shutdown(): from Ganga.Utility.logging import getLogger logger = getLogger() logger.info('Registry Shutdown') #import traceback #traceback.print_stack() # shutting down the prep registry (i.e. shareref table) first is necessary to allow the closedown() # method to perform actions on the box and/or job registries. logger.debug(started_registries) try: if 'prep' in started_registries: registry = getRegistry('prep') registry.shutdown() # in case this is called repeatedly, only call shutdown once started_registries.remove(registry.name) except Exception as err: logger.debug("Err: %s" % str(err)) logger.error("Failed to Shutdown prep Repository!!! please check for stale lock files") logger.error("Trying to shutdown cleanly regardless") for registry in getRegistries(): thisName = registry.name try: if not thisName in started_registries: continue # in case this is called repeatedly, only call shutdown once started_registries.remove(thisName) registry.shutdown() # flush and release locks except Exception as x: logger.error("Failed to Shutdown Repository: %s !!! please check for stale lock files" % thisName) logger.error("%s" % str(x)) logger.error("Trying to Shutdown cleanly regardless") from Ganga.Core.GangaRepository.SessionLock import removeGlobalSessionFiles, removeGlobalSessionFileHandlers removeGlobalSessionFileHandlers() removeGlobalSessionFiles()
def updateLocksNow(): logger.debug("Updating timestamp of Lock files") for registry in getRegistries(): registry.updateLocksNow() return
def shutdown(): # Shutdown method for all repgistries in order from Ganga.Utility.logging import getLogger logger = getLogger() logger.info('Registry Shutdown') #import traceback #traceback.print_stack() # Flush all repos before we shut them down flush_all() # shutting down the prep registry (i.e. shareref table) first is necessary to allow the closedown() # method to perform actions on the box and/or job registries. logger.debug(started_registries) all_registries = getRegistries() try: if 'prep' in started_registries: registry = getRegistry('prep') registry.shutdown() # in case this is called repeatedly, only call shutdown once started_registries.remove(registry.name) except Exception as err: logger.error("Err: %s" % err) logger.error( "Failed to Shutdown prep Repository!!! please check for stale lock files" ) logger.error("Trying to shutdown cleanly regardless") for registry in getRegistries(): thisName = registry.name try: if not thisName in started_registries: continue # in case this is called repeatedly, only call shutdown once started_registries.remove(thisName) registry.shutdown() # flush and release locks except Exception as x: logger.error( "Failed to Shutdown Repository: %s !!! please check for stale lock files" % thisName) logger.error("%s" % x) logger.error("Trying to Shutdown cleanly regardless") for registry in all_registries: my_reg = [registry] if hasattr(registry, 'metadata'): if registry.metadata: my_reg.append(registry.metadata) assigned_attrs = ['location', 'type'] for this_reg in my_reg: for attr in assigned_attrs: if hasattr(registry, attr): delattr(registry, attr) from Ganga.Core.GangaRepository.SessionLock import removeGlobalSessionFiles, removeGlobalSessionFileHandlers removeGlobalSessionFileHandlers() removeGlobalSessionFiles() removeRegistries()
retval = [] try: checkDiskQuota() except Exception, err: logger.error("Disk quota check failed due to: %s" % str(err)) # ALEX added this as need to ensure that prep registry is started up BEFORE job or template # or even named templated registries as the _auto__init from job will require the prep registry to # already be ready. This showed up when adding the named templates. def prep_filter(x, y): if x.name == "prep": return -1 return 1 for registry in sorted(getRegistries(), prep_filter): if registry.name in started_registries: continue if not hasattr(registry, "type"): registry.type = config["repositorytype"] if not hasattr(registry, "location"): registry.location = getLocalRoot() registry.startup() logger.debug("started " + registry.info(full=False)) if registry.name == "prep": registry.print_other_sessions() started_registries.append(registry.name) retval.append((registry.name, registry.getProxy(), registry.doc)) import atexit