Search in sources :

Example 16 with LogicalTransactionStore

use of org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore in project neo4j by neo4j.

the class HighlyAvailableEditionModule method assureLastCommitTimestampInitialized.

private static void assureLastCommitTimestampInitialized(DependencyResolver resolver) {
    MetaDataStore metaDataStore = resolver.resolveDependency(MetaDataStore.class);
    LogicalTransactionStore txStore = resolver.resolveDependency(LogicalTransactionStore.class);
    TransactionId txInfo = metaDataStore.getLastCommittedTransaction();
    long lastCommitTimestampFromStore = txInfo.commitTimestamp();
    if (txInfo.transactionId() == TransactionIdStore.BASE_TX_ID) {
        metaDataStore.setLastTransactionCommitTimestamp(TransactionIdStore.BASE_TX_COMMIT_TIMESTAMP);
        return;
    }
    if (lastCommitTimestampFromStore == TransactionIdStore.UNKNOWN_TX_COMMIT_TIMESTAMP || lastCommitTimestampFromStore == TransactionIdStore.BASE_TX_COMMIT_TIMESTAMP) {
        long lastCommitTimestampFromLogs;
        try {
            TransactionMetadata metadata = txStore.getMetadataFor(txInfo.transactionId());
            lastCommitTimestampFromLogs = metadata.getTimeWritten();
        } catch (NoSuchTransactionException e) {
            lastCommitTimestampFromLogs = TransactionIdStore.UNKNOWN_TX_COMMIT_TIMESTAMP;
        } catch (IOException e) {
            throw new IllegalStateException("Unable to read transaction logs", e);
        }
        metaDataStore.setLastTransactionCommitTimestamp(lastCommitTimestampFromLogs);
    }
}
Also used : MetaDataStore(org.neo4j.kernel.impl.store.MetaDataStore) LogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore) NoSuchTransactionException(org.neo4j.kernel.impl.transaction.log.NoSuchTransactionException) IOException(java.io.IOException) TransactionId(org.neo4j.kernel.impl.store.TransactionId) TransactionMetadata(org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache.TransactionMetadata)

Example 17 with LogicalTransactionStore

use of org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore in project neo4j by neo4j.

the class LabelAndIndexUpdateBatchingIT method extractTransactions.

private static List<TransactionRepresentation> extractTransactions(GraphDatabaseAPI db) throws NoSuchTransactionException, IOException {
    LogicalTransactionStore txStore = db.getDependencyResolver().resolveDependency(LogicalTransactionStore.class);
    List<TransactionRepresentation> transactions = new ArrayList<>();
    try (TransactionCursor cursor = txStore.getTransactions(TransactionIdStore.BASE_TX_ID + 1)) {
        cursor.forAll(tx -> transactions.add(tx.getTransactionRepresentation()));
    }
    return transactions;
}
Also used : TransactionCursor(org.neo4j.kernel.impl.transaction.log.TransactionCursor) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) ArrayList(java.util.ArrayList) LogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore)

Aggregations

LogicalTransactionStore (org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore)17 Test (org.junit.Test)10 TransactionIdStore (org.neo4j.kernel.impl.transaction.log.TransactionIdStore)9 Monitors (org.neo4j.kernel.monitoring.Monitors)8 IOException (java.io.IOException)7 CatchupServerProtocol (org.neo4j.causalclustering.catchup.CatchupServerProtocol)6 StoreId (org.neo4j.causalclustering.identity.StoreId)6 CommittedTransactionRepresentation (org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation)6 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)5 PageCache (org.neo4j.io.pagecache.PageCache)4 LogHeaderCache (org.neo4j.kernel.impl.transaction.log.LogHeaderCache)4 PhysicalLogFile (org.neo4j.kernel.impl.transaction.log.PhysicalLogFile)4 PhysicalLogicalTransactionStore (org.neo4j.kernel.impl.transaction.log.PhysicalLogicalTransactionStore)4 ReadableClosablePositionAwareChannel (org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel)4 TransactionMetadataCache (org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache)4 StorageEngine (org.neo4j.storageengine.api.StorageEngine)4 File (java.io.File)3 Visitor (org.neo4j.helpers.collection.Visitor)3 LogFile (org.neo4j.kernel.impl.transaction.log.LogFile)3 PhysicalLogFiles (org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles)3