use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class StoreMigratorTest method shouldNotDoActualStoreMigrationBetween3_0_5_and_next.
@Test
public void shouldNotDoActualStoreMigrationBetween3_0_5_and_next() throws Exception {
// GIVEN a store in vE.H.0 format
File storeDir = directory.directory();
new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDir).setConfig(GraphDatabaseSettings.record_format, HighLimitV3_0_0.NAME).newGraphDatabase().shutdown();
Config config = Config.embeddedDefaults(stringMap(pagecache_memory.name(), "8m"));
try (FileSystemAbstraction fs = new DefaultFileSystemAbstraction();
PageCache pageCache = new ConfiguringPageCacheFactory(fs, config, NULL, PageCursorTracerSupplier.NULL, NullLog.getInstance()).getOrCreatePageCache()) {
// For test code sanity
String fromStoreVersion = StoreVersion.HIGH_LIMIT_V3_0_0.versionString();
Result hasVersionResult = new StoreVersionCheck(pageCache).hasVersion(new File(storeDir, NEO_STORE.fileName(STORE)), fromStoreVersion);
assertTrue(hasVersionResult.actualVersion, hasVersionResult.outcome.isSuccessful());
// WHEN
StoreMigrator migrator = new StoreMigrator(fs, pageCache, config, NullLogService.getInstance(), NO_INDEX_PROVIDER);
MigrationProgressMonitor.Section monitor = mock(MigrationProgressMonitor.Section.class);
File migrationDir = new File(storeDir, "migration");
fs.mkdirs(migrationDir);
migrator.migrate(storeDir, migrationDir, monitor, fromStoreVersion, StoreVersion.HIGH_LIMIT_V3_0_6.versionString());
// THEN
verifyNoMoreInteractions(monitor);
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class BatchingNeoStoresIT method startBatchingNeoStoreWithMetricsPluginEnabled.
@Test
public void startBatchingNeoStoreWithMetricsPluginEnabled() throws Exception {
FileSystemAbstraction fileSystem = fileSystemRule.get();
File storeDir = testDirectory.graphDbDir();
Config config = Config.defaults().with(MapUtil.stringMap(MetricsSettings.metricsEnabled.name(), "true"));
AssertableLogProvider provider = new AssertableLogProvider();
SimpleLogService logService = new SimpleLogService(provider, provider);
try (BatchingNeoStores batchingNeoStores = BatchingNeoStores.batchingNeoStores(fileSystem, storeDir, RecordFormatSelector.defaultFormat(), Configuration.DEFAULT, logService, AdditionalInitialIds.EMPTY, config)) {
// empty block
}
provider.assertNone(AssertableLogProvider.inLog(MetricsExtension.class).any());
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class ReadAheadChannelTest method shouldReturnValueIfSufficientBytesAreBufferedEvenIfEOFHasBeenEncountered.
@Test
public void shouldReturnValueIfSufficientBytesAreBufferedEvenIfEOFHasBeenEncountered() throws Exception {
// Given
FileSystemAbstraction fileSystem = fileSystemRule.get();
StoreChannel storeChannel = fileSystem.open(new File("foo.txt"), "rw");
ByteBuffer buffer = ByteBuffer.allocate(1);
buffer.put((byte) 1);
buffer.flip();
storeChannel.writeAll(buffer);
storeChannel.force(false);
storeChannel.close();
storeChannel = fileSystem.open(new File("foo.txt"), "r");
ReadAheadChannel<StoreChannel> channel = new ReadAheadChannel<>(storeChannel);
try {
channel.getShort();
fail("Should have thrown exception signalling end of file reached");
} catch (ReadPastEndException endOfFile) {
// outstanding
}
assertEquals((byte) 1, channel.get());
try {
channel.get();
fail("Should have thrown exception signalling end of file reached");
} catch (ReadPastEndException endOfFile) {
// outstanding
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class ReadAheadChannelTest method shouldHandleRunningOutOfBytesWhenRequestSpansMultipleFiles.
@Test
public void shouldHandleRunningOutOfBytesWhenRequestSpansMultipleFiles() throws Exception {
// Given
FileSystemAbstraction fileSystem = fileSystemRule.get();
StoreChannel storeChannel1 = fileSystem.open(new File("foo.1"), "rw");
ByteBuffer buffer = ByteBuffer.allocate(2);
buffer.put((byte) 0);
buffer.put((byte) 0);
buffer.flip();
storeChannel1.writeAll(buffer);
storeChannel1.force(false);
storeChannel1.close();
buffer.flip();
StoreChannel storeChannel2 = fileSystem.open(new File("foo.2"), "r");
buffer.put((byte) 0);
buffer.put((byte) 1);
buffer.flip();
storeChannel2.writeAll(buffer);
storeChannel2.force(false);
storeChannel2.close();
storeChannel1 = fileSystem.open(new File("foo.1"), "r");
final StoreChannel storeChannel2Copy = fileSystem.open(new File("foo.2"), "r");
ReadAheadChannel<StoreChannel> channel = new ReadAheadChannel<StoreChannel>(storeChannel1) {
@Override
protected StoreChannel next(StoreChannel channel) throws IOException {
return storeChannel2Copy;
}
};
try {
channel.getLong();
fail("Should have thrown exception signalling end of file reached");
} catch (ReadPastEndException endOfFile) {
// outstanding
}
assertEquals(1, channel.getInt());
try {
channel.get();
fail("Should have thrown exception signalling end of file reached");
} catch (ReadPastEndException endOfFile) {
// outstanding
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class PhysicalLogFileTest method shouldOpenInFreshDirectoryAndFinallyAddHeader.
@Test
public void shouldOpenInFreshDirectoryAndFinallyAddHeader() throws Exception {
// GIVEN
String name = "log";
LifeSupport life = new LifeSupport();
FileSystemAbstraction fs = fileSystemRule.get();
PhysicalLogFiles logFiles = new PhysicalLogFiles(directory.directory(), name, fs);
life.add(new PhysicalLogFile(fs, logFiles, 1000, transactionIdStore::getLastCommittedTransactionId, logVersionRepository, mock(Monitor.class), new LogHeaderCache(10)));
// WHEN
life.start();
life.shutdown();
// THEN
File file = new PhysicalLogFiles(directory.directory(), name, fs).getLogFileForVersion(1L);
LogHeader header = readLogHeader(fs, file);
assertEquals(1L, header.logVersion);
assertEquals(5L, header.lastCommittedTxId);
}
Aggregations