コード例 #1
0
        private void dumpStatus(OpeLog logger, TextWriter writer)
        {
            int count = 0;

            for (int i = 0; i < pool.Length; i++)
            {
                Pool   p    = pool[i];
                string stat = null;
                if (p.busy)
                {
                    if (p.dbcon == null)
                    {
                        stat = "corrupted (busy but disposed)";
                    }
                    else if (p.dbcon.DBConnection == null)
                    {
                        stat = "corrupted (busy but no DB connection)";
                    }
                    else if (p.dbcon.DBConnection.State != ConnectionState.Open)
                    {
                        stat = "corrupted (busy but connection is not open)";
                    }
                    else
                    {
                        stat = "busy, SQL='" + (p.dbcon.CurrentSQL ?? "") + "'";
                    }
                }
                else if (p.dbcon != null)
                {
                    if (p.timer.ElapsedMilliseconds >= ReuseTimeout * 1000)
                    {
                        stat = String.Format("expired ({0}msec), waiting for dispose", p.timer.ElapsedMilliseconds);
                    }
                    else if (p.dbcon.DBConnection == null)
                    {
                        stat = "connection closed, waiting for dispose";
                    }
                    else if (p.dbcon.DBConnection.State != ConnectionState.Open)
                    {
                        stat = "invalid connection state " + p.dbcon.DBConnection.State.ToString();
                    }
                    else
                    {
                        stat = String.Format("free ({0}msec)", p.timer.ElapsedMilliseconds);
                    }
                }
                if (stat != null)
                {
                    string title = String.Format("DBConPool[{0}:{1}]#{2:D4}", this.Server, this.DBName, i);
                    if (logger != null)
                    {
                        logger.Log(title, OpeLog.Level.DEBUG, stat);
                    }
                    if (writer != null)
                    {
                        writer.WriteLine(title + ": " + stat);
                    }
                    count++;
                }
            }
            if (count == 0)
            {
                string title = String.Format("DBConPool[{0}:{1}]", this.Server, this.DBName);
                string msg   = "No alive connection pools.";
                if (logger != null)
                {
                    logger.Log(title, OpeLog.Level.DEBUG, msg);
                }
                if (writer != null)
                {
                    writer.WriteLine(title + ": " + msg);
                }
            }
        }
コード例 #2
0
 /// <summary>
 ///   接続中のDBConの状態を一覧表示する
 /// </summary>
 public void DumpStatus(OpeLog logger)
 {
     lock (mutex) {
         dumpStatus(logger, null);
     }
 }