Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDropUniquenessConstraintWhereConstraintRecordIsMissingAndIndexHasNoOwner() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
		 public virtual void ShouldDropUniquenessConstraintWhereConstraintRecordIsMissingAndIndexHasNoOwner()
		 {
			  // given
			  using ( Transaction tx = Db.beginTx() )
			  {
					Db.schema().constraintFor(_label).assertPropertyIsUnique(_key).create();
					tx.Success();
			  }

			  // when intentionally breaking the schema by setting the backing index rule to unused
			  RecordStorageEngine storageEngine = Db.DependencyResolver.resolveDependency( typeof( RecordStorageEngine ) );
			  SchemaStore schemaStore = storageEngine.TestAccessNeoStores().SchemaStore;
			  SchemaRule constraintRule = single( filter( rule => rule is ConstraintRule, schemaStore.LoadAllSchemaRules() ) );
			  SetSchemaRecordNotInUse( schemaStore, constraintRule.Id );
			  SchemaRule indexRule = single( filter( rule => rule is StoreIndexDescriptor, schemaStore.LoadAllSchemaRules() ) );
			  SetOwnerNull( schemaStore, ( StoreIndexDescriptor ) indexRule );
			  // At this point the SchemaCache doesn't know about this change so we have to reload it
			  storageEngine.LoadSchemaCache();
			  using ( Transaction tx = Db.beginTx() )
			  {
					// We don't use single() here, because it is okay for the schema cache reload to clean up after us.
					Db.schema().getConstraints(_label).forEach(ConstraintDefinition.drop);
					Db.schema().getIndexes(_label).forEach(IndexDefinition.drop);
					tx.Success();
			  }

			  // then
			  using ( Transaction ignore = Db.beginTx() )
			  {
					assertFalse( Db.schema().Constraints.GetEnumerator().hasNext() );
					assertFalse( Db.schema().Indexes.GetEnumerator().hasNext() );
			  }
		 }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDropUniquenessConstraintWithBackingIndexHavingNoOwner() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
		 public virtual void ShouldDropUniquenessConstraintWithBackingIndexHavingNoOwner()
		 {
			  // given
			  using ( Transaction tx = Db.beginTx() )
			  {
					Db.schema().constraintFor(_label).assertPropertyIsUnique(_key).create();
					tx.Success();
			  }

			  // when intentionally breaking the schema by setting the backing index rule to unused
			  RecordStorageEngine storageEngine = Db.DependencyResolver.resolveDependency( typeof( RecordStorageEngine ) );
			  SchemaStore schemaStore = storageEngine.TestAccessNeoStores().SchemaStore;
			  SchemaRule indexRule = single( filter( rule => rule is StoreIndexDescriptor, schemaStore.LoadAllSchemaRules() ) );
			  SetOwnerNull( schemaStore, ( StoreIndexDescriptor ) indexRule );
			  // At this point the SchemaCache doesn't know about this change so we have to reload it
			  storageEngine.LoadSchemaCache();
			  using ( Transaction tx = Db.beginTx() )
			  {
					single( Db.schema().getConstraints(_label).GetEnumerator() ).drop();
					tx.Success();
			  }

			  // then
			  using ( Transaction ignore = Db.beginTx() )
			  {
					assertFalse( Db.schema().Constraints.GetEnumerator().hasNext() );
					assertFalse( Db.schema().Indexes.GetEnumerator().hasNext() );
			  }
		 }
Beispiel #3
0
        private void PrepareDbWithDeletedRelationshipPartOfTheChain()
        {
            GraphDatabaseAPI db = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(_testDirectory.databaseDir()).setConfig(GraphDatabaseSettings.record_format, RecordFormatName).setConfig("dbms.backup.enabled", "false").newGraphDatabase();

            try
            {
                RelationshipType relationshipType = RelationshipType.withName("testRelationshipType");
                using (Transaction tx = Db.beginTx())
                {
                    Node node1 = set(Db.createNode());
                    Node node2 = set(Db.createNode(), property("key", "value"));
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    tx.Success();
                }

                RecordStorageEngine recordStorageEngine = Db.DependencyResolver.resolveDependency(typeof(RecordStorageEngine));

                NeoStores          neoStores          = recordStorageEngine.TestAccessNeoStores();
                RelationshipStore  relationshipStore  = neoStores.RelationshipStore;
                RelationshipRecord relationshipRecord = new RelationshipRecord(-1);
                RelationshipRecord record             = relationshipStore.GetRecord(4, relationshipRecord, RecordLoad.FORCE);
                record.InUse = false;
                relationshipStore.UpdateRecord(relationshipRecord);
            }
            finally
            {
                Db.shutdown();
            }
        }
            internal Worker(IndexWorkSyncTransactionApplicationStressIT outerInstance, int id, AtomicBoolean end, RecordStorageEngine storageEngine, int batchSize, IndexProxy index)
            {
                this._outerInstance = outerInstance;
                this.Id             = id;
                this.End            = end;
                this.StorageEngine  = storageEngine;
                this.BatchSize      = batchSize;
                this.Index          = index;
                NeoStores neoStores = this.StorageEngine.testAccessNeoStores();

                this.NodeIds = neoStores.NodeStore;
                this.CommandCreationContext = storageEngine.AllocateCommandCreationContext();
            }
Beispiel #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void skipMigrationIfStoreFormatNotSpecifiedButIsAvailableInRuntime()
        internal virtual void SkipMigrationIfStoreFormatNotSpecifiedButIsAvailableInRuntime()
        {
            GraphDatabaseService database = StartDatabaseWithFormatUnspecifiedUpgrade(_storeDir, StandardV3_2.NAME);

            using (Transaction transaction = database.BeginTx())
            {
                Node node = database.CreateNode();
                node.SetProperty("a", "b");
                transaction.Success();
            }
            database.Shutdown();

            GraphDatabaseAPI    nonUpgradedStore = ( GraphDatabaseAPI )(new GraphDatabaseFactory()).newEmbeddedDatabase(_storeDir);
            RecordStorageEngine storageEngine    = nonUpgradedStore.DependencyResolver.resolveDependency(typeof(RecordStorageEngine));

            assertEquals(StandardV3_2.NAME, storageEngine.TestAccessNeoStores().RecordFormats.name());
            nonUpgradedStore.Shutdown();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldApplyIndexUpdatesInWorkSyncedBatches() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldApplyIndexUpdatesInWorkSyncedBatches()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            long duration = parseTimeMillis.apply(System.getProperty(this.GetType().FullName + ".duration", "2s"));
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            int numThreads = Integer.getInteger(this.GetType().FullName + ".numThreads", Runtime.Runtime.availableProcessors());
            DefaultFileSystemAbstraction fs   = _fileSystemRule.get();
            PageCache           pageCache     = _pageCacheRule.getPageCache(fs);
            FusionIndexProvider indexProvider = NativeLuceneFusionIndexProviderFactory20.create(pageCache, _directory.databaseDir(), fs, IndexProvider.Monitor_Fields.EMPTY, Config.defaults(), OperationalMode.single, RecoveryCleanupWorkCollector.immediate());
            RecordStorageEngine storageEngine = _storageEngineRule.getWith(fs, pageCache, _directory.databaseLayout()).indexProvider(indexProvider).build();

            storageEngine.Apply(Tx(singletonList(createIndexRule(DESCRIPTOR, 1, _descriptor))), TransactionApplicationMode.EXTERNAL);
            Dependencies dependencies = new Dependencies();

            storageEngine.SatisfyDependencies(dependencies);
            IndexProxy index = dependencies.ResolveDependency(typeof(IndexingService)).getIndexProxy(_descriptor);

            AwaitOnline(index);

            // WHEN
            Workers <Worker> workers = new Workers <Worker>(this.GetType().Name);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean end = new java.util.concurrent.atomic.AtomicBoolean();
            AtomicBoolean end = new AtomicBoolean();

            for (int i = 0; i < numThreads; i++)
            {
                workers.Start(new Worker(this, i, end, storageEngine, 10, index));
            }

            // let the threads hammer the storage engine for some time
            Thread.Sleep(duration);
            end.set(true);

            // THEN (assertions as part of the workers applying transactions)
            workers.AwaitAndThrowOnError();
        }
Beispiel #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void rotationShouldNotCauseUnmappedFileProblem() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RotationShouldNotCauseUnmappedFileProblem()
        {
            // GIVEN
            GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase();

            DependencyResolver  resolver      = Db.DependencyResolver;
            RecordStorageEngine storageEngine = resolver.ResolveDependency(typeof(RecordStorageEngine));
            CountsTracker       countStore    = storageEngine.TestAccessNeoStores().Counts;

            AtomicBoolean workerContinueFlag = new AtomicBoolean(true);
            AtomicLong    lookupsCounter     = new AtomicLong();
            int           rotations          = 100;

            for (int i = 0; i < 5; i++)
            {
                _threadingRule.execute(CountStoreLookup(workerContinueFlag, lookupsCounter), countStore);
            }

            long startTxId = countStore.TxId();

            for (int i = 1; (i < rotations) || (lookupsCounter.get() == 0); i++)
            {
                using (Transaction tx = Db.beginTx())
                {
                    Db.createNode(_b);
                    tx.Success();
                }
                CheckPoint(db);
            }
            workerContinueFlag.set(false);

            assertEquals("Should perform at least 100 rotations.", rotations, Math.Min(rotations, countStore.TxId() - startTxId));
            assertTrue("Should perform more then 0 lookups without exceptions.", lookupsCounter.get() > 0);

            Db.shutdown();
        }