Ejemplo n.º 1
0
        public override void Created(BoltConnection connection)
        {
            BoltConnection previous = _activeConnections[connection.Id()] = connection;

            // We do not expect the same (keyed) connection twice
            Debug.Assert(previous == null);
        }
Ejemplo n.º 2
0
        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);
                }
            }
        }
        private BoltConnection NewConnection(string id)
        {
            BoltConnection result = mock(typeof(BoltConnection));

            when(result.Id()).thenReturn(id);
            when(result.RemoteAddress()).thenReturn(new InetSocketAddress("localhost", 32_000));
            return(result);
        }
Ejemplo n.º 4
0
        public override void Closed(BoltConnection connection)
        {
            string id = connection.Id();

            try
            {
                CompletableFuture <bool> currentFuture = _activeWorkItems.Remove(id);
                if (currentFuture != null)
                {
                    currentFuture.cancel(false);
                }
            }
            finally
            {
                _activeConnections.Remove(id);
            }
        }
Ejemplo n.º 5
0
 internal virtual bool IsActive(BoltConnection connection)
 {
     return(_activeWorkItems.ContainsKey(connection.Id()));
 }
Ejemplo n.º 6
0
 internal virtual bool IsRegistered(BoltConnection connection)
 {
     return(_activeConnections.ContainsKey(connection.Id()));
 }
Ejemplo n.º 7
0
 private void StopConnection(BoltConnection connection)
 {
     try
     {
         connection.Stop();
     }
     catch (Exception t)
     {
         _log.warn(string.Format("An unexpected error occurred while stopping BoltConnection [{0}]", connection.Id()), t);
     }
 }
Ejemplo n.º 8
0
 private void HandleSubmission(BoltConnection connection)
 {
     _activeWorkItems.computeIfAbsent(connection.Id(), key => ScheduleBatchOrHandleError(connection).whenCompleteAsync((result, error) => handleCompletion(connection, result, error), _forkJoinPool));
 }
Ejemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void idShouldReturnBoltChannelId()
        public virtual void IdShouldReturnBoltChannelId()
        {
            BoltConnection connection = NewConnection();

            assertEquals(_boltChannel.id(), connection.Id());
        }