@@ -466,6 +466,10 @@ public void store(History history, Repository repository, String tillRevision) t
466
466
LOGGER .log (Level .WARNING , "cannot create history cache directory for ''{0}''" , histDataDir );
467
467
}
468
468
469
+ Set <String > regularFiles = map .keySet ().stream ().
470
+ filter (e -> !history .isRenamed (e )).collect (Collectors .toSet ());
471
+ createDirectoriesForFiles (regularFiles );
472
+
469
473
/*
470
474
* Now traverse the list of files from the hash map built above
471
475
* and for each file store its history (saved in the value of the
@@ -475,18 +479,31 @@ public void store(History history, Repository repository, String tillRevision) t
475
479
LOGGER .log (Level .FINE , "Storing history for {0} files in repository ''{1}''" ,
476
480
new Object []{map .entrySet ().size (), repository .getDirectoryName ()});
477
481
final File root = env .getSourceRootFile ();
478
- int fileHistoryCount = 0 ;
479
- for (Map .Entry <String , List <HistoryEntry >> map_entry : map .entrySet ()) {
480
- if (handleRenamedFiles && history .isRenamed (map_entry .getKey ())) {
481
- continue ;
482
- }
483
482
484
- doFileHistory (map_entry .getKey (), new History (map_entry .getValue ()),
485
- repository , root , false );
486
- fileHistoryCount ++;
483
+ final CountDownLatch latch = new CountDownLatch (regularFiles .size ());
484
+ AtomicInteger fileHistoryCount = new AtomicInteger ();
485
+ for (String file : regularFiles ) {
486
+ env .getIndexerParallelizer ().getHistoryFileExecutor ().submit (() -> {
487
+ try {
488
+ doFileHistory (file , new History (map .get (file )), repository , root , false );
489
+ fileHistoryCount .getAndIncrement ();
490
+ } catch (Exception ex ) {
491
+ // We want to catch any exception since we are in thread.
492
+ LOGGER .log (Level .WARNING , "doFileHistory() got exception " , ex );
493
+ } finally {
494
+ latch .countDown ();
495
+ }
496
+ });
487
497
}
488
498
489
- LOGGER .log (Level .FINE , "Stored history for {0} files in repository ''{1}''" ,
499
+ // Wait for the executors to finish.
500
+ try {
501
+ // Wait for the executors to finish.
502
+ latch .await ();
503
+ } catch (InterruptedException ex ) {
504
+ LOGGER .log (Level .SEVERE , "latch exception" , ex );
505
+ }
506
+ LOGGER .log (Level .FINE , "Stored history for {0} regular files in repository ''{1}''" ,
490
507
new Object []{fileHistoryCount , repository .getDirectoryName ()});
491
508
492
509
if (!handleRenamedFiles ) {
0 commit comments