use of io.mycat.config.model.SystemConfig in project Mycat_plus by coderczp.
the class PartitionByRangeModTest method testRange.
@Test
public void testRange() throws SQLNonTransientException {
String sql = "select * from offer where id between 2000000 and 4000001 order by id desc limit 100";
SchemaConfig schema = schemaMap.get("TESTDB");
RouteResultset rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null, null, cachePool);
Assert.assertEquals(10, rrs.getNodes().length);
sql = "select * from offer where id between 9 and 2000 order by id desc limit 100";
rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null, null, cachePool);
Assert.assertEquals(5, rrs.getNodes().length);
sql = "select * from offer where id between 4000001 and 6005001 order by id desc limit 100";
rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null, null, cachePool);
Assert.assertEquals(8, rrs.getNodes().length);
}
use of io.mycat.config.model.SystemConfig in project Mycat-Server by MyCATApache.
the class RouteStrategyFactory method init.
public static void init() {
SystemConfig config = MycatServer.getInstance().getConfig().getSystem();
String defaultSqlParser = config.getDefaultSqlParser();
defaultSqlParser = defaultSqlParser == null ? "" : defaultSqlParser;
// 修改为ConcurrentHashMap,避免并发问题
strategyMap.putIfAbsent("druidparser", new DruidMycatRouteStrategy());
defaultStrategy = strategyMap.get(defaultSqlParser);
if (defaultStrategy == null) {
defaultStrategy = strategyMap.get("druidparser");
defaultSqlParser = "druidparser";
}
config.setDefaultSqlParser(defaultSqlParser);
isInit = true;
}
use of io.mycat.config.model.SystemConfig in project Mycat-Server by MyCATApache.
the class ShowSysParam method execute.
public static void execute(ManagerConnection c) {
ByteBuffer buffer = c.allocate();
// write header
buffer = header.write(buffer, c, true);
// write fields
for (FieldPacket field : fields) {
buffer = field.write(buffer, c, true);
}
// write eof
buffer = eof.write(buffer, c, true);
// write rows
byte packetId = eof.packetId;
SystemConfig sysConfig = MycatServer.getInstance().getConfig().getSystem();
List<String> paramValues = new ArrayList<String>();
paramValues.add(sysConfig.getProcessors() + "");
paramValues.add(sysConfig.getBufferPoolChunkSize() + "B");
paramValues.add(sysConfig.getBufferPoolPageSize() + "B");
paramValues.add(sysConfig.getProcessorBufferLocalPercent() + "");
paramValues.add(sysConfig.getProcessorExecutor() + "");
paramValues.add(sysConfig.getSequnceHandlerType() == 1 ? "数据库方式" : "本地文件方式");
paramValues.add(sysConfig.getPacketHeaderSize() + "B");
paramValues.add(sysConfig.getMaxPacketSize() / 1024 / 1024 + "M");
paramValues.add(sysConfig.getIdleTimeout() / 1000 / 60 + "分钟");
paramValues.add(sysConfig.getCharset() + "");
paramValues.add(ISOLATIONS[sysConfig.getTxIsolation()]);
paramValues.add(sysConfig.getSqlExecuteTimeout() + "秒");
paramValues.add(sysConfig.getProcessorCheckPeriod() / 1000 + "秒");
paramValues.add(sysConfig.getDataNodeIdleCheckPeriod() / 1000 + "秒");
paramValues.add(sysConfig.getDataNodeHeartbeatPeriod() / 1000 + "秒");
paramValues.add(sysConfig.getBindIp() + "");
paramValues.add(sysConfig.getServerPort() + "");
paramValues.add(sysConfig.getManagerPort() + "");
for (int i = 0; i < PARAMNAMES.length; i++) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(StringUtil.encode(PARAMNAMES[i], c.getCharset()));
row.add(StringUtil.encode(paramValues.get(i), c.getCharset()));
row.add(StringUtil.encode(PARAM_DESCRIPTION[i], c.getCharset()));
row.packetId = ++packetId;
buffer = row.write(buffer, c, true);
}
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c, true);
// write buffer
c.write(buffer);
}
use of io.mycat.config.model.SystemConfig in project Mycat-Server by MyCATApache.
the class DruidMysqlCreateTableTest method testInsert.
// @Test
public void testInsert() throws SQLNonTransientException {
SchemaConfig schema = schemaMap.get("mysqldb");
RouteResultset rrs = routeStrategy.route(new SystemConfig(), schema, -1, "insert into autoslot (id,sid) values(1,2) ", null, null, cachePool);
Assert.assertEquals(1, rrs.getNodes().length);
Assert.assertTrue(isInsertHasSlot(rrs.getStatement()));
}
use of io.mycat.config.model.SystemConfig in project Mycat-Server by MyCATApache.
the class DruidMysqlRouteStrategyTest method testIgnoreSchema.
public void testIgnoreSchema() throws Exception {
SchemaConfig schema = schemaMap.get("ignoreSchemaTest");
String sql = "select * from offer where offer_id=1";
RouteResultset rrs = routeStrategy.route(new SystemConfig(), schema, 1, sql, null, null, cachePool);
Assert.assertEquals(false, rrs.isCacheAble());
Assert.assertEquals("cndb_dn", rrs.getNodes()[0].getName());
Assert.assertEquals(sql, rrs.getNodes()[0].getStatement());
sql = "select * from ignoreSchemaTest.offer1 where ignoreSchemaTest.offer1.offer_id=1";
rrs = routeStrategy.route(new SystemConfig(), schema, 1, sql, null, null, cachePool);
Assert.assertEquals(false, rrs.isCacheAble());
Assert.assertEquals("select * from offer1 where offer1.offer_id=1", rrs.getNodes()[0].getStatement());
sql = "select * from ignoreSchemaTest2.offer where ignoreSchemaTest2.offer.offer_id=1";
rrs = routeStrategy.route(new SystemConfig(), schema, 1, sql, null, null, cachePool);
Assert.assertEquals(false, rrs.isCacheAble());
Assert.assertEquals(sql, rrs.getNodes()[0].getStatement(), sql);
sql = "select * from ignoreSchemaTest2.offer a,offer b where ignoreSchemaTest2.offer.offer_id=1";
rrs = routeStrategy.route(new SystemConfig(), schema, 1, sql, null, null, cachePool);
Assert.assertEquals(false, rrs.isCacheAble());
Assert.assertEquals("select * from ignoreSchemaTest2.offer a,offer b where ignoreSchemaTest2.offer.offer_id=1", rrs.getNodes()[0].getStatement());
}
Aggregations