/** * A copy constructor. All the fields are copied from the copied {@code igfsFile}, but the {@code groupBlockSize} * which is specified separately. * * @param igfsFile The file to copy. * @param grpBlockSize Group block size. */ public IgfsFileImpl(IgfsFile igfsFile, long grpBlockSize) { A.notNull(igfsFile, "igfsFile"); this.path = igfsFile.path(); this.fileId = igfsFile instanceof IgfsFileImpl ? ((IgfsFileImpl)igfsFile).fileId : IgniteUuid.randomUuid(); this.blockSize = igfsFile.blockSize(); this.len = igfsFile.length(); this.grpBlockSize = igfsFile.isFile() ? grpBlockSize : 0L; this.props = igfsFile.properties(); this.accessTime = igfsFile.accessTime(); this.modificationTime = igfsFile.modificationTime(); this.flags = IgfsUtils.flags(igfsFile.isDirectory(), igfsFile.isFile()); }
/** * Ensure that a DUAL mode file is not propagated to eviction policy * * @throws Exception If failed. */ @Test public void testFileDualExclusion() throws Exception { start(); evictPlc.setExcludePaths(Collections.singleton(FILE_RMT.toString())); // Create file in primary mode. It must not be propagated to eviction policy. igfsPrimary.create(FILE_RMT, true).close(); checkEvictionPolicy(0, 0); int blockSize = igfsPrimary.info(FILE_RMT).blockSize(); append(FILE_RMT, blockSize); checkEvictionPolicy(0, 0); read(FILE_RMT, 0, blockSize); checkEvictionPolicy(0, 0); }
/** * Test how evictions are handled for a file working in PRIMARY mode. * * @throws Exception If failed. */ @Test public void testFilePrimary() throws Exception { start(); // Create file in primary mode. It must not be propagated to eviction policy. igfsPrimary.create(FILE, true).close(); checkEvictionPolicy(0, 0); int blockSize = igfsPrimary.info(FILE).blockSize(); append(FILE, blockSize); checkEvictionPolicy(0, 0); read(FILE, 0, blockSize); checkEvictionPolicy(0, 0); }
/** * Test how evictions are handled for a file working in PRIMARY mode. * * @throws Exception If failed. */ @Test public void testFileDual() throws Exception { start(); igfsPrimary.create(FILE_RMT, true).close(); checkEvictionPolicy(0, 0); int blockSize = igfsPrimary.info(FILE_RMT).blockSize(); // File write. append(FILE_RMT, blockSize); checkEvictionPolicy(1, blockSize); // One more write. append(FILE_RMT, blockSize); checkEvictionPolicy(2, blockSize * 2); // Read. read(FILE_RMT, 0, blockSize); checkEvictionPolicy(2, blockSize * 2); }
int blockSize = desc.blockSize();
/** * Test eviction caused by too much blocks. * * @throws Exception If failed. */ @Test public void testBlockCountEviction() throws Exception { start(); int blockCnt = 3; evictPlc.setMaxBlocks(blockCnt); igfsPrimary.create(FILE_RMT, true).close(); checkEvictionPolicy(0, 0); int blockSize = igfsPrimary.info(FILE_RMT).blockSize(); // Write blocks up to the limit. append(FILE_RMT, blockSize * blockCnt); checkEvictionPolicy(blockCnt, blockCnt * blockSize); // Write one more block what should cause eviction. append(FILE_RMT, blockSize); checkEvictionPolicy(blockCnt, blockCnt * blockSize); // Read the first block. read(FILE_RMT, 0, blockSize); checkEvictionPolicy(blockCnt, blockCnt * blockSize); checkMetrics(1, 1); }
int blockSize = igfsPrimary.info(FILE_RMT).blockSize();
/** * A copy constructor. All the fields are copied from the copied {@code igfsFile}, but the {@code groupBlockSize} * which is specified separately. * * @param igfsFile The file to copy. * @param grpBlockSize Group block size. */ public IgfsFileImpl(IgfsFile igfsFile, long grpBlockSize) { A.notNull(igfsFile, "igfsFile"); this.path = igfsFile.path(); this.fileId = igfsFile instanceof IgfsFileImpl ? ((IgfsFileImpl)igfsFile).fileId : IgniteUuid.randomUuid(); this.blockSize = igfsFile.blockSize(); this.len = igfsFile.length(); this.grpBlockSize = igfsFile.isFile() ? grpBlockSize : 0L; this.props = igfsFile.properties(); this.accessTime = igfsFile.accessTime(); this.modificationTime = igfsFile.modificationTime(); this.flags = IgfsUtils.flags(igfsFile.isDirectory(), igfsFile.isFile()); }