use of com.alibaba.cobar.net.buffer.BufferQueue in project cobar by alibaba.
the class FrontendConnectionFactory method make.
public FrontendConnection make(SocketChannel channel) throws IOException {
Socket socket = channel.socket();
socket.setReceiveBufferSize(socketRecvBuffer);
socket.setSendBufferSize(socketSendBuffer);
socket.setTcpNoDelay(true);
socket.setKeepAlive(true);
FrontendConnection c = getConnection(channel);
c.setPacketHeaderSize(packetHeaderSize);
c.setMaxPacketSize(maxPacketSize);
c.setWriteQueue(new BufferQueue(writeQueueCapcity));
c.setIdleTimeout(idleTimeout);
c.setCharset(charset);
return c;
}
use of com.alibaba.cobar.net.buffer.BufferQueue in project cobar by alibaba.
the class ShowConnection method getRow.
private static RowDataPacket getRow(FrontendConnection c, String charset) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(c.getProcessor().getName().getBytes());
row.add(LongUtil.toBytes(c.getId()));
row.add(StringUtil.encode(c.getHost(), charset));
row.add(IntegerUtil.toBytes(c.getPort()));
row.add(IntegerUtil.toBytes(c.getLocalPort()));
row.add(StringUtil.encode(c.getSchema(), charset));
row.add(StringUtil.encode(c.getCharset(), charset));
row.add(LongUtil.toBytes(c.getNetInBytes()));
row.add(LongUtil.toBytes(c.getNetOutBytes()));
row.add(LongUtil.toBytes((TimeUtil.currentTimeMillis() - c.getStartupTime()) / 1000L));
row.add(IntegerUtil.toBytes(c.getWriteAttempts()));
ByteBuffer bb = c.getReadBuffer();
row.add(IntegerUtil.toBytes(bb == null ? 0 : bb.capacity()));
BufferQueue bq = c.getWriteQueue();
row.add(IntegerUtil.toBytes(bq == null ? 0 : bq.size()));
if (c instanceof ServerConnection) {
ServerConnection sc = (ServerConnection) c;
row.add(IntegerUtil.toBytes(sc.getSession().getTargetCount()));
} else {
row.add(null);
}
return row;
}
use of com.alibaba.cobar.net.buffer.BufferQueue in project cobar by alibaba.
the class BackendConnectionFactory method postConnect.
protected void postConnect(BackendConnection c, NIOConnector connector) {
c.setPacketHeaderSize(packetHeaderSize);
c.setMaxPacketSize(maxPacketSize);
c.setWriteQueue(new BufferQueue(writeQueueCapcity));
c.setIdleTimeout(idleTimeout);
c.setConnector(connector);
connector.postConnect(c);
}
Aggregations