当前位置: 首页>>代码示例>>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;未经允许,请勿转载。