Search in sources :

Example 11 with SimpleLogVersionRepository

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();
}
Also used : SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) LogVersionRepository(org.neo4j.storageengine.api.LogVersionRepository) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with SimpleLogVersionRepository

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);
}
Also used : DatabaseHealth(org.neo4j.monitoring.DatabaseHealth) TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) Health(org.neo4j.monitoring.Health) DatabaseHealth(org.neo4j.monitoring.DatabaseHealth) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) DatabasePanicEventGenerator(org.neo4j.kernel.monitoring.DatabasePanicEventGenerator) LogVersionRepository(org.neo4j.storageengine.api.LogVersionRepository) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) IOException(java.io.IOException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Race(org.neo4j.test.Race) LogRotation(org.neo4j.kernel.impl.transaction.log.rotation.LogRotation) FileLogRotation.transactionLogRotation(org.neo4j.kernel.impl.transaction.log.rotation.FileLogRotation.transactionLogRotation) Test(org.junit.jupiter.api.Test)

Example 13 with SimpleLogVersionRepository

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();
}
Also used : Path(java.nio.file.Path) SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) Config(org.neo4j.configuration.Config) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) Test(org.junit.jupiter.api.Test)

Example 14 with SimpleLogVersionRepository

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());
}
Also used : SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) Test(org.junit.jupiter.api.Test)

Example 15 with SimpleLogVersionRepository

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());
}
Also used : DatabaseHealth(org.neo4j.monitoring.DatabaseHealth) SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) Dependencies(org.neo4j.collection.Dependencies) Test(org.junit.jupiter.api.Test)

Aggregations

SimpleLogVersionRepository (org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository)17 SimpleTransactionIdStore (org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore)17 Test (org.junit.jupiter.api.Test)13 LogFiles (org.neo4j.kernel.impl.transaction.log.files.LogFiles)8 Lifespan (org.neo4j.kernel.lifecycle.Lifespan)5 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 LogFile (org.neo4j.kernel.impl.transaction.log.files.LogFile)3 LogVersionRepository (org.neo4j.storageengine.api.LogVersionRepository)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Config (org.neo4j.configuration.Config)2 TestCommandReaderFactory (org.neo4j.kernel.impl.api.TestCommandReaderFactory)2 VersionAwareLogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader)2 DatabaseHealth (org.neo4j.monitoring.DatabaseHealth)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 DisabledOnOs (org.junit.jupiter.api.condition.DisabledOnOs)1 EnabledOnOs (org.junit.jupiter.api.condition.EnabledOnOs)1