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