예제 #1
0
 public static void serialiseView(View view, ByteBuf buf) {
   buf.writeInt(view.id);
   buf.writeInt(view.members.size());
   for (Address addr : view.members) {
     AddressSerializer.INSTANCE.toBinary(addr, buf);
   }
 }
예제 #2
0
 public static byte[] serialiseAddress(Address addr) {
   ByteBuf buf = Unpooled.buffer();
   AddressSerializer.INSTANCE.toBinary(addr, buf);
   byte[] bytes = new byte[buf.readableBytes()];
   buf.readBytes(bytes);
   buf.release();
   return bytes;
 }
예제 #3
0
 public static View deserialiseView(ByteBuf buf) {
   int id = buf.readInt();
   int memsize = buf.readInt();
   ImmutableSortedSet.Builder<Address> addrs = ImmutableSortedSet.naturalOrder();
   for (int i = 0; i < memsize; i++) {
     Address addr = (Address) AddressSerializer.INSTANCE.fromBinary(buf, Optional.absent());
     addrs.add(addr);
   }
   return new View(addrs.build(), id);
 }
예제 #4
0
 public static Address deserialiseAddress(byte[] data) {
   ByteBuf buf = Unpooled.wrappedBuffer(data);
   Address addr = (Address) AddressSerializer.INSTANCE.fromBinary(buf, Optional.absent());
   buf.release();
   return addr;
 }