@ -169,36 +169,38 @@ public class DesignEnvComponent {
}
private void startScheduler ( ) {
TenantContext . doIsolatedWork ( ( ) - > {
ClusterLock lock = ClusterBridge . getLockFactory ( ) . get ( SchedulerCoreComponent . class ) ;
// 多节点同时启动quartz模块可能会产生脏数据,导致报错,使用集群锁控制一下
DBSession dbSession = null ;
try {
lock . lock ( ) ;
final DBContextProvider context = BaseDBEnv . getDBContext ( ) ;
if ( context = = null ) {
throw new IllegalArgumentException ( "ConfigDBActivator must start before SchedulerActivator" ) ;
}
dbSession = context . openSession ( ) ;
dbSession . doWork ( new AbstractWork ( ) {
@Override
public void execute ( Connection connection ) throws SQLException {
//quartz需要的数据库方言
Properties properties = context . getDBProperties ( ) ;
QuartzContext . getInstance ( ) . initScheduler ( properties ) ;
if ( WorkContext . getCurrent ( ) . isLocal ( ) ) {
TenantContext . doIsolatedWork ( ( ) - > {
ClusterLock lock = ClusterBridge . getLockFactory ( ) . get ( SchedulerCoreComponent . class ) ;
// 多节点同时启动quartz模块可能会产生脏数据,导致报错,使用集群锁控制一下
DBSession dbSession = null ;
try {
lock . lock ( ) ;
final DBContextProvider context = BaseDBEnv . getDBContext ( ) ;
if ( context = = null ) {
throw new IllegalArgumentException ( "ConfigDBActivator must start before SchedulerActivator" ) ;
}
dbSession = context . openSession ( ) ;
dbSession . doWork ( new AbstractWork ( ) {
@Override
public void execute ( Connection connection ) throws SQLException {
//quartz需要的数据库方言
Properties properties = context . getDBProperties ( ) ;
QuartzContext . getInstance ( ) . initScheduler ( properties ) ;
}
} ) ;
EventDispatcher . fire ( SchedulerEvent . START ) ;
} catch ( Exception e ) {
FineLoggerFactory . getLogger ( ) . error ( e . getMessage ( ) , e ) ;
} finally {
if ( dbSession ! = null ) {
dbSession . closeSession ( ) ;
}
} ) ;
EventDispatcher . fire ( SchedulerEvent . START ) ;
} catch ( Exception e ) {
FineLoggerFactory . getLogger ( ) . error ( e . getMessage ( ) , e ) ;
} finally {
if ( dbSession ! = null ) {
dbSession . closeSession ( ) ;
lock . unlock ( ) ;
}
lock . unlock ( ) ;
}
} , "default" ) ;
} , "default" ) ;
}
}