Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testIndexFlip()
        public virtual void TestIndexFlip()
        {
            IndexProxyFactory       indexProxyFactory       = mock(typeof(IndexProxyFactory));
            FailedIndexProxyFactory failedIndexProxyFactory = mock(typeof(FailedIndexProxyFactory));
            FlippableIndexProxy     flipper = new FlippableIndexProxy();

            flipper.FlipTarget = indexProxyFactory;

            IndexPopulator indexPopulator1 = CreateIndexPopulator();
            IndexPopulator indexPopulator2 = CreateIndexPopulator();

            AddPopulator(indexPopulator1, 1, flipper, failedIndexProxyFactory);
            AddPopulator(indexPopulator2, 2, flipper, failedIndexProxyFactory);

            when(indexPopulator1.SampleResult()).thenThrow(SampleError);

            _multipleIndexPopulator.indexAllEntities();
            _multipleIndexPopulator.flipAfterPopulation(false);

            verify(indexPopulator1).close(false);
            verify(failedIndexProxyFactory, times(1)).create(any(typeof(Exception)));

            verify(indexPopulator2).close(true);
            verify(indexPopulator2).sampleResult();
            verify(_indexStoreView).replaceIndexCounts(anyLong(), anyLong(), anyLong(), anyLong());
            verify(_schemaState).clear();
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void flip(java.util.concurrent.Callable<bool> actionDuringFlip, FailedIndexProxyFactory failureDelegate) throws org.neo4j.kernel.api.exceptions.index.FlipFailedKernelException
        public virtual void Flip(Callable <bool> actionDuringFlip, FailedIndexProxyFactory failureDelegate)
        {
            @lock.writeLock().@lock();
            try
            {
                AssertOpen();
                try
                {
                    if (actionDuringFlip.call())
                    {
                        this.@delegate = _flipTarget.create();
                        if (_started)
                        {
                            [email protected]();
                        }
                    }
                }
                catch (Exception e)
                {
                    this.@delegate = failureDelegate.Create(e);
                    throw new ExceptionDuringFlipKernelException(e);
                }
            }
            finally
            {
                @lock.writeLock().unlock();
            }
        }
        private IndexPopulationJob NewIndexPopulationJob(FailedIndexProxyFactory failureDelegateFactory, IndexPopulator populator, FlippableIndexProxy flipper, IndexStoreView storeView, LogProvider logProvider, EntityType type, IndexDescriptor descriptor)
        {
            long indexId = 0;

            flipper.FlipTarget = mock(typeof(IndexProxyFactory));

            MultipleIndexPopulator multiPopulator = new MultipleIndexPopulator(storeView, logProvider, type, _stateHolder);
            IndexPopulationJob     job            = new IndexPopulationJob(multiPopulator, NO_MONITOR, false);

            job.AddPopulator(populator, descriptor.WithId(indexId).withoutCapabilities(), format(":%s(%s)", _first.name(), _name), flipper, failureDelegateFactory);
            return(job);
        }
Exemple #4
0
        private static IndexPopulator AddPopulator(BatchingMultipleIndexPopulator batchingPopulator, IndexDescriptor descriptor)
        {
            IndexPopulator populator = mock(typeof(IndexPopulator));

            IndexProxyFactory       indexProxyFactory       = mock(typeof(IndexProxyFactory));
            FailedIndexProxyFactory failedIndexProxyFactory = mock(typeof(FailedIndexProxyFactory));
            FlippableIndexProxy     flipper = new FlippableIndexProxy();

            flipper.FlipTarget = indexProxyFactory;

            batchingPopulator.AddPopulator(populator, descriptor.WithId(1).withoutCapabilities(), flipper, failedIndexProxyFactory, "testIndex");

            return(populator);
        }
            internal IndexPopulation(MultipleIndexPopulator outerInstance, IndexPopulator populator, CapableIndexDescriptor capableIndexDescriptor, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory, string indexUserDescription)
            {
                this._outerInstance         = outerInstance;
                this.Populator              = populator;
                this.CapableIndexDescriptor = capableIndexDescriptor;
                this.IndexId = capableIndexDescriptor.Id;
                this.Flipper = flipper;
                this.FailedIndexProxyFactory = failedIndexProxyFactory;
                this.IndexUserDescription    = indexUserDescription;
                this.IndexCountsRemover      = new IndexCountsRemover(outerInstance.storeView, IndexId);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: this.batchedUpdates = new java.util.ArrayList<>(BATCH_SIZE);
                this.BatchedUpdates = new List <IndexEntryUpdate <object> >(outerInstance.BatchSize);
            }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFlipToFailedUsingFailedIndexProxyFactory() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFlipToFailedUsingFailedIndexProxyFactory()
        {
            // Given
            FailedIndexProxyFactory failureDelegateFactory = mock(typeof(FailedIndexProxyFactory));
            IndexPopulator          populator = spy(IndexPopulator(false));
            IndexPopulationJob      job       = NewIndexPopulationJob(failureDelegateFactory, populator, new FlippableIndexProxy(), _indexStoreView, NullLogProvider.Instance, EntityType.NODE, IndexDescriptor(_first, _name, false));

            System.InvalidOperationException failure = new System.InvalidOperationException("not successful");
            doThrow(failure).when(populator).close(true);

            // When
            job.Run();

            // Then
            verify(failureDelegateFactory).create(any(typeof(Exception)));
        }
Exemple #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldVerifyConstraintsBeforeFlippingIfToldTo() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldVerifyConstraintsBeforeFlippingIfToldTo()
        {
            // given
            IndexProxyFactory       indexProxyFactory       = mock(typeof(IndexProxyFactory));
            FailedIndexProxyFactory failedIndexProxyFactory = mock(typeof(FailedIndexProxyFactory));
            FlippableIndexProxy     flipper = new FlippableIndexProxy();

            flipper.FlipTarget = indexProxyFactory;
            IndexPopulator indexPopulator = CreateIndexPopulator();

            AddPopulator(indexPopulator, 1, flipper, failedIndexProxyFactory);
            when(indexPopulator.SampleResult()).thenReturn(new IndexSample());

            // when
            _multipleIndexPopulator.indexAllEntities();
            _multipleIndexPopulator.flipAfterPopulation(true);

            // then
            verify(indexPopulator).verifyDeferredConstraints(any(typeof(NodePropertyAccessor)));
            verify(indexPopulator).close(true);
        }
Exemple #8
0
 private MultipleIndexPopulator.IndexPopulation AddPopulator(MultipleIndexPopulator multipleIndexPopulator, StoreIndexDescriptor descriptor, IndexPopulator indexPopulator, FlippableIndexProxy flippableIndexProxy, FailedIndexProxyFactory failedIndexProxyFactory)
 {
     return(multipleIndexPopulator.AddPopulator(indexPopulator, descriptor.WithoutCapabilities(), flippableIndexProxy, failedIndexProxyFactory, "userIndexDescription"));
 }
Exemple #9
0
 private IndexPopulation AddPopulator(MultipleIndexPopulator multipleIndexPopulator, IndexPopulator indexPopulator, int id, FlippableIndexProxy flippableIndexProxy, FailedIndexProxyFactory failedIndexProxyFactory)
 {
     return(AddPopulator(multipleIndexPopulator, TestIndexDescriptorFactory.forLabel(id, id).withId(id), indexPopulator, flippableIndexProxy, failedIndexProxyFactory));
 }
Exemple #10
0
 private IndexPopulation AddPopulator(IndexPopulator indexPopulator, int id, FlippableIndexProxy flippableIndexProxy, FailedIndexProxyFactory failedIndexProxyFactory)
 {
     return(AddPopulator(_multipleIndexPopulator, indexPopulator, id, flippableIndexProxy, failedIndexProxyFactory));
 }
 private IndexPopulation CreatePopulation(IndexPopulator populator, CapableIndexDescriptor capableIndexDescriptor, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory, string indexUserDescription)
 {
     return(new IndexPopulation(this, populator, capableIndexDescriptor, flipper, failedIndexProxyFactory, indexUserDescription));
 }
        internal virtual IndexPopulation AddPopulator(IndexPopulator populator, CapableIndexDescriptor capableIndexDescriptor, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory, string indexUserDescription)
        {
            IndexPopulation population = CreatePopulation(populator, capableIndexDescriptor, flipper, failedIndexProxyFactory, indexUserDescription);

            Populations.Add(population);
            return(population);
        }
Exemple #13
0
 /// <summary>
 /// Adds an <seealso cref="IndexPopulator"/> to be populated in this store scan. All participating populators must
 /// be added before calling <seealso cref="run()"/>. </summary>
 ///  <param name="populator"> <seealso cref="IndexPopulator"/> to participate. </param>
 /// <param name="capableIndexDescriptor"> <seealso cref="CapableIndexDescriptor"/> meta information about index. </param>
 /// <param name="indexUserDescription"> user description of this index. </param>
 /// <param name="flipper"> <seealso cref="FlippableIndexProxy"/> to call after a successful population. </param>
 /// <param name="failedIndexProxyFactory"> <seealso cref="FailedIndexProxyFactory"/> to use after an unsuccessful population. </param>
 internal virtual MultipleIndexPopulator.IndexPopulation AddPopulator(IndexPopulator populator, CapableIndexDescriptor capableIndexDescriptor, string indexUserDescription, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory)
 {
     Debug.Assert(_storeScan == null, "Population have already started, too late to add populators at this point");
     return(this._multiPopulator.addPopulator(populator, capableIndexDescriptor, flipper, failedIndexProxyFactory, indexUserDescription));
 }