Esempio n. 1
0
 static Map<String, Map<String, Object>> getBasicDataSourceProperties() {
   if (!TOMCAT_BASIC_DATASOURCES_PROPERTIES.isEmpty()) {
     return TOMCAT_BASIC_DATASOURCES_PROPERTIES.getDataSourcesProperties();
   } else if (!DBCP_BASIC_DATASOURCES_PROPERTIES.isEmpty()) {
     return DBCP_BASIC_DATASOURCES_PROPERTIES.getDataSourcesProperties();
   } else if (!TOMCAT_JDBC_DATASOURCES_PROPERTIES.isEmpty()) {
     return TOMCAT_JDBC_DATASOURCES_PROPERTIES.getDataSourcesProperties();
   }
   return Collections.emptyMap();
 }
Esempio n. 2
0
 static int getMaxConnectionCount() {
   if (!TOMCAT_BASIC_DATASOURCES_PROPERTIES.isEmpty()) {
     return TOMCAT_BASIC_DATASOURCES_PROPERTIES.getMaxActive();
   } else if (!DBCP_BASIC_DATASOURCES_PROPERTIES.isEmpty()) {
     return DBCP_BASIC_DATASOURCES_PROPERTIES.getMaxActive();
   } else if (!TOMCAT_JDBC_DATASOURCES_PROPERTIES.isEmpty()) {
     return TOMCAT_JDBC_DATASOURCES_PROPERTIES.getMaxActive();
   }
   return -1;
 }
Esempio n. 3
0
  private static void pullTomcatJdbcDataSourceProperties(String name, DataSource dataSource) {
    // si tomcat-jdbc, alors on récupère des infos
    final org.apache.tomcat.jdbc.pool.DataSource jdbcDataSource =
        (org.apache.tomcat.jdbc.pool.DataSource) dataSource;
    final BasicDataSourcesProperties properties = TOMCAT_JDBC_DATASOURCES_PROPERTIES;
    // basicDataSource.getNumActive() est en théorie égale à USED_CONNECTION_COUNT à un instant t,
    // numIdle + numActive est le nombre de connexions ouvertes dans la bdd pour ce serveur à un
    // instant t

    // les propriétés généralement importantes en premier (se méfier aussi de testOnBorrow)
    properties.put(name, MAX_ACTIVE_PROPERTY_NAME, jdbcDataSource.getMaxActive());

    properties.put(name, "defaultCatalog", jdbcDataSource.getDefaultCatalog());
    properties.put(name, "defaultAutoCommit", jdbcDataSource.getDefaultAutoCommit());
    properties.put(name, "defaultReadOnly", jdbcDataSource.getDefaultReadOnly());
    properties.put(
        name, "defaultTransactionIsolation", jdbcDataSource.getDefaultTransactionIsolation());
    properties.put(name, "driverClassName", jdbcDataSource.getDriverClassName());
    properties.put(name, "connectionProperties", jdbcDataSource.getConnectionProperties());
    properties.put(name, "initSQL", jdbcDataSource.getInitSQL());
    properties.put(name, "initialSize", jdbcDataSource.getInitialSize());
    properties.put(name, "maxIdle", jdbcDataSource.getMaxIdle());
    properties.put(name, "maxWait", jdbcDataSource.getMaxWait());
    properties.put(name, "maxAge", jdbcDataSource.getMaxAge());
    properties.put(name, "faireQueue", jdbcDataSource.isFairQueue());
    properties.put(name, "jmxEnabled", jdbcDataSource.isJmxEnabled());
    properties.put(
        name, "minEvictableIdleTimeMillis", jdbcDataSource.getMinEvictableIdleTimeMillis());
    properties.put(name, "minIdle", jdbcDataSource.getMinIdle());
    properties.put(name, "numTestsPerEvictionRun", jdbcDataSource.getNumTestsPerEvictionRun());
    properties.put(name, "testOnBorrow", jdbcDataSource.isTestOnBorrow());
    properties.put(name, "testOnConnect", jdbcDataSource.isTestOnConnect());
    properties.put(name, "testOnReturn", jdbcDataSource.isTestOnReturn());
    properties.put(name, "testWhileIdle", jdbcDataSource.isTestWhileIdle());
    properties.put(
        name, "timeBetweenEvictionRunsMillis", jdbcDataSource.getTimeBetweenEvictionRunsMillis());
    properties.put(name, "validationInterval", jdbcDataSource.getValidationInterval());
    properties.put(name, "validationQuery", jdbcDataSource.getValidationQuery());
    properties.put(name, "validatorClassName", jdbcDataSource.getValidatorClassName());
  }
Esempio n. 4
0
  private static void pullCommonsDbcpDataSourceProperties(String name, DataSource dataSource) {
    // si dbcp et si dataSource standard, alors on récupère des infos
    final org.apache.commons.dbcp.BasicDataSource dbcpDataSource =
        (org.apache.commons.dbcp.BasicDataSource) dataSource;
    final BasicDataSourcesProperties properties = DBCP_BASIC_DATASOURCES_PROPERTIES;
    // basicDataSource.getNumActive() est en théorie égale à USED_CONNECTION_COUNT à un instant t,
    // numIdle + numActive est le nombre de connexions ouvertes dans la bdd pour ce serveur à un
    // instant t

    // les propriétés généralement importantes en premier (se méfier aussi de testOnBorrow)
    properties.put(name, MAX_ACTIVE_PROPERTY_NAME, dbcpDataSource.getMaxActive());
    properties.put(name, "poolPreparedStatements", dbcpDataSource.isPoolPreparedStatements());

    properties.put(name, "defaultCatalog", dbcpDataSource.getDefaultCatalog());
    properties.put(name, "defaultAutoCommit", dbcpDataSource.getDefaultAutoCommit());
    properties.put(name, "defaultReadOnly", dbcpDataSource.getDefaultReadOnly());
    properties.put(
        name, "defaultTransactionIsolation", dbcpDataSource.getDefaultTransactionIsolation());
    properties.put(name, "driverClassName", dbcpDataSource.getDriverClassName());
    properties.put(name, "initialSize", dbcpDataSource.getInitialSize());
    properties.put(name, "maxIdle", dbcpDataSource.getMaxIdle());
    properties.put(
        name, "maxOpenPreparedStatements", dbcpDataSource.getMaxOpenPreparedStatements());
    properties.put(name, "maxWait", dbcpDataSource.getMaxWait());
    properties.put(
        name, "minEvictableIdleTimeMillis", dbcpDataSource.getMinEvictableIdleTimeMillis());
    properties.put(name, "minIdle", dbcpDataSource.getMinIdle());
    properties.put(name, "numTestsPerEvictionRun", dbcpDataSource.getNumTestsPerEvictionRun());
    properties.put(name, "testOnBorrow", dbcpDataSource.getTestOnBorrow());
    properties.put(name, "testOnReturn", dbcpDataSource.getTestOnReturn());
    properties.put(name, "testWhileIdle", dbcpDataSource.getTestWhileIdle());
    properties.put(
        name, "timeBetweenEvictionRunsMillis", dbcpDataSource.getTimeBetweenEvictionRunsMillis());
    properties.put(name, "validationQuery", dbcpDataSource.getValidationQuery());
  }