mirror of
https://github.com/actiontech/dble.git
synced 2026-01-07 05:10:20 -06:00
#117 1.change unnecessary mycat to server2.other can repalce to ushard
This commit is contained in:
10
pom.xml
10
pom.xml
@@ -268,9 +268,9 @@
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<excludes>
|
||||
<exclude>**/.svn/**</exclude>
|
||||
</excludes>
|
||||
<includes>
|
||||
<include>*.dtd</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${basedir}</directory>
|
||||
@@ -426,6 +426,10 @@
|
||||
<replacement>
|
||||
<token>@annotation-name@</token>
|
||||
<value>mycat:</value>
|
||||
<replacement>
|
||||
<token>@root_prefix@</token>
|
||||
<value>ushard</value>
|
||||
</replacement>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -29,11 +29,11 @@ public class XARecoverCallback implements SQLQueryResultListener<SQLQueryResult<
|
||||
}
|
||||
public void onResult(SQLQueryResult<Map<String, String>> 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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#";
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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),
|
||||
|
||||
/**
|
||||
* 在当前在线的节点
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 {
|
||||
/**
|
||||
* 配制的逻辑表信息
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -22,6 +22,7 @@ import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import io.mycat.config.Versions;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -114,7 +115,7 @@ public class XmlProcessBase {
|
||||
|
||||
if (null != name) {
|
||||
marshaller.setProperty("com.sun.xml.internal.bind.xmlHeaders",
|
||||
String.format("<!DOCTYPE mycat:%1$s SYSTEM \"%1$s.dtd\">", name));
|
||||
String.format("<!DOCTYPE "+ Versions.ROOT_PREFIX+":%1$s SYSTEM \"%1$s.dtd\">", name));
|
||||
}
|
||||
|
||||
Path path = Paths.get(inputPath);
|
||||
@@ -149,7 +150,7 @@ public class XmlProcessBase {
|
||||
|
||||
if (null != name) {
|
||||
marshaller.setProperty("com.sun.xml.internal.bind.xmlHeaders",
|
||||
String.format("<!DOCTYPE mycat:%1$s SYSTEM \"%1$s.dtd\">", name));
|
||||
String.format("<!DOCTYPE "+Versions.ROOT_PREFIX+":%1$s SYSTEM \"%1$s.dtd\">", name));
|
||||
}
|
||||
|
||||
if (null != map && !map.isEmpty()) {
|
||||
|
||||
@@ -208,13 +208,4 @@ public final class FirewallConfig {
|
||||
}
|
||||
}
|
||||
}
|
||||
// public static void main(String[] args) throws Exception {
|
||||
// List<UserConfig> userConfigs = new ArrayList<UserConfig>();
|
||||
// UserConfig user = new UserConfig();
|
||||
// user.setName("mycat");
|
||||
// userConfigs.add(user);
|
||||
// updateToFile("127.0.0.1",userConfigs);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
@@ -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
|
||||
+ "]";
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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"};
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -91,8 +91,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 +103,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.
|
||||
*/
|
||||
@@ -139,7 +139,7 @@ public void releaseExecutionMemory(long numBytes, long taskAttemptId, MemoryMode
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<File> createLocalDirs(MycatPropertyConf conf) {
|
||||
|
||||
String rootDirs = conf.getString("mycat.local.dirs","datanode");
|
||||
String rootDirs = conf.getString("server.local.dirs","datanode");
|
||||
|
||||
String rdir[] = rootDirs.split(",");
|
||||
List<File> dirs = new ArrayList<File>();
|
||||
|
||||
@@ -67,7 +67,7 @@ public final class UnsafeExternalRowSorter {
|
||||
myCatMemory.getSerializerManager(),
|
||||
recordComparator,
|
||||
prefixComparator,
|
||||
myCatMemory.getConf().getSizeAsBytes("mycat.pointer.array.len","16K"),
|
||||
myCatMemory.getConf().getSizeAsBytes("server.pointer.array.len","16K"),
|
||||
pageSizeBytes,
|
||||
canUseRadixSort,
|
||||
enableSort);
|
||||
|
||||
@@ -122,7 +122,7 @@ public final class UnsafeExternalSorter extends MemoryConsumer {
|
||||
|
||||
if(MycatServer.getInstance().getMyCatMemory() != null){
|
||||
this.fileBufferSizeBytes = (int) MycatServer.getInstance().
|
||||
getMyCatMemory().getConf().getSizeAsBytes("mycat.merge.file.buffer", "32k");
|
||||
getMyCatMemory().getConf().getSizeAsBytes("server.merge.file.buffer", "32k");
|
||||
}else{
|
||||
this.fileBufferSizeBytes = 32*1024;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class HeartbeatPacket extends MySQLPacket {
|
||||
|
||||
@Override
|
||||
protected String getPacketInfo() {
|
||||
return "Mycat Heartbeat Packet";
|
||||
return "Heartbeat Packet";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -33,7 +33,7 @@ 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;
|
||||
|
||||
@@ -29,8 +29,8 @@ 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;
|
||||
|
||||
@@ -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<byte[]> fields, List<FieldPacket> fieldPackets, byte[] eof,
|
||||
boolean isLeft, BackendConnection conn) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String, String> latestErrors = new ConcurrentHashMap<String, String>();
|
||||
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<byte[]> fields, List<FieldPacket> 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -194,13 +194,13 @@ public class DataNodeMergeManager extends AbstractDataNodeMerge {
|
||||
myCatMemory,
|
||||
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);
|
||||
@@ -234,7 +234,7 @@ public class DataNodeMergeManager extends AbstractDataNodeMerge {
|
||||
schema,
|
||||
prefixComparator,
|
||||
prefixComputer,
|
||||
conf.getSizeAsBytes("mycat.buffer.pageSize", "1m"),
|
||||
conf.getSizeAsBytes("server.buffer.pageSize", "1m"),
|
||||
false,/**是否使用基数排序*/
|
||||
false/**不排序*/);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class UnsafeRowGrouper {
|
||||
groupKeySchema,
|
||||
dataNodeMemoryManager,
|
||||
2*1024,
|
||||
conf.getSizeAsBytes("mycat.buffer.pageSize", "1m"),
|
||||
conf.getSizeAsBytes("server.buffer.pageSize", "1m"),
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
76
ushard.xml
76
ushard.xml
@@ -232,12 +232,9 @@
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<excludes>
|
||||
<exclude>**/.svn/**</exclude>
|
||||
<exclude>rule_template.xml</exclude>
|
||||
<exclude>schema_template.xml</exclude>
|
||||
<exclude>server_template.xml</exclude>
|
||||
</excludes>
|
||||
<includes>
|
||||
<include>*.dtd</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<testResources>
|
||||
@@ -409,6 +406,23 @@
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>IncrSequenceMySQLHandler</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<file>${project.basedir}/src/main/java/io/mycat/route/sequence/handler/SequenceVal.java</file>
|
||||
<outputFile>${project.basedir}/src/main/java/io/mycat/route/sequence/handler/SequenceVal.java</outputFile>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>mycat_seq_nextval</token>
|
||||
<value>ushard_seq_nextval</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>init_zk_data</id>
|
||||
<phase>process-sources</phase>
|
||||
@@ -461,24 +475,28 @@
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>log4j2.xml</id>
|
||||
<id>dbseq.sql</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<file>${project.basedir}/src/main/resources/log4j2.xml</file>
|
||||
<outputFile>${project.basedir}/src/main/resources/log4j2.xml</outputFile>
|
||||
<file>${project.basedir}/src/main/resources/dbseq.sql</file>
|
||||
<outputFile>${project.basedir}/src/main/resources/dbseq.sql</outputFile>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>mycat</token>
|
||||
<value>ushard</value>
|
||||
</replacement>
|
||||
<replacement>
|
||||
<token>MYCAT</token>
|
||||
<value>USHARD</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>1log4j2.xml</id>
|
||||
<id>log4j2.xml</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
@@ -516,6 +534,40 @@
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>MycatServer.java</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<file>${project.basedir}/src/main/java/io/mycat/MycatServer.java</file>
|
||||
<outputFile>${project.basedir}/src/main/java/io/mycat/MycatServer.java</outputFile>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>MyCat_</token>
|
||||
<value>Ushard_</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>GlobalTableUtil.java</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<file>${project.basedir}/src/main/java/io/mycat/server/util/GlobalTableUtil.java</file>
|
||||
<outputFile>${project.basedir}/src/main/java/io/mycat/server/util/GlobalTableUtil.java</outputFile>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>_mycat_op_time</token>
|
||||
<value>_ushard_op_time</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>ShowServerLog.java</id>
|
||||
<phase>process-sources</phase>
|
||||
@@ -555,6 +607,10 @@
|
||||
<token>@annotation-name@</token>
|
||||
<value>ushard:</value>
|
||||
</replacement>
|
||||
<replacement>
|
||||
<token>@root_prefix@</token>
|
||||
<value>ushard</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
Reference in New Issue
Block a user