Browse Source

change sqlSessionTemplate singleton and reformat code (#1126)

* move updateTaskState into try/catch block in case of exception

* fix NPE

* using conf.getInt instead of getString

* for AbstractZKClient, remove the log, for it will print the same log message in createZNodePath.
for AlertDao, correct the spelling.

* duplicate

* refactor getTaskWorkerGroupId

* add friendly log

* update hearbeat thread num = 1

* fix the bug when worker execute task using queue. and remove checking Tenant user anymore in TaskScheduleThread

* 1. move verifyTaskInstanceIsNull after taskInstance
2. keep verifyTenantIsNull/verifyTaskInstanceIsNull clean and readable

* fix the message

* delete before check to avoid KeeperException$NoNodeException

* fix the message

* check processInstance state before delete tenant

* check processInstance state before delete worker group

* refactor

* merge api constants into common constatns

* update the resource perm

* update the dataSource perm

* fix CheckUtils.checkUserParams method

* update AlertGroupService, extends from BaseService, remove duplicate methods

* refactor

* modify method name

* add hasProjectAndPerm method

* using checkProject instead of getResultStatus

* delete checkAuth method, using hasProjectAndPerm instead.

* correct spelling

* add transactional for deleteWorkerGroupById

* add Transactional for deleteProcessInstanceById method

* change sqlSessionTemplate singleton

* change sqlSessionTemplate singleton and reformat code
pull/2/head
Tboy 5 years ago committed by lgcareer
parent
commit
da10e7fa88
  1. 16
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/ConnectionFactory.java

16
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/ConnectionFactory.java

@ -42,6 +42,8 @@ public class ConnectionFactory {
private static SqlSessionFactory sqlSessionFactory;
private static SqlSessionTemplate sqlSessionTemplate;
/**
* Load configuration file
*/
@ -125,12 +127,20 @@ public class ConnectionFactory {
* get sql session
*/
public static SqlSession getSqlSession() {
if (sqlSessionTemplate == null) {
synchronized (ConnectionFactory.class) {
if (sqlSessionTemplate == null) {
try {
return new SqlSessionTemplate(getSqlSessionFactory());
sqlSessionTemplate = new SqlSessionTemplate(getSqlSessionFactory());
return sqlSessionTemplate;
} catch (Exception e) {
logger.error(e.getMessage(),e);
throw new RuntimeException("get sqlSession failed!");
logger.error("getSqlSession error", e);
throw new RuntimeException(e);
}
}
}
}
return sqlSessionTemplate;
}
public static <T> T getMapper(Class<T> type) {

Loading…
Cancel
Save