예제 #1
0
        /// <summary>
        /// 重置TFramedTransport流,不影响Thrift原有流程
        /// </summary>
        /// <param name="protocol"></param>
        public void ResetTFramedTransport(TProtocol protocol)
        {
            try
            {
                if (protocol.Transport is TStreamTransport stream)
                {
                    var tioInputStream = TStreamTransportFieldsCache.getInstance().GetInputStream();
                    if (tioInputStream == null)
                    {
                        return;
                    }
                    var inputStream = (Stream)tioInputStream.GetValue(stream);

                    inputStream.Seek(inputStream.Position, SeekOrigin.Begin);
                }

                //TField tioInputStream = TIOStreamTransportFieldsCache.getInstance().getTIOInputStream();
                //if (tioInputStream == null)
                //{
                //    return;
                //}
                //BufferedInputStream inputStream = (BufferedInputStream)tioInputStream.get(protocol.getTransport());
                //inputStream.reset();
            }
            catch (Exception e)
            {
                throw e;
                //e.printStackTrace();
            }
        }
예제 #2
0
        public void MarkTFramedTransport(TProtocol protocol)
        {
            try
            {
                if (protocol.Transport is TStreamTransport stream)
                {
                    var tioInputStream = TStreamTransportFieldsCache.getInstance().GetInputStream();
                    if (tioInputStream == null)
                    {
                        return;
                    }
                    var inputStream = (Stream)tioInputStream.GetValue(stream);
                    inputStream.Position = 0;
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            //try
            //{
            //    TField tioInputStream = TIOStreamTransportFieldsCache.getInstance().getTIOInputStream();
            //    if (tioInputStream == null)
            //    {
            //        return;
            //    }
            //    BufferedInputStream inputStream = (BufferedInputStream)tioInputStream.get(protocol.Transport);
            //    inputStream.mark(0);
            //}
            //catch (Exception e)
            //{
            //    //e.printStackTrace();
            //}
        }