Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont use SchedulerFactory reserved prefixes #116

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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ConnectionProvider(props: Properties) {
val logger = LoggerFactory.getLogger(this.getClass)
private val dataSource = props.getProperty("org.quartz.jobStore.dataSource")
private val jdbcURL = if (dataSource != null) props.getProperty("org.quartz.dataSource." + dataSource + ".URL") else null
private val detectIpAddressFailover = if (dataSource != null) props.getProperty("org.quartz.dataSource." + dataSource + ".ipFailover") == "true" else false
private val detectIpAddressFailover = props.getProperty("supportIPFailover") == "true"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume getProperty handles null values properly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, props.getProperty("supportIPFailover") will return null if the value is not in the config. And null == "true" will return false

// Removes "jdbc:mysql://" prefix and ":{port}..." suffix
private val dataSourceHostname = if (jdbcURL != null) jdbcURL.replace("jdbc:mysql://", "").split(":")(0) else null

Expand All @@ -37,7 +37,7 @@ class ConnectionProvider(props: Properties) {
private val pool: Pool = new Pool(getIP)

// Intended to be used only for tests. This mocks an IP failover every time a connection is retreived
private val causeFailoverEveryConnection = if (dataSource != null) props.getProperty("org.quartz.dataSource." + dataSource + ".causeFailoverEveryConnection") == "true" else false
private val causeFailoverEveryConnection = props.getProperty("causeFailoverEveryConnection") == "true"

def createNewConnectionProvider(): Option[HikariCpPoolingConnectionProvider] = {
if(dataSource != null) {
Expand Down
2 changes: 1 addition & 1 deletion worker/src/test/resources/quartz_test_mysql.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ org.quartz.dataSource.test_jobs.user: root
org.quartz.dataSource.test_jobs.password: root
org.quartz.dataSource.test_jobs.maxConnections: 10
org.quartz.dataSource.test_jobs.validationQuery: select 0
org.quartz.dataSource.test_jobs.ipFailover: true
supportIPFailover: true
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ org.quartz.dataSource.test_jobs.user: root
org.quartz.dataSource.test_jobs.password: root
org.quartz.dataSource.test_jobs.maxConnections: 10
org.quartz.dataSource.test_jobs.validationQuery: select 0
org.quartz.dataSource.test_jobs.ipFailover: true
supportIPFailover: true

# Unique configuration to this file
org.quartz.dataSource.test_jobs.causeFailoverEveryConnection: true
causeFailoverEveryConnection: true
4 changes: 2 additions & 2 deletions worker/src/test/scala/com/lucidchart/piezo/ModelTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ModelTest extends Specification with BeforeAll with AfterAll {

"JobHistoryModel" should {
"work correctly" in {
properties.getProperty("org.quartz.dataSource.test_jobs.causeFailoverEveryConnection") must beNull
properties.getProperty("causeFailoverEveryConnection") must beNull
val jobHistoryModel = new JobHistoryModel(properties)
val jobKey = new JobKey("blah", "blah")
val triggerKey = new TriggerKey("blahtn", "blahtg")
Expand All @@ -81,7 +81,7 @@ class ModelTest extends Specification with BeforeAll with AfterAll {
}

"work correctly with a failover for every connection to the database" in {
propertiesWithFailoverEveryConnection.getProperty("org.quartz.dataSource.test_jobs.causeFailoverEveryConnection") mustEqual("true")
propertiesWithFailoverEveryConnection.getProperty("causeFailoverEveryConnection") mustEqual("true")
val jobHistoryModel = new JobHistoryModel(propertiesWithFailoverEveryConnection)
val jobKey = new JobKey("blahc", "blahc")
val triggerKey = new TriggerKey("blahtnc", "blahtgc")
Expand Down