-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(scheduler): add scheduler configuration and add support for clus…
…tering Fixes #3520
- Loading branch information
Showing
14 changed files
with
583 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...nsions/scheduler/deployment/src/test/java/io/quarkus/scheduler/test/NoDataSourceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.quarkus.scheduler.test; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class NoDataSourceTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setExpectedException(IllegalStateException.class) | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(SimpleJobs.class) | ||
.addAsResource(new StringAsset("simpleJobs.cron=0/1 * * * * ?\nsimpleJobs.every=1s" + | ||
"\nquarkus.scheduler.store.type=database-store\n"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void shouldFailMissingDataSource() throws InterruptedException { | ||
/** | ||
* Should not reach here | ||
*/ | ||
Assertions.fail(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...ime/src/main/java/io/quarkus/scheduler/runtime/AgroalQuartzConnectionPoolingProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package io.quarkus.scheduler.runtime; | ||
|
||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
import java.util.Properties; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import org.quartz.utils.PoolingConnectionProvider; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.arc.InstanceHandle; | ||
|
||
public class AgroalQuartzConnectionPoolingProvider implements PoolingConnectionProvider { | ||
final private DataSource dataSource; | ||
|
||
public AgroalQuartzConnectionPoolingProvider() { | ||
final InstanceHandle<DataSource> dataSourceInstanceHandle = Arc.container().instance(DataSource.class); | ||
if (dataSourceInstanceHandle.isAvailable()) { | ||
this.dataSource = dataSourceInstanceHandle.get(); | ||
} else { | ||
throw new IllegalStateException( | ||
"JDBC Store configured but datasource is missing. You can configure your datasource by following the guide available at: https://quarkus.io/guides/datasource-guide"); | ||
} | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public AgroalQuartzConnectionPoolingProvider(Properties properties) { | ||
this(); | ||
} | ||
|
||
@Override | ||
public DataSource getDataSource() { | ||
return dataSource; | ||
} | ||
|
||
@Override | ||
public Connection getConnection() throws SQLException { | ||
return dataSource.getConnection(); | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.