use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class RecoveryRequiredCheckerTest method shouldWantToRecoverBrokenStore.
@Test
public void shouldWantToRecoverBrokenStore() throws Exception {
try (FileSystemAbstraction fileSystemAbstraction = createSomeDataAndCrash(storeDir, fileSystem)) {
PageCache pageCache = pageCacheRule.getPageCache(fileSystemAbstraction);
RecoveryRequiredChecker recoverer = new RecoveryRequiredChecker(fileSystemAbstraction, pageCache);
assertThat(recoverer.isRecoveryRequiredAt(storeDir), is(true));
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class RecordStorageEngineTest method mustFlushStoresWithGivenIOLimiter.
@Test
public void mustFlushStoresWithGivenIOLimiter() throws Exception {
IOLimiter limiter = (stamp, completedIOs, swapper) -> 0;
FileSystemAbstraction fs = fsRule.get();
AtomicReference<IOLimiter> observedLimiter = new AtomicReference<>();
PageCache pageCache = new DelegatingPageCache(pageCacheRule.getPageCache(fs)) {
@Override
public void flushAndForce(IOLimiter limiter) throws IOException {
super.flushAndForce(limiter);
observedLimiter.set(limiter);
}
};
RecordStorageEngine engine = storageEngineRule.getWith(fs, pageCache).build();
engine.flushAndForce(limiter);
assertThat(observedLimiter.get(), sameInstance(limiter));
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class ConfigurableStandalonePageCacheFactoryTest method mustAutomaticallyStartEvictionThread.
@Test(timeout = 10000)
public void mustAutomaticallyStartEvictionThread() throws IOException {
try (FileSystemAbstraction fs = new DelegateFileSystemAbstraction(Jimfs.newFileSystem(jimConfig()))) {
File file = new File("/a").getCanonicalFile();
fs.create(file).close();
try (PageCache cache = ConfigurableStandalonePageCacheFactory.createPageCache(fs);
PagedFile pf = cache.map(file, 4096);
PageCursor cursor = pf.io(0, PagedFile.PF_SHARED_WRITE_LOCK)) {
// If the eviction thread has not been started, then this test will block forever.
for (int i = 0; i < 10_000; i++) {
assertTrue(cursor.next());
cursor.putInt(42);
}
}
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class IdGeneratorImplTest method shouldForceStickyMark.
@Test
public void shouldForceStickyMark() throws Exception {
// GIVEN
try (FileSystemAbstraction fs = new DefaultFileSystemAbstraction()) {
File dir = new File("target/test-data/" + getClass().getName());
fs.mkdirs(dir);
File file = new File(dir, "ids");
fs.deleteFile(file);
IdGeneratorImpl.createGenerator(fs, file, 0, false);
// WHEN opening the id generator, where the jvm crashes right after
executeSubProcess(getClass(), 1, MINUTES, file.getAbsolutePath());
// THEN
try {
IdGeneratorImpl.readHighId(fs, file);
fail("Should have thrown, saying something with sticky generator");
} catch (InvalidIdGeneratorException e) {
// THEN Good
}
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class TestGrowingFileMemoryMapping method shouldGrowAFileWhileContinuingToMemoryMapNewRegions.
@Test
public void shouldGrowAFileWhileContinuingToMemoryMapNewRegions() throws Exception {
// don't run on windows because memory mapping doesn't work properly there
assumeTrue(!SystemUtils.IS_OS_WINDOWS);
// given
int NUMBER_OF_RECORDS = 1000000;
File storeDir = testDirectory.graphDbDir();
Config config = Config.embeddedDefaults(stringMap(pagecache_memory.name(), mmapSize(NUMBER_OF_RECORDS, NodeRecordFormat.RECORD_SIZE)));
FileSystemAbstraction fileSystemAbstraction = fileSystemRule.get();
DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fileSystemAbstraction);
PageCache pageCache = pageCacheRule.getPageCache(fileSystemAbstraction, config);
StoreFactory storeFactory = new StoreFactory(storeDir, config, idGeneratorFactory, pageCache, fileSystemAbstraction, NullLogProvider.getInstance());
NeoStores neoStores = storeFactory.openAllNeoStores(true);
NodeStore nodeStore = neoStores.getNodeStore();
// when
int iterations = 2 * NUMBER_OF_RECORDS;
long startingId = nodeStore.nextId();
long nodeId = startingId;
for (int i = 0; i < iterations; i++) {
NodeRecord record = new NodeRecord(nodeId, false, i, 0);
record.setInUse(true);
nodeStore.updateRecord(record);
nodeId = nodeStore.nextId();
}
// then
NodeRecord record = new NodeRecord(0, false, 0, 0);
for (int i = 0; i < iterations; i++) {
record.setId(startingId + i);
nodeStore.getRecord(i, record, NORMAL);
assertTrue("record[" + i + "] should be in use", record.inUse());
assertThat("record[" + i + "] should have nextRelId of " + i, record.getNextRel(), is((long) i));
}
neoStores.close();
}
Aggregations