@Test public void read() { ConsumeLog consumeLog = new ConsumeLog(); consumeLog.setApp("app_test"); consumeLog.setBrokerId(1); consumeLog.setClientIp(new byte[16]); consumeLog.setBytesMessageId(new byte[16]); consumeLog.setConsumeTime(SystemClock.now()); System.out.println(ToStringBuilder.reflectionToString(consumeLog)); ByteBuffer write = ArchiveSerializer.write(consumeLog); int readLen = write.getInt(); System.out.println(readLen); ConsumeLog log = ArchiveSerializer.read(write); System.out.println(ToStringBuilder.reflectionToString(log)); }
public static ConsumeLog read(ByteBuffer buffer) { ConsumeLog log = new ConsumeLog(); byte[] byteMessageId = new byte[16]; buffer.get(byteMessageId); log.setBytesMessageId(byteMessageId); log.setBrokerId(buffer.getInt()); byte[] clientIp = new byte[16]; buffer.get(clientIp); log.setClientIp(clientIp); log.setConsumeTime(buffer.getLong()); int appLen = (int)buffer.getShort(); byte[] appBytes = new byte[appLen]; buffer.get(appBytes); log.setApp(new String(appBytes, Charset.forName("utf-8"))); return log; }
ArchiveSerializer { public static ConsumeLog read(ByteBuffer buffer) { ConsumeLog log = new ConsumeLog(); byte[] byteMessageId = new byte[16]; buffer.get(byteMessageId); log.setBytesMessageId(byteMessageId); log.setBrokerId(buffer.getInt()); byte[] clientIp = new byte[16]; buffer.get(clientIp); log.setClientIp(clientIp); log.setConsumeTime(buffer.getLong()); int appLen = (int)buffer.getShort(); byte[] appBytes = new byte[appLen]; buffer.get(appBytes); log.setApp(new String(appBytes, Charset.forName("utf-8"))); return log; } }
ArchiveSerializer { public static ConsumeLog read(ByteBuffer buffer) { ConsumeLog log = new ConsumeLog(); byte[] byteMessageId = new byte[16]; buffer.get(byteMessageId); log.setBytesMessageId(byteMessageId); log.setBrokerId(buffer.getInt()); byte[] clientIp = new byte[16]; buffer.get(clientIp); log.setClientIp(clientIp); log.setConsumeTime(buffer.getLong()); int appLen = (int)buffer.getShort(); byte[] appBytes = new byte[appLen]; buffer.get(appBytes); log.setApp(new String(appBytes, Charset.forName("utf-8"))); return log; }  }
ArchiveSerializer { public static ConsumeLog read(ByteBuffer buffer) { ConsumeLog log = new ConsumeLog(); byte[] byteMessageId = new byte[16]; buffer.get(byteMessageId); log.setBytesMessageId(byteMessageId); log.setBrokerId(buffer.getInt()); byte[] clientIp = new byte[16]; buffer.get(clientIp); log.setClientIp(clientIp); log.setConsumeTime(buffer.getLong()); int appLen = (int)buffer.getShort(); byte[] appBytes = new byte[appLen]; buffer.get(appBytes); log.setApp(new String(appBytes, Charset.forName("utf-8"))); return log; }  static void release(ByteBuffer byteBuffer); static ByteBuffer write(ConsumeLog consumeLog); static ConsumeLog read(ByteBuffer buffer); }
ArchiveSerializer { public static ConsumeLog read(ByteBuffer buffer) { ConsumeLog log = new ConsumeLog(); byte[] byteMessageId = new byte[16]; buffer.get(byteMessageId); log.setBytesMessageId(byteMessageId); log.setBrokerId(buffer.getInt()); byte[] clientIp = new byte[16]; buffer.get(clientIp); log.setClientIp(clientIp); log.setConsumeTime(buffer.getLong()); int appLen = (int)buffer.getShort(); byte[] appBytes = new byte[appLen]; buffer.get(appBytes); log.setApp(new String(appBytes, Charset.forName("utf-8"))); return log; }  static void release(ByteBuffer byteBuffer); static ByteBuffer write(ConsumeLog consumeLog); static ConsumeLog read(ByteBuffer buffer);  }