use of org.neo4j.kernel.impl.store.InvalidIdGeneratorException in project neo4j by neo4j.
the class IdGeneratorImplTest method shouldForceStickyMark.
@Test
public void shouldForceStickyMark() throws Exception {
// GIVEN
try (FileSystemAbstraction fs = new DefaultFileSystemAbstraction()) {
File dir = new File("target/test-data/" + getClass().getName());
fs.mkdirs(dir);
File file = new File(dir, "ids");
fs.deleteFile(file);
IdGeneratorImpl.createGenerator(fs, file, 0, false);
// WHEN opening the id generator, where the jvm crashes right after
executeSubProcess(getClass(), 1, MINUTES, file.getAbsolutePath());
// THEN
try {
IdGeneratorImpl.readHighId(fs, file);
fail("Should have thrown, saying something with sticky generator");
} catch (InvalidIdGeneratorException e) {
// THEN Good
}
}
}
use of org.neo4j.kernel.impl.store.InvalidIdGeneratorException in project neo4j by neo4j.
the class IdGeneratorImpl method readHighIdFromHeader.
private static ByteBuffer readHighIdFromHeader(StoreChannel channel, File fileName) throws IOException {
ByteBuffer buffer = ByteBuffer.allocate(HEADER_SIZE);
int read = channel.read(buffer);
if (read != HEADER_SIZE) {
throw new InvalidIdGeneratorException("Unable to read header, bytes read: " + read);
}
buffer.flip();
byte storageStatus = buffer.get();
if (storageStatus != CLEAN_GENERATOR) {
throw new InvalidIdGeneratorException("Sticky generator[ " + fileName + "] delete this id file and build a new one");
}
return buffer;
}
use of org.neo4j.kernel.impl.store.InvalidIdGeneratorException in project neo4j by neo4j.
the class IdGeneratorImpl method readHeader.
private ByteBuffer readHeader() throws IOException {
try {
ByteBuffer buffer = readHighIdFromHeader(fileChannel, file);
this.highId.set(buffer.getLong());
return buffer;
} catch (InvalidIdGeneratorException e) {
fileChannel.close();
throw e;
}
}
Aggregations