25
25
26
26
import java .io .FileNotFoundException ;
27
27
import java .io .IOException ;
28
+ import java .time .Duration ;
28
29
import java .util .ArrayList ;
29
30
import java .util .Collection ;
30
31
import java .util .Collections ;
38
39
import java .util .SortedMap ;
39
40
import java .util .concurrent .ExecutorService ;
40
41
import java .util .concurrent .TimeUnit ;
42
+ import java .util .concurrent .atomic .AtomicInteger ;
41
43
import java .util .stream .Stream ;
42
44
43
45
import org .apache .accumulo .core .Constants ;
65
67
import org .apache .accumulo .core .metadata .schema .TabletsMetadata ;
66
68
import org .apache .accumulo .core .security .Authorizations ;
67
69
import org .apache .accumulo .core .util .Pair ;
70
+ import org .apache .accumulo .core .util .Timer ;
68
71
import org .apache .accumulo .core .util .UtilWaitThread ;
69
72
import org .apache .accumulo .core .util .threads .ThreadPools ;
70
73
import org .apache .accumulo .core .volume .Volume ;
@@ -99,12 +102,14 @@ public class GCRun implements GarbageCollectionEnvironment {
99
102
private long inUse = 0 ;
100
103
private long deleted = 0 ;
101
104
private long errors = 0 ;
105
+ private AtomicInteger batchCount ;
102
106
103
107
public GCRun (Ample .DataLevel level , ServerContext context ) {
104
108
this .log = LoggerFactory .getLogger (GCRun .class .getName () + "." + level .name ());
105
109
this .level = level ;
106
110
this .context = context ;
107
111
this .config = context .getConfiguration ();
112
+ this .batchCount = new AtomicInteger (0 );
108
113
}
109
114
110
115
@ Override
@@ -132,7 +137,8 @@ public void deleteGcCandidates(Collection<GcCandidate> gcCandidates, GcCandidate
132
137
return ;
133
138
}
134
139
135
- log .info ("Attempting to delete gcCandidates of type {} from metadata" , type );
140
+ log .info ("Batch {} attempting to delete {} gcCandidates of type {} from metadata" ,
141
+ batchCount .get (), gcCandidates .size (), type );
136
142
context .getAmple ().deleteGcCandidates (level , gcCandidates , type );
137
143
}
138
144
@@ -143,6 +149,7 @@ public List<GcCandidate> readCandidatesThatFitInMemory(Iterator<GcCandidate> can
143
149
long candidateBatchSize = getCandidateBatchSize () / 2 ;
144
150
145
151
List <GcCandidate > candidatesBatch = new ArrayList <>();
152
+ batchCount .incrementAndGet ();
146
153
147
154
while (candidates .hasNext ()) {
148
155
GcCandidate candidate = candidates .next ();
@@ -295,8 +302,12 @@ public void deleteConfirmedCandidates(SortedMap<String,GcCandidate> confirmedDel
295
302
296
303
final List <Pair <Path ,Path >> replacements = context .getVolumeReplacements ();
297
304
305
+ log .debug ("Batch {} attempting to delete {} gcCandidate files" , batchCount .get (),
306
+ confirmedDeletes .size ());
307
+ int deleteCounter = 0 ;
308
+ Timer timer = Timer .startNew ();
298
309
for (final GcCandidate delete : confirmedDeletes .values ()) {
299
-
310
+ deleteCounter ++;
300
311
Runnable deleteTask = () -> {
301
312
boolean removeFlag = false ;
302
313
@@ -320,7 +331,7 @@ public void deleteConfirmedCandidates(SortedMap<String,GcCandidate> confirmedDel
320
331
}
321
332
322
333
for (Path pathToDel : GcVolumeUtil .expandAllVolumesUri (fs , fullPath )) {
323
- log .debug ("{} Deleting {}" , fileActionPrefix , pathToDel );
334
+ log .debug ("Batch {} {} Deleting {}" , batchCount . get () , fileActionPrefix , pathToDel );
324
335
325
336
if (moveToTrash (pathToDel ) || fs .deleteRecursively (pathToDel )) {
326
337
// delete succeeded, still want to delete
@@ -368,6 +379,11 @@ public void deleteConfirmedCandidates(SortedMap<String,GcCandidate> confirmedDel
368
379
};
369
380
370
381
deleteThreadPool .execute (deleteTask );
382
+ if (timer .hasElapsed (Duration .ofMinutes (1 ))) {
383
+ log .info ("Batch {} deleting file {} of {}" , batchCount .get (), deleteCounter ,
384
+ confirmedDeletes .size ());
385
+ timer .restart ();
386
+ }
371
387
}
372
388
373
389
deleteThreadPool .shutdown ();
@@ -451,7 +467,10 @@ static void minimizeDeletes(SortedMap<String,GcCandidate> confirmedDeletes,
451
467
452
468
String lastDirRel = null ;
453
469
Path lastDirAbs = null ;
470
+ Timer progressTimer = Timer .startNew ();
471
+ int progressCount = 0 ;
454
472
while (cdIter .hasNext ()) {
473
+ progressCount ++;
455
474
Map .Entry <String ,GcCandidate > entry = cdIter .next ();
456
475
String relPath = entry .getKey ();
457
476
Path absPath = new Path (entry .getValue ().getPath ());
@@ -492,6 +511,10 @@ static void minimizeDeletes(SortedMap<String,GcCandidate> confirmedDeletes,
492
511
}
493
512
}
494
513
}
514
+ if (progressTimer .hasElapsed (Duration .ofMinutes (1 ))) {
515
+ logger .debug ("Minimizing delete {} of {}" , progressCount , confirmedDeletes .size ());
516
+ progressTimer .restart ();
517
+ }
495
518
}
496
519
497
520
/**
0 commit comments