Class AbstractSequentialFileFactory
- java.lang.Object
-
- org.apache.activemq.artemis.core.io.AbstractSequentialFileFactory
-
- All Implemented Interfaces:
SequentialFileFactory
- Direct Known Subclasses:
AIOSequentialFileFactory,MappedSequentialFileFactory,NIOSequentialFileFactory
public abstract class AbstractSequentialFileFactory extends java.lang.Object implements SequentialFileFactory
An abstract SequentialFileFactory containing basic functionality for both AIO and NIO SequentialFactories
-
-
Field Summary
Fields Modifier and Type Field Description protected intalignmentprotected intbufferSizeprotected longbufferTimeoutprotected IOCriticalErrorListenercritialErrorListenerprotected org.apache.activemq.artemis.utils.critical.CriticalAnalyzercriticalAnalyzerprotected booleandataSyncprotected static intEXECUTOR_TIMEOUTprotected java.io.FilejournalDirprotected intmaxIOprotected TimedBuffertimedBufferprotected java.util.concurrent.ExecutorServicewriteExecutorAsynchronous writes need to be done at another executor.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSequentialFileFactory(java.io.File journalDir, boolean buffered, int bufferSize, int bufferTimeout, int maxIO, boolean logRates, IOCriticalErrorListener criticalErrorListener, org.apache.activemq.artemis.utils.critical.CriticalAnalyzer criticalAnalyzer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivateBuffer(SequentialFile file)voidcreateDirs()Create the directory if it doesn't exist yetvoiddeactivateBuffer()voidflush()intgetAlignment()longgetBufferSize()org.apache.activemq.artemis.utils.critical.CriticalAnalyzergetCriticalAnalyzer()java.io.FilegetDirectory()intgetMaxIO()booleanisDatasync()java.util.List<java.lang.String>listFiles(java.lang.String extension)Lists files that end with the given extension.voidonIOError(java.lang.Exception exception, java.lang.String message, SequentialFile file)The SequentialFile will call this method when a disk IO Error happens during the live phase.voidreleaseBuffer(java.nio.ByteBuffer buffer)AbstractSequentialFileFactorysetAlignment(int alignment)SequentialFileFactorysetDatasync(boolean enabled)voidstart()voidstop()-
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.SequentialFileFactory
allocateDirectBuffer, calculateBlockSize, clearBuffer, createSequentialFile, createSequentialFile, isSupportsCallbacks, newBuffer, newBuffer, releaseDirectBuffer, wrapBuffer
-
-
-
-
Field Detail
-
EXECUTOR_TIMEOUT
protected static final int EXECUTOR_TIMEOUT
- See Also:
- Constant Field Values
-
journalDir
protected final java.io.File journalDir
-
timedBuffer
protected final TimedBuffer timedBuffer
-
bufferSize
protected final int bufferSize
-
bufferTimeout
protected final long bufferTimeout
-
maxIO
protected final int maxIO
-
dataSync
protected boolean dataSync
-
alignment
protected volatile int alignment
-
critialErrorListener
protected final IOCriticalErrorListener critialErrorListener
-
criticalAnalyzer
protected final org.apache.activemq.artemis.utils.critical.CriticalAnalyzer criticalAnalyzer
-
writeExecutor
protected java.util.concurrent.ExecutorService writeExecutor
Asynchronous writes need to be done at another executor. This needs to be done at NIO, or else we would have the callers thread blocking for the return. At AIO this is necessary as context switches on writes would fire flushes at the kernel.
-
-
Constructor Detail
-
AbstractSequentialFileFactory
protected AbstractSequentialFileFactory(java.io.File journalDir, boolean buffered, int bufferSize, int bufferTimeout, int maxIO, boolean logRates, IOCriticalErrorListener criticalErrorListener, org.apache.activemq.artemis.utils.critical.CriticalAnalyzer criticalAnalyzer)
-
-
Method Detail
-
getCriticalAnalyzer
public org.apache.activemq.artemis.utils.critical.CriticalAnalyzer getCriticalAnalyzer()
- Specified by:
getCriticalAnalyzerin interfaceSequentialFileFactory
-
getBufferSize
public long getBufferSize()
- Specified by:
getBufferSizein interfaceSequentialFileFactory
-
getAlignment
public int getAlignment()
- Specified by:
getAlignmentin interfaceSequentialFileFactory
-
setAlignment
public AbstractSequentialFileFactory setAlignment(int alignment)
- Specified by:
setAlignmentin interfaceSequentialFileFactory
-
setDatasync
public SequentialFileFactory setDatasync(boolean enabled)
- Specified by:
setDatasyncin interfaceSequentialFileFactory
-
isDatasync
public boolean isDatasync()
- Specified by:
isDatasyncin interfaceSequentialFileFactory
-
stop
public void stop()
- Specified by:
stopin interfaceSequentialFileFactory
-
getDirectory
public java.io.File getDirectory()
- Specified by:
getDirectoryin interfaceSequentialFileFactory
-
start
public void start()
- Specified by:
startin interfaceSequentialFileFactory
-
getMaxIO
public int getMaxIO()
- Specified by:
getMaxIOin interfaceSequentialFileFactory
-
onIOError
public void onIOError(java.lang.Exception exception, java.lang.String message, SequentialFile file)Description copied from interface:SequentialFileFactoryThe SequentialFile will call this method when a disk IO Error happens during the live phase.- Specified by:
onIOErrorin interfaceSequentialFileFactory
-
activateBuffer
public void activateBuffer(SequentialFile file)
- Specified by:
activateBufferin interfaceSequentialFileFactory
-
flush
public void flush()
- Specified by:
flushin interfaceSequentialFileFactory
-
deactivateBuffer
public void deactivateBuffer()
- Specified by:
deactivateBufferin interfaceSequentialFileFactory
-
releaseBuffer
public void releaseBuffer(java.nio.ByteBuffer buffer)
- Specified by:
releaseBufferin interfaceSequentialFileFactory
-
createDirs
public void createDirs() throws java.lang.ExceptionCreate the directory if it doesn't exist yet- Specified by:
createDirsin interfaceSequentialFileFactory- Throws:
java.lang.Exception
-
listFiles
public java.util.List<java.lang.String> listFiles(java.lang.String extension) throws java.lang.ExceptionDescription copied from interface:SequentialFileFactoryLists files that end with the given extension.This method inserts a ".' before the extension.
- Specified by:
listFilesin interfaceSequentialFileFactory- Returns:
- Throws:
java.lang.Exception
-
-