@Override public File getJavaFile() { return this.sequentialFile.getJavaFile(); }
@Override public File getJavaFile() { return this.sequentialFile.getJavaFile(); }
@Override public void copyTo(SequentialFile dstFile) throws IOException { checkIsNotOpen(); if (dstFile.isOpen()) { throw new IllegalArgumentException("dstFile must be closed too"); } SequentialFile.appendTo(file.toPath(), dstFile.getJavaFile().toPath()); }
@Override public void copyTo(SequentialFile dstFile) throws IOException { checkIsNotOpen(); if (dstFile.isOpen()) { throw new IllegalArgumentException("dstFile must be closed too"); } try (RandomAccessFile src = new RandomAccessFile(file, "rw"); FileChannel srcChannel = src.getChannel(); FileLock srcLock = srcChannel.lock()) { final long readableBytes = srcChannel.size(); if (readableBytes > 0) { try (RandomAccessFile dst = new RandomAccessFile(dstFile.getJavaFile(), "rw"); FileChannel dstChannel = dst.getChannel(); FileLock dstLock = dstChannel.lock()) { final long oldLength = dst.length(); final long newLength = oldLength + readableBytes; dst.setLength(newLength); final long transferred = dstChannel.transferFrom(srcChannel, oldLength, readableBytes); if (transferred != readableBytes) { dstChannel.truncate(oldLength); throw new IOException("copied less then expected"); } } } } }
public JournalSyncFile(JournalFile jFile) throws Exception { SequentialFile seqFile = jFile.getFile(); file = seqFile.getJavaFile(); seqFile.close(); }
final long readableBytes = srcChannel.size(); if (readableBytes > 0) { try (RandomAccessFile dst = new RandomAccessFile(dstFile.getJavaFile(), "rw"); FileChannel dstChannel = dst.getChannel(); FileLock dstLock = dstChannel.lock()) {
@Override public void copyTo(SequentialFile dstFile) throws IOException { if (ActiveMQJournalLogger.LOGGER.isDebugEnabled()) { ActiveMQJournalLogger.LOGGER.debug("Copying " + this + " as " + dstFile); } if (isOpen()) { throw new IllegalStateException("File opened!"); } if (dstFile.isOpen()) { throw new IllegalArgumentException("dstFile must be closed too"); } SequentialFile.appendTo(getFile().toPath(), dstFile.getJavaFile().toPath()); } }
private int readFromMapped(StorageManager storage, List<PagedMessage> messages) throws IOException { file.position(0); //use a readonly mapped view of the file final int mappedSize = size.get(); final MappedByteBuffer mappedByteBuffer = mapFileForRead(this.file.getJavaFile(), mappedSize); ChannelBufferWrapper activeMQBuffer = wrapBuffer(mappedSize, mappedByteBuffer); try { return read(storage, activeMQBuffer, messages); } finally { //unmap the file after read it to avoid GC to take care of it PlatformDependent.freeDirectBuffer(mappedByteBuffer); } }
file.getJavaFile().deleteOnExit(); try { final ByteBuffer bufferBlock = allocateAlignedBlock(blockSize, factory);
file.getJavaFile().deleteOnExit(); try { final ByteBuffer bufferBlock = allocateAlignedBlock(blockSize, factory);
try (FileInputStream fis = new FileInputStream(file.getJavaFile()); FileChannel channel = fis.getChannel()) {