Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
yanjunli authored Aug 29, 2017
2 parents b6d7ede + 21be699 commit 323812c
Show file tree
Hide file tree
Showing 34 changed files with 1,344 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public enum CurrPacketType {
/**
* 事务提交方式
*/
public AutoCommit autoCommit = AutoCommit.OFF;

public AutoCommit autoCommit = AutoCommit.ON;
/**
* 认证中的seed报文数据
*/
Expand Down Expand Up @@ -83,6 +83,7 @@ public void setCurBufOwner(boolean curBufOwner) {
*/
public void responseOKOrError(MySQLPacket pkg) throws IOException {
// proxyBuffer.changeOwner(true);
this.proxyBuffer.reset();
pkg.write(this.proxyBuffer);
proxyBuffer.flip();
proxyBuffer.readIndex = proxyBuffer.writeIndex;
Expand Down
7 changes: 5 additions & 2 deletions source/src/main/java/io/mycat/mycat2/ConfigLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public static List<SchemaBean> loadSheamBeans(String schemaBeanuri){

NamedNodeMap map=curRuleNode.getAttributes();
String name=getAttribute(map,"name",null);
String schemaType=getAttribute(map,"nopartion","true");
String schemaType=getAttribute(map,"type","0");
String balanceSelectIntrans = getAttribute(map, "balanceSelectIntrans", "false");
String defaultDB=getAttribute(map,"default-db",null);
String[] dnItems=defaultDB.split(":");
DNBean dnBean=new DNBean(dnItems[0].trim(),dnItems[1].trim());
Expand All @@ -76,7 +77,9 @@ public static List<SchemaBean> loadSheamBeans(String schemaBeanuri){
String tRule=getAttribute(attrs,"sharding-rule",null);
TableDefBean tbBean=new TableDefBean(tName,tType,tKey,tRule);
tableLst.add(tbBean);});
SchemaBean sBean=new SchemaBean(name,dnBean,("true".equalsIgnoreCase(schemaType)),tableLst);
SchemaBean sBean=new SchemaBean(name,dnBean,schemaType,
Boolean.valueOf(balanceSelectIntrans)
,tableLst);
LOGGER.debug("schema-bean: {}", sBean);
list.add(sBean);
}
Expand Down
44 changes: 44 additions & 0 deletions source/src/main/java/io/mycat/mycat2/MyCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package io.mycat.mycat2;

import java.io.IOException;

/**
* 处理 mysql 命令
* @author Administrator
*
*/
public interface MyCommand {

/**
* 收到后端应答
*
* @param session
* 后端MySQLSession
* @return
* @throws IOException
*/
public boolean onBackendResponse(MySQLSession session) throws IOException;

public boolean onBackendClosed(MySQLSession session, boolean normal) throws IOException;

public boolean onFrontWriteFinished(MycatSession session) throws IOException;

public boolean onBackendWriteFinished(MySQLSession session) throws IOException;

/**
* 直接应答请求报文,如果是直接应答的,则此方法调用一次就完成了,如果是靠后端响应后才应答,则至少会调用两次,
*
* @param session
* @return 是否完成了应答
*/
public boolean procssSQL(MycatSession session) throws IOException;

/**
* 清理资源,只清理自己产生的资源(如创建了Buffer,以及Session中放入了某些对象)
*
* @param socketClosed
* 是否因为Session关闭而清理资源,此时应该彻底清理
*/
public void clearResouces(boolean sessionCLosed);

}
12 changes: 12 additions & 0 deletions source/src/main/java/io/mycat/mycat2/MySQLCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.mycat.mycat2;

/**
* 负责处理SQL命令
*
* @author wuzhihui
*
* @param <T>
*/
public interface MySQLCommand extends MyCommand{

}
14 changes: 13 additions & 1 deletion source/src/main/java/io/mycat/mycat2/MySQLSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
*/
public class MySQLSession extends AbstractMySQLSession {
private String database;

/**
* 当前缓存的 mysqlSession 所属的mysql-replica 的名称。用于快速判断当前连接是否可以被复用
*/
private String currBackendCachedName;
/**
* 当前所从属的mycat sesssion
*/
Expand Down Expand Up @@ -60,8 +65,15 @@ public void setMycatSession(MycatSession mycatSession) {

@Override
protected void doTakeReadOwner() {
this.getMycatSession().takeOwner(SelectionKey.OP_READ);
this.getMycatSession().takeOwner(SelectionKey.OP_READ);
}

public String getCurrBackendCachedName() {
return currBackendCachedName;
}

public void setCurrBackendCachedName(String currBackendCachedName) {
this.currBackendCachedName = currBackendCachedName;
}

}
1 change: 0 additions & 1 deletion source/src/main/java/io/mycat/mycat2/MycatCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public static void main(String[] args) throws IOException {
ClusterNode.parseNodesInf(conf.getAllNodeInfs()));
runtime.setMyCLuster(cluster);
cluster.initCluster();

}

URL datasourceURL = ConfigLoader.class.getResource("/datasource.xml");
Expand Down
Loading

0 comments on commit 323812c

Please sign in to comment.