Skip to content

Commit

Permalink
feat: JSON mode configuration takes effect
Browse files Browse the repository at this point in the history
  • Loading branch information
LUAgam committed Dec 31, 2020
1 parent e6ffb05 commit a935c4f
Show file tree
Hide file tree
Showing 50 changed files with 2,237 additions and 782 deletions.
40 changes: 37 additions & 3 deletions src/main/java/com/actiontech/dble/DbleServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
import com.actiontech.dble.backend.mysql.xa.recovery.impl.FileSystemRepository;
import com.actiontech.dble.backend.mysql.xa.recovery.impl.KVStoreRepository;
import com.actiontech.dble.buffer.DirectByteBufferPool;
import com.actiontech.dble.config.ConfigFileName;
import com.actiontech.dble.config.DbleTempConfig;
import com.actiontech.dble.config.ServerConfig;
import com.actiontech.dble.config.converter.DBConverter;
import com.actiontech.dble.config.converter.SequenceConverter;
import com.actiontech.dble.config.converter.ShardingConverter;
import com.actiontech.dble.config.converter.UserConverter;
import com.actiontech.dble.config.model.ClusterConfig;
import com.actiontech.dble.config.model.SystemConfig;
import com.actiontech.dble.config.model.sharding.SchemaConfig;
Expand Down Expand Up @@ -113,7 +119,7 @@ private DbleServer() {

public void startup() throws Exception {
LOGGER.info("===========================================DBLE SERVER STARTING===================================");
this.config = new ServerConfig();
initServerConfig();
this.startupTime = TimeUtil.currentTimeMillis();
LOGGER.info("=========================================Config file read finish==================================");

Expand Down Expand Up @@ -258,10 +264,38 @@ public void startup() throws Exception {
LOGGER.info("====================================CronScheduler started=========================================");

CustomMySQLHa.getInstance().start();
LOGGER.info("====================================sync config to xml=========================================");

if (ClusterConfig.getInstance().isClusterEnable()) {
this.config.syncJsonToLocal(true);
}
LOGGER.info("======================================ALL START INIT FINISH=======================================");
startup = true;
}

private void initServerConfig() throws Exception {
if (ClusterConfig.getInstance().isClusterEnable()) {
this.config = new ServerConfig(DbleTempConfig.getInstance().getUserConfig(), DbleTempConfig.getInstance().getDbConfig(),
DbleTempConfig.getInstance().getShardingConfig(), DbleTempConfig.getInstance().getSequenceConfig());
} else {
//sync json
String userConfig = new UserConverter().userXmlToJson();
String dbConfig = DBConverter.dbXmlToJson();
String sequenceConfig = null;
if (ClusterConfig.getInstance().getSequenceHandlerType() == ClusterConfig.SEQUENCE_HANDLER_ZK_GLOBAL_INCREMENT) {
sequenceConfig = SequenceConverter.sequencePropsToJson(ConfigFileName.SEQUENCE_FILE_NAME);
} else if (ClusterConfig.getInstance().getSequenceHandlerType() == ClusterConfig.SEQUENCE_HANDLER_MYSQL) {
sequenceConfig = SequenceConverter.sequencePropsToJson(ConfigFileName.SEQUENCE_DB_FILE_NAME);
}
String shardingConfig = new ShardingConverter().shardingXmlToJson();
DbleTempConfig.getInstance().setUserConfig(userConfig);
DbleTempConfig.getInstance().setDbConfig(dbConfig);
DbleTempConfig.getInstance().setShardingConfig(shardingConfig);
DbleTempConfig.getInstance().setSequenceConfig(sequenceConfig);
this.config = new ServerConfig(userConfig, dbConfig, shardingConfig, sequenceConfig);
}
}

private void initAioProcessor(int processorCount) throws IOException {
for (int i = 0; i < processorCount; i++) {
asyncChannelGroups[i] = AsynchronousChannelGroup.withFixedThreadPool(processorCount,
Expand Down Expand Up @@ -386,10 +420,10 @@ public void run() {

private void reviseSchemas() {
if (systemVariables.isLowerCaseTableNames()) {
config.reviseLowerCase();
config.reviseLowerCase(DbleTempConfig.getInstance().getSequenceConfig());
ConfigUtil.setSchemasForPool(config.getDbGroups(), config.getShardingNodes());
} else {
config.loadSequence();
config.loadSequence(DbleTempConfig.getInstance().getSequenceConfig());
config.selfChecking0();
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/actiontech/dble/cluster/ClusterHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public static void createSelfTempNode(String path, String value) throws Exceptio
}

public static KvBean getKV(String path) throws Exception {
if (ClusterGeneralConfig.getInstance().getClusterSender() == null) {
return null;
}
return ClusterGeneralConfig.getInstance().getClusterSender().getKV(path);
}

Expand Down Expand Up @@ -52,7 +55,10 @@ public static Map<String, String> getOnlineMap() {
}

public static void writeConfToCluster() throws Exception {
ClusterGeneralConfig.getInstance().getClusterSender().writeConfToCluster();
ClusterLogic.syncSequenceJsonToCluster();
ClusterLogic.syncDbJsonToCluster();
ClusterLogic.syncShardingJsonToCluster();
ClusterLogic.syncUseJsonToCluster();
}

public static String getPathValue(String path) throws Exception {
Expand Down
Loading

0 comments on commit a935c4f

Please sign in to comment.