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