Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPackTheHighestTxCommittedAsObligation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPackTheHighestTxCommittedAsObligation()
        {
            // GIVEN
            LogicalTransactionStore transactionStore = mock(typeof(LogicalTransactionStore));
            FileSystemAbstraction   fs = _fsRule.get();
            PageCache pageCache        = _pageCacheRule.getPageCache(fs);

            using (NeoStores neoStore = CreateNeoStore(fs, pageCache))
            {
                MetaDataStore store = neoStore.MetaDataStore;
                store.TransactionCommitted(2, 111, BASE_TX_COMMIT_TIMESTAMP);
                store.TransactionCommitted(3, 222, BASE_TX_COMMIT_TIMESTAMP);
                store.TransactionCommitted(4, 333, BASE_TX_COMMIT_TIMESTAMP);
                store.TransactionCommitted(5, 444, BASE_TX_COMMIT_TIMESTAMP);
                store.TransactionCommitted(6, 555, BASE_TX_COMMIT_TIMESTAMP);

                // skip 7 to emulate the fact we have an hole in the committed tx ids list

                const long expectedTxId = 8L;
                store.TransactionCommitted(expectedTxId, 777, BASE_TX_COMMIT_TIMESTAMP);

                ResponsePacker packer = new ResponsePacker(transactionStore, store, Suppliers.singleton(newStoreIdForCurrentVersion()));

                // WHEN
                Response <object> response = packer.PackTransactionObligationResponse(new RequestContext(0, 0, 0, 0, 0), new object());

                // THEN
                assertTrue(response is TransactionObligationResponse);
                (( TransactionObligationResponse )response).accept(new HandlerAnonymousInnerClass(this, expectedTxId));
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public ReadOnlyTransactionStore(org.neo4j.io.pagecache.PageCache pageCache, org.neo4j.io.fs.FileSystemAbstraction fs, org.neo4j.io.layout.DatabaseLayout fromDatabaseLayout, org.neo4j.kernel.configuration.Config config, org.neo4j.kernel.monitoring.Monitors monitors) throws java.io.IOException
        public ReadOnlyTransactionStore(PageCache pageCache, FileSystemAbstraction fs, DatabaseLayout fromDatabaseLayout, Config config, Monitors monitors)
        {
            TransactionMetadataCache transactionMetadataCache = new TransactionMetadataCache();
            LogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            LogFiles logFiles = LogFilesBuilder.activeFilesBuilder(fromDatabaseLayout, fs, pageCache).withLogEntryReader(logEntryReader).withConfig(config).build();

            _physicalStore = new PhysicalLogicalTransactionStore(logFiles, transactionMetadataCache, logEntryReader, monitors, true);
        }
Beispiel #3
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public OnlineBackupKernelExtension(org.neo4j.kernel.configuration.Config config, final org.neo4j.kernel.internal.GraphDatabaseAPI graphDatabaseAPI, final org.neo4j.logging.LogProvider logProvider, final org.neo4j.kernel.monitoring.Monitors monitors, final org.neo4j.kernel.NeoStoreDataSource neoStoreDataSource, final org.neo4j.io.fs.FileSystemAbstraction fileSystemAbstraction)
		 public OnlineBackupKernelExtension( Config config, GraphDatabaseAPI graphDatabaseAPI, LogProvider logProvider, Monitors monitors, NeoStoreDataSource neoStoreDataSource, FileSystemAbstraction fileSystemAbstraction ) : this(config, graphDatabaseAPI, () ->
		 {
		  {
				DependencyResolver dependencyResolver = graphDatabaseAPI.DependencyResolver;
				TransactionIdStore transactionIdStore = dependencyResolver.resolveDependency( typeof( TransactionIdStore ) );
				StoreCopyServer copier = new StoreCopyServer( neoStoreDataSource, dependencyResolver.resolveDependency( typeof( CheckPointer ) ), fileSystemAbstraction, graphDatabaseAPI.DatabaseLayout().databaseDirectory(), monitors.NewMonitor(typeof(StoreCopyServer.Monitor)) );
				LogicalTransactionStore logicalTransactionStore = dependencyResolver.resolveDependency( typeof( LogicalTransactionStore ) );
				LogFileInformation logFileInformation = dependencyResolver.resolveDependency( typeof( LogFileInformation ) );
				return new BackupImpl( copier, logicalTransactionStore, transactionIdStore, logFileInformation, graphDatabaseAPI.storeId, logProvider );
		  }, monitors, logProvider);
Beispiel #4
0
 public BackupImpl(StoreCopyServer storeCopyServer, LogicalTransactionStore logicalTransactionStore, TransactionIdStore transactionIdStore, LogFileInformation logFileInformation, System.Func <StoreId> storeId, LogProvider logProvider)
 {
     this._storeCopyServer         = storeCopyServer;
     this._logicalTransactionStore = logicalTransactionStore;
     this._transactionIdStore      = transactionIdStore;
     this._logFileInformation      = logFileInformation;
     this._storeId = storeId;
     this._logger  = logProvider.getLog(this.GetType()).InfoLogger();
     this._incrementalResponsePacker = new ResponsePacker(logicalTransactionStore, transactionIdStore, storeId);
 }
Beispiel #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static java.util.List<org.neo4j.kernel.impl.transaction.TransactionRepresentation> extractTransactions(org.neo4j.kernel.internal.GraphDatabaseAPI db) throws java.io.IOException
        private static IList <TransactionRepresentation> ExtractTransactions(GraphDatabaseAPI db)
        {
            LogicalTransactionStore           txStore      = Db.DependencyResolver.resolveDependency(typeof(LogicalTransactionStore));
            IList <TransactionRepresentation> transactions = new List <TransactionRepresentation>();

            using (TransactionCursor cursor = txStore.GetTransactions(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_ID + 1))
            {
                cursor.forAll(tx => transactions.Add(tx.TransactionRepresentation));
            }
            return(transactions);
        }
Beispiel #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private long applyTransactions(java.io.File fromPath, org.neo4j.kernel.internal.GraphDatabaseAPI toDb, org.neo4j.kernel.configuration.Config toConfig, long fromTxExclusive, long toTxInclusive, java.io.PrintStream out) throws Exception
		 private long ApplyTransactions( File fromPath, GraphDatabaseAPI toDb, Config toConfig, long fromTxExclusive, long toTxInclusive, PrintStream @out )
		 {
			  DependencyResolver resolver = toDb.DependencyResolver;
			  TransactionRepresentationCommitProcess commitProcess = new TransactionRepresentationCommitProcess( resolver.ResolveDependency( typeof( TransactionAppender ) ), resolver.ResolveDependency( typeof( StorageEngine ) ) );
			  LifeSupport life = new LifeSupport();
			  try
			  {
					  using ( DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), JobScheduler jobScheduler = createInitialisedScheduler(), PageCache pageCache = StandalonePageCacheFactory.createPageCache(fileSystem, jobScheduler) )
					  {
						LogicalTransactionStore source = life.Add( new ReadOnlyTransactionStore( pageCache, fileSystem, DatabaseLayout.of( fromPath ), Config.defaults(), new Monitors() ) );
						life.Start();
						long lastAppliedTx = fromTxExclusive;
						// Some progress if there are more than a couple of transactions to apply
						ProgressListener progress = toTxInclusive - fromTxExclusive >= 100 ? textual( @out ).singlePart( "Application progress", toTxInclusive - fromTxExclusive ) : Org.Neo4j.Helpers.progress.ProgressListener_Fields.None;
						using ( IOCursor<CommittedTransactionRepresentation> cursor = source.GetTransactions( fromTxExclusive + 1 ) )
						{
							 while ( cursor.next() )
							 {
								  CommittedTransactionRepresentation transaction = cursor.get();
								  TransactionRepresentation transactionRepresentation = transaction.TransactionRepresentation;
								  try
								  {
										commitProcess.Commit( new TransactionToApply( transactionRepresentation ), NULL, EXTERNAL );
										progress.Add( 1 );
								  }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final Throwable e)
								  catch ( Exception e )
								  {
										Console.Error.WriteLine( "ERROR applying transaction " + transaction.CommitEntry.TxId );
										throw e;
								  }
								  lastAppliedTx = transaction.CommitEntry.TxId;
								  if ( lastAppliedTx == toTxInclusive )
								  {
										break;
								  }
							 }
						}
						return lastAppliedTx;
					  }
			  }
			  finally
			  {
					life.Shutdown();
			  }
		 }
Beispiel #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static java.util.List<org.neo4j.kernel.impl.transaction.TransactionRepresentation> createTransactionsForCreatingConstraint(System.Action<org.neo4j.kernel.internal.GraphDatabaseAPI> uniqueConstraintCreator) throws Exception
        private static IList <TransactionRepresentation> CreateTransactionsForCreatingConstraint(System.Action <GraphDatabaseAPI> uniqueConstraintCreator)
        {
            // A separate db altogether
            GraphDatabaseAPI db = ( GraphDatabaseAPI )(new TestEnterpriseGraphDatabaseFactory()).newImpermanentDatabase();

            try
            {
                CreateConstraint(db, uniqueConstraintCreator);
                LogicalTransactionStore           txStore      = Db.DependencyResolver.resolveDependency(typeof(LogicalTransactionStore));
                IList <TransactionRepresentation> transactions = new List <TransactionRepresentation>();
                using (TransactionCursor cursor = txStore.GetTransactions(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_ID + 1))
                {
                    cursor.forAll(tx => transactions.Add(tx.TransactionRepresentation));
                }
                return(transactions);
            }
            finally
            {
                Db.shutdown();
            }
        }
Beispiel #8
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: public org.neo4j.com.Response<?> copyStore(StoreWriter writer)
            public override Response <object> CopyStore(StoreWriter writer)
            {
                NeoStoreDataSource neoStoreDataSource = Original.DependencyResolver.resolveDependency(typeof(NeoStoreDataSource));

                TransactionIdStore transactionIdStore = Original.DependencyResolver.resolveDependency(typeof(TransactionIdStore));

                LogicalTransactionStore logicalTransactionStore = Original.DependencyResolver.resolveDependency(typeof(LogicalTransactionStore));

                CheckPointer checkPointer = Original.DependencyResolver.resolveDependency(typeof(CheckPointer));

                RequestContext requestContext = (new StoreCopyServer(neoStoreDataSource, checkPointer, Fs, OriginalDir, (new Monitors()).newMonitor(typeof(StoreCopyServer.Monitor)))).flushStoresAndStreamStoreFiles("test", writer, IncludeLogs);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.storageengine.api.StoreId storeId = original.getDependencyResolver().resolveDependency(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine.class).getStoreId();
                StoreId storeId = Original.DependencyResolver.resolveDependency(typeof(RecordStorageEngine)).StoreId;

                ResponsePacker responsePacker = new ResponsePacker(logicalTransactionStore, transactionIdStore, () => storeId);

                Response = spy(responsePacker.PackTransactionStreamResponse(requestContext, null));
                return(Response);
            }
Beispiel #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaveFixedTargetTransactionIdEvenIfLastTransactionIdIsMoving() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHaveFixedTargetTransactionIdEvenIfLastTransactionIdIsMoving()
        {
            // GIVEN
            LogicalTransactionStore transactionStore = mock(typeof(LogicalTransactionStore));
            long lastAppliedTransactionId            = 5L;
            TransactionCursor endlessCursor          = new EndlessCursor(this, lastAppliedTransactionId + 1);

            when(transactionStore.getTransactions(anyLong())).thenReturn(endlessCursor);
            const long targetTransactionId = 8L;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.TransactionIdStore transactionIdStore = new org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore(targetTransactionId, 0, BASE_TX_COMMIT_TIMESTAMP, 0, 0);
            TransactionIdStore transactionIdStore = new SimpleTransactionIdStore(targetTransactionId, 0, BASE_TX_COMMIT_TIMESTAMP, 0, 0);
            ResponsePacker     packer             = new ResponsePacker(transactionStore, transactionIdStore, Suppliers.singleton(StoreIdTestFactory.newStoreIdForCurrentVersion()));

            // WHEN
            Response <object> response = packer.PackTransactionStreamResponse(RequestContextStartingAt(5L), null);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicLong nextExpectedVisit = new java.util.concurrent.atomic.AtomicLong(lastAppliedTransactionId);
            AtomicLong nextExpectedVisit = new AtomicLong(lastAppliedTransactionId);

            response.Accept(new HandlerAnonymousInnerClass(this, targetTransactionId, transactionIdStore, nextExpectedVisit));
        }
Beispiel #10
0
 public ResponsePacker(LogicalTransactionStore transactionStore, TransactionIdStore transactionIdStore, System.Func <StoreId> storeId)
 {
     this.TransactionStore    = transactionStore;
     this._transactionIdStore = transactionIdStore;
     this.StoreId             = storeId;
 }
Beispiel #11
0
 public LastCommittedIndexFinder(TransactionIdStore transactionIdStore, LogicalTransactionStore transactionStore, LogProvider logProvider)
 {
     this._transactionIdStore = transactionIdStore;
     this._transactionStore   = transactionStore;
     this._log = logProvider.getLog(this.GetType());
 }
Beispiel #12
0
 public DefaultRecoveryServiceAnonymousInnerClass3(RecoveryTest outerInstance, StorageEngine storageEngine, LogTailScanner tailScanner, TransactionIdStore transactionIdStore, LogicalTransactionStore txStore, SimpleLogVersionRepository versionRepository, UnknownType noMonitor, AtomicBoolean recoveryRequired) : base(storageEngine, tailScanner, transactionIdStore, txStore, versionRepository, noMonitor)
 {
     this.outerInstance     = outerInstance;
     this._recoveryRequired = recoveryRequired;
 }
Beispiel #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void verifyTransaction(TransactionIdStore transactionIdStore, TransactionMetadataCache positionCache, byte[] additionalHeader, int masterId, int authorId, long timeStarted, long latestCommittedTxWhenStarted, long timeCommitted, LogicalTransactionStore store) throws java.io.IOException
        private void VerifyTransaction(TransactionIdStore transactionIdStore, TransactionMetadataCache positionCache, sbyte[] additionalHeader, int masterId, int authorId, long timeStarted, long latestCommittedTxWhenStarted, long timeCommitted, LogicalTransactionStore store)
        {
            TransactionMetadata expectedMetadata;

            using (TransactionCursor cursor = store.GetTransactions(TransactionIdStore_Fields.BASE_TX_ID + 1))
            {
                bool hasNext = cursor.next();
                assertTrue(hasNext);
                CommittedTransactionRepresentation tx          = cursor.get();
                TransactionRepresentation          transaction = tx.TransactionRepresentation;
                assertArrayEquals(additionalHeader, transaction.AdditionalHeader());
                assertEquals(masterId, transaction.MasterId);
                assertEquals(authorId, transaction.AuthorId);
                assertEquals(timeStarted, transaction.TimeStarted);
                assertEquals(timeCommitted, transaction.TimeCommitted);
                assertEquals(latestCommittedTxWhenStarted, transaction.LatestCommittedTxWhenStarted);
                expectedMetadata = new TransactionMetadata(masterId, authorId, tx.StartEntry.StartPosition, tx.StartEntry.checksum(), timeCommitted);
            }

            positionCache.Clear();

            TransactionMetadata actualMetadata = store.GetMetadataFor(transactionIdStore.LastCommittedTransactionId);

            assertEquals(expectedMetadata, actualMetadata);
        }