예제 #1
0
  public static void execute(ManagerConnection c) {
    ByteBuffer buffer = c.allocate();

    // write header
    buffer = header.write(buffer, c, true);

    // write fields
    for (FieldPacket field : fields) {
      buffer = field.write(buffer, c, true);
    }

    // write eof
    buffer = eof.write(buffer, c, true);

    // write rows
    byte packetId = eof.packetId;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(VERSION_COMMENT);
    row.packetId = ++packetId;
    buffer = row.write(buffer, c, true);

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

    // post write
    c.write(buffer);
  }
예제 #2
0
 public static final FieldPacket getField(String name, int type) {
   FieldPacket packet = new FieldPacket();
   packet.charsetIndex = CharsetUtil.getIndex(CODE_PAGE_1252);
   packet.name = encode(name, CODE_PAGE_1252);
   packet.type = (byte) type;
   return packet;
 }
예제 #3
0
 public static final FieldPacket getField(BinaryPacket src, String fieldName) {
   FieldPacket field = new FieldPacket();
   field.read(src);
   field.name = encode(fieldName, CODE_PAGE_1252);
   field.packetLength = field.calcPacketSize();
   return field;
 }
예제 #4
0
  public static void handle(String stmt, ManagerConnection c) {
    ByteBuffer buffer = c.allocate();

    // write header
    buffer = header.write(buffer, c, true);

    // write fields
    for (FieldPacket field : fields) {
      buffer = field.write(buffer, c, true);
    }

    // write eof
    buffer = eof.write(buffer, c, true);
    // write rows
    byte packetId = eof.packetId;
    String theStmt = stmt.toUpperCase().trim();
    PackageBufINf bufInf = null;
    if (theStmt.equals("FILE @@LIST")) {
      bufInf = listConfigFiles(c, buffer, packetId);
    } else if (theStmt.startsWith("FILE @@SHOW")) {
      int index = stmt.lastIndexOf(' ');
      String fileName = stmt.substring(index + 1);
      bufInf = showConfigFile(c, buffer, packetId, fileName);
    } else if (theStmt.startsWith(UPLOAD_CMD)) {
      int index = stmt.indexOf(' ', UPLOAD_CMD.length());
      int index2 = stmt.indexOf(' ', index + 1);
      if (index <= 0 || index2 <= 0 || index + 1 > stmt.length() || index2 + 1 > stmt.length()) {
        bufInf = showInfo(c, buffer, packetId, "Invald param ,usage  ");
      }
      String fileName = stmt.substring(index + 1, index2);
      String content = stmt.substring(index2 + 1).trim();
      bufInf = upLoadConfigFile(c, buffer, packetId, fileName, content);
    } else {

      bufInf = showInfo(c, buffer, packetId, "Invald command ");
    }

    packetId = bufInf.packetId;
    buffer = bufInf.buffer;

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

    // write buffer
    c.write(buffer);
  }
예제 #5
0
 public static void response(FrontSession session) {
   ByteBuf buffer = session.allocate(128, 1024);
   buffer = header.write(buffer);
   for (FieldPacket field : fields) {
     buffer = field.write(buffer);
   }
   buffer = eof.write(buffer);
   byte packetId = eof.packetId;
   RowDataPacket row = new RowDataPacket(FIELD_COUNT);
   row.add(LongUtil.toBytes(1));
   row.packetId = ++packetId;
   buffer = row.write(buffer);
   EOFPacket lastEof = new EOFPacket();
   lastEof.packetId = ++packetId;
   buffer = lastEof.write(buffer);
   session.write(buffer);
 }