| | |
| | | } |
| | | finally |
| | | { |
| | | sorter.shutdown(); |
| | | sorter.shutdownNow(); |
| | | if (OperatingSystem.isWindows()) |
| | | { |
| | | // Try to force the JVM to close mmap()ed file so that they can be deleted. |
| | |
| | | @Override |
| | | public Void call() throws Exception |
| | | { |
| | | checkThreadNotInterrupted(); |
| | | EntryInformation entryInfo; |
| | | while ((entryInfo = reader.readEntry(entryContainers)) != null && !importConfig.isCancelled()) |
| | | { |
| | |
| | | { |
| | | reader.removePending(entry.getName()); |
| | | } |
| | | checkThreadNotInterrupted(); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | @Override |
| | | public Void call() throws Exception |
| | | { |
| | | checkThreadNotInterrupted(); |
| | | try (final MeteredCursor<ByteString, ByteString> unusued = source.flip()) |
| | | { |
| | | // force flush |
| | |
| | | } |
| | | finally |
| | | { |
| | | executor.shutdown(); |
| | | executor.shutdownNow(); |
| | | executor.awaitTermination(5, TimeUnit.SECONDS); |
| | | } |
| | | } |
| | | |
| | |
| | | * NOTE: The resulting size of the FileRegion might be less than chunk.size() because of key de-duplication |
| | | * performed by the CollectorCursor. |
| | | */ |
| | | checkThreadNotInterrupted(); |
| | | final FileRegion region = new FileRegion(channel, startOffset, chunk.size()); |
| | | final int regionSize; |
| | | try (final SequentialCursor<ByteString, ByteString> source = |
| | |
| | | mmapBuffer = channel.map(MapMode.READ_WRITE, startOffset, size); |
| | | } |
| | | |
| | | public int write(SequentialCursor<ByteString, ByteString> source) throws IOException |
| | | public int write(SequentialCursor<ByteString, ByteString> source) throws IOException, InterruptedException |
| | | { |
| | | checkThreadNotInterrupted(); |
| | | while (source.next()) |
| | | { |
| | | final ByteSequence key = source.getKey(); |
| | |
| | | PackedLong.writeCompactUnsigned(mmapBufferOS, value.length()); |
| | | key.copyTo(mmapBuffer); |
| | | value.copyTo(mmapBuffer); |
| | | checkThreadNotInterrupted(); |
| | | } |
| | | return mmapBuffer.position(); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Void call() |
| | | public Void call() throws InterruptedException |
| | | { |
| | | checkThreadNotInterrupted(); |
| | | try (final SequentialCursor<ByteString, ByteString> sourceCursor = trackCursorProgress(reporter, source.flip())) |
| | | { |
| | | copyIntoChunk(sourceCursor, asChunk(treeName, destination)); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Void call() |
| | | public Void call() throws InterruptedException |
| | | { |
| | | checkThreadNotInterrupted(); |
| | | try (final SequentialCursor<ByteString, ByteString> sourceCursor = trackCursorProgress(reporter, source.flip())) |
| | | { |
| | | final long nbRecords = copyIntoChunk(sourceCursor, asChunk(vlvIndex.getName(), destination)); |
| | |
| | | } |
| | | |
| | | private static long copyIntoChunk(SequentialCursor<ByteString, ByteString> source, Chunk destination) |
| | | throws InterruptedException |
| | | { |
| | | long nbRecords = 0; |
| | | checkThreadNotInterrupted(); |
| | | while (source.next()) |
| | | { |
| | | if (!destination.put(source.getKey(), source.getValue())) |
| | |
| | | throw new IllegalStateException("Destination chunk is full"); |
| | | } |
| | | nbRecords++; |
| | | checkThreadNotInterrupted(); |
| | | } |
| | | return nbRecords; |
| | | } |
| | |
| | | final SequentialCursor<ByteString, ByteString> dn2idCursor = |
| | | dn2id.openCursor(trackCursorProgress(reporter, chunkCursor), visitor)) |
| | | { |
| | | checkThreadNotInterrupted(); |
| | | while (dn2idCursor.next()) |
| | | { |
| | | dn2IdDestination.put(dn2idCursor.getKey(), dn2idCursor.getValue()); |
| | | totalNumberOfEntries++; |
| | | checkThreadNotInterrupted(); |
| | | } |
| | | } |
| | | id2count.importPutTotalCount(asImporter(id2CountChunk), Math.max(0, totalNumberOfEntries)); |
| | |
| | | return results; |
| | | } |
| | | |
| | | private static void checkThreadNotInterrupted() throws InterruptedException |
| | | { |
| | | if (Thread.interrupted()) |
| | | { |
| | | throw new InterruptedException(); |
| | | } |
| | | } |
| | | |
| | | /** Regularly report progress statistics from the registered list of {@link ProgressMetric}. */ |
| | | private static final class PhaseTwoProgressReporter implements Runnable, Closeable |
| | | { |