// Actually executes the command, once the event args and the thread issues have all been sorted out.
        private void ExecuteCore()
        {
            segment             = segmentOrig = eventArgs.UserToken as BufferSegment;
            eventArgs.UserToken = this;

            if (cluster.HasBufferChanged(segment))
            {
                // Reset buffer in SizeBuffer().
                segment.buffer = null;
                segment.offset = 0;
                segment.size   = 0;
            }

            // In async mode, totalTimeout and socketTimeout are mutually exclusive.
            // If totalTimeout is defined, socketTimeout is ignored.
            // This is done so we can avoid having to declare usingSocketTimeout as
            // volatile and because enabling both timeouts together has no real value.
            if (policy.totalTimeout > 0)
            {
                watch = Stopwatch.StartNew();
                AsyncTimeoutQueue.Instance.Add(this, policy.totalTimeout);
            }
            else if (policy.socketTimeout > 0)
            {
                usingSocketTimeout = true;
                watch = Stopwatch.StartNew();
                AsyncTimeoutQueue.Instance.Add(this, policy.socketTimeout);
            }
            ExecuteCommand();
        }
Exemple #2
0
        public void Execute()
        {
            eventArgs           = cluster.GetEventArgs();
            segment             = segmentOrig = eventArgs.UserToken as BufferSegment;
            eventArgs.UserToken = this;

            if (cluster.HasBufferChanged(segment))
            {
                // Reset buffer in SizeBuffer().
                segment.buffer = null;
                segment.offset = 0;
                segment.size   = 0;
            }

            Policy policy = GetPolicy();

            timeout = policy.timeout;

            if (timeout > 0)
            {
                watch = Stopwatch.StartNew();
                AsyncTimeoutQueue.Instance.Add(this, timeout);
            }

            ExecuteCommand();
        }
Exemple #3
0
        // Actually executes the command, once the event args and the thread issues have all been sorted out.
        private void ExecuteCore()
        {
            segment             = segmentOrig = eventArgs.UserToken as BufferSegment;
            eventArgs.UserToken = this;

            if (cluster.HasBufferChanged(segment))
            {
                // Reset buffer in SizeBuffer().
                segment.buffer = null;
                segment.offset = 0;
                segment.size   = 0;
            }

            if (watch == null)
            {
                // In async mode, totalTimeout and socketTimeout are mutually exclusive.
                // If totalTimeout is defined, socketTimeout is ignored.
                // This is done so we can avoid having to declare usingSocketTimeout as
                // volatile and because enabling both timeouts together has limited value.
                if (policy.totalTimeout > 0)
                {
                    watch = Stopwatch.StartNew();
                    AsyncTimeoutQueue.Instance.Add(this, policy.totalTimeout);
                }
                else if (policy.socketTimeout > 0)
                {
                    usingSocketTimeout = true;
                    watch = Stopwatch.StartNew();
                    AsyncTimeoutQueue.Instance.Add(this, policy.socketTimeout);
                }
            }
            else
            {
                // Batch split retry.
                if (state != IN_PROGRESS)
                {
                    // Free up resources and notify user on timeout.
                    // Connection should have already been closed on AsyncTimeoutQueue timeout.
                    FailCommand(new AerospikeException.Timeout(policy, true));
                    return;
                }
            }
            ExecuteCommand();
        }
        public void Execute()
        {
            eventArgs           = cluster.GetEventArgs();
            eventArgs.UserToken = this;
            dataBuffer          = eventArgs.Buffer;

            if (dataBuffer != null && cluster.HasBufferChanged(dataBuffer))
            {
                // Reset dataBuffer in SizeBuffer().
                dataBuffer = null;
            }

            Policy policy = GetPolicy();

            timeout = policy.timeout;

            if (timeout > 0)
            {
                watch = Stopwatch.StartNew();
                AsyncTimeoutQueue.Instance.Add(this, timeout);
            }

            ExecuteCommand();
        }
        // Actually executes the command, once the event args and the thread issues have all been sorted out.
        private void ExecuteCore()
        {
            segment             = segmentOrig = eventArgs.UserToken as BufferSegment;
            eventArgs.UserToken = this;

            if (cluster.HasBufferChanged(segment))
            {
                // Reset buffer in SizeBuffer().
                segment.buffer = null;
                segment.offset = 0;
                segment.size   = 0;
            }

            if (totalTimeout > 0)
            {
                // Timeout already added in Execute(). Verify state.
                if (state != IN_PROGRESS)
                {
                    // Timeout occurred. Close command.
                    PutBackArgsOnError();
                    return;
                }

                if (socketTimeout > 0)
                {
                    // socketTimeout is an idle timeout. socketWatch is restarted on every attempt.
                    socketWatch = Stopwatch.StartNew();
                }
            }
            else if (socketTimeout > 0)
            {
                socketWatch = Stopwatch.StartNew();
                AsyncTimeoutQueue.Instance.Add(this, socketTimeout);
            }
            ExecuteCommand();
        }