Search in sources :

Example 21 with TransactionId

use of org.neo4j.kernel.impl.store.TransactionId in project neo4j by neo4j.

the class StoreMigratorTest method writeAndReadLastTxInformation.

@Test
public void writeAndReadLastTxInformation() throws IOException {
    StoreMigrator migrator = newStoreMigrator();
    TransactionId writtenTxId = new TransactionId(random.nextLong(), random.nextLong(), random.nextLong());
    migrator.writeLastTxInformation(directory.graphDbDir(), writtenTxId);
    TransactionId readTxId = migrator.readLastTxInformation(directory.graphDbDir());
    assertEquals(writtenTxId, readTxId);
}
Also used : TransactionId(org.neo4j.kernel.impl.store.TransactionId) Test(org.junit.Test)

Example 22 with TransactionId

use of org.neo4j.kernel.impl.store.TransactionId in project neo4j by neo4j.

the class StoreMigratorTest method shouldExtractTransactionInformationFromLegacyLogsWhenCantFindInStore.

@Test
public void shouldExtractTransactionInformationFromLegacyLogsWhenCantFindInStore() throws Exception {
    // given
    // ... variables
    long txId = 42;
    long checksum = 123456789123456789L;
    long timestamp = 919191919191919191L;
    TransactionId expected = new TransactionId(txId, checksum, timestamp);
    // ... and files
    PageCache pageCache = pageCacheRule.getPageCache(fileSystemRule.get());
    File storeDir = directory.graphDbDir();
    File neoStore = new File(storeDir, DEFAULT_NAME);
    neoStore.createNewFile();
    // ... and mocks
    Config config = mock(Config.class);
    LogService logService = mock(LogService.class);
    LegacyLogs legacyLogs = mock(LegacyLogs.class);
    when(legacyLogs.getTransactionInformation(storeDir, txId)).thenReturn(Optional.of(expected));
    // when
    // ... neoStore is empty and with migrator
    StoreMigrator migrator = new StoreMigrator(fileSystemRule.get(), pageCache, config, logService, schemaIndexProvider, legacyLogs);
    TransactionId actual = migrator.extractTransactionIdInformation(neoStore, storeDir, txId);
    // then
    assertEquals(expected, actual);
}
Also used : Config(org.neo4j.kernel.configuration.Config) LegacyLogs(org.neo4j.kernel.impl.storemigration.legacylogs.LegacyLogs) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) LogService(org.neo4j.kernel.impl.logging.LogService) NullLogService(org.neo4j.kernel.impl.logging.NullLogService) SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) TransactionId(org.neo4j.kernel.impl.store.TransactionId) Test(org.junit.Test)

Example 23 with TransactionId

use of org.neo4j.kernel.impl.store.TransactionId in project neo4j by neo4j.

the class DeadSimpleTransactionIdStore method setLastCommittedAndClosedTransactionId.

@Override
public void setLastCommittedAndClosedTransactionId(long transactionId, long checksum, long commitTimestamp, long byteOffset, long logVersion) {
    committingTransactionId.set(transactionId);
    committedTransactionId.set(new TransactionId(transactionId, checksum, commitTimestamp));
    closedTransactionId.set(transactionId, new long[] { logVersion, byteOffset });
}
Also used : TransactionId(org.neo4j.kernel.impl.store.TransactionId)

Aggregations

TransactionId (org.neo4j.kernel.impl.store.TransactionId)23 Test (org.junit.Test)13 File (java.io.File)11 TransactionIdStore (org.neo4j.kernel.impl.transaction.log.TransactionIdStore)9 PageCache (org.neo4j.io.pagecache.PageCache)8 MasterClient (org.neo4j.kernel.ha.com.slave.MasterClient)8 StoreId (org.neo4j.kernel.impl.store.StoreId)8 URI (java.net.URI)7 Config (org.neo4j.kernel.configuration.Config)7 BranchedDataPolicy (org.neo4j.kernel.ha.BranchedDataPolicy)7 PagedFile (org.neo4j.io.pagecache.PagedFile)6 HandshakeResult (org.neo4j.kernel.ha.com.master.HandshakeResult)6 NullLogService (org.neo4j.kernel.impl.logging.NullLogService)6 BranchedDataException (org.neo4j.kernel.ha.BranchedDataException)5 IOException (java.io.IOException)4 CancellationRequest (org.neo4j.helpers.CancellationRequest)4 MismatchingStoreIdException (org.neo4j.kernel.impl.store.MismatchingStoreIdException)4 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)4 InetSocketAddress (java.net.InetSocketAddress)3 LogService (org.neo4j.kernel.impl.logging.LogService)3