• 5星
36.9MB Johnho130 2021-03-28 18:18:13
• 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

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参数设置的时间隔定时检查。

The maximum amount of time that a connection exists for before it is killed (milliseconds). Default is 4 hours.
指一个连接最大的存活时间（毫秒为单位），超过这个时间，连接会被杀死。默认值是4小时。

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:驱动名

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: 略

verbose: 详细信息设置。 参数 bool 值

展开全文
a564663276 2015-01-19 10:30:52
• ## We are already in the process of making 11 connections and the number of simultaneous builds has be MySQL

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 情况一 但是我的最大值都是120了，是非常大的，不...

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

情况一

但是我的最大值都是120了，是非常大的，不知道怎么回事提示了一个10，经过查询

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 arent 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 dont 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.

相应的解决方案也就出来了

<simultaneous-build-throttle>10</simultaneous-build-throttle>
改成
<simultaneous-build-throttle>20</simultaneous-build-throttle>

情况二

服务器端jboss控制台报如下错误:

java.sql.SQLException: We are already in the process of making 501 connections and the number of simultaneous builds has been throttled to 500
开始认为是proxool连接池连接太少了,我增加到2000个,重启jboss然后一下子就变成了
java.sql.SQLException: We are already in the process of making 2001 connections and the number of simultaneous builds has been throttled to 2000

There is a bug in the proxool library. The default parameter defined in the documentation are not set. Therefore parameter like MaximumConnectionCount are not set. JdbcUtil from QuickFixJ sets this parameter. But the parameter SimultaneousBuildThrottle is not set and therfore 0. This leads to SQLExcption under high load. I changed JdbcUtil.getDataSource() with the line
ds.setSimultaneousBuildThrottle(10);
after the line

ds.setMaximumConnectionCount(10);

Now I do not get SQLException anymore.

我以为原来用的proxool.properties配制项少了什么,然后换成proxool.xml的配制还是一样

找到如下两个方法:
http://blog.i918.cn/html/06/5806-2122.html
在經過多方測試，以及詢問官方原廠的回應下
發現這屬於官方一個系統上的特殊設定，亦可稱呼他為 mysql 的 bug
不管連結的的方式是經過 hosts 或是 IP 的模式，他都會對 DNS 做反查
會嘗試去反查 IP -> dns ，由於反查解析過慢，無法應付快速多量的查詢
反查是上層 ISP 所掌控，並不是我們可以解決及要求的

在知道問題的癥結點後，要解決這個問題就有相對應的方法
其方法分為兩個步驟，第一是開啟 Mysqld 的時候加入特定的參數啟動
第二就是修改 mysql 的連線設定等，如下所示

啟動參數； with --skip-name-resolve =>這樣就可以關閉反查動作
更改 my.cnf；加強以下設定
[mysqld]
socket=/tmp/mysql.sock
port=3306
set-variable = key_buffer_size=64M
set-variable = max_connections=1024
set-variable = interactive_timeout=30
set-variable = wait_timeout=30
set-variable = join_buffer_size=10M
set-variable = long_query_time=20
set-variable = table_cache=256
set-variable = sort_buffer=4M
set-variable = record_buffer=1M
set-variable = back_log=500

[mysqld.server]
user=mysql
basedir=/usr/local

經過以上的設定及重新啟動過後，直到現在還沒有看到一個 unauthenticated user 的情況發生
近日還是會持續的觀察 Mysql 的運作情況，如有問題將會持續的稟報及解決。

http://blog.csdn.net/eroswang/archive/2008/07/10/2633237.aspx
1、启动时带参数　 --skip-name-resolve
2、访问的主机授权时用IP，最好把该主机的IP及主机名写到/etc/hosts文件中
我们这边的管理员是做如下处理:
/etc/my.cnf
下mysqld
随便一行加skip-name-resolve

展开全文
cs123dn_ll 2013-08-10 09:44:09
• ## We are already in the process of making 11 connections and the number of simultaneous builds has ... google buffer mysql jboss

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情况一但是我的最大值都是120了，是非常大的，不知道...

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

情况一

但是我的最大值都是120了，是非常大的，不知道怎么回事提示了一个10，经过查询

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 arent 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 dont 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.

相应的解决方案也就出来了

<simultaneous-build-throttle>10</simultaneous-build-throttle>
改成
<simultaneous-build-throttle>20</simultaneous-build-throttle>

情况二

服务器端jboss控制台报如下错误:

java.sql.SQLException: We are already in the process of making 501 connections and the number of simultaneous builds has been throttled to 500
开始认为是proxool连接池连接太少了,我增加到2000个,重启jboss然后一下子就变成了
java.sql.SQLException: We are already in the process of making 2001 connections and the number of simultaneous builds has been throttled to 2000

There is a bug in the proxool library. The default parameter defined in the documentation are not set. Therefore parameter like MaximumConnectionCount are not set. JdbcUtil from QuickFixJ sets this parameter. But the parameter SimultaneousBuildThrottle is not set and therfore 0. This leads to SQLExcption under high load. I changed JdbcUtil.getDataSource() with the line
ds.setSimultaneousBuildThrottle(10);
after the line

ds.setMaximumConnectionCount(10);

Now I do not get SQLException anymore.

我以为原来用的proxool.properties配制项少了什么,然后换成proxool.xml的配制还是一样

找到如下两个方法:
http://blog.i918.cn/html/06/5806-2122.html
在經過多方測試，以及詢問官方原廠的回應下
發現這屬於官方一個系統上的特殊設定，亦可稱呼他為 mysql 的 bug
不管連結的的方式是經過 hosts 或是 IP 的模式，他都會對 DNS 做反查
會嘗試去反查 IP -> dns ，由於反查解析過慢，無法應付快速多量的查詢
反查是上層 ISP 所掌控，並不是我們可以解決及要求的

在知道問題的癥結點後，要解決這個問題就有相對應的方法
其方法分為兩個步驟，第一是開啟 Mysqld 的時候加入特定的參數啟動
第二就是修改 mysql 的連線設定等，如下所示

啟動參數； with --skip-name-resolve =>這樣就可以關閉反查動作
更改 my.cnf；加強以下設定
[mysqld]
socket=/tmp/mysql.sock
port=3306
set-variable = key_buffer_size=64M
set-variable = max_connections=1024
set-variable = interactive_timeout=30
set-variable = wait_timeout=30
set-variable = join_buffer_size=10M
set-variable = long_query_time=20
set-variable = table_cache=256
set-variable = sort_buffer=4M
set-variable = record_buffer=1M
set-variable = back_log=500

[mysqld.server]
user=mysql
basedir=/usr/local

經過以上的設定及重新啟動過後，直到現在還沒有看到一個 unauthenticated user 的情況發生
近日還是會持續的觀察 Mysql 的運作情況，如有問題將會持續的稟報及解決。

http://blog.csdn.net/eroswang/archive/2008/07/10/2633237.aspx
1、启动时带参数　 --skip-name-resolve
2、访问的主机授权时用IP，最好把该主机的IP及主机名写到/etc/hosts文件中
我们这边的管理员是做如下处理:
/etc/my.cnf
下mysqld
随便一行加skip-name-resolve

展开全文
swandragon 2009-10-28 15:16:00
• You are given two positive integers a and b. In one move, you can change a in the following way: Choose any positive odd integer x (x>0) and replace a with a+x; choose any positive even integer y ....

You are given two positive integers a and b.
In one move, you can change a in the following way:
Choose any positive odd integer x (x>0) and replace a with a+x;
choose any positive even integer y (y>0) and replace a with a−y.
You can perform as many such operations as you want. You can choose the same numbers x and y in different moves.
Your task is to find the minimum number of moves required to obtain b from a. It is guaranteed that you can always obtain b from a.
You have to answer t independent test cases.

Input
The first line of the input contains one integer t (1≤t≤104) — the number of test cases.
Then t test cases follow. Each test case is given as two space-separated integers a and b (1≤a,b≤109).

Output
For each test case, print the answer — the minimum number of moves required to obtain b from a if you can perform any number of moves described in the problem statement. It is guaranteed that you can always obtain b from a.

#include <iostream>
#include <cstdio>
using namespace std;
int pd(int a,int b){
if(a==b){
return 0;
} else if (a<b){
if((a%2==0&&b%2==0)||(a%2!=0&&b%2!=0)){
return 2;
} else {
return 1;
}
} else{
if((a%2==0&&b%2==0)||(a%2!=0&&b%2!=0)){
return 2;
} else {
return 1;
}
}
}
int main() {
int n,aa,bb;
scanf("%d",&n);
while (n--){
scanf("%d %d",aa,bb);
printf("%d\n",pd(aa,bb));
}
}

展开全文
xcdq_aaa 2020-03-23 20:51:34
• qq_41185868 2019-11-26 15:01:02
• screaming 2016-03-25 23:06:00
• ## IBM Minus One string

shunfurh 2017-03-02 14:25:14
• ## Sequence Number c

qq_34886018 2017-06-09 18:05:59
• ## The Special Number each

shunfurh 2017-02-11 05:38:05
• justin_kang 2019-01-21 11:24:04
• u011981242 2015-09-22 10:57:12
• ## 【string】#84 A. Nearly Lucky Number Codeforces

okcd00 2014-11-29 21:24:33
• violet_echo_0908 2017-12-28 16:04:37
• ## Machine Learning - Linear Regression with One Variable algorithm

iracer 2016-02-13 17:22:49
• caozhankui 2013-10-22 23:06:16
• ## Coursera Machine Learning 第一周 quiz Linear Regression with One Variable 习题答案 Coursera

mupengfei6688 2016-11-08 23:54:03
• u013385925 2018-04-29 12:22:12
• ## 全新版大学英语(第二版)综合教程3 Unit 1 测试答案 We Learn 经验分享

xhzrzb 2021-10-30 13:03:22
• ## 关于One-hot编码的一些整理及用途[转载+整理] 数据处理 机器学习 分类

qq_32793161 2019-06-23 21:44:23
• lujiandong1 2015-10-27 14:45:09
• ## Machine Learning - II. Linear Regression with One Variable单变量线性回归 (Week 1) 机器学习 线性回归

pipisorry 2015-01-25 17:50:22
• ## LeetCode Sort Colors (One Pass Solution) leetcode

yangliuy 2014-10-29 13:01:46
• inter_peng 2016-12-17 00:45:00
• dulingtingzi 2016-05-11 14:51:33
• ## LeetCode 简单算法题 算法 简单 leetCode

github_35631540 2018-06-06 19:55:57
• acetaohai123123 2017-10-17 21:58:02
• qq_43422111 2020-05-01 08:03:03
• ## HDOJ/HDU 1328 IBM Minus One(水题一个，试试手) java acm

qq_26525215 2016-06-01 16:32:24

...