當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。