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);
}
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());
}
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);
}
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());
}
}
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);
}
}
Aggregations