refactoing
This commit is contained in:
parent
16766c514e
commit
265bfd364d
|
@ -73,10 +73,8 @@ public class BaseCollectorIterator implements Iterator<Element> {
|
||||||
|
|
||||||
try (InputStream origInputStream = fs.open(filePath);
|
try (InputStream origInputStream = fs.open(filePath);
|
||||||
final TarArchiveInputStream tarInputStream = new TarArchiveInputStream(origInputStream)) {
|
final TarArchiveInputStream tarInputStream = new TarArchiveInputStream(origInputStream)) {
|
||||||
importTarStream(tarInputStream);
|
importTarStream(tarInputStream, report);
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
log.error("Error processing BASE records", e);
|
|
||||||
report.put(e.getClass().getName(), e.getMessage());
|
|
||||||
throw new RuntimeException("Error processing BASE records", e);
|
throw new RuntimeException("Error processing BASE records", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,17 +82,17 @@ public class BaseCollectorIterator implements Iterator<Element> {
|
||||||
private void importTestFile(final String resourcePath, final AggregatorReport report) {
|
private void importTestFile(final String resourcePath, final AggregatorReport report) {
|
||||||
try (final InputStream origInputStream = BaseCollectorIterator.class.getResourceAsStream(resourcePath);
|
try (final InputStream origInputStream = BaseCollectorIterator.class.getResourceAsStream(resourcePath);
|
||||||
final TarArchiveInputStream tarInputStream = new TarArchiveInputStream(origInputStream)) {
|
final TarArchiveInputStream tarInputStream = new TarArchiveInputStream(origInputStream)) {
|
||||||
importTarStream(tarInputStream);
|
importTarStream(tarInputStream, report);
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
log.error("Error processing BASE records", e);
|
|
||||||
report.put(e.getClass().getName(), e.getMessage());
|
|
||||||
throw new RuntimeException("Error processing BASE records", e);
|
throw new RuntimeException("Error processing BASE records", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void importTarStream(final TarArchiveInputStream tarInputStream) throws Exception {
|
private void importTarStream(final TarArchiveInputStream tarInputStream, final AggregatorReport report) {
|
||||||
TarArchiveEntry entry;
|
|
||||||
long count = 0;
|
long count = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
TarArchiveEntry entry;
|
||||||
while ((entry = (TarArchiveEntry) tarInputStream.getNextEntry()) != null) {
|
while ((entry = (TarArchiveEntry) tarInputStream.getNextEntry()) != null) {
|
||||||
final String name = entry.getName();
|
final String name = entry.getName();
|
||||||
|
|
||||||
|
@ -124,8 +122,13 @@ public class BaseCollectorIterator implements Iterator<Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.queue.put("__END__"); // I ADD A NOT ELEMENT OBJECT TO INDICATE THE END OF THE QUEUE
|
this.queue.put("__END__"); // I ADD A NOT ELEMENT OBJECT TO INDICATE THE END OF THE QUEUE
|
||||||
|
} catch (final Throwable e) {
|
||||||
|
log.error("Error processing BASE records", e);
|
||||||
|
report.put(e.getClass().getName(), e.getMessage());
|
||||||
|
throw new RuntimeException("Error processing BASE records", e);
|
||||||
|
} finally {
|
||||||
log.info("Total records (written in queue): " + count);
|
log.info("Total records (written in queue): " + count);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue