use of org.neo4j.storageengine.api.StoreFileMetadata in project neo4j by neo4j.
the class NeoStoreFileListingTest method shouldCloseIndexAndLabelScanSnapshots.
@Test
public void shouldCloseIndexAndLabelScanSnapshots() throws Exception {
// Given
LabelScanStore labelScanStore = mock(LabelScanStore.class);
IndexingService indexingService = mock(IndexingService.class);
LegacyIndexProviderLookup legacyIndexes = mock(LegacyIndexProviderLookup.class);
when(legacyIndexes.all()).thenReturn(Collections.emptyList());
File storeDir = mock(File.class);
filesInStoreDirAre(storeDir, STANDARD_STORE_DIR_FILES, STANDARD_STORE_DIR_DIRECTORIES);
StorageEngine storageEngine = mock(StorageEngine.class);
NeoStoreFileListing fileListing = new NeoStoreFileListing(storeDir, labelScanStore, indexingService, legacyIndexes, storageEngine);
ResourceIterator<File> scanSnapshot = scanStoreFilesAre(labelScanStore, new String[] { "blah/scan.store", "scan.more" });
ResourceIterator<File> indexSnapshot = indexFilesAre(indexingService, new String[] { "schema/index/my.index" });
ResourceIterator<StoreFileMetadata> result = fileListing.listStoreFiles(false);
// When
result.close();
// Then
verify(scanSnapshot).close();
verify(indexSnapshot).close();
}
use of org.neo4j.storageengine.api.StoreFileMetadata in project neo4j by neo4j.
the class NeoStoreFileListingTest method shouldListNeostoreDbLast.
@Test
public void shouldListNeostoreDbLast() throws Exception {
Boolean[] foundStoreType = new Boolean[StoreType.values().length];
boolean foundTxLogs = false;
final ResourceIterator<StoreFileMetadata> storeFiles = neoStoreDataSource.listStoreFiles(true);
while (storeFiles.hasNext()) {
final StoreFileMetadata storeFile = storeFiles.next();
if (storeFile.storeType().isPresent()) {
StoreType storeType = storeFile.storeType().get();
foundStoreType[storeType.ordinal()] = true;
if (storeType == StoreType.META_DATA) {
Arrays.stream(foundStoreType).forEach(Assert::assertTrue);
assertTrue("Transaction logs was not listed before neostore.db", foundTxLogs);
}
} else if (transactionLogFile(storeFile.file().getName())) {
foundTxLogs = true;
}
}
}
use of org.neo4j.storageengine.api.StoreFileMetadata in project neo4j by neo4j.
the class RecordStorageEngine method listStorageFiles.
@Override
public Collection<StoreFileMetadata> listStorageFiles() {
List<StoreFileMetadata> files = new ArrayList<>();
for (StoreType type : StoreType.values()) {
if (type.equals(StoreType.COUNTS)) {
addCountStoreFiles(files);
} else {
final RecordStore<AbstractBaseRecord> recordStore = neoStores.getRecordStore(type);
StoreFileMetadata metadata = new StoreFileMetadata(recordStore.getStorageFileName(), Optional.of(type), recordStore.getRecordSize());
files.add(metadata);
}
}
return files;
}
use of org.neo4j.storageengine.api.StoreFileMetadata in project neo4j by neo4j.
the class RecordStorageEngine method addCountStoreFiles.
private void addCountStoreFiles(List<StoreFileMetadata> files) {
Iterable<File> countStoreFiles = neoStores.getCounts().allFiles();
for (File countStoreFile : countStoreFiles) {
StoreFileMetadata countStoreFileMetadata = new StoreFileMetadata(countStoreFile, Optional.of(StoreType.COUNTS), RecordFormat.NO_RECORD_SIZE);
files.add(countStoreFileMetadata);
}
}
use of org.neo4j.storageengine.api.StoreFileMetadata in project neo4j by neo4j.
the class GetStoreRequestHandler method channelRead0.
@Override
protected void channelRead0(ChannelHandlerContext ctx, GetStoreRequest msg) throws Exception {
if (!msg.expectedStoreId().equalToKernelStoreId(dataSource.get().getStoreId())) {
endStoreCopy(SUCCESS, ctx, -1);
} else {
CheckPointer checkPointer = checkPointerSupplier.get();
long lastCheckPointedTx;
try (Resource lock = mutex.storeCopy(() -> checkPointer.tryCheckPoint(new SimpleTriggerInfo("Store copy")));
ResourceIterator<StoreFileMetadata> files = dataSource.get().listStoreFiles(false)) {
lastCheckPointedTx = checkPointer.lastCheckPointedTransactionId();
while (files.hasNext()) {
StoreFileMetadata fileMetadata = files.next();
File file = fileMetadata.file();
log.debug("Sending file " + file);
ctx.writeAndFlush(ResponseMessageType.FILE);
ctx.writeAndFlush(new FileHeader(relativePath(dataSource.get().getStoreDir(), file), fileMetadata.recordSize()));
Optional<PagedFile> existingMapping = pageCache.getExistingMapping(file);
if (existingMapping.isPresent()) {
try (PagedFile pagedFile = existingMapping.get()) {
ctx.writeAndFlush(new FileSender(pagedFile.openReadableByteChannel()));
}
} else {
ctx.writeAndFlush(new FileSender(fs.open(file, "r")));
}
}
}
endStoreCopy(SUCCESS, ctx, lastCheckPointedTx);
}
protocol.expect(State.MESSAGE_TYPE);
}
Aggregations