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());
}
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();
}
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);
}
}
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();
}
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());
}
Aggregations