示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public long lookup(long txId) throws java.io.IOException
        public virtual long Lookup(long txId)
        {
            // First off see if the requested txId is in fact the last committed transaction.
            // If so then we can extract the checksum directly from the transaction id store.
            TransactionId lastCommittedTransaction = _transactionIdStore.LastCommittedTransaction;

            if (lastCommittedTransaction.TransactionIdConflict() == txId)
            {
                return(lastCommittedTransaction.Checksum());
            }

            // Check if the requested txId is upgrade transaction
            // if so then use checksum form transaction id store.
            // That checksum can take specific values that should not be re-evaluated.
            if (_upgradeTransaction.transactionId() == txId)
            {
                return(_upgradeTransaction.checksum());
            }

            // It wasn't, so go look for it in the transaction store.
            // Intentionally let potentially thrown IOException (and NoSuchTransactionException) be thrown
            // from this call below, it's part of the contract of this method.
            try
            {
                return(_logicalTransactionStore.getMetadataFor(txId).Checksum);
            }
            catch (NoSuchTransactionException e)
            {
                // So we truly couldn't find the checksum for this txId, go ahead and throw
                throw withMessage(e, e.Message + " | transaction id store says last transaction is " + lastCommittedTransaction + " and last upgrade transaction is " + _upgradeTransaction);
            }
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateTransactionInformationWhenLogsAreEmpty() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldGenerateTransactionInformationWhenLogsAreEmpty()
        {
            // given
            long           txId           = 1;
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            File           neoStore       = databaseLayout.MetadataStore();

            neoStore.createNewFile();
            Config     config     = mock(typeof(Config));
            LogService logService = new SimpleLogService(NullLogProvider.Instance, NullLogProvider.Instance);

            // when
            // ... transaction info not in neo store
            assertEquals(FIELD_NOT_PRESENT, getRecord(_pageCache, neoStore, LAST_TRANSACTION_ID));
            assertEquals(FIELD_NOT_PRESENT, getRecord(_pageCache, neoStore, LAST_TRANSACTION_CHECKSUM));
            assertEquals(FIELD_NOT_PRESENT, getRecord(_pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP));
            // ... and with migrator
            StoreMigrator migrator = new StoreMigrator(_fileSystemRule.get(), _pageCache, config, logService, _jobScheduler);
            TransactionId actual   = migrator.ExtractTransactionIdInformation(neoStore, txId);

            // then
            assertEquals(txId, actual.TransactionIdConflict());
            assertEquals(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_CHECKSUM, actual.Checksum());
            assertEquals(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_COMMIT_TIMESTAMP, actual.CommitTimestamp());
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldExtractTransactionInformationFromMetaDataStore() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldExtractTransactionInformationFromMetaDataStore()
        {
            // given
            // ... variables
            long          txId      = 42;
            long          checksum  = 123456789123456789L;
            long          timestamp = 919191919191919191L;
            TransactionId expected  = new TransactionId(txId, checksum, timestamp);

            // ... and files
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            File           neoStore       = databaseLayout.MetadataStore();

            neoStore.createNewFile();

            // ... and mocks
            Config     config     = mock(typeof(Config));
            LogService logService = mock(typeof(LogService));

            // when
            // ... data in record
            setRecord(_pageCache, neoStore, LAST_TRANSACTION_ID, txId);
            setRecord(_pageCache, neoStore, LAST_TRANSACTION_CHECKSUM, checksum);
            setRecord(_pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP, timestamp);

            // ... and with migrator
            StoreMigrator migrator = new StoreMigrator(_fileSystemRule.get(), _pageCache, config, logService, _jobScheduler);
            TransactionId actual   = migrator.ExtractTransactionIdInformation(neoStore, txId);

            // then
            assertEquals(expected, actual);
        }
示例#4
0
        public virtual RequestContext NewRequestContext(long epoch, int machineId, int eventIdentifier)
        {
            TransactionId lastTx = _txIdStore.LastCommittedTransaction;

            // TODO beware, there's a race between getting tx id and checksum, and changes to last tx
            // it must be fixed
            return(new RequestContext(epoch, machineId, eventIdentifier, lastTx.TransactionIdConflict(), lastTx.Checksum()));
        }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void writeAndReadLastTxInformation() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void WriteAndReadLastTxInformation()
        {
            StoreMigrator migrator    = NewStoreMigrator();
            TransactionId writtenTxId = new TransactionId(_random.nextLong(), _random.nextLong(), _random.nextLong());

            migrator.WriteLastTxInformation(_directory.databaseLayout(), writtenTxId);

            TransactionId readTxId = migrator.ReadLastTxInformation(_directory.databaseLayout());

            assertEquals(writtenTxId, readTxId);
        }
示例#6
0
 public TransactionChecksumLookup(TransactionIdStore transactionIdStore, LogicalTransactionStore logicalTransactionStore)
 {
     this._transactionIdStore      = transactionIdStore;
     this._logicalTransactionStore = logicalTransactionStore;
     this._upgradeTransaction      = transactionIdStore.UpgradeTransaction;
 }