use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class CommonAbstractStoreTest method recordCursorPinsEachPageItReads.
@Test
public void recordCursorPinsEachPageItReads() throws Exception {
File storeFile = dir.file("a");
RecordingPageCacheTracer tracer = new RecordingPageCacheTracer();
RecordingPageCursorTracer pageCursorTracer = new RecordingPageCursorTracer(Pin.class);
PageCacheRule.PageCacheConfig pageCacheConfig = config().withTracer(tracer).withCursorTracerSupplier(pageCursorTracerSupplier(pageCursorTracer));
PageCache pageCache = pageCacheRule.getPageCache(fileSystemRule.get(), pageCacheConfig, Config.empty());
try (NodeStore store = new NodeStore(storeFile, Config.empty(), new DefaultIdGeneratorFactory(fileSystemRule.get()), pageCache, NullLogProvider.getInstance(), null, Standard.LATEST_RECORD_FORMATS)) {
store.initialise(true);
assertNull(tracer.tryObserve(Event.class));
long nodeId1 = insertNodeRecordAndObservePinEvent(pageCursorTracer, store);
long nodeId2 = insertNodeRecordAndObservePinEvent(pageCursorTracer, store);
try (RecordCursor<NodeRecord> cursor = store.newRecordCursor(store.newRecord())) {
cursor.acquire(0, RecordLoad.NORMAL);
assertTrue(cursor.next(nodeId1));
assertTrue(cursor.next(nodeId2));
}
// Because both nodes hit the same page, the code will only pin the page once and thus only emit one pin
// event. This pin event will not be observable until after we have closed the cursor. We could
// alternatively have chosen nodeId2 to be on a different page than nodeId1. In that case, the pin event
// for nodeId1 would have been visible after our call to cursor.next( nodeId2 ).
assertNotNull(pageCursorTracer.tryObserve(Pin.class));
assertNull(pageCursorTracer.tryObserve(Event.class));
}
}
use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class NeoStoresTest method impossibleToGetStoreFromClosedNeoStoresContainer.
@Test
public void impossibleToGetStoreFromClosedNeoStoresContainer() {
Config config = Config.embeddedDefaults();
StoreFactory sf = new StoreFactory(storeDir, config, new DefaultIdGeneratorFactory(fs.get()), pageCache, fs.get(), NullLogProvider.getInstance());
NeoStores neoStores = sf.openAllNeoStores(true);
assertNotNull(neoStores.getMetaDataStore());
neoStores.close();
exception.expect(IllegalStateException.class);
exception.expectMessage("Specified store was already closed.");
neoStores.getMetaDataStore();
}
use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class NeoStoresTest method setVersion.
@Test
public void setVersion() throws Exception {
FileSystemAbstraction fileSystem = fs.get();
File storeDir = new File("target/test-data/set-version").getAbsoluteFile();
createTestDatabase(fileSystem, storeDir).shutdown();
assertEquals(0, MetaDataStore.setRecord(pageCache, new File(storeDir, MetaDataStore.DEFAULT_NAME).getAbsoluteFile(), Position.LOG_VERSION, 10));
assertEquals(10, MetaDataStore.setRecord(pageCache, new File(storeDir, MetaDataStore.DEFAULT_NAME).getAbsoluteFile(), Position.LOG_VERSION, 12));
Config config = Config.embeddedDefaults();
StoreFactory sf = new StoreFactory(storeDir, config, new DefaultIdGeneratorFactory(fileSystem), pageCache, fileSystem, NullLogProvider.getInstance());
NeoStores neoStores = sf.openAllNeoStores();
assertEquals(12, neoStores.getMetaDataStore().getCurrentLogVersion());
neoStores.close();
}
use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class NeoStoresTest method impossibleToGetNotRequestedStore.
@Test
public void impossibleToGetNotRequestedStore() {
Config config = Config.embeddedDefaults();
StoreFactory sf = new StoreFactory(storeDir, config, new DefaultIdGeneratorFactory(fs.get()), pageCache, fs.get(), NullLogProvider.getInstance());
NeoStores neoStores = sf.openNeoStores(true, StoreType.NODE_LABEL);
exception.expect(IllegalStateException.class);
exception.expectMessage("Specified store was not initialized. Please specify " + StoreType.META_DATA.name() + " as one of the stores types that should be open to be able to use it.");
try {
neoStores.getMetaDataStore();
} finally {
neoStores.close();
}
}
use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class NeoStoresTest method testSetLatestConstraintTx.
@Test
public void testSetLatestConstraintTx() throws Exception {
// given
Config config = Config.embeddedDefaults();
StoreFactory sf = new StoreFactory(dir.directory(), config, new DefaultIdGeneratorFactory(fs.get()), pageCacheRule.getPageCache(fs.get()), fs.get(), NullLogProvider.getInstance());
// when
NeoStores neoStores = sf.openAllNeoStores(true);
MetaDataStore metaDataStore = neoStores.getMetaDataStore();
// then the default is 0
assertEquals(0L, metaDataStore.getLatestConstraintIntroducingTx());
// when
metaDataStore.setLatestConstraintIntroducingTx(10L);
// then
assertEquals(10L, metaDataStore.getLatestConstraintIntroducingTx());
// when
neoStores.flush(IOLimiter.unlimited());
neoStores.close();
neoStores = sf.openAllNeoStores();
// then the value should have been stored
assertEquals(10L, neoStores.getMetaDataStore().getLatestConstraintIntroducingTx());
neoStores.close();
}
Aggregations