本文整理汇总了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;
}
示例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();
}
}
});
}
};
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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);
}