@@ -31,8 +31,8 @@ class BBPool(Pool):
31
31
# 'key.2': UNIX TIMESTAMP
32
32
}
33
33
34
- buckets_count = 0
35
- items_count = 0 ;
34
+ buckets_num_total = 0
35
+ items_num_total = 0 ;
36
36
37
37
prev_time = None
38
38
prev_buckets_count = 0
@@ -98,7 +98,7 @@ def flush(self, key=None):
98
98
def rotate_belt (self , belt_index , flush = False ):
99
99
"""Try to rotate belt"""
100
100
101
- now = int ( time .time () )
101
+ now = time .time ()
102
102
103
103
if flush :
104
104
# explicit flush requested
@@ -129,25 +129,25 @@ def rotate_belt(self, belt_index, flush=False):
129
129
# too many buckets on the belt
130
130
# time to rotate belt and flush the most-right-bucket
131
131
132
- buckets_num = len (self .belts [belt_index ])
133
- last_bucket_size = len (self .belts [belt_index ][buckets_num - 1 ])
132
+ buckets_on_belt_num = len (self .belts [belt_index ])
133
+ most_right_bucket_size = len (self .belts [belt_index ][buckets_on_belt_num - 1 ])
134
134
135
- self .buckets_count += 1
136
- self .items_count += last_bucket_size
135
+ self .buckets_num_total += 1
136
+ self .items_num_total += most_right_bucket_size
137
137
138
- logging .info ('rot now:%d bktcnt :%d bktcontentcnt : %d index:%s reason:%s bktsonbelt:%d bktsize:%d beltnum:%d' ,
139
- now ,
140
- self .buckets_count ,
141
- self .items_count ,
142
- str (belt_index ),
143
- rotate_reason ,
144
- buckets_num ,
145
- last_bucket_size ,
146
- len (self .belts )
147
- )
138
+ logging .info ('rot now:%f bktttl :%d bktitemsttl : %d index:%s reason:%s bktsonbelt:%d bktsize:%d beltnum:%d' ,
139
+ now ,
140
+ self .buckets_num_total ,
141
+ self .items_num_total ,
142
+ str (belt_index ),
143
+ rotate_reason ,
144
+ buckets_on_belt_num ,
145
+ most_right_bucket_size ,
146
+ len (self .belts ),
147
+ )
148
148
149
149
# time to flush data for specified key
150
- self .writer_builder .param ('csv_file_path_suffix_parts' , [str (now ), str (self .buckets_count )])
150
+ self .writer_builder .param ('csv_file_path_suffix_parts' , [str (int ( now )) , str (self .buckets_num_total )])
151
151
writer = self .writer_builder .get ()
152
152
writer .insert (self .belts [belt_index ].pop ())
153
153
writer .close ()
@@ -160,8 +160,8 @@ def rotate_belt(self, belt_index, flush=False):
160
160
# can calculate belt speed
161
161
window_size = now - self .prev_time
162
162
if window_size > 0 :
163
- buckets_per_sec = (self .buckets_count - self .prev_buckets_count )/ window_size
164
- items_per_sec = (self .items_count - self .prev_items_count ) / window_size
163
+ buckets_per_sec = (self .buckets_num_total - self .prev_buckets_count ) / window_size
164
+ items_per_sec = (self .items_num_total - self .prev_items_count ) / window_size
165
165
logging .info (
166
166
'PERF - buckets_per_sec:%f items_per_sec:%f for last %d sec' ,
167
167
buckets_per_sec ,
@@ -172,8 +172,8 @@ def rotate_belt(self, belt_index, flush=False):
172
172
logging .info ("PERF - buckets window size=0 can not calc performance for this window" )
173
173
174
174
self .prev_time = now
175
- self .prev_buckets_count = self .buckets_count
176
- self .prev_items_count = self .items_count
175
+ self .prev_buckets_count = self .buckets_num_total
176
+ self .prev_items_count = self .items_num_total
177
177
178
178
# belt rotated
179
179
return True
0 commit comments