|
|
|
@ -31,6 +31,7 @@ import com.fr.cluster.ClusterBridge;
|
|
|
|
|
import com.fr.cluster.lock.ClusterLock; |
|
|
|
|
import com.fr.config.BaseDBEnv; |
|
|
|
|
import com.fr.config.ConfigEvent; |
|
|
|
|
import com.fr.config.Configuration; |
|
|
|
|
import com.fr.config.FinalPreferenceConfig; |
|
|
|
|
import com.fr.config.dao.DaoContext; |
|
|
|
|
import com.fr.config.dao.impl.BatchSubmitClassHelperDao; |
|
|
|
@ -42,6 +43,8 @@ import com.fr.config.dao.impl.hibernate.HibernateXmlEnityDao;
|
|
|
|
|
import com.fr.config.dao.impl.remote.RemoteClassHelperDao; |
|
|
|
|
import com.fr.config.dao.impl.remote.RemoteEntityDao; |
|
|
|
|
import com.fr.config.dao.impl.remote.RemoteXmlEntityDao; |
|
|
|
|
import com.fr.config.holder.ConfigChangeListener; |
|
|
|
|
import com.fr.config.holder.ValidateConfigManger; |
|
|
|
|
import com.fr.config.impl.ConfConfigProviderImpl; |
|
|
|
|
import com.fr.config.impl.ConfigInsecurityElementProviderImpl; |
|
|
|
|
import com.fr.decision.service.context.ServiceContext; |
|
|
|
@ -54,6 +57,7 @@ import com.fr.design.backup.EnvBackupHelper;
|
|
|
|
|
import com.fr.env.detect.EnvDetectorCenter; |
|
|
|
|
import com.fr.event.EventDispatcher; |
|
|
|
|
import com.fr.general.FRLogger; |
|
|
|
|
import com.fr.general.log.Log4jConfig; |
|
|
|
|
import com.fr.general.log.Log4jUtils; |
|
|
|
|
import com.fr.intelli.metrics.Compute; |
|
|
|
|
import com.fr.intelli.metrics.DBMonitorInterceptor; |
|
|
|
@ -86,6 +90,7 @@ import com.fr.stable.db.session.DBSession;
|
|
|
|
|
import com.fr.stable.project.ProjectConstants; |
|
|
|
|
import com.fr.tenant.context.TenantContext; |
|
|
|
|
import com.fr.tenant.context.provider.CurrentTenantKey; |
|
|
|
|
import com.fr.third.apache.logging.log4j.core.config.Configurator; |
|
|
|
|
import com.fr.third.net.bytebuddy.implementation.MethodDelegation; |
|
|
|
|
import com.fr.third.net.bytebuddy.matcher.ElementMatchers; |
|
|
|
|
import com.fr.third.org.hibernate.jdbc.AbstractWork; |
|
|
|
@ -164,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"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -235,6 +242,25 @@ public class DesignEnvComponent {
|
|
|
|
|
String realPath = Carina.properties(LoggerProperties.class).getXml(); |
|
|
|
|
URI uri = Log4jUtils.buildUserConfigURI(realPath); |
|
|
|
|
FRLogger.getLogger().config(uri); |
|
|
|
|
// 日志配置更新的监听在FRLogger里面,fbp去掉了但是设计器本地还是需要这个监听的,初始化的时候监听一下
|
|
|
|
|
listenConfig(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void listenConfig() { |
|
|
|
|
ValidateConfigManger.getInstance().registerListener(new ConfigChangeListener() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean accept(Class<? extends Configuration> configClass) { |
|
|
|
|
return configClass.equals(Log4jConfig.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void change() { |
|
|
|
|
// The root logger is the topmost logger with a name of "" (the empty string).
|
|
|
|
|
Configurator.setAllLevels("", Log4jConfig.getInstance().getRootLevel()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void stopLogger() { |
|
|
|
|