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


Java NIOProcessor类代码示例

本文整理汇总了Java中com.alibaba.cobar.net.NIOProcessor的典型用法代码示例。如果您正苦于以下问题:Java NIOProcessor类的具体用法?Java NIOProcessor怎么用?Java NIOProcessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getList

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的package包/类
private static List<FrontendConnection> getList(String stmt, int offset, ManagerConnection mc) {
    String ids = stmt.substring(offset).trim();
    if (ids.length() > 0) {
        String[] idList = StringUtil.split(ids, ',', true);
        List<FrontendConnection> fcList = new ArrayList<FrontendConnection>(idList.length);
        NIOProcessor[] processors = CobarServer.getInstance().getProcessors();
        for (String id : idList) {
            long value = 0;
            try {
                value = Long.parseLong(id);
            } catch (NumberFormatException e) {
                continue;
            }
            FrontendConnection fc = null;
            for (NIOProcessor p : processors) {
                if ((fc = p.getFrontends().get(value)) != null) {
                    fcList.add(fc);
                    break;
                }
            }
        }
        return fcList;
    }
    return null;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:26,代码来源:KillConnection.java

示例2: processorCheck

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的package包/类
private TimerTask processorCheck() {
    return new TimerTask() {

        @Override
        public void run() {
            timerExecutor.execute(new Runnable() {

                @Override
                public void run() {
                    for (NIOProcessor p : processors) {
                        p.check();
                    }
                }
            });
        }
    };
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:18,代码来源:CobarServer.java

示例3: getList

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的package包/类
private static List<FrontendConnection> getList(String stmt, int offset, ManagerConnection mc) {
    String ids = stmt.substring(offset).trim();
    if (ids.length() > 0) {
        String[] idList = SplitUtil.split(ids, ',', true);
        List<FrontendConnection> fcList = new ArrayList<FrontendConnection>(idList.length);
        NIOProcessor[] processors = CobarServer.getInstance().getProcessors();
        for (String id : idList) {
            long value = 0;
            try {
                value = Long.parseLong(id);
            } catch (NumberFormatException e) {
                continue;
            }
            FrontendConnection fc = null;
            for (NIOProcessor p : processors) {
                if ((fc = p.getFrontends().get(value)) != null) {
                    fcList.add(fc);
                    break;
                }
            }
        }
        return fcList;
    }
    return null;
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:26,代码来源:KillConnection.java

示例4: execute

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的package包/类
public static void execute(ManagerConnection 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;
    String charset = c.getCharset();
    for (NIOProcessor p : CobarServer.getInstance().getProcessors()) {
        for (BackendConnection bc : p.getBackends().values()) {
            if (bc != null) {
                RowDataPacket row = getRow(bc, charset);
                row.packetId = ++packetId;
                buffer = row.write(buffer, c);
            }
        }
    }
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);
    c.write(buffer);
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:24,代码来源:ShowBackend.java

示例5: execute

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的package包/类
public static void execute(ManagerConnection 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.isClosed()) {
                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,代码行数:36,代码来源:ShowConnectionSQL.java

示例6: getExecutors

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的package包/类
private static List<NameableExecutor> getExecutors() {
    List<NameableExecutor> list = new LinkedList<NameableExecutor>();
    CobarServer server = CobarServer.getInstance();
    list.add(server.getTimerExecutor());
    list.add(server.getManagerExecutor());
    list.add(server.getServerExectuor());
    for (NIOProcessor p : server.getProcessors()) {
        list.add(p.getHandler());
    }
    return list;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:12,代码来源:ShowThreadPool.java

示例7: execute

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的package包/类
public static void execute(ManagerConnection 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;
    for (NIOProcessor p : CobarServer.getInstance().getProcessors()) {
        RowDataPacket row = getRow(p, c.getCharset());
        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,代码行数:31,代码来源:ShowCommand.java

示例8: getRow

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的package包/类
private static RowDataPacket getRow(NIOProcessor processor, String charset) {
    CommandCount cc = processor.getCommands();
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(processor.getName().getBytes());
    row.add(LongUtil.toBytes(cc.initDBCount()));
    row.add(LongUtil.toBytes(cc.queryCount()));
    row.add(LongUtil.toBytes(cc.stmtPrepareCount()));
    row.add(LongUtil.toBytes(cc.stmtExecuteCount()));
    row.add(LongUtil.toBytes(cc.stmtCloseCount()));
    row.add(LongUtil.toBytes(cc.pingCount()));
    row.add(LongUtil.toBytes(cc.killCount()));
    row.add(LongUtil.toBytes(cc.quitCount()));
    row.add(LongUtil.toBytes(cc.otherCount()));
    return row;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:16,代码来源:ShowCommand.java

示例9: execute

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的package包/类
public static void execute(ManagerConnection 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) {

                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,代码行数:39,代码来源:ShowConnection.java

示例10: getRow

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的package包/类
private static RowDataPacket getRow(NIOProcessor processor, String charset) {
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(processor.getName().getBytes());
    row.add(null);
    row.add(null);
    row.add(null);
    row.add(null);
    return row;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:10,代码来源:ShowRouter.java

示例11: getRow

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的package包/类
private static RowDataPacket getRow(NIOProcessor processor, String charset) {
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(processor.getName().getBytes());
    row.add(LongUtil.toBytes(processor.getNetInBytes()));
    row.add(LongUtil.toBytes(processor.getNetOutBytes()));
    row.add(LongUtil.toBytes(processor.getReactCount()));
    row.add(IntegerUtil.toBytes(processor.getRegisterQueueSize()));
    row.add(IntegerUtil.toBytes(processor.getWriteQueueSize()));
    row.add(IntegerUtil.toBytes(processor.getBufferPool().size()));
    row.add(IntegerUtil.toBytes(processor.getBufferPool().capacity()));
    row.add(IntegerUtil.toBytes(processor.getFrontends().size()));
    row.add(IntegerUtil.toBytes(processor.getBackends().size()));
    return row;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:15,代码来源:ShowProcessor.java

示例12: handle

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的package包/类
public static void handle(String stmt, int offset, final ManagerConnection c) {
    String id = stmt.substring(offset).trim();
    if (StringUtil.isEmpty(id)) {
        c.writeErrMessage(ErrorCode.ER_NO_SUCH_THREAD, "NULL connection id");
    } else {
        // get value
        long value = 0;
        try {
            value = Long.parseLong(id);
        } catch (NumberFormatException e) {
            c.writeErrMessage(ErrorCode.ER_NO_SUCH_THREAD, "Invalid connection id:" + id);
            return;
        }

        // get the connection and kill query
        FrontendConnection fc = null;
        NIOProcessor[] processors = CobarServer.getInstance().getProcessors();
        for (NIOProcessor p : processors) {
            if ((fc = p.getFrontends().get(value)) != null) {
                break;
            }
        }
        if (fc != null && TStringUtil.equals(c.getUser(), fc.getUser())) {

            if (fc instanceof ServerConnection) {
                ((ServerConnection) fc).cancel(c);
            } else {
                c.writeErrMessage(ErrorCode.ER_UNKNOWN_COM_ERROR,
                    "Unknown command, Query to kill is not ServerConnection, but is " + fc.getClass().getName());
            }
        } else {
            c.writeErrMessage(ErrorCode.ER_NO_SUCH_THREAD, "Unknown connection id:" + id);
        }
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:36,代码来源:KillQueryHandler.java

示例13: execute

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的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

示例14: getExecutors

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的package包/类
private static List<NameableExecutor> getExecutors() {
    List<NameableExecutor> list = new LinkedList<NameableExecutor>();
    CobarServer server = CobarServer.getInstance();
    list.add(server.getInitExecutor());
    list.add(server.getTimerExecutor());
    list.add(server.getManagerExecutor());
    for (NIOProcessor p : server.getProcessors()) {
        list.add(p.getHandler());
        list.add(p.getExecutor());
        list.add(p.getCommitter());
    }
    return list;
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:14,代码来源:ShowThreadPool.java

示例15: execute

import com.alibaba.cobar.net.NIOProcessor; //导入依赖的package包/类
public static void execute(ManagerConnection 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) {
                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:alibaba,项目名称:cobar,代码行数:36,代码来源:ShowConnection.java


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