Search in sources :

Example 6 with DefaultIdGeneratorFactory

use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class TestDynamicStore method setUp.

@Before
public void setUp() {
    File storeDir = new File("dynamicstore");
    fs.get().mkdir(storeDir);
    config = config();
    storeFactory = new StoreFactory(storeDir, config, new DefaultIdGeneratorFactory(fs.get()), pageCacheRule.getPageCache(fs.get()), fs.get(), NullLogProvider.getInstance());
}
Also used : DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) File(java.io.File) Before(org.junit.Before)

Example 7 with DefaultIdGeneratorFactory

use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class TestGraphProperties method firstRecordOtherThanZeroIfNotFirst.

@Test
public void firstRecordOtherThanZeroIfNotFirst() throws Exception {
    File storeDir = new File("/store/dir").getAbsoluteFile();
    GraphDatabaseAPI db = (GraphDatabaseAPI) factory.newImpermanentDatabase(storeDir);
    Transaction tx = db.beginTx();
    Node node = db.createNode();
    node.setProperty("name", "Yo");
    tx.success();
    tx.close();
    db.shutdown();
    db = (GraphDatabaseAPI) factory.newImpermanentDatabase(storeDir);
    tx = db.beginTx();
    properties(db).setProperty("test", "something");
    tx.success();
    tx.close();
    db.shutdown();
    Config config = Config.embeddedDefaults(Collections.emptyMap());
    StoreFactory storeFactory = new StoreFactory(storeDir, config, new DefaultIdGeneratorFactory(fs.get()), pageCacheRule.getPageCache(fs.get()), fs.get(), NullLogProvider.getInstance());
    NeoStores neoStores = storeFactory.openAllNeoStores();
    long prop = neoStores.getMetaDataStore().getGraphNextProp();
    assertTrue(prop != 0);
    neoStores.close();
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Transaction(org.neo4j.graphdb.Transaction) Config(org.neo4j.kernel.configuration.Config) Node(org.neo4j.graphdb.Node) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) File(java.io.File) Test(org.junit.Test)

Example 8 with DefaultIdGeneratorFactory

use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class NeoStoresTest method notAllowCreateDynamicStoreWithNegativeBlockSize.

@Test
public void notAllowCreateDynamicStoreWithNegativeBlockSize() {
    Config config = Config.embeddedDefaults();
    StoreFactory sf = new StoreFactory(storeDir, config, new DefaultIdGeneratorFactory(fs.get()), pageCache, fs.get(), NullLogProvider.getInstance());
    exception.expect(IllegalArgumentException.class);
    exception.expectMessage("Block size of dynamic array store should be positive integer.");
    try (NeoStores neoStores = sf.openNeoStores(true)) {
        neoStores.createDynamicArrayStore("someStore", IdType.ARRAY_BLOCK, -2);
    }
}
Also used : Config(org.neo4j.kernel.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) Test(org.junit.Test)

Example 9 with DefaultIdGeneratorFactory

use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class NeoStoresTest method setUpNeoStores.

@Before
public void setUpNeoStores() throws Exception {
    storeDir = dir.graphDbDir();
    Config config = Config.embeddedDefaults();
    pageCache = pageCacheRule.getPageCache(fs.get());
    StoreFactory sf = new StoreFactory(storeDir, config, new DefaultIdGeneratorFactory(fs.get()), pageCache, fs.get(), NullLogProvider.getInstance());
    sf.openAllNeoStores(true).close();
}
Also used : Config(org.neo4j.kernel.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) Before(org.junit.Before)

Example 10 with DefaultIdGeneratorFactory

use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class NeoStoresTest method shouldCloseAllTheStoreEvenIfExceptionsAreThrown.

@Test
public void shouldCloseAllTheStoreEvenIfExceptionsAreThrown() throws Exception {
    // given
    FileSystemAbstraction fileSystem = fs.get();
    Config defaults = Config.embeddedDefaults(singletonMap(counts_store_rotation_timeout.name(), "60m"));
    StoreFactory factory = new StoreFactory(storeDir, defaults, new DefaultIdGeneratorFactory(fileSystem), pageCache, fileSystem, NullLogProvider.getInstance());
    NeoStores neoStore = factory.openAllNeoStores(true);
    // let's hack the counts store so it fails to rotate and hence it fails to close as well...
    final CountsTracker counts = neoStore.getCounts();
    counts.start();
    long nextTxId = neoStore.getMetaDataStore().getLastCommittedTransactionId() + 1;
    AtomicReference<Throwable> exRef = new AtomicReference<>();
    Thread thread = new Thread(() -> {
        try {
            counts.rotate(nextTxId);
        } catch (InterruptedIOException e) {
        // expected due to the interrupted below
        } catch (Throwable e) {
            exRef.set(e);
            throw new RuntimeException(e);
        }
    });
    thread.start();
    // let's wait for the thread to start waiting for the next transaction id
    ThreadTestUtils.awaitThreadState(thread, 500, Thread.State.TIMED_WAITING, Thread.State.WAITING);
    try {
        // when we close the stores...
        neoStore.close();
        fail("should have thrown2");
    } catch (IllegalStateException ex) {
        // then
        assertEquals("Cannot stop in state: rotating", ex.getMessage());
    }
    thread.interrupt();
    thread.join();
    // and the page cache closes with no errors
    pageCache.close();
    // and only InterruptedIOException is thrown in the other thread
    assertNull(exRef.get());
}
Also used : InterruptedIOException(java.io.InterruptedIOException) UncloseableDelegatingFileSystemAbstraction(org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) Config(org.neo4j.kernel.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountsTracker(org.neo4j.kernel.impl.store.counts.CountsTracker) Test(org.junit.Test)

Aggregations

DefaultIdGeneratorFactory (org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory)34 File (java.io.File)18 Config (org.neo4j.kernel.configuration.Config)17 Test (org.junit.Test)13 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)11 Before (org.junit.Before)10 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)8 PageCache (org.neo4j.io.pagecache.PageCache)6 NeoStores (org.neo4j.kernel.impl.store.NeoStores)5 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)4 ArrayList (java.util.ArrayList)3 UncloseableDelegatingFileSystemAbstraction (org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction)2 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)2 PagedFile (org.neo4j.io.pagecache.PagedFile)2 StandalonePageCacheFactory.createPageCache (org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory.createPageCache)2 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)2 NullLogProvider (org.neo4j.logging.NullLogProvider)2 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 PrintStream (java.io.PrintStream)1