Search in sources :

Example 11 with UnderlyingStorageException

use of org.neo4j.kernel.impl.store.UnderlyingStorageException in project neo4j by neo4j.

the class IdGeneratorImpl method close.

/**
     * Closes the id generator flushing defragged ids in memory to file. The
     * file will be truncated to the minimal size required to hold all defragged
     * ids and it will be marked as clean (not sticky).
     * <p>
     * An invoke to the <CODE>nextId</CODE> or <CODE>freeId</CODE> after
     * this method has been invoked will result in an <CODE>IOException</CODE>
     * since the highest returned id has been set to a negative value.
     */
@Override
public synchronized void close() {
    if (isClosed()) {
        return;
    }
    try {
        // first write out free ids, then mark as clean
        keeper.close();
        ByteBuffer buffer = ByteBuffer.allocate(HEADER_SIZE);
        writeHeader(buffer);
        fileChannel.force(false);
        markAsCleanlyClosed(buffer);
        closeChannel();
    } catch (IOException e) {
        throw new UnderlyingStorageException("Unable to close id generator " + file, e);
    }
}
Also used : IOException(java.io.IOException) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException) ByteBuffer(java.nio.ByteBuffer)

Example 12 with UnderlyingStorageException

use of org.neo4j.kernel.impl.store.UnderlyingStorageException in project neo4j by neo4j.

the class PositionToRecoverFromTest method shouldFailIfThereAreNoCheckPointsAndOldestLogVersionInNotZero.

@Test
public void shouldFailIfThereAreNoCheckPointsAndOldestLogVersionInNotZero() throws Throwable {
    // given
    long oldestLogVersionFound = 1L;
    when(finder.find(logVersion)).thenReturn(new LatestCheckPoint(null, true, 10L, oldestLogVersionFound));
    // when
    try {
        new PositionToRecoverFrom(finder, monitor).apply(logVersion);
    } catch (UnderlyingStorageException ex) {
        // then
        final String expectedMessage = "No check point found in any log file from version " + oldestLogVersionFound + " to " + logVersion;
        assertEquals(expectedMessage, ex.getMessage());
    }
}
Also used : LatestCheckPoint(org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException) Test(org.junit.Test)

Example 13 with UnderlyingStorageException

use of org.neo4j.kernel.impl.store.UnderlyingStorageException in project neo4j by neo4j.

the class RecordStorageEngineTest method executeFailingTransaction.

private Exception executeFailingTransaction(RecordStorageEngine engine) throws IOException {
    Exception applicationError = new UnderlyingStorageException("No space left on device");
    TransactionToApply txToApply = newTransactionThatFailsWith(applicationError);
    try {
        engine.apply(txToApply, TransactionApplicationMode.INTERNAL);
        fail("Exception expected");
    } catch (Exception e) {
        assertSame(applicationError, Exceptions.rootCause(e));
    }
    return applicationError;
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException) IOException(java.io.IOException)

Aggregations

UnderlyingStorageException (org.neo4j.kernel.impl.store.UnderlyingStorageException)13 IOException (java.io.IOException)10 ByteBuffer (java.nio.ByteBuffer)4 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 IndexEntryConflictException (org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)2 File (java.io.File)1 UncheckedIOException (java.io.UncheckedIOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Set (java.util.Set)1 Function (java.util.function.Function)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Stream (java.util.stream.Stream)1 Nonnull (javax.annotation.Nonnull)1 Matchers.hasItems (org.hamcrest.Matchers.hasItems)1 Matchers.not (org.hamcrest.Matchers.not)1