def __init__(self): # Replace the objects attributes with the original # attributes and data. self.__dict__ = DataStore._shared_state # Make sure that the DataStore object is only initialized once. if not DataStore._initialized: # Allocate a lock that will be used by all threads # that are reading or writing to the data store. self.lock = thread.allocate_lock() self.lock.acquire() self.rootElement = None # Initialize the data store with the GANGLIA_XML and GRID tags. # Data store should never be completely empty. Even if there are # no reporting data sources the web front end depends on having # at least a GANGLIA_XML tag and a nested GRID tag. cfg = getConfig() self.setNode(Element('GANGLIA_XML', {'VERSION':cfg.VERSION, 'SOURCE':'gmetad'})) self.setNode(Element('GRID', {'NAME':cfg[GmetadConfig.GRIDNAME], 'AUTHORITY':cfg[GmetadConfig.AUTHORITY], 'LOCALTIME':'%d' % time.time()}), self.rootElement) self.lock.release() # Start up the grid summary thread. self.gridSummary = DataStoreGridSummary() self.gridSummary.start() # Start up the plugin notifier. self.notifier = GmetadNotifier() self.notifier.start() DataStore._initialized = True