Skip to content

Commit 73833b9

Browse files
@initial 7.0.0-preview.614 Fix many bugs for canary
1 parent 82fc8db commit 73833b9

9 files changed

Lines changed: 81 additions & 37 deletions

File tree

src/main/java/com/talexframe/frame/core/modules/network/connection/RequestAnalyser.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ private void process() {
9797

9898
if( !could.get() ) return;
9999

100-
log.debug("[解析层] # -- CLASS -- 开始执行接收器: " + addon.getClass().getName());
100+
// log.debug("[解析层] # -- CLASS -- 开始执行接收器: " + addon.getClass().getName());
101101

102102
could.set(addon.onPreCheckAppReceiver(reqReceiver, wr));
103103

104-
log.debug("[解析层] # -- CLASS -- 接收器执行结果: " + could.get());
104+
// log.debug("[解析层] # -- CLASS -- 接收器执行结果: " + could.get());
105105

106106
});
107107

@@ -133,7 +133,8 @@ private void process() {
133133

134134
log.debug("[解析层] # -- onRequest -- 执行结果: " + JSONUtil.toJsonStr(obj));
135135

136-
receiverAddons.forEach((addon) -> addon.onPostInvokeMethod(subReqReceiver, wr, obj));
136+
final Object finalObj = obj;
137+
receiverAddons.forEach((addon) -> addon.onPostInvokeMethod(subReqReceiver, wr, finalObj));
137138

138139
log.debug("[解析层] # -- METHOD -- 执行结果完毕!");
139140

@@ -149,7 +150,7 @@ private void process() {
149150

150151
clsReceiverAddons.forEach((addon) -> addon.onPostCheckAppReceiver(reqReceiver, wr));
151152

152-
log.debug("[解析层] # -- CLASS -- 接收器执行结果完毕!");
153+
// log.debug("[解析层] # -- CLASS -- 接收器执行结果完毕!");
153154

154155
log.debug("-------------------------------------------");
155156

src/main/java/com/talexframe/frame/core/modules/network/connection/RequestConnector.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.talexframe.frame.core.modules.application.TAppManager;
66
import com.talexframe.frame.core.modules.event.events.request.RequestCannotGetTokenEvent;
77
import com.talexframe.frame.core.modules.event.events.request.RequestCorsTryEvent;
8+
import com.talexframe.frame.core.pojo.enums.FrameStatus;
89
import com.talexframe.frame.core.pojo.wrapper.ResultData;
910
import com.talexframe.frame.core.pojo.wrapper.WrappedResponse;
1011
import com.talexframe.frame.core.talex.TFrame;
@@ -39,6 +40,8 @@ public RequestConnector(WrappedResponse wr) {
3940

4041
this.processLimiter();
4142

43+
this.processFrameStatus();
44+
4245
}
4346

4447
/**
@@ -74,7 +77,21 @@ private void processLimiter() {
7477

7578
globalLimiter.acquire();
7679

77-
this.headerProcessor();
80+
}
81+
82+
private void processFrameStatus() {
83+
84+
if( tframe.getFrameStatus() != FrameStatus.RUNNING ) {
85+
86+
wr.returnDataByFailed(ResultData.ResultEnum.SERVER_ERROR, "服务器维护");
87+
88+
log.warn("[连接层] 请求已被拦截 - 服务器状态异常 | {}", tframe.getFrameStatus().getMsg());
89+
90+
} else {
91+
92+
this.headerProcessor();
93+
94+
}
7895

7996
}
8097

src/main/java/com/talexframe/frame/core/modules/network/connection/app/addon/cache/redis/ReceiverCacheRedisAddon.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,7 @@ private String getRedisCacheKey( TRedisCache tRedisCache, String url, List<Objec
194194

195195
key = url;
196196

197-
}
198-
199-
if ( key.startsWith("#url") ) {
197+
} else if ( key.startsWith("#url") ) {
200198

201199
int index = Integer.parseInt(key.substring(5, 6));
202200

src/main/java/com/talexframe/frame/core/modules/network/connection/app/subapp/MethodAppReceiver.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.talexframe.frame.core.modules.network.connection.IRequestReceiver;
66
import com.talexframe.frame.core.modules.network.connection.TRequest;
77
import com.talexframe.frame.core.modules.network.connection.app.ClassAppReceiver;
8+
import com.talexframe.frame.core.pojo.wrapper.ResultData;
89
import com.talexframe.frame.core.pojo.wrapper.WrappedResponse;
910
import com.talexframe.frame.core.talex.FrameCreator;
1011
import lombok.Getter;
@@ -79,6 +80,12 @@ public Object onRequest(ClassAppReceiver clzAppReceiver, MethodAppReceiver metho
7980
log.info("[应用层] 应用执行完毕!");
8081
log.info("[应用层] ------------------------");
8182

83+
if ( !(obj instanceof ResultData ) ) {
84+
85+
obj = ResultData.SUCCESS(obj);
86+
87+
}
88+
8289
return obj;
8390

8491
} catch (Exception e) {

src/main/java/com/talexframe/frame/core/modules/repository/TRepoCompAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class TRepoCompAdapter extends PluginCompAdapter<TRepo> {
2121
@Override
2222
public boolean injectWithInstance(PluginScanner scanner, WebPlugin webPlugin, TRepo instance) {
2323

24-
log.info("[TRepoCompAdapter] injectWithInstance: {}", instance.getClass().getName());
24+
log.debug("[TRepoCompAdapter] injectWithInstance: {}", instance.getClass().getName());
2525

2626
return repoManager.registerRepo( webPlugin, instance );
2727

src/main/java/com/talexframe/frame/core/modules/repository/TRepoManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,15 @@ public boolean registerRepo(WebPlugin plugin, TRepo Repo) {
133133

134134
if ( Repo instanceof TRepoPlus ) {
135135

136+
log.debug("Init table Repo - " + Repo.getClass().getName());
137+
136138
TRepoPlus<?> plusRepo = ( (TRepoPlus<?>) Repo );
137139
plusRepo.initTable();
138140

139141
scanner.pushService(() -> {
140142

143+
log.debug("Init Repo - " + Repo.getClass().getName());
144+
141145
plusRepo.onInstall();
142146

143147
scanner.pushService(plusRepo::onAllRepoDone);

src/main/java/com/talexframe/frame/core/modules/repository/TRepoPlus.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import cn.hutool.core.util.StrUtil;
55
import cn.hutool.db.Entity;
66
import cn.hutool.json.JSONObject;
7-
import cn.hutool.json.JSONUtil;
87
import com.talexframe.frame.core.modules.plugins.core.WebPlugin;
98
import com.talexframe.frame.core.pojo.dao.vo.auto.AutoSaveData;
109
import com.talexframe.frame.core.pojo.dao.vo.auto.TAutoColumn;
@@ -95,10 +94,15 @@ public void onSingleDataRemoved(WrappedData<?> data) {
9594

9695
}
9796

97+
/**
98+
* @param data 数据实例 默认 不cache 所以每次数据一更新就自动塞到数据库
99+
*/
98100
public void addData(T data) {
99101

100102
if( !doCached() ) {
101103

104+
saveDataToMysql(data);
105+
102106
return;
103107

104108
}
@@ -110,24 +114,14 @@ public void addData(T data) {
110114
}
111115

112116
/**
113-
* @param data 数据实例 默认 不cache 所以每次数据一更新就自动塞到数据库
114-
*
115117
* @return 返回真不放入数据map
116118
*/
117119
@SneakyThrows
118120
public boolean onSingleDataLoaded(WrappedData<T> data) {
119121

120-
if ( !doCached() ) {
121-
122-
saveDataToMysql( data.getValue() );
123-
124-
} else {
125-
126-
saveAllDataToMysql();
122+
// 每次放入map也刷新数据库中数据
127123

128-
dataMap.clear();
129-
130-
}
124+
saveDataToMysql( data.getValue() );
131125

132126
return false;
133127
}
@@ -142,31 +136,39 @@ public void onAllRepoDone() {}
142136
public void onInstall() {
143137

144138
if ( !doCached() ) {
139+
145140
return;
141+
146142
}
147143

148144
this.dataMap = new ConcurrentHashMap<>();
149145

150-
List<Entity> entityList = this.forAllData();
146+
List<Entity> entities = this.forDb().findAll(forEntity());
147+
148+
for ( Entity entity : entities ) {
151149

152-
for ( Entity entity : entityList ) {
150+
// log.debug("[AutoSaveData] Load all data for first column {}", rs);
153151

154-
@SuppressWarnings( "unchecked" ) WrappedData<T> data = (WrappedData<T>) AutoSaveData.deserialize(templateData, JSONUtil.parseObj(Base64.decodeStr(entity.getStr("as_info"))));
152+
@SuppressWarnings( "unchecked" ) WrappedData<T> data = (WrappedData<T>) AutoSaveData.deserializeByBase64Str(templateData, entity.getStr("as_info"));
155153

156154
if ( data.getValue() == null || data.getValue().getMainKey() == null ) {
155+
157156
log.error("[AutoSaveData] FatalError!! # " + templateData.getName());
157+
158158
}
159159

160160
if ( onSingleDataLoaded(data) ) {
161+
161162
continue;
163+
162164
}
163165

164166
dataMap.put(( data.getValue() ).getMainKey(), data.getValue());
165167

166-
onDataLoaded();
167-
168168
}
169169

170+
onDataLoaded();
171+
170172
}
171173

172174
public void onUninstall() {

src/main/java/com/talexframe/frame/core/pojo/dao/factory/mysql/Mysql.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ public boolean connect() {
182182
dataSource.setUsername(config.getUsername());
183183
dataSource.setPassword(config.getPassword());
184184

185-
dataSource.setTimeBetweenEvictionRunsMillis(15000);
186-
dataSource.setValidationQuery("SELECT 1");
185+
// dataSource.setTimeBetweenEvictionRunsMillis(15000);
186+
// dataSource.setValidationQuery("SELECT 1");
187187

188-
dataSource.setTestWhileIdle(true);
188+
// dataSource.setTestWhileIdle(true);
189189

190190
session = Session.create(dataSource);
191191

@@ -197,7 +197,13 @@ public boolean connect() {
197197

198198
status = DataProcessorStatus.CONNECTED;
199199

200-
task = CronUtil.schedule("0/10 * * * * ? ", (Runnable) () -> {
200+
task = CronUtil.schedule("0/10 * * * * ?", (Runnable) () -> {
201+
202+
if( status != DataProcessorStatus.CONNECTED ) {
203+
204+
return;
205+
206+
}
201207

202208
if( !checker() ) return;
203209

@@ -274,6 +280,8 @@ private boolean checker() {
274280
@Override
275281
public boolean disconnect() {
276282

283+
log.debug("[数据库] [断开] 断开数据库连接 ...");
284+
277285
status = DataProcessorStatus.DISCONNECTED;
278286

279287
if ( this.session != null ) {

src/main/java/com/talexframe/frame/core/talex/TFrame.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.talexframe.frame.core.talex;
22

3+
import cn.hutool.core.thread.ThreadUtil;
34
import com.google.common.collect.Multimap;
45
import com.talexframe.frame.TalexFrameApplication;
56
import com.talexframe.frame.core.function.command.CommandManager;
@@ -104,13 +105,14 @@ public void started() {
104105
this.repoManager = TRepoManager.init();
105106
this.appManager = TAppManager.init();
106107

108+
log.info("Loading dao-manager ...");
109+
this.daoManager = new DAOManager();
110+
111+
107112
getEventBus().registerListener(new FrameSelfListener());
108113

109114
callEvent(new FrameStartedEvent(System.nanoTime() - TalexFrameApplication.startedTimeStamp));
110115

111-
log.info("Loading dao-manager ...");
112-
this.daoManager = new DAOManager();
113-
114116
if ( frameStatus == FrameStatus.RUNNING ) {
115117

116118
log.info("Loading command-manager ...");
@@ -140,11 +142,16 @@ public void started() {
140142

141143
new YamlConfigAdapter();
142144
new JSONConfigAdapter();
143-
this.pluginManager = new PluginManager(new File(mainFile.getAbsolutePath() + "/plugins"));
144-
145-
this.pluginManager.loadAllPluginsInFolder();
146145
// ThreadUtil.execAsync(() -> this.pluginManager.loadAllPluginsInFolder());
147146

147+
ThreadUtil.execute(() -> {
148+
149+
this.pluginManager = new PluginManager(new File(mainFile.getAbsolutePath() + "/plugins"));
150+
151+
this.pluginManager.loadAllPluginsInFolder();
152+
153+
});
154+
148155
log.info("框架启动成功! (" + (System.nanoTime() - TalexFrameApplication.startedTimeStamp) + " ns)");
149156
log.debug("** DEBUG 模式已启动!");
150157

0 commit comments

Comments
 (0)