Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotLeaveLuceneIndexFilesHangingAroundIfConstraintCreationFails()
        public virtual void ShouldNotLeaveLuceneIndexFilesHangingAroundIfConstraintCreationFails()
        {
            // given
            Db.withSetting(default_schema_provider, NATIVE20.providerName());                 // <-- includes Lucene sub-provider
            AttemptAndFailConstraintCreation();

            // then
            IndexProvider indexProvider = Db.DependencyResolver.resolveDependency(typeof(IndexProviderMap)).DefaultProvider;
            File          indexDir      = indexProvider.DirectoryStructure().directoryForIndex(INDEX_ID);

            assertFalse((new IndexFolderLayout(indexDir)).IndexFolder.exists());
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaveAvailableOrphanedConstraintIndexIfUniqueConstraintCreationFails()
        public virtual void ShouldHaveAvailableOrphanedConstraintIndexIfUniqueConstraintCreationFails()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction fs = fileSystemRule.get();
            EphemeralFileSystemAbstraction fs = FileSystemRule.get();

            fs.Mkdir(new File("/tmp"));
            File pathToDb = new File("/tmp/bar2");

            TestGraphDatabaseFactory dbFactory = new TestGraphDatabaseFactory();

            dbFactory.FileSystem = fs;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction[] storeInNeedOfRecovery = new org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction[1];
            EphemeralFileSystemAbstraction[] storeInNeedOfRecovery = new EphemeralFileSystemAbstraction[1];
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean monitorCalled = new java.util.concurrent.atomic.AtomicBoolean(false);
            AtomicBoolean monitorCalled = new AtomicBoolean(false);

            Monitors monitors = new Monitors();

            monitors.AddMonitorListener(new MonitorAdapterAnonymousInnerClass(this, fs, storeInNeedOfRecovery, monitorCalled));
            dbFactory.Monitors = monitors;

            // This test relies on behaviour that is specific to the Lucene populator, where uniqueness is controlled
            // after index has been populated, which is why we're using NATIVE20 and index booleans (they end up in Lucene)
            _db = ( GraphDatabaseAPI )dbFactory.NewImpermanentDatabaseBuilder(pathToDb).setConfig(default_schema_provider, NATIVE20.providerName()).newGraphDatabase();

            using (Transaction tx = _db.beginTx())
            {
                for (int i = 0; i < 2; i++)
                {
                    _db.createNode(_label).setProperty(KEY, true);
                }

                tx.Success();
            }

            try
            {
                using (Transaction tx = _db.beginTx())
                {
                    _db.schema().constraintFor(_label).assertPropertyIsUnique(KEY).create();
                    fail("Should have failed with ConstraintViolationException");
                    tx.Success();
                }
            }
            catch (ConstraintViolationException)
            {
            }

            _db.shutdown();

            assertTrue(monitorCalled.get());

            // when
            dbFactory            = new TestGraphDatabaseFactory();
            dbFactory.FileSystem = storeInNeedOfRecovery[0];
            _db = ( GraphDatabaseAPI )dbFactory.NewImpermanentDatabase(pathToDb);

            // then
            using (Transaction ignore = _db.beginTx())
            {
                _db.schema().awaitIndexesOnline(10, TimeUnit.SECONDS);
            }

            using (Transaction ignore = _db.beginTx())
            {
                assertEquals(2, Iterables.count(_db.AllNodes));
            }

            using (Transaction ignore = _db.beginTx())
            {
                assertEquals(0, Iterables.count(Iterables.asList(_db.schema().Constraints)));
            }

            using (Transaction ignore = _db.beginTx())
            {
                IndexDefinition orphanedConstraintIndex = single(_db.schema().Indexes);
                assertEquals(_label.name(), single(orphanedConstraintIndex.Labels).name());
                assertEquals(KEY, single(orphanedConstraintIndex.PropertyKeys));
            }

            _db.shutdown();
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void oldLuceneSchemaIndexShouldBeConsideredConsistentWithFusionProvider() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void OldLuceneSchemaIndexShouldBeConsideredConsistentWithFusionProvider()
        {
            DatabaseLayout databaseLayout        = _testDirectory.databaseLayout();
            string         defaultSchemaProvider = GraphDatabaseSettings.default_schema_provider.name();
            Label          label   = Label.label("label");
            string         propKey = "propKey";

            // Given a lucene index
            GraphDatabaseService db = GetGraphDatabaseService(databaseLayout.DatabaseDirectory(), defaultSchemaProvider, LUCENE10.providerName());

            CreateIndex(db, label, propKey);
            using (Transaction tx = Db.beginTx())
            {
                Db.createNode(label).setProperty(propKey, 1);
                Db.createNode(label).setProperty(propKey, "string");
                tx.Success();
            }
            Db.shutdown();

            ConsistencyCheckService service = new ConsistencyCheckService();
            Config configuration            = Config.defaults(Settings(defaultSchemaProvider, NATIVE20.providerName()));
            Result result = RunFullConsistencyCheck(service, configuration, databaseLayout);

            assertTrue(result.Successful);
        }
        protected internal override IndexProvider CreateIndexProvider(PageCache pageCache, FileSystemAbstraction fs, File graphDbDir)
        {
            IndexProvider.Monitor monitor = IndexProvider.Monitor_Fields.EMPTY;
            Config          config        = Config.defaults(stringMap(default_schema_provider.name(), NATIVE20.providerName()));
            OperationalMode mode          = OperationalMode.single;
            RecoveryCleanupWorkCollector recoveryCleanupWorkCollector = RecoveryCleanupWorkCollector.immediate();

            return(NativeLuceneFusionIndexProviderFactory20.Create(pageCache, graphDbDir, fs, monitor, config, mode, recoveryCleanupWorkCollector));
        }