Beispiel #1
0
        private void Destroy(OrientDBNetworkConnection stream)
        {
            stream.Dispose();

            if (_connectionOptions is DatabaseConnectionOptions)
            {
                stream = CreateNetworkStream();
                var _openResult = Process(new DatabaseOpenOperation(_connectionOptions as DatabaseConnectionOptions, ConnectionMetaData), stream);
                stream.SessionId = _openResult.SessionId;
                stream.Token     = _openResult.Token;
                ReturnStream(stream);
            }
        }
Beispiel #2
0
        private async Task <T> ProcessAsync <T>(IOrientDBOperation <T> operation, OrientDBNetworkConnection stream)
        {
            try
            {
                var request = operation.CreateRequest(stream.SessionId, stream.Token);

                var reader = await SendAsync(request, stream.GetStream());

                return(operation.Execute(reader));
            }
            catch
            {
                Destroy(stream);
                throw;
            }
        }
Beispiel #3
0
        private T Process <T>(IOrientDBOperation <T> operation, OrientDBNetworkConnection stream)
        {
            try
            {
                Request request = operation.CreateRequest(stream.SessionId, stream.Token);

                var reader = Send(request, stream.GetStream());

                T result = operation.Execute(reader);

                return(result);
            }
            catch
            {
                Destroy(stream);
                throw;
            }
        }
Beispiel #4
0
        // Return the Stream back to the pool.
        private void ReturnStream(OrientDBNetworkConnection stream)
        {
            _streamPool.Enqueue(stream);

            flowControl.Release();
        }