use of org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer 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);
}
use of org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer in project neo4j by neo4j.
the class FileWatchIT method doNotNotifyAboutLuceneIndexFilesDeletion.
@Test(timeout = TEST_TIMEOUT)
public void doNotNotifyAboutLuceneIndexFilesDeletion() throws InterruptedException, IOException {
DependencyResolver dependencyResolver = ((GraphDatabaseAPI) database).getDependencyResolver();
FileWatcher fileWatcher = getFileWatcher(database);
CheckPointer checkPointer = dependencyResolver.resolveDependency(CheckPointer.class);
String propertyStoreName = MetaDataStore.DEFAULT_NAME + StoreFactory.PROPERTY_STORE_NAME;
AccumulativeDeletionEventListener accumulativeListener = new AccumulativeDeletionEventListener();
ModificationEventListener modificationListener = new ModificationEventListener(propertyStoreName);
fileWatcher.addFileWatchEventListener(modificationListener);
fileWatcher.addFileWatchEventListener(accumulativeListener);
String labelName = "labelName";
String propertyName = "propertyName";
Label testLabel = Label.label(labelName);
createIndexes(database, propertyName, testLabel);
do {
createNode(database, propertyName, testLabel);
forceCheckpoint(checkPointer);
} while (!modificationListener.awaitModificationNotification());
fileWatcher.removeFileWatchEventListener(modificationListener);
ModificationEventListener afterRemovalListener = new ModificationEventListener(propertyStoreName);
fileWatcher.addFileWatchEventListener(afterRemovalListener);
dropAllIndexes(database);
do {
createNode(database, propertyName, testLabel);
forceCheckpoint(checkPointer);
} while (!afterRemovalListener.awaitModificationNotification());
accumulativeListener.assertDoesNotHaveAnyDeletions();
}
use of org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer in project neo4j by neo4j.
the class IndexingServiceIntegrationTest method dropIndexDirectlyOnIndexingServiceRaceWithCheckpoint.
@ParameterizedTest
@MethodSource("parameters")
void dropIndexDirectlyOnIndexingServiceRaceWithCheckpoint(GraphDatabaseSettings.SchemaIndex schemaIndex) throws Throwable {
setUp(schemaIndex);
IndexingService indexingService = getIndexingService(database);
CheckPointer checkPointer = getCheckPointer(database);
IndexDescriptor indexDescriptor;
try (Transaction tx = database.beginTx()) {
IndexDefinitionImpl indexDefinition = (IndexDefinitionImpl) tx.schema().indexFor(Label.label("label")).on("prop").create();
indexDescriptor = indexDefinition.getIndexReference();
tx.commit();
}
try (Transaction tx = database.beginTx()) {
tx.schema().awaitIndexesOnline(1, TimeUnit.HOURS);
tx.commit();
}
Race race = new Race();
race.addContestant(Race.throwing(() -> checkPointer.forceCheckPoint(new SimpleTriggerInfo("Test force"))));
race.addContestant(Race.throwing(() -> indexingService.dropIndex(indexDescriptor)));
race.go();
}
use of org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer in project neo4j by neo4j.
the class RecoveryCleanupIT method checkpoint.
private static void checkpoint(GraphDatabaseService db) throws IOException {
CheckPointer checkPointer = checkPointer(db);
checkPointer.forceCheckPoint(new SimpleTriggerInfo("test"));
}
use of org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer in project neo4j by neo4j.
the class FileWatchIT method notifyAboutStoreFileDeletion.
@Test
void notifyAboutStoreFileDeletion() throws IOException, InterruptedException {
String fileName = databaseLayout.metadataStore().getFileName().toString();
FileWatcher fileWatcher = getFileWatcher(database);
CheckPointer checkpointer = getCheckpointer(database);
DeletionLatchEventListener deletionListener = new DeletionLatchEventListener(fileName);
fileWatcher.addFileWatchEventListener(deletionListener);
do {
createNode(database);
forceCheckpoint(checkpointer);
} while (!deletionListener.awaitModificationNotification());
deleteFile(databaseLayout.databaseDirectory(), fileName);
deletionListener.awaitDeletionNotification();
assertThat(logProvider).containsMessages("'" + fileName + "' which belongs to the '" + databaseLayout.databaseDirectory().getFileName().toString() + "' database was deleted while it was running.");
}
Aggregations