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

Commit

Permalink
bugFix embrace spring flyway (#2246)
Browse files Browse the repository at this point in the history
* embrace spring flyway
* embrace spring flyway - add comments
  • Loading branch information
michaelpaliy authored May 15, 2021
1 parent 2082d63 commit 8c6c36c
Show file tree
Hide file tree
Showing 22 changed files with 70 additions and 655 deletions.
10 changes: 5 additions & 5 deletions docker/server/config/config-mysql-grpc.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ conductor.grpc-server.enabled=true
# Database persistence model.
conductor.db.type=mysql

conductor.mysql.jdbcUrl=jdbc:mysql://mysql:3306/conductor
conductor.mysql.jdbcUsername=conductor
conductor.mysql.jdbcPassword=conductor
spring.datasource.url=jdbc:mysql://mysql:3306/conductor
spring.datasource.username=conductor
spring.datasource.password=conductor

# Hikari pool sizes are -1 by default and prevent startup
conductor.mysql.connectionPoolMaxSize=10
conductor.mysql.connectionPoolMinIdle=2
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.minimum-idle=2

# Elastic search instance indexing is enabled.
conductor.indexing.enabled=true
Expand Down
10 changes: 5 additions & 5 deletions docker/server/config/config-mysql.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ conductor.grpc-server.enabled=false
# Database persistence type.
conductor.db.type=mysql

conductor.mysql.jdbcUrl=jdbc:mysql://mysql:3306/conductor
conductor.mysql.jdbcUsername=conductor
conductor.mysql.jdbcPassword=conductor
spring.datasource.url=jdbc:mysql://mysql:3306/conductor
spring.datasource.username=conductor
spring.datasource.password=conductor

# Hikari pool sizes are -1 by default and prevent startup
conductor.mysql.connectionPoolMaxSize=10
conductor.mysql.connectionPoolMinIdle=2
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.minimum-idle=2

# Elastic search instance indexing is enabled.
conductor.indexing.enabled=true
Expand Down
2 changes: 1 addition & 1 deletion mysql-persistence/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
implementation "org.apache.commons:commons-lang3"

implementation "mysql:mysql-connector-java"
implementation "com.zaxxer:HikariCP"
implementation "org.springframework.boot:spring-boot-starter-jdbc"
implementation "org.flywaydb:flyway-core"

testImplementation "org.testcontainers:mysql:${revTestContainer}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,36 @@
import com.netflix.conductor.mysql.dao.MySQLQueueDAO;
import javax.sql.DataSource;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Import;

@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(MySQLProperties.class)
@ConditionalOnProperty(name = "conductor.db.type", havingValue = "mysql")
// Import the DataSourceAutoConfiguration when mysql database is selected.
// By default the datasource configuration is excluded in the main module.
@Import(DataSourceAutoConfiguration.class)
public class MySQLConfiguration {

@Bean
public DataSource dataSource(MySQLProperties properties) {
return new MySQLDataSourceProvider(properties).getDataSource();
}

@Bean
@DependsOn({"flyway", "flywayInitializer"})
public MetadataDAO mySqlMetadataDAO(ObjectMapper objectMapper, DataSource dataSource, MySQLProperties properties) {
return new MySQLMetadataDAO(objectMapper, dataSource, properties);
}

@Bean
@DependsOn({"flyway", "flywayInitializer"})
public ExecutionDAO mySqlExecutionDAO(ObjectMapper objectMapper, DataSource dataSource) {
return new MySQLExecutionDAO(objectMapper, dataSource);
}

@Bean
@DependsOn({"flyway", "flywayInitializer"})
public QueueDAO mySqlQueueDAO(ObjectMapper objectMapper, DataSource dataSource) {
return new MySQLQueueDAO(objectMapper, dataSource);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,173 +22,13 @@
@ConfigurationProperties("conductor.mysql")
public class MySQLProperties {

/**
* The jdbc url to be used for connecting to the database
*/
private String jdbcUrl = "jdbc:mysql://localhost:3306/conductor";

/**
* The username to be used for connections
*/
private String jdbcUsername = "conductor";

/**
* The password to be used for connections
*/
private String jdbcPassword = "password";

/**
* Used to enable/disable flyway migrations
*/
private boolean flywayEnabled = true;

/**
* Used to override the default flyway migration table
*/
private String flywayTable = "schema_version";

// The defaults are currently in line with the HikariConfig defaults, which are unfortunately private.
/**
* The maximum size that the connection pool is allowed to reach including idle and in-use connections
*/
private int connectionPoolMaxSize = -1;

/**
* The minimum number of idle connections that the connection pool tries to maintain in the pool
*/
private int connectionPoolMinIdle = -1;

/**
* The maximum lifetime of a connection (in minutes) in the pool
*/
@DurationUnit(ChronoUnit.MINUTES)
private Duration connectionMaxLifetime = Duration.ofMinutes(30);

/**
* The maximum amount of time (in minutes) that a connection is allowed to sit idle in the pool
*/
@DurationUnit(ChronoUnit.MINUTES)
private Duration connectionIdleTimeout = Duration.ofMinutes(10);

/**
* The maximum amount of time (in seconds) that a client will wait for a connection from the pool
*/
@DurationUnit(ChronoUnit.SECONDS)
private Duration connectionTimeout = Duration.ofSeconds(30);

/**
* The transaction isolation level as specified in {@link Connection}
*/
private String transactionIsolationLevel = "";

//This is consistent with the current default when building the Hikari Client.
/**
* The auto-commit behavior of the connections in the pool
*/
private boolean autoCommit = false;

/**
* The time (in seconds) after which the in-memory task definitions cache will be refreshed
*/
private Duration taskDefCacheRefreshInterval = Duration.ofSeconds(60);


public String getJdbcUrl() {
return jdbcUrl;
}

public void setJdbcUrl(String jdbcUrl) {
this.jdbcUrl = jdbcUrl;
}

public String getJdbcUsername() {
return jdbcUsername;
}

public void setJdbcUsername(String jdbcUsername) {
this.jdbcUsername = jdbcUsername;
}

public String getJdbcPassword() {
return jdbcPassword;
}

public void setJdbcPassword(String jdbcPassword) {
this.jdbcPassword = jdbcPassword;
}

public boolean isFlywayEnabled() {
return flywayEnabled;
}

public void setFlywayEnabled(boolean flywayEnabled) {
this.flywayEnabled = flywayEnabled;
}

public String getFlywayTable() {
return flywayTable;
}

public void setFlywayTable(String flywayTable) {
this.flywayTable = flywayTable;
}

public int getConnectionPoolMaxSize() {
return connectionPoolMaxSize;
}

public void setConnectionPoolMaxSize(int connectionPoolMaxSize) {
this.connectionPoolMaxSize = connectionPoolMaxSize;
}

public int getConnectionPoolMinIdle() {
return connectionPoolMinIdle;
}

public void setConnectionPoolMinIdle(int connectionPoolMinIdle) {
this.connectionPoolMinIdle = connectionPoolMinIdle;
}

public Duration getConnectionMaxLifetime() {
return connectionMaxLifetime;
}

public void setConnectionMaxLifetime(Duration connectionMaxLifetime) {
this.connectionMaxLifetime = connectionMaxLifetime;
}

public Duration getConnectionIdleTimeout() {
return connectionIdleTimeout;
}

public void setConnectionIdleTimeout(Duration connectionIdleTimeout) {
this.connectionIdleTimeout = connectionIdleTimeout;
}

public Duration getConnectionTimeout() {
return connectionTimeout;
}

public void setConnectionTimeout(Duration connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}

public String getTransactionIsolationLevel() {
return transactionIsolationLevel;
}

public void setTransactionIsolationLevel(String transactionIsolationLevel) {
this.transactionIsolationLevel = transactionIsolationLevel;
}

public boolean isAutoCommit() {
return autoCommit;
}

public void setAutoCommit(boolean autoCommit) {
this.autoCommit = autoCommit;
}

public Duration getTaskDefCacheRefreshInterval() {
return taskDefCacheRefreshInterval;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,12 @@ public class MySQLExecutionDAOTest extends ExecutionDAOTest {
public void setup() {
mySQLContainer = new MySQLContainer<>(DockerImageName.parse("mysql")).withDatabaseName(name.getMethodName());
mySQLContainer.start();
testUtil = new MySQLDAOTestUtil(mySQLContainer, objectMapper, name.getMethodName());
testUtil = new MySQLDAOTestUtil(mySQLContainer, objectMapper);
executionDAO = new MySQLExecutionDAO(testUtil.getObjectMapper(), testUtil.getDataSource());
testUtil.resetAllData();
}

@After
public void teardown() {
testUtil.resetAllData();
testUtil.getDataSource().close();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,13 @@ public class MySQLMetadataDAOTest {
public void setup() {
mySQLContainer = new MySQLContainer<>(DockerImageName.parse("mysql")).withDatabaseName(name.getMethodName());
mySQLContainer.start();
testUtil = new MySQLDAOTestUtil(mySQLContainer, objectMapper, name.getMethodName());
testUtil = new MySQLDAOTestUtil(mySQLContainer, objectMapper);
metadataDAO = new MySQLMetadataDAO(testUtil.getObjectMapper(), testUtil.getDataSource(),
testUtil.getTestProperties());
}

@After
public void teardown() {
testUtil.resetAllData();
testUtil.getDataSource().close();
}

Expand Down
Loading

0 comments on commit 8c6c36c

Please sign in to comment.