diff --git a/.gitignore b/.gitignore index 3769c58e2..1e6dbfc84 100644 --- a/.gitignore +++ b/.gitignore @@ -120,3 +120,5 @@ src/main/resources/zkconf/schema.xml src/main/resources/zkconf/rule.xml conf/dnindex.properties version.txt +copyResources.bat +dependency-reduced-pom.xml \ No newline at end of file diff --git a/Release_Note.md b/Release_Note.md index d55896ae2..3643ea9f0 100644 --- a/Release_Note.md +++ b/Release_Note.md @@ -3,9 +3,9 @@ VERSION 2.17.06.0 CONTENT: ## 1.feature 1.移除writeType参数,等效于原来writeType =0 -2.conf/index_to_charset.properties的内容固化到代码 -3.show @@binlog.status ,显示节点间事务一致的binlog线 -4.增强explain执行计划 +2.conf/index_to_charset.properties的内容固化到代码 #77 +3.show @@binlog.status ,显示节点间事务一致的binlog线 #118 +4.增强explain执行计划#143 5.show tables时,不显示未创建的表,show full tables 拆分表的type会显示为SHARDING TABLE,global表会显示为GLOBAL TABLE 6.ddl 执行前做一次心跳检查 7.多表查询中using()结果未合并重复列 #103 @@ -15,20 +15,81 @@ CONTENT: 2.自增序列部分算法缺陷及改进 3.单节点查询不加入主键缓存bug #160 4.租户权限不不隔离的问题 #164 -5.show full tables from db,当db为不存在的db时,多发包导致乱序 #159 +5.show full tables from db,当db为不存在的db时,多发包导致乱序 #159 6.数字范围算法(AutoPartitionByLong),有默认节点时,between...and...可能路由错误 #145 ## 3.不兼容项 -配置 : -sequence_conf.properties 库表名要用"\`"包起来,用"."连接 -sequence_db_conf.properties 库表名要用"\`"包起来,用"."连接 -cacheservice.properties 库表名要用"\`"包起来,用"_"连接。 -自增序列部分算法 -A.本地时间戳方式 +#### 3.1 全局序列配置 : +##### 3.1.1 sequence_conf.properties +库表名要用"\`"包起来,用"."连接 +##### 3.1.2 sequence_db_conf.properties +库表名要用"\`"包起来,用"."连接 +#### 3.2 缓存配置 +3.2.1 cacheservice.properties 库表名要用"\`"包起来,用"_"连接。 +#### 3.3 自增序列部分算法 +##### 3.3.1.本地时间戳方式 ID= (30(毫秒时间戳前30位)+5(机器ID)+5(业务编码)+12(重复累加)+12(毫秒时间戳后12位) -B.分布式ZK ID 生成器 +##### 3.3.2.分布式ZK ID 生成器 ID= 63位二进制 (9(线程ID) +5(实例ID)+4(机房ID)+6(重复累加) +39(毫秒求模,可用17年)) +#### 3.4 server.xml +3.4.1 mycatNodeId 改为serverNodeId ------- +## 4.ushard分支 #117 +如果不需要混淆成字母类(eg:A.class),maven编译增加参数: +-Dneed.obfuscate=false ,默认为true +#### 4.1 客户端登录信息 +显示ushard相关字样 +#### 4.2 注解 +注解内部原本用mycat的改为ushard +#### 4.3 全局序列 +数据库方式全局序列需要的dbseq.sql 已经重新生成,mycat已经用ushard替换,表结构相关名称改变 +#### 4.4 配置 +##### 4.4.1 xml的使用规约 +mycat改为ushard ,例如:server的根节点写法是: + +``` + +``` + +``` + +``` + +##### 4.4.2 cacheservice.properties +此配置中需要指定类名用于反射加载缓存池类型,可使用简称 +ehcache +leveldb +mapdb +来指代原有类名(不区分大小写),mycat分支下兼容原有方式和简称方式。 +原有方式如下,按顺序与简称方式一一对应。 +io.mycat.cache.impl.EnchachePooFactory +io.mycat.cache.impl.LevelDBCachePooFactory +io.mycat.cache.impl.MapDBCachePooFactory +和简称方式。 +##### 4.4.3 rule.xml +rule.xml配置当中需要指定类名用于反射加载拆分算法,可使用简称 +Hash +StringHash +Enum +NumberRange +Date +PatternRange +来指代原有类名(不区分大小写),mycat分支下兼容原有方式和简称方式。 +原有方式如下,按顺序与简称方式一一对应。 +io.mycat.route.function.PartitionByLong(固定Hash 分区) +io.mycat.route.function.PartitionByString(String固定Hash 分区) +io.mycat.route.function.PartitionByFileMap(枚举方式) +io.mycat.route.function.AutoPartitionByLong(数字范围) +io.mycat.route.function.PartitionByDate(日期分区) +io.mycat.route.function.PartitionByPattern(取模范围约束) +#### 4.5 全局表检查 +启用全局表检查时候,列名由_mycat_op_time改为_ushard_op_time +#### 4.6 日志 +日志路径logs/ushard.log。 +里面涉及到的包名从io.mycat 改为com.actionsky.com + +------ + + DATE:2017/04/20 VERSION 2.17.04.0 diff --git a/pom.xml b/pom.xml index 59aceaa47..89392ff30 100644 --- a/pom.xml +++ b/pom.xml @@ -268,9 +268,9 @@ src/main/resources - - **/.svn/** - + + *.dtd + ${basedir} @@ -427,6 +427,10 @@ @annotation-name@ mycat: + + @root_prefix@ + mycat + diff --git a/src/main/assembly/ushard/StructureMeta.proto b/src/main/assembly/ushard/StructureMeta.proto new file mode 100644 index 000000000..c627b5f35 --- /dev/null +++ b/src/main/assembly/ushard/StructureMeta.proto @@ -0,0 +1,46 @@ +syntax = "proto2"; +package com.actionsky.ushard.meta.protocol; + +option java_package = "com.actionsky.ushard.meta.protocol"; +option java_outer_classname = "StructureMeta"; +option optimize_for = SPEED; + + +message IndexMeta{ + required string name = 1; + required string type = 2;//PRI,UNI,MUI + repeated string columns = 3; + + +} +message ColumnMeta{ + required string name = 1; + required string dataType = 2; + optional bool isUnsigned = 3; + optional int32 length = 4; + optional int32 precision = 5; + optional int32 scale = 6; + optional bool canNull = 7; + optional string sdefault = 8; + optional bool auto_incre = 9; + optional string charsetname = 10 [default = "utf8"]; + //[COMMENT 'string'] + //[COLUMN_FORMAT {FIXED|DYNAMIC|DEFAULT}] + //[STORAGE {DISK|MEMORY|DEFAULT}] + //[reference_definition] + //[GENERATED ALWAYS] AS (expression) +} + +message TableMeta{ + optional string tableName = 1;//不带dbname的表名:如table1 + repeated ColumnMeta columns = 2;//所有的列属性,有序 + optional bool isView = 3[default = false]; + optional string createSql = 4; + optional int64 version = 5; + optional int64 aiOffset = 6[default=-1]; + optional int32 type = 7; + optional int32 aiColPos = 8[default=-1]; + optional IndexMeta primary = 9; + repeated IndexMeta uniIndex = 10; + repeated IndexMeta index = 11; +} diff --git a/src/main/assembly/assembly-ushard-linux.xml b/src/main/assembly/ushard/assembly-ushard-linux.xml similarity index 100% rename from src/main/assembly/assembly-ushard-linux.xml rename to src/main/assembly/ushard/assembly-ushard-linux.xml diff --git a/src/main/java/io/mycat/MycatServer.java b/src/main/java/io/mycat/MycatServer.java index a13f54059..62aa6de73 100644 --- a/src/main/java/io/mycat/MycatServer.java +++ b/src/main/java/io/mycat/MycatServer.java @@ -40,7 +40,6 @@ import io.mycat.config.MycatConfig; import io.mycat.config.classloader.DynaClassLoader; import io.mycat.config.loader.zkprocess.comm.ZkConfig; import io.mycat.config.loader.zkprocess.comm.ZkParamCfg; -import io.mycat.config.loader.zkprocess.entity.server.System; import io.mycat.config.model.SchemaConfig; import io.mycat.config.model.SystemConfig; import io.mycat.config.model.TableConfig; @@ -82,14 +81,14 @@ import java.util.concurrent.atomic.AtomicLong; */ public class MycatServer { - public static final String NAME = "MyCat"; + public static final String NAME = "MyCat_"; private static final long LOG_WATCH_DELAY = 60000L; private static final long TIME_UPDATE_PERIOD = 20L; private static final long DEFAULT_SQL_STAT_RECYCLE_PERIOD = 5 * 1000L; private static final long DEFAULT_OLD_CONNECTION_CLEAR_PERIOD = 5 * 1000L; private static final MycatServer INSTANCE = new MycatServer(); - private static final Logger LOGGER = LoggerFactory.getLogger("MycatServer"); + private static final Logger LOGGER = LoggerFactory.getLogger("Server"); private static final Repository fileRepository = new FileSystemRepository(); private AtomicBoolean backupLocked; @@ -119,7 +118,7 @@ public class MycatServer { /** * Mycat 内存管理类 */ - private MyCatMemory myCatMemory = null; + private MyCatMemory serverMemory = null; public static final MycatServer getInstance() { return INSTANCE; @@ -218,7 +217,7 @@ public class MycatServer { seq = xaIDInc.incrementAndGet(); } } - return "'Mycat." + this.getConfig().getSystem().getMycatNodeId() + "." + seq + "'"; + return "'"+NAME+"Server." + this.getConfig().getSystem().getServerNodeId() + "." + seq + "'"; } private void genXidSeq(String xaID) { @@ -243,8 +242,8 @@ public class MycatServer { throw new java.lang.IllegalArgumentException("Invalid sequnce handler type " + seqHandlerType); } } - public MyCatMemory getMyCatMemory() { - return myCatMemory; + public MyCatMemory getServerMemory() { + return serverMemory; } public XASessionCheck getXaSessionCheck() { @@ -288,7 +287,7 @@ public class MycatServer { // server startup LOGGER.info("==============================================="); - LOGGER.info(NAME + " is ready to startup ..."); + LOGGER.info(NAME + "Server is ready to startup ..."); String inf = "Startup processors ...,total processors:" + system.getProcessors() + ",aio thread pool size:" + system.getProcessorExecutor() @@ -330,7 +329,7 @@ public class MycatServer { */ if(system.getUseOffHeapForMerge() == 1){ try { - myCatMemory = new MyCatMemory(system,totalNetWorkBufferSize); + serverMemory = new MyCatMemory(system,totalNetWorkBufferSize); } catch (NoSuchFieldException e) { LOGGER .error("NoSuchFieldException",e); } catch (IllegalAccessException e) { diff --git a/src/main/java/io/mycat/MycatStartup.java b/src/main/java/io/mycat/MycatStartup.java index fbc1ffd90..d8e075ef4 100644 --- a/src/main/java/io/mycat/MycatStartup.java +++ b/src/main/java/io/mycat/MycatStartup.java @@ -28,6 +28,7 @@ package io.mycat; import java.text.SimpleDateFormat; import java.util.Date; +import io.mycat.manager.handler.ShowServerLog; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,7 +56,7 @@ public final class MycatStartup { // startup server.startup(); - System.out.println("MyCAT Server startup successfully. see logs in logs/mycat.log"); + System.out.println("Server startup successfully. see logs in logs/"+ ShowServerLog.DEFAULT_LOGFILE); } catch (Exception e) { SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); diff --git a/src/main/java/io/mycat/backend/heartbeat/MySQLConsistencyChecker.java b/src/main/java/io/mycat/backend/heartbeat/MySQLConsistencyChecker.java index b2d6b2314..9dbc79b9a 100644 --- a/src/main/java/io/mycat/backend/heartbeat/MySQLConsistencyChecker.java +++ b/src/main/java/io/mycat/backend/heartbeat/MySQLConsistencyChecker.java @@ -55,7 +55,7 @@ public class MySQLConsistencyChecker{ private String[] physicalSchemas; // private String columnExistSQL = "select count(*) as "+GlobalTableUtil.INNER_COLUMN // + " from information_schema.columns where column_name='" -// + GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN + "' and table_name='"; +// + GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN + "' and table_name='"; // 此处用到了 mysql 多行转一行 group_concat 的用法,主要是为了简化对结果的处理 // 得到的结果类似于:id,name,_mycat_op_time @@ -72,7 +72,7 @@ public class MySQLConsistencyChecker{ this.tableName = tableName; this.countSQL = " select count(*) as "+GlobalTableUtil.COUNT_COLUMN+" from " + this.tableName; - this.maxSQL = " select max("+GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN+") as "+ + this.maxSQL = " select max("+GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN +") as "+ GlobalTableUtil.MAX_COLUMN+" from " + this.tableName; this.columnExistSQL += this.tableName +"' "; } diff --git a/src/main/java/io/mycat/backend/mysql/nio/handler/SingleNodeHandler.java b/src/main/java/io/mycat/backend/mysql/nio/handler/SingleNodeHandler.java index 6bf734d8d..7f03ca8ee 100644 --- a/src/main/java/io/mycat/backend/mysql/nio/handler/SingleNodeHandler.java +++ b/src/main/java/io/mycat/backend/mysql/nio/handler/SingleNodeHandler.java @@ -157,6 +157,7 @@ public class SingleNodeHandler implements ResponseHandler, LoadDataResponseHandl } @Override public void connectionError(Throwable e, BackendConnection conn) { + session.handleSpecial(rrs,session.getSource().getSchema(), true); recycleResources(); session.getSource().close(e.getMessage()); } diff --git a/src/main/java/io/mycat/backend/mysql/nio/handler/builder/BaseHandlerBuilder.java b/src/main/java/io/mycat/backend/mysql/nio/handler/builder/BaseHandlerBuilder.java index 4a61603fb..ef657e16a 100644 --- a/src/main/java/io/mycat/backend/mysql/nio/handler/builder/BaseHandlerBuilder.java +++ b/src/main/java/io/mycat/backend/mysql/nio/handler/builder/BaseHandlerBuilder.java @@ -50,7 +50,7 @@ abstract class BaseHandlerBuilder { /* 当前的最后一个handler */ protected DMLResponseHandler currentLast; private PlanNode node; - protected MycatConfig mycatConfig; + protected MycatConfig config; /* 是否可以全下推 */ protected boolean canPushDown = false; /* 是否需要common中的handler,包括group by,order by,limit等 */ @@ -66,8 +66,8 @@ abstract class BaseHandlerBuilder { : MySQLNodeType.SLAVE; this.node = node; this.hBuilder = hBuilder; - this.mycatConfig = MycatServer.getInstance().getConfig(); - if (mycatConfig.getSchemas().isEmpty()) + this.config = MycatServer.getInstance().getConfig(); + if (config.getSchemas().isEmpty()) throw new MySQLOutPutException(ErrorCode.ER_QUERYHANDLER, "", "current router config is empty!"); } @@ -410,7 +410,7 @@ abstract class BaseHandlerBuilder { } protected TableConfig getTableConfig(String schema, String table) { - SchemaConfig schemaConfig = this.mycatConfig.getSchemas().get(schema); + SchemaConfig schemaConfig = this.config.getSchemas().get(schema); if (schemaConfig == null) return null; return schemaConfig.getTables().get(table); diff --git a/src/main/java/io/mycat/backend/mysql/nio/handler/builder/HandlerBuilder.java b/src/main/java/io/mycat/backend/mysql/nio/handler/builder/HandlerBuilder.java index 757005ae3..209aed1a8 100644 --- a/src/main/java/io/mycat/backend/mysql/nio/handler/builder/HandlerBuilder.java +++ b/src/main/java/io/mycat/backend/mysql/nio/handler/builder/HandlerBuilder.java @@ -89,21 +89,18 @@ public class HandlerBuilder { } private BaseHandlerBuilder createBuilder(final NonBlockingSession session, PlanNode node, HandlerBuilder context) { - switch (node.type()) { - case TABLE: { + PlanNode.PlanNodeType i = node.type(); + if (i == PlanNode.PlanNodeType.TABLE) { return new TableNodeHandlerBuilder(session, (TableNode) node, this); - } - case JOIN: { + } else if (i == PlanNode.PlanNodeType.JOIN) { return new JoinNodeHandlerBuilder(session, (JoinNode) node, this); - } - case MERGE: { + } else if (i == PlanNode.PlanNodeType.MERGE) { return new MergeNodeHandlerBuilder(session, (MergeNode) node, this); - } - case QUERY: + } else if (i == PlanNode.PlanNodeType.QUERY) { return new QueryNodeHandlerBuilder(session, (QueryNode) node, this); - case NONAME: + } else if (i == PlanNode.PlanNodeType.NONAME) { return new NoNameNodeHandlerBuilder(session, (NoNameNode) node, this); - default: + } else { } throw new RuntimeException("not supported tree node type:" + node.type()); } diff --git a/src/main/java/io/mycat/backend/mysql/nio/handler/builder/JoinNodeHandlerBuilder.java b/src/main/java/io/mycat/backend/mysql/nio/handler/builder/JoinNodeHandlerBuilder.java index aebe62c76..4753f3028 100644 --- a/src/main/java/io/mycat/backend/mysql/nio/handler/builder/JoinNodeHandlerBuilder.java +++ b/src/main/java/io/mycat/backend/mysql/nio/handler/builder/JoinNodeHandlerBuilder.java @@ -62,8 +62,7 @@ class JoinNodeHandlerBuilder extends BaseHandlerBuilder { List pres = new ArrayList(); PlanNode left = node.getLeftNode(); PlanNode right = node.getRightNode(); - switch (node.getStrategy()) { - case NESTLOOP: + if (node.getStrategy() == JoinNode.Strategy.NESTLOOP) { final boolean isLeftSmall = left.getNestLoopFilters() == null; final PlanNode tnSmall = isLeftSmall ? left : right; final PlanNode tnBig = isLeftSmall ? right : left; @@ -100,15 +99,15 @@ class JoinNodeHandlerBuilder extends BaseHandlerBuilder { } }; tempHandler.setTempDoneCallBack(tempDone); - break; - case SORTMERGE: + + } else if (node.getStrategy() == JoinNode.Strategy.SORTMERGE) { DMLResponseHandler lh = buildJoinChild(left, true); pres.add(lh); DMLResponseHandler rh = buildJoinChild(right, false); pres.add(rh); - break; - default: - throw new MySQLOutPutException(ErrorCode.ER_QUERYHANDLER, "","strategy ["+node.getStrategy()+"] not implement yet!" ); + + } else { + throw new MySQLOutPutException(ErrorCode.ER_QUERYHANDLER, "", "strategy [" + node.getStrategy() + "] not implement yet!"); } return pres; } diff --git a/src/main/java/io/mycat/backend/mysql/nio/handler/builder/MergeBuilder.java b/src/main/java/io/mycat/backend/mysql/nio/handler/builder/MergeBuilder.java index 8a2e6bf2d..db2885531 100644 --- a/src/main/java/io/mycat/backend/mysql/nio/handler/builder/MergeBuilder.java +++ b/src/main/java/io/mycat/backend/mysql/nio/handler/builder/MergeBuilder.java @@ -29,7 +29,7 @@ public class MergeBuilder { private NonBlockingSession session; private MySQLNodeType nodeType; private String schema; - private MycatConfig mycatConfig; + private MycatConfig config; private PushDownVisitor pdVisitor; public MergeBuilder(NonBlockingSession session, PlanNode node, boolean needCommon, boolean needSendMaker, @@ -41,7 +41,7 @@ public class MergeBuilder { this.schema = session.getSource().getSchema(); this.nodeType = session.getSource().isTxstart() || !session.getSource().isAutocommit() ? MySQLNodeType.MASTER : MySQLNodeType.SLAVE; - this.mycatConfig = MycatServer.getInstance().getConfig(); + this.config = MycatServer.getInstance().getConfig(); this.pdVisitor = pdVisitor; } @@ -62,7 +62,7 @@ public class MergeBuilder { RouteResultset rrs = new RouteResultset(sql, ServerParse.SELECT); LayerCachePool pool = MycatServer.getInstance().getRouterservice().getTableId2DataNodeCache(); - SchemaConfig schemaConfig = mycatConfig.getSchemas().get(node.getReferedTableNodes().get(0).getSchema()); + SchemaConfig schemaConfig = config.getSchemas().get(node.getReferedTableNodes().get(0).getSchema()); return RouterUtil.routeFromParser(druidParser, schemaConfig, rrs, select, sql, pool, visitor, session.getSource()); } diff --git a/src/main/java/io/mycat/backend/mysql/nio/handler/builder/NoNameNodeHandlerBuilder.java b/src/main/java/io/mycat/backend/mysql/nio/handler/builder/NoNameNodeHandlerBuilder.java index 2372982f5..bf175272c 100644 --- a/src/main/java/io/mycat/backend/mysql/nio/handler/builder/NoNameNodeHandlerBuilder.java +++ b/src/main/java/io/mycat/backend/mysql/nio/handler/builder/NoNameNodeHandlerBuilder.java @@ -39,7 +39,7 @@ class NoNameNodeHandlerBuilder extends BaseHandlerBuilder { this.canPushDown = true; String sql = vistor.getSql().toString(); String schema = session.getSource().getSchema(); - SchemaConfig schemacfg = mycatConfig.getSchemas().get(schema); + SchemaConfig schemacfg = config.getSchemas().get(schema); RouteResultsetNode[] rrss = getTableSources(schemacfg.getAllDataNodes(),sql); hBuilder.checkRRSS(rrss); MultiNodeMergeHandler mh = new MultiNodeMergeHandler(getSequenceId(), rrss, session.getSource().isAutocommit()&&!session.getSource().isTxstart(), diff --git a/src/main/java/io/mycat/backend/mysql/nio/handler/builder/sqlvisitor/GlobalVisitor.java b/src/main/java/io/mycat/backend/mysql/nio/handler/builder/sqlvisitor/GlobalVisitor.java index ac73c961a..fba2f8535 100644 --- a/src/main/java/io/mycat/backend/mysql/nio/handler/builder/sqlvisitor/GlobalVisitor.java +++ b/src/main/java/io/mycat/backend/mysql/nio/handler/builder/sqlvisitor/GlobalVisitor.java @@ -27,23 +27,23 @@ public class GlobalVisitor extends MysqlVisitor { if (!visited) { replaceableSqlBuilder.clear(); sqlBuilder = replaceableSqlBuilder.getCurrentElement().getSb(); - switch (query.type()) { - case TABLE: + PlanNodeType i = query.type(); + if (i == PlanNodeType.TABLE) { visit((TableNode) query); - break; - case JOIN: + + } else if (i == PlanNodeType.JOIN) { visit((JoinNode) query); - break; - case QUERY: + + } else if (i == PlanNodeType.QUERY) { visit((QueryNode) query); - break; - case MERGE: + + } else if (i == PlanNodeType.MERGE) { visit((MergeNode) query); - break; - case NONAME: + + } else if (i == PlanNodeType.NONAME) { visit((NoNameNode) query); - break; - default: + + } else { throw new RuntimeException("not implement yet!"); } visited = true; diff --git a/src/main/java/io/mycat/backend/mysql/nio/handler/builder/sqlvisitor/PushDownVisitor.java b/src/main/java/io/mycat/backend/mysql/nio/handler/builder/sqlvisitor/PushDownVisitor.java index 23a67cf0b..cfd15a1e1 100644 --- a/src/main/java/io/mycat/backend/mysql/nio/handler/builder/sqlvisitor/PushDownVisitor.java +++ b/src/main/java/io/mycat/backend/mysql/nio/handler/builder/sqlvisitor/PushDownVisitor.java @@ -38,14 +38,14 @@ public class PushDownVisitor extends MysqlVisitor { replaceableSqlBuilder.clear(); sqlBuilder = replaceableSqlBuilder.getCurrentElement().getSb(); // 在已经visited的情况下,pushdownvisitor只要进行table名称的替换即可 - switch (query.type()) { - case TABLE: + PlanNode.PlanNodeType i = query.type(); + if (i == PlanNode.PlanNodeType.TABLE) { visit((TableNode) query); - break; - case JOIN: + + } else if (i == PlanNode.PlanNodeType.JOIN) { visit((JoinNode) query); - break; - default: + + } else { throw new RuntimeException("not implement yet!"); } visited = true; @@ -170,8 +170,8 @@ public class PushDownVisitor extends MysqlVisitor { ItemSum funCol = (ItemSum) col; String funName = funCol.funcName().toUpperCase(); String colName = pdName; - switch (funCol.sumType()) { - case AVG_FUNC: { + ItemSum.Sumfunctype i = funCol.sumType(); + if (i == ItemSum.Sumfunctype.AVG_FUNC) { String colNameSum = colName.replace(funName + "(", "SUM("); colNameSum = colNameSum.replace(getMadeAggAlias(funName), getMadeAggAlias("SUM")); String colNameCount = colName.replace(funName + "(", "COUNT("); @@ -181,18 +181,14 @@ public class PushDownVisitor extends MysqlVisitor { pushDownTableInfos.add(null); pushDownTableInfos.add(null); } - } continue; - case STD_FUNC: - case VARIANCE_FUNC: { - // variance:下发时 v[0]:count,v[1]:sum,v[2]:variance(局部) + } else if (i == ItemSum.Sumfunctype.STD_FUNC || i == ItemSum.Sumfunctype.VARIANCE_FUNC) { String colNameCount = colName.replace(funName + "(", "COUNT("); colNameCount = colNameCount.replace(getMadeAggAlias(funName), getMadeAggAlias("COUNT")); String colNameSum = colName.replace(funName + "(", "SUM("); colNameSum = colNameSum.replace(getMadeAggAlias(funName), getMadeAggAlias("SUM")); String colNameVar = colName.replace(funName + "(", "VARIANCE("); colNameVar = colNameVar.replace(getMadeAggAlias(funName), getMadeAggAlias("VARIANCE")); - // VARIANCE sqlBuilder.append(colNameCount).append(",").append(colNameSum).append(",").append(colNameVar) .append(","); if (addPushDownTableInfo) { @@ -200,10 +196,7 @@ public class PushDownVisitor extends MysqlVisitor { pushDownTableInfos.add(null); pushDownTableInfos.add(null); } - } continue; - default: - break; } } sqlBuilder.append(pdName); diff --git a/src/main/java/io/mycat/backend/mysql/nio/handler/transaction/xa/XACommitNodesHandler.java b/src/main/java/io/mycat/backend/mysql/nio/handler/transaction/xa/XACommitNodesHandler.java index 14713726d..b6f49b0a5 100644 --- a/src/main/java/io/mycat/backend/mysql/nio/handler/transaction/xa/XACommitNodesHandler.java +++ b/src/main/java/io/mycat/backend/mysql/nio/handler/transaction/xa/XACommitNodesHandler.java @@ -30,8 +30,8 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { } @Override protected boolean executeCommit(MySQLConnection mysqlCon, int position) { - switch (session.getXaState()) { - case TX_STARTED_STATE: + TxState state = session.getXaState(); + if(state == TxState.TX_STARTED_STATE) { if (participantLogEntry == null) { participantLogEntry = new ParticipantLogEntry[nodeCount]; CoordinatorLogEntry coordinatorLogEntry = new CoordinatorLogEntry(session.getSessionXaID(), participantLogEntry, session.getXaState()); @@ -39,8 +39,7 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { } XAStateLog.initRecoverylog(session.getSessionXaID(), position, mysqlCon); endPhase(mysqlCon); - break; - case TX_ENDED_STATE: + }else if (state == TxState.TX_ENDED_STATE) { if (position == 0) { if (!XAStateLog.saveXARecoverylog(session.getSessionXaID(), TxState.TX_PREPARING_STATE)) { String errMsg = "saveXARecoverylog error, the stage is TX_PREPARING_STATE"; @@ -51,8 +50,7 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { } } preparePhase(mysqlCon); - break; - case TX_PREPARED_STATE: + } else if(state == TxState.TX_PREPARED_STATE) { if (position == 0) { if (!XAStateLog.saveXARecoverylog(session.getSessionXaID(), TxState.TX_COMMITING_STATE)) { String errMsg = "saveXARecoverylog error, the stage is TX_COMMITING_STATE"; @@ -63,14 +61,11 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { } } commitPhase(mysqlCon); - break; - case TX_COMMIT_FAILED_STATE: + } else if(state == TxState.TX_COMMIT_FAILED_STATE) { if (position == 0) { XAStateLog.saveXARecoverylog(session.getSessionXaID(), TxState.TX_COMMIT_FAILED_STATE); } commitPhase(mysqlCon); - break; - default: } return true; } @@ -108,30 +103,26 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { @Override public void okResponse(byte[] ok, BackendConnection conn) { MySQLConnection mysqlCon = (MySQLConnection) conn; - switch (mysqlCon.getXaStatus()) { - // END OK - case TX_STARTED_STATE: + TxState state =mysqlCon.getXaStatus(); + if(state == TxState.TX_STARTED_STATE) { mysqlCon.setXaStatus(TxState.TX_ENDED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); if (decrementCountBy(1)) { session.setXaState(TxState.TX_ENDED_STATE); nextParse(); } - break; - //PREPARE OK - case TX_ENDED_STATE: + } else if(state == TxState.TX_ENDED_STATE) { + //PREPARE OK mysqlCon.setXaStatus(TxState.TX_PREPARED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); if (decrementCountBy(1)) { - if(session.getXaState()== TxState.TX_ENDED_STATE){ + if (session.getXaState() == TxState.TX_ENDED_STATE) { session.setXaState(TxState.TX_PREPARED_STATE); } nextParse(); } - break; - //COMMIT OK - case TX_COMMIT_FAILED_STATE: - case TX_PREPARED_STATE: + }else if(state == TxState.TX_COMMIT_FAILED_STATE ||state == TxState.TX_PREPARED_STATE) { + //COMMIT OK // XA reset status now mysqlCon.setXaStatus(TxState.TX_COMMITED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); @@ -142,8 +133,6 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { } cleanAndFeedback(); } - break; - default: // LOGGER.error("Wrong XA status flag!"); } } @@ -157,9 +146,7 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { sendData = makeErrorPacket(errmsg); if (conn instanceof MySQLConnection) { MySQLConnection mysqlCon = (MySQLConnection) conn; - switch (mysqlCon.getXaStatus()) { - // 'xa end' error - case TX_STARTED_STATE: + if (mysqlCon.getXaStatus() == TxState.TX_STARTED_STATE) { mysqlCon.quit(); mysqlCon.setXaStatus(TxState.TX_CONN_QUIT); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); @@ -167,32 +154,27 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { session.setXaState(TxState.TX_ENDED_STATE); nextParse(); } - break; - // 'xa prepare' error - case TX_ENDED_STATE: + + // 'xa prepare' error + } else if (mysqlCon.getXaStatus() == TxState.TX_ENDED_STATE) { mysqlCon.quit(); mysqlCon.setXaStatus(TxState.TX_CONN_QUIT); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); if (decrementCountBy(1)) { - if(session.getXaState()== TxState.TX_ENDED_STATE){ + if (session.getXaState() == TxState.TX_ENDED_STATE) { session.setXaState(TxState.TX_PREPARED_STATE); } nextParse(); } - break; - // 'xa commit' err - case TX_COMMIT_FAILED_STATE: - case TX_PREPARED_STATE: - //TODO :服务降级? + + // 'xa commit' err + } else if (mysqlCon.getXaStatus() == TxState.TX_COMMIT_FAILED_STATE || mysqlCon.getXaStatus() == TxState.TX_PREPARED_STATE) {//TODO :服务降级? mysqlCon.setXaStatus(TxState.TX_COMMIT_FAILED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); session.setXaState(TxState.TX_COMMIT_FAILED_STATE); if (decrementCountBy(1)) { cleanAndFeedback(); } - break; - default: - // LOGGER.error("Wrong XA status flag!"); } } } @@ -205,9 +187,7 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { sendData = makeErrorPacket(errmsg); if (conn instanceof MySQLConnection) { MySQLConnection mysqlCon = (MySQLConnection) conn; - switch (mysqlCon.getXaStatus()) { - // 'xa end' connectionError - case TX_STARTED_STATE: + if (mysqlCon.getXaStatus() == TxState.TX_STARTED_STATE) { mysqlCon.quit(); mysqlCon.setXaStatus(TxState.TX_CONN_QUIT); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); @@ -215,29 +195,24 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { session.setXaState(TxState.TX_ENDED_STATE); nextParse(); } - break; - // 'xa prepare' connectionError - case TX_ENDED_STATE: + + // 'xa prepare' connectionError + } else if (mysqlCon.getXaStatus() == TxState.TX_ENDED_STATE) { mysqlCon.setXaStatus(TxState.TX_PREPARE_UNCONNECT_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); session.setXaState(TxState.TX_PREPARE_UNCONNECT_STATE); if (decrementCountBy(1)) { nextParse(); } - break; - // 'xa commit' connectionError - case TX_COMMIT_FAILED_STATE: - case TX_PREPARED_STATE: - //TODO :服务降级? + + // 'xa commit' connectionError + } else if (mysqlCon.getXaStatus() == TxState.TX_COMMIT_FAILED_STATE || mysqlCon.getXaStatus() == TxState.TX_PREPARED_STATE) {//TODO :服务降级? mysqlCon.setXaStatus(TxState.TX_COMMIT_FAILED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); session.setXaState(TxState.TX_COMMIT_FAILED_STATE); if (decrementCountBy(1)) { cleanAndFeedback(); } - break; - default: - // LOGGER.error("Wrong XA status flag!"); } } } @@ -248,9 +223,7 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { sendData = makeErrorPacket(reason); if (conn instanceof MySQLConnection) { MySQLConnection mysqlCon = (MySQLConnection) conn; - switch (mysqlCon.getXaStatus()) { - // 'xa end' connectionClose,conn has quit - case TX_STARTED_STATE: + if (mysqlCon.getXaStatus() == TxState.TX_STARTED_STATE) { mysqlCon.quit(); mysqlCon.setXaStatus(TxState.TX_CONN_QUIT); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); @@ -258,29 +231,24 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { session.setXaState(TxState.TX_ENDED_STATE); nextParse(); } - break; - // 'xa prepare' connectionClose,conn has quit - case TX_ENDED_STATE: + + // 'xa prepare' connectionClose,conn has quit + } else if (mysqlCon.getXaStatus() == TxState.TX_ENDED_STATE) { mysqlCon.setXaStatus(TxState.TX_PREPARE_UNCONNECT_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); session.setXaState(TxState.TX_PREPARE_UNCONNECT_STATE); if (decrementCountBy(1)) { nextParse(); } - break; + // 'xa commit' connectionClose - case TX_COMMIT_FAILED_STATE: - case TX_PREPARED_STATE: - //TODO :服务降级? + } else if (mysqlCon.getXaStatus() == TxState.TX_COMMIT_FAILED_STATE || mysqlCon.getXaStatus() == TxState.TX_PREPARED_STATE) {//TODO :服务降级? mysqlCon.setXaStatus(TxState.TX_COMMIT_FAILED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); session.setXaState(TxState.TX_COMMIT_FAILED_STATE); if (decrementCountBy(1)) { cleanAndFeedback(); } - break; - default: - // LOGGER.error("Wrong XA status flag!"); } } } @@ -295,9 +263,7 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { } } private void cleanAndFeedback() { - switch (session.getXaState()) { - case TX_INITIALIZE_STATE: - // clear all resources + if (session.getXaState() == TxState.TX_INITIALIZE_STATE) {// clear all resources XAStateLog.saveXARecoverylog(session.getSessionXaID(), TxState.TX_COMMITED_STATE); //在这里释放取消限制锁 session.cancelableStatusSet(NonBlockingSession.CANCEL_STATUS_INIT); @@ -307,9 +273,9 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { return; } session.getSource().write(send); - break; - // partitionly commited,must commit again - case TX_COMMIT_FAILED_STATE: + + // partitionly commited,must commit again + } else if (session.getXaState() == TxState.TX_COMMIT_FAILED_STATE) { MySQLConnection errConn = session.releaseExcept(TxState.TX_COMMIT_FAILED_STATE); if (errConn != null) { XAStateLog.saveXARecoverylog(session.getSessionXaID(), session.getXaState()); @@ -326,19 +292,19 @@ public class XACommitNodesHandler extends AbstractCommitNodesHandler { session.setXaState(TxState.TX_INITIALIZE_STATE); //在这里释放取消限制锁 session.cancelableStatusSet(NonBlockingSession.CANCEL_STATUS_INIT); - byte[]toSend = sendData; + byte[] toSend = sendData; session.clearResources(false); if (!session.closed()) { session.getSource().write(toSend); } } - break; - // need to rollback; - default: + + // need to rollback; + } else { XAStateLog.saveXARecoverylog(session.getSessionXaID(), session.getXaState()); session.getSource().write(sendData); LOGGER.warn("cleanAndFeedback:" + error); - break; + } } } diff --git a/src/main/java/io/mycat/backend/mysql/nio/handler/transaction/xa/XARollbackNodesHandler.java b/src/main/java/io/mycat/backend/mysql/nio/handler/transaction/xa/XARollbackNodesHandler.java index 01133458a..315403758 100644 --- a/src/main/java/io/mycat/backend/mysql/nio/handler/transaction/xa/XARollbackNodesHandler.java +++ b/src/main/java/io/mycat/backend/mysql/nio/handler/transaction/xa/XARollbackNodesHandler.java @@ -85,82 +85,73 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { if(position==0 && participantLogEntry != null){ XAStateLog.saveXARecoverylog(session.getSessionXaID(), session.getXaState()); } - switch (session.getXaState()) { - case TX_STARTED_STATE: + if (session.getXaState() == TxState.TX_STARTED_STATE) { if (participantLogEntry == null) { participantLogEntry = new ParticipantLogEntry[nodeCount]; CoordinatorLogEntry coordinatorLogEntry = new CoordinatorLogEntry(session.getSessionXaID(), participantLogEntry, session.getXaState()); XAStateLog.flushMemoryRepository(session.getSessionXaID(), coordinatorLogEntry); } XAStateLog.initRecoverylog(session.getSessionXaID(), position, mysqlCon); - if(mysqlCon.isClosed()){ + if (mysqlCon.isClosed()) { mysqlCon.setXaStatus(TxState.TX_CONN_QUIT); } endPhase(mysqlCon); - break; - case TX_PREPARED_STATE: + + } else if (session.getXaState() == TxState.TX_PREPARED_STATE) { if (position == 0) { - if(!XAStateLog.saveXARecoverylog(session.getSessionXaID(), TxState.TX_ROLLBACKING_STATE)){ + if (!XAStateLog.saveXARecoverylog(session.getSessionXaID(), TxState.TX_ROLLBACKING_STATE)) { this.setFail("saveXARecoverylog error, the stage is TX_ROLLBACKING_STATE"); cleanAndFeedback(); return false; } } - case TX_ROLLBACK_FAILED_STATE: - case TX_PREPARE_UNCONNECT_STATE: rollbackPhase(mysqlCon); - break; - case TX_ENDED_STATE: - if(mysqlCon.isClosed()){ + + } else if (session.getXaState() == TxState.TX_ROLLBACK_FAILED_STATE || session.getXaState() == TxState.TX_PREPARE_UNCONNECT_STATE) { + rollbackPhase(mysqlCon); + + } else if (session.getXaState() == TxState.TX_ENDED_STATE) { + if (mysqlCon.isClosed()) { mysqlCon.setXaStatus(TxState.TX_CONN_QUIT); } rollbackPhase(mysqlCon); - break; - default: } return true; } private void endPhase(MySQLConnection mysqlCon) { - switch (mysqlCon.getXaStatus()) { - case TX_STARTED_STATE: + if (mysqlCon.getXaStatus() == TxState.TX_STARTED_STATE) { String xaTxId = mysqlCon.getConnXID(session); mysqlCon.execCmd("XA END " + xaTxId + ";"); - break; - case TX_CONN_QUIT: + + } else if (mysqlCon.getXaStatus() == TxState.TX_CONN_QUIT) { if (decrementCountBy(1)) { session.setXaState(TxState.TX_ENDED_STATE); rollback(); } - default: - break; } } private void rollbackPhase(MySQLConnection mysqlCon) { - switch (mysqlCon.getXaStatus()) { - case TX_ROLLBACK_FAILED_STATE: - case TX_PREPARE_UNCONNECT_STATE: + if (mysqlCon.getXaStatus() == TxState.TX_ROLLBACK_FAILED_STATE || mysqlCon.getXaStatus() == TxState.TX_PREPARE_UNCONNECT_STATE) { MySQLConnection newConn = session.freshConn(mysqlCon, this); if (!newConn.equals(mysqlCon)) { mysqlCon = newConn; + String xaTxId = mysqlCon.getConnXID(session); + mysqlCon.execCmd("XA ROLLBACK " + xaTxId + ";"); } else if (decrementCountBy(1)) { cleanAndFeedback(); - break; } - case TX_ENDED_STATE: - case TX_PREPARED_STATE: + + } else if (mysqlCon.getXaStatus() == TxState.TX_ENDED_STATE || mysqlCon.getXaStatus() == TxState.TX_PREPARED_STATE) { String xaTxId = mysqlCon.getConnXID(session); mysqlCon.execCmd("XA ROLLBACK " + xaTxId + ";"); - break; - case TX_CONN_QUIT: - case TX_ROLLBACKED_STATE: + + } else if (mysqlCon.getXaStatus() == TxState.TX_CONN_QUIT || mysqlCon.getXaStatus() == TxState.TX_ROLLBACKED_STATE) { if (decrementCountBy(1)) { cleanAndFeedback(); } - break; - default: - break; + } } @@ -168,18 +159,16 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { public void okResponse(byte[] ok, BackendConnection conn) { if (conn instanceof MySQLConnection) { MySQLConnection mysqlCon = (MySQLConnection) conn; - switch (mysqlCon.getXaStatus()) { - // 'xa end' ok - case TX_STARTED_STATE: + if (mysqlCon.getXaStatus() == TxState.TX_STARTED_STATE) { mysqlCon.setXaStatus(TxState.TX_ENDED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); if (decrementCountBy(1)) { session.setXaState(TxState.TX_ENDED_STATE); rollback(); } - break; - // 'xa rollback' ok without prepared - case TX_ENDED_STATE: + + // 'xa rollback' ok without prepared + } else if (mysqlCon.getXaStatus() == TxState.TX_ENDED_STATE) { mysqlCon.setXaStatus(TxState.TX_ROLLBACKED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); mysqlCon.setXaStatus(TxState.TX_INITIALIZE_STATE); @@ -187,24 +176,22 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { session.setXaState(TxState.TX_INITIALIZE_STATE); cleanAndFeedback(); } - break; - // 'xa rollback' ok - case TX_PREPARED_STATE: - // we dont' konw if the conn prepared or not - case TX_PREPARE_UNCONNECT_STATE: - case TX_ROLLBACK_FAILED_STATE: + + // 'xa rollback' ok + } else if (mysqlCon.getXaStatus() == TxState.TX_PREPARED_STATE || mysqlCon.getXaStatus() == TxState.TX_PREPARE_UNCONNECT_STATE || mysqlCon.getXaStatus() == TxState.TX_ROLLBACK_FAILED_STATE) {// we dont' konw if the conn prepared or not + + mysqlCon.setXaStatus(TxState.TX_ROLLBACKED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); mysqlCon.setXaStatus(TxState.TX_INITIALIZE_STATE); if (decrementCountBy(1)) { - if(session.getXaState()== TxState.TX_PREPARED_STATE){ + if (session.getXaState() == TxState.TX_PREPARED_STATE) { session.setXaState(TxState.TX_INITIALIZE_STATE); } cleanAndFeedback(); } - break; - default: - // LOGGER.error("Wrong XA status flag!"); + + } else {// LOGGER.error("Wrong XA status flag!"); } } } @@ -213,9 +200,7 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { public void errorResponse(byte[] err, BackendConnection conn) { if (conn instanceof MySQLConnection) { MySQLConnection mysqlCon = (MySQLConnection) conn; - switch (mysqlCon.getXaStatus()) { - // 'xa end' err - case TX_STARTED_STATE: + if (mysqlCon.getXaStatus() == TxState.TX_STARTED_STATE) { mysqlCon.quit(); mysqlCon.setXaStatus(TxState.TX_ROLLBACKED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); @@ -223,9 +208,9 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { session.setXaState(TxState.TX_ENDED_STATE); rollback(); } - break; - // 'xa rollback' ok without prepared - case TX_ENDED_STATE: + + // 'xa rollback' ok without prepared + } else if (mysqlCon.getXaStatus() == TxState.TX_ENDED_STATE) { mysqlCon.quit(); mysqlCon.setXaStatus(TxState.TX_ROLLBACKED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); @@ -233,10 +218,9 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { session.setXaState(TxState.TX_INITIALIZE_STATE); cleanAndFeedback(); } - break; - // 'xa rollback' err - case TX_ROLLBACK_FAILED_STATE: - case TX_PREPARED_STATE: + + // 'xa rollback' err + } else if (mysqlCon.getXaStatus() == TxState.TX_ROLLBACK_FAILED_STATE || mysqlCon.getXaStatus() == TxState.TX_PREPARED_STATE) { mysqlCon.setXaStatus(TxState.TX_ROLLBACK_FAILED_STATE); mysqlCon.quit(); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); @@ -244,9 +228,9 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { if (decrementCountBy(1)) { cleanAndFeedback(); } - break; - // we dont' konw if the conn prepared or not - case TX_PREPARE_UNCONNECT_STATE: + + // we dont' konw if the conn prepared or not + } else if (mysqlCon.getXaStatus() == TxState.TX_PREPARE_UNCONNECT_STATE) { ErrorPacket errPacket = new ErrorPacket(); errPacket.read(err); if (errPacket.errno == ErrorCode.ER_XAER_NOTA) { @@ -267,9 +251,8 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { cleanAndFeedback(); } } - break; - default: - // LOGGER.error("Wrong XA status flag!"); + + } else {// LOGGER.error("Wrong XA status flag!"); } } } @@ -278,9 +261,7 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { public void connectionError(Throwable e, BackendConnection conn) { if (conn instanceof MySQLConnection) { MySQLConnection mysqlCon = (MySQLConnection) conn; - switch (mysqlCon.getXaStatus()) { - // 'xa end' connectionError - case TX_STARTED_STATE: + if (mysqlCon.getXaStatus() == TxState.TX_STARTED_STATE) { mysqlCon.quit(); mysqlCon.setXaStatus(TxState.TX_ROLLBACKED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); @@ -288,8 +269,9 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { session.setXaState(TxState.TX_ENDED_STATE); rollback(); } - // 'xa rollback' ok without prepared - case TX_ENDED_STATE: + + // 'xa rollback' ok without prepared + } else if (mysqlCon.getXaStatus() == TxState.TX_ENDED_STATE) { mysqlCon.quit(); mysqlCon.setXaStatus(TxState.TX_ROLLBACKED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); @@ -297,9 +279,9 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { session.setXaState(TxState.TX_INITIALIZE_STATE); cleanAndFeedback(); } - break; - // 'xa rollback' err - case TX_PREPARED_STATE: + + // 'xa rollback' err + } else if (mysqlCon.getXaStatus() == TxState.TX_PREPARED_STATE) { mysqlCon.setXaStatus(TxState.TX_ROLLBACK_FAILED_STATE); mysqlCon.quit(); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); @@ -307,17 +289,16 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { if (decrementCountBy(1)) { cleanAndFeedback(); } - break; - // we dont' konw if the conn prepared or not - case TX_PREPARE_UNCONNECT_STATE: + + // we dont' konw if the conn prepared or not + } else if (mysqlCon.getXaStatus() == TxState.TX_PREPARE_UNCONNECT_STATE) { session.setXaState(TxState.TX_ROLLBACK_FAILED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); if (decrementCountBy(1)) { cleanAndFeedback(); } - break; - default: - // LOGGER.error("Wrong XA status flag!"); + + } else {// LOGGER.error("Wrong XA status flag!"); } } } @@ -327,9 +308,7 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { this.setFail(reason); if (conn instanceof MySQLConnection) { MySQLConnection mysqlCon = (MySQLConnection) conn; - switch (mysqlCon.getXaStatus()) { - // 'xa end' err - case TX_STARTED_STATE: + if (mysqlCon.getXaStatus() == TxState.TX_STARTED_STATE) { mysqlCon.quit(); mysqlCon.setXaStatus(TxState.TX_ROLLBACKED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); @@ -337,8 +316,9 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { session.setXaState(TxState.TX_ENDED_STATE); rollback(); } - // 'xa rollback' ok without prepared - case TX_ENDED_STATE: + + // 'xa rollback' ok without prepared + } else if (mysqlCon.getXaStatus() == TxState.TX_ENDED_STATE) { mysqlCon.quit(); mysqlCon.setXaStatus(TxState.TX_ROLLBACKED_STATE); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); @@ -346,9 +326,9 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { session.setXaState(TxState.TX_INITIALIZE_STATE); cleanAndFeedback(); } - break; - // 'xa rollback' err - case TX_PREPARED_STATE: + + // 'xa rollback' err + } else if (mysqlCon.getXaStatus() == TxState.TX_PREPARED_STATE) { mysqlCon.setXaStatus(TxState.TX_ROLLBACK_FAILED_STATE); mysqlCon.quit(); XAStateLog.saveXARecoverylog(session.getSessionXaID(), mysqlCon); @@ -356,18 +336,14 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { if (decrementCountBy(1)) { cleanAndFeedback(); } - break; - default: - // LOGGER.error("Wrong XA status flag!"); + + } else {// LOGGER.error("Wrong XA status flag!"); } } } private void cleanAndFeedback() { - switch (session.getXaState()) { - // rollbak success - case TX_INITIALIZE_STATE: - // clear all resources + if (session.getXaState() == TxState.TX_INITIALIZE_STATE) {// clear all resources XAStateLog.saveXARecoverylog(session.getSessionXaID(), TxState.TX_ROLLBACKED_STATE); //取消限制 session.cancelableStatusSet(NonBlockingSession.CANCEL_STATUS_INIT); @@ -377,20 +353,18 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { return; } session.getSource().write(send); - break; - //partitionly commited,must commit again - case TX_ROLLBACK_FAILED_STATE: - case TX_PREPARED_STATE: + + //partitionly commited,must commit again + } else if (session.getXaState() == TxState.TX_ROLLBACK_FAILED_STATE || session.getXaState() == TxState.TX_PREPARED_STATE) { MySQLConnection errConn = session.releaseExcept(session.getXaState()); if (errConn != null) { XAStateLog.saveXARecoverylog(session.getSessionXaID(), session.getXaState()); if (++try_rollback_times < ROLLBACK_TIMES) { // 多试几次 rollback(); - } - else { + } else { StringBuffer closeReason = new StringBuffer("ROLLBCAK FAILED but it will try to ROLLBACK repeatedly in backend until it is success!"); - if(error!= null){ + if (error != null) { closeReason.append(", the ERROR is "); closeReason.append(error); } @@ -407,9 +381,9 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { session.getSource().write(toSend); } } - break; - // rollbak success,but closed coon must remove - default: + + // rollbak success,but closed coon must remove + } else { removeQuitConn(); XAStateLog.saveXARecoverylog(session.getSessionXaID(), TxState.TX_ROLLBACKED_STATE); session.setXaState(TxState.TX_INITIALIZE_STATE); @@ -418,7 +392,7 @@ public class XARollbackNodesHandler extends AbstractRollbackNodesHandler { return; } session.getSource().write(sendData); - break; + } } private void removeQuitConn() { diff --git a/src/main/java/io/mycat/backend/mysql/nio/handler/util/HandlerTool.java b/src/main/java/io/mycat/backend/mysql/nio/handler/util/HandlerTool.java index 60492abfd..779975f7f 100644 --- a/src/main/java/io/mycat/backend/mysql/nio/handler/util/HandlerTool.java +++ b/src/main/java/io/mycat/backend/mysql/nio/handler/util/HandlerTool.java @@ -85,28 +85,27 @@ public class HandlerTool { Item ret = null; if (sel.basicConstItem()) return sel; - switch (sel.type()) { - case FUNC_ITEM: - case COND_ITEM: + Item.ItemType i = sel.type(); + if (i == Item.ItemType.FUNC_ITEM || i == Item.ItemType.COND_ITEM) { ItemFunc func = (ItemFunc) sel; - if (func.getPushDownName()==null ||func.getPushDownName().length()==0) { + if (func.getPushDownName() == null || func.getPushDownName().length() == 0) { // 自己计算 ret = createFunctionItem(func, fields, startIndex, allPushDown, type, charset); } else { ret = createFieldItem(func, fields, startIndex); } - break; - case SUM_FUNC_ITEM: + + } else if (i == Item.ItemType.SUM_FUNC_ITEM) { ItemSum sumFunc = (ItemSum) sel; if (type != HandlerType.GROUPBY) { ret = createFieldItem(sumFunc, fields, startIndex); - } else if (sumFunc.getPushDownName()==null ||sumFunc.getPushDownName().length()==0) { + } else if (sumFunc.getPushDownName() == null || sumFunc.getPushDownName().length() == 0) { ret = createSumItem(sumFunc, fields, startIndex, allPushDown, type, charset); } else { ret = createPushDownGroupBy(sumFunc, fields, startIndex); } - break; - default: + + } else { ret = createFieldItem(sel, fields, startIndex); } if (ret == null) diff --git a/src/main/java/io/mycat/backend/mysql/store/fs/FilePath.java b/src/main/java/io/mycat/backend/mysql/store/fs/FilePath.java index f1d62de46..418d8bbd4 100644 --- a/src/main/java/io/mycat/backend/mysql/store/fs/FilePath.java +++ b/src/main/java/io/mycat/backend/mysql/store/fs/FilePath.java @@ -68,19 +68,15 @@ public abstract class FilePath { private static void registerDefaultProviders() { if (providers == null || defaultProvider == null) { Map map = Collections.synchronizedMap(new HashMap()); - for (String c : new String[] { "com.actionsky.ares.partition.store.fs.FilePathDisk", - "com.actionsky.ares.partition.store.fs.FilePathNio", - "com.actionsky.ares.partition.store.fs.FilePathNioMapped" }) { - try { - FilePath p = (FilePath) Class.forName(c).newInstance(); - map.put(p.getScheme(), p); - if (defaultProvider == null) { - defaultProvider = p; - } - } catch (Exception e) { - // ignore - the files may be excluded in purpose - } + FilePathDisk p = new FilePathDisk(); + map.put(p.getScheme(), p); + if (defaultProvider == null) { + defaultProvider = p; } + FilePathNio p2 = new FilePathNio(); + map.put(p2.getScheme(), p2); + FilePathNioMapped p3 = new FilePathNioMapped(); + map.put(p3.getScheme(), p3); providers = map; } } diff --git a/src/main/java/io/mycat/backend/mysql/store/fs/FilePathDisk.java b/src/main/java/io/mycat/backend/mysql/store/fs/FilePathDisk.java index f2b665408..353074544 100644 --- a/src/main/java/io/mycat/backend/mysql/store/fs/FilePathDisk.java +++ b/src/main/java/io/mycat/backend/mysql/store/fs/FilePathDisk.java @@ -19,6 +19,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.LockSupport; import io.mycat.config.ErrorCode; +import io.mycat.util.ResourceUtil; import io.mycat.util.exception.TmpFileException; /** @@ -277,9 +278,9 @@ public class FilePathDisk extends FilePath { if (!fileName.startsWith("/")) { fileName = "/" + fileName; } - InputStream in = getClass().getResourceAsStream(fileName); + InputStream in = ResourceUtil.getResourceAsStream(fileName); if (in == null) { - in = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); + in = ResourceUtil.getResourceAsStreamForCurrentThread(fileName); } if (in == null) { throw new FileNotFoundException("resource " + fileName); diff --git a/src/main/java/io/mycat/backend/mysql/xa/XARecoverCallback.java b/src/main/java/io/mycat/backend/mysql/xa/XARecoverCallback.java index 5ac144af5..2ab86222a 100644 --- a/src/main/java/io/mycat/backend/mysql/xa/XARecoverCallback.java +++ b/src/main/java/io/mycat/backend/mysql/xa/XARecoverCallback.java @@ -29,11 +29,11 @@ public class XARecoverCallback implements SQLQueryResultListener> result) { if (result.isSuccess()) { - LOGGER.debug("[CALLBACK][XA " + operator + "] when Mycat start"); + LOGGER.debug("[CALLBACK][XA " + operator + "] when server start"); XAStateLog.updateXARecoverylog(logEntry.getCoordinatorId(), logEntry.getHost(), logEntry.getPort(), logEntry.getSchema(), txState); XAStateLog.writeCheckpoint(logEntry.getCoordinatorId()); } else { - LOGGER.warn("[CALLBACK][XA " + operator + "] when Mycat start,but failed"); + LOGGER.warn("[CALLBACK][XA " + operator + "] when server start,but failed"); } } } diff --git a/src/main/java/io/mycat/backend/mysql/xa/recovery/impl/FileSystemRepository.java b/src/main/java/io/mycat/backend/mysql/xa/recovery/impl/FileSystemRepository.java index 1702a7376..2966a4c50 100644 --- a/src/main/java/io/mycat/backend/mysql/xa/recovery/impl/FileSystemRepository.java +++ b/src/main/java/io/mycat/backend/mysql/xa/recovery/impl/FileSystemRepository.java @@ -48,8 +48,8 @@ public class FileSystemRepository implements Repository{ // ConfigProperties configProperties = Configuration.getConfigProperties(); // String baseDir = configProperties.getLogBaseDir(); // String baseName = configProperties.getLogBaseName(); - MycatConfig mycatconfig = MycatServer.getInstance().getConfig(); - SystemConfig systemConfig = mycatconfig.getSystem(); + MycatConfig config = MycatServer.getInstance().getConfig(); + SystemConfig systemConfig = config.getSystem(); String baseDir =systemConfig.getXARecoveryLogBaseDir(); String baseName = systemConfig.getXARecoveryLogBaseName(); diff --git a/src/main/java/io/mycat/cache/CacheService.java b/src/main/java/io/mycat/cache/CacheService.java index c4549a93f..bb3cadec3 100644 --- a/src/main/java/io/mycat/cache/CacheService.java +++ b/src/main/java/io/mycat/cache/CacheService.java @@ -23,6 +23,10 @@ */ package io.mycat.cache; +import io.mycat.cache.impl.EnchachePooFactory; +import io.mycat.cache.impl.LevelDBCachePooFactory; +import io.mycat.cache.impl.MapDBCachePooFactory; +import io.mycat.util.ResourceUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,8 +68,7 @@ public class CacheService { private void init(boolean isLowerCaseTableNames) throws Exception { Properties props = new Properties(); - props.load(CacheService.class - .getResourceAsStream("/cacheservice.properties")); + props.load(ResourceUtil.getResourceAsStream("/cacheservice.properties")); final String poolFactoryPref = "factory."; final String poolKeyPref = "pool."; final String layedPoolKeyPref = "layedpool."; @@ -143,9 +146,23 @@ public class CacheService { private void createPoolFactory(String factryType, String factryClassName) throws Exception { - CachePoolFactory factry = (CachePoolFactory) Class.forName( - factryClassName).newInstance(); - poolFactorys.put(factryType, factry); + String lowerClass = factryClassName.toLowerCase(); + switch(lowerClass){ + case "ehcache": + poolFactorys.put(factryType, new EnchachePooFactory()); + break; + case "leveldb": + poolFactorys.put(factryType, new LevelDBCachePooFactory()); + break; + case "mapdb": + poolFactorys.put(factryType, new MapDBCachePooFactory()); + break; + default: + CachePoolFactory factry = (CachePoolFactory) Class.forName( + factryClassName).newInstance(); + poolFactorys.put(factryType, factry); + } + } diff --git a/src/main/java/io/mycat/config/Alarms.java b/src/main/java/io/mycat/config/Alarms.java index f954db8b6..8b1ac3e7f 100644 --- a/src/main/java/io/mycat/config/Alarms.java +++ b/src/main/java/io/mycat/config/Alarms.java @@ -30,7 +30,7 @@ package io.mycat.config; */ public interface Alarms { /** 默认报警关键词 **/ - public static final String DEFAULT = "#!MyCat#"; + public static final String DEFAULT = "#!Server#"; /** 集群无有效的节点可提供服务 **/ public static final String CLUSTER_EMPTY = "#!CLUSTER_EMPTY#"; diff --git a/src/main/java/io/mycat/config/ConfigInitializer.java b/src/main/java/io/mycat/config/ConfigInitializer.java index 8e6bdf920..40427dcf1 100644 --- a/src/main/java/io/mycat/config/ConfigInitializer.java +++ b/src/main/java/io/mycat/config/ConfigInitializer.java @@ -59,7 +59,6 @@ public class ConfigInitializer { private static final Logger LOGGER = Logger.getLogger( ConfigInitializer.class ); private volatile SystemConfig system; - private volatile MycatCluster cluster; private volatile FirewallConfig firewall; private volatile Map users; private volatile Map schemas; @@ -85,7 +84,6 @@ public class ConfigInitializer { //权限管理 this.firewall = configLoader.getFirewallConfig(); - this.cluster = initCobarCluster(configLoader); //不同类型的全局序列处理器的配置加载 if (system.getSequnceHandlerType() == SystemConfig.SEQUENCEHANDLER_MYSQLDB) { @@ -206,9 +204,6 @@ public class ConfigInitializer { return system; } - public MycatCluster getCluster() { - return cluster; - } public FirewallConfig getFirewall() { return firewall; @@ -233,10 +228,6 @@ public class ConfigInitializer { public Map> getErRelations() { return erRelations; } - private MycatCluster initCobarCluster(XMLConfigLoader configLoader) { - return new MycatCluster(configLoader.getClusterConfig()); - } - private Map initDataHosts(SchemaLoader schemaLoader) { Map nodeConfs = schemaLoader.getDataHosts(); //根据DataHost建立PhysicalDBPool,其实就是实际数据库连接池,每个DataHost对应一个PhysicalDBPool diff --git a/src/main/java/io/mycat/config/MycatCluster.java b/src/main/java/io/mycat/config/MycatCluster.java deleted file mode 100644 index 9b1f47173..000000000 --- a/src/main/java/io/mycat/config/MycatCluster.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2013, OpenCloudDB/MyCAT and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software;Designed and Developed mainly by many Chinese - * opensource volunteers. you can redistribute it and/or modify it under the - * terms of the GNU General Public License version 2 only, as published by the - * Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Any questions about this component can be directed to it's project Web address - * https://code.google.com/p/opencloudb/. - * - */ -package io.mycat.config; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import io.mycat.config.model.ClusterConfig; -import io.mycat.config.model.MycatNodeConfig; - -/** - * @author mycat - */ -public final class MycatCluster { - - private final Map nodes; - private final Map> groups; - - public MycatCluster(ClusterConfig clusterConf) { - this.nodes = new HashMap(clusterConf.getNodes().size()); - this.groups = clusterConf.getGroups(); - for (MycatNodeConfig conf : clusterConf.getNodes().values()) { - String name = conf.getName(); - MycatNode node = new MycatNode(conf); - this.nodes.put(name, node); - } - } - - public Map getNodes() { - return nodes; - } - - public Map> getGroups() { - return groups; - } - -} \ No newline at end of file diff --git a/src/main/java/io/mycat/config/MycatConfig.java b/src/main/java/io/mycat/config/MycatConfig.java index 4f952ce6d..4e11b105b 100644 --- a/src/main/java/io/mycat/config/MycatConfig.java +++ b/src/main/java/io/mycat/config/MycatConfig.java @@ -56,8 +56,6 @@ public class MycatConfig { private static final int RELOAD_ALL = 3; private volatile SystemConfig system; - private volatile MycatCluster cluster; - private volatile MycatCluster _cluster; private volatile FirewallConfig firewall; private volatile FirewallConfig _firewall; private volatile Map users; @@ -90,7 +88,6 @@ public class MycatConfig { } this.firewall = confInit.getFirewall(); - this.cluster = confInit.getCluster(); //初始化重加载配置时间 this.reloadTime = TimeUtil.currentTimeMillis(); @@ -185,14 +182,6 @@ public class MycatConfig { return _erRelations; } - public MycatCluster getCluster() { - return cluster; - } - - public MycatCluster getBackupCluster() { - return _cluster; - } - public FirewallConfig getFirewall() { return firewall; } @@ -215,16 +204,16 @@ public class MycatConfig { public void reload(Map newUsers, Map newSchemas, Map newDataNodes, Map newDataHosts, - Map> newErRelations, MycatCluster newCluster, FirewallConfig newFirewall, + Map> newErRelations, FirewallConfig newFirewall, boolean reloadAll) { - apply(newUsers, newSchemas, newDataNodes, newDataHosts, newErRelations, newCluster, newFirewall, reloadAll); + apply(newUsers, newSchemas, newDataNodes, newDataHosts, newErRelations, newFirewall, reloadAll); this.reloadTime = TimeUtil.currentTimeMillis(); this.status = reloadAll ? RELOAD_ALL : RELOAD; } public boolean canRollback() { - if (_users == null || _schemas == null || _dataNodes == null || _dataHosts == null || _cluster == null + if (_users == null || _schemas == null || _dataNodes == null || _dataHosts == null || _firewall == null || status == ROLLBACK) { return false; } else { @@ -234,9 +223,9 @@ public class MycatConfig { public void rollback(Map users, Map schemas, Map dataNodes, Map dataHosts, - Map> erRelations, MycatCluster cluster, FirewallConfig firewall) { + Map> erRelations, FirewallConfig firewall) { - apply(users, schemas, dataNodes, dataHosts, erRelations, cluster, firewall, status==RELOAD_ALL); + apply(users, schemas, dataNodes, dataHosts, erRelations, firewall, status==RELOAD_ALL); this.rollbackTime = TimeUtil.currentTimeMillis(); this.status = ROLLBACK; } @@ -339,7 +328,6 @@ public class MycatConfig { Map newDataNodes, Map newDataHosts, Map> newErRelations, - MycatCluster newCluster, FirewallConfig newFirewall, boolean isLoadAll) { final ReentrantLock lock = this.lock; @@ -364,7 +352,6 @@ public class MycatConfig { this._users = this.users; this._schemas = this.schemas; - this._cluster = this.cluster; this._firewall = this.firewall; this._erRelations = this.erRelations ; // comment BY huqing.yan and will reopen later @@ -389,7 +376,6 @@ public class MycatConfig { } this.users = newUsers; this.schemas = newSchemas; - this.cluster = newCluster; this.firewall = newFirewall; this.erRelations = newErRelations; } finally { diff --git a/src/main/java/io/mycat/config/MycatPrivileges.java b/src/main/java/io/mycat/config/MycatPrivileges.java index f7a2b83c9..5cd218864 100644 --- a/src/main/java/io/mycat/config/MycatPrivileges.java +++ b/src/main/java/io/mycat/config/MycatPrivileges.java @@ -130,8 +130,8 @@ public class MycatPrivileges implements FrontendPrivileges { @Override public boolean checkFirewallWhiteHostPolicy(String user, String host) { - MycatConfig mycatConfig = MycatServer.getInstance().getConfig(); - FirewallConfig firewallConfig = mycatConfig.getFirewall(); + MycatConfig config = MycatServer.getInstance().getConfig(); + FirewallConfig firewallConfig = config.getFirewall(); if (!checkManagerPrivilege(user)) { // return and don't trigger firewall alarm @@ -144,7 +144,7 @@ public class MycatPrivileges implements FrontendPrivileges { Map> whitehost = firewallConfig.getWhitehost(); if (whitehost == null || whitehost.size() == 0) { - Map users = mycatConfig.getUsers(); + Map users = config.getUsers(); isPassed = users.containsKey(user); } else { @@ -217,19 +217,18 @@ public class MycatPrivileges implements FrontendPrivileges { return true; } int index = -1; - switch (chekctype) { - case INSERT: + if (chekctype == Checktype.INSERT) { index = 0; - break; - case UPDATE: + + } else if (chekctype == Checktype.UPDATE) { index = 1; - break; - case SELECT: + + } else if (chekctype == Checktype.SELECT) { index = 2; - break; - case DELETE: + + } else if (chekctype == Checktype.DELETE) { index = 3; - break; + } if (tablePrivilege.getDml()[index] > 0) { return true; diff --git a/src/main/java/io/mycat/config/Versions.java b/src/main/java/io/mycat/config/Versions.java index 572069cc0..a73c38aec 100644 --- a/src/main/java/io/mycat/config/Versions.java +++ b/src/main/java/io/mycat/config/Versions.java @@ -32,9 +32,10 @@ public abstract class Versions { public static final byte PROTOCOL_VERSION = 10; /**服务器版本**/ - public static byte[] SERVER_VERSION = "5.6.29-mycat-2.17.04.0-20170508103825".getBytes(); - public static byte[] VERSION_COMMENT = "MyCat Server (OpenCloundDB)".getBytes(); + public static byte[] SERVER_VERSION = "5.6.29-mycat-2.17.06.0-20170703165824".getBytes(); + public static byte[] VERSION_COMMENT = "Mycat Server".getBytes(); public static String ANNOTATION_NAME = "mycat:"; + public static final String ROOT_PREFIX = "mycat"; public static void setServerVersion(String version) { byte[] mysqlVersionPart = version.getBytes(); @@ -45,10 +46,10 @@ public abstract class Versions { } // 重新拼接mycat version字节数组 - byte[] newMycatVersion = new byte[mysqlVersionPart.length + SERVER_VERSION.length - startIndex]; - System.arraycopy(mysqlVersionPart, 0, newMycatVersion, 0, mysqlVersionPart.length); - System.arraycopy(SERVER_VERSION, startIndex, newMycatVersion, mysqlVersionPart.length, + byte[] newVersion = new byte[mysqlVersionPart.length + SERVER_VERSION.length - startIndex]; + System.arraycopy(mysqlVersionPart, 0, newVersion, 0, mysqlVersionPart.length); + System.arraycopy(SERVER_VERSION, startIndex, newVersion, mysqlVersionPart.length, SERVER_VERSION.length - startIndex); - SERVER_VERSION = newMycatVersion; + SERVER_VERSION = newVersion; } } diff --git a/src/main/java/io/mycat/config/Versions.template b/src/main/java/io/mycat/config/Versions.template index 25eb0caa1..0c538de29 100644 --- a/src/main/java/io/mycat/config/Versions.template +++ b/src/main/java/io/mycat/config/Versions.template @@ -35,6 +35,7 @@ public abstract class Versions { public static byte[] SERVER_VERSION = "@server-version@".getBytes(); public static byte[] VERSION_COMMENT = "@version-comment@".getBytes(); public static String ANNOTATION_NAME = "@annotation-name@"; + public static final String ROOT_PREFIX = "@root_prefix@"; public static void setServerVersion(String version) { byte[] mysqlVersionPart = version.getBytes(); @@ -45,10 +46,10 @@ public abstract class Versions { } // 重新拼接mycat version字节数组 - byte[] newMycatVersion = new byte[mysqlVersionPart.length + SERVER_VERSION.length - startIndex]; - System.arraycopy(mysqlVersionPart, 0, newMycatVersion, 0, mysqlVersionPart.length); - System.arraycopy(SERVER_VERSION, startIndex, newMycatVersion, mysqlVersionPart.length, + byte[] newVersion = new byte[mysqlVersionPart.length + SERVER_VERSION.length - startIndex]; + System.arraycopy(mysqlVersionPart, 0, newVersion, 0, mysqlVersionPart.length); + System.arraycopy(SERVER_VERSION, startIndex, newVersion, mysqlVersionPart.length, SERVER_VERSION.length - startIndex); - SERVER_VERSION = newMycatVersion; + SERVER_VERSION = newVersion; } } diff --git a/src/main/java/io/mycat/config/classloader/DynaClassLoader.java b/src/main/java/io/mycat/config/classloader/DynaClassLoader.java index 2f39b9ef5..ae130a8ee 100644 --- a/src/main/java/io/mycat/config/classloader/DynaClassLoader.java +++ b/src/main/java/io/mycat/config/classloader/DynaClassLoader.java @@ -9,6 +9,7 @@ import java.util.Iterator; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import io.mycat.config.Versions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** @@ -121,7 +122,7 @@ public class DynaClassLoader { */ public Class loadClass(String name) throws ClassNotFoundException { if (name.startsWith("java") || name.startsWith("sun") - || name.startsWith("io.mycat")) { + || name.startsWith("io."+ Versions.ROOT_PREFIX)) { return super.loadClass(name); } DynaClass dynaClass = loadedDynaClassMap.get(name); diff --git a/src/main/java/io/mycat/config/loader/console/ZookeeperPath.java b/src/main/java/io/mycat/config/loader/console/ZookeeperPath.java index dfe8d7b11..ffe0a7b54 100644 --- a/src/main/java/io/mycat/config/loader/console/ZookeeperPath.java +++ b/src/main/java/io/mycat/config/loader/console/ZookeeperPath.java @@ -1,5 +1,7 @@ package io.mycat.config.loader.console; +import io.mycat.config.Versions; + /** * 专门用来操作zookeeper路径的文件信息 * 源文件名:ZkPath.java @@ -23,7 +25,7 @@ public enum ZookeeperPath { * 最基础的mycat节点 * @字段说明 FLOW_ZK_PATH_ONLINE */ - FLOW_ZK_PATH_BASE("mycat"), + FLOW_ZK_PATH_BASE(Versions.ROOT_PREFIX), /** * 在当前在线的节点 diff --git a/src/main/java/io/mycat/config/loader/xml/XMLConfigLoader.java b/src/main/java/io/mycat/config/loader/xml/XMLConfigLoader.java index 2fbe92f60..1472340ed 100644 --- a/src/main/java/io/mycat/config/loader/xml/XMLConfigLoader.java +++ b/src/main/java/io/mycat/config/loader/xml/XMLConfigLoader.java @@ -25,7 +25,6 @@ package io.mycat.config.loader.xml; import java.util.Map; -import io.mycat.config.model.ClusterConfig; import io.mycat.config.model.FirewallConfig; import io.mycat.config.model.SystemConfig; import io.mycat.config.model.UserConfig; @@ -39,28 +38,18 @@ public class XMLConfigLoader{ /** unmodifiable */ private final Map users; private final FirewallConfig firewall; - private final ClusterConfig cluster; public XMLConfigLoader() { XMLServerLoader serverLoader = new XMLServerLoader(); this.system = serverLoader.getSystem(); this.users = serverLoader.getUsers(); this.firewall = serverLoader.getFirewall(); - this.cluster = serverLoader.getCluster(); - } - - public ClusterConfig getClusterConfig() { - return cluster; } public FirewallConfig getFirewallConfig() { return firewall; } - public UserConfig getUserConfig(String user) { - return users.get(user); - } - public Map getUserConfigs() { return users; } diff --git a/src/main/java/io/mycat/config/loader/xml/XMLRuleLoader.java b/src/main/java/io/mycat/config/loader/xml/XMLRuleLoader.java index 58f8c2241..19b5d3ba0 100644 --- a/src/main/java/io/mycat/config/loader/xml/XMLRuleLoader.java +++ b/src/main/java/io/mycat/config/loader/xml/XMLRuleLoader.java @@ -31,6 +31,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import io.mycat.route.function.*; +import io.mycat.util.ResourceUtil; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -40,7 +42,6 @@ import io.mycat.config.model.rule.TableRuleConfig; import io.mycat.config.util.ConfigException; import io.mycat.config.util.ConfigUtil; import io.mycat.config.util.ParameterMapping; -import io.mycat.route.function.AbstractPartitionAlgorithm; import io.mycat.util.SplitUtil; /** @@ -80,8 +81,8 @@ public class XMLRuleLoader { InputStream dtd = null; InputStream xml = null; try { - dtd = XMLRuleLoader.class.getResourceAsStream(dtdFile); - xml = XMLRuleLoader.class.getResourceAsStream(xmlFile); + dtd = ResourceUtil.getResourceAsStream(dtdFile); + xml = ResourceUtil.getResourceAsStream(xmlFile); //读取出语意树 Element root = ConfigUtil.getDocument(dtd, xml) .getDocumentElement(); @@ -217,13 +218,31 @@ public class XMLRuleLoader { private AbstractPartitionAlgorithm createFunction(String name, String clazz) throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException { - Class clz = Class.forName(clazz); - //判断是否继承AbstractPartitionAlgorithm - if (!AbstractPartitionAlgorithm.class.isAssignableFrom(clz)) { - throw new IllegalArgumentException("rule function must implements " - + AbstractPartitionAlgorithm.class.getName() + ", name=" + name); + + String lowerClass = clazz.toLowerCase(); + switch(lowerClass){ + case "hash": + return new PartitionByLong(); + case "stringhash": + return new PartitionByString(); + case "enum": + return new PartitionByFileMap(); + case "numberrange": + return new AutoPartitionByLong(); + case "patternrange": + return new PartitionByPattern(); + case "date": + return new PartitionByDate(); + default: + Class clz = Class.forName(clazz); + //判断是否继承AbstractPartitionAlgorithm + if (!AbstractPartitionAlgorithm.class.isAssignableFrom(clz)) { + throw new IllegalArgumentException("rule function must implements " + + AbstractPartitionAlgorithm.class.getName() + ", name=" + name); + } + return (AbstractPartitionAlgorithm) clz.newInstance(); } - return (AbstractPartitionAlgorithm) clz.newInstance(); + } } \ No newline at end of file diff --git a/src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java b/src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java index 05303af11..fb31dacb3 100644 --- a/src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java +++ b/src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java @@ -37,6 +37,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import io.mycat.util.ResourceUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Element; @@ -129,8 +130,8 @@ public class XMLSchemaLoader implements SchemaLoader { InputStream dtd = null; InputStream xml = null; try { - dtd = XMLSchemaLoader.class.getResourceAsStream(dtdFile); - xml = XMLSchemaLoader.class.getResourceAsStream(xmlFile); + dtd = ResourceUtil.getResourceAsStream(dtdFile); + xml = ResourceUtil.getResourceAsStream(xmlFile); Element root = ConfigUtil.getDocument(dtd, xml).getDocumentElement(); //先加载所有的DataHost loadDataHosts(root); diff --git a/src/main/java/io/mycat/config/loader/xml/XMLServerLoader.java b/src/main/java/io/mycat/config/loader/xml/XMLServerLoader.java index 874b06d7b..31a7625b5 100644 --- a/src/main/java/io/mycat/config/loader/xml/XMLServerLoader.java +++ b/src/main/java/io/mycat/config/loader/xml/XMLServerLoader.java @@ -23,25 +23,8 @@ */ package io.mycat.config.loader.xml; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import com.alibaba.druid.wall.WallConfig; - import io.mycat.config.Versions; -import io.mycat.config.model.ClusterConfig; import io.mycat.config.model.FirewallConfig; import io.mycat.config.model.SystemConfig; import io.mycat.config.model.UserConfig; @@ -50,7 +33,16 @@ import io.mycat.config.util.ConfigException; import io.mycat.config.util.ConfigUtil; import io.mycat.config.util.ParameterMapping; import io.mycat.util.DecryptUtil; +import io.mycat.util.ResourceUtil; import io.mycat.util.SplitUtil; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; +import java.util.*; /** * @author mycat @@ -60,7 +52,6 @@ public class XMLServerLoader { private final SystemConfig system; private final Map users; private final FirewallConfig firewall; - private ClusterConfig cluster; public XMLServerLoader() { this.system = new SystemConfig(); @@ -81,17 +72,14 @@ public class XMLServerLoader { return firewall; } - public ClusterConfig getCluster() { - return cluster; - } private void load() { //读取server.xml配置 InputStream dtd = null; InputStream xml = null; try { - dtd = XMLServerLoader.class.getResourceAsStream("/server.dtd"); - xml = XMLServerLoader.class.getResourceAsStream("/server.xml"); + dtd = ResourceUtil.getResourceAsStream("/server.dtd"); + xml = ResourceUtil.getResourceAsStream("/server.xml"); Element root = ConfigUtil.getDocument(dtd, xml).getDocumentElement(); //加载System标签 @@ -100,9 +88,6 @@ public class XMLServerLoader { //加载User标签 loadUsers(root); - //加载集群配置 - this.cluster = new ClusterConfig(root, system.getServerPort()); - //加载全局SQL防火墙 loadFirewall(root); } catch (ConfigException e) { @@ -187,7 +172,7 @@ public class XMLServerLoader { Map props = ConfigUtil.loadElements(e); String password = (String) props.get("password"); String usingDecrypt = (String) props.get("usingDecrypt"); - String passwordDecrypt = DecryptUtil.mycatDecrypt(usingDecrypt, name, password); + String passwordDecrypt = DecryptUtil.decrypt(usingDecrypt, name, password); user.setName(name); user.setPassword(passwordDecrypt); user.setEncryptPassword(password); diff --git a/src/main/java/io/mycat/config/loader/zkprocess/comm/ZkConfig.java b/src/main/java/io/mycat/config/loader/zkprocess/comm/ZkConfig.java index 13a25f568..6968ba554 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/comm/ZkConfig.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/comm/ZkConfig.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Properties; +import io.mycat.util.ResourceUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -103,7 +104,7 @@ public class ZkConfig { private static Properties LoadMyidPropersites() { Properties pros = new Properties(); - try (InputStream configIS = ZkConfig.class.getResourceAsStream(ZK_CONFIG_FILE_NAME)) { + try (InputStream configIS = ResourceUtil.getResourceAsStream(ZK_CONFIG_FILE_NAME)) { if (configIS == null) { return null; } diff --git a/src/main/java/io/mycat/config/loader/zkprocess/comm/ZkParamCfg.java b/src/main/java/io/mycat/config/loader/zkprocess/comm/ZkParamCfg.java index ea0b1955f..544db9664 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/comm/ZkParamCfg.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/comm/ZkParamCfg.java @@ -36,12 +36,6 @@ public enum ZkParamCfg { * @字段说明 zk_CFG_MYID */ ZK_CFG_MYID("myid"), - - - MYCAT_SERVER_TYPE("type"), - - MYCAT_BOOSTER_DATAHOSTS("boosterDataHosts"), - /** * 集群中所有节点的名称信息 * @字段说明 ZK_CFG_CLUSTER_NODES diff --git a/src/main/java/io/mycat/config/loader/zkprocess/entity/Rules.java b/src/main/java/io/mycat/config/loader/zkprocess/entity/Rules.java index c49fc8f9a..d61c5a8f5 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/entity/Rules.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/entity/Rules.java @@ -7,11 +7,12 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; +import io.mycat.config.Versions; import io.mycat.config.loader.zkprocess.entity.rule.function.Function; import io.mycat.config.loader.zkprocess.entity.rule.tablerule.TableRule; @XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(namespace = "http://io.mycat/", name = "rule") +@XmlRootElement(namespace = "http://io."+ Versions.ROOT_PREFIX+"/", name = "rule") public class Rules { /** diff --git a/src/main/java/io/mycat/config/loader/zkprocess/entity/Schemas.java b/src/main/java/io/mycat/config/loader/zkprocess/entity/Schemas.java index 9f0792ca2..1439d9752 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/entity/Schemas.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/entity/Schemas.java @@ -7,12 +7,13 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; +import io.mycat.config.Versions; import io.mycat.config.loader.zkprocess.entity.schema.datahost.DataHost; import io.mycat.config.loader.zkprocess.entity.schema.datanode.DataNode; import io.mycat.config.loader.zkprocess.entity.schema.schema.Schema; @XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(namespace = "http://io.mycat/", name = "schema") +@XmlRootElement(namespace = "http://io."+ Versions.ROOT_PREFIX+"/", name = "schema") public class Schemas { /** * 配制的逻辑表信息 diff --git a/src/main/java/io/mycat/config/loader/zkprocess/entity/Server.java b/src/main/java/io/mycat/config/loader/zkprocess/entity/Server.java index 318e4472f..1434a830f 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/entity/Server.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/entity/Server.java @@ -7,11 +7,12 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import io.mycat.config.Versions; import io.mycat.config.loader.zkprocess.entity.server.System; import io.mycat.config.loader.zkprocess.entity.server.user.User; @XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(namespace = "http://io.mycat/", name = "server") +@XmlRootElement(namespace = "http://io."+ Versions.ROOT_PREFIX+"/", name = "server") public class Server { @XmlElement(required = true) diff --git a/src/main/java/io/mycat/config/loader/zkprocess/entity/package-info.java b/src/main/java/io/mycat/config/loader/zkprocess/entity/package-info.java index b4612832f..5d69886bc 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/entity/package-info.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/entity/package-info.java @@ -1,6 +1,8 @@ -@XmlSchema(xmlns = @XmlNs(prefix = "mycat", namespaceURI = "http://io.mycat/") , elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +@XmlSchema(xmlns = @XmlNs(prefix = Versions.ROOT_PREFIX, namespaceURI = "http://io."+ Versions.ROOT_PREFIX+"/") , elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package io.mycat.config.loader.zkprocess.entity; +import io.mycat.config.Versions; + import javax.xml.bind.annotation.XmlNs; import javax.xml.bind.annotation.XmlSchema; diff --git a/src/main/java/io/mycat/config/loader/zkprocess/parse/XmlProcessBase.java b/src/main/java/io/mycat/config/loader/zkprocess/parse/XmlProcessBase.java index 8920a4430..53de5c829 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/parse/XmlProcessBase.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/parse/XmlProcessBase.java @@ -22,6 +22,8 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.transform.stream.StreamSource; +import io.mycat.config.Versions; +import io.mycat.util.ResourceUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -114,7 +116,7 @@ public class XmlProcessBase { if (null != name) { marshaller.setProperty("com.sun.xml.internal.bind.xmlHeaders", - String.format("", name)); + String.format("", name)); } Path path = Paths.get(inputPath); @@ -149,7 +151,7 @@ public class XmlProcessBase { if (null != name) { marshaller.setProperty("com.sun.xml.internal.bind.xmlHeaders", - String.format("", name)); + String.format("", name)); } if (null != map && !map.isEmpty()) { @@ -184,7 +186,7 @@ public class XmlProcessBase { */ public Object baseParseXmlToBean(String fileName) throws JAXBException, XMLStreamException { // 搜索当前转化的文件 - InputStream inputStream = XmlProcessBase.class.getResourceAsStream(fileName); + InputStream inputStream = ResourceUtil.getResourceAsStream(fileName); // 如果能够搜索到文件 if (inputStream != null) { diff --git a/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/EcachesxmlTozkLoader.java b/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/EcachesxmlTozkLoader.java index aadeef954..3939c2780 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/EcachesxmlTozkLoader.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/EcachesxmlTozkLoader.java @@ -5,6 +5,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.io.IOException; import java.io.InputStream; +import io.mycat.util.ResourceUtil; import org.apache.curator.framework.CuratorFramework; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -139,7 +140,7 @@ public class EcachesxmlTozkLoader extends ZkMultLoader implements NotifyService String path = ZookeeperPath.ZK_LOCAL_CFG_PATH.getKey() + name; // 加载数据 - InputStream input = EcachesxmlTozkLoader.class.getResourceAsStream(path); + InputStream input = ResourceUtil.getResourceAsStream(path); checkNotNull(input, "read SeqFile file curr Path :" + path + " is null! must is not null"); diff --git a/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/RulesxmlTozkLoader.java b/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/RulesxmlTozkLoader.java index 1e4e23a04..f796e2930 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/RulesxmlTozkLoader.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/RulesxmlTozkLoader.java @@ -7,6 +7,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import io.mycat.util.ResourceUtil; import org.apache.curator.framework.CuratorFramework; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -175,7 +176,7 @@ public class RulesxmlTozkLoader extends ZkMultLoader implements NotifyService { String path = ZookeeperPath.ZK_LOCAL_CFG_PATH.getKey() + name; // 加载数据 - InputStream input = RulesxmlTozkLoader.class.getResourceAsStream(path); + InputStream input = ResourceUtil.getResourceAsStream(path); checkNotNull(input, "read Map file curr Path :" + path + " is null! must is not null"); diff --git a/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/SequenceTozkLoader.java b/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/SequenceTozkLoader.java index 8da3c236d..6c48ae687 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/SequenceTozkLoader.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/SequenceTozkLoader.java @@ -3,6 +3,7 @@ package io.mycat.config.loader.zkprocess.xmltozk.listen; import java.io.IOException; import java.io.InputStream; +import io.mycat.util.ResourceUtil; import org.apache.curator.framework.CuratorFramework; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -168,7 +169,7 @@ public class SequenceTozkLoader extends ZkMultLoader implements NotifyService { String path = ZookeeperPath.ZK_LOCAL_CFG_PATH.getKey() + name; // 加载数据 - InputStream input = SequenceTozkLoader.class.getResourceAsStream(path); + InputStream input = ResourceUtil.getResourceAsStream(path); if (null != input) { diff --git a/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/ServerxmlTozkLoader.java b/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/ServerxmlTozkLoader.java index a6e09c79a..5139fb525 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/ServerxmlTozkLoader.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/xmltozk/listen/ServerxmlTozkLoader.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.List; +import io.mycat.util.ResourceUtil; import org.apache.curator.framework.CuratorFramework; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -194,7 +195,7 @@ public class ServerxmlTozkLoader extends ZkMultLoader implements NotifyService { String path = ZookeeperPath.ZK_LOCAL_CFG_PATH.getKey() + name; // 加载数据 - InputStream input = SequenceTozkLoader.class.getResourceAsStream(path); + InputStream input = ResourceUtil.getResourceAsStream(path); if (null != input) { diff --git a/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/BinlogPauseStatusListener.java b/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/BinlogPauseStatusListener.java index 601f4b7fb..1e5716d71 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/BinlogPauseStatusListener.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/BinlogPauseStatusListener.java @@ -59,34 +59,33 @@ public class BinlogPauseStatusListener extends ZkMultLoader implements NotifySe } String binlogPause = basePath + ShowBinlogStatus.BINLOG_PAUSE_INSTANCES; String instancePath = ZKPaths.makePath(binlogPause, ZkConfig.getInstance().getValue(ZkParamCfg.ZK_CFG_MYID)); - switch (pauseInfo.getStatus()) { - case ON: - MycatServer.getInstance().getBackupLocked().compareAndSet(false, true); - if (ShowBinlogStatus.waitAllSession()) { - try { - ZKUtils.createTempNode(binlogPause, ZkConfig.getInstance().getValue(ZkParamCfg.ZK_CFG_MYID)); - } catch (Exception e) { - LOGGER.warn("create binlogPause instance failed", e); - } - } - break; - case TIMEOUT: - ShowBinlogStatus.setWaiting(false); - break; - case OFF: - while(ShowBinlogStatus.isWaiting()){ - LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(1000)); - } + if (pauseInfo.getStatus() == BinlogPause.BinlogPauseStatus.ON) { + MycatServer.getInstance().getBackupLocked().compareAndSet(false, true); + if (ShowBinlogStatus.waitAllSession()) { try { - if (this.getCurator().checkExists().forPath(instancePath) != null) { - this.getCurator().delete().forPath(instancePath); - } + ZKUtils.createTempNode(binlogPause, ZkConfig.getInstance().getValue(ZkParamCfg.ZK_CFG_MYID)); } catch (Exception e) { - LOGGER.warn("delete binlogPause instance failed", e); - } finally { - MycatServer.getInstance().getBackupLocked().compareAndSet(true, false); + LOGGER.warn("create binlogPause instance failed", e); } - break; + } + + } else if (pauseInfo.getStatus() == BinlogPause.BinlogPauseStatus.TIMEOUT) { + ShowBinlogStatus.setWaiting(false); + + } else if (pauseInfo.getStatus() == BinlogPause.BinlogPauseStatus.OFF) { + while (ShowBinlogStatus.isWaiting()) { + LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(1000)); + } + try { + if (this.getCurator().checkExists().forPath(instancePath) != null) { + this.getCurator().delete().forPath(instancePath); + } + } catch (Exception e) { + LOGGER.warn("delete binlogPause instance failed", e); + } finally { + MycatServer.getInstance().getBackupLocked().compareAndSet(true, false); + } + } diff --git a/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/EcacheszkToxmlLoader.java b/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/EcacheszkToxmlLoader.java index 62c1cc9b1..cf7ab7639 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/EcacheszkToxmlLoader.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/EcacheszkToxmlLoader.java @@ -7,6 +7,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import io.mycat.util.ResourceUtil; import org.apache.curator.framework.CuratorFramework; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -134,8 +135,7 @@ public class EcacheszkToxmlLoader extends ZkMultLoader implements NotifyService Ehcache ehcache = parseJsonEhcacheService.parseJsonToBean(ehcacheZkDirectory.getDataValue()); - String outputPath = EcacheszkToxmlLoader.class.getClassLoader() - .getResource(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()).getPath(); + String outputPath = ResourceUtil.getResourcePathFromRoot(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()); outputPath=new File(outputPath).getPath()+File.separator; outputPath += EHCACHE_NAME; @@ -172,8 +172,7 @@ public class EcacheszkToxmlLoader extends ZkMultLoader implements NotifyService private void writeCacheservice(String name, String value) { // 加载数据 - String path = RuleszkToxmlLoader.class.getClassLoader().getResource(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()) - .getPath(); + String path = ResourceUtil.getResourcePathFromRoot(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()); checkNotNull(path, "write ecache file curr Path :" + path + " is null! must is not null"); path=new File(path).getPath()+File.separator; diff --git a/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/RuleszkToxmlLoader.java b/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/RuleszkToxmlLoader.java index 5b11eec5b..0cd040e8b 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/RuleszkToxmlLoader.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/RuleszkToxmlLoader.java @@ -11,6 +11,7 @@ import java.util.List; import io.mycat.MycatServer; import io.mycat.manager.response.ReloadConfig; +import io.mycat.util.ResourceUtil; import org.apache.curator.framework.CuratorFramework; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -129,8 +130,7 @@ public class RuleszkToxmlLoader extends ZkMultLoader implements NotifyService { LOGGER.info("RuleszkToxmlLoader notifyProcess write mapFile is success "); // 数配制信息写入文件 - String path = RuleszkToxmlLoader.class.getClassLoader().getResource(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()) - .getPath(); + String path = ResourceUtil.getResourcePathFromRoot(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()); path=new File(path).getPath()+File.separator; path =path+WRITEPATH; @@ -244,8 +244,7 @@ public class RuleszkToxmlLoader extends ZkMultLoader implements NotifyService { private void writeMapFile(String name, String value) { // 加载数据 - String path = RuleszkToxmlLoader.class.getClassLoader().getResource(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()) - .getPath(); + String path = ResourceUtil.getResourcePathFromRoot(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()); checkNotNull(path, "write Map file curr Path :" + path + " is null! must is not null"); path=new File(path).getPath()+File.separator; diff --git a/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/SchemaszkToxmlLoader.java b/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/SchemaszkToxmlLoader.java index 3d2f42ebf..14f1144ef 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/SchemaszkToxmlLoader.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/SchemaszkToxmlLoader.java @@ -5,6 +5,7 @@ import java.util.List; import io.mycat.MycatServer; import io.mycat.manager.response.ReloadConfig; +import io.mycat.util.ResourceUtil; import org.apache.curator.framework.CuratorFramework; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -122,8 +123,7 @@ public class SchemaszkToxmlLoader extends ZkMultLoader implements NotifyService LOGGER.info("SchemasLoader notifyProcess zk to object zk schema Object :" + schema); - String path = SchemaszkToxmlLoader.class.getClassLoader() - .getResource(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()).getPath(); + String path = ResourceUtil.getResourcePathFromRoot(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()); path=new File(path).getPath()+File.separator; path += WRITEPATH; diff --git a/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/SequenceTopropertiesLoader.java b/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/SequenceTopropertiesLoader.java index 5981ae737..980242d56 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/SequenceTopropertiesLoader.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/SequenceTopropertiesLoader.java @@ -9,6 +9,7 @@ import java.io.IOException; import io.mycat.MycatServer; import io.mycat.manager.response.ReloadConfig; +import io.mycat.util.ResourceUtil; import org.apache.curator.framework.CuratorFramework; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -268,8 +269,7 @@ public class SequenceTopropertiesLoader extends ZkMultLoader implements NotifySe private void writeMapFile(String name, String value) { // 加载数据 - String path = RuleszkToxmlLoader.class.getClassLoader().getResource(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()) - .getPath(); + String path = ResourceUtil.getResourcePathFromRoot(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()); checkNotNull(path, "write Map file curr Path :" + path + " is null! must is not null"); diff --git a/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/ServerzkToxmlLoader.java b/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/ServerzkToxmlLoader.java index c868f8509..2b7d85dbe 100644 --- a/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/ServerzkToxmlLoader.java +++ b/src/main/java/io/mycat/config/loader/zkprocess/zktoxml/listen/ServerzkToxmlLoader.java @@ -11,6 +11,7 @@ import java.util.List; import io.mycat.MycatServer; import io.mycat.config.loader.zkprocess.comm.ZkConfig; import io.mycat.manager.response.ReloadConfig; +import io.mycat.util.ResourceUtil; import org.apache.curator.framework.CuratorFramework; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -138,8 +139,7 @@ public class ServerzkToxmlLoader extends ZkMultLoader implements NotifyService { LOGGER.info("ServerzkToxmlLoader notifyProcess zk to object zk server Object :" + server); // 数配制信息写入文件 - String path = ServerzkToxmlLoader.class.getClassLoader().getResource(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()) - .getPath(); + String path = ResourceUtil.getResourcePathFromRoot(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()); path=new File(path).getPath()+File.separator; path += WRITEPATH; @@ -248,8 +248,7 @@ public class ServerzkToxmlLoader extends ZkMultLoader implements NotifyService { private void writeProperties(String name, String value) { // 加载数据 - String path = RuleszkToxmlLoader.class.getClassLoader().getResource(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()) - .getPath(); + String path = ResourceUtil.getResourcePathFromRoot(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey()); checkNotNull(path, "write properties curr Path :" + path + " is null! must is not null"); diff --git a/src/main/java/io/mycat/config/model/ClusterConfig.java b/src/main/java/io/mycat/config/model/ClusterConfig.java deleted file mode 100644 index 08dc053bd..000000000 --- a/src/main/java/io/mycat/config/model/ClusterConfig.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2013, OpenCloudDB/MyCAT and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software;Designed and Developed mainly by many Chinese - * opensource volunteers. you can redistribute it and/or modify it under the - * terms of the GNU General Public License version 2 only, as published by the - * Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Any questions about this component can be directed to it's project Web address - * https://code.google.com/p/opencloudb/. - * - */ -package io.mycat.config.model; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import io.mycat.config.util.ConfigException; -import io.mycat.config.util.ConfigUtil; -import io.mycat.util.SplitUtil; - -/** - * @author mycat - */ -public class ClusterConfig { - private final Map nodes; - private final Map> groups; - - public ClusterConfig(Element root, int port) { - nodes = Collections.unmodifiableMap(loadNode(root, port)); - groups = Collections.unmodifiableMap(loadGroup(root, nodes)); - } - - public Map getNodes() { - return nodes; - } - - public Map> getGroups() { - return groups; - } - - private static Map loadNode(Element root, int port) { - Map nodes = new HashMap(); - NodeList list = root.getElementsByTagName("node"); - Set hostSet = new HashSet(); - for (int i = 0, n = list.getLength(); i < n; i++) { - Node node = list.item(i); - if (node instanceof Element) { - Element element = (Element) node; - String name = element.getAttribute("name").trim(); - if (nodes.containsKey(name)) { - throw new ConfigException("node name duplicated :" + name); - } - - Map props = ConfigUtil.loadElements(element); - String host = (String) props.get("host"); - if (null == host || "".equals(host)) { - throw new ConfigException("host empty in node: " + name); - } - if (hostSet.contains(host)) { - throw new ConfigException("node host duplicated :" + host); - } - - String wei = (String) props.get("weight"); - if (null == wei || "".equals(wei)) { - throw new ConfigException("weight should not be null in host:" + host); - } - int weight = Integer.parseInt(wei); - if (weight <= 0) { - throw new ConfigException("weight should be > 0 in host:" + host + " weight:" + weight); - } - - MycatNodeConfig conf = new MycatNodeConfig(name, host, port, weight); - nodes.put(name, conf); - hostSet.add(host); - } - } - return nodes; - } - - private static Map> loadGroup(Element root, Map nodes) { - Map> groups = new HashMap>(); - NodeList list = root.getElementsByTagName("group"); - for (int i = 0, n = list.getLength(); i < n; i++) { - Node node = list.item(i); - if (node instanceof Element) { - Element e = (Element) node; - String groupName = e.getAttribute("name").trim(); - if (groups.containsKey(groupName)) { - throw new ConfigException("group duplicated : " + groupName); - } - - Map props = ConfigUtil.loadElements(e); - String value = (String) props.get("nodeList"); - if (null == value || "".equals(value)) { - throw new ConfigException("group should contain 'nodeList'"); - } - - String[] sList = SplitUtil.split(value, ',', true); - - if (null == sList || sList.length == 0) { - throw new ConfigException("group should contain 'nodeList'"); - } - - for (String s : sList) { - if (!nodes.containsKey(s)) { - throw new ConfigException("[ node :" + s + "] in [ group:" + groupName + "] doesn't exist!"); - } - } - List nodeList = Arrays.asList(sList); - groups.put(groupName, nodeList); - } - } - if (!groups.containsKey("default")) { - List nodeList = new ArrayList(nodes.keySet()); - groups.put("default", nodeList); - } - return groups; - } -} \ No newline at end of file diff --git a/src/main/java/io/mycat/config/model/FirewallConfig.java b/src/main/java/io/mycat/config/model/FirewallConfig.java index 8a898536d..a0c7ccfef 100644 --- a/src/main/java/io/mycat/config/model/FirewallConfig.java +++ b/src/main/java/io/mycat/config/model/FirewallConfig.java @@ -35,6 +35,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import io.mycat.util.ResourceUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; @@ -200,7 +201,7 @@ public final class FirewallConfig { public InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws SAXException, java.io.IOException{ if (systemId.contains("server.dtd")){ //InputSource is = new InputSource(new ByteArrayInputStream("".getBytes())); - InputStream dtd = XMLServerLoader.class.getResourceAsStream("/server.dtd"); + InputStream dtd = ResourceUtil.getResourceAsStream("/server.dtd"); InputSource is = new InputSource(dtd); return is; } else { @@ -208,13 +209,4 @@ public final class FirewallConfig { } } } -// public static void main(String[] args) throws Exception { -// List userConfigs = new ArrayList(); -// UserConfig user = new UserConfig(); -// user.setName("mycat"); -// userConfigs.add(user); -// updateToFile("127.0.0.1",userConfigs); -// } - - } \ No newline at end of file diff --git a/src/main/java/io/mycat/config/model/SystemConfig.java b/src/main/java/io/mycat/config/model/SystemConfig.java index e0368ce2f..1917f527a 100644 --- a/src/main/java/io/mycat/config/model/SystemConfig.java +++ b/src/main/java/io/mycat/config/model/SystemConfig.java @@ -68,7 +68,7 @@ public final class SystemConfig { private static final boolean DEFAULT_USE_ZK_SWITCH = true; private static final boolean DEFAULT_LOWER_CASE = true; private static final String DEFAULT_TRANSACTION_BASE_DIR = "txlogs"; - private static final String DEFAULT_TRANSACTION_BASE_NAME = "mycat-tx"; + private static final String DEFAULT_TRANSACTION_BASE_NAME = "server-tx"; private static final int DEFAULT_TRANSACTION_ROTATE_SIZE = 16; private static final long CHECKTABLECONSISTENCYPERIOD = 30 * 60 * 1000; // 全局表一致性检测任务,默认24小时调度一次 @@ -128,7 +128,7 @@ public final class SystemConfig { private int usingAIO = 0; private int packetHeaderSize = 4; private int maxPacketSize = 16 * 1024 * 1024; - private int mycatNodeId=1; + private int serverNodeId =1; private int useCompression =0; private int useSqlStat = 1; @@ -742,12 +742,12 @@ public final class SystemConfig { this.usingAIO = usingAIO; } - public int getMycatNodeId() { - return mycatNodeId; + public int getServerNodeId() { + return serverNodeId; } - public void setMycatNodeId(int mycatNodeId) { - this.mycatNodeId = mycatNodeId; + public void setServerNodeId(int serverNodeId) { + this.serverNodeId = serverNodeId; } @Override @@ -791,7 +791,7 @@ public final class SystemConfig { + ", usingAIO=" + usingAIO + ", packetHeaderSize=" + packetHeaderSize + ", maxPacketSize=" + maxPacketSize - + ", mycatNodeId=" + mycatNodeId + + ", serverNodeId=" + serverNodeId + "]"; } diff --git a/src/main/java/io/mycat/log/transaction/TxnLogProcessor.java b/src/main/java/io/mycat/log/transaction/TxnLogProcessor.java index 79f85f6f5..a64399f72 100644 --- a/src/main/java/io/mycat/log/transaction/TxnLogProcessor.java +++ b/src/main/java/io/mycat/log/transaction/TxnLogProcessor.java @@ -28,8 +28,8 @@ public class TxnLogProcessor extends Thread { public TxnLogProcessor(BufferPool bufferPool) { this.dateFormat = new ISO8601DateFormat(); this.queue = new LinkedBlockingQueue(256); - MycatConfig mycatconfig = MycatServer.getInstance().getConfig(); - SystemConfig systemConfig = mycatconfig.getSystem(); + MycatConfig config = MycatServer.getInstance().getConfig(); + SystemConfig systemConfig = config.getSystem(); this.store = new DailyRotateLogStore(systemConfig.getTransactionLogBaseDir(), systemConfig.getTransactionLogBaseName(),"log",systemConfig.getTransactionRatateSize()); } diff --git a/src/main/java/io/mycat/manager/ManagerPrivileges.java b/src/main/java/io/mycat/manager/ManagerPrivileges.java index df2a17301..a9ed60c82 100644 --- a/src/main/java/io/mycat/manager/ManagerPrivileges.java +++ b/src/main/java/io/mycat/manager/ManagerPrivileges.java @@ -64,8 +64,8 @@ public class ManagerPrivileges extends MycatPrivileges { } protected boolean checkManagerPrivilege(String user) { - MycatConfig mycatConfig = MycatServer.getInstance().getConfig(); - UserConfig rUser = mycatConfig.getUsers().get(user); + MycatConfig config = MycatServer.getInstance().getConfig(); + UserConfig rUser = config.getUsers().get(user); // Manager privilege must be assign explicitly if (rUser == null || rUser.isManager() == false) return false; diff --git a/src/main/java/io/mycat/manager/handler/ConfFileHandler.java b/src/main/java/io/mycat/manager/handler/ConfFileHandler.java index afc4a8c4e..c9b61bc3d 100644 --- a/src/main/java/io/mycat/manager/handler/ConfFileHandler.java +++ b/src/main/java/io/mycat/manager/handler/ConfFileHandler.java @@ -39,6 +39,7 @@ import java.util.Date; import javax.xml.parsers.ParserConfigurationException; +import io.mycat.util.ResourceUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xml.sax.SAXException; @@ -134,20 +135,20 @@ public final class ConfFileHandler { InputStream dtdStream = new ByteArrayInputStream(new byte[0]); File confDir = new File(SystemConfig.getHomePath(), "conf"); if (xmlFileName.equals("schema.xml")) { - dtdStream = MycatServer.class.getResourceAsStream("/schema.dtd"); + dtdStream = ResourceUtil.getResourceAsStream("/schema.dtd"); if (dtdStream == null) { dtdStream = new ByteArrayInputStream(readFileByBytes(new File( confDir, "schema.dtd"))); } } else if (xmlFileName.equals("server.xml")) { - dtdStream = MycatServer.class.getResourceAsStream("/server.dtd"); + dtdStream = ResourceUtil.getResourceAsStream("/server.dtd"); if (dtdStream == null) { dtdStream = new ByteArrayInputStream(readFileByBytes(new File( confDir, "server.dtd"))); } } else if (xmlFileName.equals("rule.xml")) { - dtdStream = MycatServer.class.getResourceAsStream("/rule.dtd"); + dtdStream = ResourceUtil.getResourceAsStream("/rule.dtd"); if (dtdStream == null) { dtdStream = new ByteArrayInputStream(readFileByBytes(new File( confDir, "rule.dtd"))); diff --git a/src/main/java/io/mycat/manager/handler/ShowServerLog.java b/src/main/java/io/mycat/manager/handler/ShowServerLog.java index 9d998f1e6..971641312 100644 --- a/src/main/java/io/mycat/manager/handler/ShowServerLog.java +++ b/src/main/java/io/mycat/manager/handler/ShowServerLog.java @@ -55,7 +55,7 @@ public final class ShowServerLog { .getHeader(FIELD_COUNT); private static final FieldPacket[] fields = new FieldPacket[FIELD_COUNT]; private static final EOFPacket eof = new EOFPacket(); - private static final String DEFAULT_LOGFILE = "mycat.log"; + public static final String DEFAULT_LOGFILE = "mycat.log"; private static final Logger LOGGER = LoggerFactory .getLogger(ShowServerLog.class); static { diff --git a/src/main/java/io/mycat/manager/response/ReloadConfig.java b/src/main/java/io/mycat/manager/response/ReloadConfig.java index 824e14898..de46304e3 100644 --- a/src/main/java/io/mycat/manager/response/ReloadConfig.java +++ b/src/main/java/io/mycat/manager/response/ReloadConfig.java @@ -45,7 +45,6 @@ import io.mycat.backend.datasource.PhysicalDatasource; import io.mycat.backend.mysql.nio.MySQLConnection; import io.mycat.config.ConfigInitializer; import io.mycat.config.ErrorCode; -import io.mycat.config.MycatCluster; import io.mycat.config.MycatConfig; import io.mycat.config.model.ERTable; import io.mycat.config.model.FirewallConfig; @@ -101,7 +100,6 @@ public final class ReloadConfig { Map newDataNodes = loader.getDataNodes(); Map newDataHosts = loader.getDataHosts(); Map> newErRelations = loader.getErRelations(); - MycatCluster newCluster = loader.getCluster(); FirewallConfig newFirewall = loader.getFirewall(); /* 1.2、实际链路检测 */ @@ -154,7 +152,7 @@ public final class ReloadConfig { if ( isReloadStatusOK ) { /* 2.3、 在老的配置上,应用新的配置,开始准备承接任务 */ - config.reload(newUsers, newSchemas, newDataNodes, newDataHosts, newErRelations, newCluster, newFirewall, true); + config.reload(newUsers, newSchemas, newDataNodes, newDataHosts, newErRelations, newFirewall, true); /* 2.4、 处理旧的资源 */ LOGGER.warn("1. clear old backend connection(size): " + NIOProcessor.backends_old.size()); @@ -211,11 +209,10 @@ public final class ReloadConfig { Map dataNodes = loader.getDataNodes(); Map dataHosts = loader.getDataHosts(); Map> erRelations = loader.getErRelations(); - MycatCluster cluster = loader.getCluster(); FirewallConfig firewall = loader.getFirewall(); /* 2、在老的配置上, 应用新的配置 */ - MycatServer.getInstance().getConfig().reload(users, schemas, dataNodes, dataHosts, erRelations, cluster, firewall, false); + MycatServer.getInstance().getConfig().reload(users, schemas, dataNodes, dataHosts, erRelations, firewall, false); /* 3、清理缓存 */ MycatServer.getInstance().getCacheService().clearCache(); MycatServer.getInstance().reloadMetaData(); diff --git a/src/main/java/io/mycat/manager/response/RollbackConfig.java b/src/main/java/io/mycat/manager/response/RollbackConfig.java index 142839818..444f05619 100644 --- a/src/main/java/io/mycat/manager/response/RollbackConfig.java +++ b/src/main/java/io/mycat/manager/response/RollbackConfig.java @@ -34,7 +34,6 @@ import io.mycat.MycatServer; import io.mycat.backend.datasource.PhysicalDBNode; import io.mycat.backend.datasource.PhysicalDBPool; import io.mycat.config.ErrorCode; -import io.mycat.config.MycatCluster; import io.mycat.config.MycatConfig; import io.mycat.config.model.ERTable; import io.mycat.config.model.FirewallConfig; @@ -77,7 +76,6 @@ public final class RollbackConfig { Map schemas = conf.getBackupSchemas(); Map dataNodes = conf.getBackupDataNodes(); Map dataHosts = conf.getBackupDataHosts(); - MycatCluster cluster = conf.getBackupCluster(); FirewallConfig firewall = conf.getBackupFirewall(); Map> erRelations = conf.getBackupErRelations(); @@ -106,7 +104,7 @@ public final class RollbackConfig { } // 应用回滚 - conf.rollback(users, schemas, dataNodes, dataHosts, erRelations, cluster, firewall); + conf.rollback(users, schemas, dataNodes, dataHosts, erRelations, firewall); // 处理旧的资源 for (PhysicalDBPool dn : cNodes.values()) { diff --git a/src/main/java/io/mycat/manager/response/SelectVersionComment.java b/src/main/java/io/mycat/manager/response/SelectVersionComment.java index 5aa7572d9..051618dfc 100644 --- a/src/main/java/io/mycat/manager/response/SelectVersionComment.java +++ b/src/main/java/io/mycat/manager/response/SelectVersionComment.java @@ -27,6 +27,7 @@ import java.nio.ByteBuffer; import io.mycat.backend.mysql.PacketUtil; import io.mycat.config.Fields; +import io.mycat.config.Versions; import io.mycat.manager.ManagerConnection; import io.mycat.net.mysql.EOFPacket; import io.mycat.net.mysql.FieldPacket; @@ -38,7 +39,6 @@ import io.mycat.net.mysql.RowDataPacket; */ public final class SelectVersionComment { - private static final byte[] VERSION_COMMENT = "MyCat Server (monitor)".getBytes(); private static final int FIELD_COUNT = 1; private static final ResultSetHeaderPacket header = PacketUtil.getHeader(FIELD_COUNT); private static final FieldPacket[] fields = new FieldPacket[FIELD_COUNT]; @@ -71,7 +71,7 @@ public final class SelectVersionComment { // write rows byte packetId = eof.packetId; RowDataPacket row = new RowDataPacket(FIELD_COUNT); - row.add(VERSION_COMMENT); + row.add(Versions.VERSION_COMMENT); row.packetId = ++packetId; buffer = row.write(buffer, c,true); diff --git a/src/main/java/io/mycat/manager/response/ShowDirectMemory.java b/src/main/java/io/mycat/manager/response/ShowDirectMemory.java index 943d0a084..62021a519 100644 --- a/src/main/java/io/mycat/manager/response/ShowDirectMemory.java +++ b/src/main/java/io/mycat/manager/response/ShowDirectMemory.java @@ -115,7 +115,7 @@ public class ShowDirectMemory { if(useOffHeapForMerge == 1) { ConcurrentMap concurrentHashMap = MycatServer.getInstance(). - getMyCatMemory(). + getServerMemory(). getResultMergeMemoryManager().getDirectMemorUsage(); for (Long key : concurrentHashMap.keySet()) { @@ -203,7 +203,7 @@ public class ShowDirectMemory { * 结果集合并时,总共消耗的DirectMemory内存 */ ConcurrentMap concurrentHashMap = MycatServer.getInstance(). - getMyCatMemory(). + getServerMemory(). getResultMergeMemoryManager().getDirectMemorUsage(); for (Map.Entry entry : concurrentHashMap.entrySet()) { usedforMerge += entry.getValue(); diff --git a/src/main/java/io/mycat/manager/response/ShowHelp.java b/src/main/java/io/mycat/manager/response/ShowHelp.java index ad961486a..304f0638d 100644 --- a/src/main/java/io/mycat/manager/response/ShowHelp.java +++ b/src/main/java/io/mycat/manager/response/ShowHelp.java @@ -110,7 +110,7 @@ public final class ShowHelp { // show helps.put("show @@time.current", "Report current timestamp"); helps.put("show @@time.startup", "Report startup timestamp"); - helps.put("show @@version", "Report Mycat Server version"); + helps.put("show @@version", "Report Server version"); helps.put("show @@server", "Report server status"); helps.put("show @@threadpool", "Report threadPool status"); helps.put("show @@database", "Report databases"); @@ -145,10 +145,10 @@ public final class ShowHelp { helps.put("show @@slow where schema = ?", "Report schema slow sql"); helps.put("show @@slow where datanode = ?", "Report datanode slow sql"); helps.put("show @@sysparam", "Report system param"); - helps.put("show @@syslog limit=?", "Report system mycat.log"); - helps.put("show @@white", "show mycat white host "); - helps.put("show @@white.set=?,?", "set mycat white host,[ip,user]"); - helps.put("show @@directmemory=1 or 2", "show mycat direct memory usage"); + helps.put("show @@syslog limit=?", "Report system log"); + helps.put("show @@white", "show server white host "); + helps.put("show @@white.set=?,?", "set server white host,[ip,user]"); + helps.put("show @@directmemory=1 or 2", "show server direct memory usage"); // switch helps.put("switch @@datasource name:index", "Switch dataSource"); @@ -176,8 +176,8 @@ public final class ShowHelp { helps.put("reload @@sqlstat=close", "Close real-time sql stat analyzer"); // offline/online - helps.put("offline", "Change MyCat status to OFF"); - helps.put("online", "Change MyCat status to ON"); + helps.put("offline", "Change Server status to OFF"); + helps.put("online", "Change Server status to ON"); // clear helps.put("clear @@slow where schema = ?", "Clear slow sql by schema"); diff --git a/src/main/java/io/mycat/manager/response/ShowSysLog.java b/src/main/java/io/mycat/manager/response/ShowSysLog.java index b9b7bb23d..3607e757a 100644 --- a/src/main/java/io/mycat/manager/response/ShowSysLog.java +++ b/src/main/java/io/mycat/manager/response/ShowSysLog.java @@ -13,6 +13,7 @@ import io.mycat.backend.mysql.PacketUtil; import io.mycat.config.Fields; import io.mycat.config.model.SystemConfig; import io.mycat.manager.ManagerConnection; +import io.mycat.manager.handler.ShowServerLog; import io.mycat.net.mysql.EOFPacket; import io.mycat.net.mysql.FieldPacket; import io.mycat.net.mysql.ResultSetHeaderPacket; @@ -64,7 +65,7 @@ public class ShowSysLog { // write rows byte packetId = eof.packetId; - String filename = SystemConfig.getHomePath() + File.separator + "logs" + File.separator + "mycat.log"; + String filename = SystemConfig.getHomePath() + File.separator + "logs" + File.separator + ShowServerLog.DEFAULT_LOGFILE; String[] lines = getLinesByLogFile(filename, numLines); diff --git a/src/main/java/io/mycat/manager/response/ShowSysParam.java b/src/main/java/io/mycat/manager/response/ShowSysParam.java index b21b43c78..533cdd6a9 100644 --- a/src/main/java/io/mycat/manager/response/ShowSysParam.java +++ b/src/main/java/io/mycat/manager/response/ShowSysParam.java @@ -112,31 +112,31 @@ public class ShowSysParam { "Mysql_charset", "Mysql_txIsolation", "Mysql_sqlExecuteTimeout", - "Mycat_processorCheckPeriod", - "Mycat_dataNodeIdleCheckPeriod", - "Mycat_dataNodeHeartbeatPeriod", - "Mycat_bindIp", - "Mycat_serverPort", - "Mycat_managerPort"}; + "Server_processorCheckPeriod", + "Server_dataNodeIdleCheckPeriod", + "Server_dataNodeHeartbeatPeriod", + "Server_bindIp", + "Server_serverPort", + "Server_managerPort"}; private static final String[] PARAM_DESCRIPTION = { "主要用于指定系统可用的线程数,默认值为Runtime.getRuntime().availableProcessors()方法返回的值。主要影响processorBufferPool、processorBufferLocalPercent、processorExecutor属性。NIOProcessor的个数也是由这个属性定义的,所以调优的时候可以适当的调高这个属性。", "指定每次分配Socket Direct Buffer的大小,默认是4096个字节。这个属性也影响buffer pool的长度。", "指定bufferPool计算 比例值。由于每次执行NIO读、写操作都需要使用到buffer,系统初始化的时候会建立一定长度的buffer池来加快读、写的效率,减少建立buffer的时间", - "主要用于指定NIOProcessor上共享的businessExecutor固定线程池大小。mycat在需要处理一些异步逻辑的时候会把任务提交到这个线程池中。新版本中这个连接池的使用频率不是很大了,可以设置一个较小的值。", - "指定使用Mycat全局序列的类型。", + "主要用于指定NIOProcessor上共享的businessExecutor固定线程池大小。Server在需要处理一些异步逻辑的时候会把任务提交到这个线程池中。新版本中这个连接池的使用频率不是很大了,可以设置一个较小的值。", + "指定使用全局序列的类型。", "指定Mysql协议中的报文头长度。默认4", "指定Mysql协议可以携带的数据最大长度。默认16M", "指定连接的空闲超时时间。某连接在发起空闲检查下,发现距离上次使用超过了空闲时间,那么这个连接会被回收,就是被直接的关闭掉。默认30分钟", "连接的初始化字符集。默认为utf8", "前端连接的初始化事务隔离级别,只在初始化的时候使用,后续会根据客户端传递过来的属性对后端数据库连接进行同步。默认为REPEATED_READ", - "SQL执行超时的时间,Mycat会检查连接上最后一次执行SQL的时间,若超过这个时间则会直接关闭这连接。默认时间为300秒", + "SQL执行超时的时间,Server会检查连接上最后一次执行SQL的时间,若超过这个时间则会直接关闭这连接。默认时间为300秒", "清理NIOProcessor上前后端空闲、超时和关闭连接的间隔时间。默认是1秒", "对后端连接进行空闲、超时检查的时间间隔,默认是300秒", "对后端所有读、写库发起心跳的间隔时间,默认是10秒", - "mycat服务监听的IP地址,默认值为0.0.0.0", - "mycat的使用端口,默认值为8066", - "mycat的管理端口,默认值为9066"}; + "服务监听的IP地址,默认值为0.0.0.0", + "使用端口,默认值为8066", + "管理端口,默认值为9066"}; public static final String[] ISOLATIONS = {"", "READ_UNCOMMITTED", "READ_COMMITTED", "REPEATED_READ", "SERIALIZABLE"}; } diff --git a/src/main/java/io/mycat/memory/MyCatMemory.java b/src/main/java/io/mycat/memory/MyCatMemory.java index d24f655e5..54fb5e867 100644 --- a/src/main/java/io/mycat/memory/MyCatMemory.java +++ b/src/main/java/io/mycat/memory/MyCatMemory.java @@ -90,35 +90,35 @@ public class MyCatMemory { */ if(system.getUseOffHeapForMerge()== 1){ - conf.set("mycat.memory.offHeap.enabled","true"); + conf.set("server.memory.offHeap.enabled","true"); }else{ - conf.set("mycat.memory.offHeap.enabled","false"); + conf.set("server.memory.offHeap.enabled","false"); } if(system.getUseStreamOutput() == 1){ - conf.set("mycat.stream.output.result","true"); + conf.set("server.stream.output.result","true"); }else{ - conf.set("mycat.stream.output.result","false"); + conf.set("server.stream.output.result","false"); } if(system.getMemoryPageSize() != null){ - conf.set("mycat.buffer.pageSize",system.getMemoryPageSize()); + conf.set("server.buffer.pageSize",system.getMemoryPageSize()); }else{ - conf.set("mycat.buffer.pageSize","1m"); + conf.set("server.buffer.pageSize","1m"); } if(system.getSpillsFileBufferSize() != null){ - conf.set("mycat.merge.file.buffer",system.getSpillsFileBufferSize()); + conf.set("server.merge.file.buffer",system.getSpillsFileBufferSize()); }else{ - conf.set("mycat.merge.file.buffer","32k"); + conf.set("server.merge.file.buffer","32k"); } - conf.set("mycat.pointer.array.len","8k") - .set("mycat.memory.offHeap.size", JavaUtils.bytesToString2(resultSetBufferSize)); + conf.set("server.pointer.array.len","8k") + .set("server.memory.offHeap.size", JavaUtils.bytesToString2(resultSetBufferSize)); - LOGGER.info("mycat.memory.offHeap.size: " + + LOGGER.info("resultSetBufferSize: " + JavaUtils.bytesToString2(resultSetBufferSize)); resultMergeMemoryManager = @@ -156,13 +156,13 @@ public class MyCatMemory { * mycat.direct.output.result * mycat.local.dir */ - conf.set("mycat.memory.offHeap.enabled","true") - .set("mycat.pointer.array.len","8K") - .set("mycat.buffer.pageSize","1m") - .set("mycat.memory.offHeap.size", JavaUtils.bytesToString2(resultSetBufferSize)) - .set("mycat.stream.output.result","false"); + conf.set("server.memory.offHeap.enabled","true") + .set("server.pointer.array.len","8K") + .set("server.buffer.pageSize","1m") + .set("server.memory.offHeap.size", JavaUtils.bytesToString2(resultSetBufferSize)) + .set("server.stream.output.result","false"); - LOGGER.info("mycat.memory.offHeap.size: " + JavaUtils.bytesToString2(resultSetBufferSize)); + LOGGER.info("resultSetBufferSize: " + JavaUtils.bytesToString2(resultSetBufferSize)); resultMergeMemoryManager = new ResultMergeMemoryManager(conf,numCores,maxOnHeapMemory); diff --git a/src/main/java/io/mycat/memory/environment/EnvironmentInformation.java b/src/main/java/io/mycat/memory/environment/EnvironmentInformation.java deleted file mode 100644 index 5a750eb75..000000000 --- a/src/main/java/io/mycat/memory/environment/EnvironmentInformation.java +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.mycat.memory.environment; - - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.InputStream; -import java.lang.management.ManagementFactory; -import java.lang.management.OperatingSystemMXBean; -import java.lang.management.RuntimeMXBean; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Properties; - -/** - * Utility class that gives access to the execution environment of the JVM, like - * the executing user, startup options, or the JVM version. - */ -public class EnvironmentInformation { - - private static final Logger LOG = LoggerFactory.getLogger(EnvironmentInformation.class); - - public static final String UNKNOWN = ""; - - /** - * Returns the version of the code as String. If version == null, then the JobManager does not run from a - * Maven build. An example is a source code checkout, compile, and run from inside an IDE. - * - * @return The version string. - */ - public static String getVersion() { - String version = EnvironmentInformation.class.getPackage().getImplementationVersion(); - return version != null ? version : UNKNOWN; - } - - /** - * Returns the code revision (commit and commit date) of Flink, as generated by the Maven builds. - * - * @return The code revision. - */ - public static RevisionInformation getRevisionInformation() { - String revision = UNKNOWN; - String commitDate = UNKNOWN; - try (InputStream propFile = EnvironmentInformation.class.getClassLoader().getResourceAsStream(".version.properties")) { - if (propFile != null) { - Properties properties = new Properties(); - properties.load(propFile); - String propRevision = properties.getProperty("git.commit.id.abbrev"); - String propCommitDate = properties.getProperty("git.commit.time"); - revision = propRevision != null ? propRevision : UNKNOWN; - commitDate = propCommitDate != null ? propCommitDate : UNKNOWN; - } - } catch (Throwable t) { - if (LOG.isDebugEnabled()) { - LOG.debug("Cannot determine code revision: Unable to read version property file.", t); - } else { - LOG.info("Cannot determine code revision: Unable to read version property file."); - } - } - - return new RevisionInformation(revision, commitDate); - } - - /** - * Gets the name of the user that is running the JVM. - * - * @return The name of the user that is running the JVM. - */ - public static String getUserRunning() { - String user = System.getProperty("user.name"); - if (user == null) { - user = UNKNOWN; - if (LOG.isDebugEnabled()) { - LOG.debug("Cannot determine user/group information for the current user."); - } - } - return user; - } - - /** - * The maximum JVM heap size, in bytes. - * - * @return The maximum JVM heap size, in bytes. - */ - public static long getMaxJvmHeapMemory() { - long maxMemory = Runtime.getRuntime().maxMemory(); - - if (maxMemory == Long.MAX_VALUE) { - // amount of free memory unknown - try { - // workaround for Oracle JDK - OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); - Class clazz = Class.forName("com.sun.management.OperatingSystemMXBean"); - Method method = clazz.getMethod("getTotalPhysicalMemorySize"); - maxMemory = (Long) method.invoke(operatingSystemMXBean) / 4; - } - catch (Throwable e) { - throw new RuntimeException("Could not determine the amount of free memory.\n" + - "Please set the maximum memory for the JVM, e.g. -Xmx512M for 512 megabytes."); - } - } - - return maxMemory; - } - - /** - * Gets an estimate of the size of the free heap memory. - * - * NOTE: This method is heavy-weight. It triggers a garbage collection to reduce fragmentation and get - * a better estimate at the size of free memory. It is typically more accurate than the plain version - * {@link #getSizeOfFreeHeapMemory()}. - * - * @return An estimate of the size of the free heap memory, in bytes. - */ - public static long getSizeOfFreeHeapMemoryWithDefrag() { - // trigger a garbage collection, to reduce fragmentation - System.gc(); - - return getSizeOfFreeHeapMemory(); - } - - /** - * Gets an estimate of the size of the free heap memory. The estimate may vary, depending on the current - * level of memory fragmentation and the number of dead objects. For a better (but more heavy-weight) - * estimate, use {@link #getSizeOfFreeHeapMemoryWithDefrag()}. - * - * @return An estimate of the size of the free heap memory, in bytes. - */ - public static long getSizeOfFreeHeapMemory() { - Runtime r = Runtime.getRuntime(); - long maxMemory = r.maxMemory(); - - if (maxMemory == Long.MAX_VALUE) { - // amount of free memory unknown - try { - // workaround for Oracle JDK - OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); - Class clazz = Class.forName("com.sun.management.OperatingSystemMXBean"); - Method method = clazz.getMethod("getTotalPhysicalMemorySize"); - maxMemory = (Long) method.invoke(operatingSystemMXBean) / 4; - } catch (Throwable e) { - throw new RuntimeException("Could not determine the amount of free memory.\n" + - "Please set the maximum memory for the JVM, e.g. -Xmx512M for 512 megabytes."); - } - } - - return maxMemory - r.totalMemory() + r.freeMemory(); - } - - /** - * Gets the version of the JVM in the form "VM_Name - Vendor - Spec/Version". - * - * @return The JVM version. - */ - public static String getJvmVersion() { - try { - final RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean(); - return bean.getVmName() + " - " + bean.getVmVendor() + " - " + bean.getSpecVersion() + '/' + bean.getVmVersion(); - } - catch (Throwable t) { - return UNKNOWN; - } - } - - /** - * Gets the system parameters and environment parameters that were passed to the JVM on startup. - * - * @return The options passed to the JVM on startup. - */ - public static String getJvmStartupOptions() { - try { - final RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean(); - final StringBuilder bld = new StringBuilder(); - - for (String s : bean.getInputArguments()) { - bld.append(s).append(' '); - } - - return bld.toString(); - } - catch (Throwable t) { - return UNKNOWN; - } - } - - /** - * Gets the system parameters and environment parameters that were passed to the JVM on startup. - * - * @return The options passed to the JVM on startup. - */ - public static String[] getJvmStartupOptionsArray() { - try { - RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean(); - List options = bean.getInputArguments(); - return options.toArray(new String[options.size()]); - } - catch (Throwable t) { - return new String[0]; - } - } - - /** - * Gets the directory for temporary files, as returned by the JVM system property "java.io.tmpdir". - * - * @return The directory for temporary files. - */ - public static String getTemporaryFileDirectory() { - return System.getProperty("java.io.tmpdir"); - } - - /** - * Tries to retrieve the maximum number of open file handles. This method will only work on - * UNIX-based operating systems with Sun/Oracle Java versions. - * - *

If the number of max open file handles cannot be determined, this method returns {@code -1}.

- * - * @return The limit of open file handles, or {@code -1}, if the limit could not be determined. - */ - public static long getOpenFileHandlesLimit() { - Class sunBeanClass; - try { - sunBeanClass = Class.forName("com.sun.management.UnixOperatingSystemMXBean"); - } - catch (ClassNotFoundException e) { - return -1L; - } - - try { - Method fhLimitMethod = sunBeanClass.getMethod("getMaxFileDescriptorCount"); - Object result = fhLimitMethod.invoke(ManagementFactory.getOperatingSystemMXBean()); - return (Long) result; - } - catch (Throwable t) { - LOG.warn("Unexpected error when accessing file handle limit", t); - return -1L; - } - } - - /** - * Logs a information about the environment, like code revision, current user, java version, - * and JVM parameters. - * - * @param log The logger to log the information to. - * @param componentName The component name to mention in the log. - * @param commandLineArgs The arguments accompanying the starting the component. - */ - public static void logEnvironmentInfo(Logger log, String componentName, String[] commandLineArgs) { - if (log.isInfoEnabled()) { - RevisionInformation rev = getRevisionInformation(); - String version = getVersion(); - - String user = getUserRunning(); - - String jvmVersion = getJvmVersion(); - String[] options = getJvmStartupOptionsArray(); - - String javaHome = System.getenv("JAVA_HOME"); - - long maxHeapMegabytes = getMaxJvmHeapMemory() >>> 20; - - log.info("--------------------------------------------------------------------------------"); - log.info(" Starting " + componentName + " (Version: " + version + ", " - + "Rev:" + rev.commitId + ", " + "Date:" + rev.commitDate + ")"); - log.info(" Current user: " + user); - log.info(" JVM: " + jvmVersion); - log.info(" Maximum heap size: " + maxHeapMegabytes + " MiBytes"); - log.info(" JAVA_HOME: " + (javaHome == null ? "(not set)" : javaHome)); - - - if (options.length == 0) { - log.info(" JVM Options: (none)"); - } - else { - log.info(" JVM Options:"); - for (String s: options) { - log.info(" " + s); - } - } - - if (commandLineArgs == null || commandLineArgs.length == 0) { - log.info(" Program Arguments: (none)"); - } - else { - log.info(" Program Arguments:"); - for (String s: commandLineArgs) { - log.info(" " + s); - } - } - - log.info(" Classpath: " + System.getProperty("java.class.path")); - - log.info("--------------------------------------------------------------------------------"); - } - } - - // -------------------------------------------------------------------------------------------- - - /** Don't instantiate this class */ - private EnvironmentInformation() {} - - // -------------------------------------------------------------------------------------------- - - /** - * Revision information encapsulates information about the source code revision of the Flink - * code. - */ - public static class RevisionInformation { - - /** The git commit id (hash) */ - public final String commitId; - - /** The git commit date */ - public final String commitDate; - - public RevisionInformation(String commitId, String commitDate) { - this.commitId = commitId; - this.commitDate = commitDate; - } - } -} diff --git a/src/main/java/io/mycat/memory/environment/Hardware.java b/src/main/java/io/mycat/memory/environment/Hardware.java index 42a9f77ef..e6e9a353f 100644 --- a/src/main/java/io/mycat/memory/environment/Hardware.java +++ b/src/main/java/io/mycat/memory/environment/Hardware.java @@ -58,26 +58,20 @@ public class Hardware { * the size could not be determined */ public static long getSizeOfPhysicalMemory() { - switch (OperatingSystem.getCurrentOperatingSystem()) { - case LINUX: - return getSizeOfPhysicalMemoryForLinux(); - - case WINDOWS: - return getSizeOfPhysicalMemoryForWindows(); - - case MAC_OS: - return getSizeOfPhysicalMemoryForMac(); - - case FREE_BSD: - return getSizeOfPhysicalMemoryForFreeBSD(); - - case UNKNOWN: - LOG.error("Cannot determine size of physical memory for unknown operating system"); - return -1; - - default: - LOG.error("Unrecognized OS: " + OperatingSystem.getCurrentOperatingSystem()); - return -1; + if (OperatingSystem.getCurrentOperatingSystem() == OperatingSystem.LINUX) { + return getSizeOfPhysicalMemoryForLinux(); + } else if (OperatingSystem.getCurrentOperatingSystem() == OperatingSystem.WINDOWS) { + return getSizeOfPhysicalMemoryForWindows(); + } else if (OperatingSystem.getCurrentOperatingSystem() == OperatingSystem.MAC_OS) { + return getSizeOfPhysicalMemoryForMac(); + } else if (OperatingSystem.getCurrentOperatingSystem() == OperatingSystem.FREE_BSD) { + return getSizeOfPhysicalMemoryForFreeBSD(); + } else if (OperatingSystem.getCurrentOperatingSystem() == OperatingSystem.UNKNOWN) { + LOG.error("Cannot determine size of physical memory for unknown operating system"); + return -1; + } else { + LOG.error("Unrecognized OS: " + OperatingSystem.getCurrentOperatingSystem()); + return -1; } } diff --git a/src/main/java/io/mycat/memory/unsafe/map/UnsafeFixedWidthAggregationMap.java b/src/main/java/io/mycat/memory/unsafe/map/UnsafeFixedWidthAggregationMap.java index b85524c11..c8950e3a3 100644 --- a/src/main/java/io/mycat/memory/unsafe/map/UnsafeFixedWidthAggregationMap.java +++ b/src/main/java/io/mycat/memory/unsafe/map/UnsafeFixedWidthAggregationMap.java @@ -280,8 +280,8 @@ public final class UnsafeFixedWidthAggregationMap { return new UnsafeKVExternalSorter( groupingKeySchema, aggregationBufferSchema, - MycatServer.getInstance().getMyCatMemory().getBlockManager(), - MycatServer.getInstance().getMyCatMemory().getSerializerManager(), + MycatServer.getInstance().getServerMemory().getBlockManager(), + MycatServer.getInstance().getServerMemory().getSerializerManager(), map.getPageSizeBytes(), map); } diff --git a/src/main/java/io/mycat/memory/unsafe/memory/mm/MemoryManager.java b/src/main/java/io/mycat/memory/unsafe/memory/mm/MemoryManager.java index 33463984c..8a9d17296 100644 --- a/src/main/java/io/mycat/memory/unsafe/memory/mm/MemoryManager.java +++ b/src/main/java/io/mycat/memory/unsafe/memory/mm/MemoryManager.java @@ -29,7 +29,7 @@ public abstract class MemoryManager { public MemoryManager(MycatPropertyConf conf, int numCores, long onHeapExecutionMemory){ this.conf = conf; this.numCores =numCores; - maxOffHeapMemory = conf.getSizeAsBytes("mycat.memory.offHeap.size","128m"); + maxOffHeapMemory = conf.getSizeAsBytes("server.memory.offHeap.size","128m"); offHeapExecutionMemory = maxOffHeapMemory; onHeapExecutionMemoryPool.incrementPoolSize(onHeapExecutionMemory); @@ -43,13 +43,12 @@ public abstract class MemoryManager { */ public void releaseExecutionMemory(long numBytes, long taskAttemptId, MemoryMode memoryMode) { synchronized (this) { - switch (memoryMode) { - case ON_HEAP: - onHeapExecutionMemoryPool.releaseMemory(numBytes, taskAttemptId); - break; - case OFF_HEAP: - offHeapExecutionMemoryPool.releaseMemory(numBytes, taskAttemptId); - break; + if (memoryMode == MemoryMode.ON_HEAP) { + onHeapExecutionMemoryPool.releaseMemory(numBytes, taskAttemptId); + + } else if (memoryMode == MemoryMode.OFF_HEAP) { + offHeapExecutionMemoryPool.releaseMemory(numBytes, taskAttemptId); + } } @@ -91,8 +90,8 @@ public void releaseExecutionMemory(long numBytes, long taskAttemptId, MemoryMode * sun.misc.Unsafe. */ public final MemoryMode tungstenMemoryMode(){ - if (conf.getBoolean("mycat.memory.offHeap.enabled", false)) { - assert (conf.getSizeAsBytes("mycat.memory.offHeap.size",0) > 0); + if (conf.getBoolean("server.memory.offHeap.enabled", false)) { + assert (conf.getSizeAsBytes("server.memory.offHeap.size",0) > 0); assert (Platform.unaligned()); return MemoryMode.OFF_HEAP; } else { @@ -103,7 +102,7 @@ public void releaseExecutionMemory(long numBytes, long taskAttemptId, MemoryMode /** * The default page size, in bytes. * - * If user didn't explicitly set "mycat.buffer.pageSize", we figure out the default value + * If user didn't explicitly set "server.buffer.pageSize", we figure out the default value * by looking at the number of cores available to the process, and the total amount of memory, * and then divide it by a factor of safety. */ @@ -124,22 +123,22 @@ public void releaseExecutionMemory(long numBytes, long taskAttemptId, MemoryMode int safetyFactor = 16; long maxTungstenMemory = 0L; - switch (tungstenMemoryMode()){ - case ON_HEAP: - synchronized (this) { - maxTungstenMemory = onHeapExecutionMemoryPool.poolSize(); - } - break; - case OFF_HEAP: - synchronized (this) { - maxTungstenMemory = offHeapExecutionMemoryPool.poolSize(); - } - break; + MemoryMode i = tungstenMemoryMode(); + if (i == MemoryMode.ON_HEAP) { + synchronized (this) { + maxTungstenMemory = onHeapExecutionMemoryPool.poolSize(); + } + + } else if (i == MemoryMode.OFF_HEAP) { + synchronized (this) { + maxTungstenMemory = offHeapExecutionMemoryPool.poolSize(); + } + } long size = ByteArrayMethods.nextPowerOf2(maxTungstenMemory / cores / safetyFactor); long defaultSize = Math.min(maxPageSize, Math.max(minPageSize, size)); - defaultSize = conf.getSizeAsBytes("mycat.buffer.pageSize", defaultSize); + defaultSize = conf.getSizeAsBytes("server.buffer.pageSize", defaultSize); return defaultSize; } @@ -148,11 +147,11 @@ public void releaseExecutionMemory(long numBytes, long taskAttemptId, MemoryMode * Allocates memory for use by Unsafe/Tungsten code. */ public final MemoryAllocator tungstenMemoryAllocator() { - switch (tungstenMemoryMode()){ - case ON_HEAP: - return MemoryAllocator.HEAP; - case OFF_HEAP: - return MemoryAllocator.UNSAFE; + MemoryMode i = tungstenMemoryMode(); + if (i == MemoryMode.ON_HEAP) { + return MemoryAllocator.HEAP; + } else if (i == MemoryMode.OFF_HEAP) { + return MemoryAllocator.UNSAFE; } return null; } diff --git a/src/main/java/io/mycat/memory/unsafe/memory/mm/ResultMergeMemoryManager.java b/src/main/java/io/mycat/memory/unsafe/memory/mm/ResultMergeMemoryManager.java index 185dedbbb..0ea241df1 100644 --- a/src/main/java/io/mycat/memory/unsafe/memory/mm/ResultMergeMemoryManager.java +++ b/src/main/java/io/mycat/memory/unsafe/memory/mm/ResultMergeMemoryManager.java @@ -20,11 +20,10 @@ public class ResultMergeMemoryManager extends MemoryManager { @Override protected synchronized long acquireExecutionMemory(long numBytes,long taskAttemptId,MemoryMode memoryMode) throws InterruptedException { - switch (memoryMode) { - case ON_HEAP: - return onHeapExecutionMemoryPool.acquireMemory(numBytes,taskAttemptId); - case OFF_HEAP: - return offHeapExecutionMemoryPool.acquireMemory(numBytes,taskAttemptId); + if (memoryMode == MemoryMode.ON_HEAP) { + return onHeapExecutionMemoryPool.acquireMemory(numBytes, taskAttemptId); + } else if (memoryMode == MemoryMode.OFF_HEAP) { + return offHeapExecutionMemoryPool.acquireMemory(numBytes, taskAttemptId); } return 0L; } diff --git a/src/main/java/io/mycat/memory/unsafe/memory/mm/ResultSetMemoryPool.java b/src/main/java/io/mycat/memory/unsafe/memory/mm/ResultSetMemoryPool.java index fd13f340a..d1a06aa9f 100644 --- a/src/main/java/io/mycat/memory/unsafe/memory/mm/ResultSetMemoryPool.java +++ b/src/main/java/io/mycat/memory/unsafe/memory/mm/ResultSetMemoryPool.java @@ -27,11 +27,10 @@ public class ResultSetMemoryPool extends MemoryPool { private String poolName(){ - switch (memoryMode){ - case ON_HEAP: - return "on-heap memory"; - case OFF_HEAP: - return "off-heap memory"; + if (memoryMode == MemoryMode.ON_HEAP) { + return "on-heap memory"; + } else if (memoryMode == MemoryMode.OFF_HEAP) { + return "off-heap memory"; } return "off-heap memory"; diff --git a/src/main/java/io/mycat/memory/unsafe/storage/DataNodeDiskManager.java b/src/main/java/io/mycat/memory/unsafe/storage/DataNodeDiskManager.java index dc3d86925..d1b7eb209 100644 --- a/src/main/java/io/mycat/memory/unsafe/storage/DataNodeDiskManager.java +++ b/src/main/java/io/mycat/memory/unsafe/storage/DataNodeDiskManager.java @@ -38,7 +38,7 @@ public class DataNodeDiskManager { File file, SerializerInstance serializerInstance, int bufferSize) throws IOException { - boolean syncWrites = conf.getBoolean("mycat.merge.sync", false); + boolean syncWrites = conf.getBoolean("server.merge.sync", false); return new DiskRowWriter(file, serializerInstance, bufferSize,new FileOutputStream(file), syncWrites,blockId); } diff --git a/src/main/java/io/mycat/memory/unsafe/storage/DataNodeFileManager.java b/src/main/java/io/mycat/memory/unsafe/storage/DataNodeFileManager.java index b009c7718..23530a9ce 100644 --- a/src/main/java/io/mycat/memory/unsafe/storage/DataNodeFileManager.java +++ b/src/main/java/io/mycat/memory/unsafe/storage/DataNodeFileManager.java @@ -65,7 +65,7 @@ public class DataNodeFileManager { this.deleteFilesOnStop = deleteFilesOnStop; - subDirsPerLocalDir = conf.getInt("mycat.diskStore.subDirectories", 64); + subDirsPerLocalDir = conf.getInt("server.diskStore.subDirectories", 64); localDirs = createLocalDirs(conf); if (localDirs.isEmpty()) { System.exit(-1); @@ -138,7 +138,7 @@ public class DataNodeFileManager { */ private List createLocalDirs(MycatPropertyConf conf) { - String rootDirs = conf.getString("mycat.local.dirs","datanode"); + String rootDirs = conf.getString("server.local.dirs","datanode"); String rdir[] = rootDirs.split(","); List dirs = new ArrayList(); diff --git a/src/main/java/io/mycat/memory/unsafe/utils/sort/UnsafeExternalRowSorter.java b/src/main/java/io/mycat/memory/unsafe/utils/sort/UnsafeExternalRowSorter.java index 051c7da1d..48594622b 100644 --- a/src/main/java/io/mycat/memory/unsafe/utils/sort/UnsafeExternalRowSorter.java +++ b/src/main/java/io/mycat/memory/unsafe/utils/sort/UnsafeExternalRowSorter.java @@ -50,7 +50,7 @@ public final class UnsafeExternalRowSorter { } public UnsafeExternalRowSorter(DataNodeMemoryManager dataNodeMemoryManager, - @Nonnull MyCatMemory myCatMemory, + @Nonnull MyCatMemory memory, StructType schema, PrefixComparator prefixComparator, PrefixComputer prefixComputer, @@ -63,11 +63,11 @@ public final class UnsafeExternalRowSorter { this.recordComparator = new RowComparator(schema); sorter = UnsafeExternalSorter.create( dataNodeMemoryManager, - myCatMemory.getBlockManager(), - myCatMemory.getSerializerManager(), + memory.getBlockManager(), + memory.getSerializerManager(), recordComparator, prefixComparator, - myCatMemory.getConf().getSizeAsBytes("mycat.pointer.array.len","16K"), + memory.getConf().getSizeAsBytes("server.pointer.array.len","16K"), pageSizeBytes, canUseRadixSort, enableSort); diff --git a/src/main/java/io/mycat/memory/unsafe/utils/sort/UnsafeExternalSorter.java b/src/main/java/io/mycat/memory/unsafe/utils/sort/UnsafeExternalSorter.java index 84ac3b65a..403828112 100644 --- a/src/main/java/io/mycat/memory/unsafe/utils/sort/UnsafeExternalSorter.java +++ b/src/main/java/io/mycat/memory/unsafe/utils/sort/UnsafeExternalSorter.java @@ -120,9 +120,9 @@ public final class UnsafeExternalSorter extends MemoryConsumer { this.prefixComparator = prefixComparator; - if(MycatServer.getInstance().getMyCatMemory() != null){ + if(MycatServer.getInstance().getServerMemory() != null){ this.fileBufferSizeBytes = (int) MycatServer.getInstance(). - getMyCatMemory().getConf().getSizeAsBytes("mycat.merge.file.buffer", "32k"); + getServerMemory().getConf().getSizeAsBytes("server.merge.file.buffer", "32k"); }else{ this.fileBufferSizeBytes = 32*1024; } diff --git a/src/main/java/io/mycat/meta/ProxyMetaManager.java b/src/main/java/io/mycat/meta/ProxyMetaManager.java index 74fffbe01..0a0036679 100644 --- a/src/main/java/io/mycat/meta/ProxyMetaManager.java +++ b/src/main/java/io/mycat/meta/ProxyMetaManager.java @@ -24,9 +24,9 @@ import io.mycat.config.model.DBHostConfig; import io.mycat.config.model.SchemaConfig; import io.mycat.config.model.SystemConfig; import io.mycat.config.model.TableConfig; -import io.mycat.meta.protocol.MyCatMeta.ColumnMeta; -import io.mycat.meta.protocol.MyCatMeta.IndexMeta; -import io.mycat.meta.protocol.MyCatMeta.TableMeta; +import io.mycat.meta.protocol.StructureMeta.ColumnMeta; +import io.mycat.meta.protocol.StructureMeta.IndexMeta; +import io.mycat.meta.protocol.StructureMeta.TableMeta; import io.mycat.meta.table.AbstractTableMetaHandler; import io.mycat.meta.table.MetaHelper; import io.mycat.meta.table.MetaHelper.INDEX_TYPE; @@ -523,7 +523,7 @@ public class ProxyMetaManager { } catch (Exception e) { LOGGER.warn("updateMetaData failed,sql is" + statement.toString(), e); } finally { - removeMetaLock(schema, schemaInfo.table); + removeMetaLock(schemaInfo.schema, schemaInfo.table); if (MycatServer.getInstance().isUseZK()) { try { notifyClusterDDL(schemaInfo.schema, schemaInfo.table, sql, isSuccess ? DDLStatus.SUCCESS : DDLStatus.FAILED); @@ -548,7 +548,7 @@ public class ProxyMetaManager { } catch (Exception e) { LOGGER.warn("updateMetaData failed,sql is" + statement.toString(), e); } finally { - removeMetaLock(schema, schemaInfo.table); + removeMetaLock(schemaInfo.schema, schemaInfo.table); if (MycatServer.getInstance().isUseZK()) { try { @@ -665,7 +665,7 @@ public class ProxyMetaManager { } catch (Exception e) { LOGGER.warn("updateMetaData alterTable failed,sql is" + alterStatement.toString(), e); } finally { - removeMetaLock(schema, schemaInfo.table); + removeMetaLock(schemaInfo.schema, schemaInfo.table); if (MycatServer.getInstance().isUseZK()) { try { notifyClusterDDL(schemaInfo.schema, schemaInfo.table, sql, isSuccess ? DDLStatus.SUCCESS : DDLStatus.FAILED); @@ -697,7 +697,7 @@ public class ProxyMetaManager { } catch (Exception e) { LOGGER.warn("updateMetaData failed,sql is" + statement.toString(), e); } finally { - removeMetaLock(schema, schemaInfo.table); + removeMetaLock(schemaInfo.schema, schemaInfo.table); if (MycatServer.getInstance().isUseZK()) { try { notifyClusterDDL(schemaInfo.schema, schemaInfo.table, sql, isSuccess ? DDLStatus.SUCCESS : DDLStatus.FAILED); @@ -750,7 +750,7 @@ public class ProxyMetaManager { } catch (Exception e) { LOGGER.warn("updateMetaData failed,sql is" + dropIndexStatement.toString(), e); } finally { - removeMetaLock(schema, schemaInfo.table); + removeMetaLock(schemaInfo.schema, schemaInfo.table); if (MycatServer.getInstance().isUseZK()) { try { notifyClusterDDL(schemaInfo.schema, schemaInfo.table, sql, isSuccess ? DDLStatus.SUCCESS : DDLStatus.FAILED); diff --git a/src/main/java/io/mycat/meta/SchemaMeta.java b/src/main/java/io/mycat/meta/SchemaMeta.java index 95a59068b..069a62b63 100644 --- a/src/main/java/io/mycat/meta/SchemaMeta.java +++ b/src/main/java/io/mycat/meta/SchemaMeta.java @@ -6,7 +6,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import io.mycat.meta.protocol.MyCatMeta.TableMeta; +import io.mycat.meta.protocol.StructureMeta.TableMeta; public class SchemaMeta { diff --git a/src/main/java/io/mycat/meta/protocol/MyCatMeta.java b/src/main/java/io/mycat/meta/protocol/StructureMeta.java similarity index 86% rename from src/main/java/io/mycat/meta/protocol/MyCatMeta.java rename to src/main/java/io/mycat/meta/protocol/StructureMeta.java index 953fe206b..597d2a8c2 100644 --- a/src/main/java/io/mycat/meta/protocol/MyCatMeta.java +++ b/src/main/java/io/mycat/meta/protocol/StructureMeta.java @@ -1,10 +1,10 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: MyCatMeta.protocol +// source: StructureMeta.proto package io.mycat.meta.protocol; -public final class MyCatMeta { - private MyCatMeta() {} +public final class StructureMeta { + private StructureMeta() {} public static void registerAllExtensions( com.google.protobuf.ExtensionRegistry registry) { } @@ -161,14 +161,14 @@ public final class MyCatMeta { } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_IndexMeta_descriptor; + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_IndexMeta_descriptor; } protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_IndexMeta_fieldAccessorTable + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_IndexMeta_fieldAccessorTable .ensureFieldAccessorsInitialized( - io.mycat.meta.protocol.MyCatMeta.IndexMeta.class, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder.class); + io.mycat.meta.protocol.StructureMeta.IndexMeta.class, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder.class); } public static com.google.protobuf.Parser PARSER = @@ -362,7 +362,7 @@ public final class MyCatMeta { } if (((bitField0_ & 0x00000002) == 0x00000002)) { size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, getTypeBytes()); + .computeBytesSize(2, getTypeBytes()); } { int dataSize = 0; @@ -385,53 +385,53 @@ public final class MyCatMeta { return super.writeReplace(); } - public static io.mycat.meta.protocol.MyCatMeta.IndexMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.IndexMeta parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static io.mycat.meta.protocol.MyCatMeta.IndexMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.IndexMeta parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static io.mycat.meta.protocol.MyCatMeta.IndexMeta parseFrom(byte[] data) + public static io.mycat.meta.protocol.StructureMeta.IndexMeta parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static io.mycat.meta.protocol.MyCatMeta.IndexMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.IndexMeta parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static io.mycat.meta.protocol.MyCatMeta.IndexMeta parseFrom(java.io.InputStream input) + public static io.mycat.meta.protocol.StructureMeta.IndexMeta parseFrom(java.io.InputStream input) throws java.io.IOException { return PARSER.parseFrom(input); } - public static io.mycat.meta.protocol.MyCatMeta.IndexMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.IndexMeta parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return PARSER.parseFrom(input, extensionRegistry); } - public static io.mycat.meta.protocol.MyCatMeta.IndexMeta parseDelimitedFrom(java.io.InputStream input) + public static io.mycat.meta.protocol.StructureMeta.IndexMeta parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return PARSER.parseDelimitedFrom(input); } - public static io.mycat.meta.protocol.MyCatMeta.IndexMeta parseDelimitedFrom( + public static io.mycat.meta.protocol.StructureMeta.IndexMeta parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return PARSER.parseDelimitedFrom(input, extensionRegistry); } - public static io.mycat.meta.protocol.MyCatMeta.IndexMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.IndexMeta parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return PARSER.parseFrom(input); } - public static io.mycat.meta.protocol.MyCatMeta.IndexMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.IndexMeta parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { @@ -440,7 +440,7 @@ public final class MyCatMeta { public static Builder newBuilder() { return Builder.create(); } public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(io.mycat.meta.protocol.MyCatMeta.IndexMeta prototype) { + public static Builder newBuilder(io.mycat.meta.protocol.StructureMeta.IndexMeta prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); } @@ -457,20 +457,20 @@ public final class MyCatMeta { public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements // @@protoc_insertion_point(builder_implements:io.mycat.meta.protocol.IndexMeta) - io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder { + io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_IndexMeta_descriptor; + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_IndexMeta_descriptor; } protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_IndexMeta_fieldAccessorTable + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_IndexMeta_fieldAccessorTable .ensureFieldAccessorsInitialized( - io.mycat.meta.protocol.MyCatMeta.IndexMeta.class, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder.class); + io.mycat.meta.protocol.StructureMeta.IndexMeta.class, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder.class); } - // Construct using io.mycat.meta.protocol.MyCatMeta.IndexMeta.newBuilder() + // Construct using io.mycat.meta.protocol.StructureMeta.IndexMeta.newBuilder() private Builder() { maybeForceBuilderInitialization(); } @@ -505,23 +505,23 @@ public final class MyCatMeta { public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_IndexMeta_descriptor; + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_IndexMeta_descriptor; } - public io.mycat.meta.protocol.MyCatMeta.IndexMeta getDefaultInstanceForType() { - return io.mycat.meta.protocol.MyCatMeta.IndexMeta.getDefaultInstance(); + public io.mycat.meta.protocol.StructureMeta.IndexMeta getDefaultInstanceForType() { + return io.mycat.meta.protocol.StructureMeta.IndexMeta.getDefaultInstance(); } - public io.mycat.meta.protocol.MyCatMeta.IndexMeta build() { - io.mycat.meta.protocol.MyCatMeta.IndexMeta result = buildPartial(); + public io.mycat.meta.protocol.StructureMeta.IndexMeta build() { + io.mycat.meta.protocol.StructureMeta.IndexMeta result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; } - public io.mycat.meta.protocol.MyCatMeta.IndexMeta buildPartial() { - io.mycat.meta.protocol.MyCatMeta.IndexMeta result = new io.mycat.meta.protocol.MyCatMeta.IndexMeta(this); + public io.mycat.meta.protocol.StructureMeta.IndexMeta buildPartial() { + io.mycat.meta.protocol.StructureMeta.IndexMeta result = new io.mycat.meta.protocol.StructureMeta.IndexMeta(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { @@ -543,16 +543,16 @@ public final class MyCatMeta { } public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.mycat.meta.protocol.MyCatMeta.IndexMeta) { - return mergeFrom((io.mycat.meta.protocol.MyCatMeta.IndexMeta)other); + if (other instanceof io.mycat.meta.protocol.StructureMeta.IndexMeta) { + return mergeFrom((io.mycat.meta.protocol.StructureMeta.IndexMeta)other); } else { super.mergeFrom(other); return this; } } - public Builder mergeFrom(io.mycat.meta.protocol.MyCatMeta.IndexMeta other) { - if (other == io.mycat.meta.protocol.MyCatMeta.IndexMeta.getDefaultInstance()) return this; + public Builder mergeFrom(io.mycat.meta.protocol.StructureMeta.IndexMeta other) { + if (other == io.mycat.meta.protocol.StructureMeta.IndexMeta.getDefaultInstance()) return this; if (other.hasName()) { bitField0_ |= 0x00000001; name_ = other.name_; @@ -593,11 +593,11 @@ public final class MyCatMeta { com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - io.mycat.meta.protocol.MyCatMeta.IndexMeta parsedMessage = null; + io.mycat.meta.protocol.StructureMeta.IndexMeta parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.mycat.meta.protocol.MyCatMeta.IndexMeta) e.getUnfinishedMessage(); + parsedMessage = (io.mycat.meta.protocol.StructureMeta.IndexMeta) e.getUnfinishedMessage(); throw e; } finally { if (parsedMessage != null) { @@ -1060,8 +1060,7 @@ public final class MyCatMeta { com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { initFields(); - @SuppressWarnings("unused") - int mutable_bitField0_ = 0; + int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -1147,14 +1146,14 @@ public final class MyCatMeta { } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_ColumnMeta_descriptor; + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_ColumnMeta_descriptor; } protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_ColumnMeta_fieldAccessorTable + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_ColumnMeta_fieldAccessorTable .ensureFieldAccessorsInitialized( - io.mycat.meta.protocol.MyCatMeta.ColumnMeta.class, io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder.class); + io.mycat.meta.protocol.StructureMeta.ColumnMeta.class, io.mycat.meta.protocol.StructureMeta.ColumnMeta.Builder.class); } public static com.google.protobuf.Parser PARSER = @@ -1579,53 +1578,53 @@ public final class MyCatMeta { return super.writeReplace(); } - public static io.mycat.meta.protocol.MyCatMeta.ColumnMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.ColumnMeta parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static io.mycat.meta.protocol.MyCatMeta.ColumnMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.ColumnMeta parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static io.mycat.meta.protocol.MyCatMeta.ColumnMeta parseFrom(byte[] data) + public static io.mycat.meta.protocol.StructureMeta.ColumnMeta parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static io.mycat.meta.protocol.MyCatMeta.ColumnMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.ColumnMeta parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static io.mycat.meta.protocol.MyCatMeta.ColumnMeta parseFrom(java.io.InputStream input) + public static io.mycat.meta.protocol.StructureMeta.ColumnMeta parseFrom(java.io.InputStream input) throws java.io.IOException { return PARSER.parseFrom(input); } - public static io.mycat.meta.protocol.MyCatMeta.ColumnMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.ColumnMeta parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return PARSER.parseFrom(input, extensionRegistry); } - public static io.mycat.meta.protocol.MyCatMeta.ColumnMeta parseDelimitedFrom(java.io.InputStream input) + public static io.mycat.meta.protocol.StructureMeta.ColumnMeta parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return PARSER.parseDelimitedFrom(input); } - public static io.mycat.meta.protocol.MyCatMeta.ColumnMeta parseDelimitedFrom( + public static io.mycat.meta.protocol.StructureMeta.ColumnMeta parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return PARSER.parseDelimitedFrom(input, extensionRegistry); } - public static io.mycat.meta.protocol.MyCatMeta.ColumnMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.ColumnMeta parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return PARSER.parseFrom(input); } - public static io.mycat.meta.protocol.MyCatMeta.ColumnMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.ColumnMeta parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { @@ -1634,7 +1633,7 @@ public final class MyCatMeta { public static Builder newBuilder() { return Builder.create(); } public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(io.mycat.meta.protocol.MyCatMeta.ColumnMeta prototype) { + public static Builder newBuilder(io.mycat.meta.protocol.StructureMeta.ColumnMeta prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); } @@ -1651,20 +1650,20 @@ public final class MyCatMeta { public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements // @@protoc_insertion_point(builder_implements:io.mycat.meta.protocol.ColumnMeta) - io.mycat.meta.protocol.MyCatMeta.ColumnMetaOrBuilder { + io.mycat.meta.protocol.StructureMeta.ColumnMetaOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_ColumnMeta_descriptor; + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_ColumnMeta_descriptor; } protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_ColumnMeta_fieldAccessorTable + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_ColumnMeta_fieldAccessorTable .ensureFieldAccessorsInitialized( - io.mycat.meta.protocol.MyCatMeta.ColumnMeta.class, io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder.class); + io.mycat.meta.protocol.StructureMeta.ColumnMeta.class, io.mycat.meta.protocol.StructureMeta.ColumnMeta.Builder.class); } - // Construct using io.mycat.meta.protocol.MyCatMeta.ColumnMeta.newBuilder() + // Construct using io.mycat.meta.protocol.StructureMeta.ColumnMeta.newBuilder() private Builder() { maybeForceBuilderInitialization(); } @@ -1713,23 +1712,23 @@ public final class MyCatMeta { public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_ColumnMeta_descriptor; + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_ColumnMeta_descriptor; } - public io.mycat.meta.protocol.MyCatMeta.ColumnMeta getDefaultInstanceForType() { - return io.mycat.meta.protocol.MyCatMeta.ColumnMeta.getDefaultInstance(); + public io.mycat.meta.protocol.StructureMeta.ColumnMeta getDefaultInstanceForType() { + return io.mycat.meta.protocol.StructureMeta.ColumnMeta.getDefaultInstance(); } - public io.mycat.meta.protocol.MyCatMeta.ColumnMeta build() { - io.mycat.meta.protocol.MyCatMeta.ColumnMeta result = buildPartial(); + public io.mycat.meta.protocol.StructureMeta.ColumnMeta build() { + io.mycat.meta.protocol.StructureMeta.ColumnMeta result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; } - public io.mycat.meta.protocol.MyCatMeta.ColumnMeta buildPartial() { - io.mycat.meta.protocol.MyCatMeta.ColumnMeta result = new io.mycat.meta.protocol.MyCatMeta.ColumnMeta(this); + public io.mycat.meta.protocol.StructureMeta.ColumnMeta buildPartial() { + io.mycat.meta.protocol.StructureMeta.ColumnMeta result = new io.mycat.meta.protocol.StructureMeta.ColumnMeta(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { @@ -1778,16 +1777,16 @@ public final class MyCatMeta { } public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.mycat.meta.protocol.MyCatMeta.ColumnMeta) { - return mergeFrom((io.mycat.meta.protocol.MyCatMeta.ColumnMeta)other); + if (other instanceof io.mycat.meta.protocol.StructureMeta.ColumnMeta) { + return mergeFrom((io.mycat.meta.protocol.StructureMeta.ColumnMeta)other); } else { super.mergeFrom(other); return this; } } - public Builder mergeFrom(io.mycat.meta.protocol.MyCatMeta.ColumnMeta other) { - if (other == io.mycat.meta.protocol.MyCatMeta.ColumnMeta.getDefaultInstance()) return this; + public Builder mergeFrom(io.mycat.meta.protocol.StructureMeta.ColumnMeta other) { + if (other == io.mycat.meta.protocol.StructureMeta.ColumnMeta.getDefaultInstance()) return this; if (other.hasName()) { bitField0_ |= 0x00000001; name_ = other.name_; @@ -1846,11 +1845,11 @@ public final class MyCatMeta { com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - io.mycat.meta.protocol.MyCatMeta.ColumnMeta parsedMessage = null; + io.mycat.meta.protocol.StructureMeta.ColumnMeta parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.mycat.meta.protocol.MyCatMeta.ColumnMeta) e.getUnfinishedMessage(); + parsedMessage = (io.mycat.meta.protocol.StructureMeta.ColumnMeta) e.getUnfinishedMessage(); throw e; } finally { if (parsedMessage != null) { @@ -2453,7 +2452,7 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - java.util.List + java.util.List getColumnsList(); /** * repeated .io.mycat.meta.protocol.ColumnMeta columns = 2; @@ -2462,7 +2461,7 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - io.mycat.meta.protocol.MyCatMeta.ColumnMeta getColumns(int index); + io.mycat.meta.protocol.StructureMeta.ColumnMeta getColumns(int index); /** * repeated .io.mycat.meta.protocol.ColumnMeta columns = 2; * @@ -2478,7 +2477,7 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - java.util.List + java.util.List getColumnsOrBuilderList(); /** * repeated .io.mycat.meta.protocol.ColumnMeta columns = 2; @@ -2487,7 +2486,7 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - io.mycat.meta.protocol.MyCatMeta.ColumnMetaOrBuilder getColumnsOrBuilder( + io.mycat.meta.protocol.StructureMeta.ColumnMetaOrBuilder getColumnsOrBuilder( int index); /** @@ -2556,21 +2555,21 @@ public final class MyCatMeta { /** * optional .io.mycat.meta.protocol.IndexMeta primary = 9; */ - io.mycat.meta.protocol.MyCatMeta.IndexMeta getPrimary(); + io.mycat.meta.protocol.StructureMeta.IndexMeta getPrimary(); /** * optional .io.mycat.meta.protocol.IndexMeta primary = 9; */ - io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder getPrimaryOrBuilder(); + io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder getPrimaryOrBuilder(); /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - java.util.List + java.util.List getUniIndexList(); /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - io.mycat.meta.protocol.MyCatMeta.IndexMeta getUniIndex(int index); + io.mycat.meta.protocol.StructureMeta.IndexMeta getUniIndex(int index); /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ @@ -2578,23 +2577,23 @@ public final class MyCatMeta { /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - java.util.List + java.util.List getUniIndexOrBuilderList(); /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder getUniIndexOrBuilder( + io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder getUniIndexOrBuilder( int index); /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - java.util.List + java.util.List getIndexList(); /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - io.mycat.meta.protocol.MyCatMeta.IndexMeta getIndex(int index); + io.mycat.meta.protocol.StructureMeta.IndexMeta getIndex(int index); /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ @@ -2602,12 +2601,12 @@ public final class MyCatMeta { /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - java.util.List + java.util.List getIndexOrBuilderList(); /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder getIndexOrBuilder( + io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder getIndexOrBuilder( int index); } /** @@ -2670,10 +2669,10 @@ public final class MyCatMeta { } case 18: { if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - columns_ = new java.util.ArrayList(); + columns_ = new java.util.ArrayList(); mutable_bitField0_ |= 0x00000002; } - columns_.add(input.readMessage(io.mycat.meta.protocol.MyCatMeta.ColumnMeta.PARSER, extensionRegistry)); + columns_.add(input.readMessage(io.mycat.meta.protocol.StructureMeta.ColumnMeta.PARSER, extensionRegistry)); break; } case 24: { @@ -2708,11 +2707,11 @@ public final class MyCatMeta { break; } case 74: { - io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder subBuilder = null; + io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder subBuilder = null; if (((bitField0_ & 0x00000080) == 0x00000080)) { subBuilder = primary_.toBuilder(); } - primary_ = input.readMessage(io.mycat.meta.protocol.MyCatMeta.IndexMeta.PARSER, extensionRegistry); + primary_ = input.readMessage(io.mycat.meta.protocol.StructureMeta.IndexMeta.PARSER, extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom(primary_); primary_ = subBuilder.buildPartial(); @@ -2722,18 +2721,18 @@ public final class MyCatMeta { } case 82: { if (!((mutable_bitField0_ & 0x00000200) == 0x00000200)) { - uniIndex_ = new java.util.ArrayList(); + uniIndex_ = new java.util.ArrayList(); mutable_bitField0_ |= 0x00000200; } - uniIndex_.add(input.readMessage(io.mycat.meta.protocol.MyCatMeta.IndexMeta.PARSER, extensionRegistry)); + uniIndex_.add(input.readMessage(io.mycat.meta.protocol.StructureMeta.IndexMeta.PARSER, extensionRegistry)); break; } case 90: { if (!((mutable_bitField0_ & 0x00000400) == 0x00000400)) { - index_ = new java.util.ArrayList(); + index_ = new java.util.ArrayList(); mutable_bitField0_ |= 0x00000400; } - index_.add(input.readMessage(io.mycat.meta.protocol.MyCatMeta.IndexMeta.PARSER, extensionRegistry)); + index_.add(input.readMessage(io.mycat.meta.protocol.StructureMeta.IndexMeta.PARSER, extensionRegistry)); break; } } @@ -2759,14 +2758,14 @@ public final class MyCatMeta { } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_TableMeta_descriptor; + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_TableMeta_descriptor; } protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_TableMeta_fieldAccessorTable + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_TableMeta_fieldAccessorTable .ensureFieldAccessorsInitialized( - io.mycat.meta.protocol.MyCatMeta.TableMeta.class, io.mycat.meta.protocol.MyCatMeta.TableMeta.Builder.class); + io.mycat.meta.protocol.StructureMeta.TableMeta.class, io.mycat.meta.protocol.StructureMeta.TableMeta.Builder.class); } public static com.google.protobuf.Parser PARSER = @@ -2840,7 +2839,7 @@ public final class MyCatMeta { } public static final int COLUMNS_FIELD_NUMBER = 2; - private java.util.List columns_; + private java.util.List columns_; /** * repeated .io.mycat.meta.protocol.ColumnMeta columns = 2; * @@ -2848,7 +2847,7 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - public java.util.List getColumnsList() { + public java.util.List getColumnsList() { return columns_; } /** @@ -2858,7 +2857,7 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - public java.util.List + public java.util.List getColumnsOrBuilderList() { return columns_; } @@ -2879,7 +2878,7 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - public io.mycat.meta.protocol.MyCatMeta.ColumnMeta getColumns(int index) { + public io.mycat.meta.protocol.StructureMeta.ColumnMeta getColumns(int index) { return columns_.get(index); } /** @@ -2889,7 +2888,7 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - public io.mycat.meta.protocol.MyCatMeta.ColumnMetaOrBuilder getColumnsOrBuilder( + public io.mycat.meta.protocol.StructureMeta.ColumnMetaOrBuilder getColumnsOrBuilder( int index) { return columns_.get(index); } @@ -3012,7 +3011,7 @@ public final class MyCatMeta { } public static final int PRIMARY_FIELD_NUMBER = 9; - private io.mycat.meta.protocol.MyCatMeta.IndexMeta primary_; + private io.mycat.meta.protocol.StructureMeta.IndexMeta primary_; /** * optional .io.mycat.meta.protocol.IndexMeta primary = 9; */ @@ -3022,28 +3021,28 @@ public final class MyCatMeta { /** * optional .io.mycat.meta.protocol.IndexMeta primary = 9; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMeta getPrimary() { + public io.mycat.meta.protocol.StructureMeta.IndexMeta getPrimary() { return primary_; } /** * optional .io.mycat.meta.protocol.IndexMeta primary = 9; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder getPrimaryOrBuilder() { + public io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder getPrimaryOrBuilder() { return primary_; } public static final int UNIINDEX_FIELD_NUMBER = 10; - private java.util.List uniIndex_; + private java.util.List uniIndex_; /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - public java.util.List getUniIndexList() { + public java.util.List getUniIndexList() { return uniIndex_; } /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - public java.util.List + public java.util.List getUniIndexOrBuilderList() { return uniIndex_; } @@ -3056,29 +3055,29 @@ public final class MyCatMeta { /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMeta getUniIndex(int index) { + public io.mycat.meta.protocol.StructureMeta.IndexMeta getUniIndex(int index) { return uniIndex_.get(index); } /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder getUniIndexOrBuilder( + public io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder getUniIndexOrBuilder( int index) { return uniIndex_.get(index); } public static final int INDEX_FIELD_NUMBER = 11; - private java.util.List index_; + private java.util.List index_; /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - public java.util.List getIndexList() { + public java.util.List getIndexList() { return index_; } /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - public java.util.List + public java.util.List getIndexOrBuilderList() { return index_; } @@ -3091,13 +3090,13 @@ public final class MyCatMeta { /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMeta getIndex(int index) { + public io.mycat.meta.protocol.StructureMeta.IndexMeta getIndex(int index) { return index_.get(index); } /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder getIndexOrBuilder( + public io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder getIndexOrBuilder( int index) { return index_.get(index); } @@ -3111,7 +3110,7 @@ public final class MyCatMeta { aiOffset_ = -1L; type_ = 0; aiColPos_ = -1; - primary_ = io.mycat.meta.protocol.MyCatMeta.IndexMeta.getDefaultInstance(); + primary_ = io.mycat.meta.protocol.StructureMeta.IndexMeta.getDefaultInstance(); uniIndex_ = java.util.Collections.emptyList(); index_ = java.util.Collections.emptyList(); } @@ -3250,53 +3249,53 @@ public final class MyCatMeta { return super.writeReplace(); } - public static io.mycat.meta.protocol.MyCatMeta.TableMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.TableMeta parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static io.mycat.meta.protocol.MyCatMeta.TableMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.TableMeta parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static io.mycat.meta.protocol.MyCatMeta.TableMeta parseFrom(byte[] data) + public static io.mycat.meta.protocol.StructureMeta.TableMeta parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static io.mycat.meta.protocol.MyCatMeta.TableMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.TableMeta parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static io.mycat.meta.protocol.MyCatMeta.TableMeta parseFrom(java.io.InputStream input) + public static io.mycat.meta.protocol.StructureMeta.TableMeta parseFrom(java.io.InputStream input) throws java.io.IOException { return PARSER.parseFrom(input); } - public static io.mycat.meta.protocol.MyCatMeta.TableMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.TableMeta parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return PARSER.parseFrom(input, extensionRegistry); } - public static io.mycat.meta.protocol.MyCatMeta.TableMeta parseDelimitedFrom(java.io.InputStream input) + public static io.mycat.meta.protocol.StructureMeta.TableMeta parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return PARSER.parseDelimitedFrom(input); } - public static io.mycat.meta.protocol.MyCatMeta.TableMeta parseDelimitedFrom( + public static io.mycat.meta.protocol.StructureMeta.TableMeta parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return PARSER.parseDelimitedFrom(input, extensionRegistry); } - public static io.mycat.meta.protocol.MyCatMeta.TableMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.TableMeta parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return PARSER.parseFrom(input); } - public static io.mycat.meta.protocol.MyCatMeta.TableMeta parseFrom( + public static io.mycat.meta.protocol.StructureMeta.TableMeta parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { @@ -3305,7 +3304,7 @@ public final class MyCatMeta { public static Builder newBuilder() { return Builder.create(); } public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(io.mycat.meta.protocol.MyCatMeta.TableMeta prototype) { + public static Builder newBuilder(io.mycat.meta.protocol.StructureMeta.TableMeta prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); } @@ -3322,20 +3321,20 @@ public final class MyCatMeta { public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements // @@protoc_insertion_point(builder_implements:io.mycat.meta.protocol.TableMeta) - io.mycat.meta.protocol.MyCatMeta.TableMetaOrBuilder { + io.mycat.meta.protocol.StructureMeta.TableMetaOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_TableMeta_descriptor; + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_TableMeta_descriptor; } protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_TableMeta_fieldAccessorTable + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_TableMeta_fieldAccessorTable .ensureFieldAccessorsInitialized( - io.mycat.meta.protocol.MyCatMeta.TableMeta.class, io.mycat.meta.protocol.MyCatMeta.TableMeta.Builder.class); + io.mycat.meta.protocol.StructureMeta.TableMeta.class, io.mycat.meta.protocol.StructureMeta.TableMeta.Builder.class); } - // Construct using io.mycat.meta.protocol.MyCatMeta.TableMeta.newBuilder() + // Construct using io.mycat.meta.protocol.StructureMeta.TableMeta.newBuilder() private Builder() { maybeForceBuilderInitialization(); } @@ -3380,7 +3379,7 @@ public final class MyCatMeta { aiColPos_ = -1; bitField0_ = (bitField0_ & ~0x00000080); if (primaryBuilder_ == null) { - primary_ = io.mycat.meta.protocol.MyCatMeta.IndexMeta.getDefaultInstance(); + primary_ = io.mycat.meta.protocol.StructureMeta.IndexMeta.getDefaultInstance(); } else { primaryBuilder_.clear(); } @@ -3406,23 +3405,23 @@ public final class MyCatMeta { public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return io.mycat.meta.protocol.MyCatMeta.internal_static_io_mycat_meta_protocol_TableMeta_descriptor; + return io.mycat.meta.protocol.StructureMeta.internal_static_io_mycat_meta_protocol_TableMeta_descriptor; } - public io.mycat.meta.protocol.MyCatMeta.TableMeta getDefaultInstanceForType() { - return io.mycat.meta.protocol.MyCatMeta.TableMeta.getDefaultInstance(); + public io.mycat.meta.protocol.StructureMeta.TableMeta getDefaultInstanceForType() { + return io.mycat.meta.protocol.StructureMeta.TableMeta.getDefaultInstance(); } - public io.mycat.meta.protocol.MyCatMeta.TableMeta build() { - io.mycat.meta.protocol.MyCatMeta.TableMeta result = buildPartial(); + public io.mycat.meta.protocol.StructureMeta.TableMeta build() { + io.mycat.meta.protocol.StructureMeta.TableMeta result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; } - public io.mycat.meta.protocol.MyCatMeta.TableMeta buildPartial() { - io.mycat.meta.protocol.MyCatMeta.TableMeta result = new io.mycat.meta.protocol.MyCatMeta.TableMeta(this); + public io.mycat.meta.protocol.StructureMeta.TableMeta buildPartial() { + io.mycat.meta.protocol.StructureMeta.TableMeta result = new io.mycat.meta.protocol.StructureMeta.TableMeta(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { @@ -3494,16 +3493,16 @@ public final class MyCatMeta { } public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof io.mycat.meta.protocol.MyCatMeta.TableMeta) { - return mergeFrom((io.mycat.meta.protocol.MyCatMeta.TableMeta)other); + if (other instanceof io.mycat.meta.protocol.StructureMeta.TableMeta) { + return mergeFrom((io.mycat.meta.protocol.StructureMeta.TableMeta)other); } else { super.mergeFrom(other); return this; } } - public Builder mergeFrom(io.mycat.meta.protocol.MyCatMeta.TableMeta other) { - if (other == io.mycat.meta.protocol.MyCatMeta.TableMeta.getDefaultInstance()) return this; + public Builder mergeFrom(io.mycat.meta.protocol.StructureMeta.TableMeta other) { + if (other == io.mycat.meta.protocol.StructureMeta.TableMeta.getDefaultInstance()) return this; if (other.hasTableName()) { bitField0_ |= 0x00000001; tableName_ = other.tableName_; @@ -3646,11 +3645,11 @@ public final class MyCatMeta { com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - io.mycat.meta.protocol.MyCatMeta.TableMeta parsedMessage = null; + io.mycat.meta.protocol.StructureMeta.TableMeta parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (io.mycat.meta.protocol.MyCatMeta.TableMeta) e.getUnfinishedMessage(); + parsedMessage = (io.mycat.meta.protocol.StructureMeta.TableMeta) e.getUnfinishedMessage(); throw e; } finally { if (parsedMessage != null) { @@ -3761,17 +3760,17 @@ public final class MyCatMeta { return this; } - private java.util.List columns_ = + private java.util.List columns_ = java.util.Collections.emptyList(); private void ensureColumnsIsMutable() { if (!((bitField0_ & 0x00000002) == 0x00000002)) { - columns_ = new java.util.ArrayList(columns_); + columns_ = new java.util.ArrayList(columns_); bitField0_ |= 0x00000002; } } private com.google.protobuf.RepeatedFieldBuilder< - io.mycat.meta.protocol.MyCatMeta.ColumnMeta, io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder, io.mycat.meta.protocol.MyCatMeta.ColumnMetaOrBuilder> columnsBuilder_; + io.mycat.meta.protocol.StructureMeta.ColumnMeta, io.mycat.meta.protocol.StructureMeta.ColumnMeta.Builder, io.mycat.meta.protocol.StructureMeta.ColumnMetaOrBuilder> columnsBuilder_; /** * repeated .io.mycat.meta.protocol.ColumnMeta columns = 2; @@ -3780,7 +3779,7 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - public java.util.List getColumnsList() { + public java.util.List getColumnsList() { if (columnsBuilder_ == null) { return java.util.Collections.unmodifiableList(columns_); } else { @@ -3808,7 +3807,7 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - public io.mycat.meta.protocol.MyCatMeta.ColumnMeta getColumns(int index) { + public io.mycat.meta.protocol.StructureMeta.ColumnMeta getColumns(int index) { if (columnsBuilder_ == null) { return columns_.get(index); } else { @@ -3823,7 +3822,7 @@ public final class MyCatMeta { * */ public Builder setColumns( - int index, io.mycat.meta.protocol.MyCatMeta.ColumnMeta value) { + int index, io.mycat.meta.protocol.StructureMeta.ColumnMeta value) { if (columnsBuilder_ == null) { if (value == null) { throw new NullPointerException(); @@ -3844,7 +3843,7 @@ public final class MyCatMeta { * */ public Builder setColumns( - int index, io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder builderForValue) { + int index, io.mycat.meta.protocol.StructureMeta.ColumnMeta.Builder builderForValue) { if (columnsBuilder_ == null) { ensureColumnsIsMutable(); columns_.set(index, builderForValue.build()); @@ -3861,7 +3860,7 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - public Builder addColumns(io.mycat.meta.protocol.MyCatMeta.ColumnMeta value) { + public Builder addColumns(io.mycat.meta.protocol.StructureMeta.ColumnMeta value) { if (columnsBuilder_ == null) { if (value == null) { throw new NullPointerException(); @@ -3882,7 +3881,7 @@ public final class MyCatMeta { * */ public Builder addColumns( - int index, io.mycat.meta.protocol.MyCatMeta.ColumnMeta value) { + int index, io.mycat.meta.protocol.StructureMeta.ColumnMeta value) { if (columnsBuilder_ == null) { if (value == null) { throw new NullPointerException(); @@ -3903,7 +3902,7 @@ public final class MyCatMeta { * */ public Builder addColumns( - io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder builderForValue) { + io.mycat.meta.protocol.StructureMeta.ColumnMeta.Builder builderForValue) { if (columnsBuilder_ == null) { ensureColumnsIsMutable(); columns_.add(builderForValue.build()); @@ -3921,7 +3920,7 @@ public final class MyCatMeta { * */ public Builder addColumns( - int index, io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder builderForValue) { + int index, io.mycat.meta.protocol.StructureMeta.ColumnMeta.Builder builderForValue) { if (columnsBuilder_ == null) { ensureColumnsIsMutable(); columns_.add(index, builderForValue.build()); @@ -3939,7 +3938,7 @@ public final class MyCatMeta { * */ public Builder addAllColumns( - java.lang.Iterable values) { + java.lang.Iterable values) { if (columnsBuilder_ == null) { ensureColumnsIsMutable(); com.google.protobuf.AbstractMessageLite.Builder.addAll( @@ -3991,7 +3990,7 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - public io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder getColumnsBuilder( + public io.mycat.meta.protocol.StructureMeta.ColumnMeta.Builder getColumnsBuilder( int index) { return getColumnsFieldBuilder().getBuilder(index); } @@ -4002,7 +4001,7 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - public io.mycat.meta.protocol.MyCatMeta.ColumnMetaOrBuilder getColumnsOrBuilder( + public io.mycat.meta.protocol.StructureMeta.ColumnMetaOrBuilder getColumnsOrBuilder( int index) { if (columnsBuilder_ == null) { return columns_.get(index); } else { @@ -4016,7 +4015,7 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - public java.util.List + public java.util.List getColumnsOrBuilderList() { if (columnsBuilder_ != null) { return columnsBuilder_.getMessageOrBuilderList(); @@ -4031,9 +4030,9 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - public io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder addColumnsBuilder() { + public io.mycat.meta.protocol.StructureMeta.ColumnMeta.Builder addColumnsBuilder() { return getColumnsFieldBuilder().addBuilder( - io.mycat.meta.protocol.MyCatMeta.ColumnMeta.getDefaultInstance()); + io.mycat.meta.protocol.StructureMeta.ColumnMeta.getDefaultInstance()); } /** * repeated .io.mycat.meta.protocol.ColumnMeta columns = 2; @@ -4042,10 +4041,10 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - public io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder addColumnsBuilder( + public io.mycat.meta.protocol.StructureMeta.ColumnMeta.Builder addColumnsBuilder( int index) { return getColumnsFieldBuilder().addBuilder( - index, io.mycat.meta.protocol.MyCatMeta.ColumnMeta.getDefaultInstance()); + index, io.mycat.meta.protocol.StructureMeta.ColumnMeta.getDefaultInstance()); } /** * repeated .io.mycat.meta.protocol.ColumnMeta columns = 2; @@ -4054,16 +4053,16 @@ public final class MyCatMeta { *所有的列属性,有序 * */ - public java.util.List + public java.util.List getColumnsBuilderList() { return getColumnsFieldBuilder().getBuilderList(); } private com.google.protobuf.RepeatedFieldBuilder< - io.mycat.meta.protocol.MyCatMeta.ColumnMeta, io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder, io.mycat.meta.protocol.MyCatMeta.ColumnMetaOrBuilder> + io.mycat.meta.protocol.StructureMeta.ColumnMeta, io.mycat.meta.protocol.StructureMeta.ColumnMeta.Builder, io.mycat.meta.protocol.StructureMeta.ColumnMetaOrBuilder> getColumnsFieldBuilder() { if (columnsBuilder_ == null) { columnsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - io.mycat.meta.protocol.MyCatMeta.ColumnMeta, io.mycat.meta.protocol.MyCatMeta.ColumnMeta.Builder, io.mycat.meta.protocol.MyCatMeta.ColumnMetaOrBuilder>( + io.mycat.meta.protocol.StructureMeta.ColumnMeta, io.mycat.meta.protocol.StructureMeta.ColumnMeta.Builder, io.mycat.meta.protocol.StructureMeta.ColumnMetaOrBuilder>( columns_, ((bitField0_ & 0x00000002) == 0x00000002), getParentForChildren(), @@ -4309,9 +4308,9 @@ public final class MyCatMeta { return this; } - private io.mycat.meta.protocol.MyCatMeta.IndexMeta primary_ = io.mycat.meta.protocol.MyCatMeta.IndexMeta.getDefaultInstance(); + private io.mycat.meta.protocol.StructureMeta.IndexMeta primary_ = io.mycat.meta.protocol.StructureMeta.IndexMeta.getDefaultInstance(); private com.google.protobuf.SingleFieldBuilder< - io.mycat.meta.protocol.MyCatMeta.IndexMeta, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder, io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder> primaryBuilder_; + io.mycat.meta.protocol.StructureMeta.IndexMeta, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder, io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder> primaryBuilder_; /** * optional .io.mycat.meta.protocol.IndexMeta primary = 9; */ @@ -4321,7 +4320,7 @@ public final class MyCatMeta { /** * optional .io.mycat.meta.protocol.IndexMeta primary = 9; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMeta getPrimary() { + public io.mycat.meta.protocol.StructureMeta.IndexMeta getPrimary() { if (primaryBuilder_ == null) { return primary_; } else { @@ -4331,7 +4330,7 @@ public final class MyCatMeta { /** * optional .io.mycat.meta.protocol.IndexMeta primary = 9; */ - public Builder setPrimary(io.mycat.meta.protocol.MyCatMeta.IndexMeta value) { + public Builder setPrimary(io.mycat.meta.protocol.StructureMeta.IndexMeta value) { if (primaryBuilder_ == null) { if (value == null) { throw new NullPointerException(); @@ -4348,7 +4347,7 @@ public final class MyCatMeta { * optional .io.mycat.meta.protocol.IndexMeta primary = 9; */ public Builder setPrimary( - io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder builderForValue) { + io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder builderForValue) { if (primaryBuilder_ == null) { primary_ = builderForValue.build(); onChanged(); @@ -4361,12 +4360,12 @@ public final class MyCatMeta { /** * optional .io.mycat.meta.protocol.IndexMeta primary = 9; */ - public Builder mergePrimary(io.mycat.meta.protocol.MyCatMeta.IndexMeta value) { + public Builder mergePrimary(io.mycat.meta.protocol.StructureMeta.IndexMeta value) { if (primaryBuilder_ == null) { if (((bitField0_ & 0x00000100) == 0x00000100) && - primary_ != io.mycat.meta.protocol.MyCatMeta.IndexMeta.getDefaultInstance()) { + primary_ != io.mycat.meta.protocol.StructureMeta.IndexMeta.getDefaultInstance()) { primary_ = - io.mycat.meta.protocol.MyCatMeta.IndexMeta.newBuilder(primary_).mergeFrom(value).buildPartial(); + io.mycat.meta.protocol.StructureMeta.IndexMeta.newBuilder(primary_).mergeFrom(value).buildPartial(); } else { primary_ = value; } @@ -4382,7 +4381,7 @@ public final class MyCatMeta { */ public Builder clearPrimary() { if (primaryBuilder_ == null) { - primary_ = io.mycat.meta.protocol.MyCatMeta.IndexMeta.getDefaultInstance(); + primary_ = io.mycat.meta.protocol.StructureMeta.IndexMeta.getDefaultInstance(); onChanged(); } else { primaryBuilder_.clear(); @@ -4393,7 +4392,7 @@ public final class MyCatMeta { /** * optional .io.mycat.meta.protocol.IndexMeta primary = 9; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder getPrimaryBuilder() { + public io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder getPrimaryBuilder() { bitField0_ |= 0x00000100; onChanged(); return getPrimaryFieldBuilder().getBuilder(); @@ -4401,7 +4400,7 @@ public final class MyCatMeta { /** * optional .io.mycat.meta.protocol.IndexMeta primary = 9; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder getPrimaryOrBuilder() { + public io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder getPrimaryOrBuilder() { if (primaryBuilder_ != null) { return primaryBuilder_.getMessageOrBuilder(); } else { @@ -4412,11 +4411,11 @@ public final class MyCatMeta { * optional .io.mycat.meta.protocol.IndexMeta primary = 9; */ private com.google.protobuf.SingleFieldBuilder< - io.mycat.meta.protocol.MyCatMeta.IndexMeta, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder, io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder> + io.mycat.meta.protocol.StructureMeta.IndexMeta, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder, io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder> getPrimaryFieldBuilder() { if (primaryBuilder_ == null) { primaryBuilder_ = new com.google.protobuf.SingleFieldBuilder< - io.mycat.meta.protocol.MyCatMeta.IndexMeta, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder, io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder>( + io.mycat.meta.protocol.StructureMeta.IndexMeta, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder, io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder>( getPrimary(), getParentForChildren(), isClean()); @@ -4425,22 +4424,22 @@ public final class MyCatMeta { return primaryBuilder_; } - private java.util.List uniIndex_ = + private java.util.List uniIndex_ = java.util.Collections.emptyList(); private void ensureUniIndexIsMutable() { if (!((bitField0_ & 0x00000200) == 0x00000200)) { - uniIndex_ = new java.util.ArrayList(uniIndex_); + uniIndex_ = new java.util.ArrayList(uniIndex_); bitField0_ |= 0x00000200; } } private com.google.protobuf.RepeatedFieldBuilder< - io.mycat.meta.protocol.MyCatMeta.IndexMeta, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder, io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder> uniIndexBuilder_; + io.mycat.meta.protocol.StructureMeta.IndexMeta, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder, io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder> uniIndexBuilder_; /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - public java.util.List getUniIndexList() { + public java.util.List getUniIndexList() { if (uniIndexBuilder_ == null) { return java.util.Collections.unmodifiableList(uniIndex_); } else { @@ -4460,7 +4459,7 @@ public final class MyCatMeta { /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMeta getUniIndex(int index) { + public io.mycat.meta.protocol.StructureMeta.IndexMeta getUniIndex(int index) { if (uniIndexBuilder_ == null) { return uniIndex_.get(index); } else { @@ -4471,7 +4470,7 @@ public final class MyCatMeta { * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ public Builder setUniIndex( - int index, io.mycat.meta.protocol.MyCatMeta.IndexMeta value) { + int index, io.mycat.meta.protocol.StructureMeta.IndexMeta value) { if (uniIndexBuilder_ == null) { if (value == null) { throw new NullPointerException(); @@ -4488,7 +4487,7 @@ public final class MyCatMeta { * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ public Builder setUniIndex( - int index, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder builderForValue) { + int index, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder builderForValue) { if (uniIndexBuilder_ == null) { ensureUniIndexIsMutable(); uniIndex_.set(index, builderForValue.build()); @@ -4501,7 +4500,7 @@ public final class MyCatMeta { /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - public Builder addUniIndex(io.mycat.meta.protocol.MyCatMeta.IndexMeta value) { + public Builder addUniIndex(io.mycat.meta.protocol.StructureMeta.IndexMeta value) { if (uniIndexBuilder_ == null) { if (value == null) { throw new NullPointerException(); @@ -4518,7 +4517,7 @@ public final class MyCatMeta { * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ public Builder addUniIndex( - int index, io.mycat.meta.protocol.MyCatMeta.IndexMeta value) { + int index, io.mycat.meta.protocol.StructureMeta.IndexMeta value) { if (uniIndexBuilder_ == null) { if (value == null) { throw new NullPointerException(); @@ -4535,7 +4534,7 @@ public final class MyCatMeta { * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ public Builder addUniIndex( - io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder builderForValue) { + io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder builderForValue) { if (uniIndexBuilder_ == null) { ensureUniIndexIsMutable(); uniIndex_.add(builderForValue.build()); @@ -4549,7 +4548,7 @@ public final class MyCatMeta { * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ public Builder addUniIndex( - int index, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder builderForValue) { + int index, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder builderForValue) { if (uniIndexBuilder_ == null) { ensureUniIndexIsMutable(); uniIndex_.add(index, builderForValue.build()); @@ -4563,7 +4562,7 @@ public final class MyCatMeta { * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ public Builder addAllUniIndex( - java.lang.Iterable values) { + java.lang.Iterable values) { if (uniIndexBuilder_ == null) { ensureUniIndexIsMutable(); com.google.protobuf.AbstractMessageLite.Builder.addAll( @@ -4603,14 +4602,14 @@ public final class MyCatMeta { /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder getUniIndexBuilder( + public io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder getUniIndexBuilder( int index) { return getUniIndexFieldBuilder().getBuilder(index); } /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder getUniIndexOrBuilder( + public io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder getUniIndexOrBuilder( int index) { if (uniIndexBuilder_ == null) { return uniIndex_.get(index); } else { @@ -4620,7 +4619,7 @@ public final class MyCatMeta { /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - public java.util.List + public java.util.List getUniIndexOrBuilderList() { if (uniIndexBuilder_ != null) { return uniIndexBuilder_.getMessageOrBuilderList(); @@ -4631,31 +4630,31 @@ public final class MyCatMeta { /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder addUniIndexBuilder() { + public io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder addUniIndexBuilder() { return getUniIndexFieldBuilder().addBuilder( - io.mycat.meta.protocol.MyCatMeta.IndexMeta.getDefaultInstance()); + io.mycat.meta.protocol.StructureMeta.IndexMeta.getDefaultInstance()); } /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder addUniIndexBuilder( + public io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder addUniIndexBuilder( int index) { return getUniIndexFieldBuilder().addBuilder( - index, io.mycat.meta.protocol.MyCatMeta.IndexMeta.getDefaultInstance()); + index, io.mycat.meta.protocol.StructureMeta.IndexMeta.getDefaultInstance()); } /** * repeated .io.mycat.meta.protocol.IndexMeta uniIndex = 10; */ - public java.util.List + public java.util.List getUniIndexBuilderList() { return getUniIndexFieldBuilder().getBuilderList(); } private com.google.protobuf.RepeatedFieldBuilder< - io.mycat.meta.protocol.MyCatMeta.IndexMeta, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder, io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder> + io.mycat.meta.protocol.StructureMeta.IndexMeta, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder, io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder> getUniIndexFieldBuilder() { if (uniIndexBuilder_ == null) { uniIndexBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - io.mycat.meta.protocol.MyCatMeta.IndexMeta, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder, io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder>( + io.mycat.meta.protocol.StructureMeta.IndexMeta, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder, io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder>( uniIndex_, ((bitField0_ & 0x00000200) == 0x00000200), getParentForChildren(), @@ -4665,22 +4664,22 @@ public final class MyCatMeta { return uniIndexBuilder_; } - private java.util.List index_ = + private java.util.List index_ = java.util.Collections.emptyList(); private void ensureIndexIsMutable() { if (!((bitField0_ & 0x00000400) == 0x00000400)) { - index_ = new java.util.ArrayList(index_); + index_ = new java.util.ArrayList(index_); bitField0_ |= 0x00000400; } } private com.google.protobuf.RepeatedFieldBuilder< - io.mycat.meta.protocol.MyCatMeta.IndexMeta, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder, io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder> indexBuilder_; + io.mycat.meta.protocol.StructureMeta.IndexMeta, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder, io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder> indexBuilder_; /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - public java.util.List getIndexList() { + public java.util.List getIndexList() { if (indexBuilder_ == null) { return java.util.Collections.unmodifiableList(index_); } else { @@ -4700,7 +4699,7 @@ public final class MyCatMeta { /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMeta getIndex(int index) { + public io.mycat.meta.protocol.StructureMeta.IndexMeta getIndex(int index) { if (indexBuilder_ == null) { return index_.get(index); } else { @@ -4711,7 +4710,7 @@ public final class MyCatMeta { * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ public Builder setIndex( - int index, io.mycat.meta.protocol.MyCatMeta.IndexMeta value) { + int index, io.mycat.meta.protocol.StructureMeta.IndexMeta value) { if (indexBuilder_ == null) { if (value == null) { throw new NullPointerException(); @@ -4728,7 +4727,7 @@ public final class MyCatMeta { * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ public Builder setIndex( - int index, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder builderForValue) { + int index, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder builderForValue) { if (indexBuilder_ == null) { ensureIndexIsMutable(); index_.set(index, builderForValue.build()); @@ -4741,7 +4740,7 @@ public final class MyCatMeta { /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - public Builder addIndex(io.mycat.meta.protocol.MyCatMeta.IndexMeta value) { + public Builder addIndex(io.mycat.meta.protocol.StructureMeta.IndexMeta value) { if (indexBuilder_ == null) { if (value == null) { throw new NullPointerException(); @@ -4758,7 +4757,7 @@ public final class MyCatMeta { * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ public Builder addIndex( - int index, io.mycat.meta.protocol.MyCatMeta.IndexMeta value) { + int index, io.mycat.meta.protocol.StructureMeta.IndexMeta value) { if (indexBuilder_ == null) { if (value == null) { throw new NullPointerException(); @@ -4775,7 +4774,7 @@ public final class MyCatMeta { * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ public Builder addIndex( - io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder builderForValue) { + io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder builderForValue) { if (indexBuilder_ == null) { ensureIndexIsMutable(); index_.add(builderForValue.build()); @@ -4789,7 +4788,7 @@ public final class MyCatMeta { * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ public Builder addIndex( - int index, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder builderForValue) { + int index, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder builderForValue) { if (indexBuilder_ == null) { ensureIndexIsMutable(); index_.add(index, builderForValue.build()); @@ -4803,7 +4802,7 @@ public final class MyCatMeta { * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ public Builder addAllIndex( - java.lang.Iterable values) { + java.lang.Iterable values) { if (indexBuilder_ == null) { ensureIndexIsMutable(); com.google.protobuf.AbstractMessageLite.Builder.addAll( @@ -4843,14 +4842,14 @@ public final class MyCatMeta { /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder getIndexBuilder( + public io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder getIndexBuilder( int index) { return getIndexFieldBuilder().getBuilder(index); } /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder getIndexOrBuilder( + public io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder getIndexOrBuilder( int index) { if (indexBuilder_ == null) { return index_.get(index); } else { @@ -4860,7 +4859,7 @@ public final class MyCatMeta { /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - public java.util.List + public java.util.List getIndexOrBuilderList() { if (indexBuilder_ != null) { return indexBuilder_.getMessageOrBuilderList(); @@ -4871,31 +4870,31 @@ public final class MyCatMeta { /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder addIndexBuilder() { + public io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder addIndexBuilder() { return getIndexFieldBuilder().addBuilder( - io.mycat.meta.protocol.MyCatMeta.IndexMeta.getDefaultInstance()); + io.mycat.meta.protocol.StructureMeta.IndexMeta.getDefaultInstance()); } /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - public io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder addIndexBuilder( + public io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder addIndexBuilder( int index) { return getIndexFieldBuilder().addBuilder( - index, io.mycat.meta.protocol.MyCatMeta.IndexMeta.getDefaultInstance()); + index, io.mycat.meta.protocol.StructureMeta.IndexMeta.getDefaultInstance()); } /** * repeated .io.mycat.meta.protocol.IndexMeta index = 11; */ - public java.util.List + public java.util.List getIndexBuilderList() { return getIndexFieldBuilder().getBuilderList(); } private com.google.protobuf.RepeatedFieldBuilder< - io.mycat.meta.protocol.MyCatMeta.IndexMeta, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder, io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder> + io.mycat.meta.protocol.StructureMeta.IndexMeta, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder, io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder> getIndexFieldBuilder() { if (indexBuilder_ == null) { indexBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - io.mycat.meta.protocol.MyCatMeta.IndexMeta, io.mycat.meta.protocol.MyCatMeta.IndexMeta.Builder, io.mycat.meta.protocol.MyCatMeta.IndexMetaOrBuilder>( + io.mycat.meta.protocol.StructureMeta.IndexMeta, io.mycat.meta.protocol.StructureMeta.IndexMeta.Builder, io.mycat.meta.protocol.StructureMeta.IndexMetaOrBuilder>( index_, ((bitField0_ & 0x00000400) == 0x00000400), getParentForChildren(), @@ -4940,24 +4939,24 @@ public final class MyCatMeta { descriptor; static { java.lang.String[] descriptorData = { - "\n\022MyCatMeta.protocol\022\026io.mycat.meta.prot" + - "ocol\"8\n\tIndexMeta\022\014\n\004name\030\001 \002(\t\022\014\n\004type\030" + - "\002 \002(\t\022\017\n\007columns\030\003 \003(\t\"\304\001\n\nColumnMeta\022\014\n" + - "\004name\030\001 \002(\t\022\020\n\010dataType\030\002 \002(\t\022\022\n\nisUnsig" + - "ned\030\003 \001(\010\022\016\n\006length\030\004 \001(\005\022\021\n\tprecision\030\005" + - " \001(\005\022\r\n\005scale\030\006 \001(\005\022\017\n\007canNull\030\007 \001(\010\022\020\n\010" + - "sdefault\030\010 \001(\t\022\022\n\nauto_incre\030\t \001(\010\022\031\n\013ch" + - "arsetname\030\n \001(\t:\004utf8\"\343\002\n\tTableMeta\022\021\n\tt" + - "ableName\030\001 \001(\t\0223\n\007columns\030\002 \003(\0132\".io.myc" + - "at.meta.protocol.ColumnMeta\022\025\n\006isView\030\003 ", - "\001(\010:\005false\022\021\n\tcreateSql\030\004 \001(\t\022\017\n\007version" + - "\030\005 \001(\003\022\024\n\010aiOffset\030\006 \001(\003:\002-1\022\014\n\004type\030\007 \001" + - "(\005\022\024\n\010aiColPos\030\010 \001(\005:\002-1\0222\n\007primary\030\t \001(" + - "\0132!.io.mycat.meta.protocol.IndexMeta\0223\n\010" + - "uniIndex\030\n \003(\0132!.io.mycat.meta.protocol." + - "IndexMeta\0220\n\005index\030\013 \003(\0132!.io.mycat.meta" + - ".protocol.IndexMetaB%\n\026io.mycat.meta.pro" + - "tocolB\tMyCatMetaH\001" + "\n\026StructureMeta.protocol\022\026io.mycat.meta." + + "protocol\"8\n\tIndexMeta\022\014\n\004name\030\001 \002(\t\022\014\n\004t" + + "ype\030\002 \002(\t\022\017\n\007columns\030\003 \003(\t\"\304\001\n\nColumnMet" + + "a\022\014\n\004name\030\001 \002(\t\022\020\n\010dataType\030\002 \002(\t\022\022\n\nisU" + + "nsigned\030\003 \001(\010\022\016\n\006length\030\004 \001(\005\022\021\n\tprecisi" + + "on\030\005 \001(\005\022\r\n\005scale\030\006 \001(\005\022\017\n\007canNull\030\007 \001(\010" + + "\022\020\n\010sdefault\030\010 \001(\t\022\022\n\nauto_incre\030\t \001(\010\022\031" + + "\n\013charsetname\030\n \001(\t:\004utf8\"\343\002\n\tTableMeta\022" + + "\021\n\ttableName\030\001 \001(\t\0223\n\007columns\030\002 \003(\0132\".io" + + ".mycat.meta.protocol.ColumnMeta\022\025\n\006isVie", + "w\030\003 \001(\010:\005false\022\021\n\tcreateSql\030\004 \001(\t\022\017\n\007ver" + + "sion\030\005 \001(\003\022\024\n\010aiOffset\030\006 \001(\003:\002-1\022\014\n\004type" + + "\030\007 \001(\005\022\024\n\010aiColPos\030\010 \001(\005:\002-1\0222\n\007primary\030" + + "\t \001(\0132!.io.mycat.meta.protocol.IndexMeta" + + "\0223\n\010uniIndex\030\n \003(\0132!.io.mycat.meta.proto" + + "col.IndexMeta\0220\n\005index\030\013 \003(\0132!.io.mycat." + + "meta.protocol.IndexMetaB)\n\026io.mycat.meta" + + ".protocolB\rStructureMetaH\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { diff --git a/src/main/java/io/mycat/meta/protocol/MyCatMeta.protocol b/src/main/java/io/mycat/meta/protocol/StructureMeta.proto similarity index 96% rename from src/main/java/io/mycat/meta/protocol/MyCatMeta.protocol rename to src/main/java/io/mycat/meta/protocol/StructureMeta.proto index 8b3476cad..5f2c386b8 100644 --- a/src/main/java/io/mycat/meta/protocol/MyCatMeta.protocol +++ b/src/main/java/io/mycat/meta/protocol/StructureMeta.proto @@ -1,7 +1,8 @@ +syntax = "proto2"; package io.mycat.meta.protocol; option java_package = "io.mycat.meta.protocol"; -option java_outer_classname = "MyCatMeta"; +option java_outer_classname = "StructureMeta"; option optimize_for = SPEED; diff --git a/src/main/java/io/mycat/meta/table/AbstractTableMetaHandler.java b/src/main/java/io/mycat/meta/table/AbstractTableMetaHandler.java index 9afcba1be..7e7f57207 100644 --- a/src/main/java/io/mycat/meta/table/AbstractTableMetaHandler.java +++ b/src/main/java/io/mycat/meta/table/AbstractTableMetaHandler.java @@ -19,7 +19,7 @@ import com.alibaba.druid.sql.parser.SQLStatementParser; import io.mycat.MycatServer; import io.mycat.backend.datasource.PhysicalDBNode; import io.mycat.config.model.TableConfig; -import io.mycat.meta.protocol.MyCatMeta.TableMeta; +import io.mycat.meta.protocol.StructureMeta.TableMeta; import io.mycat.sqlengine.OneRawSQLQueryResultHandler; import io.mycat.sqlengine.SQLJob; import io.mycat.sqlengine.SQLQueryResult; diff --git a/src/main/java/io/mycat/meta/table/MetaHelper.java b/src/main/java/io/mycat/meta/table/MetaHelper.java index 151493483..e62c97dd8 100644 --- a/src/main/java/io/mycat/meta/table/MetaHelper.java +++ b/src/main/java/io/mycat/meta/table/MetaHelper.java @@ -21,9 +21,9 @@ import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr; import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlTableIndex; import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor; -import io.mycat.meta.protocol.MyCatMeta.ColumnMeta; -import io.mycat.meta.protocol.MyCatMeta.IndexMeta; -import io.mycat.meta.protocol.MyCatMeta.TableMeta; +import io.mycat.meta.protocol.StructureMeta.ColumnMeta; +import io.mycat.meta.protocol.StructureMeta.IndexMeta; +import io.mycat.meta.protocol.StructureMeta.TableMeta; import io.mycat.util.StringUtil; public class MetaHelper { diff --git a/src/main/java/io/mycat/meta/table/TableMetaCheckHandler.java b/src/main/java/io/mycat/meta/table/TableMetaCheckHandler.java index f7103d86e..e9e29ec99 100644 --- a/src/main/java/io/mycat/meta/table/TableMetaCheckHandler.java +++ b/src/main/java/io/mycat/meta/table/TableMetaCheckHandler.java @@ -3,7 +3,7 @@ package io.mycat.meta.table; import io.mycat.MycatServer; import io.mycat.config.model.TableConfig; import io.mycat.meta.ProxyMetaManager; -import io.mycat.meta.protocol.MyCatMeta.TableMeta; +import io.mycat.meta.protocol.StructureMeta.TableMeta; import java.util.Set; diff --git a/src/main/java/io/mycat/meta/table/TableMetaInitHandler.java b/src/main/java/io/mycat/meta/table/TableMetaInitHandler.java index 0a8a088db..593d01d08 100644 --- a/src/main/java/io/mycat/meta/table/TableMetaInitHandler.java +++ b/src/main/java/io/mycat/meta/table/TableMetaInitHandler.java @@ -2,7 +2,7 @@ package io.mycat.meta.table; import io.mycat.MycatServer; import io.mycat.config.model.TableConfig; -import io.mycat.meta.protocol.MyCatMeta.TableMeta; +import io.mycat.meta.protocol.StructureMeta.TableMeta; import java.util.Set; diff --git a/src/main/java/io/mycat/net/AIOAcceptor.java b/src/main/java/io/mycat/net/AIOAcceptor.java index 64c772d5e..f72ce7051 100644 --- a/src/main/java/io/mycat/net/AIOAcceptor.java +++ b/src/main/java/io/mycat/net/AIOAcceptor.java @@ -102,7 +102,7 @@ public final class AIOAcceptor implements SocketAcceptor, serverChannel.accept(ID_GENERATOR.getId(), this); } else { throw new IllegalStateException( - "MyCAT Server Channel has been closed"); + "Server Channel has been closed"); } } diff --git a/src/main/java/io/mycat/net/mysql/HeartbeatPacket.java b/src/main/java/io/mycat/net/mysql/HeartbeatPacket.java index 5a04c3d8c..d942a7174 100644 --- a/src/main/java/io/mycat/net/mysql/HeartbeatPacket.java +++ b/src/main/java/io/mycat/net/mysql/HeartbeatPacket.java @@ -70,7 +70,7 @@ public class HeartbeatPacket extends MySQLPacket { @Override protected String getPacketInfo() { - return "Mycat Heartbeat Packet"; + return "Heartbeat Packet"; } } \ No newline at end of file diff --git a/src/main/java/io/mycat/plan/common/field/Field.java b/src/main/java/io/mycat/plan/common/field/Field.java index a750584a1..bb49912d1 100644 --- a/src/main/java/io/mycat/plan/common/field/Field.java +++ b/src/main/java/io/mycat/plan/common/field/Field.java @@ -51,59 +51,52 @@ public abstract class Field { public static Field getFieldItem(String name, String table, int type, int charsetIndex, int field_length, int decimals, long flags) { FieldTypes field_type = FieldTypes.valueOf(type); - switch (field_type) { - case MYSQL_TYPE_NEWDECIMAL: - // mysql use newdecimal after some version + if (field_type == FieldTypes.MYSQL_TYPE_NEWDECIMAL) {// mysql use newdecimal after some version return new FieldNewdecimal(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_DECIMAL: + } else if (field_type == FieldTypes.MYSQL_TYPE_DECIMAL) { return new FieldDecimal(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_TINY: + } else if (field_type == FieldTypes.MYSQL_TYPE_TINY) { return new FieldTiny(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_SHORT: + } else if (field_type == FieldTypes.MYSQL_TYPE_SHORT) { return new FieldShort(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_LONG: + } else if (field_type == FieldTypes.MYSQL_TYPE_LONG) { return new FieldLong(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_FLOAT: + } else if (field_type == FieldTypes.MYSQL_TYPE_FLOAT) { return new FieldFloat(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_DOUBLE: + } else if (field_type == FieldTypes.MYSQL_TYPE_DOUBLE) { return new FieldDouble(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_NULL: + } else if (field_type == FieldTypes.MYSQL_TYPE_NULL) { return FieldNull.getInstance(); - case MYSQL_TYPE_TIMESTAMP: + } else if (field_type == FieldTypes.MYSQL_TYPE_TIMESTAMP) { return new FieldTimestamp(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_LONGLONG: + } else if (field_type == FieldTypes.MYSQL_TYPE_LONGLONG) { return new FieldLonglong(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_INT24: + } else if (field_type == FieldTypes.MYSQL_TYPE_INT24) { return new FieldMedium(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_DATE: - case MYSQL_TYPE_NEWDATE: + } else if (field_type == FieldTypes.MYSQL_TYPE_DATE || field_type == FieldTypes.MYSQL_TYPE_NEWDATE) { return new FieldDate(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_TIME: + } else if (field_type == FieldTypes.MYSQL_TYPE_TIME) { return new FieldTime(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_DATETIME: + } else if (field_type == FieldTypes.MYSQL_TYPE_DATETIME) { return new FieldDatetime(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_YEAR: + } else if (field_type == FieldTypes.MYSQL_TYPE_YEAR) { return new FieldYear(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_VARCHAR: + } else if (field_type == FieldTypes.MYSQL_TYPE_VARCHAR) { return new FieldVarchar(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_BIT: + } else if (field_type == FieldTypes.MYSQL_TYPE_BIT) { return new FieldBit(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_VAR_STRING: + } else if (field_type == FieldTypes.MYSQL_TYPE_VAR_STRING) { return new FieldVarstring(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_STRING: + } else if (field_type == FieldTypes.MYSQL_TYPE_STRING) { return new FieldString(name, table, charsetIndex, field_length, decimals, flags); - /** --下列的类型函数目前不支持,因为select *出来的mysql都转化成string了,无法知晓它们在数据库中的type-- **/ - case MYSQL_TYPE_ENUM: + /** --下列的类型函数目前不支持,因为select *出来的mysql都转化成string了,无法知晓它们在数据库中的type-- **/ + } else if (field_type == FieldTypes.MYSQL_TYPE_ENUM) { return new FieldEnum(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_SET: + } else if (field_type == FieldTypes.MYSQL_TYPE_SET) { return new FieldSet(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_TINY_BLOB: - case MYSQL_TYPE_MEDIUM_BLOB: - case MYSQL_TYPE_LONG_BLOB: - case MYSQL_TYPE_BLOB: + } else if (field_type == FieldTypes.MYSQL_TYPE_TINY_BLOB || field_type == FieldTypes.MYSQL_TYPE_MEDIUM_BLOB || field_type == FieldTypes.MYSQL_TYPE_LONG_BLOB || field_type == FieldTypes.MYSQL_TYPE_BLOB) { return new FieldBlob(name, table, charsetIndex, field_length, decimals, flags); - case MYSQL_TYPE_GEOMETRY: - default: + } else { throw new RuntimeException("unsupported field type :" + field_type.toString() + "!"); } } diff --git a/src/main/java/io/mycat/plan/common/field/FieldUtil.java b/src/main/java/io/mycat/plan/common/field/FieldUtil.java index 17cda5f26..b71b5a4a3 100644 --- a/src/main/java/io/mycat/plan/common/field/FieldUtil.java +++ b/src/main/java/io/mycat/plan/common/field/FieldUtil.java @@ -93,14 +93,9 @@ public class FieldUtil { } public static boolean is_temporal_type(FieldTypes valuetype) { - switch (valuetype) { - case MYSQL_TYPE_DATE: - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: - case MYSQL_TYPE_TIME: - case MYSQL_TYPE_NEWDATE: + if (valuetype == FieldTypes.MYSQL_TYPE_DATE || valuetype == FieldTypes.MYSQL_TYPE_DATETIME || valuetype == FieldTypes.MYSQL_TYPE_TIMESTAMP || valuetype == FieldTypes.MYSQL_TYPE_TIME || valuetype == FieldTypes.MYSQL_TYPE_NEWDATE) { return true; - default: + } else { return false; } } @@ -115,34 +110,25 @@ public class FieldUtil { * @retval false If field real type is not temporal */ public static boolean is_temporal_real_type(FieldTypes type) { - switch (type) { - case MYSQL_TYPE_TIME2: - case MYSQL_TYPE_TIMESTAMP2: - case MYSQL_TYPE_DATETIME2: + if (type == FieldTypes.MYSQL_TYPE_TIME2 || type == FieldTypes.MYSQL_TYPE_TIMESTAMP2 || type == FieldTypes.MYSQL_TYPE_DATETIME2) { return true; - default: + } else { return FieldUtil.is_temporal_type(type); } } public static boolean is_temporal_type_with_time(FieldTypes type) { - switch (type) { - case MYSQL_TYPE_TIME: - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + if (type == FieldTypes.MYSQL_TYPE_TIME || type == FieldTypes.MYSQL_TYPE_DATETIME || type == FieldTypes.MYSQL_TYPE_TIMESTAMP) { return true; - default: + } else { return false; } } public static boolean is_temporal_type_with_date(FieldTypes valuetype) { - switch (valuetype) { - case MYSQL_TYPE_DATE: - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + if (valuetype == FieldTypes.MYSQL_TYPE_DATE || valuetype == FieldTypes.MYSQL_TYPE_DATETIME || valuetype == FieldTypes.MYSQL_TYPE_TIMESTAMP) { return true; - default: + } else { return false; } } @@ -158,11 +144,9 @@ public class FieldUtil { * parts. */ public static boolean is_temporal_type_with_date_and_time(FieldTypes type) { - switch (type) { - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + if (type == FieldTypes.MYSQL_TYPE_DATETIME || type == FieldTypes.MYSQL_TYPE_TIMESTAMP) { return true; - default: + } else { return false; } } @@ -184,17 +168,16 @@ public class FieldUtil { * @retval Field type. */ public static FieldTypes real_type_to_type(FieldTypes real_type) { - switch (real_type) { - case MYSQL_TYPE_TIME2: + if (real_type == FieldTypes.MYSQL_TYPE_TIME2) { return FieldTypes.MYSQL_TYPE_TIME; - case MYSQL_TYPE_DATETIME2: + } else if (real_type == FieldTypes.MYSQL_TYPE_DATETIME2) { return FieldTypes.MYSQL_TYPE_DATETIME; - case MYSQL_TYPE_TIMESTAMP2: + } else if (real_type == FieldTypes.MYSQL_TYPE_TIMESTAMP2) { return FieldTypes.MYSQL_TYPE_TIMESTAMP; - case MYSQL_TYPE_NEWDATE: + } else if (real_type == FieldTypes.MYSQL_TYPE_NEWDATE) { return FieldTypes.MYSQL_TYPE_DATE; /* Note: NEWDECIMAL is a type, not only a real_type */ - default: + } else { return real_type; } } diff --git a/src/main/java/io/mycat/plan/common/item/Item.java b/src/main/java/io/mycat/plan/common/item/Item.java index ca1c2474a..5ef81089c 100644 --- a/src/main/java/io/mycat/plan/common/item/Item.java +++ b/src/main/java/io/mycat/plan/common/item/Item.java @@ -114,17 +114,16 @@ public abstract class Item { } public FieldTypes fieldType() { - switch (resultType()) { - case STRING_RESULT: + ItemResult i = resultType(); + if (i == ItemResult.STRING_RESULT) { return FieldTypes.MYSQL_TYPE_STRING; - case INT_RESULT: + } else if (i == ItemResult.INT_RESULT) { return FieldTypes.MYSQL_TYPE_LONG; - case DECIMAL_RESULT: + } else if (i == ItemResult.DECIMAL_RESULT) { return FieldTypes.MYSQL_TYPE_DECIMAL; - case REAL_RESULT: + } else if (i == ItemResult.REAL_RESULT) { return FieldTypes.MYSQL_TYPE_DOUBLE; - case ROW_RESULT: - default: + } else { return FieldTypes.MYSQL_TYPE_STRING; } } @@ -194,22 +193,31 @@ public abstract class Item { byte[] result = null; FieldTypes f_type; - switch (f_type = fieldType()) { - default: - case MYSQL_TYPE_NULL: - case MYSQL_TYPE_DECIMAL: - case MYSQL_TYPE_ENUM: - case MYSQL_TYPE_SET: - case MYSQL_TYPE_TINY_BLOB: - case MYSQL_TYPE_MEDIUM_BLOB: - case MYSQL_TYPE_LONG_BLOB: - case MYSQL_TYPE_BLOB: - case MYSQL_TYPE_GEOMETRY: - case MYSQL_TYPE_STRING: - case MYSQL_TYPE_VAR_STRING: - case MYSQL_TYPE_VARCHAR: - case MYSQL_TYPE_BIT: - case MYSQL_TYPE_NEWDECIMAL: { + FieldTypes i = f_type = fieldType(); + if (i == FieldTypes.MYSQL_TYPE_TINY || i == FieldTypes.MYSQL_TYPE_SHORT || i == FieldTypes.MYSQL_TYPE_YEAR || i == FieldTypes.MYSQL_TYPE_INT24 || i == FieldTypes.MYSQL_TYPE_LONG || i == FieldTypes.MYSQL_TYPE_LONGLONG) { + BigInteger bi = valInt(); + if (!nullValue) + result = bi.toString().getBytes(); + } else if (i == FieldTypes.MYSQL_TYPE_FLOAT || i == FieldTypes.MYSQL_TYPE_DOUBLE) { + BigDecimal bd = valReal(); + if (!nullValue) + result = bd.toString().getBytes(); + } else if (i == FieldTypes.MYSQL_TYPE_DATETIME || i == FieldTypes.MYSQL_TYPE_DATE || i == FieldTypes.MYSQL_TYPE_TIMESTAMP) { + MySQLTime tm = new MySQLTime(); + getDate(tm, MyTime.TIME_FUZZY_DATE); + if (!nullValue) { + if (f_type == FieldTypes.MYSQL_TYPE_DATE) { + result = MyTime.my_date_to_str(tm).getBytes(); + } else { + result = MyTime.my_datetime_to_str(tm, decimals).getBytes(); + } + } + } else if (i == FieldTypes.MYSQL_TYPE_TIME) { + MySQLTime tm = new MySQLTime(); + getTime(tm); + if (!nullValue) + result = MyTime.my_time_to_str(tm, decimals).getBytes(); + } else { String res = null; if ((res = valStr()) != null) try { @@ -220,47 +228,11 @@ public abstract class Item { else { assert (nullValue); } - break; - } - case MYSQL_TYPE_TINY: - case MYSQL_TYPE_SHORT: - case MYSQL_TYPE_YEAR: - case MYSQL_TYPE_INT24: - case MYSQL_TYPE_LONG: - case MYSQL_TYPE_LONGLONG: { + + BigInteger bi = valInt(); if (!nullValue) result = bi.toString().getBytes(); - break; - } - case MYSQL_TYPE_FLOAT: - case MYSQL_TYPE_DOUBLE: { - BigDecimal bd = valReal(); - if (!nullValue) - result = bd.toString().getBytes(); - break; - } - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_DATE: - case MYSQL_TYPE_TIMESTAMP: { - MySQLTime tm = new MySQLTime(); - getDate(tm, MyTime.TIME_FUZZY_DATE); - if (!nullValue) { - if (f_type == FieldTypes.MYSQL_TYPE_DATE) { - result = MyTime.my_date_to_str(tm).getBytes(); - } else { - result = MyTime.my_datetime_to_str(tm, decimals).getBytes(); - } - } - break; - } - case MYSQL_TYPE_TIME: { - MySQLTime tm = new MySQLTime(); - getTime(tm); - if (!nullValue) - result = MyTime.my_time_to_str(tm, decimals).getBytes(); - break; - } } if (nullValue) result = null; @@ -268,20 +240,17 @@ public abstract class Item { } public boolean valBool() { - switch (resultType()) { - case INT_RESULT: + ItemResult i = resultType(); + if (i == ItemResult.INT_RESULT) { return valInt().longValue() != 0; - case DECIMAL_RESULT: { + } else if (i == ItemResult.DECIMAL_RESULT) { BigDecimal val = valDecimal(); if (val != null) return val.compareTo(BigDecimal.ZERO) != 0; return false; - } - case REAL_RESULT: - case STRING_RESULT: + } else if (i == ItemResult.REAL_RESULT || i == ItemResult.STRING_RESULT) { return !(valReal().compareTo(BigDecimal.ZERO) == 0); - case ROW_RESULT: - default: + } else { return false; // Wrong (but safe) } } @@ -316,17 +285,15 @@ public abstract class Item { } public Comparable getValueWithType(ItemResult type) { - switch (type) { - case REAL_RESULT: + if (type == ItemResult.REAL_RESULT) { return valReal(); - case DECIMAL_RESULT: + } else if (type == ItemResult.DECIMAL_RESULT) { return valDecimal(); - case INT_RESULT: + } else if (type == ItemResult.INT_RESULT) { return valInt(); - case STRING_RESULT: + } else if (type == ItemResult.STRING_RESULT) { return valStr(); - default: - break; + } else { } return null; } @@ -593,15 +560,14 @@ public abstract class Item { * Convert a numeric type to date */ protected boolean getDateFromNumeric(MySQLTime ltime, long flags) { - switch (resultType()) { - case REAL_RESULT: + ItemResult i = resultType(); + if (i == ItemResult.REAL_RESULT) { return getDateFromReal(ltime, flags); - case DECIMAL_RESULT: + } else if (i == ItemResult.DECIMAL_RESULT) { return getDateFromDecimal(ltime, flags); - case INT_RESULT: + } else if (i == ItemResult.INT_RESULT) { return getDateFromInt(ltime, flags); - case STRING_RESULT: - case ROW_RESULT: + } else if (i == ItemResult.STRING_RESULT || i == ItemResult.ROW_RESULT) { assert (false); } return (nullValue = true); // Impossible result_type @@ -612,16 +578,16 @@ public abstract class Item { */ protected boolean getDateFromNonTemporal(MySQLTime ltime, long fuzzydate) { assert (!isTemporal()); - switch (resultType()) { - case STRING_RESULT: + ItemResult i = resultType(); + if (i == ItemResult.STRING_RESULT) { return getDateFromString(ltime, fuzzydate); - case REAL_RESULT: + } else if (i == ItemResult.REAL_RESULT) { return getDateFromReal(ltime, fuzzydate); - case DECIMAL_RESULT: + } else if (i == ItemResult.DECIMAL_RESULT) { return getDateFromDecimal(ltime, fuzzydate); - case INT_RESULT: + } else if (i == ItemResult.INT_RESULT) { return getDateFromInt(ltime, fuzzydate); - case ROW_RESULT: + } else if (i == ItemResult.ROW_RESULT) { assert (false); } return (nullValue = true); // Impossible result_type @@ -701,15 +667,14 @@ public abstract class Item { */ protected boolean getTimeFromNumeric(MySQLTime ltime) { assert (!isTemporal()); - switch (resultType()) { - case REAL_RESULT: + ItemResult i = resultType(); + if (i == ItemResult.REAL_RESULT) { return getTimeFromReal(ltime); - case DECIMAL_RESULT: + } else if (i == ItemResult.DECIMAL_RESULT) { return getTimeFromDecimal(ltime); - case INT_RESULT: + } else if (i == ItemResult.INT_RESULT) { return getTimeFromInt(ltime); - case STRING_RESULT: - case ROW_RESULT: + } else if (i == ItemResult.STRING_RESULT || i == ItemResult.ROW_RESULT) { assert (false); } return (nullValue = true); // Impossible result type @@ -720,16 +685,16 @@ public abstract class Item { */ protected boolean getTimeFromNonTemporal(MySQLTime ltime) { assert (!isTemporal()); - switch (resultType()) { - case STRING_RESULT: + ItemResult i = resultType(); + if (i == ItemResult.STRING_RESULT) { return getTimeFromString(ltime); - case REAL_RESULT: + } else if (i == ItemResult.REAL_RESULT) { return getTimeFromReal(ltime); - case DECIMAL_RESULT: + } else if (i == ItemResult.DECIMAL_RESULT) { return getTimeFromDecimal(ltime); - case INT_RESULT: + } else if (i == ItemResult.INT_RESULT) { return getTimeFromInt(ltime); - case ROW_RESULT: + } else if (i == ItemResult.ROW_RESULT) { assert (false); } return (nullValue = true); // Impossible result type diff --git a/src/main/java/io/mycat/plan/common/item/function/ItemCreate.java b/src/main/java/io/mycat/plan/common/item/function/ItemCreate.java index 378e10b12..4545e855b 100644 --- a/src/main/java/io/mycat/plan/common/item/function/ItemCreate.java +++ b/src/main/java/io/mycat/plan/common/item/function/ItemCreate.java @@ -313,29 +313,25 @@ public class ItemCreate { public ItemFunc create_func_cast(Item a, CastType type) { CastTarget cast_type = type.target; ItemFunc res = null; - switch (cast_type) { - case ITEM_CAST_BINARY: - res = new ItemFuncBinary(a,type.length); - break; - case ITEM_CAST_SIGNED_INT: + if (cast_type == CastTarget.ITEM_CAST_BINARY) { + res = new ItemFuncBinary(a, type.length); + + } else if (cast_type == CastTarget.ITEM_CAST_SIGNED_INT) { res = new ItemFuncSigned(a); - break; - case ITEM_CAST_UNSIGNED_INT: + + } else if (cast_type == CastTarget.ITEM_CAST_UNSIGNED_INT) { res = new ItemFuncUnsigned(a); - break; - case ITEM_CAST_DATE: + + } else if (cast_type == CastTarget.ITEM_CAST_DATE) { res = new ItemDateTypecast(a); - break; - case ITEM_CAST_TIME: - case ITEM_CAST_DATETIME: { + + } else if (cast_type == CastTarget.ITEM_CAST_TIME || cast_type == CastTarget.ITEM_CAST_DATETIME) { if (type.length > MyTime.DATETIME_MAX_DECIMALS) throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "", "too big precision in cast time/datetime,max 6,current:" + type.length); res = (cast_type == CastTarget.ITEM_CAST_TIME) ? new ItemTimeTypecast(a, type.length) : new ItemDatetimeTypecast(a, type.length); - break; - } - case ITEM_CAST_DECIMAL: { + } else if (cast_type == CastTarget.ITEM_CAST_DECIMAL) { if (type.length < type.dec) { throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "", "For float(m,d), double(m,d) or decimal(m,d), M must be >= d"); @@ -349,19 +345,13 @@ public class ItemCreate { "Too big scale " + type.dec + " max is " + MySQLcom.DECIMAL_MAX_SCALE); } res = new ItemDecimalTypecast(a, type.length, type.dec); - break; - } - case ITEM_CAST_NCHAR: { + } else if (cast_type == CastTarget.ITEM_CAST_NCHAR) { int len = -1; if (type.length > 0) len = type.length; res = new ItemNCharTypecast(a, len); - break; - } - default: { + } else { assert (false); - break; - } } return res; } diff --git a/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncCeiling.java b/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncCeiling.java index 0d8212344..b8cb0b00d 100644 --- a/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncCeiling.java +++ b/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncCeiling.java @@ -23,20 +23,18 @@ public class ItemFuncCeiling extends ItemFuncIntVal { @Override public BigInteger intOp() { BigInteger result; - switch (args.get(0).resultType()) { - case INT_RESULT: + ItemResult i = args.get(0).resultType(); + if (i == ItemResult.INT_RESULT) { result = args.get(0).valInt(); nullValue = args.get(0).nullValue; - break; - case DECIMAL_RESULT: { + + } else if (i == ItemResult.DECIMAL_RESULT) { BigDecimal dec = decimalOp(); if (dec == null) result = BigInteger.ZERO; else result = dec.toBigInteger(); - break; - } - default: + } else { result = realOp().toBigInteger(); } ; diff --git a/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncFloor.java b/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncFloor.java index bf740b272..ecc5561f0 100644 --- a/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncFloor.java +++ b/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncFloor.java @@ -23,20 +23,18 @@ public class ItemFuncFloor extends ItemFuncIntVal { @Override public BigInteger intOp() { BigInteger result; - switch (args.get(0).resultType()) { - case INT_RESULT: + ItemResult i = args.get(0).resultType(); + if (i == ItemResult.INT_RESULT) { result = args.get(0).valInt(); nullValue = args.get(0).nullValue; - break; - case DECIMAL_RESULT: { + + } else if (i == ItemResult.DECIMAL_RESULT) { BigDecimal dec = decimalOp(); if (dec == null) result = BigInteger.ZERO; else result = dec.toBigInteger(); - break; - } - default: + } else { result = realOp().toBigInteger(); } ; diff --git a/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncIntVal.java b/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncIntVal.java index c735ae3ff..553de165e 100644 --- a/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncIntVal.java +++ b/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncIntVal.java @@ -19,19 +19,18 @@ public abstract class ItemFuncIntVal extends ItemFuncNum1 { @Override public void findNumType() { - switch (hybrid_type = args.get(0).resultType()) { - case STRING_RESULT: - case REAL_RESULT: + ItemResult i = hybrid_type = args.get(0).resultType(); + if (i == ItemResult.STRING_RESULT || i == ItemResult.REAL_RESULT) { hybrid_type = ItemResult.REAL_RESULT; maxLength = floatLength(decimals); - break; - case INT_RESULT: + + } else if (i == ItemResult.INT_RESULT) { hybrid_type = ItemResult.INT_RESULT; - break; - case DECIMAL_RESULT: + + } else if (i == ItemResult.DECIMAL_RESULT) { hybrid_type = ItemResult.DECIMAL_RESULT; - break; - default: + + } else { assert (false); } } diff --git a/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncRoundOrTruncate.java b/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncRoundOrTruncate.java index 37659d44a..e8a26e5fb 100644 --- a/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncRoundOrTruncate.java +++ b/src/main/java/io/mycat/plan/common/item/function/mathsfunc/ItemFuncRoundOrTruncate.java @@ -78,26 +78,22 @@ public abstract class ItemFuncRoundOrTruncate extends ItemFuncNum1 { return; } - switch (args.get(0).resultType()) { - case REAL_RESULT: - case STRING_RESULT: + ItemResult i = args.get(0).resultType(); + if (i == ItemResult.REAL_RESULT || i == ItemResult.STRING_RESULT) { hybrid_type = ItemResult.REAL_RESULT; decimals = Math.min(decimals_to_set, NOT_FIXED_DEC); maxLength = floatLength(decimals); - break; - case INT_RESULT: - /* Here we can keep INT_RESULT */ + + } else if (i == ItemResult.INT_RESULT) {/* Here we can keep INT_RESULT */ hybrid_type = ItemResult.INT_RESULT; decimals = 0; - break; + /* fall through */ - case DECIMAL_RESULT: { + } else if (i == ItemResult.DECIMAL_RESULT) { hybrid_type = ItemResult.DECIMAL_RESULT; decimals_to_set = Math.min(DECIMAL_MAX_SCALE, decimals_to_set); decimals = Math.min(decimals_to_set, DECIMAL_MAX_SCALE); - break; - } - default: + } else { assert (false); /* This result type isn't handled */ } } diff --git a/src/main/java/io/mycat/plan/common/item/function/mathsfunc/operator/ItemFuncDiv.java b/src/main/java/io/mycat/plan/common/item/function/mathsfunc/operator/ItemFuncDiv.java index 5b6fbf5e0..01ab6d7b8 100644 --- a/src/main/java/io/mycat/plan/common/item/function/mathsfunc/operator/ItemFuncDiv.java +++ b/src/main/java/io/mycat/plan/common/item/function/mathsfunc/operator/ItemFuncDiv.java @@ -33,9 +33,7 @@ public class ItemFuncDiv extends ItemNumOp { @Override public void fixLengthAndDec() { super.fixLengthAndDec(); - switch (hybrid_type) { - case REAL_RESULT: { - // see sql/item_func.cc Item_func_div::fix_length_and_dec() + if (hybrid_type == ItemResult.REAL_RESULT) { decimals = Math.max(args.get(0).decimals, args.get(1).decimals) + prec_increment; decimals = Math.min(decimals, NOT_FIXED_DEC); int tmp = floatLength(decimals); @@ -45,16 +43,14 @@ public class ItemFuncDiv extends ItemNumOp { maxLength = args.get(0).maxLength - args.get(1).decimals + decimals; maxLength = Math.min(maxLength, tmp); } - break; - } - case INT_RESULT: + } else if (hybrid_type == ItemResult.INT_RESULT) { hybrid_type = ItemResult.DECIMAL_RESULT; result_precision(); - break; - case DECIMAL_RESULT: + + } else if (hybrid_type == ItemResult.DECIMAL_RESULT) { result_precision(); - default: - break; + + } } diff --git a/src/main/java/io/mycat/plan/common/item/function/operator/cmpfunc/ItemFuncCoalesce.java b/src/main/java/io/mycat/plan/common/item/function/operator/cmpfunc/ItemFuncCoalesce.java index 5afcf5885..076c3cd4c 100644 --- a/src/main/java/io/mycat/plan/common/item/function/operator/cmpfunc/ItemFuncCoalesce.java +++ b/src/main/java/io/mycat/plan/common/item/function/operator/cmpfunc/ItemFuncCoalesce.java @@ -37,20 +37,17 @@ public class ItemFuncCoalesce extends ItemFuncNumhybrid { public void fixLengthAndDec() { cached_field_type = MySQLcom.agg_field_type(args, 0, args.size()); hybrid_type = MySQLcom.agg_result_type(args, 0, args.size()); - switch (hybrid_type) { - case STRING_RESULT: - break; - case DECIMAL_RESULT: + if (hybrid_type == ItemResult.STRING_RESULT) { + } else if (hybrid_type == ItemResult.DECIMAL_RESULT) { countDecimalLength(); - break; - case REAL_RESULT: + + } else if (hybrid_type == ItemResult.REAL_RESULT) { countRealLength(); - break; - case INT_RESULT: + + } else if (hybrid_type == ItemResult.INT_RESULT) { decimals = 0; - break; - case ROW_RESULT: - default: + + } else { assert (false); } } diff --git a/src/main/java/io/mycat/plan/common/item/function/operator/cmpfunc/ItemFuncMinMax.java b/src/main/java/io/mycat/plan/common/item/function/operator/cmpfunc/ItemFuncMinMax.java index 01f98a04c..83d99a8ff 100644 --- a/src/main/java/io/mycat/plan/common/item/function/operator/cmpfunc/ItemFuncMinMax.java +++ b/src/main/java/io/mycat/plan/common/item/function/operator/cmpfunc/ItemFuncMinMax.java @@ -183,26 +183,22 @@ public abstract class ItemFuncMinMax extends ItemFunc { } } - switch (cmp_type) { - case INT_RESULT: { + if (cmp_type == ItemResult.INT_RESULT) { BigInteger nr = valInt(); if (nullValue) return null; return nr.toString(); - } - case DECIMAL_RESULT: { + } else if (cmp_type == ItemResult.DECIMAL_RESULT) { BigDecimal bd = valDecimal(); if (nullValue) return null; return bd.toString(); - } - case REAL_RESULT: { + } else if (cmp_type == ItemResult.REAL_RESULT) { BigDecimal nr = valReal(); if (nullValue) return null; /* purecov: inspected */ return nr.toString(); - } - case STRING_RESULT: { + } else if (cmp_type == ItemResult.STRING_RESULT) { String res = null; for (int i = 0; i < args.size(); i++) { if (i == 0) @@ -219,10 +215,7 @@ public abstract class ItemFuncMinMax extends ItemFunc { return null; } return res; - } - case ROW_RESULT: - default: - // This case should never be chosen + } else {// This case should never be chosen return null; } } @@ -266,15 +259,15 @@ public abstract class ItemFuncMinMax extends ItemFunc { return MyTime.check_date(ltime, ltime.isNonZeroDate(), fuzzydate, warnings); } - switch (fieldType()) { - case MYSQL_TYPE_TIME: + FieldTypes i = fieldType(); + if (i == FieldTypes.MYSQL_TYPE_TIME) { return getDateFromTime(ltime); - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: - case MYSQL_TYPE_DATE: + } else if (i == FieldTypes.MYSQL_TYPE_DATETIME || i == FieldTypes.MYSQL_TYPE_TIMESTAMP || i == FieldTypes.MYSQL_TYPE_DATE) { assert (false); // Should have been processed in "compare_as_dates" - // block. - default: + // block. + + return getDateFromNonTemporal(ltime, fuzzydate); + } else { return getDateFromNonTemporal(ltime, fuzzydate); } } @@ -292,21 +285,20 @@ public abstract class ItemFuncMinMax extends ItemFunc { return false; } - switch (fieldType()) { - case MYSQL_TYPE_TIME: { + FieldTypes i = fieldType(); + if (i == FieldTypes.MYSQL_TYPE_TIME) { LongPtr result = new LongPtr(0); cmp_times(result); if (nullValue) return true; MyTime.TIME_from_longlong_time_packed(ltime, result.get()); return false; - } - case MYSQL_TYPE_DATE: - case MYSQL_TYPE_TIMESTAMP: - case MYSQL_TYPE_DATETIME: + } else if (i == FieldTypes.MYSQL_TYPE_DATE || i == FieldTypes.MYSQL_TYPE_TIMESTAMP || i == FieldTypes.MYSQL_TYPE_DATETIME) { assert (false); // Should have been processed in "compare_as_dates" - // block. - default: + // block. + + return getTimeFromNonTemporal(ltime); + } else { return getTimeFromNonTemporal(ltime); } } diff --git a/src/main/java/io/mycat/plan/common/item/function/operator/cmpfunc/util/ArgComparator.java b/src/main/java/io/mycat/plan/common/item/function/operator/cmpfunc/util/ArgComparator.java index 58c5de5dd..6cefbdb35 100644 --- a/src/main/java/io/mycat/plan/common/item/function/operator/cmpfunc/util/ArgComparator.java +++ b/src/main/java/io/mycat/plan/common/item/function/operator/cmpfunc/util/ArgComparator.java @@ -101,18 +101,14 @@ public class ArgComparator { public int setCompareFunc(ItemFunc ownerarg, ItemResult type) { owner = ownerarg; func = comparator_matrix[type.ordinal()][isOwnerEqualFunc() == true ? 1 : 0]; - switch (type) { - case ROW_RESULT: - // 未实现 + if (type == ItemResult.ROW_RESULT) {// 未实现 return 1; - case STRING_RESULT: { + } else if (type == ItemResult.STRING_RESULT) { if (func instanceof CompareString) func = new CompareBinaryString(); else if (func instanceof CompareEString) func = new CompareEBinaryString(); - break; - } - case INT_RESULT: { + } else if (type == ItemResult.INT_RESULT) { if (a.isTemporal() && b.isTemporal()) { func = isOwnerEqualFunc() ? new CompareETimePacked() : new CompareTimePacked(); } else if (func instanceof CompareIntSigned) { @@ -120,11 +116,8 @@ public class ArgComparator { } else if (func instanceof CompareEInt) { // } - break; - } - case DECIMAL_RESULT: - break; - case REAL_RESULT: { + } else if (type == ItemResult.DECIMAL_RESULT) { + } else if (type == ItemResult.REAL_RESULT) { if (a.decimals < Item.NOT_FIXED_DEC && b.decimals < Item.NOT_FIXED_DEC) { precision = 5 / Math.pow(10, (Math.max(a.decimals, b.decimals) + 1)); if (func instanceof CompareReal) @@ -132,9 +125,7 @@ public class ArgComparator { else if (func instanceof CompareEReal) func = new CompareERealFixed(); } - break; - } - default: + } else { } return 0; } diff --git a/src/main/java/io/mycat/plan/common/item/function/operator/controlfunc/ItemFuncCase.java b/src/main/java/io/mycat/plan/common/item/function/operator/controlfunc/ItemFuncCase.java index 68957e460..bacfc7c07 100644 --- a/src/main/java/io/mycat/plan/common/item/function/operator/controlfunc/ItemFuncCase.java +++ b/src/main/java/io/mycat/plan/common/item/function/operator/controlfunc/ItemFuncCase.java @@ -101,15 +101,14 @@ public class ItemFuncCase extends ItemFunc { @Override public String valStr() { - switch (fieldType()) { - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + FieldTypes i = fieldType(); + if (i == FieldTypes.MYSQL_TYPE_DATETIME || i == FieldTypes.MYSQL_TYPE_TIMESTAMP) { return valStringFromDatetime(); - case MYSQL_TYPE_DATE: + } else if (i == FieldTypes.MYSQL_TYPE_DATE) { return valStringFromDate(); - case MYSQL_TYPE_TIME: + } else if (i == FieldTypes.MYSQL_TYPE_TIME) { return valStringFromTime(); - default: { + } else { Item item = findItem(); if (item != null) { String res; @@ -119,7 +118,6 @@ public class ItemFuncCase extends ItemFunc { } } } - } nullValue = true; return null; } diff --git a/src/main/java/io/mycat/plan/common/item/function/operator/controlfunc/ItemFuncIf.java b/src/main/java/io/mycat/plan/common/item/function/operator/controlfunc/ItemFuncIf.java index 6e0f438cf..a5bf5ef8d 100644 --- a/src/main/java/io/mycat/plan/common/item/function/operator/controlfunc/ItemFuncIf.java +++ b/src/main/java/io/mycat/plan/common/item/function/operator/controlfunc/ItemFuncIf.java @@ -87,15 +87,13 @@ public class ItemFuncIf extends ItemFunc { @Override public String valStr() { - switch (fieldType()) { - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + if (fieldType() == FieldTypes.MYSQL_TYPE_DATETIME || fieldType() == FieldTypes.MYSQL_TYPE_TIMESTAMP) { return valStringFromDatetime(); - case MYSQL_TYPE_DATE: + } else if (fieldType() == FieldTypes.MYSQL_TYPE_DATE) { return valStringFromDate(); - case MYSQL_TYPE_TIME: + } else if (fieldType() == FieldTypes.MYSQL_TYPE_TIME) { return valStringFromTime(); - default: { + } else { Item item = args.get(0).valBool() ? args.get(1) : args.get(2); String res; if ((res = item.valStr()) != null) { @@ -103,7 +101,6 @@ public class ItemFuncIf extends ItemFunc { return res; } } - } nullValue = true; return null; } diff --git a/src/main/java/io/mycat/plan/common/item/function/primary/ItemFuncNum1.java b/src/main/java/io/mycat/plan/common/item/function/primary/ItemFuncNum1.java index 16c75baa0..09214113a 100644 --- a/src/main/java/io/mycat/plan/common/item/function/primary/ItemFuncNum1.java +++ b/src/main/java/io/mycat/plan/common/item/function/primary/ItemFuncNum1.java @@ -25,17 +25,14 @@ public abstract class ItemFuncNum1 extends ItemFuncNumhybrid { @Override public void findNumType() { - switch (hybrid_type = args.get(0).resultType()) { - case INT_RESULT: - break; - case STRING_RESULT: - case REAL_RESULT: + ItemResult i = hybrid_type = args.get(0).resultType(); + if (i == ItemResult.INT_RESULT) { + } else if (i == ItemResult.STRING_RESULT || i == ItemResult.REAL_RESULT) { hybrid_type = ItemResult.REAL_RESULT; maxLength = floatLength(decimals); - break; - case DECIMAL_RESULT: - break; - default: + + } else if (i == ItemResult.DECIMAL_RESULT) { + } else { assert (false); } } diff --git a/src/main/java/io/mycat/plan/common/item/function/primary/ItemFuncNumhybrid.java b/src/main/java/io/mycat/plan/common/item/function/primary/ItemFuncNumhybrid.java index 6672e940a..8d92aa3a3 100644 --- a/src/main/java/io/mycat/plan/common/item/function/primary/ItemFuncNumhybrid.java +++ b/src/main/java/io/mycat/plan/common/item/function/primary/ItemFuncNumhybrid.java @@ -4,6 +4,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.util.List; +import io.mycat.plan.common.item.FieldTypes; import io.mycat.plan.common.item.Item; import io.mycat.plan.common.item.function.ItemFunc; import io.mycat.plan.common.time.MySQLTime; @@ -42,28 +43,20 @@ public abstract class ItemFuncNumhybrid extends ItemFunc { @Override public BigDecimal valReal() { - switch (hybrid_type) { - case DECIMAL_RESULT: { + if (hybrid_type == ItemResult.DECIMAL_RESULT) { BigDecimal val = decimalOp(); if (val == null) - return BigDecimal.ZERO; // null is set - return val; - } - case INT_RESULT: { + return BigDecimal.ZERO; // null is setreturn val; + } else if (hybrid_type == ItemResult.INT_RESULT) { BigInteger result = intOp(); return new BigDecimal(result); - } - case REAL_RESULT: + } else if (hybrid_type == ItemResult.REAL_RESULT) { return realOp(); - case STRING_RESULT: { - switch (fieldType()) { - case MYSQL_TYPE_TIME: - case MYSQL_TYPE_DATE: - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + } else if (hybrid_type == ItemResult.STRING_RESULT) { + FieldTypes i = fieldType(); + if (i == FieldTypes.MYSQL_TYPE_TIME || i == FieldTypes.MYSQL_TYPE_DATE || i == FieldTypes.MYSQL_TYPE_DATETIME || i == FieldTypes.MYSQL_TYPE_TIMESTAMP) { return valRealFromDecimal(); - default: - break; + } else { } String res = strOp(); if (res == null) @@ -75,36 +68,31 @@ public abstract class ItemFuncNumhybrid extends ItemFunc { logger.error(res + " to BigDecimal error!", e); } } - } - default: + } else { } return BigDecimal.ZERO; } @Override public BigInteger valInt() { - switch (hybrid_type) { - case DECIMAL_RESULT: { + if (hybrid_type == ItemResult.DECIMAL_RESULT) { BigDecimal val = decimalOp(); if (val == null) return BigInteger.ZERO; return val.toBigInteger(); - } - case INT_RESULT: + } else if (hybrid_type == ItemResult.INT_RESULT) { return intOp(); - case REAL_RESULT: + } else if (hybrid_type == ItemResult.REAL_RESULT) { return realOp().toBigInteger(); - case STRING_RESULT: { - switch (fieldType()) { - case MYSQL_TYPE_DATE: + } else if (hybrid_type == ItemResult.STRING_RESULT) { + FieldTypes i = fieldType(); + if (i == FieldTypes.MYSQL_TYPE_DATE) { return new BigDecimal(valIntFromDate()).toBigInteger(); - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + } else if (i == FieldTypes.MYSQL_TYPE_DATETIME || i == FieldTypes.MYSQL_TYPE_TIMESTAMP) { return new BigDecimal(valIntFromDatetime()).toBigInteger(); - case MYSQL_TYPE_TIME: + } else if (i == FieldTypes.MYSQL_TYPE_TIME) { return new BigDecimal(valIntFromTime()).toBigInteger(); - default: - break; + } else { } String res = strOp(); if (res == null) @@ -114,8 +102,7 @@ public abstract class ItemFuncNumhybrid extends ItemFunc { } catch (Exception e) { logger.error(res + " to BigInteger error!", e); } - } - default: + } else { } return BigInteger.ZERO; } @@ -123,30 +110,22 @@ public abstract class ItemFuncNumhybrid extends ItemFunc { @Override public BigDecimal valDecimal() { BigDecimal val = null; - switch (hybrid_type) { - case DECIMAL_RESULT: + if (hybrid_type == ItemResult.DECIMAL_RESULT) { val = decimalOp(); - break; - case INT_RESULT: { + + } else if (hybrid_type == ItemResult.INT_RESULT) { BigInteger result = intOp(); val = new BigDecimal(result); - break; - } - case REAL_RESULT: { + } else if (hybrid_type == ItemResult.REAL_RESULT) { BigDecimal result = realOp(); val = result; - break; - } - case STRING_RESULT: { - switch (fieldType()) { - case MYSQL_TYPE_DATE: - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + } else if (hybrid_type == ItemResult.STRING_RESULT) { + FieldTypes i = fieldType(); + if (i == FieldTypes.MYSQL_TYPE_DATE || i == FieldTypes.MYSQL_TYPE_DATETIME || i == FieldTypes.MYSQL_TYPE_TIMESTAMP) { return valDecimalFromDate(); - case MYSQL_TYPE_TIME: + } else if (i == FieldTypes.MYSQL_TYPE_TIME) { return valDecimalFromTime(); - default: - break; + } else { } String res = strOp(); if (res == null) @@ -156,10 +135,7 @@ public abstract class ItemFuncNumhybrid extends ItemFunc { } catch (Exception e) { val = null; } - break; - } - case ROW_RESULT: - default: + } else { } return val; } @@ -167,42 +143,32 @@ public abstract class ItemFuncNumhybrid extends ItemFunc { @Override public String valStr() { String str = null; - switch (hybrid_type) { - case DECIMAL_RESULT: { + if (hybrid_type == ItemResult.DECIMAL_RESULT) { BigDecimal val = decimalOp(); if (val == null) - return null; // null is set - str = val.toString(); - break; - } - case INT_RESULT: { + return null; // null is setstr = val.toString(); + } else if (hybrid_type == ItemResult.INT_RESULT) { BigInteger nr = intOp(); if (nullValue) return null; /* purecov: inspected */ str = nr.toString(); - break; - } - case REAL_RESULT: { + } else if (hybrid_type == ItemResult.REAL_RESULT) { BigDecimal nr = realOp(); if (nullValue) return null; /* purecov: inspected */ str = nr.toString(); - break; - } - case STRING_RESULT: - switch (fieldType()) { - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + } else if (hybrid_type == ItemResult.STRING_RESULT) { + FieldTypes i = fieldType(); + if (i == FieldTypes.MYSQL_TYPE_DATETIME || i == FieldTypes.MYSQL_TYPE_TIMESTAMP) { return valStringFromDatetime(); - case MYSQL_TYPE_DATE: + } else if (i == FieldTypes.MYSQL_TYPE_DATE) { return valStringFromDate(); - case MYSQL_TYPE_TIME: + } else if (i == FieldTypes.MYSQL_TYPE_TIME) { return valStringFromTime(); - default: - break; + } else { } return strOp(); - default: + } else { } return str; } @@ -210,14 +176,12 @@ public abstract class ItemFuncNumhybrid extends ItemFunc { @Override public boolean getDate(MySQLTime ltime, long flags) { assert (fixed == true); - switch (fieldType()) { - case MYSQL_TYPE_DATE: - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + FieldTypes i = fieldType(); + if (i == FieldTypes.MYSQL_TYPE_DATE || i == FieldTypes.MYSQL_TYPE_DATETIME || i == FieldTypes.MYSQL_TYPE_TIMESTAMP) { return dateOp(ltime, flags); - case MYSQL_TYPE_TIME: + } else if (i == FieldTypes.MYSQL_TYPE_TIME) { return getDateFromTime(ltime); - default: + } else { return getDateFromNonTemporal(ltime, flags); } } @@ -225,15 +189,14 @@ public abstract class ItemFuncNumhybrid extends ItemFunc { @Override public boolean getTime(MySQLTime ltime) { assert (fixed == true); - switch (fieldType()) { - case MYSQL_TYPE_TIME: + FieldTypes i = fieldType(); + if (i == FieldTypes.MYSQL_TYPE_TIME) { return timeOp(ltime); - case MYSQL_TYPE_DATE: + } else if (i == FieldTypes.MYSQL_TYPE_DATE) { return getTimeFromDate(ltime); - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + } else if (i == FieldTypes.MYSQL_TYPE_DATETIME || i == FieldTypes.MYSQL_TYPE_TIMESTAMP) { return getTimeFromDatetime(ltime); - default: + } else { return getTimeFromNonTemporal(ltime); } } diff --git a/src/main/java/io/mycat/plan/common/item/function/strfunc/ItemFuncTrim.java b/src/main/java/io/mycat/plan/common/item/function/strfunc/ItemFuncTrim.java index 6d75f052f..3b91077bd 100644 --- a/src/main/java/io/mycat/plan/common/item/function/strfunc/ItemFuncTrim.java +++ b/src/main/java/io/mycat/plan/common/item/function/strfunc/ItemFuncTrim.java @@ -47,18 +47,17 @@ public class ItemFuncTrim extends ItemStrFunc { @Override public final String funcName() { - switch (mTrimMode) { - case DEFAULT: + if (mTrimMode == TRIM_TYPE_ENUM.DEFAULT) { return "TRIM"; - case BOTH: + } else if (mTrimMode == TRIM_TYPE_ENUM.BOTH) { return "TRIM"; - case LEADING: + } else if (mTrimMode == TRIM_TYPE_ENUM.LEADING) { return "LTRIM"; - case TRAILING: + } else if (mTrimMode == TRIM_TYPE_ENUM.TRAILING) { return "RTRIM"; - case LTRIM: + } else if (mTrimMode == TRIM_TYPE_ENUM.LTRIM) { return "LTRIM"; - case RTRIM: + } else if (mTrimMode == TRIM_TYPE_ENUM.RTRIM) { return "RTRIM"; } return null; @@ -91,22 +90,21 @@ public class ItemFuncTrim extends ItemStrFunc { @Override public SQLExpr toExpression() { SQLMethodInvokeExpr method = new SQLMethodInvokeExpr(); - switch (mTrimMode) { - case LTRIM: + if (mTrimMode == TRIM_TYPE_ENUM.LTRIM) { method.setMethodName("LTRIM"); method.addParameter(args.get(0).toExpression()); - break; - case RTRIM: + + } else if (mTrimMode == TRIM_TYPE_ENUM.RTRIM) { method.setMethodName("RTRIM"); method.addParameter(args.get(0).toExpression()); - break; - default: + + } else { method.setMethodName("TRIM"); method.addParameter(args.get(0).toExpression()); - if (this.getArgCount() > 1){ + if (this.getArgCount() > 1) { method.putAttribute(ItemFuncKeyWord.FROM, args.get(1).toExpression()); } - if(mTrimMode!=TRIM_TYPE_ENUM.DEFAULT){ + if (mTrimMode != TRIM_TYPE_ENUM.DEFAULT) { method.putAttribute(ItemFuncKeyWord.TRIM_TYPE, mTrimMode.toString()); } } diff --git a/src/main/java/io/mycat/plan/common/item/function/sumfunc/ItemSum.java b/src/main/java/io/mycat/plan/common/item/function/sumfunc/ItemSum.java index 4f301115c..1a1176321 100644 --- a/src/main/java/io/mycat/plan/common/item/function/sumfunc/ItemSum.java +++ b/src/main/java/io/mycat/plan/common/item/function/sumfunc/ItemSum.java @@ -226,13 +226,12 @@ public abstract class ItemSum extends ItemResultField { } aggr = null; - switch (aggregator) { - case DISTINCT_AGGREGATOR: + if (aggregator == AggregatorType.DISTINCT_AGGREGATOR) { aggr = new AggregatorDistinct(this, store); - break; - case SIMPLE_AGGREGATOR: + + } else if (aggregator == AggregatorType.SIMPLE_AGGREGATOR) { aggr = new AggregatorSimple(this); - break; + } ; return aggr != null ? FALSE : TRUE; diff --git a/src/main/java/io/mycat/plan/common/item/function/sumfunc/ItemSumHybrid.java b/src/main/java/io/mycat/plan/common/item/function/sumfunc/ItemSumHybrid.java index 3dae67508..f18006744 100644 --- a/src/main/java/io/mycat/plan/common/item/function/sumfunc/ItemSumHybrid.java +++ b/src/main/java/io/mycat/plan/common/item/function/sumfunc/ItemSumHybrid.java @@ -40,17 +40,14 @@ public abstract class ItemSumHybrid extends ItemSum { value = Field.getFieldItem(funcName(), null, item.fieldType().numberValue(), item.charsetIndex, item.maxLength, item.decimals, (item.maybeNull ? 0 : FieldUtil.NOT_NULL_FLAG)); - switch (hybrid_type = item.resultType()) { - case INT_RESULT: - case DECIMAL_RESULT: - case STRING_RESULT: + ItemResult i = hybrid_type = item.resultType(); + if (i == ItemResult.INT_RESULT || i == ItemResult.DECIMAL_RESULT || i == ItemResult.STRING_RESULT) { maxLength = item.maxLength; - break; - case REAL_RESULT: + + } else if (i == ItemResult.REAL_RESULT) { maxLength = floatLength(decimals); - break; - case ROW_RESULT: - default: + + } else { assert (false); } charsetIndex = item.charsetIndex; diff --git a/src/main/java/io/mycat/plan/common/item/function/sumfunc/ItemSumSum.java b/src/main/java/io/mycat/plan/common/item/function/sumfunc/ItemSumSum.java index 403cf311c..dde1f8255 100644 --- a/src/main/java/io/mycat/plan/common/item/function/sumfunc/ItemSumSum.java +++ b/src/main/java/io/mycat/plan/common/item/function/sumfunc/ItemSumSum.java @@ -28,23 +28,15 @@ public class ItemSumSum extends ItemSumNum { public void fixLengthAndDec() { maybeNull = nullValue = true; decimals = args.get(0).decimals; - switch (args.get(0).numericContextResultType()) { - case REAL_RESULT: + ItemResult i = args.get(0).numericContextResultType(); + if (i == ItemResult.REAL_RESULT) { hybrid_type = ItemResult.REAL_RESULT; sum = BigDecimal.ZERO; - break; - case INT_RESULT: - case DECIMAL_RESULT: { - /* SUM result can't be longer than length(arg) + length(MAX_ROWS) */ + + } else if (i == ItemResult.INT_RESULT || i == ItemResult.DECIMAL_RESULT) { int precision = args.get(0).decimalPrecision() + MySQLcom.DECIMAL_LONGLONG_DIGITS; - maxLength = precision + 2;// 一个小数点一个负号 - hybrid_type = ItemResult.DECIMAL_RESULT; - sum = BigDecimal.ZERO; - break; - } - case STRING_RESULT: - case ROW_RESULT: - default: + maxLength = precision + 2;// 一个小数点一个负号hybrid_type = ItemResult.DECIMAL_RESULT;sum = BigDecimal.ZERO; + } else { assert (false); } } diff --git a/src/main/java/io/mycat/plan/common/time/MyTime.java b/src/main/java/io/mycat/plan/common/time/MyTime.java index 3286a8f9e..becb91ff1 100644 --- a/src/main/java/io/mycat/plan/common/time/MyTime.java +++ b/src/main/java/io/mycat/plan/common/time/MyTime.java @@ -791,9 +791,9 @@ public class MyTime { * * @param nr * Number to convert. - * @param OUT + * @param ltime * ltime Variable to convert to. - * @param OUT + * @param warnings * warnings Warning vector. * @retval false OK * @retval true No. is out of range @@ -846,17 +846,15 @@ public class MyTime { } public static long TIME_to_ulonglong(final MySQLTime my_time) { - switch (my_time.time_type) { - case MYSQL_TIMESTAMP_DATETIME: + if (my_time.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_DATETIME) { return TIME_to_ulonglong_datetime(my_time); - case MYSQL_TIMESTAMP_DATE: + } else if (my_time.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_DATE) { return TIME_to_ulonglong_date(my_time); - case MYSQL_TIMESTAMP_TIME: + } else if (my_time.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_TIME) { return TIME_to_ulonglong_time(my_time); - case MYSQL_TIMESTAMP_NONE: - case MYSQL_TIMESTAMP_ERROR: + } else if (my_time.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_NONE || my_time.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_ERROR) { return 0; - default: + } else { assert (false); } return 0; @@ -937,15 +935,13 @@ public class MyTime { * @return Packed numeric time/date/datetime representation. */ public static long TIME_to_longlong_packed(final MySQLTime ltime) { - switch (ltime.time_type) { - case MYSQL_TIMESTAMP_DATE: + if (ltime.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_DATE) { return TIME_to_longlong_date_packed(ltime); - case MYSQL_TIMESTAMP_DATETIME: + } else if (ltime.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_DATETIME) { return TIME_to_longlong_datetime_packed(ltime); - case MYSQL_TIMESTAMP_TIME: + } else if (ltime.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_TIME) { return TIME_to_longlong_time_packed(ltime); - case MYSQL_TIMESTAMP_NONE: - case MYSQL_TIMESTAMP_ERROR: + } else if (ltime.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_NONE || ltime.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_ERROR) { return 0; } assert (false); @@ -955,7 +951,7 @@ public class MyTime { /** * Convert packed numeric datetime representation to MYSQL_TIME. * - * @param OUT + * @param ltime * ltime The datetime variable to convert to. * @param tmp * The packed numeric datetime value. @@ -987,7 +983,7 @@ public class MyTime { /** * Convert packed numeric date representation to MYSQL_TIME. * - * @param OUT + * @param ltime * ltime The date variable to convert to. * @param tmp * The packed numeric date value. @@ -1000,8 +996,8 @@ public class MyTime { /** * Convert time packed numeric representation to time. * - * @param OUT - * ltime The MYSQL_TIME variable to set. + * @param ltime + * The MYSQL_TIME variable to set. * @param tmp * The packed numeric representation. */ @@ -1133,17 +1129,15 @@ public class MyTime { * reserved. */ public static String my_TIME_to_str(final MySQLTime l_time, int dec) { - switch (l_time.time_type) { - case MYSQL_TIMESTAMP_DATETIME: + if (l_time.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_DATETIME) { return my_datetime_to_str(l_time, dec); - case MYSQL_TIMESTAMP_DATE: + } else if (l_time.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_DATE) { return my_date_to_str(l_time); - case MYSQL_TIMESTAMP_TIME: + } else if (l_time.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_TIME) { return my_time_to_str(l_time, dec); - case MYSQL_TIMESTAMP_NONE: - case MYSQL_TIMESTAMP_ERROR: + } else if (l_time.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_NONE || l_time.time_type == MySQLTimestampType.MYSQL_TIMESTAMP_ERROR) { return null; - default: + } else { return null; } } @@ -1194,8 +1188,8 @@ public class MyTime { /** * Round time value to the given precision. * - * @param IN - * /OUT ltime The value to round. + * @param ltime + * The value to round. * @param dec * Precision. * @return False on success, true on error. @@ -1211,8 +1205,8 @@ public class MyTime { /** * Round datetime value to the given precision. * - * @param IN - * /OUT ltime The value to round. + * @param ltime + * ltime The value to round. * @param dec * Precision. * @return False on success, true on error. @@ -1233,32 +1227,31 @@ public class MyTime { sign = (interval.neg ? -1 : 1); - switch (int_type) { - case SECOND: - case SECOND_MICROSECOND: - case MICROSECOND: - case MINUTE: - case HOUR: - case MINUTE_MICROSECOND: - case MINUTE_SECOND: - case HOUR_MICROSECOND: - case HOUR_SECOND: - case HOUR_MINUTE: - case DAY_MICROSECOND: - case DAY_SECOND: - case DAY_MINUTE: - case DAY_HOUR: { + if (int_type == MySqlIntervalUnit.SECOND + || int_type == MySqlIntervalUnit.SECOND_MICROSECOND + || int_type == MySqlIntervalUnit.MICROSECOND + || int_type == MySqlIntervalUnit.MINUTE + || int_type == MySqlIntervalUnit.HOUR + || int_type == MySqlIntervalUnit.MINUTE_MICROSECOND + || int_type == MySqlIntervalUnit.MINUTE_SECOND + || int_type == MySqlIntervalUnit.HOUR_MICROSECOND + || int_type == MySqlIntervalUnit.HOUR_SECOND + || int_type == MySqlIntervalUnit.HOUR_MINUTE + || int_type == MySqlIntervalUnit.DAY_MICROSECOND + || int_type == MySqlIntervalUnit.DAY_SECOND + || int_type == MySqlIntervalUnit.DAY_MINUTE + || int_type == MySqlIntervalUnit.DAY_HOUR) { long sec, days, daynr, microseconds, extra_sec; ltime.time_type = MySQLTimestampType.MYSQL_TIMESTAMP_DATETIME; // Return - // full - // date + // full + // date microseconds = ltime.second_part + sign * interval.second_part; extra_sec = microseconds / 1000000L; microseconds = microseconds % 1000000L; sec = ((ltime.day - 1) * 3600 * 24L + ltime.hour * 3600 + ltime.minute * 60 + ltime.second + sign * (long) (interval.day * 3600 * 24L + interval.hour * 3600 + interval.minute * (60) - + interval.second)) + + interval.second)) + extra_sec; if (microseconds < 0) { microseconds += (1000000L); @@ -1285,10 +1278,7 @@ public class MyTime { ltime.year = ptrYear.get(); ltime.month = ptrMonth.get(); ltime.day = ptrDay.get(); - break; - } - case DAY: - case WEEK: + } else if (int_type == MySqlIntervalUnit.DAY || int_type == MySqlIntervalUnit.WEEK) { period = (calc_daynr(ltime.year, ltime.month, ltime.day) + sign * (long) interval.day); /* Daynumber from year 0 to 9999-12-31 */ if (period > MAX_DAY_NUMBER) @@ -1300,17 +1290,15 @@ public class MyTime { ltime.year = ptrYear.get(); ltime.month = ptrMonth.get(); ltime.day = ptrDay.get(); - break; - case YEAR: + + } else if (int_type == MySqlIntervalUnit.YEAR) { ltime.year += sign * (long) interval.year; if (ltime.year >= 10000) return true; if (ltime.month == 2 && ltime.day == 29 && calc_days_in_year(ltime.year) != 366) ltime.day = 28; // Was leap-year - break; - case YEAR_MONTH: - case QUARTER: - case MONTH: + + } else if (int_type == MySqlIntervalUnit.YEAR_MONTH || int_type == MySqlIntervalUnit.QUARTER || int_type == MySqlIntervalUnit.MONTH) { period = (ltime.year * 12 + sign * (long) interval.year * 12 + ltime.month - 1 + sign * (long) interval.month); if (period >= 120000L) @@ -1323,8 +1311,8 @@ public class MyTime { if (ltime.month == 2 && calc_days_in_year(ltime.year) == 366) ltime.day++; // Leap-year } - break; - default: + + } else { return true; } @@ -1335,7 +1323,7 @@ public class MyTime { /** * Convert double value to datetime value with a warning. * - * @param nr + * @param db * The value to convert from. * @param[out] ltime The variable to convert to. * @param flags @@ -1431,10 +1419,10 @@ public class MyTime { * * The time value is added to the current datetime value. * - * @param IN - * ltime Time value to convert from. - * @param OUT - * ltime2 Datetime value to convert to. + * @param ltime + * Time value to convert from. + * @param ltime2 + * Datetime value to convert to. */ public static void time_to_datetime(final MySQLTime ltime, MySQLTime ltime2) { java.util.Calendar cal1 = ltime.toCalendar(); @@ -1498,11 +1486,11 @@ public class MyTime { * Convert a datetime from broken-down MYSQL_TIME representation to * corresponding TIMESTAMP value. * - * @param thd + * @param * - current thread * @param t * - datetime in broken-down representation, - * @param in_dst_time_gap + * @param * - pointer to bool which is set to true if t represents value * which doesn't exists (falls into the spring time-gap) or to * false otherwise. @@ -1518,44 +1506,38 @@ public class MyTime { } public static long TIME_to_longlong_packed(final MySQLTime ltime, FieldTypes type) { - switch (type) { - case MYSQL_TYPE_TIME: + if (type == FieldTypes.MYSQL_TYPE_TIME) { return TIME_to_longlong_time_packed(ltime); - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + } else if (type == FieldTypes.MYSQL_TYPE_DATETIME || type == FieldTypes.MYSQL_TYPE_TIMESTAMP) { return TIME_to_longlong_datetime_packed(ltime); - case MYSQL_TYPE_DATE: + } else if (type == FieldTypes.MYSQL_TYPE_DATE) { return TIME_to_longlong_date_packed(ltime); - default: + } else { return TIME_to_longlong_packed(ltime); } } public static void TIME_from_longlong_packed(MySQLTime ltime, FieldTypes type, long packed_value) { - switch (type) { - case MYSQL_TYPE_TIME: + if (type == FieldTypes.MYSQL_TYPE_TIME) { TIME_from_longlong_time_packed(ltime, packed_value); - break; - case MYSQL_TYPE_DATE: + + } else if (type == FieldTypes.MYSQL_TYPE_DATE) { TIME_from_longlong_date_packed(ltime, packed_value); - break; - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + + } else if (type == FieldTypes.MYSQL_TYPE_DATETIME || type == FieldTypes.MYSQL_TYPE_TIMESTAMP) { TIME_from_longlong_datetime_packed(ltime, packed_value); - break; - default: + + } else { assert (false); ltime.set_zero_time(MySQLTimestampType.MYSQL_TIMESTAMP_ERROR); - break; + } } /** * Unpack packed numeric temporal value to date/time value and then convert * to decimal representation. - * - * @param OUT - * dec The variable to write to. + * * @param type * MySQL field type. * @param packed_value @@ -1565,18 +1547,16 @@ public class MyTime { */ public static BigDecimal my_decimal_from_datetime_packed(FieldTypes type, long packed_value) { MySQLTime ltime = new MySQLTime(); - switch (type) { - case MYSQL_TYPE_TIME: + if (type == FieldTypes.MYSQL_TYPE_TIME) { TIME_from_longlong_time_packed(ltime, packed_value); return time2my_decimal(ltime); - case MYSQL_TYPE_DATE: + } else if (type == FieldTypes.MYSQL_TYPE_DATE) { TIME_from_longlong_date_packed(ltime, packed_value); return ulonglong2decimal(TIME_to_ulonglong_date(ltime)); - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + } else if (type == FieldTypes.MYSQL_TYPE_DATETIME || type == FieldTypes.MYSQL_TYPE_TIMESTAMP) { TIME_from_longlong_datetime_packed(ltime, packed_value); return date2my_decimal(ltime); - default: + } else { assert (false); return ulonglong2decimal(0); } @@ -1584,18 +1564,16 @@ public class MyTime { public static long longlong_from_datetime_packed(FieldTypes type, long packed_value) { MySQLTime ltime = new MySQLTime(); - switch (type) { - case MYSQL_TYPE_TIME: + if (type == FieldTypes.MYSQL_TYPE_TIME) { TIME_from_longlong_time_packed(ltime, packed_value); return TIME_to_ulonglong_time(ltime); - case MYSQL_TYPE_DATE: + } else if (type == FieldTypes.MYSQL_TYPE_DATE) { TIME_from_longlong_date_packed(ltime, packed_value); return TIME_to_ulonglong_date(ltime); - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_TIMESTAMP: + } else if (type == FieldTypes.MYSQL_TYPE_DATETIME || type == FieldTypes.MYSQL_TYPE_TIMESTAMP) { TIME_from_longlong_datetime_packed(ltime, packed_value); return TIME_to_ulonglong_datetime(ltime); - default: + } else { return 0; } } @@ -1610,8 +1588,6 @@ public class MyTime { * * @param ltime * Date value to convert from. - * @param dec - * Decimal value to convert to. */ public static BigDecimal time2my_decimal(final MySQLTime ltime) { String stmp = String.format("%02d%02d%02d.%06d", ltime.hour, ltime.minute, ltime.second, ltime.second_part); @@ -1623,8 +1599,6 @@ public class MyTime { * * @param ltime * Date value to convert from. - * @param dec - * Decimal value to convert to. */ public static BigDecimal date2my_decimal(final MySQLTime ltime) { String stmp = String.format("%04d%02d%02d%02d%02d%02d.%06d", ltime.year, ltime.month, ltime.day, ltime.hour, @@ -1985,12 +1959,10 @@ public class MyTime { /** * Add nanoseconds to a datetime value with rounding. * - * @param IN - * /OUT ltime MYSQL_TIME variable to add to. - * @param nanosecons + * @param ltime + * MYSQL_TIME variable to add to. + * @param nanoseconds * Nanosecons value. - * @param IN - * /OUT warnings Warning flag vector. * @retval False on success, true on error. */ private static boolean datetime_add_nanoseconds_with_round(MySQLTime ltime, long nanoseconds) { @@ -2146,81 +2118,80 @@ public class MyTime { } BoolPtr negPtr = new BoolPtr(interval.neg); - switch (unit) { - case YEAR: + if (unit == MySqlIntervalUnit.YEAR) { interval.year = value; - break; - case QUARTER: + + } else if (unit == MySqlIntervalUnit.QUARTER) { interval.month = (value * 3); - break; - case MONTH: + + } else if (unit == MySqlIntervalUnit.MONTH) { interval.month = value; - break; - case WEEK: + + } else if (unit == MySqlIntervalUnit.WEEK) { interval.day = (value * 7); - break; - case DAY: + + } else if (unit == MySqlIntervalUnit.DAY) { interval.day = value; - break; - case HOUR: + + } else if (unit == MySqlIntervalUnit.HOUR) { interval.hour = value; - break; - case MINUTE: + + } else if (unit == MySqlIntervalUnit.MINUTE) { interval.minute = value; - break; - case SECOND: + + } else if (unit == MySqlIntervalUnit.SECOND) { interval.second = value; - break; - case MICROSECOND: + + } else if (unit == MySqlIntervalUnit.MICROSECOND) { interval.second_part = value; - break; - case YEAR_MONTH: // Allow YEAR-MONTH YYYYYMM + + } else if (unit == MySqlIntervalUnit.YEAR_MONTH) { if (get_interval_info(arg, str_value, negPtr, 2, array, false)) return true; interval.year = array[0]; interval.month = array[1]; - break; - case DAY_HOUR: + + } else if (unit == MySqlIntervalUnit.DAY_HOUR) { if (get_interval_info(arg, str_value, negPtr, 2, array, false)) return true; interval.day = array[0]; interval.hour = array[1]; - break; - case DAY_MINUTE: + + } else if (unit == MySqlIntervalUnit.DAY_MINUTE) { if (get_interval_info(arg, str_value, negPtr, 3, array, false)) return true; interval.day = array[0]; interval.hour = array[1]; interval.minute = array[2]; - break; - case DAY_SECOND: + + } else if (unit == MySqlIntervalUnit.DAY_SECOND) { if (get_interval_info(arg, str_value, negPtr, 4, array, false)) return true; interval.day = array[0]; interval.hour = array[1]; interval.minute = array[2]; interval.second = array[3]; - break; - case HOUR_MINUTE: + + } else if (unit == MySqlIntervalUnit.HOUR_MINUTE) { if (get_interval_info(arg, str_value, negPtr, 2, array, false)) return true; interval.hour = array[0]; interval.minute = array[1]; - break; - case HOUR_SECOND: + + } else if (unit == MySqlIntervalUnit.HOUR_SECOND) { if (get_interval_info(arg, str_value, negPtr, 3, array, false)) return true; interval.hour = array[0]; interval.minute = array[1]; interval.second = array[2]; - break; - case MINUTE_SECOND: + + } else if (unit == MySqlIntervalUnit.MINUTE_SECOND) { if (get_interval_info(arg, str_value, negPtr, 2, array, false)) return true; interval.minute = array[0]; interval.second = array[1]; - break; - case DAY_MICROSECOND: + + } else if (unit == MySqlIntervalUnit.DAY_MICROSECOND) { if (get_interval_info(arg, str_value, negPtr, 5, array, true)) return true; interval.day = array[0]; @@ -2228,28 +2199,28 @@ public class MyTime { interval.minute = array[2]; interval.second = array[3]; interval.second_part = array[4]; - break; - case HOUR_MICROSECOND: + + } else if (unit == MySqlIntervalUnit.HOUR_MICROSECOND) { if (get_interval_info(arg, str_value, negPtr, 4, array, true)) return true; interval.hour = array[0]; interval.minute = array[1]; interval.second = array[2]; interval.second_part = array[3]; - break; - case MINUTE_MICROSECOND: + + } else if (unit == MySqlIntervalUnit.MINUTE_MICROSECOND) { if (get_interval_info(arg, str_value, negPtr, 3, array, true)) return true; interval.minute = array[0]; interval.second = array[1]; interval.second_part = array[2]; - break; - case SECOND_MICROSECOND: + + } else if (unit == MySqlIntervalUnit.SECOND_MICROSECOND) { if (get_interval_info(arg, str_value, negPtr, 2, array, true)) return true; interval.second = array[0]; interval.second_part = array[1]; - break; + } interval.neg = negPtr.get(); return false; @@ -2351,7 +2322,7 @@ public class MyTime { * * @param format * date/time format specification - * @param val + * @param val_str * String to decode * @param l_time * Store result here diff --git a/src/main/java/io/mycat/plan/node/TableNode.java b/src/main/java/io/mycat/plan/node/TableNode.java index 9a423384d..388da43be 100644 --- a/src/main/java/io/mycat/plan/node/TableNode.java +++ b/src/main/java/io/mycat/plan/node/TableNode.java @@ -11,8 +11,8 @@ import io.mycat.config.MycatConfig; import io.mycat.config.model.SchemaConfig; import io.mycat.config.model.TableConfig; import io.mycat.config.model.TableConfig.TableTypeEnum; -import io.mycat.meta.protocol.MyCatMeta.ColumnMeta; -import io.mycat.meta.protocol.MyCatMeta.TableMeta; +import io.mycat.meta.protocol.StructureMeta.ColumnMeta; +import io.mycat.meta.protocol.StructureMeta.TableMeta; import io.mycat.plan.NamedField; import io.mycat.plan.PlanNode; import io.mycat.plan.common.item.Item; @@ -39,12 +39,12 @@ public class TableNode extends PlanNode { throw new RuntimeException("Table db or name is null error!"); this.schema = catalog; this.tableName = tableName; - MycatConfig mycatConfig = MycatServer.getInstance().getConfig(); - if(mycatConfig.getSystem().isLowerCaseTableNames()){ + MycatConfig config = MycatServer.getInstance().getConfig(); + if(config.getSystem().isLowerCaseTableNames()){ this.schema = this.schema.toLowerCase(); this.tableName = this.tableName.toLowerCase(); } - SchemaConfig schemaConfig = mycatConfig.getSchemas().get(this.schema); + SchemaConfig schemaConfig = config.getSchemas().get(this.schema); if(schemaConfig == null){ throw new RuntimeException("schema "+this.schema+" is not exists!"); } diff --git a/src/main/java/io/mycat/plan/node/view/ViewNode.java b/src/main/java/io/mycat/plan/node/view/ViewNode.java index 210824acf..2fb34a2d2 100644 --- a/src/main/java/io/mycat/plan/node/view/ViewNode.java +++ b/src/main/java/io/mycat/plan/node/view/ViewNode.java @@ -3,7 +3,7 @@ package io.mycat.plan.node.view; import java.util.ArrayList; import java.util.List; -import io.mycat.meta.protocol.MyCatMeta.ColumnMeta; +import io.mycat.meta.protocol.StructureMeta.ColumnMeta; import io.mycat.plan.PlanNode; import io.mycat.plan.common.item.Item; import io.mycat.plan.node.QueryNode; diff --git a/src/main/java/io/mycat/plan/optimizer/FilterJoinColumnPusher.java b/src/main/java/io/mycat/plan/optimizer/FilterJoinColumnPusher.java index 654971c1b..6aa37950c 100644 --- a/src/main/java/io/mycat/plan/optimizer/FilterJoinColumnPusher.java +++ b/src/main/java/io/mycat/plan/optimizer/FilterJoinColumnPusher.java @@ -56,16 +56,16 @@ public class FilterJoinColumnPusher { qtn.query(FilterUtils.and(nonJoinFilter)); } } - switch (qtn.type()) { - case QUERY: + PlanNode.PlanNodeType i = qtn.type(); + if (i == PlanNode.PlanNodeType.QUERY) { if (DNFNodeToPush.isEmpty()) { return qtn; } refreshPdFilters(qtn, DNFNodeToPush); PlanNode child = pushFilter(qtn.getChild(), DNFNodeToPush); ((QueryNode) qtn).setChild(child); - break; - case JOIN: + + } else if (i == PlanNode.PlanNodeType.JOIN) { JoinNode jn = (JoinNode) qtn; PlanUtil.findJoinKeysAndRemoveIt(DNFNodeToPush, jn); if (DNFNodeToPush.isEmpty()) { @@ -111,15 +111,13 @@ public class FilterJoinColumnPusher { jn.query(FilterUtils.and(DNFNodeToPush)); } } - break; - case MERGE: + + } else if (i == PlanNode.PlanNodeType.MERGE) { List children = qtn.getChildren(); for (int index = 0; index < children.size(); index++) { pushFilter(children.get(index), new ArrayList()); } - break; - default: - break; + } return qtn; } diff --git a/src/main/java/io/mycat/plan/optimizer/SelectedProcessor.java b/src/main/java/io/mycat/plan/optimizer/SelectedProcessor.java index 5bad07332..8f5c0b0f8 100644 --- a/src/main/java/io/mycat/plan/optimizer/SelectedProcessor.java +++ b/src/main/java/io/mycat/plan/optimizer/SelectedProcessor.java @@ -82,12 +82,12 @@ public class SelectedProcessor { } qtn.setUpRefers(isPushDownNode); } - switch (qtn.type()) { - case NONAME: + PlanNodeType i = qtn.type(); + if (i == PlanNodeType.NONAME) { return qtn; - case TABLE: + } else if (i == PlanNodeType.TABLE) { return qtn; - default: + } else { for (PlanNode child : qtn.getChildren()) { List referList = qtn.getColumnsReferedByChild(child); if (referList.isEmpty()) { diff --git a/src/main/java/io/mycat/route/RouteService.java b/src/main/java/io/mycat/route/RouteService.java index 2f4351743..aa30435a1 100644 --- a/src/main/java/io/mycat/route/RouteService.java +++ b/src/main/java/io/mycat/route/RouteService.java @@ -46,12 +46,10 @@ import java.util.Map; public class RouteService { private static final Logger LOGGER = LoggerFactory .getLogger(RouteService.class); - public static final String MYCAT_HINT_TYPE = "_mycatHintType"; + public static final String HINT_TYPE = "_serverHintType"; private final CachePool sqlRouteCache; private final LayerCachePool tableId2DataNodeCache; - private final String OLD_MYCAT_HINT = "/*!mycat:"; // 处理自定义分片注解, 注解格式:/*!mycat: type = value */ sql - private final String NEW_MYCAT_HINT = "/*#mycat:"; // 新的注解格式:/* !mycat: type = value */ sql,oldMycatHint的格式不兼容直连mysql private final String HINT_SPLIT = "="; @@ -98,11 +96,12 @@ public class RouteService { int firstSplitPos = hint.indexOf(HINT_SPLIT); if(firstSplitPos > 0 ){ Map hintMap= parseHint(hint); - String hintType = (String) hintMap.get(MYCAT_HINT_TYPE); + String hintType = (String) hintMap.get(HINT_TYPE); String hintSql = (String) hintMap.get(hintType); if( hintSql.length() == 0 ) { - LOGGER.warn("comment int sql must meet :/*!mycat:type=value*/ or /*#mycat:type=value*/ or /*mycat:type=value*/: "+stmt); - throw new SQLSyntaxErrorException("comment int sql must meet :/*!mycat:type=value*/ or /*#mycat:type=value*/ or /*mycat:type=value*/: "+stmt); + String msg = "comment in sql must meet :/*!"+ Versions.ANNOTATION_NAME+"type=value*/ or /*#"+ Versions.ANNOTATION_NAME+"type=value*/ or /*"+ Versions.ANNOTATION_NAME+"type=value*/: "+stmt; + LOGGER.warn(msg); + throw new SQLSyntaxErrorException(msg); } String realSQL = stmt.substring(endPos + "*/".length()).trim(); @@ -126,8 +125,9 @@ public class RouteService { } }else{//fixed by runfriends@126.com - LOGGER.warn("comment in sql must meet :/*!mycat:type=value*/ or /*#mycat:type=value*/ or /*mycat:type=value*/: "+stmt); - throw new SQLSyntaxErrorException("comment in sql must meet :/*!mcat:type=value*/ or /*#mycat:type=value*/ or /*mycat:type=value*/: "+stmt); + String msg = "comment in sql must meet :/*!"+ Versions.ANNOTATION_NAME+"type=value*/ or /*#"+ Versions.ANNOTATION_NAME+"type=value*/ or /*"+ Versions.ANNOTATION_NAME+"type=value*/: "+stmt; + LOGGER.warn(msg); + throw new SQLSyntaxErrorException(msg); } } } else { @@ -218,7 +218,7 @@ public class RouteService { } if(map.isEmpty()) { - map.put(MYCAT_HINT_TYPE,key) ; + map.put(HINT_TYPE,key) ; } map.put(key,value.trim()); diff --git a/src/main/java/io/mycat/route/function/AutoPartitionByLong.java b/src/main/java/io/mycat/route/function/AutoPartitionByLong.java index b07fe14aa..d1fb87335 100644 --- a/src/main/java/io/mycat/route/function/AutoPartitionByLong.java +++ b/src/main/java/io/mycat/route/function/AutoPartitionByLong.java @@ -29,6 +29,7 @@ import java.io.InputStreamReader; import java.util.LinkedList; import io.mycat.config.model.rule.RuleAlgorithm; +import io.mycat.util.ResourceUtil; /** * auto partition by Long ,can be used in auto increment primary key partition @@ -137,8 +138,7 @@ public class AutoPartitionByLong extends AbstractPartitionAlgorithm implements R BufferedReader in = null; try { // FileInputStream fin = new FileInputStream(new File(fileMapPath)); - InputStream fin = this.getClass().getClassLoader() - .getResourceAsStream(mapFile); + InputStream fin = ResourceUtil.getResourceAsStreamFromRoot(mapFile); if (fin == null) { throw new RuntimeException("can't find class resource file " + mapFile); diff --git a/src/main/java/io/mycat/route/function/PartitionByFileMap.java b/src/main/java/io/mycat/route/function/PartitionByFileMap.java index 296007f18..cfba3020f 100644 --- a/src/main/java/io/mycat/route/function/PartitionByFileMap.java +++ b/src/main/java/io/mycat/route/function/PartitionByFileMap.java @@ -32,6 +32,7 @@ import java.util.Map; import java.util.Set; import io.mycat.config.model.rule.RuleAlgorithm; +import io.mycat.util.ResourceUtil; /** * @@ -114,8 +115,8 @@ public class PartitionByFileMap extends AbstractPartitionAlgorithm implements Ru BufferedReader in = null; try { // FileInputStream fin = new FileInputStream(new File(fileMapPath)); - InputStream fin = this.getClass().getClassLoader() - .getResourceAsStream(mapFile); + + InputStream fin = ResourceUtil.getResourceAsStreamFromRoot(mapFile); if (fin == null) { throw new RuntimeException("can't find class resource file " + mapFile); diff --git a/src/main/java/io/mycat/route/function/PartitionByPattern.java b/src/main/java/io/mycat/route/function/PartitionByPattern.java index dd5d3873a..87eb84161 100644 --- a/src/main/java/io/mycat/route/function/PartitionByPattern.java +++ b/src/main/java/io/mycat/route/function/PartitionByPattern.java @@ -31,6 +31,7 @@ import java.util.HashSet; import java.util.regex.Pattern; import io.mycat.config.model.rule.RuleAlgorithm; +import io.mycat.util.ResourceUtil; /** * auto partition by Long @@ -187,7 +188,7 @@ public class PartitionByPattern extends AbstractPartitionAlgorithm implements Ru BufferedReader in = null; try { // FileInputStream fin = new FileInputStream(new File(fileMapPath)); - InputStream fin = this.getClass().getClassLoader().getResourceAsStream(mapFile); + InputStream fin = ResourceUtil.getResourceAsStreamFromRoot(mapFile); if (fin == null) { throw new RuntimeException("can't find class resource file " + mapFile); } diff --git a/src/main/java/io/mycat/route/impl/DruidMycatRouteStrategy.java b/src/main/java/io/mycat/route/impl/DruidMycatRouteStrategy.java index 9255b9e7c..4105150c9 100644 --- a/src/main/java/io/mycat/route/impl/DruidMycatRouteStrategy.java +++ b/src/main/java/io/mycat/route/impl/DruidMycatRouteStrategy.java @@ -44,7 +44,7 @@ public class DruidMycatRouteStrategy extends AbstractRouteStrategy { statement = list.get(0); visitor = new MycatSchemaStatVisitor(); } catch (Exception t) { - LOGGER.error("DruidMycatRouteStrategyError", t); + LOGGER.error("routeNormalSqlWithAST", t); throw new SQLSyntaxErrorException(t); } diff --git a/src/main/java/io/mycat/route/parser/druid/MycatLexer.java b/src/main/java/io/mycat/route/parser/druid/MycatLexer.java deleted file mode 100644 index 21a019327..000000000 --- a/src/main/java/io/mycat/route/parser/druid/MycatLexer.java +++ /dev/null @@ -1,56 +0,0 @@ -package io.mycat.route.parser.druid; - -import com.alibaba.druid.sql.dialect.mysql.parser.MySqlLexer; -import com.alibaba.druid.sql.parser.Keywords; -import com.alibaba.druid.sql.parser.Token; - -import java.util.HashMap; -import java.util.Map; - -/** - * Created by magicdoom on 2015/3/13. - */ -public class MycatLexer extends MySqlLexer -{ - public final static Keywords DEFAULT_MYCAT_KEYWORDS; - static { - Map map = new HashMap(); - - map.putAll(Keywords.DEFAULT_KEYWORDS.getKeywords()); - - map.put("DUAL", Token.DUAL); - map.put("FALSE", Token.FALSE); - map.put("IDENTIFIED", Token.IDENTIFIED); - map.put("IF", Token.IF); - map.put("KILL", Token.KILL); - - map.put("LIMIT", Token.LIMIT); - map.put("TRUE", Token.TRUE); - map.put("BINARY", Token.BINARY); - map.put("SHOW", Token.SHOW); - map.put("CACHE", Token.CACHE); - map.put("ANALYZE", Token.ANALYZE); - map.put("OPTIMIZE", Token.OPTIMIZE); - map.put("ROW", Token.ROW); - map.put("BEGIN", Token.BEGIN); - map.put("END", Token.END); - - map.put("TOP", Token.TOP); - - - DEFAULT_MYCAT_KEYWORDS = new Keywords(map); - } - - - public MycatLexer(char[] input, int inputLength, boolean skipComment) - { - super(input, inputLength, skipComment); - super.keywods = DEFAULT_MYCAT_KEYWORDS; - } - - public MycatLexer(String input) - { - super(input); - super.keywods = DEFAULT_MYCAT_KEYWORDS; - } -} diff --git a/src/main/java/io/mycat/route/parser/druid/impl/DruidInsertParser.java b/src/main/java/io/mycat/route/parser/druid/impl/DruidInsertParser.java index e3fda4c18..0fdfd1d75 100644 --- a/src/main/java/io/mycat/route/parser/druid/impl/DruidInsertParser.java +++ b/src/main/java/io/mycat/route/parser/druid/impl/DruidInsertParser.java @@ -28,8 +28,8 @@ import io.mycat.config.MycatPrivileges; import io.mycat.config.MycatPrivileges.Checktype; import io.mycat.config.model.SchemaConfig; import io.mycat.config.model.TableConfig; -import io.mycat.meta.protocol.MyCatMeta.IndexMeta; -import io.mycat.meta.protocol.MyCatMeta.TableMeta; +import io.mycat.meta.protocol.StructureMeta.IndexMeta; +import io.mycat.meta.protocol.StructureMeta.TableMeta; import io.mycat.route.RouteResultset; import io.mycat.route.RouteResultsetNode; import io.mycat.route.function.AbstractPartitionAlgorithm; @@ -434,7 +434,7 @@ public class DruidInsertParser extends DefaultDruidParser { sb.append(","); } sb.append(column); - if (isGlobalCheck && column.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN)) { + if (isGlobalCheck && column.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN)) { idxGlobal = i; // 找到 内部列的索引位置 } } @@ -447,7 +447,7 @@ public class DruidInsertParser extends DefaultDruidParser { else sb.append(columns.get(i).toString()); String column = StringUtil.removeBackQuote(insert.getColumns().get(i).toString()); - if (isGlobalCheck && column.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN)) { + if (isGlobalCheck && column.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN)) { String msg = "In insert Syntax, you can't set value for Global check column!"; LOGGER.warn(msg); throw new SQLNonTransientException(msg); @@ -466,7 +466,7 @@ public class DruidInsertParser extends DefaultDruidParser { } if (isGlobalCheck ){ idxGlobal = isAutoIncrement ? columns.size() + 1 : columns.size(); - sb.append(",").append(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN); + sb.append(",").append(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN); colSize++; } sb.append(")"); @@ -499,7 +499,7 @@ public class DruidInsertParser extends DefaultDruidParser { throw new SQLNonTransientException(msg); } SQLBinaryOpExpr binaryOpExpr = (SQLBinaryOpExpr)exp; - if (isGlobalCheck && !flag && GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN.equals(binaryOpExpr.getLeft().toString())) { + if (isGlobalCheck && !flag && GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN.equals(binaryOpExpr.getLeft().toString())) { flag = true; onDuplicateGlobalColumn(sb); } else { @@ -518,9 +518,9 @@ public class DruidInsertParser extends DefaultDruidParser { } private static void onDuplicateGlobalColumn(StringBuilder sb){ - sb.append(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN); + sb.append(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN); sb.append("=values("); - sb.append(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN); + sb.append(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN); sb.append(")"); } diff --git a/src/main/java/io/mycat/route/parser/druid/impl/DruidSelectParser.java b/src/main/java/io/mycat/route/parser/druid/impl/DruidSelectParser.java index efb6e8673..c76dc7983 100644 --- a/src/main/java/io/mycat/route/parser/druid/impl/DruidSelectParser.java +++ b/src/main/java/io/mycat/route/parser/druid/impl/DruidSelectParser.java @@ -19,8 +19,8 @@ import io.mycat.config.MycatPrivileges; import io.mycat.config.MycatPrivileges.Checktype; import io.mycat.config.model.SchemaConfig; import io.mycat.config.model.TableConfig; -import io.mycat.meta.protocol.MyCatMeta.ColumnMeta; -import io.mycat.meta.protocol.MyCatMeta.TableMeta; +import io.mycat.meta.protocol.StructureMeta.ColumnMeta; +import io.mycat.meta.protocol.StructureMeta.TableMeta; import io.mycat.plan.common.item.Item; import io.mycat.plan.visitor.MySQLItemVisitor; import io.mycat.route.RouteResultset; diff --git a/src/main/java/io/mycat/route/parser/druid/impl/DruidUpdateParser.java b/src/main/java/io/mycat/route/parser/druid/impl/DruidUpdateParser.java index b4721da94..cc9592476 100644 --- a/src/main/java/io/mycat/route/parser/druid/impl/DruidUpdateParser.java +++ b/src/main/java/io/mycat/route/parser/druid/impl/DruidUpdateParser.java @@ -27,13 +27,12 @@ import com.alibaba.druid.sql.ast.statement.SQLUpdateStatement; import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateStatement; import io.mycat.MycatServer; -import io.mycat.config.ErrorCode; import io.mycat.config.MycatPrivileges; import io.mycat.config.MycatPrivileges.Checktype; import io.mycat.config.model.ERTable; import io.mycat.config.model.SchemaConfig; import io.mycat.config.model.TableConfig; -import io.mycat.meta.protocol.MyCatMeta.TableMeta; +import io.mycat.meta.protocol.StructureMeta.TableMeta; import io.mycat.route.RouteResultset; import io.mycat.route.parser.druid.MycatSchemaStatVisitor; import io.mycat.route.util.RouterUtil; @@ -123,7 +122,7 @@ public class DruidUpdateParser extends DefaultDruidParser { SQLUpdateSetItem item = items.get(i); String col = item.getColumn().toString(); - if (StringUtil.removeBackQuote(col).equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN)) { + if (StringUtil.removeBackQuote(col).equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN)) { flag = true; SQLUpdateSetItem newItem = new SQLUpdateSetItem(); newItem.setColumn(item.getColumn()); @@ -134,7 +133,7 @@ public class DruidUpdateParser extends DefaultDruidParser { } if(!flag){ SQLUpdateSetItem newItem = new SQLUpdateSetItem(); - newItem.setColumn(new SQLIdentifierExpr(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN)); + newItem.setColumn(new SQLIdentifierExpr(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN)); newItem.setValue(new SQLIntegerExpr(opTimestamp)); items.add(newItem); } diff --git a/src/main/java/io/mycat/route/parser/druid/impl/ddl/DruidAlterTableParser.java b/src/main/java/io/mycat/route/parser/druid/impl/ddl/DruidAlterTableParser.java index 631153e88..4812064c6 100644 --- a/src/main/java/io/mycat/route/parser/druid/impl/ddl/DruidAlterTableParser.java +++ b/src/main/java/io/mycat/route/parser/druid/impl/ddl/DruidAlterTableParser.java @@ -26,11 +26,10 @@ import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlAlterTableChangeCo import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlAlterTableModifyColumn; import io.mycat.MycatServer; -import io.mycat.config.ErrorCode; import io.mycat.config.model.SchemaConfig; import io.mycat.config.model.TableConfig; -import io.mycat.meta.protocol.MyCatMeta.ColumnMeta; -import io.mycat.meta.protocol.MyCatMeta.TableMeta; +import io.mycat.meta.protocol.StructureMeta.ColumnMeta; +import io.mycat.meta.protocol.StructureMeta.TableMeta; import io.mycat.route.RouteResultset; import io.mycat.route.parser.druid.MycatSchemaStatVisitor; import io.mycat.route.parser.druid.impl.DefaultDruidParser; @@ -119,7 +118,7 @@ public class DruidAlterTableParser extends DefaultDruidParser { } alterStatement.getItems().clear(); if(newAlterItems.size()==0){ - String msg = "you can't drop the column "+GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN+", sql:" + alterStatement; + String msg = "you can't drop the column "+GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN +", sql:" + alterStatement; throw new SQLNonTransientException(msg); } for (SQLAlterTableItem newAlterItem : newAlterItems) { @@ -131,7 +130,7 @@ public class DruidAlterTableParser extends DefaultDruidParser { private void dropColumn(List cols, SQLAlterTableDropColumnItem dropColumn, List newAlterItems) { for (SQLName dropName : dropColumn.getColumns()) { String dropColName = StringUtil.removeBackQuote(dropName.getSimpleName()); - if (dropColName.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN)) { + if (dropColName.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN)) { continue; } removeOldCol(cols, dropColName); @@ -142,9 +141,9 @@ public class DruidAlterTableParser extends DefaultDruidParser { private void modifyColumn(List cols, MySqlAlterTableModifyColumn modifyColumn, List newAlterItems) { String modifyColName = StringUtil.removeBackQuote(modifyColumn.getNewColumnDefinition().getName().getSimpleName()); MySqlAlterTableModifyColumn newModifyColumn = modifyColumn; - if (modifyColName.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN)) { + if (modifyColName.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN)) { removeOldCol(cols, modifyColName); - newModifyColumn.setNewColumnDefinition(GlobalTableUtil.createMycatColumn()); + newModifyColumn.setNewColumnDefinition(GlobalTableUtil.createCheckColumn()); newModifyColumn.setAfterColumn(new SQLIdentifierExpr(cols.get(cols.size() - 1))); cols.add(modifyColName); } else { @@ -153,9 +152,9 @@ public class DruidAlterTableParser extends DefaultDruidParser { removeOldCol(cols, modifyColName); int lastIndex = cols.size() - 1; String afterColName = StringUtil.removeBackQuote(((SQLIdentifierExpr) afterColumn).getName()); - //last column is GLOBAL_TABLE_MYCAT_COLUMN,so new add will move to the pos before it - if (afterColName.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN) - && cols.get(lastIndex).equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN)) { + //last column is GLOBAL_TABLE_CHECK_COLUMN,so new add will move to the pos before it + if (afterColName.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN) + && cols.get(lastIndex).equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN)) { newModifyColumn.setAfterColumn(new SQLIdentifierExpr(cols.get(lastIndex - 1))); cols.add(lastIndex, modifyColName); } else { @@ -190,20 +189,20 @@ public class DruidAlterTableParser extends DefaultDruidParser { String oldColName = StringUtil.removeBackQuote(changeColumn.getColumnName().getSimpleName()); String newColName = StringUtil.removeBackQuote(changeColumn.getNewColumnDefinition().getName().getSimpleName()); MySqlAlterTableChangeColumn newChangeColumn = changeColumn; - if (oldColName.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN)) { + if (oldColName.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN)) { removeOldCol(cols, oldColName); - newChangeColumn.setNewColumnDefinition(GlobalTableUtil.createMycatColumn()); + newChangeColumn.setNewColumnDefinition(GlobalTableUtil.createCheckColumn()); newChangeColumn.setAfterColumn(new SQLIdentifierExpr(cols.get(cols.size() - 1))); cols.add(newColName); } else { SQLExpr afterColumn = changeColumn.getAfterColumn(); if (afterColumn != null) { - //last column is GLOBAL_TABLE_MYCAT_COLUMN,so new add will move to the pos before it + //last column is GLOBAL_TABLE_CHECK_COLUMN,so new add will move to the pos before it removeOldCol(cols, oldColName); int lastIndex = cols.size() - 1; String afterColName = StringUtil.removeBackQuote(((SQLIdentifierExpr) afterColumn).getName()); - if (afterColName.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN) - && cols.get(lastIndex).equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN)) { + if (afterColName.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN) + && cols.get(lastIndex).equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN)) { newChangeColumn.setAfterColumn(new SQLIdentifierExpr(cols.get(lastIndex-1))); cols.add(lastIndex, newColName); } else { @@ -222,16 +221,16 @@ public class DruidAlterTableParser extends DefaultDruidParser { if (afterColumn != null || addColumn.isFirst()) { SQLAlterTableAddColumn newAddColumn = addColumn; String addName = StringUtil.removeBackQuote(addColumn.getColumns().get(0).getName().getSimpleName()); - if (addName.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN)) { + if (addName.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN)) { newAddColumn.setFirst(false); newAddColumn.setAfterColumn(null); cols.add(cols.size(), addName); } else if (afterColumn != null) { String afterColName = StringUtil.removeBackQuote(afterColumn.getSimpleName()); - //last column is GLOBAL_TABLE_MYCAT_COLUMN,so new add will move to the pos before it + //last column is GLOBAL_TABLE_CHECK_COLUMN,so new add will move to the pos before it int lastIndex = cols.size() - 1; - if (afterColName.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN) - && cols.get(lastIndex).equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN)) { + if (afterColName.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN) + && cols.get(lastIndex).equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN)) { newAddColumn.setAfterColumn(new SQLIdentifierExpr(cols.get(lastIndex-1))); cols.add(lastIndex, addName); } @@ -245,7 +244,7 @@ public class DruidAlterTableParser extends DefaultDruidParser { newAddColumn.addColumn(columnDef); String addName = StringUtil.removeBackQuote(columnDef.getName().getSimpleName()); int lastIndex = cols.size()-1; - if (cols.get(lastIndex).equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN)) { + if (cols.get(lastIndex).equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN)) { newAddColumn.setAfterColumn(new SQLIdentifierExpr(cols.get(lastIndex-1))); cols.add(lastIndex, addName); }else{ diff --git a/src/main/java/io/mycat/route/parser/druid/impl/ddl/DruidCreateTableParser.java b/src/main/java/io/mycat/route/parser/druid/impl/ddl/DruidCreateTableParser.java index df8d68717..e3262f1f3 100644 --- a/src/main/java/io/mycat/route/parser/druid/impl/ddl/DruidCreateTableParser.java +++ b/src/main/java/io/mycat/route/parser/druid/impl/ddl/DruidCreateTableParser.java @@ -13,7 +13,6 @@ import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; import com.alibaba.druid.sql.ast.statement.SQLTableElement; import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateTableStatement; -import io.mycat.config.ErrorCode; import io.mycat.config.model.SchemaConfig; import io.mycat.route.RouteResultset; import io.mycat.route.parser.druid.MycatSchemaStatVisitor; @@ -64,7 +63,7 @@ public class DruidCreateTableParser extends DefaultDruidParser { private String addColumnIfCreate(MySqlCreateTableStatement createStmt) { removeGlobalColumnIfExist(createStmt); - createStmt.getTableElementList().add(GlobalTableUtil.createMycatColumn()); + createStmt.getTableElementList().add(GlobalTableUtil.createCheckColumn()); return createStmt.toString(); } @@ -77,7 +76,7 @@ public class DruidCreateTableParser extends DefaultDruidParser { if (sqlName != null) { String simpleName = sqlName.getSimpleName(); simpleName = StringUtil.removeBackQuote(simpleName); - if (GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN.equalsIgnoreCase(simpleName)) { + if (GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN.equalsIgnoreCase(simpleName)) { statement.getTableElementList().remove(tableElement); break; } diff --git a/src/main/java/io/mycat/route/sequence/handler/FetchMySQLSequnceHandler.java b/src/main/java/io/mycat/route/sequence/handler/FetchMySQLSequnceHandler.java new file mode 100644 index 000000000..994d01b98 --- /dev/null +++ b/src/main/java/io/mycat/route/sequence/handler/FetchMySQLSequnceHandler.java @@ -0,0 +1,148 @@ +package io.mycat.route.sequence.handler; + +import io.mycat.MycatServer; +import io.mycat.backend.BackendConnection; +import io.mycat.backend.datasource.PhysicalDBNode; +import io.mycat.backend.mysql.nio.handler.ResponseHandler; +import io.mycat.config.MycatConfig; +import io.mycat.net.mysql.ErrorPacket; +import io.mycat.net.mysql.FieldPacket; +import io.mycat.net.mysql.RowDataPacket; +import io.mycat.route.RouteResultsetNode; +import io.mycat.server.parser.ServerParse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; + +/** + * Created by huqing.yan on 2017/7/3. + */ +public class FetchMySQLSequnceHandler implements ResponseHandler { + protected static final Logger LOGGER = LoggerFactory + .getLogger(FetchMySQLSequnceHandler.class); + public void execute(SequenceVal seqVal) { + MycatConfig conf = MycatServer.getInstance().getConfig(); + PhysicalDBNode mysqlDN = conf.getDataNodes().get(seqVal.dataNode); + try { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("execute in datanode " + seqVal.dataNode + + " for fetch sequnce sql " + seqVal.sql); + } + // 修正获取seq的逻辑,在读写分离的情况下只能走写节点。修改Select模式为Update模式。 + mysqlDN.getConnection(mysqlDN.getDatabase(), true, + new RouteResultsetNode(seqVal.dataNode, ServerParse.UPDATE, + seqVal.sql), this, seqVal); + } catch (Exception e) { + LOGGER.warn("get connection err " + e); + } + + } + + public String getLastestError(String seqName) { + return IncrSequenceMySQLHandler.latestErrors.get(seqName); + } + + @Override + public void connectionAcquired(BackendConnection conn) { + + conn.setResponseHandler(this); + try { + conn.query(((SequenceVal) conn.getAttachment()).sql); + } catch (Exception e) { + executeException(conn, e); + } + } + + @Override + public void connectionError(Throwable e, BackendConnection conn) { + ((SequenceVal) conn.getAttachment()).dbfinished = true; + LOGGER.warn("connectionError " + e); + + } + + @Override + public void errorResponse(byte[] data, BackendConnection conn) { + SequenceVal seqVal = ((SequenceVal) conn.getAttachment()); + seqVal.dbfinished = true; + + ErrorPacket err = new ErrorPacket(); + err.read(data); + String errMsg = new String(err.message); + LOGGER.warn("errorResponse " + err.errno + " " + errMsg); + IncrSequenceMySQLHandler.latestErrors.put(seqVal.seqName, errMsg); + conn.release(); + + } + + @Override + public void okResponse(byte[] ok, BackendConnection conn) { + boolean executeResponse = conn.syncAndExcute(); + if (executeResponse) { + ((SequenceVal) conn.getAttachment()).dbfinished = true; + conn.release(); + } + + } + + @Override + public boolean rowResponse(byte[] row, RowDataPacket rowPacket, boolean isLeft, BackendConnection conn) { + RowDataPacket rowDataPkg = new RowDataPacket(1); + rowDataPkg.read(row); + byte[] columnData = rowDataPkg.fieldValues.get(0); + String columnVal = new String(columnData); + SequenceVal seqVal = (SequenceVal) conn.getAttachment(); + if (IncrSequenceMySQLHandler.errSeqResult.equals(columnVal)) { + seqVal.dbretVal = IncrSequenceMySQLHandler.errSeqResult; + LOGGER.warn(" sequnce sql returned err value ,sequence:" + + seqVal.seqName + " " + columnVal + " sql:" + seqVal.sql); + } else { + seqVal.dbretVal = columnVal; + } + return false; + } + + @Override + public void rowEofResponse(byte[] eof, boolean isLeft, BackendConnection conn) { + ((SequenceVal) conn.getAttachment()).dbfinished = true; + conn.release(); + } + + @Override + public void relayPacketResponse(byte[] relayPacket, BackendConnection conn) { + + } + + @Override + public void endPacketResponse(byte[] endPacket, BackendConnection conn) { + + } + + private void executeException(BackendConnection c, Throwable e) { + SequenceVal seqVal = ((SequenceVal) c.getAttachment()); + seqVal.dbfinished = true; + String errMgs=e.toString(); + IncrSequenceMySQLHandler.latestErrors.put(seqVal.seqName, errMgs); + LOGGER.warn("executeException " + errMgs); + c.close("exception:" +errMgs); + + } + + @Override + public void writeQueueAvailable() { + + } + + @Override + public void connectionClose(BackendConnection conn, String reason) { + + LOGGER.warn("connection closed " + conn + " reason:" + reason); + } + + @Override + public void fieldEofResponse(byte[] header, List fields, List fieldPackets, byte[] eof, + boolean isLeft, BackendConnection conn) { + + } + +} \ No newline at end of file diff --git a/src/main/java/io/mycat/route/sequence/handler/IncrSequenceMySQLHandler.java b/src/main/java/io/mycat/route/sequence/handler/IncrSequenceMySQLHandler.java index 6d165d01b..385256287 100644 --- a/src/main/java/io/mycat/route/sequence/handler/IncrSequenceMySQLHandler.java +++ b/src/main/java/io/mycat/route/sequence/handler/IncrSequenceMySQLHandler.java @@ -1,19 +1,5 @@ package io.mycat.route.sequence.handler; -import java.io.IOException; -import java.io.InputStream; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicLong; - -import io.mycat.net.mysql.FieldPacket; -import io.mycat.route.util.PropertiesUtil; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import io.mycat.MycatServer; import io.mycat.backend.BackendConnection; import io.mycat.backend.datasource.PhysicalDBNode; @@ -21,9 +7,21 @@ import io.mycat.backend.mysql.nio.handler.ResponseHandler; import io.mycat.config.MycatConfig; import io.mycat.config.util.ConfigException; import io.mycat.net.mysql.ErrorPacket; +import io.mycat.net.mysql.FieldPacket; import io.mycat.net.mysql.RowDataPacket; import io.mycat.route.RouteResultsetNode; +import io.mycat.route.util.PropertiesUtil; import io.mycat.server.parser.ServerParse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; public class IncrSequenceMySQLHandler implements SequenceHandler { @@ -34,13 +32,10 @@ public class IncrSequenceMySQLHandler implements SequenceHandler { protected static final String errSeqResult = "-999999999,null"; protected static Map latestErrors = new ConcurrentHashMap(); private final FetchMySQLSequnceHandler mysqlSeqFetcher = new FetchMySQLSequnceHandler(); - - private static class IncrSequenceMySQLHandlerHolder { - private static final IncrSequenceMySQLHandler instance = new IncrSequenceMySQLHandler(); - } + private static final IncrSequenceMySQLHandler instance = new IncrSequenceMySQLHandler(); public static IncrSequenceMySQLHandler getInstance() { - return IncrSequenceMySQLHandlerHolder.instance; + return IncrSequenceMySQLHandler.instance; } public void load(boolean isLowerCaseTableNames) { @@ -134,202 +129,6 @@ public class IncrSequenceMySQLHandler implements SequenceHandler { } } -class FetchMySQLSequnceHandler implements ResponseHandler { - private static final Logger LOGGER = LoggerFactory - .getLogger(FetchMySQLSequnceHandler.class); - public void execute(SequenceVal seqVal) { - MycatConfig conf = MycatServer.getInstance().getConfig(); - PhysicalDBNode mysqlDN = conf.getDataNodes().get(seqVal.dataNode); - try { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("execute in datanode " + seqVal.dataNode - + " for fetch sequnce sql " + seqVal.sql); - } - // 修正获取seq的逻辑,在读写分离的情况下只能走写节点。修改Select模式为Update模式。 - mysqlDN.getConnection(mysqlDN.getDatabase(), true, - new RouteResultsetNode(seqVal.dataNode, ServerParse.UPDATE, - seqVal.sql), this, seqVal); - } catch (Exception e) { - LOGGER.warn("get connection err " + e); - } - } - public String getLastestError(String seqName) { - return IncrSequenceMySQLHandler.latestErrors.get(seqName); - } - - @Override - public void connectionAcquired(BackendConnection conn) { - - conn.setResponseHandler(this); - try { - conn.query(((SequenceVal) conn.getAttachment()).sql); - } catch (Exception e) { - executeException(conn, e); - } - } - - @Override - public void connectionError(Throwable e, BackendConnection conn) { - ((SequenceVal) conn.getAttachment()).dbfinished = true; - LOGGER.warn("connectionError " + e); - - } - - @Override - public void errorResponse(byte[] data, BackendConnection conn) { - SequenceVal seqVal = ((SequenceVal) conn.getAttachment()); - seqVal.dbfinished = true; - - ErrorPacket err = new ErrorPacket(); - err.read(data); - String errMsg = new String(err.message); - LOGGER.warn("errorResponse " + err.errno + " " + errMsg); - IncrSequenceMySQLHandler.latestErrors.put(seqVal.seqName, errMsg); - conn.release(); - - } - - @Override - public void okResponse(byte[] ok, BackendConnection conn) { - boolean executeResponse = conn.syncAndExcute(); - if (executeResponse) { - ((SequenceVal) conn.getAttachment()).dbfinished = true; - conn.release(); - } - - } - - @Override - public boolean rowResponse(byte[] row, RowDataPacket rowPacket, boolean isLeft, BackendConnection conn) { - RowDataPacket rowDataPkg = new RowDataPacket(1); - rowDataPkg.read(row); - byte[] columnData = rowDataPkg.fieldValues.get(0); - String columnVal = new String(columnData); - SequenceVal seqVal = (SequenceVal) conn.getAttachment(); - if (IncrSequenceMySQLHandler.errSeqResult.equals(columnVal)) { - seqVal.dbretVal = IncrSequenceMySQLHandler.errSeqResult; - LOGGER.warn(" sequnce sql returned err value ,sequence:" - + seqVal.seqName + " " + columnVal + " sql:" + seqVal.sql); - } else { - seqVal.dbretVal = columnVal; - } - return false; - } - - @Override - public void rowEofResponse(byte[] eof, boolean isLeft, BackendConnection conn) { - ((SequenceVal) conn.getAttachment()).dbfinished = true; - conn.release(); - } - - @Override - public void relayPacketResponse(byte[] relayPacket, BackendConnection conn) { - - } - - @Override - public void endPacketResponse(byte[] endPacket, BackendConnection conn) { - - } - - private void executeException(BackendConnection c, Throwable e) { - SequenceVal seqVal = ((SequenceVal) c.getAttachment()); - seqVal.dbfinished = true; - String errMgs=e.toString(); - IncrSequenceMySQLHandler.latestErrors.put(seqVal.seqName, errMgs); - LOGGER.warn("executeException " + errMgs); - c.close("exception:" +errMgs); - - } - - @Override - public void writeQueueAvailable() { - - } - - @Override - public void connectionClose(BackendConnection conn, String reason) { - - LOGGER.warn("connection closed " + conn + " reason:" + reason); - } - - @Override - public void fieldEofResponse(byte[] header, List fields, List fieldPackets, byte[] eof, - boolean isLeft, BackendConnection conn) { - - } - -} - -class SequenceVal { - public AtomicBoolean newValueSetted = new AtomicBoolean(false); - public AtomicLong curVal = new AtomicLong(0); - public volatile String dbretVal = null; - public volatile boolean dbfinished; - public AtomicBoolean fetching = new AtomicBoolean(false); - public volatile long maxSegValue; - public volatile boolean successFetched; - public volatile String dataNode; - public final String seqName; - public final String sql; - - public SequenceVal(String seqName, String dataNode) { - this.seqName = seqName; - this.dataNode = dataNode; - sql = "SELECT mycat_seq_nextval('" + seqName + "')"; - } - - public boolean isNexValValid(Long nexVal) { - if (nexVal < this.maxSegValue) { - return true; - } else { - return false; - } - } - -// FetchMySQLSequnceHandler seqHandler; - - public void setCurValue(long newValue) { - curVal.set(newValue); - successFetched = true; - } - - public Long[] waitFinish() { - long start = System.currentTimeMillis(); - long end = start + 10 * 1000; - while (System.currentTimeMillis() < end) { - if (dbretVal == IncrSequenceMySQLHandler.errSeqResult) { - throw new java.lang.RuntimeException( - "sequnce not found in db table "); - } else if (dbretVal != null) { - String[] items = dbretVal.split(","); - Long curVal = Long.parseLong(items[0]); - int span = Integer.parseInt(items[1]); - return new Long[] { curVal, curVal + span }; - } else { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - IncrSequenceMySQLHandler.LOGGER - .warn("wait db fetch sequnce err " + e); - } - } - } - return null; - } - - public boolean isSuccessFetched() { - return successFetched; - } - - public long nextValue() { - if (successFetched == false) { - throw new java.lang.RuntimeException( - "sequnce fetched failed from db "); - } - return curVal.incrementAndGet(); - } -} diff --git a/src/main/java/io/mycat/route/sequence/handler/SequenceVal.java b/src/main/java/io/mycat/route/sequence/handler/SequenceVal.java new file mode 100644 index 000000000..9996250b5 --- /dev/null +++ b/src/main/java/io/mycat/route/sequence/handler/SequenceVal.java @@ -0,0 +1,78 @@ +package io.mycat.route.sequence.handler; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; + +/** + * Created by huqing.yan on 2017/7/3. + */ +public class SequenceVal { + + public AtomicBoolean newValueSetted = new AtomicBoolean(false); + public AtomicLong curVal = new AtomicLong(0); + public volatile String dbretVal = null; + public volatile boolean dbfinished; + public AtomicBoolean fetching = new AtomicBoolean(false); + public volatile long maxSegValue; + public volatile boolean successFetched; + public volatile String dataNode; + public final String seqName; + public final String sql; + + public SequenceVal(String seqName, String dataNode) { + this.seqName = seqName; + this.dataNode = dataNode; + sql = "SELECT mycat_seq_nextval('" + seqName + "')"; + } + + public boolean isNexValValid(Long nexVal) { + if (nexVal < this.maxSegValue) { + return true; + } else { + return false; + } + } + +// FetchMySQLSequnceHandler seqHandler; + + public void setCurValue(long newValue) { + curVal.set(newValue); + successFetched = true; + } + + public Long[] waitFinish() { + long start = System.currentTimeMillis(); + long end = start + 10 * 1000; + while (System.currentTimeMillis() < end) { + if (dbretVal == IncrSequenceMySQLHandler.errSeqResult) { + throw new java.lang.RuntimeException( + "sequnce not found in db table "); + } else if (dbretVal != null) { + String[] items = dbretVal.split(","); + Long curVal = Long.parseLong(items[0]); + int span = Integer.parseInt(items[1]); + return new Long[] { curVal, curVal + span }; + } else { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + IncrSequenceMySQLHandler.LOGGER + .warn("wait db fetch sequnce err " + e); + } + } + } + return null; + } + + public boolean isSuccessFetched() { + return successFetched; + } + + public long nextValue() { + if (successFetched == false) { + throw new java.lang.RuntimeException( + "sequnce fetched failed from db "); + } + return curVal.incrementAndGet(); + } +} diff --git a/src/main/java/io/mycat/route/util/PropertiesUtil.java b/src/main/java/io/mycat/route/util/PropertiesUtil.java index 0f2b12413..ae3da6a42 100644 --- a/src/main/java/io/mycat/route/util/PropertiesUtil.java +++ b/src/main/java/io/mycat/route/util/PropertiesUtil.java @@ -1,5 +1,7 @@ package io.mycat.route.util; +import io.mycat.util.ResourceUtil; + import java.io.IOException; import java.io.InputStream; import java.util.Enumeration; @@ -15,7 +17,7 @@ import java.util.Properties; public class PropertiesUtil { public static Properties loadProps(String propsFile){ Properties props = new Properties(); - InputStream inp = Thread.currentThread().getContextClassLoader().getResourceAsStream(propsFile); + InputStream inp = ResourceUtil.getResourceAsStreamForCurrentThread(propsFile); if (inp == null) { throw new java.lang.RuntimeException("time sequnce properties not found " + propsFile); diff --git a/src/main/java/io/mycat/route/util/RouterUtil.java b/src/main/java/io/mycat/route/util/RouterUtil.java index ac57a869c..b1e456f07 100644 --- a/src/main/java/io/mycat/route/util/RouterUtil.java +++ b/src/main/java/io/mycat/route/util/RouterUtil.java @@ -654,12 +654,7 @@ public class RouterUtil { //为单库表找路由,全局表不改变结果集,全局表*任意表 无交集的已经退化为普通表join了 for (String tableName : tables) { TableConfig tableConfig = schema.getTables().get(tableName); - if (tableConfig == null) { - String msg = "Table '" + schema.getName() + "." + tableName + "' doesn't exist"; - throw new SQLException(msg, "42S02", ErrorCode.ER_NO_SUCH_TABLE); - } - - if (!tableConfig.isGlobalTable() && tablesRouteMap.get(tableName) == null) { // 余下的表都是单库表 + if (tableConfig != null && !tableConfig.isGlobalTable() && tablesRouteMap.get(tableName) == null) { // 余下的表都是单库表 tablesRouteMap.put(tableName, new HashSet()); tablesRouteMap.get(tableName).addAll(tableConfig.getDataNodes()); } diff --git a/src/main/java/io/mycat/server/ServerConnection.java b/src/main/java/io/mycat/server/ServerConnection.java index 6138b2f00..84707e111 100644 --- a/src/main/java/io/mycat/server/ServerConnection.java +++ b/src/main/java/io/mycat/server/ServerConnection.java @@ -193,7 +193,7 @@ public class ServerConnection extends FrontendConnection { if (db != null){ schemaConfig = MycatServer.getInstance().getConfig().getSchemas().get(db); if (schemaConfig == null) { - writeErrMessage(ErrorCode.ERR_BAD_LOGICDB, "Unknown MyCAT Database '" + db + "'"); + writeErrMessage(ErrorCode.ERR_BAD_LOGICDB, "Unknown Database '" + db + "'"); return; } } @@ -205,12 +205,12 @@ public class ServerConnection extends FrontendConnection { // 检查当前使用的DB String db = this.schema; if (db == null) { - writeErrMessage(ErrorCode.ERR_BAD_LOGICDB,"No MyCAT Database selected"); + writeErrMessage(ErrorCode.ERR_BAD_LOGICDB,"No Database selected"); return null; } SchemaConfig schema = MycatServer.getInstance().getConfig().getSchemas().get(db); if (schema == null) { - writeErrMessage(ErrorCode.ERR_BAD_LOGICDB,"Unknown MyCAT Database '" + db + "'"); + writeErrMessage(ErrorCode.ERR_BAD_LOGICDB,"Unknown Database '" + db + "'"); return null; } diff --git a/src/main/java/io/mycat/server/handler/ShowHandler.java b/src/main/java/io/mycat/server/handler/ShowHandler.java index 4ae64f805..d10933e9a 100644 --- a/src/main/java/io/mycat/server/handler/ShowHandler.java +++ b/src/main/java/io/mycat/server/handler/ShowHandler.java @@ -27,8 +27,6 @@ import io.mycat.server.ServerConnection; import io.mycat.server.parser.ServerParse; import io.mycat.server.parser.ServerParseShow; import io.mycat.server.response.ShowDatabases; -import io.mycat.server.response.ShowMyCATCluster; -import io.mycat.server.response.ShowMyCatStatus; import io.mycat.server.response.ShowTables; import io.mycat.util.StringUtil; @@ -53,12 +51,6 @@ public final class ShowHandler { case ServerParseShow.FULLTABLES: ShowTables.response(c, stmt, true); break; - case ServerParseShow.MYCAT_STATUS: - ShowMyCatStatus.response(c); - break; - case ServerParseShow.MYCAT_CLUSTER: - ShowMyCATCluster.response(c); - break; case ServerParseShow.CHARSET: stmt = stmt.toLowerCase().replaceFirst("charset","character set"); default: diff --git a/src/main/java/io/mycat/server/parser/ServerParse.java b/src/main/java/io/mycat/server/parser/ServerParse.java index 394e1a237..6475037df 100644 --- a/src/main/java/io/mycat/server/parser/ServerParse.java +++ b/src/main/java/io/mycat/server/parser/ServerParse.java @@ -26,6 +26,7 @@ package io.mycat.server.parser; import java.util.regex.Matcher; import java.util.regex.Pattern; +import io.mycat.config.Versions; import io.mycat.route.parser.util.ParseUtil; /** @@ -696,7 +697,7 @@ public final class ServerParse { // /*!mycat: sql=SELECT * FROM test where id=99 */set @pin=1; // call p_test(@pin,@pout); // select @pout; - if(stmt.startsWith("/*!mycat:")||stmt.startsWith("/*#mycat:")||stmt.startsWith("/*mycat:")) + if(stmt.startsWith("/*!"+ Versions.ANNOTATION_NAME)||stmt.startsWith("/*#"+ Versions.ANNOTATION_NAME)||stmt.startsWith("/*"+ Versions.ANNOTATION_NAME)) { Matcher matcher = callPattern.matcher(stmt); if (matcher.find()) { diff --git a/src/main/java/io/mycat/server/parser/ServerParseShow.java b/src/main/java/io/mycat/server/parser/ServerParseShow.java index 3ce6e1466..4b58df882 100644 --- a/src/main/java/io/mycat/server/parser/ServerParseShow.java +++ b/src/main/java/io/mycat/server/parser/ServerParseShow.java @@ -37,8 +37,6 @@ public final class ServerParseShow { public static final int OTHER = -1; public static final int DATABASES = 1; public static final int DATASOURCES = 2; - public static final int MYCAT_STATUS = 3; - public static final int MYCAT_CLUSTER = 4; public static final int TABLES = 5; public static final int FULLTABLES =6; public static final int CHARSET = 7; @@ -59,9 +57,6 @@ public final class ServerParseShow { case '#': i = ParseUtil.comment(stmt, i); continue; - case 'M': - case 'm': - return mycatCheck(stmt, i); case 'D': case 'd': return dataCheck(stmt, i); @@ -81,75 +76,7 @@ public final class ServerParseShow { return OTHER; } - // SHOW MYCAT_ - static int mycatCheck(String stmt, int offset) { - if (stmt.length() > offset + "ycat_?".length()) { - char c1 = stmt.charAt(++offset); - char c2 = stmt.charAt(++offset); - char c3 = stmt.charAt(++offset); - char c4 = stmt.charAt(++offset); - char c5 = stmt.charAt(++offset); - if ((c1 == 'Y' || c1 == 'y') && (c2 == 'C' || c2 == 'c') - && (c3 == 'A' || c3 == 'a') && (c4 == 'T' || c4 == 't') - && (c5 == '_')) { - switch (stmt.charAt(++offset)) { - case 'S': - case 's': - return showMyCatStatus(stmt, offset); - case 'C': - case 'c': - return showMyCatCluster(stmt, offset); - default: - return OTHER; - } - } - } - return OTHER; - } - // SHOW MyCat_STATUS - static int showMyCatStatus(String stmt, int offset) { - if (stmt.length() > offset + "tatus".length()) { - char c1 = stmt.charAt(++offset); - char c2 = stmt.charAt(++offset); - char c3 = stmt.charAt(++offset); - char c4 = stmt.charAt(++offset); - char c5 = stmt.charAt(++offset); - if ((c1 == 't' || c1 == 'T') - && (c2 == 'a' || c2 == 'A') - && (c3 == 't' || c3 == 'T') - && (c4 == 'u' || c4 == 'U') - && (c5 == 's' || c5 == 'S') - && (stmt.length() == ++offset || ParseUtil.isEOF(stmt - .charAt(offset)))) { - return MYCAT_STATUS; - } - } - return OTHER; - } - - // SHOW MyCat_CLUSTER - static int showMyCatCluster(String stmt, int offset) { - if (stmt.length() > offset + "luster".length()) { - char c1 = stmt.charAt(++offset); - char c2 = stmt.charAt(++offset); - char c3 = stmt.charAt(++offset); - char c4 = stmt.charAt(++offset); - char c5 = stmt.charAt(++offset); - char c6 = stmt.charAt(++offset); - if ((c1 == 'L' || c1 == 'l') - && (c2 == 'U' || c2 == 'u') - && (c3 == 'S' || c3 == 's') - && (c4 == 'T' || c4 == 't') - && (c5 == 'E' || c5 == 'e') - && (c6 == 'R' || c6 == 'r') - && (stmt.length() == ++offset || ParseUtil.isEOF(stmt - .charAt(offset)))) { - return MYCAT_CLUSTER; - } - } - return OTHER; - } // SHOW DATA static int dataCheck(String stmt, int offset) { diff --git a/src/main/java/io/mycat/server/response/ShowMyCATCluster.java b/src/main/java/io/mycat/server/response/ShowMyCATCluster.java deleted file mode 100644 index 9d53b24aa..000000000 --- a/src/main/java/io/mycat/server/response/ShowMyCATCluster.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2013, OpenCloudDB/MyCAT and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software;Designed and Developed mainly by many Chinese - * opensource volunteers. you can redistribute it and/or modify it under the - * terms of the GNU General Public License version 2 only, as published by the - * Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Any questions about this component can be directed to it's project Web address - * https://code.google.com/p/opencloudb/. - * - */ -package io.mycat.server.response; - -import java.nio.ByteBuffer; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import io.mycat.MycatServer; -import io.mycat.backend.mysql.PacketUtil; -import io.mycat.config.Alarms; -import io.mycat.config.Fields; -import io.mycat.config.MycatCluster; -import io.mycat.config.MycatConfig; -import io.mycat.config.MycatNode; -import io.mycat.config.model.MycatNodeConfig; -import io.mycat.config.model.SchemaConfig; -import io.mycat.net.mysql.EOFPacket; -import io.mycat.net.mysql.FieldPacket; -import io.mycat.net.mysql.ResultSetHeaderPacket; -import io.mycat.net.mysql.RowDataPacket; -import io.mycat.server.ServerConnection; -import io.mycat.util.IntegerUtil; -import io.mycat.util.StringUtil; - -/** - * @author mycat - */ -public class ShowMyCATCluster { - - private static final Logger alarm = LoggerFactory.getLogger("alarm"); - - private static final int FIELD_COUNT = 2; - private static final ResultSetHeaderPacket header = PacketUtil.getHeader(FIELD_COUNT); - private static final FieldPacket[] fields = new FieldPacket[FIELD_COUNT]; - private static final EOFPacket eof = new EOFPacket(); - static { - int i = 0; - byte packetId = 0; - header.packetId = ++packetId; - fields[i] = PacketUtil.getField("HOST", Fields.FIELD_TYPE_VAR_STRING); - fields[i++].packetId = ++packetId; - fields[i] = PacketUtil.getField("WEIGHT", Fields.FIELD_TYPE_LONG); - fields[i++].packetId = ++packetId; - eof.packetId = ++packetId; - } - - public static void response(ServerConnection c) { - ByteBuffer buffer = c.allocate(); - - // write header - buffer = header.write(buffer, c,true); - - // write field - for (FieldPacket field : fields) { - buffer = field.write(buffer, c,true); - } - - // write eof - buffer = eof.write(buffer, c,true); - - // write rows - byte packetId = eof.packetId; - for (RowDataPacket row : getRows(c)) { - row.packetId = ++packetId; - buffer = row.write(buffer, c,true); - } - - // last eof - EOFPacket lastEof = new EOFPacket(); - lastEof.packetId = ++packetId; - buffer = lastEof.write(buffer, c,true); - - // post write - c.write(buffer); - } - - private static List getRows(ServerConnection c) { - List rows = new LinkedList(); - MycatConfig config = MycatServer.getInstance().getConfig(); - MycatCluster cluster = config.getCluster(); - Map schemas = config.getSchemas(); - SchemaConfig schema = (c.getSchema() == null) ? null : schemas.get(c.getSchema()); - - // 如果没有指定schema或者schema为null,则使用全部集群。 - if (schema == null) { - Map nodes = cluster.getNodes(); - for (MycatNode n : nodes.values()) { - if (n != null && n.isOnline()) { - rows.add(getRow(n, c.getCharset())); - } - } - } else { - - Map nodes = cluster.getNodes(); - for (MycatNode n : nodes.values()) { - if (n != null && n.isOnline()) { - rows.add(getRow(n, c.getCharset())); - } - } - } - - if (rows.size() == 0) { - alarm.error(Alarms.CLUSTER_EMPTY + c.toString()); - } - - return rows; - } - - private static RowDataPacket getRow(MycatNode node, String charset) { - MycatNodeConfig conf = node.getConfig(); - RowDataPacket row = new RowDataPacket(FIELD_COUNT); - row.add(StringUtil.encode(conf.getHost(), charset)); - row.add(IntegerUtil.toBytes(conf.getWeight())); - return row; - } - -} \ No newline at end of file diff --git a/src/main/java/io/mycat/server/response/ShowMyCatStatus.java b/src/main/java/io/mycat/server/response/ShowMyCatStatus.java deleted file mode 100644 index 6388dd573..000000000 --- a/src/main/java/io/mycat/server/response/ShowMyCatStatus.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2013, OpenCloudDB/MyCAT and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software;Designed and Developed mainly by many Chinese - * opensource volunteers. you can redistribute it and/or modify it under the - * terms of the GNU General Public License version 2 only, as published by the - * Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Any questions about this component can be directed to it's project Web address - * https://code.google.com/p/opencloudb/. - * - */ -package io.mycat.server.response; - -import java.nio.ByteBuffer; - -import io.mycat.MycatServer; -import io.mycat.backend.mysql.PacketUtil; -import io.mycat.config.Fields; -import io.mycat.net.mysql.EOFPacket; -import io.mycat.net.mysql.ErrorPacket; -import io.mycat.net.mysql.FieldPacket; -import io.mycat.net.mysql.ResultSetHeaderPacket; -import io.mycat.net.mysql.RowDataPacket; -import io.mycat.server.ServerConnection; - -/** - * 加入了offline状态推送,用于心跳语句。 - * - * @author mycat - * @author mycat - */ -public class ShowMyCatStatus { - - private static final int FIELD_COUNT = 1; - private static final ResultSetHeaderPacket header = PacketUtil.getHeader(FIELD_COUNT); - private static final FieldPacket[] fields = new FieldPacket[FIELD_COUNT]; - private static final EOFPacket eof = new EOFPacket(); - private static final RowDataPacket status = new RowDataPacket(FIELD_COUNT); - private static final EOFPacket lastEof = new EOFPacket(); - private static final ErrorPacket error = PacketUtil.getShutdown(); - static { - int i = 0; - byte packetId = 0; - header.packetId = ++packetId; - fields[i] = PacketUtil.getField("STATUS", Fields.FIELD_TYPE_VAR_STRING); - fields[i++].packetId = ++packetId; - eof.packetId = ++packetId; - status.add("ON".getBytes()); - status.packetId = ++packetId; - lastEof.packetId = ++packetId; - } - - public static void response(ServerConnection c) { - if (MycatServer.getInstance().isOnline()) { - ByteBuffer buffer = c.allocate(); - buffer = header.write(buffer, c,true); - for (FieldPacket field : fields) { - buffer = field.write(buffer, c,true); - } - buffer = eof.write(buffer, c,true); - buffer = status.write(buffer, c,true); - buffer = lastEof.write(buffer, c,true); - c.write(buffer); - } else { - error.write(c); - } - } - -} \ No newline at end of file diff --git a/src/main/java/io/mycat/server/response/ShowTables.java b/src/main/java/io/mycat/server/response/ShowTables.java index 1a0f8193f..d5e9938c0 100644 --- a/src/main/java/io/mycat/server/response/ShowTables.java +++ b/src/main/java/io/mycat/server/response/ShowTables.java @@ -80,8 +80,6 @@ public class ShowTables { byte packetId = writeTablesHeader(buffer, c, tableMap, cSchema); writeRowEof(buffer, c, packetId); } - - c.recycle(buffer); } public static byte writeFullTablesHeader(ByteBuffer buffer, ServerConnection c, Map tableMap, String cSchema) { diff --git a/src/main/java/io/mycat/server/util/GlobalTableUtil.java b/src/main/java/io/mycat/server/util/GlobalTableUtil.java index 8c47ef160..5e2518681 100644 --- a/src/main/java/io/mycat/server/util/GlobalTableUtil.java +++ b/src/main/java/io/mycat/server/util/GlobalTableUtil.java @@ -29,7 +29,7 @@ import io.mycat.config.MycatConfig; import io.mycat.config.model.SchemaConfig; import io.mycat.config.model.SystemConfig; import io.mycat.config.model.TableConfig; -import io.mycat.meta.protocol.MyCatMeta.TableMeta; +import io.mycat.meta.protocol.StructureMeta.TableMeta; import io.mycat.server.util.SchemaUtil.SchemaInfo; import io.mycat.sqlengine.SQLQueryResult; import io.mycat.util.StringUtil; @@ -42,7 +42,7 @@ public class GlobalTableUtil{ private static final Logger LOGGER = LoggerFactory.getLogger(GlobalTableUtil.class); private static Map globalTableMap = new ConcurrentHashMap<>(); /** 全局表 保存修改时间戳 的字段名,用于全局表一致性检查 */ - public static final String GLOBAL_TABLE_MYCAT_COLUMN = "_mycat_op_time"; + public static final String GLOBAL_TABLE_CHECK_COLUMN = "_mycat_op_time"; public static final String COUNT_COLUMN = "record_count"; public static final String MAX_COLUMN = "max_timestamp"; public static final String INNER_COLUMN = "inner_col_exist"; @@ -58,10 +58,10 @@ public class GlobalTableUtil{ getGlobalTable(); // 初始化 globalTableMap } - public static SQLColumnDefinition createMycatColumn(){ + public static SQLColumnDefinition createCheckColumn(){ SQLColumnDefinition column = new SQLColumnDefinition(); column.setDataType(new SQLCharacterDataType("bigint")); - column.setName(new SQLIdentifierExpr(GLOBAL_TABLE_MYCAT_COLUMN)); + column.setName(new SQLIdentifierExpr(GLOBAL_TABLE_CHECK_COLUMN)); column.setComment(new SQLCharExpr("全局表保存修改时间戳的字段名")); return column; } @@ -69,11 +69,11 @@ public class GlobalTableUtil{ public static boolean isInnerColExist(SchemaInfo schemaInfo ,TableMeta orgTbMeta) { for (int i = 0; i < orgTbMeta.getColumnsList().size(); i++) { String column = orgTbMeta.getColumnsList().get(i).getName(); - if (column.equalsIgnoreCase(GLOBAL_TABLE_MYCAT_COLUMN)) + if (column.equalsIgnoreCase(GLOBAL_TABLE_CHECK_COLUMN)) return true; } StringBuilder warnStr = new StringBuilder(schemaInfo.schema).append(".").append(schemaInfo.table) - .append(" inner column: ").append(GLOBAL_TABLE_MYCAT_COLUMN).append(" is not exist."); + .append(" inner column: ").append(GLOBAL_TABLE_CHECK_COLUMN).append(" is not exist."); LOGGER.warn(warnStr.toString()); return false; // tableName 全局表没有内部列 } @@ -207,10 +207,10 @@ public class GlobalTableUtil{ LOGGER.warn(row.get(GlobalTableUtil.INNER_COLUMN) + ", " + e.getMessage()); }finally{ if(columnsList == null - || columnsList.indexOf(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN) == -1){ + || columnsList.indexOf(GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN) == -1){ LOGGER.warn(map.getDataNode() + "." + map.getTableName() + " inner column: " - + GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN + + GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN + " is not exist."); }else{ LOGGER.debug("columnsList: " + columnsList); diff --git a/src/main/java/io/mycat/sqlengine/mpp/DataNodeMergeManager.java b/src/main/java/io/mycat/sqlengine/mpp/DataNodeMergeManager.java index 195a4e560..bb4b35dcb 100644 --- a/src/main/java/io/mycat/sqlengine/mpp/DataNodeMergeManager.java +++ b/src/main/java/io/mycat/sqlengine/mpp/DataNodeMergeManager.java @@ -66,16 +66,16 @@ public class DataNodeMergeManager extends AbstractDataNodeMerge { /** * sorter需要的上下文环境 */ - private final MyCatMemory myCatMemory; + private final MyCatMemory serverMemory; private final MemoryManager memoryManager; private final MycatPropertyConf conf; public DataNodeMergeManager(MultiNodeQueryHandler handler, RouteResultset rrs) { super(handler,rrs); - this.myCatMemory = MycatServer.getInstance().getMyCatMemory(); - this.memoryManager = myCatMemory.getResultMergeMemoryManager(); - this.conf = myCatMemory.getConf(); + this.serverMemory = MycatServer.getInstance().getServerMemory(); + this.memoryManager = serverMemory.getResultMergeMemoryManager(); + this.conf = serverMemory.getConf(); } @@ -191,16 +191,16 @@ public class DataNodeMergeManager extends AbstractDataNodeMerge { */ globalSorter = new UnsafeExternalRowSorter( dataNodeMemoryManager, - myCatMemory, + serverMemory, schema, prefixComparator, prefixComputer, - conf.getSizeAsBytes("mycat.buffer.pageSize","1m"), + conf.getSizeAsBytes("server.buffer.pageSize","1m"), false/**是否使用基数排序*/, true/**排序*/); } - if(conf.getBoolean("mycat.stream.output.result",false) + if(conf.getBoolean("server.stream.output.result",false) && globalSorter == null && unsafeRowGrouper == null){ setStreamOutputResult(true); @@ -230,11 +230,11 @@ public class DataNodeMergeManager extends AbstractDataNodeMerge { globalMergeResult = new UnsafeExternalRowSorter( dataNodeMemoryManager, - myCatMemory, + serverMemory, schema, prefixComparator, prefixComputer, - conf.getSizeAsBytes("mycat.buffer.pageSize", "1m"), + conf.getSizeAsBytes("server.buffer.pageSize", "1m"), false,/**是否使用基数排序*/ false/**不排序*/); } diff --git a/src/main/java/io/mycat/sqlengine/mpp/UnsafeRowGrouper.java b/src/main/java/io/mycat/sqlengine/mpp/UnsafeRowGrouper.java index 86eb49125..d89c324da 100644 --- a/src/main/java/io/mycat/sqlengine/mpp/UnsafeRowGrouper.java +++ b/src/main/java/io/mycat/sqlengine/mpp/UnsafeRowGrouper.java @@ -83,7 +83,7 @@ public class UnsafeRowGrouper { private StructType groupKeySchema ; private StructType aggBufferSchema; private UnsafeRow emptyAggregationBuffer; - private final MyCatMemory myCatMemory; + private final MyCatMemory serverMemory; private final MemoryManager memoryManager; private final MycatPropertyConf conf; @@ -99,9 +99,9 @@ public class UnsafeRowGrouper { this.sortColumnsByIndex = columns !=null ? toSortColumnsByIndex(columns,columToIndx):null; this.groupKeyfieldCount = columns != null?columns.length:0; this.valuefieldCount = columToIndx != null?columToIndx.size():0; - this.myCatMemory = MycatServer.getInstance().getMyCatMemory(); - this.memoryManager = myCatMemory.getResultMergeMemoryManager(); - this.conf = myCatMemory.getConf(); + this.serverMemory = MycatServer.getInstance().getServerMemory(); + this.memoryManager = serverMemory.getResultMergeMemoryManager(); + this.conf = serverMemory.getConf(); logger.debug("columToIndx :" + (columToIndx != null ? columToIndx.toString():"null")); @@ -117,7 +117,7 @@ public class UnsafeRowGrouper { groupKeySchema, dataNodeMemoryManager, 2*1024, - conf.getSizeAsBytes("mycat.buffer.pageSize", "1m"), + conf.getSizeAsBytes("server.buffer.pageSize", "1m"), false); } diff --git a/src/main/java/io/mycat/util/CompareLike.java b/src/main/java/io/mycat/util/CompareLike.java index 2a4d7b80a..6bc744dbb 100644 --- a/src/main/java/io/mycat/util/CompareLike.java +++ b/src/main/java/io/mycat/util/CompareLike.java @@ -101,12 +101,11 @@ public class CompareLike { } public boolean compare(String s) { - switch (type) { - case IS_NULL: + if (type == CompareType.IS_NULL) { return s != null; - case FULL_MATCH: + } else if (type == CompareType.FULL_MATCH) { return StringUtil.equalsIgnoreCase(patternString, s); - default: + } else { return compareAt(s, 0, 0, s.length(), patternChars, patternTypes); } } diff --git a/src/main/java/io/mycat/util/DecryptUtil.java b/src/main/java/io/mycat/util/DecryptUtil.java index 48fcb54fc..15eaa91bd 100644 --- a/src/main/java/io/mycat/util/DecryptUtil.java +++ b/src/main/java/io/mycat/util/DecryptUtil.java @@ -57,7 +57,7 @@ public class DecryptUtil { System.out.println(encrypt(password)); } - public static String mycatDecrypt(String usingDecrypt,String user ,String passwrod){ + public static String decrypt(String usingDecrypt, String user , String passwrod){ if("1".equals(usingDecrypt)){ //type:user:password //0:test:test diff --git a/src/main/java/io/mycat/util/ResourceUtil.java b/src/main/java/io/mycat/util/ResourceUtil.java new file mode 100644 index 000000000..1361883fe --- /dev/null +++ b/src/main/java/io/mycat/util/ResourceUtil.java @@ -0,0 +1,21 @@ +package io.mycat.util; + +import java.io.InputStream; + +/** + * Created by huqing.yan on 2017/7/5. + */ +public class ResourceUtil { + public static InputStream getResourceAsStream(String name){ + return ResourceUtil.class.getResourceAsStream(name); + } + public static InputStream getResourceAsStreamForCurrentThread(String name){ + return Thread.currentThread().getContextClassLoader().getResourceAsStream(name); + } + public static String getResourcePathFromRoot(String path){ + return ResourceUtil.class.getClassLoader().getResource(path).getPath(); + } + public static InputStream getResourceAsStreamFromRoot(String path){ + return ResourceUtil.class.getClassLoader().getResourceAsStream(path); + } +} diff --git a/src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java b/src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java index bb39e1123..363a486c7 100644 --- a/src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java +++ b/src/main/java/io/mycat/util/dataMigrator/ConfigComparer.java @@ -10,6 +10,7 @@ import java.util.Map.Entry; import java.util.Properties; import java.util.Set; +import io.mycat.util.ResourceUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -104,7 +105,7 @@ public class ConfigComparer { dnIndexProps = loadDnIndexProps(); } try{ - pro.load(ConfigComparer.class.getResourceAsStream(TABLES_FILE)); + pro.load(ResourceUtil.getResourceAsStream(TABLES_FILE)); }catch(Exception e){ throw new ConfigException("tablesFile.properties read fail!"); } @@ -242,7 +243,7 @@ public class ConfigComparer { Properties prop = new Properties(); InputStream is = null; try { - is = ConfigComparer.class.getResourceAsStream(DN_INDEX_FILE); + is = ResourceUtil.getResourceAsStream(DN_INDEX_FILE); prop.load(is); } catch (Exception e) { throw new ConfigException("please check file \"dnindex.properties\" "+e.getMessage()); diff --git a/src/main/java/io/mycat/util/exception/TmpFileException.java b/src/main/java/io/mycat/util/exception/TmpFileException.java index 319aea413..0393a3fe6 100644 --- a/src/main/java/io/mycat/util/exception/TmpFileException.java +++ b/src/main/java/io/mycat/util/exception/TmpFileException.java @@ -1,9 +1,7 @@ package io.mycat.util.exception; import java.io.IOException; -import java.io.InputStream; import java.text.MessageFormat; -import java.util.Locale; import java.util.Properties; @@ -11,17 +9,19 @@ public class TmpFileException extends RuntimeException { private static final long serialVersionUID = 1L; private static final Properties MESSAGES = new Properties(); static { - try { - InputStream in = TmpFileException.class.getResourceAsStream("/io/mycat/util/exception/res/_messages_en.prop"); - if (in != null) { - MESSAGES.load(in); - } - String language = Locale.getDefault().getLanguage(); - if (!"en".equals(language)) { - - } - } catch (IOException e) { - } + MESSAGES.put("5301","Could not open file {0}"); + MESSAGES.put("5302","Could not force file {0}"); + MESSAGES.put("5303","Could not sync file {0}"); + MESSAGES.put("5304","Reading from {0} failed"); + MESSAGES.put("5305","Writing to {0} failed"); + MESSAGES.put("5306","Error while renaming file {0} to {1}"); + MESSAGES.put("5307","Cannot delete file {0}"); + MESSAGES.put("5308","IO Exception: {0}"); + MESSAGES.put("5309","Reading from {0} failed,index out of bounds"); + MESSAGES.put("5310","Hex a decimal string with odd number of characters: {0}"); + MESSAGES.put("5311","Hex a decimal string contains non-hex character: {0}"); + MESSAGES.put("5312","Invalid value {0} for parameter {1}"); + MESSAGES.put("5313","Error while creating file {0}"); } private TmpFileException(String message) { @@ -43,11 +43,7 @@ public class TmpFileException extends RuntimeException { } private static String translate(String key, String... params) { - String message = null; - if (MESSAGES != null) { - // Tomcat sets final static fields to null sometimes - message = MESSAGES.getProperty(key); - } + String message = MESSAGES.getProperty(key); if (message == null) { message = "(Message " + key + " not found)"; } @@ -109,16 +105,4 @@ public class TmpFileException extends RuntimeException { return get(errorCode * 10, e.toString(), message); } - /** - * Gets a exception meaning this value is invalid. - * - * @param param - * the name of the parameter - * @param value - * the value passed - * @return the IllegalArgumentException object - */ - public static TmpFileException getInvalidValueException(int errorCode, String param, Object value) { - return get(errorCode, value == null ? "null" : value.toString(), param); - } } diff --git a/src/main/resources/index_to_charset.properties b/src/main/resources/index_to_charset.properties deleted file mode 100644 index b990ce466..000000000 --- a/src/main/resources/index_to_charset.properties +++ /dev/null @@ -1,219 +0,0 @@ -1=big5 -2=latin2 -3=dec8 -4=cp850 -5=latin1 -6=hp8 -7=koi8r -8=latin1 -9=latin2 -10=swe7 -11=ascii -12=ujis -13=sjis -14=cp1251 -15=latin1 -16=hebrew -18=tis620 -19=euckr -20=latin7 -21=latin2 -22=koi8u -23=cp1251 -24=gb2312 -25=greek -26=cp1250 -27=latin2 -28=gbk -29=cp1257 -30=latin5 -31=latin1 -32=armscii8 -33=utf8 -34=cp1250 -35=ucs2 -36=cp866 -37=keybcs2 -38=macce -39=macroman -40=cp852 -41=latin7 -42=latin7 -43=macce -44=cp1250 -45=utf8mb4 -46=utf8mb4 -47=latin1 -48=latin1 -49=latin1 -50=cp1251 -51=cp1251 -52=cp1251 -53=macroman -54=utf16 -55=utf16 -56=utf16le -57=cp1256 -58=cp1257 -59=cp1257 -60=utf32 -61=utf32 -62=utf16le -63=binary -64=armscii8 -65=ascii -66=cp1250 -67=cp1256 -68=cp866 -69=dec8 -70=greek -71=hebrew -72=hp8 -73=keybcs2 -74=koi8r -75=koi8u -77=latin2 -78=latin5 -79=latin7 -80=cp850 -81=cp852 -82=swe7 -83=utf8 -84=big5 -85=euckr -86=gb2312 -87=gbk -88=sjis -89=tis620 -90=ucs2 -91=ujis -92=geostd8 -93=geostd8 -94=latin1 -95=cp932 -96=cp932 -97=eucjpms -98=eucjpms -99=cp1250 -101=utf16 -102=utf16 -103=utf16 -104=utf16 -105=utf16 -106=utf16 -107=utf16 -108=utf16 -109=utf16 -110=utf16 -111=utf16 -112=utf16 -113=utf16 -114=utf16 -115=utf16 -116=utf16 -117=utf16 -118=utf16 -119=utf16 -120=utf16 -121=utf16 -122=utf16 -123=utf16 -124=utf16 -128=ucs2 -129=ucs2 -130=ucs2 -131=ucs2 -132=ucs2 -133=ucs2 -134=ucs2 -135=ucs2 -136=ucs2 -137=ucs2 -138=ucs2 -139=ucs2 -140=ucs2 -141=ucs2 -142=ucs2 -143=ucs2 -144=ucs2 -145=ucs2 -146=ucs2 -147=ucs2 -148=ucs2 -149=ucs2 -150=ucs2 -151=ucs2 -159=ucs2 -160=utf32 -161=utf32 -162=utf32 -163=utf32 -164=utf32 -165=utf32 -166=utf32 -167=utf32 -168=utf32 -169=utf32 -170=utf32 -171=utf32 -172=utf32 -173=utf32 -174=utf32 -175=utf32 -176=utf32 -177=utf32 -178=utf32 -179=utf32 -180=utf32 -181=utf32 -182=utf32 -183=utf32 -192=utf8 -193=utf8 -194=utf8 -195=utf8 -196=utf8 -197=utf8 -198=utf8 -199=utf8 -200=utf8 -201=utf8 -202=utf8 -203=utf8 -204=utf8 -205=utf8 -206=utf8 -207=utf8 -208=utf8 -209=utf8 -210=utf8 -211=utf8 -212=utf8 -213=utf8 -214=utf8 -215=utf8 -223=utf8 -224=utf8mb4 -225=utf8mb4 -226=utf8mb4 -227=utf8mb4 -228=utf8mb4 -229=utf8mb4 -230=utf8mb4 -231=utf8mb4 -232=utf8mb4 -233=utf8mb4 -234=utf8mb4 -235=utf8mb4 -236=utf8mb4 -237=utf8mb4 -238=utf8mb4 -239=utf8mb4 -240=utf8mb4 -241=utf8mb4 -242=utf8mb4 -243=utf8mb4 -244=utf8mb4 -245=utf8mb4 -246=utf8mb4 -247=utf8mb4 \ No newline at end of file diff --git a/src/main/resources/myid.properties b/src/main/resources/myid.properties index 5f654fb80..951b16844 100644 --- a/src/main/resources/myid.properties +++ b/src/main/resources/myid.properties @@ -1,8 +1,5 @@ loadZk=false zkURL=127.0.0.1:2181 clusterId=mycat-cluster-1 -myid=mycat_fz_01 -clusterNodes=mycat_fz_01,mycat_fz_02,mycat_fz_04 -#server booster ; booster install on db same server,will reset all minCon to 1 -type=server -boosterDataHosts=dn2,dn3 +myid=server_fz_01 +clusterNodes=server_fz_01,server_fz_02,server_fz_04 diff --git a/src/test/java/io/mycat/parser/ServerParserTest.java b/src/test/java/io/mycat/parser/ServerParserTest.java index 85e80939e..c414b66a6 100644 --- a/src/test/java/io/mycat/parser/ServerParserTest.java +++ b/src/test/java/io/mycat/parser/ServerParserTest.java @@ -154,26 +154,6 @@ public class ServerParserTest { Assert.assertEquals(ServerParseShow.DATASOURCES, ServerParseShow.parse(" SHOW DATASOURCES ", 6)); } - @Test - public void testShowMycatStatus() { - Assert.assertEquals(ServerParseShow.MYCAT_STATUS, ServerParseShow.parse("show mycat_status", 4)); - Assert.assertEquals(ServerParseShow.MYCAT_STATUS, ServerParseShow.parse("show mycat_status ", 4)); - Assert.assertEquals(ServerParseShow.MYCAT_STATUS, ServerParseShow.parse(" SHOW MYCAT_STATUS", " SHOW".length())); - Assert.assertEquals(ServerParseShow.OTHER, ServerParseShow.parse(" show mycat_statu", " SHOW".length())); - Assert.assertEquals(ServerParseShow.OTHER, ServerParseShow.parse(" show mycat_status2", " SHOW".length())); - Assert.assertEquals(ServerParseShow.OTHER, ServerParseShow.parse("Show mycat_status2 ", "SHOW".length())); - } - - @Test - public void testShowMycatCluster() { - Assert.assertEquals(ServerParseShow.MYCAT_CLUSTER, ServerParseShow.parse("show mycat_cluster", 4)); - Assert.assertEquals(ServerParseShow.MYCAT_CLUSTER, ServerParseShow.parse("Show mycat_CLUSTER ", 4)); - Assert.assertEquals(ServerParseShow.MYCAT_CLUSTER, ServerParseShow.parse(" show MYCAT_cluster", 5)); - Assert.assertEquals(ServerParseShow.OTHER, ServerParseShow.parse(" show mycat_clust", 5)); - Assert.assertEquals(ServerParseShow.OTHER, ServerParseShow.parse(" show mycat_cluster2", 5)); - Assert.assertEquals(ServerParseShow.OTHER, ServerParseShow.parse("Show mycat_cluster9 ", 4)); - } - @Test public void testIsShowOther() { Assert.assertEquals(ServerParseShow.OTHER, ServerParseShow.parse("show ...", 4)); diff --git a/ushard.xml b/ushard.xml index bba87bfb7..69bee5333 100644 --- a/ushard.xml +++ b/ushard.xml @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 - io.mycat + com.actionsky UShard 2.17.07.0-dev jar @@ -18,6 +18,7 @@ UTF-8 + true @@ -232,12 +233,9 @@ src/main/resources - - **/.svn/** - rule_template.xml - schema_template.xml - server_template.xml - + + *.dtd + @@ -299,30 +297,7 @@ - - maven-resources-plugin - 3.0.2 - - - copy-resources - - validate - - copy-resources - - - src/main/resources - - - ushard - true - - - - - - - + org.apache.maven.plugins maven-compiler-plugin @@ -349,6 +324,127 @@ + + org.apache.maven.plugins + maven-source-plugin + 2.1.2 + + ${app.encoding} + true + + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + **/.svn/** + + + + + + test-jar + + + + + + + org.apache.maven.plugins + maven-eclipse-plugin + + + **/.svn/** + + true + classes + + + .settings/org.eclipse.core.resources.prefs + + =${app.encoding}${line.separator}]]> + + + + + + + maven-resources-plugin + 3.0.2 + + + copy-resources + + validate + + copy-resources + + + src/main/resources + + + ushard + true + + + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + 1.3 + + + validate + + create-timestamp + + + + + yyyyMMddHHmmss + + + + + com.github.os72 + protoc-jar-maven-plugin + 3.3.0.1 + + + generate-sources + + run + + + 2.6.1 + + src/main/assembly/ushard + + + + java + none + src/main/java + + + + + + + com.google.code.maven-replacer-plugin replacer @@ -409,6 +505,23 @@ + + IncrSequenceMySQLHandler + process-sources + + replace + + + ${project.basedir}/src/main/java/io/mycat/route/sequence/handler/SequenceVal.java + ${project.basedir}/src/main/java/io/mycat/route/sequence/handler/SequenceVal.java + + + mycat_seq_nextval + ushard_seq_nextval + + + + init_zk_data process-sources @@ -423,6 +536,10 @@ MYCAT USHARD + + io.mycat.MycatStartup + com.actionsky.ushard.UshardStartup + @@ -460,40 +577,49 @@ - - log4j2.xml - process-sources - - replace - - - ${project.basedir}/src/main/resources/log4j2.xml - ${project.basedir}/src/main/resources/log4j2.xml - - - mycat - ushard - - - - - - 1log4j2.xml - process-sources - - replace - - - ${project.basedir}/src/main/assembly/conf/log4j2.xml - ${project.basedir}/src/main/assembly/conf/log4j2.xml - - - mycat - ushard - - - - + + dbseq.sql + process-sources + + replace + + + ${project.basedir}/src/main/resources/dbseq.sql + ${project.basedir}/src/main/resources/dbseq.sql + + + mycat + ushard + + + MYCAT + USHARD + + + + + + log4j2.xml + process-sources + + replace + + + ${project.basedir}/src/main/assembly/conf/log4j2.xml + ${project.basedir}/src/main/assembly/conf/log4j2.xml + + + mycat + ushard + + + MYCAT_HOME + USHARD_HOME + + + + + server.dtd process-sources @@ -511,23 +637,57 @@ - - ShowServerLog.java - process-sources - - replace - - - ${project.basedir}/src/main/java/io/mycat/manager/handler/ShowServerLog.java - ${project.basedir}/src/main/java/io/mycat/manager/handler/ShowServerLog.java - - - mycat.log - ushard.log - - - - + + MycatServer.java + process-sources + + replace + + + ${project.basedir}/src/main/java/io/mycat/MycatServer.java + ${project.basedir}/src/main/java/io/mycat/MycatServer.java + + + MyCat_ + Ushard_ + + + + + + GlobalTableUtil.java + process-sources + + replace + + + ${project.basedir}/src/main/java/io/mycat/server/util/GlobalTableUtil.java + ${project.basedir}/src/main/java/io/mycat/server/util/GlobalTableUtil.java + + + _mycat_op_time + _ushard_op_time + + + + + + ShowServerLog.java + process-sources + + replace + + + ${project.basedir}/src/main/java/io/mycat/manager/handler/ShowServerLog.java + ${project.basedir}/src/main/java/io/mycat/manager/handler/ShowServerLog.java + + + mycat.log + ushard.log + + + + version2 process-sources @@ -550,6 +710,10 @@ @annotation-name@ ushard: + + @root_prefix@ + ushard + @@ -560,59 +724,105 @@ org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - ${app.encoding} - true - + maven-shade-plugin + 3.0.0 - attach-sources + package - jar-no-fork + shade + + + + *:* + + com/actionsky/ushard/** + io/mycat/** + server.dtd + schema.dtd + rule.dtd + META-INF/MANIFEST.MF + + + io/mycat/meta/protocol/** + + + + + + io.mycat.Mycat + com.actionsky.ushard.Ushard + + + io.mycat.config.Mycat + com.actionsky.ushard.config.Ushard + + + io.mycat.config.model.Mycat + com.actionsky.ushard.config.model.Ushard + + + io.mycat.memory.MyCat + com.actionsky.ushard.memory.Ushard + + + io.mycat.memory.unsafe.utils.Mycat + com.actionsky.ushard.memory.unsafe.utils.Ushard + + + io.mycat.route.parser.druid.Mycat + com.actionsky.ushard.route.parser.druid.Ushard + + + io.mycat.route.impl.DruidMycatRouteStrategy + com.actionsky.ushard.route.impl.DruidUshardRouteStrategy + + + io.mycat + com.actionsky.ushard + + + - - org.apache.maven.plugins - maven-jar-plugin - - - **/.svn/** - - - - - - test-jar - - - - - - - org.apache.maven.plugins - maven-eclipse-plugin - - - **/.svn/** - - true - classes - - - .settings/org.eclipse.core.resources.prefs - - =${app.encoding}${line.separator}]]> - - - - - + + com.github.wvengen + proguard-maven-plugin + + + package + + proguard + + + + + ${need.obfuscate} + + + + + + + + + + + + + + + + ${project.build.finalName}.jar + ${project.build.finalName}.jar + + ${java.home}/lib/rt.jar + + + org.codehaus.mojo @@ -626,7 +836,7 @@ ushard - io.mycat.MycatStartup + com.actionsky.ushard.UshardStartup start @@ -713,7 +923,7 @@ maven-assembly-plugin - src/main/assembly/assembly-ushard-linux.xml + src/main/assembly/ushard/assembly-ushard-linux.xml @@ -726,22 +936,7 @@ - - org.codehaus.mojo - buildnumber-maven-plugin - 1.3 - - - validate - - create-timestamp - - - - - yyyyMMddHHmmss - - +