Esempio n. 1
0
        public void ExecuteOperation(OperationItem operation, TcpPackageConnection connection)
        {
            operation.ConnectionId = connection.ConnectionId;
            operation.LastUpdated  = DateTime.UtcNow;
            _activeOperations.Add(operation.CorrelationId, operation);

            var package = operation.Operation.CreateNetworkPackage(operation.CorrelationId);

            LogDebug("ExecuteOperation package {0}, {1}, {2}.", package.Command, package.CorrelationId, operation);
            connection.EnqueueSend(package);
        }
Esempio n. 2
0
 public bool RemoveOperation(OperationItem operation)
 {
     if (!_activeOperations.Remove(operation.CorrelationId))
     {
         LogDebug("RemoveOperation FAILED for {0}", operation);
         return(false);
     }
     LogDebug("RemoveOperation SUCCEEDED for {0}", operation);
     _totalOperationCount = _activeOperations.Count + _waitingOperations.Count;
     return(true);
 }
Esempio n. 3
0
        bool TryExpireItem(DateTime cutoffDate, OperationItem operation)
        {
            if (operation.CreatedTime > cutoffDate)
            {
                return(false);
            }

            var err = string.Format("EventStoreConnection '{0}': request expired.\n"
                                    + "UTC now: {1:HH:mm:ss.fff}, operation: {2}.",
                                    _connectionName, DateTime.UtcNow, operation);

            _settings.Log.Debug(err);
            operation.Operation.Fail(new OperationExpiredException(err));
            return(true);
        }
Esempio n. 4
0
        public void ScheduleOperationRetry(OperationItem operation)
        {
            if (!RemoveOperation(operation))
            {
                return;
            }

            LogDebug("ScheduleOperationRetry for {0}", operation);
            if (operation.MaxRetries >= 0 && operation.RetryCount >= operation.MaxRetries)
            {
                operation.Operation.Fail(new RetriesLimitReachedException(operation.ToString(), operation.RetryCount));
                return;
            }
            _retryPendingOperations.Add(operation);
        }
Esempio n. 5
0
        public void ScheduleOperation(OperationItem operation, TcpPackageConnection connection)
        {
            Ensure.NotNull(connection, "connection");

            if (_activeOperations.Count >= _settings.MaxConcurrentItems)
            {
                LogDebug("ScheduleOperation WAITING for {0}.", operation);
                _waitingOperations.Enqueue(operation);
            }
            else
            {
                operation.ConnectionId = connection.ConnectionId;
                operation.LastUpdated  = DateTime.UtcNow;
                _activeOperations.Add(operation.CorrelationId, operation);

                var package = operation.Operation.CreateNetworkPackage(operation.CorrelationId);
                LogDebug("ScheduleOperation package {0}, {1}, {2}.", package.Command, package.CorrelationId, operation);
                connection.EnqueueSend(package);
            }
            _totalOperationCount = _activeOperations.Count + _waitingOperations.Count;
        }
Esempio n. 6
0
 public bool TryGetActiveOperation(Guid correlationId, out OperationItem operation)
 {
     return(_activeOperations.TryGetValue(correlationId, out operation));
 }
Esempio n. 7
0
 public void ScheduleOperation(OperationItem operation, TcpPackageConnection connection)
 {
     Ensure.NotNull(connection, "connection");
     _waitingOperations.Enqueue(operation);
     TryScheduleWaitingOperations(connection);
 }
Esempio n. 8
0
 public void EnqueueOperation(OperationItem operation)
 {
     LogDebug("EnqueueOperation WAITING for {0}.", operation);
     _waitingOperations.Enqueue(operation);
 }