private void HandleCompletion(BoltConnection connection, bool?shouldContinueScheduling, Exception error) { try { if (error != null && ExceptionUtils.hasCause(error, typeof(RejectedExecutionException))) { connection.HandleSchedulingError(error); return; } } finally { // we need to ensure that the entry is removed only after any possible handleSchedulingError // call is completed. Otherwise, we can end up having different threads executing against // bolt state machine. _activeWorkItems.Remove(connection.Id()); } if (error != null) { _log.error(string.Format("Unexpected error during job scheduling for session '{0}'.", connection.Id()), error); StopConnection(connection); } else { if (shouldContinueScheduling && connection.HasPendingJobs()) { HandleSubmission(connection); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void createdWorkerThreadsShouldContainConnectorName() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CreatedWorkerThreadsShouldContainConnectorName() { AtomicInteger executeBatchCompletionCount = new AtomicInteger(); AtomicReference <Thread> poolThread = new AtomicReference <Thread>(); AtomicReference <string> poolThreadName = new AtomicReference <string>(); string id = System.Guid.randomUUID().ToString(); BoltConnection connection = NewConnection(id); when(connection.HasPendingJobs()).thenAnswer(inv => { executeBatchCompletionCount.incrementAndGet(); return(false); }); when(connection.ProcessNextBatch()).thenAnswer(inv => { poolThread.set(Thread.CurrentThread); poolThreadName.set(Thread.CurrentThread.Name); return(true); }); _boltScheduler.start(); _boltScheduler.created(connection); _boltScheduler.enqueued(connection, Jobs.noop()); Predicates.await(() => executeBatchCompletionCount.get() > 0, 1, MINUTES); assertThat(poolThread.get().Name, not(equalTo(poolThreadName.get()))); assertThat(poolThread.get().Name, containsString(string.Format("[{0}]", CONNECTOR_KEY))); assertThat(poolThread.get().Name, not(containsString(string.Format("[{0}]", connection.RemoteAddress())))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void enqueuedShouldQueueJob() public virtual void EnqueuedShouldQueueJob() { Job job = Jobs.noop(); BoltConnection connection = NewConnection(); connection.Enqueue(job); assertTrue(connection.HasPendingJobs()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void successfulJobsShouldTriggerSchedulingOfPendingJobs() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SuccessfulJobsShouldTriggerSchedulingOfPendingJobs() { AtomicInteger counter = new AtomicInteger(); string id = System.Guid.randomUUID().ToString(); BoltConnection connection = NewConnection(id); when(connection.ProcessNextBatch()).thenAnswer(inv => counter.incrementAndGet() > 0); when(connection.HasPendingJobs()).thenReturn(true).thenReturn(false); _boltScheduler.start(); _boltScheduler.created(connection); _boltScheduler.enqueued(connection, Jobs.noop()); Predicates.await(() => counter.get() > 1, 1, MINUTES); verify(connection, times(2)).processNextBatch(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void hasPendingJobsShouldReportFalseWhenInitialised() public virtual void HasPendingJobsShouldReportFalseWhenInitialised() { BoltConnection connection = NewConnection(); assertFalse(connection.HasPendingJobs()); }