本文整理汇总了Java中com.alibaba.cobar.server.ServerConnection.isAutocommit方法的典型用法代码示例。如果您正苦于以下问题:Java ServerConnection.isAutocommit方法的具体用法?Java ServerConnection.isAutocommit怎么用?Java ServerConnection.isAutocommit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.cobar.server.ServerConnection
的用法示例。
在下文中一共展示了ServerConnection.isAutocommit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: okResponse
import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
@Override
public void okResponse(byte[] data, MySQLConnection conn) {
boolean executeResponse = false;
try {
executeResponse = conn.syncAndExcute();
} catch (UnsupportedEncodingException e) {
executeException(conn);
}
if (executeResponse) {
conn.setRunning(false);
ServerConnection source = session.getSource();
if (source.isAutocommit()) {
session.clearConnections();
}
endRunning();
OkPacket ok = new OkPacket();
ok.read(data);
source.setLastInsertId(ok.insertId);
buffer = source.writeToBuffer(data, buffer);
source.write(buffer);
}
}
示例2: handleSuccessEOF
import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
/**
* @throws nothing never throws any exception
*/
private void handleSuccessEOF(BlockingSession ss, BinaryPacket bin) {
if (decrementCountAndIsZero()) {
if (isFail.get()) {
notifyFailure(ss);
return;
}
try {
ServerConnection source = ss.getSource();
if (source.isAutocommit()) {
ss.release();
}
bin.packetId = ++packetId;// LAST_EOF
source.write(bin.write(buffer, source));
} catch (Exception e) {
LOGGER.warn("exception happens in success notification: " + ss.getSource(), e);
}
}
}
示例3: rowEofResponse
import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
@Override
public void rowEofResponse(byte[] eof, MySQLConnection conn) {
ServerConnection source = session.getSource();
conn.setRunning(false);
conn.recordSql(source.getHost(), source.getSchema(), route.getStatement());
if (source.isAutocommit()) {
session.clearConnections();
}
endRunning();
buffer = source.writeToBuffer(eof, buffer);
source.write(buffer);
}
示例4: handleSuccessOK
import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
/**
* @throws nothing never throws any exception
*/
private void handleSuccessOK(BlockingSession ss, RouteResultsetNode rrn, boolean autocommit, OkPacket ok) {
if (decrementCountAndIsZero()) {
if (isFail.get()) {
notifyFailure(ss);
return;
}
try {
ServerConnection source = ss.getSource();
ok.packetId = ++packetId;// OK_PACKET
ok.affectedRows = affectedRows;
if (insertId > 0) {
ok.insertId = insertId;
source.setLastInsertId(insertId);
}
if (source.isAutocommit()) {
if (!autocommit) { // 前端非事务模式,后端事务模式,则需要自动递交后端事务。
icExecutor.commit(ok, ss, ss.getTarget().size());
} else {
ss.release();
ok.write(source);
}
} else {
ok.write(source);
}
source.recycle(buffer);
} catch (Exception e) {
LOGGER.warn("exception happens in success notification: " + ss.getSource(), e);
}
}
}
示例5: handle
import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void handle(String stmt, ServerConnection c, int offset) {
int rs = ServerParseSet.parse(stmt, offset);
switch (rs & 0xff) {
case AUTOCOMMIT_ON:
if (!c.isAutocommit()) {
c.setAutocommit(true);
}
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
case AUTOCOMMIT_OFF: {
if (c.isAutocommit()) {
c.setAutocommit(false);
}
c.write(c.writeToBuffer(AC_OFF, c.allocate()));
break;
}
case TX_READ_UNCOMMITTED: {
c.setTxIsolation(Isolations.READ_UNCOMMITTED.getCode());
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case TX_READ_COMMITTED: {
c.setTxIsolation(Isolations.READ_COMMITTED.getCode());
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case TX_REPEATED_READ: {
c.setTxIsolation(Isolations.REPEATED_READ.getCode());
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case TX_SERIALIZABLE: {
c.setTxIsolation(Isolations.SERIALIZABLE.getCode());
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case NAMES:
String charset = stmt.substring(rs >>> 8).trim();
if (c.setCharset(charset)) {
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
} else {
c.writeErrMessage(ErrorCode.ER_UNKNOWN_CHARACTER_SET, "Unknown charset '" + charset + "'");
}
break;
case CHARACTER_SET_CLIENT:
case CHARACTER_SET_CONNECTION:
case CHARACTER_SET_RESULTS:
CharacterSet.response(stmt, c, rs);
break;
case SQL_MODE:
SqlMode.response(stmt, c, rs);
break;
case TX_POLICY_1:
c.setTrxPolicy(ITransactionPolicy.TDDL);
break;
// case TX_POLICY_2:
// c.setTrxPolicy(new Cobar());
// c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
// break;
case TX_POLICY_3:
c.setTrxPolicy(ITransactionPolicy.ALLOW_READ_CROSS_DB);
break;
// case TX_POLICY_4:
// c.setTrxPolicy(new Corona());
// c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
// break;
case TX_POLICY_5:
c.setTrxPolicy(ITransactionPolicy.FREE);
break;
case AT_VAR:
c.execute(stmt, ServerParse.SET);
default:
StringBuilder s = new StringBuilder();
logger.warn(s.append(stmt).append(" is not executed").toString());
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
}
}
示例6: handle
import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void handle(String stmt, ServerConnection c, int offset) {
int rs = ServerParseSet.parse(stmt, offset);
switch (rs & 0xff) {
case AUTOCOMMIT_ON:
if (c.isAutocommit()) {
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
} else {
c.commit();
c.setAutocommit(true);
}
break;
case AUTOCOMMIT_OFF: {
if (c.isAutocommit()) {
c.setAutocommit(false);
}
c.write(c.writeToBuffer(AC_OFF, c.allocate()));
break;
}
case TX_READ_UNCOMMITTED: {
c.setTxIsolation(Isolations.READ_UNCOMMITTED);
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case TX_READ_COMMITTED: {
c.setTxIsolation(Isolations.READ_COMMITTED);
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case TX_REPEATED_READ: {
c.setTxIsolation(Isolations.REPEATED_READ);
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case TX_SERIALIZABLE: {
c.setTxIsolation(Isolations.SERIALIZABLE);
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case NAMES:
String charset = stmt.substring(rs >>> 8).trim();
if (c.setCharset(charset)) {
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
} else {
c.writeErrMessage(ErrorCode.ER_UNKNOWN_CHARACTER_SET, "Unknown charset '" + charset + "'");
}
break;
case CHARACTER_SET_CLIENT:
case CHARACTER_SET_CONNECTION:
case CHARACTER_SET_RESULTS:
CharacterSet.response(stmt, c, rs);
break;
default:
StringBuilder s = new StringBuilder();
logger.warn(s.append(c).append(stmt).append(" is not executed").toString());
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
}
}
示例7: rowEofResponse
import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
@Override
public void rowEofResponse(byte[] eof, MySQLConnection conn) {
conn.setRunning(false);
ServerConnection source = session.getSource();
RouteResultsetNode node = null;
Object attachment = conn.getAttachment();
if (attachment instanceof RouteResultsetNode) {
node = (RouteResultsetNode) attachment;
conn.recordSql(source.getHost(), source.getSchema(), node.getStatement());
} else {
LOGGER.warn(new StringBuilder().append("back-end conn: ")
.append(conn)
.append(" has wrong attachment: ")
.append(attachment)
.append(", for front-end conn: ")
.append(source));
}
if (source.isAutocommit()) {
if (node != null) {
conn = session.removeTarget(node);
if (conn != null) {
if (isFail.get() || session.closed()) {
conn.quit();
} else {
conn.release();
}
}
}
}
if (decrementCountBy(1)) {
if (isFail.get()) {
notifyError();
recycleResources();
return;
}
try {
if (source.isAutocommit()) {
session.releaseConnections();
}
eof[3] = ++packetId;
source.write(source.writeToBuffer(eof, buffer));
} catch (Exception e) {
LOGGER.warn("exception happens in success notification: " + session.getSource(), e);
}
}
}
示例8: handleRowData
import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
/**
* 处理RowData数据
*/
private void handleRowData(final RouteResultsetNode rrn, Channel c, BlockingSession ss) throws IOException {
final ServerConnection source = ss.getSource();
BinaryPacket bin = null;
int size = 0;
for (;;) {
bin = ((MySQLChannel) c).receive();
switch (bin.data[0]) {
case ErrorPacket.FIELD_COUNT:
c.setRunning(false);
handleFailure(ss, rrn, new BinaryErrInfo(((MySQLChannel) c), bin, source, rrn));
return;
case EOFPacket.FIELD_COUNT:
c.setRunning(false);
if (source.isAutocommit()) {
c = ss.getTarget().remove(rrn);
if (c != null) {
if (isFail.get() || source.isClosed()) {
/**
* this {@link Channel} might be closed by other
* thread in this condition, so that do not release
* this channel
*/
c.close();
} else {
c.release();
}
}
}
handleSuccessEOF(ss, bin);
return;
default:
bin.packetId = ++packetId;// ROWS
buffer = bin.write(buffer, source);
size += bin.packetLength;
if (size > RECEIVE_CHUNK_SIZE) {
handleNext(rrn, c, ss);
return;
}
}
}
}