com.vladmihalcea.flexypool.strategy.IncrementPoolOnTimeoutConnectionAcquiringStrategy Java Examples
The following examples show how to use
com.vladmihalcea.flexypool.strategy.IncrementPoolOnTimeoutConnectionAcquiringStrategy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlexyPoolConfigurationTests.java From spring-boot-data-source-decorator with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("unchecked") void testDecoratingHikariDataSourceWithDefaultStrategies() { ApplicationContextRunner contextRunner = this.contextRunner.withPropertyValues("spring.datasource.type:" + HikariDataSource.class.getName()); contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); assertDataSourceOfType(dataSource, HikariDataSource.class); FlexyPoolDataSource<HikariDataSource> flexyPoolDataSource = assertDataSourceOfType(dataSource, HikariDataSource.class); IncrementPoolOnTimeoutConnectionAcquiringStrategy<HikariDataSource> strategy1 = findStrategy(flexyPoolDataSource, IncrementPoolOnTimeoutConnectionAcquiringStrategy.class); assertThat(strategy1).isNotNull(); assertThat(strategy1).hasFieldOrPropertyWithValue("maxOverflowPoolSize", 15); assertThat(strategy1).hasFieldOrPropertyWithValue("timeoutMillis", 500); RetryConnectionAcquiringStrategy<HikariDataSource> strategy2 = findStrategy(flexyPoolDataSource, RetryConnectionAcquiringStrategy.class); assertThat(strategy2).isNotNull(); assertThat(strategy2).hasFieldOrPropertyWithValue("retryAttempts", 2); }); }
Example #2
Source File: FlexyPoolConfigurationTests.java From spring-boot-data-source-decorator with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("unchecked") void testDecoratingHikariDataSourceWithCustomPropertyStrategies() { ApplicationContextRunner contextRunner = this.contextRunner.withPropertyValues("spring.datasource.type:" + HikariDataSource.class.getName(), "decorator.datasource.flexy-pool.acquiring-strategy.increment-pool.max-overflow-pool-size:15", "decorator.datasource.flexy-pool.acquiring-strategy.increment-pool.timeout-millis:500", "decorator.datasource.flexy-pool.acquiring-strategy.retry.attempts:5") .withUserConfiguration(HikariConfiguration.class); contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); FlexyPoolDataSource<HikariDataSource> flexyPoolDataSource = assertDataSourceOfType(dataSource, HikariDataSource.class); IncrementPoolOnTimeoutConnectionAcquiringStrategy<HikariDataSource> strategy1 = findStrategy(flexyPoolDataSource, IncrementPoolOnTimeoutConnectionAcquiringStrategy.class); assertThat(strategy1).isNotNull(); assertThat(strategy1).hasFieldOrPropertyWithValue("maxOverflowPoolSize", 35); assertThat(strategy1).hasFieldOrPropertyWithValue("timeoutMillis", 10000); RetryConnectionAcquiringStrategy<HikariDataSource> strategy2 = findStrategy(flexyPoolDataSource, RetryConnectionAcquiringStrategy.class); assertThat(strategy2).isNotNull(); assertThat(strategy2).hasFieldOrPropertyWithValue("retryAttempts", 5); }); }
Example #3
Source File: FlexyPoolConfiguration.java From spring-boot-data-source-decorator with Apache License 2.0 | 6 votes |
static <T extends DataSource> List<ConnectionAcquiringStrategyFactory<?, T>> mergeFactories( List<ConnectionAcquiringStrategyFactory<?, T>> factories, FlexyPoolProperties flexyPool) { List<ConnectionAcquiringStrategyFactory<?, T>> newFactories = new ArrayList<>(); List<? extends Class<?>> factoryClasses; if (factories != null) { factoryClasses = factories.stream().map(Object::getClass).collect(Collectors.toList()); newFactories.addAll(factories); } else { factoryClasses = Collections.emptyList(); } if (!factoryClasses.contains(IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory.class)) { IncrementPool incrementPool = flexyPool.getAcquiringStrategy().getIncrementPool(); if (incrementPool.getMaxOverflowPoolSize() > 0) { newFactories.add(new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory<>( incrementPool.getMaxOverflowPoolSize(), incrementPool.getTimeoutMillis())); } } if (!factoryClasses.contains(RetryConnectionAcquiringStrategy.Factory.class)) { Retry retry = flexyPool.getAcquiringStrategy().getRetry(); if (retry.getAttempts() > 0) { newFactories.add(new RetryConnectionAcquiringStrategy.Factory<>(retry.getAttempts())); } } return newFactories; }
Example #4
Source File: FlexyPoolWrapper.java From hammock with Apache License 2.0 | 5 votes |
private DataSource wrapInternal(String name, HikariDataSource dataSource) { Configuration<HikariDataSource> configuration = createConfiguration(name, config, dataSource); int maxOverflow = config.getOptionalValue(format(MAX_OVERFLOW_PROPERTY_FORMAT, name), Integer.class).orElse(5); int retry = config.getOptionalValue(format(RETRY_PROPERTY_FORMAT, name), Integer.class).orElse(2); return new FlexyPoolDataSource<HikariDataSource>(configuration, new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory(maxOverflow), new RetryConnectionAcquiringStrategy.Factory(retry) ); }
Example #5
Source File: FlexyPoolConfiguration.java From flexy-pool with Apache License 2.0 | 5 votes |
@Bean(initMethod = "start", destroyMethod = "stop") public FlexyPoolDataSource dataSource() { Configuration<PoolingDataSource> configuration = configuration(); return new FlexyPoolDataSource<PoolingDataSource>(configuration, new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory(5), new RetryConnectionAcquiringStrategy.Factory(2) ); }
Example #6
Source File: FlexyPoolConfiguration.java From flexy-pool with Apache License 2.0 | 5 votes |
@Bean(initMethod = "start", destroyMethod = "stop") public FlexyPoolDataSource dataSource() { Configuration<HikariDataSource> configuration = configuration(); return new FlexyPoolDataSource<HikariDataSource>(configuration, new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory(5), new RetryConnectionAcquiringStrategy.Factory(2) ); }
Example #7
Source File: FlexyPoolConfiguration.java From flexy-pool with Apache License 2.0 | 5 votes |
@Bean(initMethod = "start", destroyMethod = "stop") public FlexyPoolDataSource dataSource() { Configuration<ComboPooledDataSource> configuration = configuration(); return new FlexyPoolDataSource<ComboPooledDataSource>(configuration, new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory(5), new RetryConnectionAcquiringStrategy.Factory(2) ); }
Example #8
Source File: AbstractFlexyDataSourceConfiguration.java From flexy-pool with Apache License 2.0 | 5 votes |
@Bean(initMethod = "start", destroyMethod = "stop") public FlexyPoolDataSource dataSource() { Configuration configuration = configuration(); return new FlexyPoolDataSource(configuration, new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory(getMaxOverflowPoolSize()), new RetryConnectionAcquiringStrategy.Factory(getRetryAttempts()) ); }
Example #9
Source File: FlexyPoolConfiguration.java From flexy-pool with Apache License 2.0 | 5 votes |
@Bean(initMethod = "start", destroyMethod = "stop") public FlexyPoolDataSource dataSource() { Configuration<DruidDataSource> configuration = configuration(); return new FlexyPoolDataSource<DruidDataSource>( configuration, new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory( 5 ), new RetryConnectionAcquiringStrategy.Factory( 2 ) ); }
Example #10
Source File: FlexyPoolConfiguration.java From flexy-pool with Apache License 2.0 | 5 votes |
@Bean(initMethod = "start", destroyMethod = "stop") public FlexyPoolDataSource dataSource() { Configuration<DataSource> configuration = configuration(); return new FlexyPoolDataSource<DataSource>(configuration, new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory(5), new RetryConnectionAcquiringStrategy.Factory(2) ); }
Example #11
Source File: FlexyPoolConfiguration.java From flexy-pool with Apache License 2.0 | 5 votes |
@Bean(initMethod = "start", destroyMethod = "stop") public FlexyPoolDataSource dataSource() { Configuration<BasicDataSource> configuration = configuration(); return new FlexyPoolDataSource<BasicDataSource>(configuration, new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory(5), new RetryConnectionAcquiringStrategy.Factory(2) ); }
Example #12
Source File: FlexyPoolConfiguration.java From flexy-pool with Apache License 2.0 | 5 votes |
@Bean(initMethod = "start", destroyMethod = "stop") public FlexyPoolDataSource dataSource() { Configuration<BasicDataSource> configuration = configuration(); return new FlexyPoolDataSource<BasicDataSource>(configuration, new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory(5), new RetryConnectionAcquiringStrategy.Factory(2) ); }
Example #13
Source File: FlexyPoolConfiguration.java From flexy-pool with Apache License 2.0 | 5 votes |
@Bean(initMethod = "start", destroyMethod = "stop") public FlexyPoolDataSource dataSource() { Configuration<AbstractDataSourceBean> configuration = configuration(); return new FlexyPoolDataSource<AbstractDataSourceBean>(configuration, new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory(5), new RetryConnectionAcquiringStrategy.Factory(2) ); }
Example #14
Source File: FlexyPoolConfiguration.java From flexy-pool with Apache License 2.0 | 5 votes |
@Bean(initMethod = "start", destroyMethod = "stop") public FlexyPoolDataSource dataSource() { Configuration<DataSource> configuration = configuration(); return new FlexyPoolDataSource<DataSource>(configuration, new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory(5), new RetryConnectionAcquiringStrategy.Factory(2) ); }
Example #15
Source File: FlexyPoolConfiguration.java From flexy-pool with Apache License 2.0 | 5 votes |
@Bean(initMethod = "start", destroyMethod = "stop") public FlexyPoolDataSource dataSource() { Configuration<AbstractDataSourceBean> configuration = configuration(); return new FlexyPoolDataSource<AbstractDataSourceBean>(configuration, new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory(5), new RetryConnectionAcquiringStrategy.Factory(2) ); }
Example #16
Source File: FlexyPoolConfigurationTests.java From spring-boot-data-source-decorator with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings("unchecked") void testDecoratingHikariDataSourceWithCustomBeanStrategies() { ApplicationContextRunner contextRunner = this.contextRunner.withPropertyValues("spring.datasource.type:" + HikariDataSource.class.getName()) .withConfiguration(AutoConfigurations.of(HikariConfiguration.class)); contextRunner.run(context -> { DataSource dataSource = context.getBean(DataSource.class); FlexyPoolDataSource<HikariDataSource> flexyPoolDataSource = assertDataSourceOfType(dataSource, HikariDataSource.class); IncrementPoolOnTimeoutConnectionAcquiringStrategy<HikariDataSource> strategy1 = findStrategy(flexyPoolDataSource, IncrementPoolOnTimeoutConnectionAcquiringStrategy.class); assertThat(strategy1).isNotNull(); assertThat(strategy1).hasFieldOrPropertyWithValue("maxOverflowPoolSize", 35); assertThat(strategy1).hasFieldOrPropertyWithValue("timeoutMillis", 10000); RetryConnectionAcquiringStrategy<HikariDataSource> strategy2 = findStrategy(flexyPoolDataSource, RetryConnectionAcquiringStrategy.class); assertThat(strategy2).isNotNull(); assertThat(strategy2).hasFieldOrPropertyWithValue("retryAttempts", 5); HikariConnectionAcquiringFactory strategy3 = findStrategy(flexyPoolDataSource, HikariConnectionAcquiringFactory.class); assertThat(strategy3).isNotNull(); Dbcp2ConnectionAcquiringFactory strategy4 = findStrategy(flexyPoolDataSource, Dbcp2ConnectionAcquiringFactory.class); assertThat(strategy4).isNull(); }); }
Example #17
Source File: FlexyPoolConfigurationTests.java From spring-boot-data-source-decorator with Apache License 2.0 | 4 votes |
@Bean public IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory<HikariDataSource> incrementPoolOnTimeoutConnectionAcquiringStrategyFactory() { return new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory<>(35, 10000); }