You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/06/03 11:35:42 UTC

[GitHub] [shardingsphere] 15724757448 opened a new issue #10640: AbstractConnectionAdapter#getConnections Is it possible to make effective use of Connections?

15724757448 opened a new issue #10640:
URL: https://github.com/apache/shardingsphere/issues/10640


   public final List<Connection> getConnections(final ConnectionMode connectionMode, final String dataSourceName, final int connectionSize) throws SQLException {
           DataSource dataSource = getDataSourceMap().get(dataSourceName);
           Preconditions.checkState(null != dataSource, "Missing the data source name: '%s'", dataSourceName);
           Collection<Connection> connections;
           synchronized (cachedConnections) {
               connections = cachedConnections.get(dataSourceName);
           }
           List<Connection> result;
           if (connections.size() >= connectionSize) {
               result = new ArrayList<>(connections).subList(0, connectionSize);
           } else if (!connections.isEmpty()) {
               result = new ArrayList<>(connectionSize);
               result.addAll(connections);
               List<Connection> newConnections = createConnections(dataSourceName, connectionMode, dataSource, connectionSize - connections.size());
               result.addAll(newConnections);
               synchronized (cachedConnections) {
                   cachedConnections.putAll(dataSourceName, newConnections);
               }
           } else {
               result = new ArrayList<>(createConnections(dataSourceName, connectionMode, dataSource, connectionSize));
               synchronized (cachedConnections) {
                   cachedConnections.putAll(dataSourceName, result);
               }
           }
           return result;
       }
   
   When cachedconnections > = connectionsize, the data source is obtained from cachedconnections. If the maximum number of connections of the data source is greater than max.connections.size.per.query, will the maximum number of links never be used?
   
   for example
   
   <bean  id="druidDataSource" class="com.alibaba.druid.pool.DruidDataSource" >
       <property name="maxActive" value="80"/>
   </bean>
   <bean class="xxxDataSourceBuilder" actory-method="buildShardingDataSource">
       <constructor-arg name="dataSource" ref="druidDataSource"/>
       <constructor-arg name="properties">
           <props>
               <prop key="sql.show">true</prop>
               <prop key="max.connections.size.per.query">20</prop>
               <prop key="executor.size">20</prop>
           </props>
       </constructor-arg>
   </bean>
   
   maxActive=80. max.connections.size.per.query=20
   If this data source is only used by shardingDataSource, is maxactive limited to 20 at most?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] 15724757448 removed a comment on issue #10640: AbstractConnectionAdapter#getConnections Is it possible to make effective use of Connections? version 4.1.0

Posted by GitBox <gi...@apache.org>.
15724757448 removed a comment on issue #10640:
URL: https://github.com/apache/shardingsphere/issues/10640#issuecomment-853803027


   -----------code----------
   > public final List getConnections(final ConnectionMode connectionMode, final String dataSourceName, final int connectionSize) throws SQLException {
   > DataSource dataSource = getDataSourceMap().get(dataSourceName);
   > Preconditions.checkState(null != dataSource, "Missing the data source name: '%s'", dataSourceName);
   > Collection connections;
   > synchronized (cachedConnections) {
   > connections = cachedConnections.get(dataSourceName);
   > }
   > List result;
   > if (connections.size() >= connectionSize) {
   > result = new ArrayList<>(connections).subList(0, connectionSize);
   > } else if (!connections.isEmpty()) {
   > result = new ArrayList<>(connectionSize);
   > result.addAll(connections);
   > List newConnections = createConnections(dataSourceName, connectionMode, dataSource, connectionSize - connections.size());
   > result.addAll(newConnections);
   > synchronized (cachedConnections) {
   > cachedConnections.putAll(dataSourceName, newConnections);
   > }
   > } else {
   > result = new ArrayList<>(createConnections(dataSourceName, connectionMode, dataSource, connectionSize));
   > synchronized (cachedConnections) {
   > cachedConnections.putAll(dataSourceName, result);
   > }
   > }
   > return result;
   > }
   > 
   -----------question------
   > When cachedconnections > = connectionsize, the data source is obtained from cachedconnections. If the maximum number of connections of the data source is greater than max.connections.size.per.query, will the maximum number of links never be used?
   > 
   > for example
   > 
   > true 20 20
   > maxActive=80. max.connections.size.per.query=20
   > If this data source is only used by shardingDataSource, is maxactive limited to 20 at most?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] 15724757448 commented on issue #10640: AbstractConnectionAdapter#getConnections Is it possible to make effective use of Connections?

Posted by GitBox <gi...@apache.org>.
15724757448 commented on issue #10640:
URL: https://github.com/apache/shardingsphere/issues/10640#issuecomment-853803027


   -----------code----------
   > public final List getConnections(final ConnectionMode connectionMode, final String dataSourceName, final int connectionSize) throws SQLException {
   > DataSource dataSource = getDataSourceMap().get(dataSourceName);
   > Preconditions.checkState(null != dataSource, "Missing the data source name: '%s'", dataSourceName);
   > Collection connections;
   > synchronized (cachedConnections) {
   > connections = cachedConnections.get(dataSourceName);
   > }
   > List result;
   > if (connections.size() >= connectionSize) {
   > result = new ArrayList<>(connections).subList(0, connectionSize);
   > } else if (!connections.isEmpty()) {
   > result = new ArrayList<>(connectionSize);
   > result.addAll(connections);
   > List newConnections = createConnections(dataSourceName, connectionMode, dataSource, connectionSize - connections.size());
   > result.addAll(newConnections);
   > synchronized (cachedConnections) {
   > cachedConnections.putAll(dataSourceName, newConnections);
   > }
   > } else {
   > result = new ArrayList<>(createConnections(dataSourceName, connectionMode, dataSource, connectionSize));
   > synchronized (cachedConnections) {
   > cachedConnections.putAll(dataSourceName, result);
   > }
   > }
   > return result;
   > }
   > 
   -----------question------
   > When cachedconnections > = connectionsize, the data source is obtained from cachedconnections. If the maximum number of connections of the data source is greater than max.connections.size.per.query, will the maximum number of links never be used?
   > 
   > for example
   > 
   > true 20 20
   > maxActive=80. max.connections.size.per.query=20
   > If this data source is only used by shardingDataSource, is maxactive limited to 20 at most?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] 15724757448 removed a comment on issue #10640: AbstractConnectionAdapter#getConnections Is it possible to make effective use of Connections? version 4.1.0

Posted by GitBox <gi...@apache.org>.
15724757448 removed a comment on issue #10640:
URL: https://github.com/apache/shardingsphere/issues/10640#issuecomment-853803027


   -----------code----------
   > public final List getConnections(final ConnectionMode connectionMode, final String dataSourceName, final int connectionSize) throws SQLException {
   > DataSource dataSource = getDataSourceMap().get(dataSourceName);
   > Preconditions.checkState(null != dataSource, "Missing the data source name: '%s'", dataSourceName);
   > Collection connections;
   > synchronized (cachedConnections) {
   > connections = cachedConnections.get(dataSourceName);
   > }
   > List result;
   > if (connections.size() >= connectionSize) {
   > result = new ArrayList<>(connections).subList(0, connectionSize);
   > } else if (!connections.isEmpty()) {
   > result = new ArrayList<>(connectionSize);
   > result.addAll(connections);
   > List newConnections = createConnections(dataSourceName, connectionMode, dataSource, connectionSize - connections.size());
   > result.addAll(newConnections);
   > synchronized (cachedConnections) {
   > cachedConnections.putAll(dataSourceName, newConnections);
   > }
   > } else {
   > result = new ArrayList<>(createConnections(dataSourceName, connectionMode, dataSource, connectionSize));
   > synchronized (cachedConnections) {
   > cachedConnections.putAll(dataSourceName, result);
   > }
   > }
   > return result;
   > }
   > 
   -----------question------
   > When cachedconnections > = connectionsize, the data source is obtained from cachedconnections. If the maximum number of connections of the data source is greater than max.connections.size.per.query, will the maximum number of links never be used?
   > 
   > for example
   > 
   > true 20 20
   > maxActive=80. max.connections.size.per.query=20
   > If this data source is only used by shardingDataSource, is maxactive limited to 20 at most?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] 15724757448 commented on issue #10640: AbstractConnectionAdapter#getConnections Is it possible to make effective use of Connections?

Posted by GitBox <gi...@apache.org>.
15724757448 commented on issue #10640:
URL: https://github.com/apache/shardingsphere/issues/10640#issuecomment-853803027


   -----------code----------
   > public final List getConnections(final ConnectionMode connectionMode, final String dataSourceName, final int connectionSize) throws SQLException {
   > DataSource dataSource = getDataSourceMap().get(dataSourceName);
   > Preconditions.checkState(null != dataSource, "Missing the data source name: '%s'", dataSourceName);
   > Collection connections;
   > synchronized (cachedConnections) {
   > connections = cachedConnections.get(dataSourceName);
   > }
   > List result;
   > if (connections.size() >= connectionSize) {
   > result = new ArrayList<>(connections).subList(0, connectionSize);
   > } else if (!connections.isEmpty()) {
   > result = new ArrayList<>(connectionSize);
   > result.addAll(connections);
   > List newConnections = createConnections(dataSourceName, connectionMode, dataSource, connectionSize - connections.size());
   > result.addAll(newConnections);
   > synchronized (cachedConnections) {
   > cachedConnections.putAll(dataSourceName, newConnections);
   > }
   > } else {
   > result = new ArrayList<>(createConnections(dataSourceName, connectionMode, dataSource, connectionSize));
   > synchronized (cachedConnections) {
   > cachedConnections.putAll(dataSourceName, result);
   > }
   > }
   > return result;
   > }
   > 
   -----------question------
   > When cachedconnections > = connectionsize, the data source is obtained from cachedconnections. If the maximum number of connections of the data source is greater than max.connections.size.per.query, will the maximum number of links never be used?
   > 
   > for example
   > 
   > true 20 20
   > maxActive=80. max.connections.size.per.query=20
   > If this data source is only used by shardingDataSource, is maxactive limited to 20 at most?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org