Search in sources :

Example 11 with ConfigException

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);
}
Also used : Element(org.w3c.dom.Element) ConfigException(io.mycat.config.util.ConfigException) TableRuleConfig(io.mycat.config.model.rule.TableRuleConfig) RuleConfig(io.mycat.config.model.rule.RuleConfig)

Example 12 with ConfigException

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;
}
Also used : PhysicalDatasource(io.mycat.backend.datasource.PhysicalDatasource) MySQLDataSource(io.mycat.backend.mysql.nio.MySQLDataSource) JDBCDatasource(io.mycat.backend.jdbc.JDBCDatasource) ConfigException(io.mycat.config.util.ConfigException)

Example 13 with ConfigException

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);
    }
}
Also used : XMLSchemaLoader(io.mycat.config.loader.xml.XMLSchemaLoader) ConfigException(io.mycat.config.util.ConfigException) IOException(java.io.IOException) ConfigException(io.mycat.config.util.ConfigException)

Example 14 with ConfigException

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);
    }
}
Also used : XMLSchemaLoader(io.mycat.config.loader.xml.XMLSchemaLoader) ConfigException(io.mycat.config.util.ConfigException) IOException(java.io.IOException) ConfigException(io.mycat.config.util.ConfigException)

Example 15 with ConfigException

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;
}
Also used : InputStream(java.io.InputStream) ConfigException(io.mycat.config.util.ConfigException) IOException(java.io.IOException) Properties(java.util.Properties) IOException(java.io.IOException) ConfigException(io.mycat.config.util.ConfigException)

Aggregations

ConfigException (io.mycat.config.util.ConfigException)30 Element (org.w3c.dom.Element)16 NodeList (org.w3c.dom.NodeList)12 IOException (java.io.IOException)9 Node (org.w3c.dom.Node)8 HashMap (java.util.HashMap)5 TableConfig (io.mycat.config.model.TableConfig)4 RuleConfig (io.mycat.config.model.rule.RuleConfig)4 AbstractPartitionAlgorithm (io.mycat.route.function.AbstractPartitionAlgorithm)4 InputStream (java.io.InputStream)4 PhysicalDatasource (io.mycat.backend.datasource.PhysicalDatasource)3 DataNodeConfig (io.mycat.config.model.DataNodeConfig)3 TableRuleConfig (io.mycat.config.model.rule.TableRuleConfig)3 PhysicalDBNode (io.mycat.backend.datasource.PhysicalDBNode)2 PhysicalDBPool (io.mycat.backend.datasource.PhysicalDBPool)2 JDBCDatasource (io.mycat.backend.jdbc.JDBCDatasource)2 MySQLDataSource (io.mycat.backend.mysql.nio.MySQLDataSource)2 XMLSchemaLoader (io.mycat.config.loader.xml.XMLSchemaLoader)2 DBHostConfig (io.mycat.config.model.DBHostConfig)2 DataHostConfig (io.mycat.config.model.DataHostConfig)2