コード例 #1
0
 def findMasterCfg(self, find_checksum):
     value, stat = self.szk.zk.get(szk.MASTER_CONFIG_NODE)
     checksum = utils.getChecksum(value)
     if checksum == find_checksum:
         return value
     value, stat = self.szk.zk.get(szk.MASTER_DEBUG_CONFIG_NODE)
     checksum = utils.getChecksum(value)
     if checksum == find_checksum:
         return value
     value, stat = self.szk.zk.get(szk.MASTER_ANALYSIS_CONFIG_NODE)
     checksum = utils.getChecksum(value)
     if checksum == find_checksum:
         return value
     value, stat = self.szk.zk.get(szk.MASTER_POV_CONFIG_NODE)
     checksum = utils.getChecksum(value)
     if checksum == find_checksum:
         return value
     try:
         value, stat = self.szk.zk.get(szk.MASTER_MSC_CONFIG_NODE)
         checksum = utils.getChecksum(value)
         if checksum == find_checksum:
             return value
     except kazoo.exceptions.NoNodeError:
         print('no msc config node')
     return None
コード例 #2
0
ファイル: packageMgr.py プロジェクト: wyu0hop/cgc-monitor
    def checkConfig(self, event=None, config_name='master'):
        monitor_config, timestamp = self.szk.getOurChecksum(self.lgr)
        config_node, dum = self.szk.nodeFromConfigName(config_name)
        if self.checksum is None:
            value, stat = self.szk.zk.get(config_node) 
            checksum = utils.getChecksum(value)
            self.lgr.debug('checkConfig got config from master configuration "%s" node, checksum is %s' % (config_name, checksum))
            #print('checkConfig got config from zk node, checksum is %s' % checksum)
        else:
            checksum = self.checksum
            self.lgr.debug('checkConfig got config from dequeued package, checksum is %s' % checksum)
            print('checkConfig got config from dequeued package, checksum is %s' % checksum)

        if monitor_config != checksum:
            print('checkConfig configurations do not match current: %s monitor started with: %s, reInit cgcMonitor and try again' % \
                 (checksum, monitor_config))
            self.lgr.debug('checkConfig configurations do not match current: %s  monitor started with: %s, reInit cgcMonitor and try again' % \
                          (checksum, monitor_config))
            success = self.szk.deleteOurReset()
            if not success:
                self.lgr.debug('checkConfig found reset node already deleted %d' % success)
            done = False
            count = 0
            while not done:
                monitor_config = None
                while monitor_config == None:
                    self.lgr.debug('checkConfig wait one second and try again to get master config')
                    time.sleep(1)
                    monitor_config, timestamp = self.szk.getOurChecksum(self.lgr)
                if self.checksum is None:
                    value, stat = self.szk.zk.get(config_node) 
                    checksum = utils.getChecksum(value)
                else:
                    checksum = self.checksum
                done = True
                if monitor_config != checksum:
                    print('checkConfig failed after attempt to reInit cgcMonitor')
                    self.lgr.debug('checkConfig failed after attempt to reInit cgcMonitor')
                    done = False
                    if count > 3:
                        self.lgr.error('checkConfig failed after 3 attempts to reInit cgcMonitor we see %s cgcMonitor reports %s' % (checksum, monitor_config))
                        self.hungSoDie()
                    else:
                        self.lgr.debug('checkConfig, wait three and try again.  count now %d' % count)
                        time.sleep(3)
                        count += 1
        self.checksum = checksum
        ''' tell the getMonitor we only want replays having this checksum '''
        #self.lgr.debug('checkConfig update getMonitor with new checksum %s' % checksum)
        self.gm.setChecksum(checksum)
コード例 #3
0
ファイル: packageMgr.py プロジェクト: wyu0hop/cgc-monitor
    def alternateConfig(self, checksum):
        '''
        If the given checksum is not what the is in the master config node, define an alternate
        Returns true if an alternate was defined
        '''
        retval = False
        value, stat = self.szk.zk.get(szk.MASTER_CONFIG_NODE) 
        master_config = utils.getChecksum(value)
        self.lgr.debug('alternateConfig given checksum is %s, the checksum from the MASTER_CONFIG_NODE zk node is %s' % (checksum, master_config))
        if master_config != checksum:
            retval = True
            self.checksum = checksum

            monitor_config, timestamp = self.szk.getOurChecksum(self.lgr)
            if checksum != monitor_config:
                self.lgr.debug('alternateConfig, need to define alternate config node for given %s, master config was %s' % (checksum, master_config))
                #sql = accessSQL.accessSQL(self.cfg.db_name, self.lgr)
                #config = sql.getConfig(checksum)      
                config = self.umc.findMasterCfg(checksum)
                if config is None or len(config) < 10:
                    self.lgr.debug('packageMgr, alternateConfig, Could not get config for checksum %s, leftover dbgQueue entry?' % checksum)
                    return False
                config = self.editConfig(config)
                self.szk.putAlternateConfig(config)
                #sql.close()
            else:
                self.lgr.debug('alternateConfig, monitor started with what would have been the alternate, do not create alternate node')
        else:
            self.lgr.debug('alternateConfig, given checksum matches that in MASTER_CONFIG_NODE')
        return retval
コード例 #4
0
ファイル: packageMgr.py プロジェクト: wyu0hop/cgc-monitor
 def editConfig(self, config):
     debug_cb = self.root.find('debug_cb')
     if debug_cb is not None:
         self.lgr.debug('editConfig, debug_cb, set, change setting in config')
         config = config.replace('debug_cb=no', 'debug_cb=yes')
         self.checksum = utils.getChecksum(config)
         if 'debug_cb=yes' not in config:
             self.lgr.error('debug_cb not set in %s' % config)
     else:
         debug_pov = self.root.find('debug_pov')
         if debug_pov is not None:
             self.lgr.debug('editConfig, debug_pov, set, change setting in config')
             config = config.replace('debug_cb=no', 'debug_cb=no\ndebug_pov=yes')
             self.checksum = utils.getChecksum(config)
             if 'debug_pov=yes' not in config:
                 self.lgr.error('debug_pov not set in %s' % config)
         else: 
             self.lgr.debug('debug_cb and debug_pov, NOT SET')
             pass
     return config
コード例 #5
0
 def getChecksum(self, node):
     '''
     get the master config checksum  for the given node
     '''
     value = None
     if node == szk.MASTER_CONFIG_NODE:
         value, stat = self.szk.zk.get(szk.MASTER_CONFIG_NODE)
     elif node == szk.MASTER_DEBUG_CONFIG_NODE:
         value, stat = self.szk.zk.get(szk.MASTER_DEBUG_CONFIG_NODE)
     elif node == szk.MASTER_ANALYSIS_CONFIG_NODE:
         value, stat = self.szk.zk.get(szk.MASTER_ANALYSIS_CONFIG_NODE)
     elif node == szk.MASTER_MSC_CONFIG_NODE:
         value, stat = self.szk.zk.get(szk.MASTER_MSC_CONFIG_NODE)
     elif node == szk.MASTER_POV_CONFIG_NODE:
         value, stat = self.szk.zk.get(szk.MASTER_POV_CONFIG_NODE)
     else:
         return None
     checksum = utils.getChecksum(value)
     return checksum
コード例 #6
0
    def updateMasterCfg(self, node, config):
        '''
        Write a given master configuration to the named master config node, creating it if needed
        This is intended for use by putMonitor and related tools to reflect the desired
        configuration via which the packages should be processed.
        '''
        try:
            self.szk.zk.create(node, config)
        except kazoo.exceptions.NodeExistsError:
            pass
        except kazoo.exceptions.NoNodeError:
            print 'updateMasterCfg error creating node at %s, missing node in path, exiting' % path
            raise kazoo.exceptions.NoNodeError
        self.szk.zk.set(node, config)

        self.recordMasterCfg(node)

        retval = utils.getChecksum(config)
        print('in updateMasterCfg for node: %s,  checksum is %s' %
              (node, retval))
        return retval
コード例 #7
0
 def recordMasterCfg(self, node):
     '''
     Record the master config and its checksum in the sql database
     '''
     sql = accessSQL.accessSQL(self.cfg.db_name, self.lgr)
     if sql is None:
         print('Missing mysql database %s' % self.cfg.db_name)
         exit(1)
     value = None
     if node == szk.MASTER_CONFIG_NODE:
         value, stat = self.szk.zk.get(szk.MASTER_CONFIG_NODE)
     elif node == szk.MASTER_DEBUG_CONFIG_NODE:
         value, stat = self.szk.zk.get(szk.MASTER_DEBUG_CONFIG_NODE)
     elif node == szk.MASTER_ANALYSIS_CONFIG_NODE:
         value, stat = self.szk.zk.get(szk.MASTER_ANALYSIS_CONFIG_NODE)
     elif node == szk.MASTER_MSC_CONFIG_NODE:
         value, stat = self.szk.zk.get(szk.MASTER_MSC_CONFIG_NODE)
     elif node == szk.MASTER_POV_CONFIG_NODE:
         value, stat = self.szk.zk.get(szk.MASTER_POV_CONFIG_NODE)
     checksum = utils.getChecksum(value)
     sql.addConfig(value, checksum)
     if sql is not None:
         sql.close()