mirror of
https://github.com/actiontech/dble.git
synced 2026-05-02 12:30:31 -05:00
@@ -31,11 +31,6 @@
|
||||
<name>Maven Repository Switchboard</name>
|
||||
<url>https://repo1.maven.org/maven2/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>repo2</id>
|
||||
<name>Human Readable Name for this Mirror.</name>
|
||||
<url>https://repo2.maven.org/maven2/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jenkins</id>
|
||||
<name>Jenkins Releases Repository</name>
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.actiontech.dble.cluster.ClusterController;
|
||||
import com.actiontech.dble.config.Versions;
|
||||
import com.actiontech.dble.config.loader.SystemConfigLoader;
|
||||
import com.actiontech.dble.config.model.SystemConfig;
|
||||
import com.actiontech.dble.config.util.StartProblemReporter;
|
||||
import com.actiontech.dble.manager.handler.ShowServerLog;
|
||||
import com.actiontech.dble.singleton.CustomMySQLHa;
|
||||
import com.actiontech.dble.singleton.OnlineStatus;
|
||||
@@ -24,16 +25,19 @@ public final class DbleStartup {
|
||||
//lod system properties
|
||||
SystemConfigLoader.initSystemConfig();
|
||||
if (SystemConfig.getInstance().getInstanceName() == null) {
|
||||
String msg = "You must config instanceName in bootstrap.cnf and make sure it is an unique key for cluster";
|
||||
System.out.println(msg);
|
||||
StartProblemReporter.getInstance().addError("You must config instanceName in bootstrap.cnf and make sure it is an unique key for cluster");
|
||||
}
|
||||
String home = SystemConfig.getInstance().getHomePath();
|
||||
if (home == null) {
|
||||
StartProblemReporter.getInstance().addError("homePath is not set.");
|
||||
}
|
||||
if (StartProblemReporter.getInstance().getErrorConfigs().size() > 0) {
|
||||
for (String errInfo : StartProblemReporter.getInstance().getErrorConfigs()) {
|
||||
System.out.println(errInfo);
|
||||
}
|
||||
System.exit(-1);
|
||||
}
|
||||
ClusterController.init();
|
||||
String home = SystemConfig.getInstance().getHomePath();
|
||||
if (home == null) {
|
||||
System.out.println("homePath is not set.");
|
||||
System.exit(-1);
|
||||
}
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
package com.actiontech.dble.cluster;
|
||||
|
||||
import com.actiontech.dble.config.model.ClusterConfig;
|
||||
import com.actiontech.dble.config.util.ConfigException;
|
||||
import com.actiontech.dble.config.util.ParameterMapping;
|
||||
import com.actiontech.dble.config.util.StartProblemReporter;
|
||||
import com.actiontech.dble.util.ResourceUtil;
|
||||
@@ -39,14 +38,17 @@ public final class ClusterController {
|
||||
private ClusterController() {
|
||||
}
|
||||
|
||||
public static ClusterGeneralConfig init() {
|
||||
//read from cluster.cnf to tall use zk or ucore
|
||||
try {
|
||||
ClusterGeneralConfig clusterGeneralConfig = ClusterGeneralConfig.initConfig();
|
||||
ClusterGeneralConfig.initData();
|
||||
return clusterGeneralConfig;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
public static void init() {
|
||||
if (ClusterConfig.getInstance().isClusterEnable()) {
|
||||
//read from cluster.cnf to tall use zk or ucore
|
||||
try {
|
||||
ClusterGeneralConfig.initConfig();
|
||||
ClusterGeneralConfig.initData();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
LOGGER.info("No Cluster Config .......start in single mode");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +75,7 @@ public final class ClusterController {
|
||||
}
|
||||
pros.load(configIS);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("ClusterController LoadMyidPropersites error:", e);
|
||||
LOGGER.error("ClusterController load " + CONFIG_FILE_NAME + " error:", e);
|
||||
}
|
||||
ClusterConfig clusterConfig = ClusterConfig.getInstance();
|
||||
|
||||
@@ -81,13 +83,17 @@ public final class ClusterController {
|
||||
if (pros.size() > 0) {
|
||||
String[] propItem = new String[pros.size()];
|
||||
pros.keySet().toArray(propItem);
|
||||
throw new ConfigException("These properties of system are not recognized: " + StringUtil.join(propItem, ","));
|
||||
StartProblemReporter.getInstance().addError("These properties in cluster.cnf are not recognized: " + StringUtil.join(propItem, ","));
|
||||
}
|
||||
if (clusterConfig.isClusterEnable()) {
|
||||
if (Strings.isNullOrEmpty(clusterConfig.getClusterIP()) ||
|
||||
Strings.isNullOrEmpty(clusterConfig.getClusterId()) ||
|
||||
Strings.isNullOrEmpty(clusterConfig.getRootPath())) {
|
||||
throw new RuntimeException("Cluster Config is not completely set");
|
||||
if (Strings.isNullOrEmpty(clusterConfig.getClusterIP())) {
|
||||
StartProblemReporter.getInstance().addError("clusterIP need to set in cluster.cnf when clusterEnable is true");
|
||||
}
|
||||
if (Strings.isNullOrEmpty(clusterConfig.getClusterId())) {
|
||||
StartProblemReporter.getInstance().addError("clusterId need to set in cluster.cnf when clusterEnable is true");
|
||||
}
|
||||
if (Strings.isNullOrEmpty(clusterConfig.getRootPath())) {
|
||||
StartProblemReporter.getInstance().addError("rootPath need to set in cluster.cnf when clusterEnable is true");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.actiontech.dble.config.model.ClusterConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.actiontech.dble.backend.mysql.nio.handler.ResetConnHandler.LOGGER;
|
||||
import static com.actiontech.dble.cluster.ClusterController.*;
|
||||
|
||||
/**
|
||||
@@ -30,52 +29,42 @@ public final class ClusterGeneralConfig {
|
||||
|
||||
}
|
||||
|
||||
public static ClusterGeneralConfig initConfig() {
|
||||
if (ClusterConfig.getInstance().isClusterEnable()) {
|
||||
switch (ClusterConfig.getInstance().getClusterMode()) {
|
||||
case CONFIG_MODE_USHARD:
|
||||
INSTANCE.clusterSender = new UshardSender();
|
||||
INSTANCE.clusterType = CONFIG_MODE_USHARD;
|
||||
break;
|
||||
case CONFIG_MODE_UCORE:
|
||||
INSTANCE.clusterSender = new UcoreSender();
|
||||
INSTANCE.clusterType = CONFIG_MODE_UCORE;
|
||||
break;
|
||||
case CONFIG_MODE_ZK:
|
||||
INSTANCE.clusterType = CONFIG_MODE_ZK;
|
||||
break;
|
||||
default:
|
||||
String clazz = ClusterConfig.getInstance().getClusterMode();
|
||||
try {
|
||||
INSTANCE.clusterType = CONFIG_MODE_CUSTOMIZATION;
|
||||
Class<?> clz = Class.forName(clazz);
|
||||
//all function must be extend from AbstractPartitionAlgorithm
|
||||
if (!AbstractClusterSender.class.isAssignableFrom(clz)) {
|
||||
throw new IllegalArgumentException("No ClusterSender AS " + clazz);
|
||||
}
|
||||
INSTANCE.clusterSender = (AbstractClusterSender) clz.newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Get error when try to create " + clazz);
|
||||
static void initConfig() {
|
||||
switch (ClusterConfig.getInstance().getClusterMode()) {
|
||||
case CONFIG_MODE_USHARD:
|
||||
INSTANCE.clusterSender = new UshardSender();
|
||||
INSTANCE.clusterType = CONFIG_MODE_USHARD;
|
||||
break;
|
||||
case CONFIG_MODE_UCORE:
|
||||
INSTANCE.clusterSender = new UcoreSender();
|
||||
INSTANCE.clusterType = CONFIG_MODE_UCORE;
|
||||
break;
|
||||
case CONFIG_MODE_ZK:
|
||||
INSTANCE.clusterType = CONFIG_MODE_ZK;
|
||||
break;
|
||||
default:
|
||||
String clazz = ClusterConfig.getInstance().getClusterMode();
|
||||
try {
|
||||
INSTANCE.clusterType = CONFIG_MODE_CUSTOMIZATION;
|
||||
Class<?> clz = Class.forName(clazz);
|
||||
//all function must be extend from AbstractPartitionAlgorithm
|
||||
if (!AbstractClusterSender.class.isAssignableFrom(clz)) {
|
||||
throw new IllegalArgumentException("No ClusterSender AS " + clazz);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
INSTANCE.clusterType = "No Cluster";
|
||||
LOGGER.info("No Cluster Config .......start in single mode");
|
||||
INSTANCE.clusterSender = (AbstractClusterSender) clz.newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Get error when try to create " + clazz);
|
||||
}
|
||||
}
|
||||
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
public static void initData() throws IOException {
|
||||
if (ClusterConfig.getInstance().isClusterEnable()) {
|
||||
if (CONFIG_MODE_ZK.equals(ClusterConfig.getInstance().getClusterMode())) {
|
||||
ZkConfig.initZk();
|
||||
} else {
|
||||
INSTANCE.clusterSender.initCluster();
|
||||
ClusterToXml.loadKVtoFile();
|
||||
|
||||
}
|
||||
static void initData() throws IOException {
|
||||
if (CONFIG_MODE_ZK.equals(ClusterConfig.getInstance().getClusterMode())) {
|
||||
ZkConfig.initZk();
|
||||
} else {
|
||||
INSTANCE.clusterSender.initCluster();
|
||||
ClusterToXml.loadKVtoFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.actiontech.dble.backend.mysql.store.fs.FileUtils;
|
||||
import com.actiontech.dble.config.Versions;
|
||||
import com.actiontech.dble.config.model.ClusterConfig;
|
||||
import com.actiontech.dble.config.model.SystemConfig;
|
||||
import com.actiontech.dble.config.util.ConfigException;
|
||||
import com.actiontech.dble.config.util.ParameterMapping;
|
||||
import com.actiontech.dble.config.util.StartProblemReporter;
|
||||
import com.actiontech.dble.memory.unsafe.Platform;
|
||||
@@ -107,7 +106,7 @@ public final class SystemConfigLoader {
|
||||
SystemConfig systemConfig = SystemConfig.getInstance();
|
||||
|
||||
//-D properties
|
||||
Properties system = ParameterMapping.mapping(systemConfig);
|
||||
Properties system = ParameterMapping.mapping(systemConfig, StartProblemReporter.getInstance());
|
||||
|
||||
if (systemConfig.getInstanceName() == null) {
|
||||
// if not start with wrapper , usually for debug
|
||||
@@ -139,7 +138,7 @@ public final class SystemConfigLoader {
|
||||
}
|
||||
}
|
||||
if (propItem.size() > 0) {
|
||||
throw new ConfigException("These properties of system are not recognized: " + StringUtil.join(propItem, ","));
|
||||
StartProblemReporter.getInstance().addError("These properties in bootstrap.cnf or bootstrap.dynamic.cnf are not recognized: " + StringUtil.join(propItem, ","));
|
||||
}
|
||||
}
|
||||
if (systemConfig.isUseDefaultPageNumber()) {
|
||||
@@ -162,13 +161,12 @@ public final class SystemConfigLoader {
|
||||
if (validVersion) {
|
||||
Versions.setServerVersion(systemConfig.getFakeMySQLVersion());
|
||||
} else {
|
||||
throw new ConfigException("The specified MySQL Version (" + systemConfig.getFakeMySQLVersion() + ") is not valid, " +
|
||||
StartProblemReporter.getInstance().addError("The specified MySQL Version (" + systemConfig.getFakeMySQLVersion() + ") is not valid, " +
|
||||
"the version should look like 'x.y.z'.");
|
||||
}
|
||||
}
|
||||
if (ClusterConfig.getInstance().isClusterEnable()) {
|
||||
LOGGER.info("use cluster, can not use simple python ha, so setUseOuterHa = true");
|
||||
systemConfig.setUseOuterHa(true);
|
||||
if (ClusterConfig.getInstance().isClusterEnable() && !systemConfig.isUseOuterHa()) {
|
||||
StartProblemReporter.getInstance().addError("when use cluster mode, you can not use simple python ha, so please set useOuterHa=true in bootstrap.cnf");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public final class ClusterConfig {
|
||||
if (showBinlogStatusTimeout > 0) {
|
||||
this.showBinlogStatusTimeout = showBinlogStatusTimeout;
|
||||
} else {
|
||||
problemReporter.warn("showBinlogStatusTimeout value is " + showBinlogStatusTimeout + ", it will use default value:" + this.showBinlogStatusTimeout);
|
||||
problemReporter.warn("showBinlogStatusTimeout value is " + showBinlogStatusTimeout + ", you can use default value:" + this.showBinlogStatusTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,10 +153,10 @@ public final class ClusterConfig {
|
||||
try {
|
||||
startMilliseconds = DateUtil.parseDate(sequenceStartTime).getTime();
|
||||
} catch (ParseException e) {
|
||||
problemReporter.warn("sequenceStartTime in cluster.cnf parse exception, starting from 2010-11-04 09:42:54");
|
||||
problemReporter.warn("sequenceStartTime in cluster.cnf parse exception, you can use default value 2010-11-04 09:42:54");
|
||||
}
|
||||
if (startMilliseconds > System.currentTimeMillis()) {
|
||||
problemReporter.warn("sequenceStartTime in cluster.cnf mustn't be over than dble start time, starting from 2010-11-04 09:42:54");
|
||||
problemReporter.warn("sequenceStartTime in cluster.cnf mustn't be over than dble start time, you can use default value 2010-11-04 09:42:54");
|
||||
}
|
||||
this.startTimeMilliseconds = startMilliseconds;
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@ public final class ParameterMapping {
|
||||
Class<?> cls = pd.getPropertyType();
|
||||
if (cls == null) {
|
||||
if (problemReporter != null) {
|
||||
problemReporter.warn("unknown property [ " + pd.getName() + " ], skip");
|
||||
problemReporter.warn("unknown property [ " + pd.getName() + " ]");
|
||||
} else {
|
||||
LOGGER.warn("unknown property [ " + pd.getName() + " ], skip");
|
||||
LOGGER.warn("unknown property [ " + pd.getName() + " ]");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -56,9 +56,9 @@ public final class ParameterMapping {
|
||||
value = convert(cls, valStr);
|
||||
} catch (NumberFormatException nfe) {
|
||||
if (problemReporter != null) {
|
||||
problemReporter.warn("property [ " + pd.getName() + " ] '" + valStr + "' data type should be " + cls.toString() + ", skip");
|
||||
problemReporter.warn("property [ " + pd.getName() + " ] '" + valStr + "' data type should be " + cls.toString() + "");
|
||||
} else {
|
||||
LOGGER.warn("property [ " + pd.getName() + " ] '" + valStr + "' data type should be " + cls.toString() + ", skip");
|
||||
LOGGER.warn("property [ " + pd.getName() + " ] '" + valStr + "' data type should be " + cls.toString() + "");
|
||||
}
|
||||
parameter.remove(pd.getName());
|
||||
continue;
|
||||
@@ -76,7 +76,7 @@ public final class ParameterMapping {
|
||||
}
|
||||
|
||||
|
||||
public static Properties mapping(Object object) throws IllegalAccessException,
|
||||
public static Properties mapping(Object object, ProblemReporter problemReporter) throws IllegalAccessException,
|
||||
InvocationTargetException {
|
||||
Properties systemProperties = (Properties) (System.getProperties().clone());
|
||||
for (String key : SystemProperty.getInnerProperties()) {
|
||||
@@ -92,9 +92,13 @@ public final class ParameterMapping {
|
||||
Object value = valStr;
|
||||
Class<?> cls = pd.getPropertyType();
|
||||
if (cls == null) {
|
||||
String msg = "unknown property [ " + pd.getName() + " ], skip";
|
||||
LOGGER.warn(msg);
|
||||
throw new ConfigException(msg);
|
||||
String msg = "unknown property [ " + pd.getName() + " ]";
|
||||
if (problemReporter != null) {
|
||||
problemReporter.warn(msg);
|
||||
} else {
|
||||
LOGGER.warn(msg);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!StringUtil.isEmpty(valStr)) {
|
||||
@@ -104,9 +108,14 @@ public final class ParameterMapping {
|
||||
try {
|
||||
value = convert(cls, valStr);
|
||||
} catch (NumberFormatException nfe) {
|
||||
String msg = "property [ " + pd.getName() + " ] '" + valStr + "' data type should be " + cls.toString() + ", skip";
|
||||
LOGGER.warn(msg);
|
||||
throw new ConfigException(msg);
|
||||
String msg = "property [ " + pd.getName() + " ] '" + valStr + "' data type should be " + cls.toString() ;
|
||||
if (problemReporter != null) {
|
||||
problemReporter.warn(msg);
|
||||
} else {
|
||||
LOGGER.warn(msg);
|
||||
}
|
||||
systemProperties.remove(propertyName);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (value != null) {
|
||||
|
||||
@@ -9,10 +9,19 @@ import com.actiontech.dble.config.ProblemReporter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class StartProblemReporter implements ProblemReporter {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(StartProblemReporter.class);
|
||||
private static final StartProblemReporter INSTANCE = new StartProblemReporter();
|
||||
|
||||
public List<String> getErrorConfigs() {
|
||||
return errorConfigs;
|
||||
}
|
||||
|
||||
private List<String> errorConfigs = new ArrayList<>();
|
||||
|
||||
public static StartProblemReporter getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
@@ -29,11 +38,15 @@ public final class StartProblemReporter implements ProblemReporter {
|
||||
@Override
|
||||
public void warn(String problem) {
|
||||
LOGGER.warn(problem);
|
||||
throw new ConfigException(problem);
|
||||
errorConfigs.add(problem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notice(String problem) {
|
||||
LOGGER.info(problem);
|
||||
}
|
||||
|
||||
public void addError(String problem) {
|
||||
warn(problem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
# base config
|
||||
-DhomePath=.
|
||||
-DinstanceName=1
|
||||
# valid for sequenceHandlerType=2 or 3
|
||||
-DinstanceId=1
|
||||
-DserverId=xxx1
|
||||
#-DbindIp=0.0.0.0
|
||||
@@ -69,7 +68,6 @@
|
||||
# processor check conn
|
||||
-DprocessorCheckPeriod=1000
|
||||
-DsqlExecuteTimeout=3000
|
||||
-DidleTimeout=1800000
|
||||
|
||||
|
||||
#-DbackSocket unit:bytes
|
||||
|
||||
Reference in New Issue
Block a user