use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class SingleFilePageSwapperTest method setUp.
@Before
public void setUp() throws IOException {
file = new File("file").getCanonicalFile();
ephemeralFileSystem = new EphemeralFileSystemAbstraction();
fileSystem = new DefaultFileSystemAbstraction();
}
use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class EphemeralFileSystemRule method snapshot.
public EphemeralFileSystemAbstraction snapshot(Runnable action) throws Exception {
EphemeralFileSystemAbstraction snapshot = fs.snapshot();
try {
action.run();
} finally {
fs.close();
fs = snapshot;
}
return fs;
}
use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class StateRecoveryManagerTest method shouldFailIfBothFilesAreEmpty.
@Test
public void shouldFailIfBothFilesAreEmpty() throws Exception {
// given
EphemeralFileSystemAbstraction fsa = fileSystemRule.get();
fsa.mkdir(testDir.directory());
File fileA = fileA();
fsa.create(fileA);
File fileB = fileB();
fsa.create(fileB);
StateRecoveryManager<Long> manager = new StateRecoveryManager<>(fsa, new LongMarshal());
try {
// when
StateRecoveryManager.RecoveryStatus recoveryStatus = manager.recover(fileA, fileB);
fail();
} catch (IllegalStateException ex) {
// then
// expected
}
}
use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class StateRecoveryManagerTest method shouldReturnTheEmptyFileAsPreviouslyInactiveWhenActiveContainsCorruptEntry.
@Test
public void shouldReturnTheEmptyFileAsPreviouslyInactiveWhenActiveContainsCorruptEntry() throws Exception {
// given
EphemeralFileSystemAbstraction fsa = fileSystemRule.get();
fsa.mkdir(testDir.directory());
File fileA = fileA();
StoreChannel channel = fsa.create(fileA);
ByteBuffer buffer = writeLong(999);
channel.writeAll(buffer);
channel.force(false);
File fileB = fileB();
channel = fsa.create(fileB);
channel.close();
StateRecoveryManager<Long> manager = new StateRecoveryManager<>(fsa, new LongMarshal());
// when
final StateRecoveryManager.RecoveryStatus recoveryStatus = manager.recover(fileA, fileB);
// then
assertEquals(999L, recoveryStatus.recoveredState());
assertEquals(fileB, recoveryStatus.activeFile());
}
use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class StateRecoveryManagerTest method shouldReturnTheFullFileAsPreviouslyInactiveWhenActiveContainsCorruptEntry.
@Test
public void shouldReturnTheFullFileAsPreviouslyInactiveWhenActiveContainsCorruptEntry() throws Exception {
// given
EphemeralFileSystemAbstraction fsa = fileSystemRule.get();
fsa.mkdir(testDir.directory());
File fileA = fileA();
StoreChannel channel = fsa.create(fileA);
ByteBuffer buffer = writeLong(42);
channel.writeAll(buffer);
channel.force(false);
buffer.clear();
// extraneous bytes
buffer.putLong(101);
buffer.flip();
channel.writeAll(buffer);
channel.force(false);
File fileB = fileB();
fsa.create(fileB);
StateRecoveryManager<Long> manager = new StateRecoveryManager<>(fsa, new LongMarshal());
// when
final StateRecoveryManager.RecoveryStatus recoveryStatus = manager.recover(fileA, fileB);
// then
assertEquals(fileB, recoveryStatus.activeFile());
}
Aggregations