use of io.mycat.config.util.ConfigException in project Mycat-Server by MyCATApache.
the class XMLRuleLoader method loadRule.
private RuleConfig loadRule(Element element) throws SQLSyntaxErrorException {
//读取columns
Element columnsEle = ConfigUtil.loadElement(element, "columns");
String column = columnsEle.getTextContent();
String[] columns = SplitUtil.split(column, ',', true);
if (columns.length > 1) {
throw new ConfigException("table rule coulmns has multi values:" + columnsEle.getTextContent());
}
//读取algorithm
Element algorithmEle = ConfigUtil.loadElement(element, "algorithm");
String algorithm = algorithmEle.getTextContent();
return new RuleConfig(column.toUpperCase(), algorithm);
}
use of io.mycat.config.util.ConfigException in project Mycat-Server by MyCATApache.
the class ConfigTest method createDataSource.
private PhysicalDatasource[] createDataSource(DataHostConfig conf, String hostName, String dbType, String dbDriver, DBHostConfig[] nodes, boolean isRead) {
PhysicalDatasource[] dataSources = new PhysicalDatasource[nodes.length];
if (dbType.equals("mysql") && dbDriver.equals("native")) {
for (int i = 0; i < nodes.length; i++) {
nodes[i].setIdleTimeout(system.getIdleTimeout());
MySQLDataSource ds = new MySQLDataSource(nodes[i], conf, isRead);
dataSources[i] = ds;
}
} else if (dbDriver.equals("jdbc")) {
for (int i = 0; i < nodes.length; i++) {
nodes[i].setIdleTimeout(system.getIdleTimeout());
JDBCDatasource ds = new JDBCDatasource(nodes[i], conf, isRead);
dataSources[i] = ds;
}
} else {
throw new ConfigException("not supported yet !" + hostName);
}
return dataSources;
}
use of io.mycat.config.util.ConfigException in project Mycat-Server by MyCATApache.
the class ConfigComparer method loadOldConfig.
private void loadOldConfig() {
try {
oldLoader = new XMLSchemaLoader();
oldDataHosts = oldLoader.getDataHosts();
oldDataNodes = oldLoader.getDataNodes();
oldSchemas = oldLoader.getSchemas();
} catch (Exception e) {
throw new ConfigException(" old config for migrate read fail!please check schema.xml or rule.xml " + e);
}
}
use of io.mycat.config.util.ConfigException in project Mycat-Server by MyCATApache.
the class ConfigComparer method loadNewConfig.
private void loadNewConfig() {
try {
newLoader = new XMLSchemaLoader(NEW_SCHEMA, NEW_RULE);
newDataHosts = newLoader.getDataHosts();
newDataNodes = newLoader.getDataNodes();
newSchemas = newLoader.getSchemas();
} catch (Exception e) {
throw new ConfigException(" new config for migrate read fail!please check newSchema.xml or newRule.xml " + e);
}
}
use of io.mycat.config.util.ConfigException in project Mycat-Server by MyCATApache.
the class ConfigComparer method loadDnIndexProps.
private Properties loadDnIndexProps() {
Properties prop = new Properties();
InputStream is = null;
try {
is = ConfigComparer.class.getResourceAsStream(DN_INDEX_FILE);
prop.load(is);
} catch (Exception e) {
throw new ConfigException("please check file \"dnindex.properties\" " + e.getMessage());
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
throw new ConfigException(e.getMessage());
}
}
return prop;
}
Aggregations