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 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 CriticalAnalyzercriticalAnalyzerprotected booleandataSyncprotected static intEXECUTOR_TIMEOUTprotected FilejournalDirprotected intmaxIOprotected TimedBuffertimedBufferprotected ExecutorServicewriteExecutorAsynchronous writes need to be done at another executor.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSequentialFileFactory(File journalDir, boolean buffered, int bufferSize, int bufferTimeout, int maxIO, boolean logRates, IOCriticalErrorListener criticalErrorListener, 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()CriticalAnalyzergetCriticalAnalyzer()IOCriticalErrorListenergetCriticalErrorListener()FilegetDirectory()intgetMaxIO()booleanisDatasync()List<String>listFiles(String extension)Lists files that end with the given extension.voidonIOError(Throwable exception, String message, String file)The SequentialFile will call this method when a disk IO Error happens during the live phase.voidreleaseBuffer(ByteBuffer buffer)AbstractSequentialFileFactorysetAlignment(int alignment)voidsetCriticalErrorListener(IOCriticalErrorListener listener)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, onIOError, onIOError, releaseDirectBuffer, wrapBuffer
-
-
-
-
Field Detail
-
EXECUTOR_TIMEOUT
protected static final int EXECUTOR_TIMEOUT
- See Also:
- Constant Field Values
-
journalDir
protected final 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 IOCriticalErrorListener critialErrorListener
-
criticalAnalyzer
protected final CriticalAnalyzer criticalAnalyzer
-
writeExecutor
protected 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(File journalDir, boolean buffered, int bufferSize, int bufferTimeout, int maxIO, boolean logRates, IOCriticalErrorListener criticalErrorListener, CriticalAnalyzer criticalAnalyzer)
-
-
Method Detail
-
getCriticalErrorListener
public IOCriticalErrorListener getCriticalErrorListener()
- Specified by:
getCriticalErrorListenerin interfaceSequentialFileFactory
-
setCriticalErrorListener
public void setCriticalErrorListener(IOCriticalErrorListener listener)
- Specified by:
setCriticalErrorListenerin interfaceSequentialFileFactory
-
getCriticalAnalyzer
public 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 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(Throwable exception, String message, String 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(ByteBuffer buffer)
- Specified by:
releaseBufferin interfaceSequentialFileFactory
-
createDirs
public void createDirs() throws ExceptionCreate the directory if it doesn't exist yet- Specified by:
createDirsin interfaceSequentialFileFactory- Throws:
Exception
-
listFiles
public List<String> listFiles(String extension) throws Exception
Description copied from interface:SequentialFileFactoryLists files that end with the given extension.This method inserts a ".' before the extension.
- Specified by:
listFilesin interfaceSequentialFileFactory- Returns:
- Throws:
Exception
-
-