调用热更新
parent
2416934b0f
commit
ea12488b93
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"version":"5",
|
||||||
|
"tables":""
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"version":"5",
|
||||||
|
"classes":[
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
========hotfix=========
|
||||||
|
热更新class目录
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.ljsd.jieling.hotfix;
|
||||||
|
|
||||||
|
public class CDataBaseVersion {
|
||||||
|
|
||||||
|
|
||||||
|
private int version;
|
||||||
|
private String tables;
|
||||||
|
|
||||||
|
public CDataBaseVersion(int version) {
|
||||||
|
this.version = version;
|
||||||
|
this.tables = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public CDataBaseVersion() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTables() {
|
||||||
|
return tables;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,15 +1,15 @@
|
||||||
package com.ljsd.jieling.logic;
|
package com.ljsd.jieling.logic;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.ljsd.jieling.hotfix.CDataBaseVersion;
|
||||||
import com.ljsd.jieling.util.StringUtil;
|
import com.ljsd.jieling.util.StringUtil;
|
||||||
import com.ljsd.jieling.util.SysUtil;
|
import com.ljsd.jieling.util.SysUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.*;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -22,26 +22,32 @@ public class STableManager {
|
||||||
*/
|
*/
|
||||||
private static String data_parackage = null;
|
private static String data_parackage = null;
|
||||||
|
|
||||||
|
private static String jsonPath;
|
||||||
|
|
||||||
|
private static int currentDbVersion;
|
||||||
|
|
||||||
public static void initialize(String data_parackage) throws Exception {
|
public static void initialize(String data_parackage) throws Exception {
|
||||||
STableManager.data_parackage = data_parackage;
|
STableManager.data_parackage = data_parackage;
|
||||||
updateTablesWithTableNames(null);
|
updateTablesWithTableNames(false);
|
||||||
|
initJsonPath();
|
||||||
|
initDbVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据表名字更新表数据
|
* 根据表名字更新表数据
|
||||||
*
|
*
|
||||||
* @param hotfixTableStr
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static void updateTablesWithTableNames(String hotfixTableStr) throws Exception {
|
public static void updateTablesWithTableNames(boolean isHotFix) throws Exception {
|
||||||
|
|
||||||
String[] tableList = null;
|
String[] tableList = null;
|
||||||
if (hotfixTableStr == null || hotfixTableStr.isEmpty()) { // 启动而不是热更
|
if (isHotFix) {
|
||||||
// 加载全部
|
CDataBaseVersion version = getJsonFilePathInJsonConf("c_database_version.json",CDataBaseVersion.class);
|
||||||
tableList = null;
|
if (version == null || version.getTables().isEmpty() || version.getVersion() == currentDbVersion) { // 启动而不是热更
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
currentDbVersion = version.getVersion();
|
||||||
//更新指定表
|
//更新指定表
|
||||||
tableList = hotfixTableStr.split("\\|");
|
tableList = version.getTables().split("\\|");
|
||||||
}
|
}
|
||||||
Set<Class<?>> messageCommandClasses = ClassScanner.listClassesWithAnnotation(data_parackage, Table.class);
|
Set<Class<?>> messageCommandClasses = ClassScanner.listClassesWithAnnotation(data_parackage, Table.class);
|
||||||
for (Class<?> cls : messageCommandClasses) {
|
for (Class<?> cls : messageCommandClasses) {
|
||||||
|
@ -278,4 +284,39 @@ public class STableManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static <T> T getJsonFilePathInJsonConf(String fileName, Class<T> fileClass) {
|
||||||
|
File file = new File(jsonPath + fileName);
|
||||||
|
if (!file.exists()) {
|
||||||
|
LOGGER.info("the {} is not exist",fileName);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try (InputStream in = new FileInputStream(file);) {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||||
|
return mapper.readValue(in, fileClass);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void initJsonPath() {
|
||||||
|
String osName = System.getProperty("os.name");
|
||||||
|
jsonPath = "../conf/";
|
||||||
|
if (osName.matches("^(?i)Windows.*$")) {// Window 系统
|
||||||
|
jsonPath = "conf/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void initDbVersion() {
|
||||||
|
CDataBaseVersion cDataBaseVersion = getJsonFilePathInJsonConf("c_database_version.json",CDataBaseVersion.class);
|
||||||
|
if (null == cDataBaseVersion) {
|
||||||
|
currentDbVersion = 0;
|
||||||
|
} else {
|
||||||
|
currentDbVersion = cDataBaseVersion.getVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,13 @@ package com.ljsd.jieling.thread.task;
|
||||||
import com.ljsd.jieling.config.reportData.DataMessageUtils;
|
import com.ljsd.jieling.config.reportData.DataMessageUtils;
|
||||||
import com.ljsd.jieling.core.GlobalsDef;
|
import com.ljsd.jieling.core.GlobalsDef;
|
||||||
import com.ljsd.jieling.handler.map.MapLogic;
|
import com.ljsd.jieling.handler.map.MapLogic;
|
||||||
|
import com.ljsd.jieling.hotfix.HotfixUtil;
|
||||||
import com.ljsd.jieling.ktbeans.BeanBuilder.KtBeanBuilderUtils;
|
import com.ljsd.jieling.ktbeans.BeanBuilder.KtBeanBuilderUtils;
|
||||||
import com.ljsd.jieling.ktbeans.KTAppOnline;
|
import com.ljsd.jieling.ktbeans.KTAppOnline;
|
||||||
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
||||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
|
import com.ljsd.jieling.logic.STableManager;
|
||||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||||
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
||||||
import com.ljsd.jieling.logic.fight.CombatLogic;
|
import com.ljsd.jieling.logic.fight.CombatLogic;
|
||||||
|
@ -31,7 +33,9 @@ public class MinuteTask extends Thread {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
LOGGER.info("MinuteTask start...");
|
LOGGER.info("MinuteTask start...");
|
||||||
|
HotfixUtil.getInstance().doWork("../conf/hotfix.json");
|
||||||
ActivityLogic.getInstance().checkActiviyStatus();
|
ActivityLogic.getInstance().checkActiviyStatus();
|
||||||
|
STableManager.updateTablesWithTableNames(true);
|
||||||
ActivityLogic.getInstance().checkSecretBoxSeason();
|
ActivityLogic.getInstance().checkSecretBoxSeason();
|
||||||
MapLogic.getInstance().minuteCheckAndRemoveMapRank();
|
MapLogic.getInstance().minuteCheckAndRemoveMapRank();
|
||||||
GlobalDataManaager.getInstance().checkSystemFunctioIsOpen();
|
GlobalDataManaager.getInstance().checkSystemFunctioIsOpen();
|
||||||
|
|
Loading…
Reference in New Issue