Search in sources :

Example 16 with StoreId

use of org.neo4j.storageengine.api.StoreId in project neo4j by neo4j.

the class LogHeaderWriter method writeLogHeader.

public static void writeLogHeader(FlushableChannel channel, LogHeader logHeader) throws IOException {
    channel.putLong(encodeLogVersion(logHeader.getLogVersion(), logHeader.getLogFormatVersion()));
    channel.putLong(logHeader.getLastCommittedTxId());
    StoreId storeId = logHeader.getStoreId();
    channel.putLong(storeId.getCreationTime());
    channel.putLong(storeId.getRandomId());
    channel.putLong(storeId.getStoreVersion());
    channel.putLong(storeId.getUpgradeTime());
    channel.putLong(storeId.getUpgradeTxId());
    channel.putLong(0);
}
Also used : StoreId(org.neo4j.storageengine.api.StoreId)

Example 17 with StoreId

use of org.neo4j.storageengine.api.StoreId in project neo4j by neo4j.

the class CheckpointInfoTest method checkpointInfoOfDetachedCheckpointEntry.

@Test
void checkpointInfoOfDetachedCheckpointEntry() {
    var logPosition = new LogPosition(0, 1);
    var storeId = new StoreId(3, 4, 5, 6, 7);
    LogPosition position = new LogPosition(1, 2);
    var checkpointInfo = new CheckpointInfo(new LogEntryDetachedCheckpoint(KernelVersion.V4_0, logPosition, 2, storeId, "checkpoint"), position);
    assertSame(logPosition, checkpointInfo.getTransactionLogPosition());
    assertSame(storeId, checkpointInfo.storeId());
    assertSame(position, checkpointInfo.getCheckpointEntryPosition());
}
Also used : LogEntryDetachedCheckpoint(org.neo4j.kernel.impl.transaction.log.entry.LogEntryDetachedCheckpoint) StoreId(org.neo4j.storageengine.api.StoreId) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Test(org.junit.jupiter.api.Test)

Example 18 with StoreId

use of org.neo4j.storageengine.api.StoreId in project neo4j by neo4j.

the class LogHeaderWriterTest method shouldWriteALogHeaderInTheGivenChannel.

@Test
void shouldWriteALogHeaderInTheGivenChannel() throws IOException {
    // given
    final InMemoryClosableChannel channel = new InMemoryClosableChannel();
    // when
    writeLogHeader(channel, logHeader);
    // then
    long encodedLogVersions = channel.getLong();
    assertEquals(encodeLogVersion(expectedLogVersion, CURRENT_LOG_FORMAT_VERSION), encodedLogVersions);
    byte logFormatVersion = decodeLogFormatVersion(encodedLogVersions);
    assertEquals(CURRENT_LOG_FORMAT_VERSION, logFormatVersion);
    long logVersion = decodeLogVersion(encodedLogVersions);
    assertEquals(expectedLogVersion, logVersion);
    long txId = channel.getLong();
    assertEquals(expectedTxId, txId);
    StoreId storeId = new StoreId(channel.getLong(), channel.getLong(), channel.getLong(), channel.getLong(), channel.getLong());
    assertEquals(expectedStoreId, storeId);
}
Also used : StoreId(org.neo4j.storageengine.api.StoreId) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Test(org.junit.jupiter.api.Test)

Example 19 with StoreId

use of org.neo4j.storageengine.api.StoreId in project neo4j by neo4j.

the class MetaDataStoreTest method setStoreIdShouldSetAllRelatedFields.

@Test
void setStoreIdShouldSetAllRelatedFields() throws IOException {
    // given
    int creationTime = 1;
    int randomId = 2;
    long storeVersion = versionStringToLong(LATEST_STORE_VERSION);
    int upgradeTime = 4;
    int upgradeTxId = 5;
    int upgradeTxChecksum = 6;
    long upgradeTxCommitTimestamp = 7;
    StoreId storeId = new StoreId(creationTime, randomId, storeVersion, upgradeTime, upgradeTxId);
    // when
    try (MetaDataStore store = newMetaDataStore()) {
        MetaDataStore.setStoreId(pageCache, store.getStorageFile(), storeId, upgradeTxChecksum, upgradeTxCommitTimestamp, databaseLayout.getDatabaseName(), NULL);
    }
    // then
    try (MetaDataStore store = newMetaDataStore()) {
        assertEquals(creationTime, store.getCreationTime());
        assertEquals(randomId, store.getRandomNumber());
        assertEquals(storeVersion, store.getStoreVersion());
        assertEquals(upgradeTime, store.getUpgradeTime());
        TransactionId expectedTx = new TransactionId(upgradeTxId, upgradeTxChecksum, upgradeTxCommitTimestamp);
        assertEquals(expectedTx, store.getUpgradeTransaction());
    }
}
Also used : ExternalStoreId(org.neo4j.storageengine.api.ExternalStoreId) StoreId(org.neo4j.storageengine.api.StoreId) TransactionId(org.neo4j.storageengine.api.TransactionId) Test(org.junit.jupiter.api.Test)

Example 20 with StoreId

use of org.neo4j.storageengine.api.StoreId in project neo4j by neo4j.

the class MetaDataStoreTest method tracePageCacheAssessOnSetStoreId.

@Test
void tracePageCacheAssessOnSetStoreId() throws IOException {
    var cacheTracer = new DefaultPageCacheTracer();
    var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("tracePageCacheAssessOnSetStoreId"));
    try (var metaDataStore = newMetaDataStore()) {
        var storeId = new StoreId(1, 2, 3, 4, 5);
        MetaDataStore.setStoreId(pageCache, metaDataStore.getStorageFile(), storeId, 6, 7, databaseLayout.getDatabaseName(), cursorContext);
        PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
        assertThat(cursorTracer.pins()).isEqualTo(7);
        assertThat(cursorTracer.unpins()).isEqualTo(7);
        assertThat(cursorTracer.hits()).isEqualTo(7);
    }
}
Also used : PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer) ExternalStoreId(org.neo4j.storageengine.api.ExternalStoreId) StoreId(org.neo4j.storageengine.api.StoreId) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Aggregations

StoreId (org.neo4j.storageengine.api.StoreId)20 Test (org.junit.jupiter.api.Test)9 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)9 ExternalStoreId (org.neo4j.storageengine.api.ExternalStoreId)3 Path (java.nio.file.Path)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)2 LogEntryDetachedCheckpoint (org.neo4j.kernel.impl.transaction.log.entry.LogEntryDetachedCheckpoint)2 LogEntryInlinedCheckPoint (org.neo4j.kernel.impl.transaction.log.entry.LogEntryInlinedCheckPoint)2 LogHeader (org.neo4j.kernel.impl.transaction.log.entry.LogHeader)2 TransactionId (org.neo4j.storageengine.api.TransactionId)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ByteBuffer (java.nio.ByteBuffer)1 ClosedByInterruptException (java.nio.channels.ClosedByInterruptException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 LongSupplier (java.util.function.LongSupplier)1 UnsatisfiedDependencyException (org.neo4j.exceptions.UnsatisfiedDependencyException)1 StoreChannel (org.neo4j.io.fs.StoreChannel)1