示例#1
0
 // use IndexSamplingControllerFactory.create do not instantiate directly
 internal IndexSamplingController(IndexSamplingConfig config, IndexSamplingJobFactory jobFactory, IndexSamplingJobQueue <long> jobQueue, IndexSamplingJobTracker jobTracker, IndexMapSnapshotProvider indexMapSnapshotProvider, JobScheduler scheduler, RecoveryCondition indexRecoveryCondition)
 {
     this._backgroundSampling       = config.BackgroundSampling();
     this._jobFactory               = jobFactory;
     this._indexMapSnapshotProvider = indexMapSnapshotProvider;
     this._jobQueue               = jobQueue;
     this._jobTracker             = jobTracker;
     this._scheduler              = scheduler;
     this._indexRecoveryCondition = indexRecoveryCondition;
 }
示例#2
0
        public virtual IndexSamplingController Create(IndexMapSnapshotProvider snapshotProvider)
        {
            OnlineIndexSamplingJobFactory jobFactory = new OnlineIndexSamplingJobFactory(_storeView, _tokenNameLookup, _logProvider);

            System.Predicate <long>      samplingUpdatePredicate = CreateSamplingPredicate();
            IndexSamplingJobQueue <long> jobQueue   = new IndexSamplingJobQueue <long>(samplingUpdatePredicate);
            IndexSamplingJobTracker      jobTracker = new IndexSamplingJobTracker(_config, _scheduler);

            IndexSamplingController.RecoveryCondition indexRecoveryCondition = CreateIndexRecoveryCondition(_logProvider, _tokenNameLookup);
            return(new IndexSamplingController(_config, jobFactory, jobQueue, jobTracker, snapshotProvider, _scheduler, indexRecoveryCondition));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotEnqueueJobOnlyIfForbiddenByThePredicate()
        public virtual void ShouldNotEnqueueJobOnlyIfForbiddenByThePredicate()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final IndexSamplingJobQueue<Object> jobQueue = new IndexSamplingJobQueue<>(FALSE);
            IndexSamplingJobQueue <object> jobQueue = new IndexSamplingJobQueue <object>(False);

            // when
            jobQueue.Add(false, _something);

            // then
            assertNull(jobQueue.Poll());
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldForceEnqueueOfAnJobEvenIfThePredicateForbidsIt()
        public virtual void ShouldForceEnqueueOfAnJobEvenIfThePredicateForbidsIt()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final IndexSamplingJobQueue<Object> jobQueue = new IndexSamplingJobQueue<>(FALSE);
            IndexSamplingJobQueue <object> jobQueue = new IndexSamplingJobQueue <object>(False);

            // when
            jobQueue.Add(true, _something);

            // then
            assertEquals(_something, jobQueue.Poll());
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEnqueueJobWhenEmpty()
        public virtual void ShouldEnqueueJobWhenEmpty()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final IndexSamplingJobQueue<Object> jobQueue = new IndexSamplingJobQueue<>(TRUE);
            IndexSamplingJobQueue <object> jobQueue = new IndexSamplingJobQueue <object>(True);

            jobQueue.Add(false, _something);

            // when
            object result = jobQueue.Poll();

            // then
            assertEquals(_something, result);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDequeueAll()
        public virtual void ShouldDequeueAll()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Object somethingElse = new Object();
            object somethingElse = new object();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final IndexSamplingJobQueue<Object> jobQueue = new IndexSamplingJobQueue<>(TRUE);
            IndexSamplingJobQueue <object> jobQueue = new IndexSamplingJobQueue <object>(True);

            jobQueue.Add(false, _something);
            jobQueue.Add(false, somethingElse);

            // when
            IEnumerable <object> objects = jobQueue.PollAll();

            // then
            assertArrayEquals(new object[] { _something, somethingElse }, asArray(typeof(object), objects));
            assertNull(jobQueue.Poll());
        }