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;
}
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("");
}
}
Aggregations