Search in sources :

Example 31 with MycatConfig

use of io.mycat.config.MycatConfig in project Mycat-Server by MyCATApache.

the class ShowTables method getTableSet.

private static Set<String> getTableSet(ServerConnection c, Map<String, String> parm) {
    TreeSet<String> tableSet = new TreeSet<String>();
    MycatConfig conf = MycatServer.getInstance().getConfig();
    Map<String, UserConfig> users = conf.getUsers();
    UserConfig user = users == null ? null : users.get(c.getUser());
    if (user != null) {
        Map<String, SchemaConfig> schemas = conf.getSchemas();
        for (String name : schemas.keySet()) {
            if (null != parm.get(SCHEMA_KEY) && parm.get(SCHEMA_KEY).toUpperCase().equals(name.toUpperCase())) {
                if (null == parm.get("LIKE_KEY")) {
                    tableSet.addAll(schemas.get(name).getTables().keySet());
                } else {
                    String p = "^" + parm.get("LIKE_KEY").replaceAll("%", ".*");
                    Pattern pattern = Pattern.compile(p, Pattern.CASE_INSENSITIVE);
                    Matcher ma;
                    for (String tname : schemas.get(name).getTables().keySet()) {
                        ma = pattern.matcher(tname);
                        if (ma.matches()) {
                            tableSet.add(tname);
                        }
                    }
                }
            }
        }
        ;
    }
    return tableSet;
}
Also used : Pattern(java.util.regex.Pattern) SchemaConfig(io.mycat.config.model.SchemaConfig) Matcher(java.util.regex.Matcher) TreeSet(java.util.TreeSet) MycatConfig(io.mycat.config.MycatConfig) UserConfig(io.mycat.config.model.UserConfig)

Example 32 with MycatConfig

use of io.mycat.config.MycatConfig in project Mycat-Server by MyCATApache.

the class DistributedSequenceHandlerTest method initialize.

@Before
public void initialize() throws Exception {
    distributedSequenceHandler = new DistributedSequenceHandler[16];
    MycatConfig mycatConfig = new MycatConfig();
    testingServer = new TestingServer();
    testingServer.start();
    for (int i = 0; i < 16; i++) {
        distributedSequenceHandler[i] = new DistributedSequenceHandler(mycatConfig.getSystem());
        distributedSequenceHandler[i].initializeZK(testingServer.getConnectString());
        distributedSequenceHandler[i].nextId("");
    }
}
Also used : TestingServer(org.apache.curator.test.TestingServer) DistributedSequenceHandler(io.mycat.route.sequence.handler.DistributedSequenceHandler) MycatConfig(io.mycat.config.MycatConfig) Before(org.junit.Before)

Aggregations

MycatConfig (io.mycat.config.MycatConfig)32 PhysicalDBNode (io.mycat.backend.datasource.PhysicalDBNode)15 PhysicalDBPool (io.mycat.backend.datasource.PhysicalDBPool)10 RowDataPacket (io.mycat.net.mysql.RowDataPacket)10 PhysicalDatasource (io.mycat.backend.datasource.PhysicalDatasource)9 SchemaConfig (io.mycat.config.model.SchemaConfig)9 LinkedList (java.util.LinkedList)8 RouteResultsetNode (io.mycat.route.RouteResultsetNode)7 BackendConnection (io.mycat.backend.BackendConnection)6 DBHeartbeat (io.mycat.backend.heartbeat.DBHeartbeat)5 UserConfig (io.mycat.config.model.UserConfig)5 MycatCluster (io.mycat.config.MycatCluster)4 IOException (java.io.IOException)4 TableConfig (io.mycat.config.model.TableConfig)3 EOFPacket (io.mycat.net.mysql.EOFPacket)3 FieldPacket (io.mycat.net.mysql.FieldPacket)3 DataSourceSyncRecorder (io.mycat.statistic.DataSourceSyncRecorder)3 ByteBuffer (java.nio.ByteBuffer)3 ArrayList (java.util.ArrayList)3 TreeSet (java.util.TreeSet)3