Skip to content

Commit

Permalink
fix: merge commit
Browse files Browse the repository at this point in the history
feat: JSON mode configuration takes effect
#2386

feat: table dble_config to view the json configuration in memory

inner-453

fix: json to map add unit test/update copyright

fix: 1 for Dereferenced variable may be null

fix: Dereferenced variable may be null
  • Loading branch information
LUAgam committed Jan 7, 2021
1 parent a130735 commit 7a2b6cd
Show file tree
Hide file tree
Showing 68 changed files with 2,691 additions and 865 deletions.
22 changes: 19 additions & 3 deletions src/main/java/com/actiontech/dble/DbleServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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.DbleTempConfig;
import com.actiontech.dble.config.ServerConfig;
import com.actiontech.dble.config.model.ClusterConfig;
import com.actiontech.dble.config.model.SystemConfig;
Expand Down Expand Up @@ -113,7 +114,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 +259,25 @@ 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() {
if (ClusterConfig.getInstance().isClusterEnable()) {
this.config = new ServerConfig(DbleTempConfig.getInstance().getUserConfig(), DbleTempConfig.getInstance().getDbConfig(),
DbleTempConfig.getInstance().getShardingConfig(), DbleTempConfig.getInstance().getSequenceConfig());
DbleTempConfig.getInstance().clean();
} else {
this.config = new ServerConfig();
}
}

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 +402,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
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public boolean checkInstanceExist(String instanceName) {
return true;
}

boolean equalsBaseInfo(PhysicalDbGroup pool) {
public boolean equalsBaseInfo(PhysicalDbGroup pool) {
return pool.getDbGroupConfig().getName().equals(this.dbGroupConfig.getName()) &&
pool.getDbGroupConfig().getHeartbeatSQL().equals(this.dbGroupConfig.getHeartbeatSQL()) &&
pool.getDbGroupConfig().getHeartbeatTimeout() == this.dbGroupConfig.getHeartbeatTimeout() &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.actiontech.dble.net.connection.BackendConnection;
import com.actiontech.dble.route.RouteResultsetNode;
import com.actiontech.dble.singleton.TraceManager;
import com.actiontech.dble.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -122,4 +123,12 @@ private Boolean canRunOnMaster(RouteResultsetNode rrs, boolean autoCommit) {
}
return master;
}


public boolean equalsBaseInfo(ShardingNode shardingNode) {
return StringUtil.equalsWithEmpty(this.name, shardingNode.getName()) &&
StringUtil.equalsWithEmpty(this.dbGroupName, shardingNode.getDbGroupName()) &&
StringUtil.equalsWithEmpty(this.database, shardingNode.getDatabase()) &&
this.dbGroup.equalsBaseInfo(shardingNode.getDbGroup());
}
}
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 7a2b6cd

Please sign in to comment.