天天看點

We are already in the process of making n+ connections and the number of simultaneous builds has bee

simultaneous-build-throttle:

This is the maximum number of connections we can be building at any one time.

That is, the number of new connections that have been requested but aren’t yet available for use.

Because connections can be built using more than one thread (for instance, when they are built on demand)

and it takes a finite time between deciding to build the connection and it becoming available we need some

way of ensuring that a lot of threads don’t all decide to build a connection at once. (We could solve this in a

smarter way – and indeed we will one day) Default is 10.

是指在任一時刻,可以(同時)建立的最大連接配接數,也就是說,就是已經請求的、但還沒可用的新連接配接數量。因為連接配接可以用多線程建立,

從決定要建立連接配接到連接配接 可用是需要一定時間的,是以我們需要一些方式來避免大量的線程想同時建立連接配接。

(我們本應該找一個更聰明的方式來解決這個問題,總有一天我們會找到的)默 認值是10

當我使用140個使用者,進行壓力測試時,發現偶爾,會有多于10個要求同時建立連接配接的請求,當請求數量超過限定的數值時,會出現連接配接失敗的情況。

是以結論就是,當資料庫并發連接配接可能會比較高的應用,這個值應該适當的設大一點。

如果并發請求很高,可能出現的bug為

Caused by: java.sql.SQLException: We are already in the process of making 11 connections and the number of simultaneous builds has been throttled to 10

maximum-active-time:

If the housekeeper comes across a thread that has been active for longer than this then it will kill it. So make sure you set this to a number bigger than your slowest expected response! Default is 5 minutes.

如果一個線程活動時間超過這個數值,線程會被殺死。是以要確定這個數值設定得比最慢的響應時間長。預設是5分鐘。守護程序會把連接配接池中多餘的可用線程(未 用的、超過這個時間的)殺死,最終保留的連接配接數量就是minimum-connection-count規定的數量。守護程序會根據house- keeping-sleep-time參數設定的時間隔定時檢查。

maximum-connection-lifetime:

The maximum amount of time that a connection exists for before it is killed (milliseconds). Default is 4 hours.

指一個連接配接最大的存活時間(毫秒為機關),超過這個時間,連接配接會被殺死。預設值是4小時。

overload-without-refusal-lifetime:

This helps us determine the pool status. If we have refused a connection within this threshold (milliseconds) then we are overloaded. Default is 60 seconds.

這個參數幫助我們确定連接配接池的狀态,如果在這個時間閥值内(機關為毫秒)拒絕了一個連接配接,就認為是過載了。預設值是60。

alias:資料源的别名

driver-url:url連接配接串,須确定使用者名和密碼

driver-class:驅動名

username:使用者名(proxool沒有使用,但是不能沒有)

password:密碼(proxool沒有使用,但是不能沒有)

maximum-new-connections:沒有空閑連接配接可以配置設定而在隊列中等候的最大請求數,超過這個請求數的使用者連接配接就不會被接受

test-before-use:

If you set this to true then each connection is tested (with whatever is defined in house-keeping-test-sql) before being served. If a connection fails then it is discarded and another one is picked. If all connections fail a new one is built. If that one fails then you get an SQLException saying so.

如果連接配接池在運作當中,出現網絡或者資料庫故障而無法連接配接到資料庫,在恢複正常以後,由于連接配接是在連接配接池中持久儲存的,會出現連接配接仍然不可用的情況,這時連接配接池裡的連接配接實際上都是壞連接配接,怎麼讓連接配接池可以自動重連清除這些壞連接配接呢? 隻要配置了test-before-use 參數,即每次取出連接配接都檢查連接配接是否可用,就可以做到讓連接配接池實作在故障恢複後自動重連接配接

需要注意一點,對于Mysql資料庫還必須在連接配接參數裡加上autoReconnect=true 參數,否則即使打開了test-before-use 參數,仍然不能重連接配接!

fatal-sql-exception:

它是一個逗号分割的資訊片段.當一個SQL異常發生時,他的異常資訊将與這個資訊片段進行比較.如果在片段中存在,那麼這個異常将被認為是個緻命錯 誤(Fatal SQL Exception ).這種情況下,資料庫連接配接将要被放棄.無論發生什麼,這個異常将會被重擲以提供給消費者.使用者最好自己配置一個不同的異常來抛出.

fatal-sql-exception-wrapper-class:

正如上面所說,你最好配置一個不同的異常來重擲.利用這個屬性,使用者可以包裝SQLException,使他變成另外一個異常.這個異常或者繼承 SQLException或者繼承字RuntimeException.proxool自帶了2個實 現:’org.logicalcobwebs.proxool.FatalSQLException’ 和’org.logicalcobwebs.proxool.FatalRuntimeException’ .後者更合适.

house-keeping-sleep-time:

proxool自動偵察各個連接配接狀态的時間間隔(毫秒),偵察到空閑的連接配接就馬上回收,逾時的銷毀 預設30秒)

house keeper 保留線程處于睡眠狀态的最長時間,house keeper 的職責就是檢查各個連接配接的狀态,并判斷是否需要銷毀或者建立.

house-keeping-test-sql:

如果發現了空閑的資料庫連接配接.house keeper 将會用這個語句來測試.這個語句最好非常快的被執行.如果沒有定義,測試過程将會被忽略。

一般mysql可用select SYSDATE ,Oracle可用 select sysdate from dual 或者 select 1 from dual

injectable-connection-interface: 允許proxool實作被代理的connection對象的方法.

injectable-statement-interface: 允許proxool實作被代理的Statement 對象方法.

injectable-prepared-statement-interface: 允許proxool實作被代理的PreparedStatement 對象方法.

injectable-callable-statement-interface: 允許proxool實作被代理的CallableStatement 對象方法.

jmx: 略

jmx-agent-id: 略

jndi-name: 資料源的名稱

maximum-active-time: 如果housekeeper 檢測到某個線程的活動時間大于這個數值.它将會殺掉這個線程.是以确認一下你的伺服器的帶寬.然後定一個合适的值.預設是5分鐘.

maximum-connection-count:

The maximum number of connections to the database. Default is 15.

最大的資料庫連接配接數.預設是15

minimum-connection-count: 最小的資料庫連接配接數,預設是5

prototype-count:

If there are fewer than this number of connections available then we will build some more (assuming the maximum-connection-count is not exceeded). For example. Of we have 3 active connections and 2 available, but our prototype-count is 4 then it will attempt to build another 2. This differs from minimum-connection-count because it takes into account the number of active connections. minimum-connection-count is absolute and doesn’t care how many are in use. prototype-count is the number of spare connections it strives to keep over and above the ones that are currently active. Default is 0.

連接配接池中可用的連接配接數量.如果目前的連接配接池中的連接配接少于這個數值.新的連接配接将被建立(假設沒有超過最大可用數).例如.我們有3個活動連接配接2個可用 連接配接,而我們的prototype-count是4,那麼資料庫連接配接池将試圖建立另外2個連接配接.這和 minimum-connection-count不同. minimum-connection-count把活動的連接配接也計算在内.prototype-count 是spare connections 的數量.

recently-started-threshold: 略

statistics: 連接配接池使用狀況統計。 參數“10s,1m,1d”

statistics-log-level: 日志統計跟蹤類型。 參數“ERROR”或 “INFO”

test-after-use: 略

trace: 如果為true,那麼每個被執行的SQL語句将會在執行期被log記錄(DEBUG LEVEL).你也可以注冊一個ConnectionListener (參看ProxoolFacade)得到這些資訊.

verbose: 詳細資訊設定。 參數 bool 值