use of org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository in project neo4j by neo4j.
the class ReversedSingleFileTransactionCursorTest method setUp.
@BeforeEach
void setUp() throws IOException {
LogVersionRepository logVersionRepository = new SimpleLogVersionRepository();
SimpleTransactionIdStore transactionIdStore = new SimpleTransactionIdStore();
logFiles = LogFilesBuilder.builder(databaseLayout, fs).withRotationThreshold(ByteUnit.mebiBytes(10)).withLogVersionRepository(logVersionRepository).withTransactionIdStore(transactionIdStore).withLogEntryReader(logEntryReader()).withStoreId(StoreId.UNKNOWN).build();
life.add(logFiles);
logFile = logFiles.getLogFile();
}
use of org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository in project neo4j by neo4j.
the class TransactionLogAppendAndRotateIT method shouldKeepTransactionsIntactWhenConcurrentlyRotationAndAppending.
@Test
void shouldKeepTransactionsIntactWhenConcurrentlyRotationAndAppending() throws Throwable {
// GIVEN
LogVersionRepository logVersionRepository = new SimpleLogVersionRepository();
LogFiles logFiles = LogFilesBuilder.builder(databaseLayout, fileSystem).withLogVersionRepository(logVersionRepository).withRotationThreshold(ByteUnit.mebiBytes(1)).withTransactionIdStore(new SimpleTransactionIdStore()).withLogEntryReader(logEntryReader()).withStoreId(StoreId.UNKNOWN).build();
life.add(logFiles);
final AtomicBoolean end = new AtomicBoolean();
AllTheMonitoring monitoring = new AllTheMonitoring(end, 100);
TransactionIdStore txIdStore = new SimpleTransactionIdStore();
TransactionMetadataCache metadataCache = new TransactionMetadataCache();
monitoring.setLogFile(logFiles.getLogFile());
Health health = new DatabaseHealth(mock(DatabasePanicEventGenerator.class), NullLog.getInstance());
LogRotation rotation = transactionLogRotation(logFiles, Clock.systemUTC(), health, monitoring);
final TransactionAppender appender = life.add(new BatchingTransactionAppender(logFiles, rotation, metadataCache, txIdStore, health));
// WHEN
Race race = new Race();
for (int i = 0; i < 4; i++) {
race.addContestant(() -> {
while (!end.get()) {
try {
appender.append(new TransactionToApply(sillyTransaction(1_000), CursorContext.NULL), LogAppendEvent.NULL);
} catch (Exception e) {
e.printStackTrace(System.out);
end.set(true);
fail(e.getMessage(), e);
}
}
});
}
race.addContestant(endAfterMax(250, MILLISECONDS, end, monitoring));
race.go();
// THEN
assertTrue(monitoring.numberOfRotations() > 0);
}
use of org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository in project neo4j by neo4j.
the class LogFilesBuilderTest method buildContextWithCustomAbsoluteLogFilesLocations.
@Test
void buildContextWithCustomAbsoluteLogFilesLocations() throws Throwable {
Path customLogDirectory = testDirectory.directory("absoluteCustomLogDirectory");
Config config = Config.newBuilder().set(neo4j_home, testDirectory.homePath()).set(transaction_logs_root_path, customLogDirectory.toAbsolutePath()).build();
LogFiles logFiles = builder(DatabaseLayout.of(config), fileSystem).withRotationThreshold(ByteUnit.mebiBytes(1)).withLogVersionRepository(new SimpleLogVersionRepository()).withTransactionIdStore(new SimpleTransactionIdStore()).withLogEntryReader(logEntryReader()).withStoreId(StoreId.UNKNOWN).build();
logFiles.init();
logFiles.start();
assertEquals(customLogDirectory.resolve(databaseLayout.getDatabaseName()), logFiles.getLogFile().getHighestLogFile().getParent());
logFiles.shutdown();
}
use of org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository in project neo4j by neo4j.
the class LogFilesBuilderTest method buildDefaultContext.
@Test
void buildDefaultContext() throws IOException {
TransactionLogFilesContext context = builder(databaseLayout, fileSystem).withLogVersionRepository(new SimpleLogVersionRepository(2)).withTransactionIdStore(new SimpleTransactionIdStore()).withLogEntryReader(logEntryReader()).buildContext();
assertEquals(fileSystem, context.getFileSystem());
assertNotNull(context.getLogEntryReader());
assertEquals(ByteUnit.mebiBytes(250), context.getRotationThreshold().get());
assertEquals(1, context.getLastCommittedTransactionId());
assertEquals(2, context.getLogVersionRepository().getCurrentLogVersion());
}
use of org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository in project neo4j by neo4j.
the class LogFilesBuilderTest method buildDefaultContextWithDependencies.
@Test
void buildDefaultContextWithDependencies() throws IOException {
SimpleLogVersionRepository logVersionRepository = new SimpleLogVersionRepository(2);
SimpleTransactionIdStore transactionIdStore = new SimpleTransactionIdStore();
DatabaseHealth databaseHealth = new DatabaseHealth(PanicEventGenerator.NO_OP, NullLog.getInstance());
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependency(logVersionRepository);
dependencies.satisfyDependency(transactionIdStore);
dependencies.satisfyDependency(databaseHealth);
TransactionLogFilesContext context = builder(databaseLayout, fileSystem).withDependencies(dependencies).withLogEntryReader(logEntryReader()).buildContext();
assertEquals(fileSystem, context.getFileSystem());
assertNotNull(context.getLogEntryReader());
assertEquals(ByteUnit.mebiBytes(250), context.getRotationThreshold().get());
assertEquals(databaseHealth, context.getDatabaseHealth());
assertEquals(1, context.getLastCommittedTransactionId());
assertEquals(2, context.getLogVersionRepository().getCurrentLogVersion());
}
Aggregations