internal DatabasePool(string hostname, int port, string databaseName, ODatabaseType databaseType, string userName, string userPassword, int poolSize, string alias) { Hostname = hostname; Port = port; DatabaseName = databaseName; DatabaseType = databaseType; UserName = userName; UserPassword = userPassword; PoolSize = poolSize; Alias = alias; _connections = new Queue<Connection>(); for (int i = 0; i < poolSize; i++) { Connection connection = new Connection(Hostname, Port, databaseName, databaseType, userName, userPassword, alias, true); _connections.Enqueue(connection); } //get release from last connection var lastConnection = _connections.LastOrDefault(); if (lastConnection != null) { Release = lastConnection.Document.GetField<string>("OrientdbRelease"); } }
internal static Connection ReleaseConnection(string alias) { lock (_syncRoot) { Connection connection = null; if (_databasePools.Exists(db => db.Alias == alias)) { DatabasePool pool = _databasePools.Find(db => db.Alias == alias); // deque free database connection if the pool has one if (pool.CurrentSize > 0) { connection = pool.DequeueConnection(); } // if the pool is empty - create new dedicated database connection else if (pool.CurrentSize == 0) { connection = new Connection(pool.Hostname, pool.Port, pool.DatabaseName, pool.DatabaseType, pool.UserName, pool.UserPassword, alias, false); } } return connection; } }
internal static void ReturnConnection(Connection connection) { lock (_syncRoot) { if (_databasePools.Exists(db => db.Alias == connection.Alias) && connection.IsReusable) { DatabasePool pool = _databasePools.Find(q => q.Alias == connection.Alias); pool.EnqueueConnection(connection); } else { connection.Dispose(); } } }
internal DatabasePool(string hostname, int port, string databaseName, ODatabaseType databaseType, string userName, string userPassword, int poolSize, string alias) { Hostname = hostname; Port = port; DatabaseName = databaseName; DatabaseType = databaseType; UserName = userName; UserPassword = userPassword; PoolSize = poolSize; Alias = alias; _connections = new Queue<Connection>(); for (int i = 0; i < poolSize; i++) { Connection connection = new Connection(Hostname, Port, databaseName, databaseType, userName, userPassword, alias, true); _connections.Enqueue(connection); } }
public OServer(string hostname, int port, string userName, string userPassword) { _connection = new Connection(hostname, port, userName, userPassword); }
internal OLoadRecord(Connection connection) { _connection = connection; }
internal ORecordMetadata(Connection connection) { _connection = connection; }
internal OSqlCreateProperty(Connection connection) { _connection = connection; _sqlQuery = new SqlQuery(_connection); }
public Response(Connection connection) { this.Connection = connection; }
internal OCommandQuery(Connection connection, CommandPayloadBase payload) { _connection = connection; _payload = payload; }
internal OClusterQuery(Connection _connection) { this._connection = _connection; }
internal static void ReturnConnection(Connection connection) { lock (_syncRoot) { DatabasePool pool = _databasePools.Find(q => q.Alias == connection.Alias); // enqueue the connection back if it's active, reusable and the pool size is not full // otherwise dispose it if ((pool != null) && (pool.CurrentSize < pool.PoolSize) && connection.IsActive && connection.IsReusable) { pool.EnqueueConnection(connection); } else { connection.Dispose(); } } }
internal Request(Connection connection) { OperationMode = OperationMode.Synchronous; DataItems = new List<RequestDataItem>(); this.Connection = connection; }
internal void SetConnection(Connection connection) { _connection = connection; }
internal void EnqueueConnection(Connection connection) { if (connection.IsActive) _connections.Enqueue(connection); }
internal OSqlCreateProperty(Connection connection) { _connection = connection; }
internal void EnqueueConnection(Connection connection) { _connections.Enqueue(connection); }
internal OSqlDeleteCluster(Connection connection, short clusterid) { _connection = connection; _clusterid = clusterid; }