Changeset 53


Ignore:
Timestamp:
04/08/05 09:39:01 (19 years ago)
Author:
bastiaans
Message:

daemon/togad.py:

  • Changed store functions, so that they will pop() data off list so experimenting with multiple storethreads can begin
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/togad.py

    r52 r53  
    8787                last_update = 0
    8888
     89                debug_msg( 8, self.binary + ' info "' + filename + '"' )
     90
    8991                for line in os.popen( self.binary + ' info "' + filename + '"' ).readlines():
    9092
     
    377379                # Store metrics somewhere between every 60 and 180 seconds
    378380                #
    379                 #STORE_INTERVAL = random.randint( 360, 640 )
    380                 STORE_INTERVAL = random.randint( 90, 120 )
     381                STORE_INTERVAL = random.randint( 360, 640 )
    381382
    382383                storethread = threading.Thread( None, self.storeThread, 'storemetricthread' )
     
    593594                        self.myMetrics[ host ][ metric['name'] ] = [ ]
    594595
    595                 # Ah, psst, push it
     596                # <ATOMIC>
    596597                #
    597                 # <atomic>
    598598                self.slot.acquire()
    599599
     
    601601
    602602                self.slot.release()
    603                 # </atomic>
     603                #
     604                # </ATOMIC>
    604605
    605606        def makeUpdateList( self, host, metriclist ):
     
    610611                while len( metriclist ) > 0:
    611612
    612                         # Kabouter pop
    613                         #
    614                         # <atomic>     
    615                         #self.slot.acquire()
    616 
    617                         # len might have changed since loop start
    618                         #
    619                         if len( metriclist ) > 0:
    620                                 metric = metriclist.pop( 0 )
    621 
    622                         #self.slot.release()
    623                         # </atomic>
    624 
    625                         if metric:
    626                                 if self.checkStoreMetric( host, metric ):
    627                                         update_list.append( '%s:%s' %( metric['time'], metric['val'] ) )
     613                        metric = metriclist.pop( 0 )
     614
     615                        if self.checkStoreMetric( host, metric ):
     616                                update_list.append( '%s:%s' %( metric['time'], metric['val'] ) )
    628617
    629618                return update_list
     
    668657                        for metricname, mymetric in mymetrics.items():
    669658
    670                                 # Atomic: Don't want other threads messing around now
     659                                metrics_to_store = [ ]
     660
     661                                # <ATOMIC>
    671662                                #
    672663                                self.slot.acquire()
    673664
     665                                while len( mymetric ) > 0:
     666
     667                                        metrics_to_store.append( mymetric.pop( 0 ) )
     668
     669                                self.slot.release()
     670                                #
     671                                # </ATOMIC>
     672
    674673                                # Create a mapping table, each metric to the period where it should be stored
    675674                                #
    676                                 metric_serial_table = self.determineSerials( hostname, metricname, mymetric )
     675                                metric_serial_table = self.determineSerials( hostname, metricname, metrics_to_store )
    677676                                self.myMetrics[ hostname ][ metricname ] = [ ]
    678 
    679                                 self.slot.release() # Atomic end
    680677
    681678                                update_rets = [ ]
Note: See TracChangeset for help on using the changeset viewer.