Inheritance: IDisposable
Exemplo n.º 1
0
        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");
            }
        }
Exemplo n.º 2
0
        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;
            }
        }
Exemplo n.º 3
0
        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();
                }
            }
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
 public OServer(string hostname, int port, string userName, string userPassword)
 {
     _connection = new Connection(hostname, port, userName, userPassword);
 }
Exemplo n.º 6
0
 internal OLoadRecord(Connection connection)
 {
     _connection = connection;
 }
 internal ORecordMetadata(Connection connection)
 {
     _connection = connection;
 }
 internal OSqlCreateProperty(Connection connection)
 {
     _connection = connection;
     _sqlQuery = new SqlQuery(_connection);
 }
Exemplo n.º 9
0
 public Response(Connection connection)
 {
     this.Connection = connection;
 }
Exemplo n.º 10
0
 internal OCommandQuery(Connection connection, CommandPayloadBase payload)
 {
     _connection = connection;
     _payload = payload;
 }
Exemplo n.º 11
0
 internal OClusterQuery(Connection _connection)
 {
     this._connection = _connection;
 }
Exemplo n.º 12
0
        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();
                }
            }
        }
Exemplo n.º 13
0
 internal Request(Connection connection)
 {
     OperationMode = OperationMode.Synchronous;
     DataItems = new List<RequestDataItem>();
     this.Connection = connection;
 }
Exemplo n.º 14
0
 internal void SetConnection(Connection connection)
 {
     _connection = connection;
 }
Exemplo n.º 15
0
 internal void EnqueueConnection(Connection connection)
 {
     if (connection.IsActive)
         _connections.Enqueue(connection);
 }
 internal OSqlCreateProperty(Connection connection)
 {
     _connection = connection;
 }
Exemplo n.º 17
0
 internal void EnqueueConnection(Connection connection)
 {
     _connections.Enqueue(connection);
 }
 internal OSqlDeleteCluster(Connection connection, short clusterid)
 {
     _connection = connection;
     _clusterid = clusterid;
 }