use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class ResponsePackerIT method shouldPackTheHighestTxCommittedAsObligation.
@Test
public void shouldPackTheHighestTxCommittedAsObligation() throws Exception {
// GIVEN
LogicalTransactionStore transactionStore = mock(LogicalTransactionStore.class);
FileSystemAbstraction fs = fsRule.get();
PageCache pageCache = pageCacheRule.getPageCache(fs);
try (NeoStores neoStore = createNeoStore(fs, pageCache)) {
MetaDataStore store = neoStore.getMetaDataStore();
store.transactionCommitted(2, 111, BASE_TX_COMMIT_TIMESTAMP);
store.transactionCommitted(3, 222, BASE_TX_COMMIT_TIMESTAMP);
store.transactionCommitted(4, 333, BASE_TX_COMMIT_TIMESTAMP);
store.transactionCommitted(5, 444, BASE_TX_COMMIT_TIMESTAMP);
store.transactionCommitted(6, 555, BASE_TX_COMMIT_TIMESTAMP);
// skip 7 to emulate the fact we have an hole in the committed tx ids list
final long expectedTxId = 8L;
store.transactionCommitted(expectedTxId, 777, BASE_TX_COMMIT_TIMESTAMP);
ResponsePacker packer = new ResponsePacker(transactionStore, store, Suppliers.singleton(newStoreIdForCurrentVersion()));
// WHEN
Response<Object> response = packer.packTransactionObligationResponse(new RequestContext(0, 0, 0, 0, 0), new Object());
// THEN
assertTrue(response instanceof TransactionObligationResponse);
((TransactionObligationResponse) response).accept(new Response.Handler() {
@Override
public void obligation(long txId) throws IOException {
assertEquals(expectedTxId, txId);
}
@Override
public Visitor<CommittedTransactionRepresentation, Exception> transactions() {
throw new UnsupportedOperationException("not expected");
}
});
}
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class StoreCopyClientTest method checkStoreCopyClientWithRecordFormats.
private void checkStoreCopyClientWithRecordFormats(String recordFormatsName) throws Exception {
final File copyDir = new File(testDir.directory(), "copy");
final File originalDir = new File(testDir.directory(), "original");
PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
Config config = Config.empty().augment(stringMap(record_format.name(), recordFormatsName));
StoreCopyClient copier = new StoreCopyClient(copyDir, config, loadKernelExtensions(), NullLogProvider.getInstance(), fileSystem, pageCache, new StoreCopyClient.Monitor.Adapter(), false);
final GraphDatabaseAPI original = (GraphDatabaseAPI) startDatabase(originalDir, recordFormatsName);
StoreCopyClient.StoreCopyRequester storeCopyRequest = new LocalStoreCopyRequester(original, originalDir, fileSystem);
copier.copyStore(storeCopyRequest, CancellationRequest.NEVER_CANCELLED, MoveAfterCopy.moveReplaceExisting());
assertFalse(new File(copyDir, TEMP_COPY_DIRECTORY_NAME).exists());
// Must not throw
startDatabase(copyDir, recordFormatsName).shutdown();
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class StoreCopyClientTest method shouldCopyStoreFilesAcrossIfACancellationRequestHappensAfterTheTempStoreHasBeenRecovered.
@Test
public void shouldCopyStoreFilesAcrossIfACancellationRequestHappensAfterTheTempStoreHasBeenRecovered() throws Exception {
// given
final File copyDir = new File(testDir.directory(), "copy");
final File originalDir = new File(testDir.directory(), "original");
final AtomicBoolean cancelStoreCopy = new AtomicBoolean(false);
StoreCopyClient.Monitor storeCopyMonitor = new StoreCopyClient.Monitor.Adapter() {
@Override
public void finishRecoveringStore() {
// simulate a cancellation request
cancelStoreCopy.set(true);
}
};
PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
StoreCopyClient copier = new StoreCopyClient(copyDir, Config.empty(), loadKernelExtensions(), NullLogProvider.getInstance(), fileSystem, pageCache, storeCopyMonitor, false);
final GraphDatabaseAPI original = (GraphDatabaseAPI) startDatabase(originalDir);
try (Transaction tx = original.beginTx()) {
original.createNode(label("BeforeCopyBegins"));
tx.success();
}
StoreCopyClient.StoreCopyRequester storeCopyRequest = spy(new LocalStoreCopyRequester(original, originalDir, fileSystem));
// when
copier.copyStore(storeCopyRequest, cancelStoreCopy::get, MoveAfterCopy.moveReplaceExisting());
// Then
GraphDatabaseService copy = startDatabase(copyDir);
try (Transaction tx = copy.beginTx()) {
long nodesCount = Iterators.count(copy.findNodes(label("BeforeCopyBegins")));
assertThat(nodesCount, equalTo(1L));
assertThat(Iterators.single(copy.findNodes(label("BeforeCopyBegins"))).getId(), equalTo(0L));
tx.success();
}
verify(storeCopyRequest, times(1)).done();
assertFalse(new File(copyDir, TEMP_COPY_DIRECTORY_NAME).exists());
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class StoreCopyClientTest method shouldEndUpWithAnEmptyStoreIfCancellationRequestIssuedJustBeforeRecoveryTakesPlace.
@Test
public void shouldEndUpWithAnEmptyStoreIfCancellationRequestIssuedJustBeforeRecoveryTakesPlace() throws Exception {
// given
final File copyDir = new File(testDir.directory(), "copy");
final File originalDir = new File(testDir.directory(), "original");
final AtomicBoolean cancelStoreCopy = new AtomicBoolean(false);
StoreCopyClient.Monitor storeCopyMonitor = new StoreCopyClient.Monitor.Adapter() {
@Override
public void finishReceivingStoreFiles() {
// simulate a cancellation request
cancelStoreCopy.set(true);
}
};
PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
StoreCopyClient copier = new StoreCopyClient(copyDir, Config.empty(), loadKernelExtensions(), NullLogProvider.getInstance(), fileSystem, pageCache, storeCopyMonitor, false);
final GraphDatabaseAPI original = (GraphDatabaseAPI) startDatabase(originalDir);
try (Transaction tx = original.beginTx()) {
original.createNode(label("BeforeCopyBegins"));
tx.success();
}
StoreCopyClient.StoreCopyRequester storeCopyRequest = spy(new LocalStoreCopyRequester(original, originalDir, fileSystem));
// when
copier.copyStore(storeCopyRequest, cancelStoreCopy::get, MoveAfterCopy.moveReplaceExisting());
// Then
GraphDatabaseService copy = startDatabase(copyDir);
try (Transaction tx = copy.beginTx()) {
long nodesCount = Iterators.count(copy.findNodes(label("BeforeCopyBegins")));
assertThat(nodesCount, equalTo(0L));
tx.success();
}
verify(storeCopyRequest, times(1)).done();
assertFalse(new File(copyDir, TEMP_COPY_DIRECTORY_NAME).exists());
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class RecordFormatSelectorTest method selectForStoreWithInvalidStoreVersion.
@Test
public void selectForStoreWithInvalidStoreVersion() throws IOException {
PageCache pageCache = getPageCache();
prepareNeoStoreFile("v9.Z.9", pageCache);
assertNull(selectForStore(storeDir, fs, getPageCache(), LOG));
}
Aggregations