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;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.packetId = ++packetId;
    row.add(LongUtil.toBytes(1));
    buffer = row.write(buffer, c);

    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);

    // post write
    c.write(buffer);
  }
Example #2
0
  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);
  }
Example #3
0
  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;
    Map<String, SchemaConfig> schemas = CobarServer.getInstance().getConfig().getSchemas();
    for (String name : new TreeSet<String>(schemas.keySet())) {
      RowDataPacket row = new RowDataPacket(FIELD_COUNT);
      row.add(StringUtil.encode(name, c.getCharset()));
      row.packetId = ++packetId;
      buffer = row.write(buffer, c);
    }

    // write lastEof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);

    // write buffer
    c.write(buffer);
  }
Example #4
0
 public static void handle(String stmt, ManagerConnection c, int offset) {
   switch (ManagerParseSelect.parse(stmt, offset)) {
     case VERSION_COMMENT:
       SelectVersionComment.execute(c);
       break;
     case SESSION_AUTO_INCREMENT:
       SelectSessionAutoIncrement.execute(c);
       break;
     default:
       c.writeErrMessage(ErrorCode.ER_YES, "Unsupported statement");
   }
 }
Example #5
0
 public static void execute(ManagerConnection c) {
   boolean status = false;
   if (status) {
     StringBuilder s = new StringBuilder();
     s.append(c).append("Rollback user success by manager");
     logger.warn(s.toString());
     OkPacket ok = new OkPacket();
     ok.packetId = 1;
     ok.affectedRows = 1;
     ok.serverStatus = 2;
     ok.message = "Rollback user success".getBytes();
     ok.write(c);
   } else {
     c.writeErrMessage(ErrorCode.ER_YES, "Unsupported statement");
   }
 }