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 java.lang.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 java.io.Filedirectoryprotected SequentialFileFactoryfactoryprotected java.io.Filefileprotected longfileSizeprotected java.util.concurrent.atomic.AtomicLongpositionprotected TimedBuffertimedBufferprotected TimedBufferObservertimedBufferObserverInstead of having AIOSequentialFile implementing the Observer, I have done it on an inner class.
-
Constructor Summary
Constructors Constructor Description AbstractSequentialFile(java.io.File directory, java.lang.String file, SequentialFileFactory factory, java.util.concurrent.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 java.io.FilegetFile()java.lang.StringgetFileName()java.io.FilegetJavaFile()Returns a native File of the file underlying this sequential file.protected java.nio.ByteBuffernewBuffer(int requiredCapacity, boolean zeroed)longposition()voidposition(long pos)voidrenameTo(java.lang.String newFileName)voidsetTimedBuffer(TimedBuffer buffer)voidwrite(org.apache.activemq.artemis.api.core.ActiveMQBuffer bytes, boolean sync)voidwrite(org.apache.activemq.artemis.api.core.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 java.io.File file
-
directory
protected final java.io.File directory
-
factory
protected final SequentialFileFactory factory
-
fileSize
protected long fileSize
-
position
protected final java.util.concurrent.atomic.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(java.io.File directory, java.lang.String file, SequentialFileFactory factory, java.util.concurrent.Executor writerExecutor)- Parameters:
file-directory-
-
-
Method Detail
-
createTimedBufferObserver
protected TimedBufferObserver createTimedBufferObserver()
-
exists
public final boolean exists()
- Specified by:
existsin interfaceSequentialFile
-
getFileName
public final java.lang.String getFileName()
- Specified by:
getFileNamein interfaceSequentialFile
-
delete
public final void delete() throws java.io.IOException, java.lang.InterruptedException, org.apache.activemq.artemis.api.core.ActiveMQException- Specified by:
deletein interfaceSequentialFile- Throws:
java.io.IOExceptionjava.lang.InterruptedExceptionorg.apache.activemq.artemis.api.core.ActiveMQException
-
copyTo
public void copyTo(SequentialFile newFileName) throws java.lang.Exception
- Specified by:
copyToin interfaceSequentialFile- Throws:
java.lang.Exception
-
position
public void position(long pos) throws java.io.IOException- Specified by:
positionin interfaceSequentialFile- Throws:
java.io.IOException- only declare exception due to signature. Sub-class needs it.
-
position
public long position()
- Specified by:
positionin interfaceSequentialFile
-
renameTo
public final void renameTo(java.lang.String newFileName) throws java.io.IOException, java.lang.InterruptedException, org.apache.activemq.artemis.api.core.ActiveMQException- Specified by:
renameToin interfaceSequentialFile- Throws:
java.io.IOExceptionjava.lang.InterruptedExceptionorg.apache.activemq.artemis.api.core.ActiveMQException
-
close
public void close() throws java.io.IOException, java.lang.InterruptedException, org.apache.activemq.artemis.api.core.ActiveMQException- Specified by:
closein interfaceSequentialFile- Throws:
java.io.IOException- we declare throwing IOException because sub-classes need to do itorg.apache.activemq.artemis.api.core.ActiveMQExceptionjava.lang.InterruptedException
-
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(org.apache.activemq.artemis.api.core.ActiveMQBuffer bytes, boolean sync, IOCallback callback) throws java.io.IOException- Specified by:
writein interfaceSequentialFile- Throws:
java.io.IOException
-
write
public void write(org.apache.activemq.artemis.api.core.ActiveMQBuffer bytes, boolean sync) throws java.io.IOException, java.lang.InterruptedException, org.apache.activemq.artemis.api.core.ActiveMQException- Specified by:
writein interfaceSequentialFile- Throws:
java.io.IOExceptionjava.lang.InterruptedExceptionorg.apache.activemq.artemis.api.core.ActiveMQException
-
write
public void write(EncodingSupport bytes, boolean sync, IOCallback callback)
- Specified by:
writein interfaceSequentialFile
-
write
public void write(EncodingSupport bytes, boolean sync) throws java.lang.InterruptedException, org.apache.activemq.artemis.api.core.ActiveMQException
- Specified by:
writein interfaceSequentialFile- Throws:
java.lang.InterruptedExceptionorg.apache.activemq.artemis.api.core.ActiveMQException
-
getFile
protected java.io.File getFile()
-
newBuffer
protected java.nio.ByteBuffer newBuffer(int requiredCapacity, boolean zeroed)
-
getJavaFile
public java.io.File getJavaFile()
Description copied from interface:SequentialFileReturns a native File of the file underlying this sequential file.- Specified by:
getJavaFilein interfaceSequentialFile
-
-