Пример #1
0
        protected internal virtual Response <R> SendRequest <R>(RequestType type, RequestContext context, Serializer serializer, Deserializer <R> deserializer, StoreId specificStoreId, ResponseUnpacker_TxHandler txHandler)
        {
            ChannelContext channelContext = AcquireChannelContext(type);

            Exception failure = null;

            try
            {
                _requestMonitor.beginRequest(channelContext.Channel().RemoteAddress, type, context);

                // Request
                _protocol.serializeRequest(channelContext.Channel(), channelContext.Output(), type, context, serializer);

                // Response
                Response <R> response = _protocol.deserializeResponse(ExtractBlockingReadHandler(channelContext), channelContext.Input(), GetReadTimeout(type, _readTimeout), deserializer, _resourcePoolReleaser, _entryReader);

                if (type.ResponseShouldBeUnpacked())
                {
                    _responseUnpacker.unpackResponse(response, txHandler);
                }

                if (ShouldCheckStoreId(type))
                {
                    // specificStoreId is there as a workaround for then the graphDb isn't initialized yet
                    if (specificStoreId != null)
                    {
                        AssertCorrectStoreId(response.StoreId, specificStoreId);
                    }
                    else
                    {
                        AssertCorrectStoreId(response.StoreId, _storeId);
                    }
                }

                return(response);
            }
            catch (ComException e)
            {
                failure = e;
                _comExceptionHandler.handle(e);
                throw TraceComException(e, "Client.sendRequest");
            }
            catch (Exception e)
            {
                failure = e;
                throwIfUnchecked(e);
                throw new Exception(e);
            }
            finally
            {
                /*
                 * Otherwise the user must call response.close() to prevent resource leaks.
                 */
                if (failure != null)
                {
                    Dispose(channelContext);
                }
                _requestMonitor.endRequest(failure);
            }
        }
Пример #2
0
 private void Dispose(ChannelContext channelContext)
 {
     channelContext.Channel().close().awaitUninterruptibly();
     if (_channelPool != null)
     {
         _channelPool.release();
     }
 }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") private static org.jboss.netty.handler.queue.BlockingReadHandler<org.jboss.netty.buffer.ChannelBuffer> extractBlockingReadHandler(ChannelContext channelContext)
        private static BlockingReadHandler <ChannelBuffer> ExtractBlockingReadHandler(ChannelContext channelContext)
        {
            ChannelPipeline pipeline = channelContext.Channel().Pipeline;

            return((BlockingReadHandler <ChannelBuffer>)pipeline.get(BLOCKING_CHANNEL_HANDLER_NAME));
        }