@@ -110,10 +110,6 @@ public class Tdb2MojoShared extends AbstractMojo {
110
110
@ Parameter (defaultValue = "nt,ttl,nq,trig,owl,nt.gz,ttl.gz,nq.gz,trig.gz,owl.gz,nt.bz2,ttl.bz2,nq.bz2,trig.bz2,owl.bz2" )
111
111
private String includeTypes ;
112
112
113
-
114
- // protected boolean metaDataGraph;
115
-
116
-
117
113
@ Parameter (defaultValue = "${project.build.directory}/tdb2" )
118
114
private File outputFolder ;
119
115
@@ -253,13 +249,8 @@ public void executeActual() throws Exception {
253
249
Node destNode = update .getDest ();
254
250
255
251
String destNodeLabel = getGraphLabel (destNode );
256
-
257
- // logger.info("Preparing TDB2 workload: " + update.getSource() + " -> " + update.getDest());
258
-
259
252
boolean isAlreadyLoaded = loadState .getFileStates ().containsKey (source );
260
- // boolean isAlreadyLoaded = destNode == null
261
- // ? false
262
- // : Txn.calculateRead(dg, () -> dg.containsGraph(destNode));
253
+
263
254
if (isAlreadyLoaded ) {
264
255
logger .info ("Skipping TDB2 workload (already loaded): " + source + " -> " + destNodeLabel );
265
256
} else {
@@ -448,33 +439,40 @@ public static void packageTdb2(Consumer<String> fileCallback, Path fileToWrite,
448
439
fileCallback .accept (msg );
449
440
};
450
441
451
- ScheduledExecutorService ses = Executors .newSingleThreadScheduledExecutor ();
452
- try {
453
- for (Entry <String , Path > e : fileSet .entrySet ()) {
454
- String relPathStr = e .getKey ();
455
- Path file = e .getValue ();
456
-
457
- Path displayPath = basePath == null ? file : basePath .relativize (file );
442
+ for (Entry <String , Path > e : fileSet .entrySet ()) {
443
+ String relPathStr = e .getKey ();
444
+ Path file = e .getValue ();
445
+ Path displayPath = basePath == null ? file : basePath .relativize (file );
458
446
459
- ++tracker .currentFileIdx ;
460
- tracker .currentFileName = displayPath .toString ();
461
- tracker .currentFileSize = Files .size (file );
447
+ ++tracker .currentFileIdx ;
448
+ tracker .currentFileName = displayPath .toString ();
449
+ tracker .currentFileSize = Files .size (file );
462
450
463
- TarArchiveEntry tarEntry = new TarArchiveEntry (file , relPathStr );
464
- tOut .putArchiveEntry (tarEntry );
451
+ TarArchiveEntry tarEntry = new TarArchiveEntry (file , relPathStr );
452
+ tOut .putArchiveEntry (tarEntry );
465
453
466
- try (CountingInputStream cin = new CountingInputStream (Files .newInputStream (file ))) {
467
- tracker .currentFileProgress = () -> cin .getCount ();
468
- ScheduledFuture <?> future = ses .scheduleAtFixedRate (monitorProgress , 1 , 10 , TimeUnit .SECONDS );
454
+ ScheduledExecutorService ses = Executors .newSingleThreadScheduledExecutor ();
455
+ try (CountingInputStream cin = new CountingInputStream (Files .newInputStream (file ))) {
456
+ tracker .currentFileProgress = () -> cin .getCount ();
457
+ ScheduledFuture <?> future = ses .scheduleAtFixedRate (monitorProgress , 1 , 10 , TimeUnit .SECONDS );
458
+ try {
469
459
cin .transferTo (tOut );
460
+ } finally {
470
461
future .cancel (false );
471
462
}
472
- monitorProgress .run ();
473
- tracker .currentFileStartProgress += tracker .currentFileProgress .getAsLong ();
474
- tOut .closeArchiveEntry ();
463
+ } finally {
464
+ ses .shutdown ();
465
+ try {
466
+ if (!ses .awaitTermination (5 , TimeUnit .SECONDS )) {
467
+ throw new RuntimeException ("Progress monitor: Failed to stop." );
468
+ }
469
+ } catch (InterruptedException e1 ) {
470
+ throw new RuntimeException ("Progress monitor: Unexpected interruption" , e1 );
471
+ }
475
472
}
476
- } finally {
477
- ses .shutdown ();
473
+ monitorProgress .run ();
474
+ tracker .currentFileStartProgress += tracker .currentFileProgress .getAsLong ();
475
+ tOut .closeArchiveEntry ();
478
476
}
479
477
tOut .finish ();
480
478
}
0 commit comments