コード例 #1
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public void scheduleSamplingJob(final IndexSamplingJob samplingJob)
        public virtual void ScheduleSamplingJob(IndexSamplingJob samplingJob)
        {
            @lock.@lock();
            try
            {
                if (_stopped)
                {
                    return;
                }

                long indexId = samplingJob.IndexId();
                if (_executingJobs.Contains(indexId))
                {
                    return;
                }

                _executingJobs.Add(indexId);
                _jobScheduler.schedule(Group.INDEX_SAMPLING, () =>
                {
                    try
                    {
                        samplingJob.run();
                    }
                    finally
                    {
                        SamplingJobCompleted(samplingJob);
                    }
                });
            }
            finally
            {
                @lock.unlock();
            }
        }
コード例 #2
0
        /// <summary>
        /// This test come from a support case where dropping an index would block forever after index sampling failed.
        /// <para>
        /// A fusion index has multiple <seealso cref="IndexSampler index samplers"/> that are called sequentially. If one fails, then the other will never be invoked.
        /// This was a problem for <seealso cref="LuceneIndexSampler"/>. It owns a <seealso cref="org.neo4j.helpers.TaskControl"/> that it will try to release in try-finally
        /// in <seealso cref="LuceneIndexSampler.sampleIndex()"/>. But it never gets here because a prior <seealso cref="IndexSampler"/> fails.
        /// </para>
        /// <para>
        /// Because the <seealso cref="org.neo4j.helpers.TaskControl"/> was never released the lucene accessor would block forever, waiting for
        /// <seealso cref="TaskCoordinator.awaitCompletion()"/>.
        /// </para>
        /// <para>
        /// This situation was solved by making <seealso cref="IndexSampler"/> <seealso cref="System.IDisposable"/> and include it in try-with-resource together with
        /// <seealso cref="IndexReader"/> that created it.
        /// </para>
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = 5_000L) public void failedIndexSamplingMustNotPreventIndexDrop() throws java.io.IOException, org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void FailedIndexSamplingMustNotPreventIndexDrop()
        {
            LuceneIndexProvider luceneProvider = luceneProvider();

            MakeSureIndexHasSomeData(luceneProvider);                 // Otherwise no sampler will be created.

            IndexProvider       failingProvider = failingProvider();
            FusionIndexProvider fusionProvider  = CreateFusionProvider(luceneProvider, failingProvider);

            using (IndexAccessor fusionAccessor = fusionProvider.GetOnlineAccessor(_storeIndexDescriptor, _samplingConfig))
            {
                IndexSamplingJob indexSamplingJob = CreateIndexSamplingJob(fusionAccessor);

                // Call run from other thread
                try
                {
                    indexSamplingJob.run();
                }
                catch (Exception e)
                {
                    assertSame(e, _sampleException);
                }

                // then
                fusionAccessor.Drop();
                // should not block forever
            }
        }
コード例 #3
0
        private void SampleIndexOnCurrentThread(IndexMap indexMap, long indexId)
        {
            IndexSamplingJob job = CreateSamplingJob(indexMap, indexId);

            if (job != null)
            {
                job.run();
            }
        }
コード例 #4
0
        private void SampleIndexOnTracker(IndexMap indexMap, long indexId)
        {
            IndexSamplingJob job = CreateSamplingJob(indexMap, indexId);

            if (job != null)
            {
                _jobTracker.scheduleSamplingJob(job);
            }
        }
コード例 #5
0
 private void SamplingJobCompleted(IndexSamplingJob samplingJob)
 {
     @lock.@lock();
     try
     {
         _executingJobs.remove(samplingJob.IndexId());
         _canSchedule.signalAll();
         _allJobsFinished.signalAll();
     }
     finally
     {
         @lock.unlock();
     }
 }