String partitions = config.getString("partitions"); if (partitions.equals("default")) { ds.setPartitionCount(Math.max(8, Runtime.getRuntime().availableProcessors())); } else { ds.setPartitionCount(Integer.valueOf(partitions));
public static DataSource getDataSource(File file) throws ClassNotFoundException, IOException, DaoException { Class.forName("org.h2.Driver"); BoneCPDataSource ds = new BoneCPDataSource(); ds.setPartitionCount(8); ds.setMaxConnectionsPerPartition(4); ds.setJdbcUrl("jdbc:h2:"+file.getAbsolutePath()); ds.setUsername("sa"); ds.setPassword(""); // Initialize the database to create files try { ds.getConnection().close(); } catch (SQLException e) { throw new DaoException(e); } return ds; } }
DB_MIN_CONNECTIONS_PER_PARTITION, Integer.class, DB_DEFAULT_MIN_CONNECTIONS_PER_PARTITION)); datasource.setPartitionCount(env.getProperty(DB_PARTITION_COUNT, Integer.class, DB_DEFAULT_PARTITION_COUNT)); datasource.setAcquireIncrement(env.getProperty(DB_ACQUIRE_INCREMENT,
dataSource.setMaxConnectionsPerPartition(5); dataSource.setMinConnectionsPerPartition(2); dataSource.setPartitionCount(3); dataSource.setAcquireIncrement(2); dataSource.setStatementsCacheSize(100);
dataSource.setMaxConnectionsPerPartition(5); dataSource.setMinConnectionsPerPartition(2); dataSource.setPartitionCount(3); dataSource.setAcquireIncrement(2); dataSource.setStatementsCacheSize(100);
@Bean(destroyMethod = "close") public DataSource mainDataSource() { BoneCPDataSource dataSource = new BoneCPDataSource(); dataSource.setDriverClass(jdbcDriverClass); dataSource.setJdbcUrl(jdbcUrl); dataSource.setUsername(jdbcUsername); dataSource.setPassword(jdbcPassword); dataSource.setIdleConnectionTestPeriodInMinutes(2); dataSource.setIdleMaxAge(2, TimeUnit.HOURS); dataSource.setMaxConnectionsPerPartition(60); dataSource.setMinConnectionsPerPartition(20); dataSource.setPartitionCount(3); dataSource.setAcquireIncrement(10); dataSource.setStatementsCacheSize(50); return dataSource; } }
dataSource.setPartitionCount(PartitionCount); dataSource.setAcquireIncrement(AcquireIncrement); dataSource.setStatementsCacheSize(StatementsCacheSize);
private BoneCPDataSource createNewDataSource() { BoneCPDataSource target = new BoneCPDataSource(); target.setDriverClass(config.getDriverClassName()); target.setJdbcUrl(config.getJdbcUrl()); target.setUsername(config.getUserName()); target.setPassword(config.getPassword()); target.setIdleConnectionTestPeriodInMinutes(config.getIdleConnectionTestPeriodInMinutes()); target.setIdleMaxAgeInMinutes(config.getIdleMaxAgeInMinutes()); target.setMaxConnectionsPerPartition(config.getMaxConnectionsPerPartition()); target.setMinConnectionsPerPartition(config.getMinConnectionsPerPartition()); target.setPartitionCount(config.getPartitionCount()); target.setAcquireIncrement(config.getAcquireIncrement()); target.setStatementsCacheSize(config.getStatementsCacheSize()); target.setDisableJMX(true); return target; }
datasource.setPartitionCount(dbConf.getIntegerWithDefault("partitionCount", 1)); datasource.setMaxConnectionsPerPartition(dbConf.getIntegerWithDefault("maxConnectionsPerPartition", 30)); datasource.setMinConnectionsPerPartition(dbConf.getIntegerWithDefault("minConnectionsPerPartition", 5));