当前位置: 首页>>代码示例>>Java>>正文


Java ServerConnection.write方法代码示例

本文整理汇总了Java中com.alibaba.cobar.server.ServerConnection.write方法的典型用法代码示例。如果您正苦于以下问题:Java ServerConnection.write方法的具体用法?Java ServerConnection.write怎么用?Java ServerConnection.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.cobar.server.ServerConnection的用法示例。


在下文中一共展示了ServerConnection.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    ByteBuffer buffer = c.allocate();
    buffer = header.write(buffer, c);
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c);
    }
    buffer = eof.write(buffer, c);
    byte packetId = eof.packetId;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(FrontendConnection.getServerVersion().getBytes());
    row.packetId = ++packetId;
    buffer = row.write(buffer, c);
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);
    c.write(buffer);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:18,代码来源:SelectVersion.java

示例2: oneSetResponse

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
private static void oneSetResponse(String stmt, ServerConnection c, int rs) {
    if ((rs & 0xff) == CHARACTER_SET_CLIENT) {
        /* 忽略client属性设置 */
        c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
    } else {
        String charset = stmt.substring(rs >>> 8).trim();
        if (charset.endsWith(";")) {
            /* 结尾为 ; 标识符 */
            charset = charset.substring(0, charset.length() - 1);
        }

        if (charset.startsWith("'") || charset.startsWith("`")) {
            /* 与mysql保持一致,引号里的字符集不做trim操作 */
            charset = charset.substring(1, charset.length() - 1);
        }

        // 设置字符集
        setCharset(charset, c);
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:21,代码来源:CharacterSet.java

示例3: setCharset

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
private static void setCharset(String charset, ServerConnection c) {
    if ("null".equalsIgnoreCase(charset)) {
        /* 忽略字符集为null的属性设置 */
        c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
    } else if (c.setCharset(charset)) {
        c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
    } else {
        try {
            if (c.setCharsetIndex(Integer.parseInt(charset))) {
                c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
            } else {
                c.writeErrMessage(ErrorCode.ER_UNKNOWN_CHARACTER_SET, "Unknown charset :" + charset);
            }
        } catch (RuntimeException e) {
            c.writeErrMessage(ErrorCode.ER_UNKNOWN_CHARACTER_SET, "Unknown charset :" + charset);
        }
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:19,代码来源:CharacterSet.java

示例4: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    ByteBuffer buffer = c.allocate();
    buffer = header.write(buffer, c);
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c);
    }
    buffer = eof.write(buffer, c);
    byte packetId = eof.packetId;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(getUser(c));
    row.packetId = ++packetId;
    buffer = row.write(buffer, c);
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);
    c.write(buffer);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:18,代码来源:SelectUser.java

示例5: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    ByteBuffer buffer = c.allocate();
    buffer = header.write(buffer, c);
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c);
    }
    buffer = eof.write(buffer, c);
    byte packetId = eof.packetId;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(StringUtil.encode(c.getSchema(), c.getCharset()));
    row.packetId = ++packetId;
    buffer = row.write(buffer, c);
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);
    c.write(buffer);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:18,代码来源:SelectDatabase.java

示例6: okResponse

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
@Override
public void okResponse(byte[] ok, MySQLConnection conn) {
    conn.setRunning(false);
    if (decrementCountBy(1)) {
        if (isFail.get() || session.closed()) {
            notifyError((byte) 1);
        } else {
            session.releaseConnections();
            if (okPacket == null) {
                ServerConnection source = session.getSource();
                source.write(ok);
            } else {
                okPacket.write(session.getSource());
            }
        }
    }
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:18,代码来源:CommitNodeHandler.java

示例7: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    if (CobarServer.getInstance().isOnline()) {
        ByteBuffer buffer = c.allocate();
        buffer = header.write(buffer, c);
        for (FieldPacket field : fields) {
            buffer = field.write(buffer, c);
        }
        buffer = eof.write(buffer, c);
        byte packetId = eof.packetId;
        RowDataPacket row = new RowDataPacket(FIELD_COUNT);
        row.add(getUser(c));
        row.packetId = ++packetId;
        buffer = row.write(buffer, c);
        EOFPacket lastEof = new EOFPacket();
        lastEof.packetId = ++packetId;
        buffer = lastEof.write(buffer, c);
        c.write(buffer);
    } else {
        error.write(c);
    }
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:22,代码来源:SelectUser.java

示例8: 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);
        }
    }
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:23,代码来源:MultiNodeExecutor.java

示例9: 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);
    }
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:23,代码来源:SingleNodeHandler.java

示例10: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    if (CobarServer.getInstance().isOnline()) {
        ByteBuffer buffer = c.allocate();
        buffer = header.write(buffer, c);
        for (FieldPacket field : fields) {
            buffer = field.write(buffer, c);
        }
        buffer = eof.write(buffer, c);
        buffer = status.write(buffer, c);
        buffer = lastEof.write(buffer, c);
        c.write(buffer);
    } else {
        error.write(c);
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:16,代码来源:ShowCobarStatus.java

示例11: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(String stmt, ServerConnection c, int rs) {
    String sqlMode = stmt.substring(rs >>> 8).trim();
    if (sqlMode.startsWith("'") || sqlMode.startsWith("`") || sqlMode.startsWith("\"")) {
        sqlMode = sqlMode.substring(1, sqlMode.length() - 1);
    }
    
    c.setSqlMode(sqlMode);
    c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:10,代码来源:SqlMode.java

示例12: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c) {
    ByteBuffer buffer = c.allocate();

    // write header
    buffer = header.write(buffer, c);

    // write fields
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c);
    }

    // write eof
    buffer = eof.write(buffer, c);

    // write rows
    byte packetId = eof.packetId;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(VERSION_COMMENT);
    row.packetId = ++packetId;
    buffer = row.write(buffer, c);

    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);

    // post write
    c.write(buffer);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:30,代码来源:SelectVersionComment.java

示例13: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c, String stmt, int aliasIndex) {
    String alias = ParseUtil.parseAlias(stmt, aliasIndex);
    if (alias == null) {
        alias = ORG_NAME;
    }

    ByteBuffer buffer = c.allocate();

    // write header
    buffer = header.write(buffer, c);

    // write fields
    byte packetId = header.packetId;
    FieldPacket field = PacketUtil.getField(alias, ORG_NAME, Fields.FIELD_TYPE_LONGLONG);
    field.packetId = ++packetId;
    buffer = field.write(buffer, c);

    // write eof
    EOFPacket eof = new EOFPacket();
    eof.packetId = ++packetId;
    buffer = eof.write(buffer, c);

    // write rows
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(LongUtil.toBytes(c.getLastInsertId()));
    row.packetId = ++packetId;
    buffer = row.write(buffer, c);

    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);

    // post write
    c.write(buffer);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:37,代码来源:SelectLastInsertId.java

示例14: response

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void response(ServerConnection c, String stmt, int aliasIndex, final String orgName) {
    String alias = ParseUtil.parseAlias(stmt, aliasIndex);
    if (alias == null) {
        alias = orgName;
    }

    ByteBuffer buffer = c.allocate();

    // write header
    buffer = header.write(buffer, c);

    // write fields
    byte packetId = header.packetId;
    FieldPacket field = PacketUtil.getField(alias, orgName, Fields.FIELD_TYPE_LONGLONG);
    field.packetId = ++packetId;
    buffer = field.write(buffer, c);

    // write eof
    EOFPacket eof = new EOFPacket();
    eof.packetId = ++packetId;
    buffer = eof.write(buffer, c);

    // write rows
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(LongUtil.toBytes(c.getLastInsertId()));
    row.packetId = ++packetId;
    buffer = row.write(buffer, c);

    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);

    // post write
    c.write(buffer);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:37,代码来源:SelectIdentity.java

示例15: execute

import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void execute(ServerConnection c) {
    ByteBuffer buffer = c.allocate();

    // write header
    buffer = header.write(buffer, c);

    // write fields
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c);
    }

    // write eof
    buffer = eof.write(buffer, c);

    // write rows
    byte packetId = eof.packetId;
    String charset = c.getCharset();
    for (NIOProcessor p : CobarServer.getInstance().getProcessors()) {
        for (FrontendConnection fc : p.getFrontends().values()) {

            if (fc != null) {

                if (c.getUser().equals(fc.getUser())) {
                    RowDataPacket row = getRow(fc, charset);
                    row.packetId = ++packetId;
                    buffer = row.write(buffer, c);
                }

            }
        }
    }

    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);

    // write buffer
    c.write(buffer);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:41,代码来源:ShowConnection.java


注:本文中的com.alibaba.cobar.server.ServerConnection.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。