當前位置: 首頁>>代碼示例>>Java>>正文


Java ServerConnection.isClosed方法代碼示例

本文整理匯總了Java中com.alibaba.cobar.server.ServerConnection.isClosed方法的典型用法代碼示例。如果您正苦於以下問題:Java ServerConnection.isClosed方法的具體用法?Java ServerConnection.isClosed怎麽用?Java ServerConnection.isClosed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.alibaba.cobar.server.ServerConnection的用法示例。


在下文中一共展示了ServerConnection.isClosed方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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;
            }
        }
    }
}
 
開發者ID:alibaba,項目名稱:cobar,代碼行數:45,代碼來源:MultiNodeExecutor.java

示例2: rollback

import com.alibaba.cobar.server.ServerConnection; //導入方法依賴的package包/類
/**
 * 事務回滾
 */
public void rollback(final BlockingSession session) {
    final ServerConnection source = session.getSource();
    final ConcurrentMap<RouteResultsetNode, Channel> target = session.getTarget();
    final int initNodeCount = target.size();
    if (initNodeCount <= 0) {
        ByteBuffer buffer = source.allocate();
        source.write(source.writeToBuffer(OkPacket.OK, buffer));
        return;
    }

    // 初始化
    final ReentrantLock lock = this.lock;
    lock.lock();
    try {
        this.isFail.set(false);
        this.nodeCount = initNodeCount;
    } finally {
        lock.unlock();
    }

    if (source.isClosed()) {
        decrementCountToZero();
        return;
    }

    // 執行
    Executor committer = source.getProcessor().getCommitter();

    int started = 0;
    for (RouteResultsetNode rrn : target.keySet()) {
        final MySQLChannel mc = (MySQLChannel) target.get(rrn);
        if (mc != null) {
            mc.setRunning(true);
            committer.execute(new Runnable() {
                @Override
                public void run() {
                    _rollback(mc, session);
                }
            });
            ++started;
        }
    }

    if (started < initNodeCount) {
        decrementCountBy(initNodeCount - started);
    }
}
 
開發者ID:alibaba,項目名稱:cobar,代碼行數:51,代碼來源:RollbackExecutor.java


注:本文中的com.alibaba.cobar.server.ServerConnection.isClosed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。