Class AbstractSequentialFile
- java.lang.Object
-
- org.apache.activemq.artemis.core.io.AbstractSequentialFile
-
- All Implemented Interfaces:
SequentialFile
- Direct Known Subclasses:
AIOSequentialFile,NIOSequentialFile
public abstract class AbstractSequentialFile extends Object implements SequentialFile
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractSequentialFile.LocalBufferObserver
-
Field Summary
Fields Modifier and Type Field Description protected Filedirectoryprotected SequentialFileFactoryfactoryprotected Filefileprotected longfileSizeprotected AtomicLongpositionprotected TimedBuffertimedBufferprotected TimedBufferObservertimedBufferObserverInstead of having AIOSequentialFile implementing the Observer, I have done it on an inner class.
-
Constructor Summary
Constructors Constructor Description AbstractSequentialFile(File directory, String file, SequentialFileFactory factory, Executor writerExecutor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidcopyTo(SequentialFile newFileName)protected TimedBufferObservercreateTimedBufferObserver()voiddelete()booleanexists()booleanfits(int size)protected FilegetFile()StringgetFileName()FilegetJavaFile()Returns a native File of the file underlying this sequential file.protected ByteBuffernewBuffer(int requiredCapacity, boolean zeroed)longposition()voidposition(long pos)voidrenameTo(String newFileName)voidsetTimedBuffer(TimedBuffer buffer)voidwrite(ActiveMQBuffer bytes, boolean sync)voidwrite(ActiveMQBuffer bytes, boolean sync, IOCallback callback)voidwrite(EncodingSupport bytes, boolean sync)voidwrite(EncodingSupport bytes, boolean sync, IOCallback callback)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.activemq.artemis.core.io.SequentialFile
afterComplete, blockingWriteDirect, calculateBlockStart, cloneFile, close, fill, isOpen, map, open, open, read, read, size, sync, writeDirect, writeDirect
-
-
-
-
Field Detail
-
file
protected File file
-
directory
protected final File directory
-
factory
protected final SequentialFileFactory factory
-
fileSize
protected long fileSize
-
position
protected final AtomicLong position
-
timedBuffer
protected TimedBuffer timedBuffer
-
timedBufferObserver
protected final TimedBufferObserver timedBufferObserver
Instead of having AIOSequentialFile implementing the Observer, I have done it on an inner class. This is the class returned to the factory when the file is being activated.
-
-
Constructor Detail
-
AbstractSequentialFile
public AbstractSequentialFile(File directory, String file, SequentialFileFactory factory, Executor writerExecutor)
- Parameters:
file-directory-
-
-
Method Detail
-
createTimedBufferObserver
protected TimedBufferObserver createTimedBufferObserver()
-
exists
public final boolean exists()
- Specified by:
existsin interfaceSequentialFile
-
getFileName
public final String getFileName()
- Specified by:
getFileNamein interfaceSequentialFile
-
delete
public final void delete() throws IOException, InterruptedException, ActiveMQException- Specified by:
deletein interfaceSequentialFile- Throws:
IOExceptionInterruptedExceptionActiveMQException
-
copyTo
public void copyTo(SequentialFile newFileName) throws Exception
- Specified by:
copyToin interfaceSequentialFile- Throws:
Exception
-
position
public void position(long pos) throws IOException- Specified by:
positionin interfaceSequentialFile- Throws:
IOException- only declare exception due to signature. Sub-class needs it.
-
position
public long position()
- Specified by:
positionin interfaceSequentialFile
-
renameTo
public final void renameTo(String newFileName) throws IOException, InterruptedException, ActiveMQException
- Specified by:
renameToin interfaceSequentialFile- Throws:
IOExceptionInterruptedExceptionActiveMQException
-
close
public void close() throws IOException, InterruptedException, ActiveMQException- Specified by:
closein interfaceSequentialFile- Throws:
IOException- we declare throwing IOException because sub-classes need to do itActiveMQExceptionInterruptedException
-
fits
public final boolean fits(int size)
- Specified by:
fitsin interfaceSequentialFile
-
setTimedBuffer
public void setTimedBuffer(TimedBuffer buffer)
- Specified by:
setTimedBufferin interfaceSequentialFile
-
write
public void write(ActiveMQBuffer bytes, boolean sync, IOCallback callback) throws IOException
- Specified by:
writein interfaceSequentialFile- Throws:
IOException
-
write
public void write(ActiveMQBuffer bytes, boolean sync) throws IOException, InterruptedException, ActiveMQException
- Specified by:
writein interfaceSequentialFile- Throws:
IOExceptionInterruptedExceptionActiveMQException
-
write
public void write(EncodingSupport bytes, boolean sync, IOCallback callback)
- Specified by:
writein interfaceSequentialFile
-
write
public void write(EncodingSupport bytes, boolean sync) throws InterruptedException, ActiveMQException
- Specified by:
writein interfaceSequentialFile- Throws:
InterruptedExceptionActiveMQException
-
getFile
protected File getFile()
-
newBuffer
protected ByteBuffer newBuffer(int requiredCapacity, boolean zeroed)
-
getJavaFile
public File getJavaFile()
Description copied from interface:SequentialFileReturns a native File of the file underlying this sequential file.- Specified by:
getJavaFilein interfaceSequentialFile
-
-