Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
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()));
        }
Ejemplo n.º 3
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());
        }