示例#1
0
 internal BatchingResponseHandler(int maxBatchSize, TransactionQueue.Applier applier, TransactionObligationFulfiller obligationFulfiller, ResponseUnpacker_TxHandler txHandler, VersionContextSupplier versionContextSupplier, Log log)
 {
     this._obligationFulfiller    = obligationFulfiller;
     this._txHandler              = txHandler;
     this._versionContextSupplier = versionContextSupplier;
     this._queue = new TransactionQueue(maxBatchSize, applier);
     this._log   = log;
 }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void unpackResponse(org.neo4j.com.Response<?> response, ResponseUnpacker_TxHandler txHandler) throws Exception
        public override void UnpackResponse <T1>(Response <T1> response, ResponseUnpacker_TxHandler txHandler)
        {
            if (_stopped)
            {
                throw new System.InvalidOperationException("Component is currently stopped");
            }

            BatchingResponseHandler responseHandler = new BatchingResponseHandler(_maxBatchSize, _batchCommitter, _obligationFulfiller, txHandler, _versionContextSupplier, _log);

            try
            {
                response.Accept(responseHandler);
            }
            finally
            {
                responseHandler.ApplyQueuedTransactions();
            }
        }
示例#3
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);
            }
        }