コード例 #1
0
ファイル: OfflineAds.py プロジェクト: zwets/htcondor
    def Update(self, available_sites):
        """
        Main function used in the OfflineAds class.  This function will
        calculate all of the offline ad needs of the class, and return
        what it believes should be submitted.
        
        @param available_sites: List of site names that we should look for.
        @return list - Sites that should have a glidein matched to it.
        """

        # Query the status
        self.condor_status = CondorStatus()
        try:
            self.condor_status.load()
        except:
            return {}

        # Check last match times for an recent match
        matched_sites = self.GetLastMatchedSites()

        # Check for expired classads, delete them (OFFLINE_EXPIRE_ADS_AFTER should do this)
        #self.RemoveExpiredClassads()

        # Check for new startd's reporting, save them while deleting the older ones (max numclassads)
        for site in self.GetUniqueAliveSites():
            new_ads = self.GetNewStartdAds(site)
            logging.debug("New Ads = %i", len(new_ads))

            # Limit new_ads to the number of ads we care about
            new_ads = new_ads[:self.numclassads]
            offline_ads = self.GetOfflineAds(site)
            if (self.numclassads - (len(offline_ads) + len(new_ads))) < 0:
                # Remove old ads
                sorted_offline = SortClassAdsByElement(offline_ads,
                                                       "LastHeardFrom")
                self.DeAdvertiseAds(
                    sorted_offline[:len(offline_ads) -
                                   (self.numclassads - len(new_ads))])

            for ad in new_ads:
                ad.ConvertToOffline(self.timekeep)
            self.AdvertiseAds(new_ads)

        self.lastupdatetime = int(time.time())
        return matched_sites
コード例 #2
0
    def GetCondorStatus(self, constraint=None):
        """
        Returns the current condor_status.  Refreshes data if necessary
        
        @return: [(ClusterID, ProcID): [classad,...]]
        
        """
        if constraint == None:
            constraint = self.status_constraint

        # Refresh the condor_status, if necessary
        if self.status_refresh_timer < int(time.time()):
            condorstatus = CondorStatus()
            try:
                self.condor_status = condorstatus.fetch(constraint=constraint)
                self.status_refresh_timer = int(
                    time.time()) + self.refresh_interval
            except:
                # There was an error in getting the information from condor_status
                self.condor_status = {}

        # Return the queue
        return self.condor_status