Beispiel #1
0
        /// <summary>
        /// Dispatch created command for execution.
        /// </summary>
        public void Dispatch()
        {
            try
            {
                lock (this)
                {
                    this.State = ParserState.Ready;
                    if (_inputDataStream.Lenght > 0)
                    {
                        ThreadPool.ExecuteTask(this);
                    }
                    else
                    {
                        this.Alive = false;
                    }
                }
            }
            catch (Exception e)
            {
                _logManager.Error("ProtocolParser.Dispatch()", " Failed to dispatch parsed command. Exception: " + e.Message);
                return;
            }

            if (_commandConsumer != null)
            {
                _commandConsumer.Start();
            }
        }
Beispiel #2
0
        public void StartSequentialExecution()
        {
            bool go = false;

            do
            {
                AbstractCommand command;
                lock (this)
                {
                    command = _commandsQueue.Dequeue();
                }
                try
                {
                    _logManager.Debug("SequentialExecutionManager", " Executing command : " + command.Opcode);
                    if (command.ErrorMessage == null)
                    {
                        command.Execute(_cacheProvider);
                    }
                    else
                    {
                        _logManager.Debug("SequentialExecutionManager", "\tCannot execute command: " + command.Opcode + "  Error:" + command.ErrorMessage);
                    }
                }
                catch (Alachisoft.NCache.Integrations.Memcached.Provider.Exceptions.InvalidArgumentsException e)
                {
                    _logManager.Error("SequentialExecutionManager.StartSequentialExecution()", "\tError while executing command. CommandType = " + command.Opcode.ToString() + "  " + e.Message);
                    command.ExceptionOccured = true;
                    command.ErrorMessage     = e.Message;
                }
                catch (Alachisoft.NCache.Integrations.Memcached.Provider.Exceptions.CacheRuntimeException e)
                {
                    _logManager.Error("SequentialExecutionManager.StartSequentialExecution()", "\tError while executing command. CommandType = " + command.Opcode.ToString() + "  " + e.Message);
                    command.ExceptionOccured = true;
                    command.ErrorMessage     = e.Message;
                }

                ConsumerStatus responseMgrStatus = _commandConsumer.RegisterCommand(command);

                lock (this)
                {
                    go = (responseMgrStatus == ConsumerStatus.Running) && _commandsQueue.Count > 0;
                }
            } while (go);


            lock (this)
            {
                if (_commandsQueue.Count > 0)
                {
                    ThreadPool.ExecuteTask(this);
                }
                else
                {
                    _alive = false;
                }
            }

            if (_commandConsumer != null)
            {
                _commandConsumer.Start();
            }
        }