Search in sources :

Example 1 with ReadOnlyDbException

use of org.neo4j.kernel.api.exceptions.ReadOnlyDbException in project neo4j by neo4j.

the class IndexStatisticsStoreTest method shouldNotStartWithoutFileIfReadOnly.

@Test
void shouldNotStartWithoutFileIfReadOnly() {
    final IndexStatisticsStore indexStatisticsStore = new IndexStatisticsStore(pageCache, testDirectory.file("non-existing"), immediate(), readOnly(), DEFAULT_DATABASE_NAME, PageCacheTracer.NULL);
    final Exception e = assertThrows(Exception.class, indexStatisticsStore::init);
    assertTrue(Exceptions.contains(e, t -> t instanceof ReadOnlyDbException));
    assertTrue(Exceptions.contains(e, t -> t instanceof TreeFileNotFoundException));
    assertTrue(Exceptions.contains(e, t -> t instanceof IllegalStateException));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) DatabaseReadOnlyChecker.readOnly(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.readOnly) RandomExtension(org.neo4j.test.extension.RandomExtension) CursorContext(org.neo4j.io.pagecache.context.CursorContext) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TreeFileNotFoundException(org.neo4j.index.internal.gbptree.TreeFileNotFoundException) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) DEFAULT_DATABASE_NAME(org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) ReadOnlyDbException(org.neo4j.kernel.api.exceptions.ReadOnlyDbException) Inject(org.neo4j.test.extension.Inject) RandomRule(org.neo4j.test.rule.RandomRule) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) Exceptions(org.neo4j.internal.helpers.Exceptions) PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer) PageCache(org.neo4j.io.pagecache.PageCache) IndexSample(org.neo4j.kernel.api.index.IndexSample) ReporterFactories.noopReporterFactory(org.neo4j.annotations.documented.ReporterFactories.noopReporterFactory) DatabaseReadOnlyChecker.writable(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.writable) TestDirectory(org.neo4j.test.rule.TestDirectory) IOException(java.io.IOException) EphemeralPageCacheExtension(org.neo4j.test.extension.pagecache.EphemeralPageCacheExtension) Test(org.junit.jupiter.api.Test) RecoveryCleanupWorkCollector.immediate(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.immediate) AfterEach(org.junit.jupiter.api.AfterEach) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Race.throwing(org.neo4j.test.Race.throwing) Race(org.neo4j.test.Race) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) ReadOnlyDbException(org.neo4j.kernel.api.exceptions.ReadOnlyDbException) TreeFileNotFoundException(org.neo4j.index.internal.gbptree.TreeFileNotFoundException) TreeFileNotFoundException(org.neo4j.index.internal.gbptree.TreeFileNotFoundException) ReadOnlyDbException(org.neo4j.kernel.api.exceptions.ReadOnlyDbException) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Example 2 with ReadOnlyDbException

use of org.neo4j.kernel.api.exceptions.ReadOnlyDbException in project neo4j by neo4j.

the class GBPTreeGenericCountsStoreTest method shouldNotStartWithoutFileIfReadOnly.

@Test
void shouldNotStartWithoutFileIfReadOnly() {
    final Path file = directory.file("non-existing");
    final IllegalStateException e = assertThrows(IllegalStateException.class, () -> new GBPTreeCountsStore(pageCache, file, fs, immediate(), CountsBuilder.EMPTY, readOnly(), PageCacheTracer.NULL, NO_MONITOR, DEFAULT_DATABASE_NAME, randomMaxCacheSize()));
    assertTrue(Exceptions.contains(e, t -> t instanceof ReadOnlyDbException));
    assertTrue(Exceptions.contains(e, t -> t instanceof TreeFileNotFoundException));
    assertTrue(Exceptions.contains(e, t -> t instanceof IllegalStateException));
}
Also used : Path(java.nio.file.Path) BeforeEach(org.junit.jupiter.api.BeforeEach) NoSuchFileException(java.nio.file.NoSuchFileException) DatabaseReadOnlyChecker.readOnly(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.readOnly) RandomExtension(org.neo4j.test.extension.RandomExtension) CursorContext(org.neo4j.io.pagecache.context.CursorContext) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Random(java.util.Random) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) ANY_LABEL(org.neo4j.token.api.TokenConstants.ANY_LABEL) ByteBuffer(java.nio.ByteBuffer) NO_MONITOR(org.neo4j.internal.counts.GBPTreeCountsStore.NO_MONITOR) DEFAULT_DATABASE_NAME(org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME) Future(java.util.concurrent.Future) StoreChannel(org.neo4j.io.fs.StoreChannel) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) RandomRule(org.neo4j.test.rule.RandomRule) Map(java.util.Map) Mockito.doAnswer(org.mockito.Mockito.doAnswer) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) NULL(org.neo4j.io.pagecache.context.CursorContext.NULL) Path(java.nio.file.Path) Exceptions(org.neo4j.internal.helpers.Exceptions) PageCache(org.neo4j.io.pagecache.PageCache) EMPTY_REBUILD(org.neo4j.internal.counts.GBPTreeGenericCountsStore.EMPTY_REBUILD) ArrayQueueOutOfOrderSequence(org.neo4j.util.concurrent.ArrayQueueOutOfOrderSequence) OtherThreadExecutor.command(org.neo4j.test.OtherThreadExecutor.command) DatabaseReadOnlyChecker.writable(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.writable) StandardOpenOption(java.nio.file.StandardOpenOption) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) TestDirectory(org.neo4j.test.rule.TestDirectory) String.format(java.lang.String.format) Test(org.junit.jupiter.api.Test) INSTANCE(org.neo4j.memory.EmptyMemoryTracker.INSTANCE) GBPTreeCountsStore.nodeKey(org.neo4j.internal.counts.GBPTreeCountsStore.nodeKey) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Rebuilder(org.neo4j.internal.counts.GBPTreeGenericCountsStore.Rebuilder) EMPTY_LONG_ARRAY(org.apache.commons.lang3.ArrayUtils.EMPTY_LONG_ARRAY) Race.throwing(org.neo4j.test.Race.throwing) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) DatabaseReadOnlyChecker(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker) Assertions.assertDoesNotThrow(org.junit.jupiter.api.Assertions.assertDoesNotThrow) Mockito.mock(org.mockito.Mockito.mock) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) OutOfOrderSequence(org.neo4j.util.concurrent.OutOfOrderSequence) TreeFileNotFoundException(org.neo4j.index.internal.gbptree.TreeFileNotFoundException) HashMap(java.util.HashMap) MINUTES(java.util.concurrent.TimeUnit.MINUTES) BASE_TX_ID(org.neo4j.storageengine.api.TransactionIdStore.BASE_TX_ID) AtomicReference(java.util.concurrent.atomic.AtomicReference) ConcurrentMap(java.util.concurrent.ConcurrentMap) ReadOnlyDbException(org.neo4j.kernel.api.exceptions.ReadOnlyDbException) Inject(org.neo4j.test.extension.Inject) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) GBPTreeCountsStore.relationshipKey(org.neo4j.internal.counts.GBPTreeCountsStore.relationshipKey) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) OtherThreadExecutor(org.neo4j.test.OtherThreadExecutor) MemoryTracker(org.neo4j.memory.MemoryTracker) PageCacheExtension(org.neo4j.test.extension.pagecache.PageCacheExtension) IOException(java.io.IOException) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) RecoveryCleanupWorkCollector.immediate(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.immediate) AfterEach(org.junit.jupiter.api.AfterEach) ANY_RELATIONSHIP_TYPE(org.neo4j.token.api.TokenConstants.ANY_RELATIONSHIP_TYPE) Race(org.neo4j.test.Race) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) ReadOnlyDbException(org.neo4j.kernel.api.exceptions.ReadOnlyDbException) TreeFileNotFoundException(org.neo4j.index.internal.gbptree.TreeFileNotFoundException) Test(org.junit.jupiter.api.Test)

Example 3 with ReadOnlyDbException

use of org.neo4j.kernel.api.exceptions.ReadOnlyDbException in project neo4j by neo4j.

the class IndexedIdGeneratorTest method shouldNotStartWithoutFileIfReadOnly.

@Test
void shouldNotStartWithoutFileIfReadOnly() {
    Path file = directory.file("non-existing");
    final IllegalStateException e = assertThrows(IllegalStateException.class, () -> new IndexedIdGenerator(pageCache, file, immediate(), IdType.LABEL_TOKEN, false, () -> 0, MAX_ID, readOnly(), Config.defaults(), DEFAULT_DATABASE_NAME, NULL));
    assertTrue(Exceptions.contains(e, t -> t instanceof ReadOnlyDbException));
    assertTrue(Exceptions.contains(e, t -> t instanceof TreeFileNotFoundException));
    assertTrue(Exceptions.contains(e, t -> t instanceof IllegalStateException));
}
Also used : Path(java.nio.file.Path) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) DatabaseReadOnlyChecker.readOnly(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.readOnly) LongSupplier(java.util.function.LongSupplier) RandomExtension(org.neo4j.test.extension.RandomExtension) CursorContext(org.neo4j.io.pagecache.context.CursorContext) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Random(java.util.Random) Config(org.neo4j.configuration.Config) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) MutableLongList(org.eclipse.collections.api.list.primitive.MutableLongList) DEFAULT_DATABASE_NAME(org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME) Future(java.util.concurrent.Future) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) RandomRule(org.neo4j.test.rule.RandomRule) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) IdValidator(org.neo4j.internal.id.IdValidator) NULL(org.neo4j.io.pagecache.context.CursorContext.NULL) Path(java.nio.file.Path) Exceptions(org.neo4j.internal.helpers.Exceptions) PageCache(org.neo4j.io.pagecache.PageCache) DatabaseReadOnlyChecker.writable(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.writable) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) TestDirectory(org.neo4j.test.rule.TestDirectory) Test(org.junit.jupiter.api.Test) IdType(org.neo4j.internal.id.IdType) Stream(java.util.stream.Stream) Sets.immutable(org.eclipse.collections.impl.factory.Sets.immutable) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) Race.throwing(org.neo4j.test.Race.throwing) DatabaseReadOnlyChecker(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker) Assertions.assertDoesNotThrow(org.junit.jupiter.api.Assertions.assertDoesNotThrow) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Mockito.mock(org.mockito.Mockito.mock) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TreeFileNotFoundException(org.neo4j.index.internal.gbptree.TreeFileNotFoundException) NO_FREE_IDS(org.neo4j.internal.id.FreeIds.NO_FREE_IDS) IDS_PER_ENTRY(org.neo4j.internal.id.indexed.IndexedIdGenerator.IDS_PER_ENTRY) LongList(org.eclipse.collections.api.list.primitive.LongList) FreeIds(org.neo4j.internal.id.FreeIds) Function(java.util.function.Function) ReadOnlyDbException(org.neo4j.kernel.api.exceptions.ReadOnlyDbException) Inject(org.neo4j.test.extension.Inject) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) OtherThreadExecutor(org.neo4j.test.OtherThreadExecutor) Sets(org.eclipse.collections.api.factory.Sets) IdCapacityExceededException(org.neo4j.internal.id.IdCapacityExceededException) ValueSource(org.junit.jupiter.params.provider.ValueSource) ReporterFactories.noopReporterFactory(org.neo4j.annotations.documented.ReporterFactories.noopReporterFactory) Barrier(org.neo4j.test.Barrier) PageCacheExtension(org.neo4j.test.extension.pagecache.PageCacheExtension) MutableLongIterator(org.eclipse.collections.api.iterator.MutableLongIterator) Iterator(java.util.Iterator) Collections.emptySet(java.util.Collections.emptySet) Files(java.nio.file.Files) IOException(java.io.IOException) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) RecoveryCleanupWorkCollector.immediate(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.immediate) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Executable(org.junit.jupiter.api.function.Executable) Marker(org.neo4j.internal.id.IdGenerator.Marker) IdRange(org.neo4j.internal.id.IdRange) Comparator(java.util.Comparator) Race(org.neo4j.test.Race) ReadOnlyDbException(org.neo4j.kernel.api.exceptions.ReadOnlyDbException) TreeFileNotFoundException(org.neo4j.index.internal.gbptree.TreeFileNotFoundException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

IOException (java.io.IOException)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 AfterEach (org.junit.jupiter.api.AfterEach)3 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)3 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)3 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 Test (org.junit.jupiter.api.Test)3 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)3 DEFAULT_DATABASE_NAME (org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME)3 DatabaseReadOnlyChecker.readOnly (org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.readOnly)3 DatabaseReadOnlyChecker.writable (org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.writable)3 RecoveryCleanupWorkCollector.immediate (org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.immediate)3 TreeFileNotFoundException (org.neo4j.index.internal.gbptree.TreeFileNotFoundException)3 Exceptions (org.neo4j.internal.helpers.Exceptions)3 PageCache (org.neo4j.io.pagecache.PageCache)3 CursorContext (org.neo4j.io.pagecache.context.CursorContext)3 DefaultPageCacheTracer (org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer)3 ReadOnlyDbException (org.neo4j.kernel.api.exceptions.ReadOnlyDbException)3 Race (org.neo4j.test.Race)3