コード例 #1
0
ファイル: EOFPacket.java プロジェクト: wwhwj1981720/cobar
 @Override
 public ByteBuffer write(ByteBuffer buffer, FrontendConnection c) {
   int size = calcPacketSize();
   buffer = c.checkWriteBuffer(buffer, c.getPacketHeaderSize() + size);
   BufferUtil.writeUB3(buffer, size);
   buffer.put(packetId);
   buffer.put(fieldCount);
   BufferUtil.writeUB2(buffer, warningCount);
   BufferUtil.writeUB2(buffer, status);
   return buffer;
 }
コード例 #2
0
ファイル: SimpleServer.java プロジェクト: Shacho/cat
  public void startup() throws IOException {
    SystemConfig system = CobarServer.getInstance().getConfig().getSystem();
    FrontendConnection.setServerVersion(VERSION);
    // start processors
    NIOProcessor[] processors = new NIOProcessor[system.getProcessors()];

    for (int i = 0; i < processors.length; i++) {
      processors[i] =
          new NIOProcessor(
              "Processor" + i, system.getProcessorHandler(), system.getProcessorExecutor());
      processors[i].startup();
    }

    // startup connector
    NIOConnector connector = new NIOConnector("BeeConnector");

    connector.setProcessors(processors);
    connector.start();

    // startup server
    SimpleServerConnectionFactory sf = new SimpleServerConnectionFactory();

    sf.setIdleTimeout(system.getIdleTimeout()); // one hour
    sf.setContainer(ContainerLoader.getDefaultContainer());

    NIOAcceptor server = new NIOAcceptor("BeeServer", m_port, sf);

    server.setProcessors(processors);
    server.start();

    Threads.forGroup("Bee").start(new ProcessorCheckTask(processors));

    LOGGER.info(String.format("BEE server started at %s", m_port));
  }
コード例 #3
0
 public void write(FrontendConnection c) {
   ByteBuffer buffer = c.allocate();
   BufferUtil.writeUB3(buffer, getPacketLength());
   buffer.put(packetId);
   buffer.put(protocolVersion);
   BufferUtil.writeWithNull(buffer, serverVersion);
   BufferUtil.writeUB4(buffer, threadId);
   BufferUtil.writeWithNull(buffer, seed);
   BufferUtil.writeUB2(buffer, serverCapabilities);
   buffer.put(serverCharsetIndex);
   BufferUtil.writeUB2(buffer, serverStatus);
   // buffer.position(buffer.position() + 13);
   for (int i = 1; i <= 13; i++) {
     buffer.put((byte) 0);
   }
   BufferUtil.writeWithNull(buffer, restOfScrambleBuff);
   c.write(buffer);
 }
コード例 #4
0
ファイル: SelectVersion.java プロジェクト: xieyuan1988/tddl5
 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);
 }