Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getPopulationFailureMustThrowEvenIfFailureOnOtherIndex()
        public virtual void getPopulationFailureMustThrowEvenIfFailureOnOtherIndex()
        {
            // given
            _provider = NewProvider();

            int            nonFailedIndexId   = NativeIndexProviderTests.INDEX_ID;
            IndexPopulator nonFailedPopulator = _provider.getPopulator(Descriptor(nonFailedIndexId), SamplingConfig(), heapBufferFactory(1024));

            nonFailedPopulator.Create();
            nonFailedPopulator.Close(true);

            int            failedIndexId   = 2;
            IndexPopulator failedPopulator = _provider.getPopulator(Descriptor(failedIndexId), SamplingConfig(), heapBufferFactory(1024));

            failedPopulator.Create();

            // when
            failedPopulator.MarkAsFailed("failure");
            failedPopulator.Close(false);

            // then
            try
            {
                _provider.getPopulationFailure(Descriptor(nonFailedIndexId));
                fail("Should have failed");
            }
            catch (System.InvalidOperationException e)
            {
                // good
                assertThat(e.Message, Matchers.containsString(Convert.ToString(nonFailedIndexId)));
            }
        }
Exemple #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void buildReferencePopulatorSingleThreaded(Generator[] generators, java.util.Collection<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates) throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
        private void BuildReferencePopulatorSingleThreaded <T1>(Generator[] generators, ICollection <T1> updates)
        {
            IndexPopulator referencePopulator = _indexProvider.getPopulator(_descriptor2, _samplingConfig, heapBufferFactory(1024));

            referencePopulator.Create();
            bool referenceSuccess = false;

            try
            {
                foreach (Generator generator in generators)
                {
                    generator.Reset();
                    for (int i = 0; i < BATCHES_PER_THREAD; i++)
                    {
                        referencePopulator.Add(generator.Batch());
                    }
                }
                using (IndexUpdater updater = referencePopulator.NewPopulatingUpdater(_nodePropertyAccessor))
                {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (org.neo4j.kernel.api.index.IndexEntryUpdate<?> update : updates)
                    foreach (IndexEntryUpdate <object> update in updates)
                    {
                        updater.Process(update);
                    }
                }
                referenceSuccess = true;
            }
            finally
            {
                referencePopulator.Close(referenceSuccess);
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void logConstraintJobProgress() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void LogConstraintJobProgress()
        {
            // Given
            CreateNode(map(_name, "irrelephant"), _first);
            AssertableLogProvider logProvider = new AssertableLogProvider();
            FlippableIndexProxy   index       = mock(typeof(FlippableIndexProxy));

            when(index.State).thenReturn(InternalIndexState.POPULATING);
            IndexPopulator populator = spy(IndexPopulator(false));

            try
            {
                IndexPopulationJob job = NewIndexPopulationJob(populator, index, _indexStoreView, logProvider, EntityType.NODE, IndexDescriptor(_first, _name, true));

                // When
                job.Run();

                // Then
                AssertableLogProvider.LogMatcherBuilder match = inLog(typeof(IndexPopulationJob));
                logProvider.AssertExactly(match.info("Index population started: [%s]", ":FIRST(name)"), match.info("Index created. Starting data checks. Index [%s] is %s.", ":FIRST(name)", "POPULATING"), match.info(containsString("TIME/PHASE Final: SCAN[")));
            }
            finally
            {
                populator.Close(true);
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void createEmptyIndex(org.neo4j.storageengine.api.schema.StoreIndexDescriptor schemaIndexDescriptor, SpatialIndexProvider provider) throws java.io.IOException
        private void CreateEmptyIndex(StoreIndexDescriptor schemaIndexDescriptor, SpatialIndexProvider provider)
        {
            IndexPopulator populator = provider.GetPopulator(schemaIndexDescriptor, SamplingConfig(), heapBufferFactory(1024));

            populator.Create();
            populator.Close(true);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Before()
        {
            IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
            IndexPopulator      populator           = IndexProvider.getPopulator(Descriptor, indexSamplingConfig, heapBufferFactory(1024));

            populator.Create();
            populator.Close(true);
            Accessor = IndexProvider.getOnlineAccessor(Descriptor, indexSamplingConfig);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToDropAClosedIndexPopulator() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToDropAClosedIndexPopulator()
        {
            // GIVEN
            IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final IndexPopulator p = indexProvider.getPopulator(descriptor, indexSamplingConfig, heapBufferFactory(1024));
            IndexPopulator p = IndexProvider.getPopulator(Descriptor, indexSamplingConfig, heapBufferFactory(1024));

            p.Close(false);

            // WHEN
            p.Drop();

            // THEN - no exception should be thrown (it's been known to!)
        }
Exemple #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportInitialStateAsOnlineIfPopulationCompletedSuccessfully()
        public virtual void ShouldReportInitialStateAsOnlineIfPopulationCompletedSuccessfully()
        {
            // given
            _provider = NewProvider();
            IndexPopulator populator = _provider.getPopulator(Descriptor(), SamplingConfig(), heapBufferFactory(1024));

            populator.Create();
            populator.Close(true);

            // when
            InternalIndexState state = _provider.getInitialState(Descriptor());

            // then
            assertEquals(InternalIndexState.ONLINE, state);
        }
Exemple #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportInitialStateAsPopulatingIfPopulationStartedButIncomplete()
        public virtual void ShouldReportInitialStateAsPopulatingIfPopulationStartedButIncomplete()
        {
            // given
            _provider = NewProvider();
            IndexPopulator populator = _provider.getPopulator(Descriptor(), SamplingConfig(), heapBufferFactory(1024));

            populator.Create();

            // when
            InternalIndexState state = _provider.getInitialState(Descriptor());

            // then
            assertEquals(InternalIndexState.POPULATING, state);
            populator.Close(true);
        }
Exemple #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportInitialStateAsFailedIfMarkedAsFailed()
        public virtual void ShouldReportInitialStateAsFailedIfMarkedAsFailed()
        {
            // given
            _provider = NewProvider();
            IndexPopulator populator = _provider.getPopulator(Descriptor(), SamplingConfig(), heapBufferFactory(1024));

            populator.Create();
            populator.MarkAsFailed("Just some failure");
            populator.Close(false);

            // when
            InternalIndexState state = _provider.getInitialState(Descriptor());

            // then
            assertEquals(InternalIndexState.FAILED, state);
        }
Exemple #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void withPopulator(IndexPopulator populator, org.neo4j.function.ThrowingConsumer<IndexPopulator,Exception> runWithPopulator, boolean closeSuccessfully) throws Exception
            internal virtual void WithPopulator(IndexPopulator populator, ThrowingConsumer <IndexPopulator, Exception> runWithPopulator, bool closeSuccessfully)
            {
                try
                {
                    populator.Create();
                    runWithPopulator.Accept(populator);
                    if (closeSuccessfully)
                    {
                        populator.ScanCompleted(Org.Neo4j.Kernel.Impl.Api.index.PhaseTracker_Fields.NullInstance);
                        TestSuite.consistencyCheck(populator);
                    }
                }
                finally
                {
                    populator.Close(closeSuccessfully);
                }
            }
Exemple #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getPopulationFailureMustReturnReportedFailure()
        public virtual void getPopulationFailureMustReturnReportedFailure()
        {
            // given
            _provider = NewProvider();
            IndexPopulator populator = _provider.getPopulator(Descriptor(), SamplingConfig(), heapBufferFactory(1024));

            populator.Create();

            // when
            string failureMessage = "fail";

            populator.MarkAsFailed(failureMessage);
            populator.Close(false);

            // then
            string populationFailure = _provider.getPopulationFailure(Descriptor());

            assertThat(populationFailure, @is(failureMessage));
        }
Exemple #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getPopulationFailureMustReturnReportedFailuresForDifferentIndexIds()
        public virtual void getPopulationFailureMustReturnReportedFailuresForDifferentIndexIds()
        {
            // given
            _provider = NewProvider();
            int            first          = 1;
            int            second         = 2;
            int            third          = 3;
            IndexPopulator firstPopulator = _provider.getPopulator(Descriptor(first), SamplingConfig(), heapBufferFactory(1024));

            firstPopulator.Create();
            IndexPopulator secondPopulator = _provider.getPopulator(Descriptor(second), SamplingConfig(), heapBufferFactory(1024));

            secondPopulator.Create();
            IndexPopulator thirdPopulator = _provider.getPopulator(Descriptor(third), SamplingConfig(), heapBufferFactory(1024));

            thirdPopulator.Create();

            // when
            string firstFailure = "first failure";

            firstPopulator.MarkAsFailed(firstFailure);
            firstPopulator.Close(false);
            secondPopulator.Close(true);
            string thirdFailure = "third failure";

            thirdPopulator.MarkAsFailed(thirdFailure);
            thirdPopulator.Close(false);

            // then
            assertThat(_provider.getPopulationFailure(Descriptor(first)), @is(firstFailure));
            assertThat(_provider.getPopulationFailure(Descriptor(third)), @is(thirdFailure));
            try
            {
                _provider.getPopulationFailure(Descriptor(second));
                fail("Should have failed");
            }
            catch (System.InvalidOperationException)
            {
                // good
            }
        }
Exemple #13
0
        /* getPopulationFailure */

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getPopulationFailureMustThrowIfNoFailure()
        public virtual void getPopulationFailureMustThrowIfNoFailure()
        {
            // given
            _provider = NewProvider();
            IndexPopulator populator = _provider.getPopulator(Descriptor(), SamplingConfig(), heapBufferFactory(1024));

            populator.Create();
            populator.Close(true);

            // when
            // ... no failure on populator

            // then
            try
            {
                _provider.getPopulationFailure(Descriptor());
                fail("Should have failed");
            }
            catch (System.InvalidOperationException e)
            {
                // good
                assertThat(e.Message, Matchers.containsString(Convert.ToString(INDEX_ID)));
            }
        }