コード例 #1
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> createConstraintCreatingTransactions() throws Exception
        private static IList <TransactionRepresentation> CreateConstraintCreatingTransactions()
        {
            GraphDatabaseAPI db = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newImpermanentDatabase();

            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    Db.schema().constraintFor(LABEL).assertPropertyIsUnique(KEY).create();
                    tx.Success();
                }

                LogicalTransactionStore           txStore = Db.DependencyResolver.resolveDependency(typeof(LogicalTransactionStore));
                IList <TransactionRepresentation> result  = new List <TransactionRepresentation>();
                using (TransactionCursor cursor = txStore.GetTransactions(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_ID + 1))
                {
                    while (cursor.next())
                    {
                        result.Add(cursor.get().TransactionRepresentation);
                    }
                }
                return(result);
            }
            finally
            {
                Db.shutdown();
            }
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
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();
			  }
		 }
コード例 #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> 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();
            }
        }