public class FilePageStoreManager extends GridCacheSharedManagerAdapter implements IgnitePageStoreManager
| 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 |
DFLT_STORE_DIR |
static String |
FILE_SUFFIX
File suffix.
|
static String |
INDEX_FILE_NAME |
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 |
beforeCacheGroupStart(CacheGroupDescriptor grpDesc) |
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,
LongAdderMetric 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.
|
long |
metaPageId(int grpId)
Gets meta page ID for specified cache.
|
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)
Reads a page for the given cache ID.
|
void |
read(int grpId,
long pageId,
ByteBuffer pageBuf,
boolean keepCrc)
Will preserve crc in buffer if keepCrc is true.
|
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() |
void |
write(int grpId,
long pageId,
ByteBuffer pageBuf,
int tag)
Writes the page for the given cache ID.
|
PageStore |
writeInternal(int cacheId,
long pageId,
ByteBuffer pageBuf,
int tag,
boolean calculateCrc) |
context, isStopping, kernalStartInfo, kernalStopInfo, log, onDisconnected, onKernalStart, onKernalStart0, onKernalStop, onReconnected, printMemoryStats, start, startInfo, stop, stopInfo, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitonDisconnected, onKernalStart, onKernalStop, onReconnected, printMemoryStats, start, stoppublic 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_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 FilePageStoreManager(GridKernalContext ctx)
ctx - Kernal context.public void start0()
throws IgniteCheckedException
start0 in class GridCacheSharedManagerAdapterIgniteCheckedException - If failed.public void cleanupPersistentSpace(CacheConfiguration cacheConfiguration) throws IgniteCheckedException
cleanupPersistentSpace in interface IgnitePageStoreManagercacheConfiguration - Cache configuration of cache which should be cleanup.IgniteCheckedExceptionpublic void cleanupPersistentSpace()
throws IgniteCheckedException
cleanupPersistentSpace in interface IgnitePageStoreManagerIgniteCheckedExceptionpublic void cleanupPageStoreIfMatch(Predicate<Integer> cacheGrpPred, boolean cleanFiles)
cleanupPageStoreIfMatch in interface IgnitePageStoreManagercacheGrpPred - 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 GridCacheSharedManagerAdaptercancel - Cancel flag.public void onKernalStop0(boolean cancel)
onKernalStop0 in class GridCacheSharedManagerAdaptercancel - Cancel flag.public void onActivate(GridKernalContext kctx) throws IgniteCheckedException
onActivate in interface IgniteChangeGlobalStateSupportkctx - Kernal context.IgniteCheckedException - If failed.public void onDeActivate(GridKernalContext kctx)
onDeActivate in interface IgniteChangeGlobalStateSupportkctx - Kernal context.public void beginRecover()
beginRecover in interface IgnitePageStoreManagerpublic void finishRecover()
throws IgniteCheckedException
finishRecover in interface IgnitePageStoreManagerIgniteCheckedExceptionpublic void initialize(int cacheId,
int partitions,
String workingDir,
LongAdderMetric tracker)
throws IgniteCheckedException
initialize in interface IgnitePageStoreManagercacheId - 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 IgnitePageStoreManagergrpDesc - 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 IgnitePageStoreManagerIgniteCheckedExceptionpublic void storeCacheData(StoredCacheData cacheData, boolean overwrite) throws IgniteCheckedException
storeCacheData in interface IgnitePageStoreManagercacheData - 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 IgnitePageStoreManagergrp - 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 IgnitePageStoreManagergrpId - 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 IgnitePageStoreManagergrpId - 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)
throws IgniteCheckedException
0 if the page is a meta page.read in interface IgnitePageStoreManagergrpId - Cache group ID.pageId - PageID to read.pageBuf - Page buffer to write to.IgniteCheckedException - If failed to read the page.public void read(int grpId,
long pageId,
ByteBuffer pageBuf,
boolean keepCrc)
throws IgniteCheckedException
grpId - Group ID.pageId - Page ID.pageBuf - Page buffer.keepCrc - Keep CRC flag.IgniteCheckedException - If failed.public boolean exists(int grpId,
int partId)
throws IgniteCheckedException
exists in interface IgnitePageStoreManagergrpId - 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 IgnitePageStoreManagergrpId - Cache group ID.partId - Partition ID.buf - Buffer to write to.IgniteCheckedException - If failed.public void write(int grpId,
long pageId,
ByteBuffer pageBuf,
int tag)
throws IgniteCheckedException
0 if the page is a meta page.write in interface IgnitePageStoreManagergrpId - 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 IgnitePageStoreManagergrpId - Cache group ID.pageId - Page ID.IgniteCheckedException - If failed.public PageStore writeInternal(int cacheId, long pageId, ByteBuffer pageBuf, int tag, boolean calculateCrc) throws IgniteCheckedException
cacheId - Cache ID to write.pageId - Page ID.pageBuf - Page buffer.tag - Partition tag (growing 1-based partition file version). Used to validate page is not outdatedcalculateCrc - if False crc calculation will be forcibly skipped.IgniteCheckedException - If IO error occurred.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 IgnitePageStoreManagercacheCfg - Cache configuration.True if work directory already exists.IgniteCheckedException - If failed.public void sync(int grpId,
int partId)
throws IgniteCheckedException
sync in interface IgnitePageStoreManagergrpId - 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 IgnitePageStoreManagergrpId - Cache group ID.partId - Partition ID.IgniteCheckedException - If failed.public long allocatePage(int grpId,
int partId,
byte flags)
throws IgniteCheckedException
allocatePage in interface IgnitePageStoreManagergrpId - Cache group ID.partId - Partition ID. Used only if flags is equal to PageIdAllocator.FLAG_DATA.flags - Page allocation flags.IgniteCheckedException - If IO exception occurred while allocating a page ID.public long metaPageId(int grpId)
metaPageId in interface IgnitePageStoreManagergrpId - Cache group ID.public int pages(int grpId,
int partId)
throws IgniteCheckedException
pages in interface IgnitePageStoreManagergrpId - 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 IgnitePageStoreManagerIgniteCheckedException - If failed.public boolean hasIndexStore(int grpId)
hasIndexStore in interface IgnitePageStoreManagergrpId - Cache group ID.True if index store for given cache group existed before node started.public long pagesAllocated(int grpId)
pagesAllocated in interface IgnitePageStoreManagergrpId - 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 IgnitePageStoreManagercacheData - Cache configuration.IgniteCheckedException - If failed.public Collection<PageStore> getStores(int grpId) throws IgniteCheckedException
grpId - Cache group ID.IgniteCheckedException - If failed.public PageStore getStore(int grpId, int partId) throws IgniteCheckedException
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 beforeCacheGroupStart(CacheGroupDescriptor grpDesc)
beforeCacheGroupStart in interface IgnitePageStoreManagergrpDesc - Cache group descriptor.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.9.1 Release Date : December 9 2020