Esempio n. 1
0
        protected Exception CreateTimeoutException(uint opaque)
        {
            const string format = ", {0}", kv = "kv";
            var          correlationId = CreateCorrelationId(opaque);

            var builder = new StringBuilder(ExceptionUtil.OperationTimeout);

            builder.AppendFormat(format, kv);
            builder.AppendFormat(format, correlationId);
            builder.AppendFormat(format, LocalEndPoint);
            builder.AppendFormat(format, Configuration.SendTimeout);
            builder.AppendFormat(format, EndPoint);

            var message = builder.ToString();

            Log.Info(message);

            var exception = new SendTimeoutExpiredException(message);

            exception.Data.Add("ServiceType", kv);
            exception.Data.Add("CorrelationId", correlationId);
            exception.Data.Add("LocalEndpoint", LocalEndPoint.ToString());
            exception.Data.Add("Timeout", Configuration.SendTimeout);
            exception.Data.Add("RemoteEndpoint", EndPoint.ToString());
            return(exception);
        }
        /// <summary>
        /// Completes the specified Memcached response.
        /// </summary>
        /// <param name="response">The Memcached response packet.</param>
        public void Complete(byte[] response)
        {
            Timer.Dispose();

            //defaults
            var       status = ResponseStatus.None;
            Exception e      = null;

            //this means the request never completed - assume a transport failure
            if (response == null)
            {
                response = new byte[24];
                Converter.FromUInt32(Id, response, HeaderIndexFor.Opaque);
                e      = new SendTimeoutExpiredException();
                status = ResponseStatus.TransportFailure;
            }

            //somewhat of hack for backwards compatibility
            Callback(new SocketAsyncState
            {
                Data      = new MemoryStream(response),
                Opaque    = Id,
                Exception = e,
                Status    = status,
                EndPoint  = EndPoint
            });
        }
Esempio n. 3
0
        /// <summary>
        /// Completes the specified Memcached response.
        /// </summary>
        /// <param name="response">The Memcached response packet.</param>
        public void Complete(byte[] response)
        {
            if (Timer != null)
            {
                Timer.Dispose();
            }

            //defaults
            var       status = ResponseStatus.None;
            Exception e      = null;

            //this means the request never completed - assume a transport failure
            if (response == null)
            {
                response = new byte[OperationHeader.Length];
                Converter.FromUInt32(Opaque, response, HeaderIndexFor.Opaque);
                e      = new SendTimeoutExpiredException();
                status = ResponseStatus.TransportFailure;
            }

            //somewhat of hack for backwards compatibility
            Task.Run(() => Callback(new SocketAsyncState
            {
                Data          = new MemoryStream(response),
                Opaque        = Opaque,
                Exception     = e,
                Status        = status,
                EndPoint      = EndPoint,
                DispatchSpan  = DispatchSpan,
                CorrelationId = CorrelationId,
                ErrorMap      = ErrorMap
            }));
        }
Esempio n. 4
0
        protected Exception CreateTimeoutException(uint opaque)
        {
            const string kv            = "kv";
            var          correlationId = CreateCorrelationId(opaque);

            var context = new OperationContext(kv, correlationId)
            {
                BucketName          = Configuration.BucketName,
                LocalEndpoint       = LocalEndPoint.ToString(),
                RemoteEndpoint      = EndPoint.ToString(),
                TimeoutMicroseconds = Configuration.SendTimeout
            };

            var message = context.ToString();

            Log.Info(message);

            var exception = new SendTimeoutExpiredException(message);

            exception.Data.Add("ServiceType", kv);
            exception.Data.Add("CorrelationId", correlationId);
            exception.Data.Add("LocalEndpoint", LocalEndPoint.ToString());
            exception.Data.Add("Timeout", Configuration.SendTimeout);
            exception.Data.Add("RemoteEndpoint", EndPoint.ToString());
            return(exception);
        }
Esempio n. 5
0
        protected Exception CreateTimeoutException(uint opaque)
        {
            var context = CreateOperationContext(opaque);
            var message = context.ToString();

            Log.Info(message);

            var exception = new SendTimeoutExpiredException(message);

            exception.Data.Add("ServiceType", CouchbaseTags.ServiceKv);
            exception.Data.Add("OperationId", context.OperationId);
            exception.Data.Add("Bucket", context.BucketName);
            exception.Data.Add("ConnectionId", context.ConnectionId);
            exception.Data.Add("LocalEndpoint", context.LocalEndpoint);
            exception.Data.Add("RemoteEndpoint", context.RemoteEndpoint);
            exception.Data.Add("Timeout", context.TimeoutMicroseconds);
            return(exception);
        }