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);
        }
            public override void Process <T1>(IndexEntryUpdate <T1> update)
            {
                Pair <IndexPopulation, IndexUpdater> pair = PopulationsWithUpdaters[update.IndexKey().schema()];

                if (pair != null)
                {
                    IndexPopulation population = pair.First();
                    IndexUpdater    updater    = pair.Other();

                    try
                    {
                        population.Populator.includeSample(update);
                        updater.Process(update);
                    }
                    catch (Exception t)
                    {
                        try
                        {
                            updater.Close();
                        }
                        catch (Exception ce)
                        {
                            Log.error(format("Failed to close index updater: [%s]", updater), ce);
                        }
                        PopulationsWithUpdaters.Remove(update.IndexKey().schema());
                        MultipleIndexPopulator.fail(population, t);
                    }
                }
            }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void cancelAndDropShouldCallDropOnPopulator() throws org.neo4j.kernel.api.exceptions.index.FlipFailedKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CancelAndDropShouldCallDropOnPopulator()
        {
            IndexPopulator  populator       = CreateIndexPopulator();
            IndexPopulation indexPopulation = AddPopulator(populator, 1);

            indexPopulation.CancelAndDrop();

            verify(populator, never()).close(false);
            verify(populator).drop();
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testFailByNonExistingPopulation() throws org.neo4j.kernel.api.exceptions.index.FlipFailedKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestFailByNonExistingPopulation()
        {
            IndexPopulation nonExistingPopulation = mock(typeof(IndexPopulation));
            IndexPopulator  populator             = CreateIndexPopulator();

            AddPopulator(populator, 1);

            _multipleIndexPopulator.fail(nonExistingPopulation, PopulatorException);

            verify(populator, never()).markAsFailed(anyString());
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canceledPopulationNotAbleToFlip() throws org.neo4j.kernel.api.exceptions.index.FlipFailedKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CanceledPopulationNotAbleToFlip()
        {
            IndexPopulator  populator       = CreateIndexPopulator();
            IndexPopulation indexPopulation = AddPopulator(populator, 1);

            indexPopulation.Cancel();

            indexPopulation.Flip(false);

            verify(indexPopulation.Populator, never()).sampleResult();
        }
 internal virtual void DoFlush(IndexPopulation population)
 {
     try
     {
         population.Populator.add(population.TakeCurrentBatch());
     }
     catch (Exception failure)
     {
         Fail(population, failure);
     }
 }
Example #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void flippedPopulationAreNotCanceable() throws org.neo4j.kernel.api.exceptions.index.FlipFailedKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void FlippedPopulationAreNotCanceable()
        {
            IndexPopulator  populator       = CreateIndexPopulator();
            IndexPopulation indexPopulation = AddPopulator(populator, 1);

            indexPopulation.Flip(false);

            indexPopulation.Cancel();

            verify(indexPopulation.Populator, never()).close(false);
        }
Example #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canceledPopulationNotAbleToCreateNewIndex() throws org.neo4j.kernel.api.exceptions.index.FlipFailedKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CanceledPopulationNotAbleToCreateNewIndex()
        {
            IndexPopulator  populator       = CreateIndexPopulator();
            IndexPopulation indexPopulation = AddPopulator(populator, 1);

            indexPopulation.Cancel();

            _multipleIndexPopulator.create();

            verify(populator, never()).create();
        }
Example #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testFailByPopulation() throws org.neo4j.kernel.api.exceptions.index.FlipFailedKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestFailByPopulation()
        {
            IndexPopulator populator1 = CreateIndexPopulator();
            IndexPopulator populator2 = CreateIndexPopulator();

            AddPopulator(populator1, 1);
            IndexPopulation population2 = AddPopulator(populator2, 2);

            _multipleIndexPopulator.fail(population2, PopulatorException);

            verify(populator1, never()).markAsFailed(anyString());
            CheckPopulatorFailure(populator2);
        }
Example #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testFailByPopulationRemovesPopulator() throws org.neo4j.kernel.api.exceptions.index.FlipFailedKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestFailByPopulationRemovesPopulator()
        {
            IndexPopulator populator1 = CreateIndexPopulator();
            IndexPopulator populator2 = CreateIndexPopulator();

            IndexPopulation population1 = AddPopulator(populator1, 1);
            IndexPopulation population2 = AddPopulator(populator2, 2);

            _multipleIndexPopulator.fail(population1, PopulatorException);
            _multipleIndexPopulator.fail(population2, PopulatorException);

            CheckPopulatorFailure(populator1);
            CheckPopulatorFailure(populator2);
            assertFalse(_multipleIndexPopulator.hasPopulators());
        }
Example #11
0
            public override void Close()
            {
                foreach (Pair <IndexPopulation, IndexUpdater> pair in PopulationsWithUpdaters.Values)
                {
                    IndexPopulation population = pair.First();
                    IndexUpdater    updater    = pair.Other();

                    try
                    {
                        updater.Close();
                    }
                    catch (Exception t)
                    {
                        MultipleIndexPopulator.fail(population, t);
                    }
                }
                PopulationsWithUpdaters.Clear();
            }
Example #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void cancelingSinglePopulatorDoNotCancelAnyOther() throws org.neo4j.kernel.api.exceptions.index.FlipFailedKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CancelingSinglePopulatorDoNotCancelAnyOther()
        {
            IndexPopulator indexPopulator1 = CreateIndexPopulator();
            IndexPopulator indexPopulator2 = CreateIndexPopulator();

            IndexPopulation populationToCancel     = AddPopulator(indexPopulator1, 1);
            IndexPopulation populationToKeepActive = AddPopulator(indexPopulator2, 2);

            _multipleIndexPopulator.create();

            _multipleIndexPopulator.cancelIndexPopulation(populationToCancel);

            _multipleIndexPopulator.indexAllEntities();

            assertTrue(_multipleIndexPopulator.hasPopulators());

            _multipleIndexPopulator.flipAfterPopulation(false);

            verify(populationToKeepActive.Flipper).flip(any(typeof(Callable)), any(typeof(FailedIndexProxyFactory)));
        }
Example #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canceledPopulatorDoNotFlipWhenPopulationCompleted() throws org.neo4j.kernel.api.exceptions.index.FlipFailedKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CanceledPopulatorDoNotFlipWhenPopulationCompleted()
        {
            IndexPopulator indexPopulator1 = CreateIndexPopulator();
            IndexPopulator indexPopulator2 = CreateIndexPopulator();

            IndexPopulation populationToCancel = AddPopulator(indexPopulator1, 1);

            AddPopulator(indexPopulator2, 2);

            _multipleIndexPopulator.create();

            _multipleIndexPopulator.cancelIndexPopulation(populationToCancel);

            _multipleIndexPopulator.indexAllEntities();

            assertTrue(_multipleIndexPopulator.hasPopulators());

            _multipleIndexPopulator.flipAfterPopulation(false);

            verify(populationToCancel.Flipper, never()).flip(any(typeof(Callable)), any(typeof(FailedIndexProxyFactory)));
        }
Example #14
0
        protected internal virtual void Fail(IndexPopulation population, Exception failure)
        {
            if (!RemoveFromOngoingPopulations(population))
            {
                return;
            }

            // If the cause of index population failure is a conflict in a (unique) index, the conflict is the failure
            if (failure is IndexPopulationFailedKernelException)
            {
                Exception cause = failure.InnerException;
                if (cause is IndexEntryConflictException)
                {
                    failure = cause;
                }
            }

            Log.error(format("Failed to populate index: [%s]", population.IndexUserDescription), failure);

            // The flipper will have already flipped to a failed index context here, but
            // it will not include the cause of failure, so we do another flip to a failed
            // context that does.

            // The reason for having the flipper transition to the failed index context in the first
            // place is that we would otherwise introduce a race condition where updates could come
            // in to the old context, if something failed in the job we send to the flipper.
            IndexPopulationFailure indexPopulationFailure = failure(failure);

            population.FlipToFailed(indexPopulationFailure);
            try
            {
                population.Populator.markAsFailed(indexPopulationFailure.AsString());
                population.Populator.close(false);
            }
            catch (Exception e)
            {
                Log.error(format("Unable to close failed populator for index: [%s]", population.IndexUserDescription), e);
            }
        }
        /// <summary>
        /// Insert the given batch of updates into the index defined by the given <seealso cref="IndexPopulation"/>.
        /// Called from <seealso cref="MultipleIndexPopulator.flush(IndexPopulation)"/>.
        /// </summary>
        /// <param name="population"> the index population. </param>
        internal override void DoFlush(IndexPopulation population)
        {
            _activeTasks.incrementAndGet();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> batch = population.takeCurrentBatch();
            IList <IndexEntryUpdate <object> > batch = population.TakeCurrentBatch();

            _executor.execute(() =>
            {
                try
                {
                    string batchDescription = "EMPTY";
                    if (PrintDebug)
                    {
                        if (batch.Count > 0)
                        {
                            batchDescription = format("[%d, %d - %d]", batch.Count, batch[0].EntityId, batch[batch.Count - 1].EntityId);
                        }
                        Log.info("Applying scan batch %s", batchDescription);
                    }
                    population.Populator.add(batch);
                    if (PrintDebug)
                    {
                        Log.info("Applied scan batch %s", batchDescription);
                    }
                }
                catch (Exception failure)
                {
                    Fail(population, failure);
                }
                finally
                {
                    _activeTasks.decrementAndGet();
                }
            });
        }
Example #16
0
 private IntStream PropertyKeyIds(IndexPopulation population)
 {
     return(IntStream.of(population.Schema().PropertyIds));
 }
Example #17
0
 internal virtual void DropIndexPopulation(IndexPopulation indexPopulation)
 {
     indexPopulation.CancelAndDrop();
 }
Example #18
0
 private bool RemoveFromOngoingPopulations(IndexPopulation indexPopulation)
 {
     return(Populations.Remove(indexPopulation));
 }
Example #19
0
 protected internal virtual void Flush(IndexPopulation population)
 {
     _phaseTracker.enterPhase(PhaseTracker_Phase.Write);
     DoFlush(population);
 }
Example #20
0
 private void ResetIndexCountsForPopulation(IndexPopulation indexPopulation)
 {
     _storeView.replaceIndexCounts(indexPopulation.IndexId, 0, 0, 0);
 }
Example #21
0
 internal virtual void CancelIndexPopulation(IndexPopulation indexPopulation)
 {
     indexPopulation.Cancel();
 }