public class FilePageStoreManager extends GridCacheSharedManagerAdapter implements IgnitePageStoreManager, PageStoreCollection
Modifier and Type | Class and Description |
---|---|
protected static class |
FilePageStoreManager.LongOperationAsyncExecutor
Synchronization wrapper for long operations that should be executed asynchronously
and operations that can not be executed in parallel with long operation.
|
Modifier and Type | Field and Description |
---|---|
static String |
CACHE_DATA_FILENAME |
static String |
CACHE_DATA_TMP_FILENAME |
static String |
CACHE_DIR_PREFIX |
static String |
CACHE_GRP_DIR_PREFIX |
static String |
CORRUPTED_DATA_FILES_MNTC_TASK_NAME
Unique name for corrupted data files maintenance task.
|
static String |
DFLT_STORE_DIR |
static String |
FILE_SUFFIX
File suffix.
|
static String |
INDEX_FILE_NAME |
static String |
INDEX_FILE_PREFIX |
static String |
META_STORAGE_NAME |
static String |
PART_FILE_PREFIX
Partition file prefix.
|
static String |
PART_FILE_TEMPLATE |
static PathMatcher |
TMP_FILE_MATCHER
Matcher for searching of *.tmp files.
|
static String |
TMP_SUFFIX
Suffix for tmp files
|
static String |
ZIP_SUFFIX
Suffix for zip files
|
cctx, diagnosticLog, log
Constructor and Description |
---|
FilePageStoreManager(GridKernalContext ctx) |
Modifier and Type | Method and Description |
---|---|
void |
addConfigurationChangeListener(BiConsumer<String,File> lsnr) |
long |
allocatePage(int grpId,
int partId,
byte flags)
Allocates a page for the given page space.
|
void |
beginRecover()
Invoked before starting checkpoint recover.
|
static String |
cacheDirName(boolean isSharedGroup,
String cacheOrGroupName) |
static String |
cacheDirName(CacheConfiguration<?,?> ccfg) |
File |
cacheWorkDir(boolean isSharedGroup,
String cacheOrGroupName) |
File |
cacheWorkDir(CacheConfiguration<?,?> ccfg) |
static File |
cacheWorkDir(File storeWorkDir,
String cacheDirName) |
boolean |
checkAndInitCacheWorkDir(CacheConfiguration cacheCfg)
Creates and initializes cache work directory retrieved from
cacheCfg . |
void |
cleanupPageStoreIfMatch(Predicate<Integer> cacheGrpPred,
boolean cleanFiles)
Cleanup cache store whether it matches the provided predicate and if matched
store was previously initizlized.
|
void |
cleanupPersistentSpace()
Cleanup persistent space for all caches except metastore.
|
void |
cleanupPersistentSpace(CacheConfiguration cacheConfiguration)
Cleanup persistent space for cache.
|
void |
ensure(int grpId,
int partId) |
boolean |
exists(int grpId,
int partId)
Checks if partition store exists.
|
void |
finishRecover()
Invoked after checkpoint recover is finished.
|
FilePageStoreFactory |
getPageStoreFactory(int grpId,
boolean encrypted) |
FileIOFactory |
getPageStoreFileIoFactory() |
static @NotNull File |
getPartitionFile(File workDir,
String cacheDirName,
int partId) |
static String |
getPartitionFileName(int partId) |
Path |
getPath(boolean isSharedGroup,
String cacheOrGroupName,
int partId) |
PageStore |
getStore(int grpId,
int partId) |
Collection<PageStore> |
getStores(int grpId) |
boolean |
hasIndexStore(int grpId) |
void |
initialize(int cacheId,
int partitions,
String workingDir,
LongConsumer tracker)
Initializes disk store structures.
|
void |
initializeForCache(CacheGroupDescriptor grpDesc,
StoredCacheData cacheData)
Callback called when a cache is starting.
|
void |
initializeForMetastorage()
Initializes disk cache store structures.
|
void |
onActivate(GridKernalContext kctx)
Called when cluster performing activation.
|
void |
onDeActivate(GridKernalContext kctx)
Called when cluster performing deactivation.
|
void |
onKernalStop0(boolean cancel) |
void |
onPartitionCreated(int grpId,
int partId)
Callback called when a partition is created on the local node.
|
void |
onPartitionDestroyed(int grpId,
int partId,
int tag)
Callback called when a partition for the given cache is evicted from the local node.
|
long |
pageOffset(int grpId,
long pageId)
Gets page offset within the page store file.
|
int |
pages(int grpId,
int partId)
Gets total number of allocated pages for the given space.
|
long |
pagesAllocated(int grpId)
Calculates number of pages currently allocated for given cache group.
|
int |
pageSize() |
void |
read(int grpId,
long pageId,
ByteBuffer pageBuf,
boolean keepCrc)
Reads a page for the given cache ID.
|
Map<String,StoredCacheData> |
readCacheConfigurations() |
void |
readConfigurationFiles(List<CacheConfiguration<?,?>> ccfgs,
BiConsumer<CacheConfiguration<?,?>,File> ccfgCons) |
void |
readHeader(int grpId,
int partId,
ByteBuffer buf)
Reads a header of a page store.
|
void |
removeCacheData(StoredCacheData cacheData)
Remove cache configuration data file.
|
void |
removeConfigurationChangeListener(BiConsumer<String,File> lsnr) |
void |
setPageStoreFileIOFactories(FileIOFactory pageStoreFileIoFactory,
FileIOFactory pageStoreV1FileIoFactory) |
void |
shutdownForCacheGroup(CacheGroupContext grp,
boolean destroy)
Callback called when a cache is stopping.
|
void |
start0() |
void |
stop0(boolean cancel) |
void |
storeCacheData(StoredCacheData cacheData,
boolean overwrite) |
void |
sync(int grpId,
int partId)
Makes sure that all previous writes to the store has been written to disk.
|
File |
workDir() |
PageStore |
write(int grpId,
long pageId,
ByteBuffer pageBuf,
int tag,
boolean calculateCrc)
Writes the page for the given cache ID.
|
context, isStopping, kernalStartInfo, kernalStopInfo, log, onDisconnected, onKernalStart, onKernalStart0, onKernalStop, onReconnected, printMemoryStats, start, startInfo, stop, stopInfo, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
onDisconnected, onKernalStart, onKernalStop, onReconnected, printMemoryStats, start, stop
public static final String FILE_SUFFIX
public static final String ZIP_SUFFIX
public static final String TMP_SUFFIX
public static final String PART_FILE_PREFIX
public static final String INDEX_FILE_PREFIX
public static final String INDEX_FILE_NAME
public static final String PART_FILE_TEMPLATE
public static final String CACHE_DIR_PREFIX
public static final String CACHE_GRP_DIR_PREFIX
public static final String CACHE_DATA_FILENAME
public static final String CACHE_DATA_TMP_FILENAME
public static final String DFLT_STORE_DIR
public static final String META_STORAGE_NAME
public static final PathMatcher TMP_FILE_MATCHER
public static final String CORRUPTED_DATA_FILES_MNTC_TASK_NAME
public FilePageStoreManager(GridKernalContext ctx)
ctx
- Kernal context.public void start0() throws IgniteCheckedException
start0
in class GridCacheSharedManagerAdapter
IgniteCheckedException
- If failed.public void cleanupPersistentSpace(CacheConfiguration cacheConfiguration) throws IgniteCheckedException
cleanupPersistentSpace
in interface IgnitePageStoreManager
cacheConfiguration
- Cache configuration of cache which should be cleanup.IgniteCheckedException
public void cleanupPersistentSpace() throws IgniteCheckedException
cleanupPersistentSpace
in interface IgnitePageStoreManager
IgniteCheckedException
public void cleanupPageStoreIfMatch(Predicate<Integer> cacheGrpPred, boolean cleanFiles)
cleanupPageStoreIfMatch
in interface IgnitePageStoreManager
cacheGrpPred
- Predicate to match by id cache group stores to clean.cleanFiles
- True
to delete all persisted files related to particular store.public void stop0(boolean cancel)
stop0
in class GridCacheSharedManagerAdapter
cancel
- Cancel flag.public void onKernalStop0(boolean cancel)
onKernalStop0
in class GridCacheSharedManagerAdapter
cancel
- Cancel flag.public void onActivate(GridKernalContext kctx) throws IgniteCheckedException
onActivate
in interface IgniteChangeGlobalStateSupport
kctx
- Kernal context.IgniteCheckedException
- If failed.public void onDeActivate(GridKernalContext kctx)
onDeActivate
in interface IgniteChangeGlobalStateSupport
kctx
- Kernal context.public void beginRecover()
beginRecover
in interface IgnitePageStoreManager
public void finishRecover() throws IgniteCheckedException
finishRecover
in interface IgnitePageStoreManager
IgniteCheckedException
public void initialize(int cacheId, int partitions, String workingDir, LongConsumer tracker) throws IgniteCheckedException
initialize
in interface IgnitePageStoreManager
cacheId
- Cache id.partitions
- Partitions count.workingDir
- Working directory.tracker
- Allocation tracker.IgniteCheckedException
- If failed.public void initializeForCache(CacheGroupDescriptor grpDesc, StoredCacheData cacheData) throws IgniteCheckedException
initializeForCache
in interface IgnitePageStoreManager
grpDesc
- Cache group descriptor.cacheData
- Cache data of the cache being started.IgniteCheckedException
- If failed to handle cache start callback.public void initializeForMetastorage() throws IgniteCheckedException
initializeForMetastorage
in interface IgnitePageStoreManager
IgniteCheckedException
public void storeCacheData(StoredCacheData cacheData, boolean overwrite) throws IgniteCheckedException
storeCacheData
in interface IgnitePageStoreManager
cacheData
- Cache configuration.overwrite
- Whether stored configuration should be overwritten if it exists.IgniteCheckedException
- If failed.public void addConfigurationChangeListener(BiConsumer<String,File> lsnr)
lsnr
- Instance of listener to add.public void removeConfigurationChangeListener(BiConsumer<String,File> lsnr)
lsnr
- Instance of listener to remove.public void shutdownForCacheGroup(CacheGroupContext grp, boolean destroy) throws IgniteCheckedException
shutdownForCacheGroup
in interface IgnitePageStoreManager
grp
- Cache group being stopped.destroy
- Flag indicating if the cache is being destroyed and data should be cleaned.IgniteCheckedException
- If failed to handle cache destroy callback.public void onPartitionCreated(int grpId, int partId)
onPartitionCreated
in interface IgnitePageStoreManager
grpId
- Cache group ID where the partition is being created.partId
- ID of the partition being created.public void onPartitionDestroyed(int grpId, int partId, int tag) throws IgniteCheckedException
onPartitionDestroyed
in interface IgnitePageStoreManager
grpId
- Cache group ID of the evicted partition.partId
- Partition ID.tag
- Partition tag (growing 1-based partition file version).IgniteCheckedException
- If failed to handle partition destroy callback.public void read(int grpId, long pageId, ByteBuffer pageBuf, boolean keepCrc) throws IgniteCheckedException
0
if the page is a meta page.read
in interface PageReadWriteManager
grpId
- Cache group ID.pageId
- PageID to read.pageBuf
- Page buffer to write to.keepCrc
- Keep CRC flag.IgniteCheckedException
- If failed to read the page.public boolean exists(int grpId, int partId) throws IgniteCheckedException
exists
in interface IgnitePageStoreManager
grpId
- Cache group ID.partId
- Partition ID.True
if partition store exists.IgniteCheckedException
- If failed.public void readHeader(int grpId, int partId, ByteBuffer buf) throws IgniteCheckedException
readHeader
in interface IgnitePageStoreManager
grpId
- Cache group ID.partId
- Partition ID.buf
- Buffer to write to.IgniteCheckedException
- If failed.public PageStore write(int grpId, long pageId, ByteBuffer pageBuf, int tag, boolean calculateCrc) throws IgniteCheckedException
0
if the page is a meta page.write
in interface IgnitePageStoreManager
write
in interface PageReadWriteManager
grpId
- Cache group ID.pageId
- Page ID.pageBuf
- Page buffer to write.IgniteCheckedException
- If failed to write page.public long pageOffset(int grpId, long pageId) throws IgniteCheckedException
pageOffset
in interface IgnitePageStoreManager
grpId
- Cache group ID.pageId
- Page ID.IgniteCheckedException
- If failed.public FilePageStoreFactory getPageStoreFactory(int grpId, boolean encrypted)
grpId
- Cache group id.encrypted
- true
if cache group encryption enabled.@NotNull public static @NotNull File getPartitionFile(File workDir, String cacheDirName, int partId)
workDir
- Cache work directory.cacheDirName
- Cache directory name.partId
- Partition id.public static String getPartitionFileName(int partId)
partId
- Partition id.public boolean checkAndInitCacheWorkDir(CacheConfiguration cacheCfg) throws IgniteCheckedException
cacheCfg
.checkAndInitCacheWorkDir
in interface IgnitePageStoreManager
cacheCfg
- Cache configuration.True
if work directory already exists.IgniteCheckedException
- If failed.public void sync(int grpId, int partId) throws IgniteCheckedException
sync
in interface IgnitePageStoreManager
grpId
- Cache group ID to sync.partId
- Partition ID to sync.IgniteCheckedException
- If IO error occurred while running sync.public void ensure(int grpId, int partId) throws IgniteCheckedException
ensure
in interface IgnitePageStoreManager
grpId
- Cache group ID.partId
- Partition ID.IgniteCheckedException
- If failed.public long allocatePage(int grpId, int partId, byte flags) throws IgniteCheckedException
allocatePage
in interface IgnitePageStoreManager
allocatePage
in interface PageReadWriteManager
grpId
- Cache group ID.partId
- Partition ID. Used only if flags
is not equal to PageIdAllocator.FLAG_IDX
.flags
- Page allocation flags.IgniteCheckedException
- If IO exception occurred while allocating a page ID.public int pages(int grpId, int partId) throws IgniteCheckedException
pages
in interface IgnitePageStoreManager
grpId
- Cache group ID.partId
- Partition ID.IgniteCheckedException
- If failed.public void readConfigurationFiles(List<CacheConfiguration<?,?>> ccfgs, BiConsumer<CacheConfiguration<?,?>,File> ccfgCons)
ccfgs
- List of cache configurations to process.ccfgCons
- Consumer which accepts found configurations files.public Map<String,StoredCacheData> readCacheConfigurations() throws IgniteCheckedException
readCacheConfigurations
in interface IgnitePageStoreManager
IgniteCheckedException
- If failed.public boolean hasIndexStore(int grpId)
hasIndexStore
in interface IgnitePageStoreManager
grpId
- Cache group ID.True
if index store for given cache group existed before node started.public long pagesAllocated(int grpId)
pagesAllocated
in interface IgnitePageStoreManager
grpId
- cache group id.public File workDir()
public File cacheWorkDir(CacheConfiguration<?,?> ccfg)
ccfg
- Cache configuration.public File cacheWorkDir(boolean isSharedGroup, String cacheOrGroupName)
isSharedGroup
- True
if cache is sharing the same `underlying` cache.cacheOrGroupName
- Cache name.public static File cacheWorkDir(File storeWorkDir, String cacheDirName)
cacheDirName
- Cache directory name.public static String cacheDirName(boolean isSharedGroup, String cacheOrGroupName)
isSharedGroup
- True
if cache is sharing the same `underlying` cache.cacheOrGroupName
- Cache name.public static String cacheDirName(CacheConfiguration<?,?> ccfg)
ccfg
- Cache configuration.public void removeCacheData(StoredCacheData cacheData) throws IgniteCheckedException
removeCacheData
in interface IgnitePageStoreManager
cacheData
- Cache configuration.IgniteCheckedException
- If failed.public Collection<PageStore> getStores(int grpId) throws IgniteCheckedException
getStores
in interface PageStoreCollection
grpId
- Cache group ID.IgniteCheckedException
- If failed.public PageStore getStore(int grpId, int partId) throws IgniteCheckedException
getStore
in interface PageStoreCollection
grpId
- Cache group ID.partId
- Partition ID.IgniteCheckedException
- If cache or partition with the given ID was not created.
Note: visible for testing.public void setPageStoreFileIOFactories(FileIOFactory pageStoreFileIoFactory, FileIOFactory pageStoreV1FileIoFactory)
pageStoreFileIoFactory
- File IO factory to override default, may be used for blocked read-write.pageStoreV1FileIoFactory
- File IO factory for reading V1 page store and for fast touching page files
(non blocking).public FileIOFactory getPageStoreFileIoFactory()
public int pageSize()
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.10.0 Release Date : March 10 2021