org.apache.activemq.kaha.impl.async
Class AsyncDataManager
java.lang.Object
org.apache.activemq.kaha.impl.async.AsyncDataManager
- Direct Known Subclasses:
- ReadOnlyAsyncDataManager
public class AsyncDataManager
- extends Object
Manages DataFiles
- Version:
- $Revision: 1.1.1.1 $
Method Summary |
void |
addInterestInFile(int file)
|
void |
close()
|
void |
consolidateDataFiles()
|
void |
consolidateDataFilesNotIn(Set<Integer> inUse,
Integer lastFile)
|
void |
consolidateDataFilesNotIn(Set<Integer> inUse,
Set<Integer> inProgress)
|
boolean |
delete()
|
Integer |
getCurrentDataFileId()
|
File |
getDirectory()
|
File |
getDirectoryArchive()
|
long |
getDiskSize()
|
long |
getDiskSizeUntil(Location startPosition)
|
String |
getFilePrefix()
|
Set<File> |
getFiles()
Get a set of files - only valid after start() |
Map<DataFileAppender.WriteKey,DataFileAppender.WriteCommand> |
getInflightWrites()
|
Location |
getLastAppendLocation()
|
Location |
getMark()
|
int |
getMaxFileLength()
|
Location |
getNextLocation(DataFile dataFile,
Location lastLocation,
boolean thisFileOnly)
|
Location |
getNextLocation(File file,
Location lastLocation,
boolean thisFileOnly)
|
Location |
getNextLocation(Location location)
|
boolean |
isArchiveDataLogs()
|
boolean |
isUseNio()
|
void |
lock()
|
ByteSequence |
read(Location location)
|
protected Location |
recoveryCheck(DataFile dataFile,
Location location)
|
void |
removeInterestInFile(int file)
|
void |
removeLocation(Location location)
|
void |
setArchiveDataLogs(boolean archiveDataLogs)
|
void |
setDirectory(File directory)
|
void |
setDirectoryArchive(File directoryArchive)
|
void |
setFilePrefix(String filePrefix)
|
void |
setLastAppendLocation(Location lastSyncedLocation)
|
void |
setMark(Location location,
boolean sync)
|
void |
setMaxFileLength(int maxFileLength)
|
void |
setUseNio(boolean useNio)
|
void |
start()
|
protected void |
storeState(boolean sync)
|
String |
toString()
|
protected void |
unmarshallState(ByteSequence sequence)
|
void |
update(Location location,
ByteSequence data,
boolean sync)
|
Location |
write(ByteSequence data,
boolean sync)
|
Location |
write(ByteSequence data,
byte type,
boolean sync)
|
Location |
write(ByteSequence data,
Runnable onComplete)
|
CONTROL_RECORD_MAX_LENGTH
public static final int CONTROL_RECORD_MAX_LENGTH
- See Also:
- Constant Field Values
ITEM_HEAD_RESERVED_SPACE
public static final int ITEM_HEAD_RESERVED_SPACE
- See Also:
- Constant Field Values
ITEM_HEAD_SPACE
public static final int ITEM_HEAD_SPACE
- See Also:
- Constant Field Values
ITEM_HEAD_OFFSET_TO_SOR
public static final int ITEM_HEAD_OFFSET_TO_SOR
- See Also:
- Constant Field Values
ITEM_FOOT_SPACE
public static final int ITEM_FOOT_SPACE
- See Also:
- Constant Field Values
ITEM_HEAD_FOOT_SPACE
public static final int ITEM_HEAD_FOOT_SPACE
- See Also:
- Constant Field Values
ITEM_HEAD_SOR
public static final byte[] ITEM_HEAD_SOR
ITEM_HEAD_EOR
public static final byte[] ITEM_HEAD_EOR
DATA_ITEM_TYPE
public static final byte DATA_ITEM_TYPE
- See Also:
- Constant Field Values
REDO_ITEM_TYPE
public static final byte REDO_ITEM_TYPE
- See Also:
- Constant Field Values
DEFAULT_DIRECTORY
public static final String DEFAULT_DIRECTORY
- See Also:
- Constant Field Values
DEFAULT_ARCHIVE_DIRECTORY
public static final String DEFAULT_ARCHIVE_DIRECTORY
- See Also:
- Constant Field Values
DEFAULT_FILE_PREFIX
public static final String DEFAULT_FILE_PREFIX
- See Also:
- Constant Field Values
DEFAULT_MAX_FILE_LENGTH
public static final int DEFAULT_MAX_FILE_LENGTH
- See Also:
- Constant Field Values
DEFAULT_CLEANUP_INTERVAL
public static final int DEFAULT_CLEANUP_INTERVAL
- See Also:
- Constant Field Values
PREFERED_DIFF
public static final int PREFERED_DIFF
- See Also:
- Constant Field Values
scheduler
protected static Scheduler scheduler
inflightWrites
protected final Map<DataFileAppender.WriteKey,DataFileAppender.WriteCommand> inflightWrites
directory
protected File directory
directoryArchive
protected File directoryArchive
filePrefix
protected String filePrefix
controlFile
protected ControlFile controlFile
started
protected boolean started
useNio
protected boolean useNio
maxFileLength
protected int maxFileLength
preferedFileLength
protected int preferedFileLength
appender
protected org.apache.activemq.kaha.impl.async.DataFileAppender appender
accessorPool
protected DataFileAccessorPool accessorPool
fileMap
protected Map<Integer,DataFile> fileMap
fileByFileMap
protected Map<File,DataFile> fileByFileMap
currentWriteFile
protected DataFile currentWriteFile
mark
protected Location mark
lastAppendLocation
protected final AtomicReference<Location> lastAppendLocation
cleanupTask
protected Runnable cleanupTask
storeSize
protected final AtomicLong storeSize
archiveDataLogs
protected boolean archiveDataLogs
AsyncDataManager
public AsyncDataManager(AtomicLong storeSize)
AsyncDataManager
public AsyncDataManager()
start
public void start()
throws IOException
- Throws:
IOException
lock
public void lock()
throws IOException
- Throws:
IOException
recoveryCheck
protected Location recoveryCheck(DataFile dataFile,
Location location)
throws IOException
- Throws:
IOException
unmarshallState
protected void unmarshallState(ByteSequence sequence)
throws IOException
- Throws:
IOException
removeLocation
public void removeLocation(Location location)
throws IOException
- Throws:
IOException
close
public void close()
throws IOException
- Throws:
IOException
delete
public boolean delete()
throws IOException
- Throws:
IOException
addInterestInFile
public void addInterestInFile(int file)
throws IOException
- Throws:
IOException
removeInterestInFile
public void removeInterestInFile(int file)
throws IOException
- Throws:
IOException
consolidateDataFilesNotIn
public void consolidateDataFilesNotIn(Set<Integer> inUse,
Set<Integer> inProgress)
throws IOException
- Throws:
IOException
consolidateDataFilesNotIn
public void consolidateDataFilesNotIn(Set<Integer> inUse,
Integer lastFile)
throws IOException
- Throws:
IOException
consolidateDataFiles
public void consolidateDataFiles()
throws IOException
- Throws:
IOException
getMaxFileLength
public int getMaxFileLength()
- Returns:
- the maxFileLength
setMaxFileLength
public void setMaxFileLength(int maxFileLength)
- Parameters:
maxFileLength
- the maxFileLength to set
toString
public String toString()
- Overrides:
toString
in class Object
getMark
public Location getMark()
throws IllegalStateException
- Throws:
IllegalStateException
getNextLocation
public Location getNextLocation(Location location)
throws IOException,
IllegalStateException
- Throws:
IOException
IllegalStateException
getNextLocation
public Location getNextLocation(File file,
Location lastLocation,
boolean thisFileOnly)
throws IllegalStateException,
IOException
- Throws:
IllegalStateException
IOException
getNextLocation
public Location getNextLocation(DataFile dataFile,
Location lastLocation,
boolean thisFileOnly)
throws IOException,
IllegalStateException
- Throws:
IOException
IllegalStateException
read
public ByteSequence read(Location location)
throws IOException,
IllegalStateException
- Throws:
IOException
IllegalStateException
setMark
public void setMark(Location location,
boolean sync)
throws IOException,
IllegalStateException
- Throws:
IOException
IllegalStateException
storeState
protected void storeState(boolean sync)
throws IOException
- Throws:
IOException
write
public Location write(ByteSequence data,
boolean sync)
throws IOException,
IllegalStateException
- Throws:
IOException
IllegalStateException
write
public Location write(ByteSequence data,
Runnable onComplete)
throws IOException,
IllegalStateException
- Throws:
IOException
IllegalStateException
write
public Location write(ByteSequence data,
byte type,
boolean sync)
throws IOException,
IllegalStateException
- Throws:
IOException
IllegalStateException
update
public void update(Location location,
ByteSequence data,
boolean sync)
throws IOException
- Throws:
IOException
getDirectory
public File getDirectory()
setDirectory
public void setDirectory(File directory)
getFilePrefix
public String getFilePrefix()
setFilePrefix
public void setFilePrefix(String filePrefix)
getInflightWrites
public Map<DataFileAppender.WriteKey,DataFileAppender.WriteCommand> getInflightWrites()
getLastAppendLocation
public Location getLastAppendLocation()
setLastAppendLocation
public void setLastAppendLocation(Location lastSyncedLocation)
isUseNio
public boolean isUseNio()
setUseNio
public void setUseNio(boolean useNio)
getDirectoryArchive
public File getDirectoryArchive()
setDirectoryArchive
public void setDirectoryArchive(File directoryArchive)
isArchiveDataLogs
public boolean isArchiveDataLogs()
setArchiveDataLogs
public void setArchiveDataLogs(boolean archiveDataLogs)
getCurrentDataFileId
public Integer getCurrentDataFileId()
getFiles
public Set<File> getFiles()
- Get a set of files - only valid after start()
- Returns:
- files currently being used
getDiskSize
public long getDiskSize()
getDiskSizeUntil
public long getDiskSizeUntil(Location startPosition)
Copyright © 2005-2011 Apache Software Foundation. All Rights Reserved.