Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Dependency Updates #567

Merged
merged 1 commit into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions scheduler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.21.RELEASE</version>
<version>1.5.22.RELEASE</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -80,8 +80,9 @@
<version>8.0.18</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp2.BasicDataSource;

import io.prometheus.client.Collector;
import io.prometheus.client.GaugeMetricFamily;
Expand Down Expand Up @@ -39,7 +39,7 @@ public List<MetricFamilySamples> collect() {
basicDataSource.getInitialSize()));
mfs.add(new GaugeMetricFamily(namespace + "_" + subSystem + "_data_source" + "_max_active",
"The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit",
basicDataSource.getMaxActive()));
basicDataSource.getMaxTotal()));
mfs.add(new GaugeMetricFamily(namespace + "_" + subSystem + "_data_source" + "_max_idle",
"The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.",
basicDataSource.getMaxIdle()));
Expand All @@ -64,7 +64,7 @@ public List<MetricFamilySamples> collect() {
policyBasicDataSource.getInitialSize()));
mfs.add(new GaugeMetricFamily(namespace + "_" + subSystem + "_policy_db_data_source" + "_max_active",
"The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit",
policyBasicDataSource.getMaxActive()));
policyBasicDataSource.getMaxTotal()));
mfs.add(new GaugeMetricFamily(namespace + "_" + subSystem + "_policy_db_data_source" + "_max_idle",
"The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.",
policyBasicDataSource.getMaxIdle()));
Expand Down
24 changes: 12 additions & 12 deletions scheduler/src/main/resources/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,31 @@
</property>
</bean>

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" primary="true"
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" primary="true"
destroy-method="close">
<property name="driverClassName" value="${spring.datasource.driverClassName}"/>
<property name="url" value="${spring.datasource.url}"/>
<property name="username" value="${spring.datasource.username}"/>
<property name="password" value="${spring.datasource.password}"/>
<property name="maxActive" value="${spring.datasource.maxActive:8}"/>
<property name="maxIdle" value="${spring.datasource.maxIdle:8}"/>
<property name="minIdle" value="${spring.datasource.minIdle:0}"/>
<property name="initialSize" value="${spring.datasource.initialSize:0}"/>

<property name="maxTotal" value="${spring.datasource.dbcp2.max-total:8}"/>
<property name="maxIdle" value="${spring.datasource.dbcp2.max-idle:8}"/>
<property name="minIdle" value="${spring.datasource.dbcp2.min-idle:0}"/>
<property name="initialSize" value="${spring.datasource.dbcp2.initial-size:0}"/>

</bean>

<bean id="policyDbDataSource" class="org.apache.commons.dbcp.BasicDataSource"
<bean id="policyDbDataSource" class="org.apache.commons.dbcp2.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${spring.policyDbDataSource.driverClassName}"/>
<property name="url" value="${spring.policyDbDataSource.url}"/>
<property name="username" value="${spring.policyDbDataSource.username}"/>
<property name="password" value="${spring.policyDbDataSource.password}"/>
<property name="maxActive" value="${spring.policyDbDataSource.maxActive:8}"/>
<property name="maxIdle" value="${spring.policyDbDataSource.maxIdle:8}"/>
<property name="minIdle" value="${spring.policyDbDataSource.minIdle:0}"/>
<property name="initialSize" value="${spring.policyDbDataSource.initialSize:0}"/>

<property name="maxTotal" value="${spring.policyDbDataSource.max-total:8}"/>
<property name="maxIdle" value="${spring.policyDbDataSource.max-idle:8}"/>
<property name="minIdle" value="${spring.policyDbDataSource.min-idle:0}"/>
<property name="initialSize" value="${spring.policyDbDataSource.initial-size:0}"/>
</bean>

<bean id="dbStatusCollector" class="org.cloudfoundry.autoscaler.scheduler.health.DBStatusCollector">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
package org.cloudfoundry.autoscaler.scheduler;

import static org.hamcrest.Matchers.equalToIgnoringCase;
import static org.hamcrest.Matchers.isA;
import static org.junit.Assert.assertThat;

import org.apache.commons.dbcp2.BasicDataSource;
import org.cloudfoundry.autoscaler.scheduler.util.error.DataSourceConfigurationException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class SchedulerApplicationTest {
@Autowired
private BasicDataSource dataSource;

@Rule
public ExpectedException expectedEx = ExpectedException.none();

@Test
public void testTomcatConnectionPoolNameCorrect() {
assertThat(dataSource.getClass().getName(), equalToIgnoringCase("org.apache.commons.dbcp2.BasicDataSource"));
}

@Test
public void testApplicationExitsWhenSchedulerDBUnreachable() {
expectedEx.expect(BeanCreationException.class);
Expand Down