From 9406103a0355b7a96ceb1755ab3671ecffec1afb Mon Sep 17 00:00:00 2001 From: lgcareer <18610854716@163.com> Date: Wed, 14 Aug 2019 14:36:02 +0800 Subject: [PATCH 1/4] add druid connection provider (#699) * add druid connection provider in order to change quartz default connection pool * remove c3p0 in escheduler-api and escheduler-dao * change method name queryByIdAndIp to queryBySessionId and queryByUserIdAndIp to queryByUserId * change connectionProvider.class from c3p0 to druid * change connectionProvider.class from c3p0 to druid --- escheduler-api/pom.xml | 6 + .../src/main/resources/quartz.properties | 2 +- escheduler-dao/pom.xml | 6 + .../dao/mapper/SessionMapperProvider.java | 8 +- .../quartz/DruidConnectionProvider.java | 203 ++++++++++++++++++ 5 files changed, 220 insertions(+), 5 deletions(-) create mode 100644 escheduler-server/src/main/java/cn/escheduler/server/quartz/DruidConnectionProvider.java diff --git a/escheduler-api/pom.xml b/escheduler-api/pom.xml index 2ac260f314..766993ca4e 100644 --- a/escheduler-api/pom.xml +++ b/escheduler-api/pom.xml @@ -141,6 +141,12 @@ org.quartz-scheduler quartz + + + c3p0 + c3p0 + + diff --git a/escheduler-common/src/main/resources/quartz.properties b/escheduler-common/src/main/resources/quartz.properties index 3aa3df5fca..1f17801b8d 100644 --- a/escheduler-common/src/main/resources/quartz.properties +++ b/escheduler-common/src/main/resources/quartz.properties @@ -30,7 +30,7 @@ org.quartz.jobStore.dataSource = myDs #============================================================================ # Configure Datasources #============================================================================ - +org.quartz.dataSource.myDs.connectionProvider.class = cn.escheduler.server.quartz.DruidConnectionProvider org.quartz.dataSource.myDs.driver = com.mysql.jdbc.Driver org.quartz.dataSource.myDs.URL = jdbc:mysql://192.168.xx.xx:3306/escheduler?characterEncoding=utf8 org.quartz.dataSource.myDs.user = xx diff --git a/escheduler-dao/pom.xml b/escheduler-dao/pom.xml index 4d8fb6912e..bbd45c0c89 100644 --- a/escheduler-dao/pom.xml +++ b/escheduler-dao/pom.xml @@ -116,6 +116,12 @@ org.quartz-scheduler quartz + + + c3p0 + c3p0 + + diff --git a/escheduler-dao/src/main/java/cn/escheduler/dao/mapper/SessionMapperProvider.java b/escheduler-dao/src/main/java/cn/escheduler/dao/mapper/SessionMapperProvider.java index 07567fd9ea..5dec6b0fcc 100644 --- a/escheduler-dao/src/main/java/cn/escheduler/dao/mapper/SessionMapperProvider.java +++ b/escheduler-dao/src/main/java/cn/escheduler/dao/mapper/SessionMapperProvider.java @@ -103,11 +103,11 @@ public class SessionMapperProvider { } /** - * query by session id and ip + * query by session id * @param parameter * @return */ - public String queryByIdAndIp(Map parameter) { + public String queryBySessionId(Map parameter) { return new SQL() {{ SELECT("*"); @@ -118,11 +118,11 @@ public class SessionMapperProvider { } /** - * query by user id and ip + * query by user id * @param parameter * @return */ - public String queryByUserIdAndIp(Map parameter) { + public String queryByUserId(Map parameter) { return new SQL() {{ SELECT("*"); diff --git a/escheduler-server/src/main/java/cn/escheduler/server/quartz/DruidConnectionProvider.java b/escheduler-server/src/main/java/cn/escheduler/server/quartz/DruidConnectionProvider.java new file mode 100644 index 0000000000..b58d87ce9d --- /dev/null +++ b/escheduler-server/src/main/java/cn/escheduler/server/quartz/DruidConnectionProvider.java @@ -0,0 +1,203 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package cn.escheduler.server.quartz; + +import com.alibaba.druid.pool.DruidDataSource; +import org.quartz.SchedulerException; +import java.sql.Connection; +import java.sql.SQLException; +import org.quartz.utils.ConnectionProvider; + +/** + * druid connection provider + */ +public class DruidConnectionProvider implements ConnectionProvider { + + /** + * JDBC driver + */ + public String driver; + + /** + * JDBC URL + */ + public String URL; + + /** + * Database user name + */ + public String user; + + /** + * Database password + */ + public String password; + + /** + * Maximum number of database connections + */ + public int maxConnections; + + /** + * The query that validates the database connection + */ + public String validationQuery; + + /** + * Whether the database sql query to validate connections should be executed every time + * a connection is retrieved from the pool to ensure that it is still valid. If false, + * then validation will occur on check-in. Default is false. + */ + private boolean validateOnCheckout; + + /** + * The number of seconds between tests of idle connections - only enabled + * if the validation query property is set. Default is 50 seconds. + */ + private int idleConnectionValidationSeconds; + + /** + * The maximum number of prepared statements that will be cached per connection in the pool. + * Depending upon your JDBC Driver this may significantly help performance, or may slightly + * hinder performance. + * Default is 120, as Quartz uses over 100 unique statements. 0 disables the feature. + */ + public String maxCachedStatementsPerConnection; + + /** + * Discard connections after they have been idle this many seconds. 0 disables the feature. Default is 0. + */ + private String discardIdleConnectionsSeconds; + + /** + * Default maximum number of database connections in the pool. + */ + public static final int DEFAULT_DB_MAX_CONNECTIONS = 10; + + /** + * The maximum number of prepared statements that will be cached per connection in the pool. + */ + public static final int DEFAULT_DB_MAX_CACHED_STATEMENTS_PER_CONNECTION = 120; + + /** + * Druid connection pool + */ + private DruidDataSource datasource; + + public Connection getConnection() throws SQLException { + return datasource.getConnection(); + } + public void shutdown() throws SQLException { + datasource.close(); + } + public void initialize() throws SQLException{ + if (this.URL == null) { + throw new SQLException("DBPool could not be created: DB URL cannot be null"); + } + if (this.driver == null) { + throw new SQLException("DBPool driver could not be created: DB driver class name cannot be null!"); + } + if (this.maxConnections < 0) { + throw new SQLException("DBPool maxConnectins could not be created: Max connections must be greater than zero!"); + } + datasource = new DruidDataSource(); + try{ + datasource.setDriverClassName(this.driver); + } catch (Exception e) { + try { + throw new SchedulerException("Problem setting driver class name on datasource: " + e.getMessage(), e); + } catch (SchedulerException e1) { + } + } + datasource.setUrl(this.URL); + datasource.setUsername(this.user); + datasource.setPassword(this.password); + datasource.setMaxActive(this.maxConnections); + datasource.setMinIdle(1); + datasource.setMaxWait(0); + datasource.setMaxPoolPreparedStatementPerConnectionSize(DEFAULT_DB_MAX_CONNECTIONS); + if (this.validationQuery != null) { + datasource.setValidationQuery(this.validationQuery); + if(!this.validateOnCheckout) + datasource.setTestOnReturn(true); + else + datasource.setTestOnBorrow(true); + datasource.setValidationQueryTimeout(this.idleConnectionValidationSeconds); + } + } + + public String getDriver() { + return driver; + } + public void setDriver(String driver) { + this.driver = driver; + } + public String getURL() { + return URL; + } + public void setURL(String URL) { + this.URL = URL; + } + public String getUser() { + return user; + } + public void setUser(String user) { + this.user = user; + } + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + public int getMaxConnections() { + return maxConnections; + } + public void setMaxConnections(int maxConnections) { + this.maxConnections = maxConnections; + } + public String getValidationQuery() { + return validationQuery; + } + public void setValidationQuery(String validationQuery) { + this.validationQuery = validationQuery; + } + public boolean isValidateOnCheckout() { + return validateOnCheckout; + } + public void setValidateOnCheckout(boolean validateOnCheckout) { + this.validateOnCheckout = validateOnCheckout; + } + public int getIdleConnectionValidationSeconds() { + return idleConnectionValidationSeconds; + } + public void setIdleConnectionValidationSeconds(int idleConnectionValidationSeconds) { + this.idleConnectionValidationSeconds = idleConnectionValidationSeconds; + } + public DruidDataSource getDatasource() { + return datasource; + } + public void setDatasource(DruidDataSource datasource) { + this.datasource = datasource; + } + public String getDiscardIdleConnectionsSeconds() { + return discardIdleConnectionsSeconds; + } + public void setDiscardIdleConnectionsSeconds(String discardIdleConnectionsSeconds) { + this.discardIdleConnectionsSeconds = discardIdleConnectionsSeconds; + } +} From 1b76bb019c198b31f535a91495d08764d63f386f Mon Sep 17 00:00:00 2001 From: easyscheduler Date: Thu, 15 Aug 2019 14:59:02 +0800 Subject: [PATCH 2/4] update proposal (#704) * Update EasyScheduler Proposal.md * update proposal --- docs/en_US/EasyScheduler Proposal.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/en_US/EasyScheduler Proposal.md b/docs/en_US/EasyScheduler Proposal.md index 83da414022..7f7de05787 100644 --- a/docs/en_US/EasyScheduler Proposal.md +++ b/docs/en_US/EasyScheduler Proposal.md @@ -42,31 +42,30 @@ Then we open the source code of EasyScheduler on March 2019. It soon gained lot' ## Rationale -Many organizations (>30) (refer to [Who is using EasyScheduler](https://github.com/analysys/EasyScheduler/issues/57) ) already benefit from running EasyScheduler to make data process pipelines more easier. More than 100 [feature ideas](https://github.com/analysys/EasyScheduler/projects/1) come from EasyScheduler community. Some 3th projects also wanted to integrate with EasyScheduler through task plugin, like [Scriptis](https://github.com/WeBankFinTech/Scriptis) 、[waterdrop](https://github.com/InterestingLab/waterdrop) and so on. these will strengthen the features of EasyScheduler. +Many organizations (>30) (refer to [Who is using EasyScheduler](https://github.com/analysys/EasyScheduler/issues/57) ) already benefit from running EasyScheduler to make data process pipelines more easier. More than 100 [feature ideas](https://github.com/analysys/EasyScheduler/projects/1) come from EasyScheduler community. Some 3rd-party projects also plan to integrate with EasyScheduler through task plugin, such as [Scriptis](https://github.com/WeBankFinTech/Scriptis), [waterdrop](https://github.com/InterestingLab/waterdrop). These will strengthen the features of EasyScheduler. ## Current Status ### Meritocracy -EasyScheduler was incubated at Analysys in 2017 and open sourced on GitHub in March 2019. Once open source,We have been quickly adopted by multiple organizations,EasyScheduler has contributors and users from many companies; we have set up the PMC Team and Committer Team. New contributors are guided and reviewed by existed PMC members. -When they are ready, PMC will start a vote to promote him/her to become a member of PMC or Committer Team. +EasyScheduler was incubated at Analysys in 2017 and open sourced on GitHub in March 2019. Once open sourced, we have been quickly adopted by multiple organizations,EasyScheduler has contributors and users from many companies; we have set up the Committer Team. New contributors are guided and reviewed by existed committer members. Contributions are always welcomed and highly valued. ### Community -Now we have set development teams for EasyScheduler in Analysys, and we already have external developers who contributed the code. We already have a user group of more than 1,000 people. +Now we have set development teams for EasyScheduler in Analysys, and we already have external developers who contributed the code. We already have a user group of more than 1,000 people. We hope to grow the base of contributors by inviting all those who offer contributions through The Apache Way. Right now, we make use of github as code hosting as well as gitter for community communication. ### Core Developers -The core developers, including experienced open source developers and team leaders, have formed a group full of diversity. All of these core developers have deep expertise in workflow processing and the Hadoop Ecosystem in general. +The core developers, including experienced senior developers, are often guided by mentors. ## Known Risks ### Orphaned products -EasyScheduler is widely adopted in China by many [companies and organizations](https://github.com/analysys/EasyScheduler/issues/57). The core developers of EasyScheduler team plan to work full time on this project. Currently there are 10 use cases with more that 1000 activity tasks per day using EasyScheduler in the user's production environment. Furthermore, since EasyScheduler has received more than 1500 stars and been forked more than 500 times. EasyScheduler has eight major release so far and and received 365 pull requests from contributors, which further demonstrates EasyScheduler as a very active project. We plan to extend and diversify this community further through Apache. +EasyScheduler is widely adopted in China by many [companies and organizations](https://github.com/analysys/EasyScheduler/issues/57). The core developers of EasyScheduler team plan to work full time on this project. Currently there are 10 use cases with more that 1000 activity tasks per day using EasyScheduler in the user's production environment. There is very little risk of EasyScheduler getting orphaned since at least two large company (xueqiu、fengjr) is extensively using it in their production, and developers from these companies have also joined Easy Scheduler's team of contributors, EasyScheduler has eight major release so far and and received 373 pull requests from contributors, which further demonstrates EasyScheduler as a very active project. We also plan to extend and diversify this community further through Apache. Thus, it is very unlikely that EasyScheduler becomes orphaned. @@ -83,7 +82,7 @@ Considering that fengjr and sefonsoft have shown great interest in EasyScheduler ### Reliance on Salaried Developers At present, eight of the core developers are paid by their employer to contribute to EasyScheduler project. -we also find some developers and researchers (>8) to contribute to the project, and we will make efforts to increase the diversity of the contributors and actively lobby for Domain experts in the workflow space to contribute. +we also have some other developers and researchers taking part in the project, and we will make efforts to increase the diversity of the contributors and actively lobby for Domain experts in the workflow space to contribute. ### Relationships with Other Apache Products @@ -1418,13 +1417,13 @@ Travis (TODO) ### Champion -- Sheng Wu ( Apache Software Foundation Member [wusheng@apache.org](mailto:wusheng@apache.org)) +- Sheng Wu ( Apache Incubator PMC, [wusheng@apache.org](mailto:wusheng@apache.org)) ### Mentors - Sheng Wu ( Apache Incubator PMC, [wusheng@apache.org](mailto:wusheng@apache.org)) -- ShaoFeng Shi ( Apache Kylin committer & PMC, Apache Incubator PMC, [shaofengshi@apache.org](mailto:wusheng@apache.org)) +- ShaoFeng Shi ( Apache Incubator PMC, [shaofengshi@apache.org](mailto:wusheng@apache.org)) - Liang Chen ( Apache Software Foundation Member, [chenliang613@apache.org](mailto:chenliang613@apache.org)) From 522f9efe6940ae3dba024d99eec8686ba747f9e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=99=9F=20Wu=20Sheng?= Date: Thu, 15 Aug 2019 16:11:00 +0800 Subject: [PATCH 3/4] Update EasyScheduler Proposal.md (#705) --- docs/en_US/EasyScheduler Proposal.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/en_US/EasyScheduler Proposal.md b/docs/en_US/EasyScheduler Proposal.md index 7f7de05787..1d5968a844 100644 --- a/docs/en_US/EasyScheduler Proposal.md +++ b/docs/en_US/EasyScheduler Proposal.md @@ -65,19 +65,19 @@ The core developers, including experienced senior developers, are often guided b ### Orphaned products -EasyScheduler is widely adopted in China by many [companies and organizations](https://github.com/analysys/EasyScheduler/issues/57). The core developers of EasyScheduler team plan to work full time on this project. Currently there are 10 use cases with more that 1000 activity tasks per day using EasyScheduler in the user's production environment. There is very little risk of EasyScheduler getting orphaned since at least two large company (xueqiu、fengjr) is extensively using it in their production, and developers from these companies have also joined Easy Scheduler's team of contributors, EasyScheduler has eight major release so far and and received 373 pull requests from contributors, which further demonstrates EasyScheduler as a very active project. We also plan to extend and diversify this community further through Apache. +EasyScheduler is widely adopted in China by many [companies and organizations](https://github.com/analysys/EasyScheduler/issues/57). The core developers of EasyScheduler team plan to work full time on this project. Currently there are 10 use cases with more that 1000 activity tasks per day using EasyScheduler in the user's production environment. There is very little risk of EasyScheduler getting orphaned as at least two large companies (xueqiu、fengjr) are widely using it in their production, and developers from these companies have also joined Easy Scheduler's team of contributors, EasyScheduler has eight major releases so far, and and received 373 pull requests from contributors, which further demonstrates EasyScheduler as a very active project. We also plan to extend and diversify this community further through Apache. Thus, it is very unlikely that EasyScheduler becomes orphaned. ### Inexperience with Open Source -EasyScheduler's core developers have been running it as a community-oriented open source project for some time, several of them already have experience working with open source communities, they are also active in presto, alluxio and other projects.At the same time, we will learn more open source experience from the excellent apache open source project to make up for this shortcoming. +EasyScheduler's core developers have been running it as a community-oriented open source project for some time, several of them already have experience working with open source communities, they are also active in presto, alluxio and other projects. At the same time, we will learn more open source experiences by following the Apache way in our incubator journey. ### Homogenous Developers The current developers work across a variety of organizations including Analysys, guandata and hydee; some individual developers are accepted as developers of EasyScheduler as well. -Considering that fengjr and sefonsoft have shown great interest in EasyScheduler, we plan to encourage them to contribute and invite them as contributors to work together. +Considering that fengjr and sefonsoft have shown great interests in EasyScheduler, we plan to encourage them to contribute and invite them as contributors to work together. ### Reliance on Salaried Developers @@ -110,7 +110,7 @@ The project consists of three distinct codebases: core and document. The address ## Source and Intellectual Property Submission Plan -As soon as EasyScheduler is approved to join Apache Incubator, Analysys will execute a Software Grant Agreement and the source code will be transitioned onto ASF infrastructure. The code is already licensed under the Apache Software License, version 2.0. +As soon as EasyScheduler is approved to join Apache Incubator, Analysys will provide the Software Grant Agreement(SGA) and intial committers will submit ICLA(s). The code is already licensed under the Apache Software License, version 2.0. ## External Dependencies @@ -1384,7 +1384,7 @@ The community would like to continue using GitHub Issues. ### Continuous Integration tool -Travis (TODO) +Travis ### Mailing Lists From 8d1e46ec43eb47fd763b4e2b19b02ffdf198d018 Mon Sep 17 00:00:00 2001 From: easyscheduler Date: Thu, 15 Aug 2019 16:35:58 +0800 Subject: [PATCH 4/4] use Jenkins (#706) * Update EasyScheduler Proposal.md * update proposal --- docs/en_US/EasyScheduler Proposal.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en_US/EasyScheduler Proposal.md b/docs/en_US/EasyScheduler Proposal.md index 1d5968a844..c01c368f4c 100644 --- a/docs/en_US/EasyScheduler Proposal.md +++ b/docs/en_US/EasyScheduler Proposal.md @@ -1384,7 +1384,7 @@ The community would like to continue using GitHub Issues. ### Continuous Integration tool -Travis +Jenkins ### Mailing Lists