Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit a62a1a3

Browse files
authored
Merge pull request #4 from pmandrik/FFF_DQMTOOLS_V1
Change strategy to delete files
2 parents 44de900 + b8b5d30 commit a62a1a3

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

applets/fff_deleter.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def stat(x):
8686
return collected, collected_paths
8787

8888
class FileDeleter(object):
89-
def __init__(self, top, thresholds, report_directory, log, fake=True, app_tag="fff_deleter"):
89+
def __init__(self, top, thresholds, report_directory, log, fake=True, skip_latest=False, app_tag="fff_deleter"):
9090
self.top = top
9191
self.fake = fake
9292
self.thresholds = thresholds
@@ -95,6 +95,7 @@ def __init__(self, top, thresholds, report_directory, log, fake=True, app_tag="f
9595
self.app_tag = app_tag
9696
self.log = log
9797
self.delay_seconds = 30
98+
self.skip_latest = skip_latest
9899

99100
self.hostname = socket.gethostname()
100101

@@ -121,7 +122,7 @@ def rename(self, f):
121122

122123
return fn
123124

124-
def delete(self, f):
125+
def overwrite(self, f):
125126
if not f.endswith(".deleted"):
126127
return f
127128

@@ -137,7 +138,7 @@ def delete(self, f):
137138

138139
return f
139140

140-
def unlink(self, f, json=False):
141+
def delete(self, f, json=False):
141142
if not f.endswith(".deleted"):
142143
return f
143144

@@ -205,6 +206,8 @@ def do_the_cleanup(self):
205206
collected, collected_paths = collect(self.top, self.log)
206207
self.log.info("Done file collection, took %.03fs.", time.time() - start)
207208

209+
latest_run = collected[-1][0][0]
210+
208211
file_count = len(collected)
209212

210213
# stopSizeDelete can still be positive after this
@@ -214,14 +217,15 @@ def do_the_cleanup(self):
214217
start_cleanup = time.time()
215218
for entry in collected:
216219
sort_key, fp, fsize, ftime = entry
220+
if self.skip_latest and latest_run == sort_key: continue # do not want to
217221

218222
# unlink file and json older than 2 days
219223
# this has no effect on thresholds, but affects performance
220224
age = start - ftime
221225
if fsize == 0 and age >= 2*24*60*60 and fp.endswith(".deleted"):
222226
# remove empty and old files
223227
# no one uses them anymore...
224-
self.unlink(fp, json=True)
228+
self.delete(fp, json=True)
225229

226230
if stopSizeRename <= 0:
227231
break
@@ -230,11 +234,11 @@ def do_the_cleanup(self):
230234
stopSizeRename -= fsize
231235

232236
if fp.endswith(".deleted") and stopSizeDelete > 0:
233-
# delete the files which have been previously marked
237+
# overwrite the files which have been previously marked with dummy
234238
# and we have disk over-usage
235239
stopSizeDelete -= fsize
236240

237-
self.delete(fp)
241+
self.overwrite(fp)
238242
elif fp.endswith(".deleted"):
239243
# already renamed, do nothing
240244
pass
@@ -244,6 +248,7 @@ def do_the_cleanup(self):
244248

245249
if self.thresholds.has_key("delete_folders") and self.thresholds["delete_folders"]:
246250
for entry in collected_paths:
251+
if self.skip_latest and str(latest_run) in entry.path : continue
247252

248253
# check if empty - we don't non-empty dirs
249254
# empty as in a 'no stream files left to truncate' sense

applets/fff_deleter_c2f11_09_01.py

+1
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ def __run__(opts, **kwargs):
2626
service.delay_seconds = 30
2727

2828
service.run_greenlet()
29+

applets/fff_simulator.py

+1
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ def output_join(f):
397397
else:
398398
log.info("Files for this lumi (%06d) will be skipped (to simulate holes in delivery)", play_lumi)
399399

400+
return # files are rather removed gently by FileDeleter greenlet
400401
self.manager.register_files_for_cleanup(run, play_lumi, written_files)
401402

402403
class RunManager(object):

utils/makerpm.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cd $BUILDDIR
1111

1212
cat > fff-dqmtools.spec <<EOF
1313
Name: fff-dqmtools
14-
Version: 1.7.5
14+
Version: 1.7.6
1515
Release: 1
1616
Summary: DQM tools for FFF.
1717
License: gpl

0 commit comments

Comments
 (0)